feat(health): 消息推送集成 — 定时任务启动 + 预约提醒事件
- erp-server: 启动逾期随访检查(6h)、积分过期(24h)、预约提醒(1h) 定时任务 - appointment_service: 新增 send_reminders 扫描明日确认预约发送事件 - erp-message: 订阅 appointment.reminder 事件,向患者发送提醒消息
This commit is contained in:
@@ -352,6 +352,42 @@ async fn handle_workflow_event(
|
||||
.map_err(|e| e.to_string())?;
|
||||
}
|
||||
}
|
||||
"appointment.reminder" => {
|
||||
let patient_id = event
|
||||
.payload
|
||||
.get("patient_id")
|
||||
.and_then(|v| v.as_str())
|
||||
.and_then(|s| uuid::Uuid::parse_str(s).ok());
|
||||
let appointment_date = event
|
||||
.payload
|
||||
.get("appointment_date")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("明天");
|
||||
let time_slot = event
|
||||
.payload
|
||||
.get("time_slot")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
|
||||
if let Some(pid) = patient_id {
|
||||
if should_skip_for_dnd(event.tenant_id, pid, "normal", db).await {
|
||||
return Ok(());
|
||||
}
|
||||
let _ = crate::service::message_service::MessageService::send_system(
|
||||
event.tenant_id,
|
||||
pid,
|
||||
"预约提醒".to_string(),
|
||||
format!("您明天({})有一个预约,时间段:{},请准时就诊。", appointment_date, time_slot),
|
||||
"normal",
|
||||
Some("appointment".to_string()),
|
||||
event.payload.get("appointment_id").and_then(|v| v.as_str()).and_then(|s| uuid::Uuid::parse_str(s).ok()),
|
||||
db,
|
||||
event_bus,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
}
|
||||
}
|
||||
"health_data.critical_alert" => {
|
||||
let patient_name = event
|
||||
.payload
|
||||
|
||||
Reference in New Issue
Block a user