fix(health+ai+dialysis): 审计 P1 批次修复 — EventBus接入/盲索引去重/事件消费者补全
P1-2: erp-ai EventBus 接入 - handler 层 SSE 流完成/失败时发布 ai.analysis.completed/failed 事件 - build_sse_stream 新增 tenant_id 参数 P1-2: erp-dialysis EventBus 接入 - create_dialysis_record 审计后发布 dialysis.record.created 事件 P1-5: message.sent 消费者改进 - 从占位 tracing::info 升级为带 payload 详情的结构化日志 P1-7: 盲索引去重 - create_patient 中新增 id_number HMAC 去重检查(查 blind_indexes 表) - 患者创建成功后写入 blind_indexes 表(id_number + phone) - 防止同租户重复建档 P1-1: 事件消费者补全 - 新增 ai.analysis.completed 消费者(幂等处理 + 日志) - 新增 dialysis.record.created 消费者(幂等处理 + 日志)
This commit is contained in:
@@ -4,6 +4,7 @@ use chrono::Utc;
|
||||
use erp_core::audit::AuditLog;
|
||||
use erp_core::audit_service;
|
||||
use erp_core::crypto as pii;
|
||||
use erp_core::events::DomainEvent;
|
||||
use num_traits::ToPrimitive;
|
||||
use sea_orm::entity::prelude::*;
|
||||
use sea_orm::{ActiveValue::Set, QueryOrder, QuerySelect};
|
||||
@@ -130,6 +131,18 @@ pub async fn create_dialysis_record(
|
||||
&state.db,
|
||||
).await;
|
||||
|
||||
// 发布透析记录创建事件
|
||||
let event = DomainEvent::new(
|
||||
"dialysis.record.created",
|
||||
tenant_id,
|
||||
erp_core::events::build_event_payload(serde_json::json!({
|
||||
"record_id": m.id,
|
||||
"patient_id": m.patient_id,
|
||||
"dialysis_type": m.dialysis_type,
|
||||
})),
|
||||
);
|
||||
state.event_bus.publish(event, &state.db).await;
|
||||
|
||||
Ok(to_resp(&state.crypto, m))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user