From 8d55d98f4f30ce2ee7900117d9588a00adfeb188 Mon Sep 17 00:00:00 2001 From: iven Date: Mon, 27 Apr 2026 17:42:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(health):=20daily=5Fmonitoring.created=20?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 日常监测记录创建后发布 domain event,payload 包含 record_id、 patient_id、record_date 及关键体征数据。 --- crates/erp-health/src/event.rs | 3 +++ .../src/service/daily_monitoring_service.rs | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/erp-health/src/event.rs b/crates/erp-health/src/event.rs index 2655001..241c82d 100644 --- a/crates/erp-health/src/event.rs +++ b/crates/erp-health/src/event.rs @@ -35,6 +35,9 @@ pub const FOLLOW_UP_CREATED: &str = "follow_up.created"; pub const FOLLOW_UP_COMPLETED: &str = "follow_up.completed"; pub const FOLLOW_UP_OVERDUE: &str = "follow_up.overdue"; +// 日常监测 +pub const DAILY_MONITORING_CREATED: &str = "daily_monitoring.created"; + // 健康数据 pub const LAB_REPORT_UPLOADED: &str = "lab_report.uploaded"; pub const HEALTH_DATA_CRITICAL_ALERT: &str = "health_data.critical_alert"; diff --git a/crates/erp-health/src/service/daily_monitoring_service.rs b/crates/erp-health/src/service/daily_monitoring_service.rs index 40d73e2..aab797d 100644 --- a/crates/erp-health/src/service/daily_monitoring_service.rs +++ b/crates/erp-health/src/service/daily_monitoring_service.rs @@ -8,10 +8,13 @@ use uuid::Uuid; use erp_core::types::PaginatedResponse; +use erp_core::events::DomainEvent; + use crate::dto::daily_monitoring_dto::*; use crate::dto::health_data_dto::CreateVitalSignsReq; use crate::entity::vital_signs; use crate::error::{HealthError, HealthResult}; +use crate::event::DAILY_MONITORING_CREATED; use crate::service::health_data_service; use crate::state::HealthState; @@ -94,7 +97,22 @@ pub async fn create_daily_monitoring( let vs = health_data_service::create_vital_signs( state, tenant_id, req.patient_id, operator_id, vs_req, ).await?; - Ok(vs_to_dm(vs)) + + let dm = vs_to_dm(vs); + let event = DomainEvent::new( + DAILY_MONITORING_CREATED, + tenant_id, + serde_json::json!({ + "record_id": dm.id, + "patient_id": dm.patient_id, + "record_date": dm.record_date, + "weight": dm.weight, + "blood_sugar": dm.blood_sugar, + }), + ); + state.event_bus.publish(event, &state.db).await; + + Ok(dm) } pub async fn update_daily_monitoring(