feat(health+workflow): 行动分发→工作流启动集成 — 事件驱动 BPMN 实例化
- create_pending_action 新增 workflow.ai_action.start_requested 事件发布 - 根据 action_type 映射到对应 BPMN 流程定义 key - erp-workflow 消费启动请求,自动创建审批流程实例 - 流程变量包含 risk_level/patient_id/action_type/params
This commit is contained in:
@@ -136,6 +136,7 @@ async fn create_pending_action(
|
||||
risk_level: &str,
|
||||
decision: &DispatchDecision,
|
||||
) {
|
||||
// 发布待审批事件(通知/日志用)
|
||||
let event = erp_core::events::DomainEvent::new(
|
||||
"health.ai_action.pending_approval",
|
||||
tenant_id,
|
||||
@@ -149,6 +150,28 @@ async fn create_pending_action(
|
||||
})),
|
||||
);
|
||||
event_bus.publish(event, db).await;
|
||||
|
||||
// 发布工作流启动请求事件(触发 BPMN 审批流程)
|
||||
let workflow_key = match action_type {
|
||||
"followup" => "ai_followup_workflow",
|
||||
"appointment" => "ai_appointment_workflow",
|
||||
"alert" => "ai_alert_workflow",
|
||||
_ => return,
|
||||
};
|
||||
|
||||
let workflow_event = erp_core::events::DomainEvent::new(
|
||||
"workflow.ai_action.start_requested",
|
||||
tenant_id,
|
||||
erp_core::events::build_event_payload(serde_json::json!({
|
||||
"workflow_key": workflow_key,
|
||||
"patient_id": patient_id,
|
||||
"doctor_id": doctor_id,
|
||||
"risk_level": risk_level,
|
||||
"action_type": action_type,
|
||||
"params": params,
|
||||
})),
|
||||
);
|
||||
event_bus.publish(workflow_event, db).await;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user