feat(health): daily_monitoring.created 事件发布
日常监测记录创建后发布 domain event,payload 包含 record_id、 patient_id、record_date 及关键体征数据。
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user