feat(core): 新增 HealthDataProvider trait + DTO 定义
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
99
crates/erp-core/src/health_provider.rs
Normal file
99
crates/erp-core/src/health_provider.rs
Normal file
@@ -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<LabReportDto>;
|
||||
|
||||
/// 获取生命体征趋势数据
|
||||
async fn get_vital_signs(
|
||||
&self,
|
||||
tenant_id: Uuid,
|
||||
patient_id: Uuid,
|
||||
metrics: &[String],
|
||||
range: &TimeRange,
|
||||
) -> AppResult<Vec<VitalSignDto>>;
|
||||
|
||||
/// 获取患者摘要(用于个性化方案)
|
||||
async fn get_patient_summary(
|
||||
&self,
|
||||
tenant_id: Uuid,
|
||||
patient_id: Uuid,
|
||||
) -> AppResult<PatientSummaryDto>;
|
||||
|
||||
/// 获取完整健康报告(用于摘要生成)
|
||||
async fn get_full_report(
|
||||
&self,
|
||||
tenant_id: Uuid,
|
||||
report_id: Uuid,
|
||||
) -> AppResult<HealthReportDto>;
|
||||
}
|
||||
|
||||
// === DTO 定义 ===
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct TimeRange {
|
||||
pub start: chrono::DateTime<chrono::Utc>,
|
||||
pub end: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
#[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<LabItemDto>,
|
||||
}
|
||||
|
||||
#[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<String>,
|
||||
pub medications: Vec<String>,
|
||||
pub family_history: Vec<String>,
|
||||
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<ReportSectionDto>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ReportSectionDto {
|
||||
pub title: String,
|
||||
pub findings: Vec<String>,
|
||||
pub abnormal_items: Vec<String>,
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user