100 lines
2.5 KiB
Rust
100 lines
2.5 KiB
Rust
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>,
|
||
}
|