fix(dialysis): 添加患者存在性校验 + 质量验证汇总
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

- create_dialysis_record 中添加患者存在性校验,修复集成测试
  test_dialysis_create_without_patient_returns_error
- 添加质量验证汇总报告 (docs/qa/quality-verification-summary.md)
This commit is contained in:
iven
2026-05-05 10:35:37 +08:00
parent 15b5781dbb
commit 0f55d26076
2 changed files with 110 additions and 2 deletions

View File

@@ -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 加密