新建 erp-health 原生 Rust crate,覆盖设计规格中定义的 5 大业务域: - 16 个 SeaORM Entity(患者/家属/标签/医生/健康档案/体征/化验单/预约/排班/随访/咨询等) - 16 表数据库迁移(含索引、外键、默认值、可回滚) - 40+ API 路由骨架(患者管理/健康数据/预约排班/随访/咨询/医生管理) - 12 个权限声明(health.patient/health-data/appointment/follow-up/consultation/doctor 各 .list/.manage) - DTO / Service / Handler / Event 四层架构,Service 使用 todo!() 占位 - erp-server 集成:模块注册 + AppState FromRef 桥接 + 路由挂载 同步更新 CLAUDE.md 项目进度、wiki 知识库、设计规格文档。
208 lines
5.6 KiB
Rust
208 lines
5.6 KiB
Rust
//! 健康数据 Service — 体征记录、化验报告、体检记录、趋势分析
|
|
|
|
use chrono::NaiveDate;
|
|
use uuid::Uuid;
|
|
|
|
use erp_core::types::{PaginatedResponse, Pagination};
|
|
|
|
use crate::dto::health_data_dto::{
|
|
CreateHealthRecordReq, CreateLabReportReq, CreateVitalSignsReq, HealthRecordResp,
|
|
IndicatorTimeseriesResp, LabReportResp, TrendResp, UpdateVitalSignsReq,
|
|
};
|
|
use crate::error::HealthResult;
|
|
use crate::state::HealthState;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// 体征记录 (Vital Signs)
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/// 体征记录列表
|
|
pub async fn list_vital_signs(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
pagination: Pagination,
|
|
) -> HealthResult<PaginatedResponse<crate::dto::health_data_dto::VitalSignsResp>> {
|
|
let _ = (state, tenant_id, patient_id, pagination);
|
|
todo!()
|
|
}
|
|
|
|
/// 创建体征记录
|
|
pub async fn create_vital_signs(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
req: CreateVitalSignsReq,
|
|
user_id: Option<Uuid>,
|
|
) -> HealthResult<crate::dto::health_data_dto::VitalSignsResp> {
|
|
let _ = (state, tenant_id, patient_id, req, user_id);
|
|
todo!()
|
|
}
|
|
|
|
/// 更新体征记录(乐观锁)
|
|
pub async fn update_vital_signs(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
vital_signs_id: Uuid,
|
|
req: UpdateVitalSignsReq,
|
|
version: i32,
|
|
) -> HealthResult<crate::dto::health_data_dto::VitalSignsResp> {
|
|
let _ = (state, tenant_id, patient_id, vital_signs_id, req, version);
|
|
todo!()
|
|
}
|
|
|
|
/// 删除体征记录
|
|
pub async fn delete_vital_signs(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
vital_signs_id: Uuid,
|
|
) -> HealthResult<()> {
|
|
let _ = (state, tenant_id, patient_id, vital_signs_id);
|
|
todo!()
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// 化验报告 (Lab Reports)
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/// 化验报告列表
|
|
pub async fn list_lab_reports(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
pagination: Pagination,
|
|
) -> HealthResult<PaginatedResponse<LabReportResp>> {
|
|
let _ = (state, tenant_id, patient_id, pagination);
|
|
todo!()
|
|
}
|
|
|
|
/// 创建化验报告
|
|
pub async fn create_lab_report(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
req: CreateLabReportReq,
|
|
user_id: Option<Uuid>,
|
|
) -> HealthResult<LabReportResp> {
|
|
let _ = (state, tenant_id, patient_id, req, user_id);
|
|
todo!()
|
|
}
|
|
|
|
/// 更新化验报告(乐观锁)
|
|
pub async fn update_lab_report(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
report_id: Uuid,
|
|
req: CreateLabReportReq,
|
|
version: i32,
|
|
) -> HealthResult<LabReportResp> {
|
|
let _ = (state, tenant_id, patient_id, report_id, req, version);
|
|
todo!()
|
|
}
|
|
|
|
/// 删除化验报告
|
|
pub async fn delete_lab_report(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
report_id: Uuid,
|
|
) -> HealthResult<()> {
|
|
let _ = (state, tenant_id, patient_id, report_id);
|
|
todo!()
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// 体检记录 (Health Records)
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/// 体检记录列表
|
|
pub async fn list_health_records(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
pagination: Pagination,
|
|
) -> HealthResult<PaginatedResponse<HealthRecordResp>> {
|
|
let _ = (state, tenant_id, patient_id, pagination);
|
|
todo!()
|
|
}
|
|
|
|
/// 创建体检记录
|
|
pub async fn create_health_record(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
req: CreateHealthRecordReq,
|
|
user_id: Option<Uuid>,
|
|
) -> HealthResult<HealthRecordResp> {
|
|
let _ = (state, tenant_id, patient_id, req, user_id);
|
|
todo!()
|
|
}
|
|
|
|
/// 更新体检记录(乐观锁)
|
|
pub async fn update_health_record(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
record_id: Uuid,
|
|
req: CreateHealthRecordReq,
|
|
version: i32,
|
|
) -> HealthResult<HealthRecordResp> {
|
|
let _ = (state, tenant_id, patient_id, record_id, req, version);
|
|
todo!()
|
|
}
|
|
|
|
/// 删除体检记录
|
|
pub async fn delete_health_record(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
record_id: Uuid,
|
|
) -> HealthResult<()> {
|
|
let _ = (state, tenant_id, patient_id, record_id);
|
|
todo!()
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// 趋势分析 (Trends)
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/// 趋势列表
|
|
pub async fn list_trends(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
pagination: Pagination,
|
|
) -> HealthResult<PaginatedResponse<TrendResp>> {
|
|
let _ = (state, tenant_id, patient_id, pagination);
|
|
todo!()
|
|
}
|
|
|
|
/// 生成趋势分析报告(基于历史体征 + 化验数据聚合)
|
|
pub async fn generate_trend(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
period_start: NaiveDate,
|
|
period_end: NaiveDate,
|
|
user_id: Option<Uuid>,
|
|
) -> HealthResult<TrendResp> {
|
|
let _ = (state, tenant_id, patient_id, period_start, period_end, user_id);
|
|
todo!()
|
|
}
|
|
|
|
/// 获取单个指标的时间序列数据
|
|
pub async fn get_indicator_timeseries(
|
|
state: &HealthState,
|
|
tenant_id: Uuid,
|
|
patient_id: Uuid,
|
|
indicator: String,
|
|
start_date: Option<NaiveDate>,
|
|
end_date: Option<NaiveDate>,
|
|
) -> HealthResult<IndicatorTimeseriesResp> {
|
|
let _ = (state, tenant_id, patient_id, indicator, start_date, end_date);
|
|
todo!()
|
|
}
|