P1-3: medication_reminder 全栈实现
- migration 000096: 创建 medication_reminder 表(含患者关联/提醒时间/频率)
- entity + dto + service + handler: 完整 CRUD(乐观锁/软删除/审计日志)
- 路由注册: GET /patients/{id}/medication-reminders, POST/PUT/DELETE
- HealthError 新增 MedicationReminderNotFound
P2-4: 后台任务启动统一
- appointment_reminder 迁移到 HealthModule::on_startup()(启动时立即执行 + 周期循环)
- 删除 main.rs 中重复的 overdue_checker/points_expiration/appointment_reminder 调用
- 所有 Health 后台任务现由模块 on_startup 统一管理
P2-5: Web dead code 清理
- 删除 healthData.ts 中 getMiniTrend/getMiniToday(小程序专用端点,Web 无调用)
- 删除 patients.ts 中 getHealthSummary(标记 TODO 未使用)
152 lines
4.0 KiB
Rust
152 lines
4.0 KiB
Rust
use erp_core::error::AppError;
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum HealthError {
|
|
#[error("{0}")]
|
|
Validation(String),
|
|
|
|
#[error("患者不存在")]
|
|
PatientNotFound,
|
|
|
|
#[error("医护档案不存在")]
|
|
DoctorNotFound,
|
|
|
|
#[error("预约不存在")]
|
|
AppointmentNotFound,
|
|
|
|
#[error("排班不存在")]
|
|
ScheduleNotFound,
|
|
|
|
#[error("体征记录不存在")]
|
|
VitalSignsNotFound,
|
|
|
|
#[error("化验报告不存在")]
|
|
LabReportNotFound,
|
|
|
|
#[error("日常监测记录不存在")]
|
|
DailyMonitoringNotFound,
|
|
|
|
#[error("积分规则不存在")]
|
|
PointsRuleNotFound,
|
|
|
|
#[error("兑换商品不存在")]
|
|
PointsProductNotFound,
|
|
|
|
#[error("兑换订单不存在")]
|
|
PointsOrderNotFound,
|
|
|
|
#[error("线下活动不存在")]
|
|
OfflineEventNotFound,
|
|
|
|
#[error("健康档案不存在")]
|
|
HealthRecordNotFound,
|
|
|
|
#[error("家庭成员不存在")]
|
|
FamilyMemberNotFound,
|
|
|
|
#[error("标签不存在")]
|
|
TagNotFound,
|
|
|
|
#[error("排班已满,无法预约")]
|
|
ScheduleFull,
|
|
|
|
#[error("随访任务不存在")]
|
|
FollowUpTaskNotFound,
|
|
|
|
#[error("会话不存在")]
|
|
ConsultationNotFound,
|
|
|
|
#[error("文章不存在")]
|
|
ArticleNotFound,
|
|
|
|
#[error("危急值阈值不存在")]
|
|
ThresholdNotFound,
|
|
|
|
#[error("知情同意记录不存在")]
|
|
ConsentNotFound,
|
|
|
|
#[error("设备绑定不存在")]
|
|
DeviceNotFound,
|
|
|
|
#[error("告警规则不存在")]
|
|
AlertRuleNotFound,
|
|
|
|
#[error("告警记录不存在")]
|
|
AlertNotFound,
|
|
|
|
#[error("随访模板不存在")]
|
|
FollowUpTemplateNotFound,
|
|
|
|
#[error("危急值告警不存在")]
|
|
CriticalAlertNotFound,
|
|
|
|
#[error("药物提醒不存在")]
|
|
MedicationReminderNotFound,
|
|
|
|
#[error("状态转换无效: {0}")]
|
|
InvalidStatusTransition(String),
|
|
|
|
#[error("版本冲突: 数据已被其他操作修改,请刷新后重试")]
|
|
VersionMismatch,
|
|
|
|
#[error("数据库操作失败: {0}")]
|
|
DbError(String),
|
|
}
|
|
|
|
impl From<HealthError> for AppError {
|
|
fn from(err: HealthError) -> Self {
|
|
match err {
|
|
HealthError::Validation(s) => AppError::Validation(s),
|
|
HealthError::PatientNotFound
|
|
| HealthError::DoctorNotFound
|
|
| HealthError::AppointmentNotFound
|
|
| HealthError::ScheduleNotFound
|
|
| HealthError::VitalSignsNotFound
|
|
| HealthError::LabReportNotFound
|
|
| HealthError::HealthRecordNotFound
|
|
| HealthError::FamilyMemberNotFound
|
|
| HealthError::TagNotFound
|
|
| HealthError::FollowUpTaskNotFound
|
|
| HealthError::ConsultationNotFound
|
|
| HealthError::ArticleNotFound
|
|
| HealthError::PointsRuleNotFound
|
|
| HealthError::PointsProductNotFound
|
|
| HealthError::PointsOrderNotFound
|
|
| HealthError::OfflineEventNotFound
|
|
| HealthError::DailyMonitoringNotFound
|
|
| HealthError::ThresholdNotFound
|
|
| HealthError::ConsentNotFound
|
|
| HealthError::AlertRuleNotFound
|
|
| HealthError::DeviceNotFound
|
|
| HealthError::AlertNotFound
|
|
| HealthError::FollowUpTemplateNotFound
|
|
| HealthError::CriticalAlertNotFound
|
|
| HealthError::MedicationReminderNotFound => AppError::NotFound(err.to_string()),
|
|
HealthError::ScheduleFull => AppError::Validation(err.to_string()),
|
|
HealthError::InvalidStatusTransition(s) => AppError::Validation(s),
|
|
HealthError::VersionMismatch => AppError::VersionMismatch,
|
|
HealthError::DbError(_) => AppError::Internal(err.to_string()),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<sea_orm::DbErr> for HealthError {
|
|
fn from(err: sea_orm::DbErr) -> Self {
|
|
HealthError::DbError(err.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<AppError> for HealthError {
|
|
fn from(err: AppError) -> Self {
|
|
HealthError::Validation(err.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<String> for HealthError {
|
|
fn from(err: String) -> Self {
|
|
HealthError::Validation(err)
|
|
}
|
|
}
|
|
|
|
pub type HealthResult<T> = Result<T, HealthError>;
|