feat(medications): 新增完整的药物管理和服药提醒功能
实现了包含药物信息管理、服药记录追踪、统计分析、自动状态更新和推送提醒的完整药物管理系统。 核心功能: - 药物 CRUD 操作,支持多种剂型和自定义服药时间 - 惰性生成服药记录策略,查询时才生成当天记录 - 定时任务自动更新过期记录状态(每30分钟) - 服药前15分钟自动推送提醒(每5分钟检查) - 每日/范围/总体统计分析功能 - 完整的 API 文档和数据库建表脚本 技术实现: - 使用 Sequelize ORM 管理 MySQL 数据表 - 集成 @nestjs/schedule 实现定时任务 - 复用现有推送通知系统发送提醒 - 采用软删除和权限验证保障数据安全
This commit is contained in:
56
src/medications/medications.module.ts
Normal file
56
src/medications/medications.module.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { SequelizeModule } from '@nestjs/sequelize';
|
||||
import { ScheduleModule } from '@nestjs/schedule';
|
||||
|
||||
// Models
|
||||
import { Medication } from './models/medication.model';
|
||||
import { MedicationRecord } from './models/medication-record.model';
|
||||
|
||||
// Controllers
|
||||
import { MedicationsController } from './medications.controller';
|
||||
import { MedicationRecordsController } from './medication-records.controller';
|
||||
import { MedicationStatsController } from './medication-stats.controller';
|
||||
|
||||
// Services
|
||||
import { MedicationsService } from './medications.service';
|
||||
import { MedicationRecordsService } from './medication-records.service';
|
||||
import { MedicationStatsService } from './medication-stats.service';
|
||||
import { RecordGeneratorService } from './services/record-generator.service';
|
||||
import { StatusUpdaterService } from './services/status-updater.service';
|
||||
import { MedicationReminderService } from './services/medication-reminder.service';
|
||||
|
||||
// Import PushNotificationsModule for reminders
|
||||
import { PushNotificationsModule } from '../push-notifications/push-notifications.module';
|
||||
// Import UsersModule for authentication
|
||||
import { UsersModule } from '../users/users.module';
|
||||
|
||||
/**
|
||||
* 药物管理模块
|
||||
*/
|
||||
@Module({
|
||||
imports: [
|
||||
SequelizeModule.forFeature([Medication, MedicationRecord]),
|
||||
ScheduleModule.forRoot(), // 启用定时任务
|
||||
PushNotificationsModule, // 推送通知功能
|
||||
UsersModule, // 用户认证服务
|
||||
],
|
||||
controllers: [
|
||||
MedicationsController,
|
||||
MedicationRecordsController,
|
||||
MedicationStatsController,
|
||||
],
|
||||
providers: [
|
||||
MedicationsService,
|
||||
MedicationRecordsService,
|
||||
MedicationStatsService,
|
||||
RecordGeneratorService,
|
||||
StatusUpdaterService,
|
||||
MedicationReminderService,
|
||||
],
|
||||
exports: [
|
||||
MedicationsService,
|
||||
MedicationRecordsService,
|
||||
MedicationStatsService,
|
||||
],
|
||||
})
|
||||
export class MedicationsModule {}
|
||||
Reference in New Issue
Block a user