diff --git a/crates/erp-core/src/health_provider.rs b/crates/erp-core/src/health_provider.rs new file mode 100644 index 0000000..b31d995 --- /dev/null +++ b/crates/erp-core/src/health_provider.rs @@ -0,0 +1,99 @@ +use async_trait::async_trait; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +use crate::error::AppResult; + +/// 健康数据提供者 trait,由 erp-health 实现 +/// 返回的 DTO 已脱去 PII(姓名、身份证号等),只包含年龄/性别/医疗数据 +#[async_trait] +pub trait HealthDataProvider: Send + Sync { + /// 获取化验报告(指标列表) + async fn get_lab_report( + &self, + tenant_id: Uuid, + report_id: Uuid, + ) -> AppResult; + + /// 获取生命体征趋势数据 + async fn get_vital_signs( + &self, + tenant_id: Uuid, + patient_id: Uuid, + metrics: &[String], + range: &TimeRange, + ) -> AppResult>; + + /// 获取患者摘要(用于个性化方案) + async fn get_patient_summary( + &self, + tenant_id: Uuid, + patient_id: Uuid, + ) -> AppResult; + + /// 获取完整健康报告(用于摘要生成) + async fn get_full_report( + &self, + tenant_id: Uuid, + report_id: Uuid, + ) -> AppResult; +} + +// === DTO 定义 === + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TimeRange { + pub start: chrono::DateTime, + pub end: chrono::DateTime, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct LabReportDto { + pub age_group: String, + pub sex: String, + pub department: String, + pub report_date: String, + pub items: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct LabItemDto { + pub name: String, + pub value: f64, + pub unit: String, + pub reference_range: String, + pub is_abnormal: bool, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct VitalSignDto { + pub metric: String, + pub values: Vec<(String, f64)>, + pub unit: String, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PatientSummaryDto { + pub age_group: String, + pub sex: String, + pub chronic_conditions: Vec, + pub medications: Vec, + pub family_history: Vec, + pub last_checkup_date: String, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct HealthReportDto { + pub age_group: String, + pub sex: String, + pub department: String, + pub report_date: String, + pub sections: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ReportSectionDto { + pub title: String, + pub findings: Vec, + pub abnormal_items: Vec, +} diff --git a/crates/erp-core/src/lib.rs b/crates/erp-core/src/lib.rs index c66a748..ed8fd5e 100644 --- a/crates/erp-core/src/lib.rs +++ b/crates/erp-core/src/lib.rs @@ -3,6 +3,7 @@ pub mod audit_service; pub mod entity; pub mod error; pub mod events; +pub mod health_provider; pub mod module; pub mod rbac; pub mod sanitize;