- crypto.rs: AES-256-GCM 加密/解密 + HMAC-SHA256 索引 - create/update: id_number 加密存储, id_number_hash 索引 - list: 不返回 id_number, 手机号掩码 - detail: 解密后身份证掩码(前3后4), 手机号掩码 - 搜索: 改用 HMAC 精确匹配(不再模糊搜索加密列) - 迁移 m000048: 添加 patients.id_number_hash 列
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::DbError(err.to_string())
|
|
}
|
|
}
|
|
|
|
pub type HealthResult<T> = Result<T, HealthError>;
|