fix(health): 审计修复 — alert 时序 + outbox 幂等性
1. CRITICAL: check_vital_signs_alert 移至 insert 之后执行, 防止数据未持久化就触发告警 2. CRITICAL: send_system 添加 business_id 幂等检查, 防止 outbox relay 重放导致重复消息通知 3. 修复 consent_service unused_mut 警告
This commit is contained in:
@@ -23,7 +23,7 @@ pub async fn list_consents(
|
||||
let limit = page_size.min(100);
|
||||
let offset = page.saturating_sub(1) * limit;
|
||||
|
||||
let mut query = consent::Entity::find()
|
||||
let query = consent::Entity::find()
|
||||
.filter(consent::Column::TenantId.eq(tenant_id))
|
||||
.filter(consent::Column::PatientId.eq(patient_id))
|
||||
.filter(consent::Column::DeletedAt.is_null());
|
||||
|
||||
@@ -86,7 +86,7 @@ pub async fn create_vital_signs(
|
||||
.ok_or(HealthError::PatientNotFound)?;
|
||||
|
||||
let now = Utc::now();
|
||||
check_vital_signs_alert(state, tenant_id, patient_id, operator_id, req.clone()).await;
|
||||
let alert_req = req.clone();
|
||||
let active = vital_signs::ActiveModel {
|
||||
id: Set(Uuid::now_v7()),
|
||||
tenant_id: Set(tenant_id),
|
||||
@@ -112,11 +112,15 @@ pub async fn create_vital_signs(
|
||||
};
|
||||
let m = active.insert(&state.db).await?;
|
||||
|
||||
// 数据持久化成功后再触发危急值检测
|
||||
check_vital_signs_alert(state, tenant_id, patient_id, operator_id, alert_req).await;
|
||||
|
||||
audit_service::record(
|
||||
AuditLog::new(tenant_id, operator_id, "vital_signs.created", "vital_signs")
|
||||
.with_resource_id(m.id),
|
||||
&state.db,
|
||||
).await;
|
||||
)
|
||||
.await;
|
||||
|
||||
Ok(VitalSignsResp {
|
||||
id: m.id, patient_id: m.patient_id, record_date: m.record_date,
|
||||
|
||||
Reference in New Issue
Block a user