审计发现并修复的问题: HIGH: - H1: ConsultationDetail 使用 getSession(id) 替代错误的列表搜索 - H2: SessionResp 添加 version/updated_at 字段 - H3: 移除 FollowUpRecordList 调用不存在的导出端点 - H4: 新增 articles.ts 前端 API 模块 MEDIUM: - M1: article delete 添加乐观锁 (expected_version) - M2: 取消预约排班释放传播错误 (log::warn -> ?) - M3: FollowUpTaskList 日期格式 Dayjs -> string - M4: 补充 15 个缺失审计日志 LOW: - L1: 替换 follow_up_service 中的 .unwrap() - L2: PatientListItem 添加 version 字段 CRITICAL (新发现): - 权限未同步: 健康模块 14 个权限从未写入数据库,添加启动时自动同步 - migration 表名错误: patients -> patient - 编译错误: health_trend entity 未导入, ToPrimitive trait 未导入 - HealthError 缺少 From<AppError> 实现
94 lines
2.5 KiB
Rust
94 lines
2.5 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("健康档案不存在")]
|
|
HealthRecordNotFound,
|
|
|
|
#[error("家庭成员不存在")]
|
|
FamilyMemberNotFound,
|
|
|
|
#[error("标签不存在")]
|
|
TagNotFound,
|
|
|
|
#[error("排班已满,无法预约")]
|
|
ScheduleFull,
|
|
|
|
#[error("随访任务不存在")]
|
|
FollowUpTaskNotFound,
|
|
|
|
#[error("会话不存在")]
|
|
ConsultationNotFound,
|
|
|
|
#[error("文章不存在")]
|
|
ArticleNotFound,
|
|
|
|
#[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 => 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())
|
|
}
|
|
}
|
|
|
|
pub type HealthResult<T> = Result<T, HealthError>;
|