fix(health+dialysis): S2 smoke test 修复 — Entity 表名 + 透析状态转换
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

- 修复 6 个 Entity table_name 与迁移不匹配: shift, handoff_log,
  patient_assignment, blind_index, critical_alert, critical_alert_response
- 添加透析记录 draft→completed 状态转换 API (PUT /complete)
- 修复 family_proxy_service 告警状态过滤 (active→pending/acknowledged)
- dev.ps1 添加 RATE_LIMIT__FAIL_CLOSE=false 开发模式
- S2 透析日流程 smoke test 报告
This commit is contained in:
iven
2026-05-05 03:07:41 +08:00
parent 99dad17eac
commit 2acd9485c7
13 changed files with 150 additions and 8 deletions

View File

@@ -211,6 +211,43 @@ pub async fn update_dialysis_record(
Ok(to_resp(&state.crypto, m))
}
pub async fn complete_dialysis_record(
state: &DialysisState,
tenant_id: Uuid,
record_id: Uuid,
operator_id: Option<Uuid>,
expected_version: i32,
) -> DialysisResult<DialysisRecordResp> {
let model = dialysis_record::Entity::find()
.filter(dialysis_record::Column::Id.eq(record_id))
.filter(dialysis_record::Column::TenantId.eq(tenant_id))
.filter(dialysis_record::Column::DeletedAt.is_null())
.one(&state.db)
.await?
.ok_or(DialysisError::DialysisRecordNotFound)?;
let next_ver = check_version(expected_version, model.version)
.map_err(|_| DialysisError::VersionMismatch)?;
validate_dialysis_status_transition(&model.status, "completed")?;
let now = Utc::now();
let mut active: dialysis_record::ActiveModel = model.into();
active.status = Set("completed".to_string());
active.updated_at = Set(now);
active.updated_by = Set(operator_id);
active.version = Set(next_ver);
let m = active.update(&state.db).await?;
audit_service::record(
AuditLog::new(tenant_id, operator_id, "dialysis_record.completed", "dialysis_record")
.with_resource_id(m.id),
&state.db,
).await;
Ok(to_resp(&state.crypto, m))
}
pub async fn review_dialysis_record(
state: &DialysisState,
tenant_id: Uuid,