fix(dialysis): 添加患者存在性校验 + 质量验证汇总
- create_dialysis_record 中添加患者存在性校验,修复集成测试 test_dialysis_create_without_patient_returns_error - 添加质量验证汇总报告 (docs/qa/quality-verification-summary.md)
This commit is contained in:
@@ -70,10 +70,25 @@ pub async fn create_dialysis_record(
|
||||
operator_id: Option<Uuid>,
|
||||
req: CreateDialysisRecordReq,
|
||||
) -> DialysisResult<DialysisRecordResp> {
|
||||
// 患者存在性由数据库 FK 约束保证,不再显式查询 patient 表
|
||||
|
||||
validate_dialysis_type(&req.dialysis_type)?;
|
||||
|
||||
// 患者存在性校验
|
||||
let patient_sql = sea_orm::Statement::from_sql_and_values(
|
||||
sea_orm::DatabaseBackend::Postgres,
|
||||
"SELECT EXISTS(SELECT 1 FROM patients WHERE id = $1 AND tenant_id = $2 AND deleted_at IS NULL)",
|
||||
[req.patient_id.into(), tenant_id.into()],
|
||||
);
|
||||
if let Ok(row) = state.db.query_one(patient_sql).await {
|
||||
if let Some(r) = row {
|
||||
let exists: bool = r.try_get("", "exists").unwrap_or(false);
|
||||
if !exists {
|
||||
return Err(DialysisError::PatientNotFound);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Err(DialysisError::PatientNotFound);
|
||||
}
|
||||
|
||||
let kek = state.crypto.kek();
|
||||
|
||||
// PII 加密
|
||||
|
||||
Reference in New Issue
Block a user