feat(health): 添加 erp-health 健康管理模块骨架
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

新建 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 知识库、设计规格文档。
This commit is contained in:
iven
2026-04-23 19:59:22 +08:00
parent 5ac8e18d74
commit ca50d32f6e
61 changed files with 6853 additions and 1208 deletions

View File

@@ -0,0 +1,226 @@
use axum::Extension;
use axum::extract::{FromRef, Json, Path, Query, State};
use serde::{Deserialize, Serialize};
use utoipa::{IntoParams, ToSchema};
use uuid::Uuid;
use erp_core::error::AppError;
use erp_core::types::{ApiResponse, PaginatedResponse, TenantContext};
use crate::state::HealthState;
// ---------------------------------------------------------------------------
// DTO — 预约排班
// ---------------------------------------------------------------------------
/// 预约列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct AppointmentListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
pub patient_id: Option<Uuid>,
pub doctor_id: Option<Uuid>,
pub status: Option<String>,
pub date: Option<String>,
}
/// 创建预约请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateAppointmentReq {
pub patient_id: Uuid,
pub doctor_id: Uuid,
pub schedule_id: Uuid,
pub appointment_date: String,
pub start_time: String,
pub end_time: String,
pub reason: Option<String>,
}
/// 更新预约状态请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct UpdateAppointmentStatusReq {
pub status: String,
pub cancel_reason: Option<String>,
}
/// 预约响应
#[derive(Debug, Serialize, ToSchema)]
pub struct AppointmentResp {
pub id: Uuid,
pub patient_id: Uuid,
pub doctor_id: Uuid,
pub schedule_id: Uuid,
pub appointment_date: String,
pub start_time: String,
pub end_time: String,
pub status: String,
pub reason: Option<String>,
pub cancel_reason: Option<String>,
pub created_at: String,
pub updated_at: String,
}
/// 排班列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct ScheduleListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
pub doctor_id: Option<Uuid>,
pub start_date: Option<String>,
pub end_date: Option<String>,
}
/// 创建排班请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateScheduleReq {
pub doctor_id: Uuid,
pub schedule_date: String,
pub start_time: String,
pub end_time: String,
pub max_appointments: i32,
pub slot_duration_minutes: Option<i32>,
}
/// 更新排班请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct UpdateScheduleReq {
pub start_time: Option<String>,
pub end_time: Option<String>,
pub max_appointments: Option<i32>,
pub slot_duration_minutes: Option<i32>,
pub version: i32,
}
/// 排班响应
#[derive(Debug, Serialize, ToSchema)]
pub struct ScheduleResp {
pub id: Uuid,
pub doctor_id: Uuid,
pub schedule_date: String,
pub start_time: String,
pub end_time: String,
pub max_appointments: i32,
pub current_appointments: i32,
pub slot_duration_minutes: Option<i32>,
pub created_at: String,
pub updated_at: String,
}
/// 日历视图查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct CalendarViewParams {
pub doctor_id: Option<Uuid>,
pub start_date: String,
pub end_date: String,
}
/// 日历视图单个日期条目
#[derive(Debug, Serialize, ToSchema)]
pub struct CalendarDayEntry {
pub date: String,
pub schedules: Vec<ScheduleResp>,
pub appointments: Vec<AppointmentResp>,
}
/// 日历视图响应
#[derive(Debug, Serialize, ToSchema)]
pub struct CalendarViewResp {
pub days: Vec<CalendarDayEntry>,
}
// ---------------------------------------------------------------------------
// Handler — 预约排班 (7 个端点)
// ---------------------------------------------------------------------------
/// GET /api/v1/health/appointments — 预约列表
pub async fn list_appointments<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<AppointmentListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<AppointmentResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/appointments — 创建预约
pub async fn create_appointment<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Json(_req): Json<CreateAppointmentReq>,
) -> Result<Json<ApiResponse<AppointmentResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// PUT /api/v1/health/appointments/{id}/status — 更新预约状态
pub async fn update_appointment_status<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<UpdateAppointmentStatusReq>,
) -> Result<Json<ApiResponse<AppointmentResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/schedules — 排班列表
pub async fn list_schedules<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<ScheduleListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<ScheduleResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/schedules — 创建排班
pub async fn create_schedule<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Json(_req): Json<CreateScheduleReq>,
) -> Result<Json<ApiResponse<ScheduleResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// PUT /api/v1/health/schedules/{id} — 更新排班
pub async fn update_schedule<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<UpdateScheduleReq>,
) -> Result<Json<ApiResponse<ScheduleResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/calendar — 日历视图
pub async fn calendar_view<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<CalendarViewParams>,
) -> Result<Json<ApiResponse<CalendarViewResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}

View File

@@ -0,0 +1,142 @@
use axum::Extension;
use axum::extract::{FromRef, Json, Path, Query, State};
use serde::{Deserialize, Serialize};
use utoipa::{IntoParams, ToSchema};
use uuid::Uuid;
use erp_core::error::AppError;
use erp_core::types::{ApiResponse, PaginatedResponse, TenantContext};
use crate::state::HealthState;
// ---------------------------------------------------------------------------
// DTO — 咨询管理
// ---------------------------------------------------------------------------
/// 会话列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct SessionListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
pub patient_id: Option<Uuid>,
pub doctor_id: Option<Uuid>,
pub status: Option<String>,
}
/// 会话响应
#[derive(Debug, Serialize, ToSchema)]
pub struct ConsultationSessionResp {
pub id: Uuid,
pub patient_id: Uuid,
pub doctor_id: Uuid,
pub subject: String,
pub status: String,
pub created_at: String,
pub updated_at: String,
}
/// 消息列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct MessageListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
}
/// 创建消息请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateConsultationMessageReq {
pub content: String,
pub message_type: Option<String>,
}
/// 消息响应
#[derive(Debug, Serialize, ToSchema)]
pub struct ConsultationMessageResp {
pub id: Uuid,
pub session_id: Uuid,
pub sender_id: Uuid,
pub sender_type: String,
pub content: String,
pub message_type: String,
pub created_at: String,
}
/// 导出会话请求
#[derive(Debug, Deserialize, IntoParams)]
pub struct ExportSessionsParams {
pub patient_id: Option<Uuid>,
pub doctor_id: Option<Uuid>,
pub start_date: Option<String>,
pub end_date: Option<String>,
}
// ---------------------------------------------------------------------------
// Handler — 咨询管理 (5 个端点)
// ---------------------------------------------------------------------------
/// GET /api/v1/health/consultations/sessions — 会话列表
pub async fn list_sessions<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<SessionListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<ConsultationSessionResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/consultations/sessions/{id}/messages — 消息列表
pub async fn list_messages<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_session_id): Path<Uuid>,
Query(_params): Query<MessageListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<ConsultationMessageResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// PUT /api/v1/health/consultations/sessions/{id}/close — 关闭会话
pub async fn close_session<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<ConsultationSessionResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/consultations/sessions/{id}/messages — 创建消息
pub async fn create_message<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_session_id): Path<Uuid>,
Json(_req): Json<CreateConsultationMessageReq>,
) -> Result<Json<ApiResponse<ConsultationMessageResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/consultations/export — 导出会话
pub async fn export_sessions<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<ExportSessionsParams>,
) -> Result<Json<ApiResponse<Vec<ConsultationSessionResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}

View File

@@ -0,0 +1,136 @@
use axum::Extension;
use axum::extract::{FromRef, Json, Path, Query, State};
use serde::{Deserialize, Serialize};
use utoipa::{IntoParams, ToSchema};
use uuid::Uuid;
use erp_core::error::AppError;
use erp_core::types::{ApiResponse, PaginatedResponse, TenantContext};
use crate::state::HealthState;
// ---------------------------------------------------------------------------
// DTO — 医护管理
// ---------------------------------------------------------------------------
/// 医护列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct DoctorListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
/// 按姓名模糊搜索
pub search: Option<String>,
/// 按科室筛选
pub department: Option<String>,
/// 按职称筛选
pub title: Option<String>,
}
/// 创建医护档案请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateDoctorReq {
pub user_id: Uuid,
pub name: String,
pub department: Option<String>,
pub title: Option<String>,
pub specialty: Option<String>,
pub license_number: Option<String>,
pub bio: Option<String>,
}
/// 更新医护档案请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct UpdateDoctorReq {
pub name: Option<String>,
pub department: Option<String>,
pub title: Option<String>,
pub specialty: Option<String>,
pub license_number: Option<String>,
pub bio: Option<String>,
pub version: i32,
}
/// 医护档案响应
#[derive(Debug, Serialize, ToSchema)]
pub struct DoctorResp {
pub id: Uuid,
pub user_id: Uuid,
pub name: String,
pub department: Option<String>,
pub title: Option<String>,
pub specialty: Option<String>,
pub license_number: Option<String>,
pub bio: Option<String>,
pub created_at: String,
pub updated_at: String,
}
// ---------------------------------------------------------------------------
// Handler — 医护管理 (5 个端点)
// ---------------------------------------------------------------------------
/// GET /api/v1/health/doctors — 医护档案列表
pub async fn list_doctors<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<DoctorListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<DoctorResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/doctors — 创建医护档案
pub async fn create_doctor<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Json(_req): Json<CreateDoctorReq>,
) -> Result<Json<ApiResponse<DoctorResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/doctors/{id} — 获取医护档案详情
pub async fn get_doctor<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<DoctorResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// PUT /api/v1/health/doctors/{id} — 更新医护档案
pub async fn update_doctor<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<UpdateDoctorReq>,
) -> Result<Json<ApiResponse<DoctorResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// DELETE /api/v1/health/doctors/{id} — 删除医护档案
pub async fn delete_doctor<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}

View File

@@ -0,0 +1,178 @@
use axum::Extension;
use axum::extract::{FromRef, Json, Path, Query, State};
use serde::{Deserialize, Serialize};
use utoipa::{IntoParams, ToSchema};
use uuid::Uuid;
use erp_core::error::AppError;
use erp_core::types::{ApiResponse, PaginatedResponse, TenantContext};
use crate::state::HealthState;
// ---------------------------------------------------------------------------
// DTO — 随访管理
// ---------------------------------------------------------------------------
/// 随访任务列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct FollowUpTaskListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
pub patient_id: Option<Uuid>,
pub assigned_to: Option<Uuid>,
pub status: Option<String>,
}
/// 创建随访任务请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateFollowUpTaskReq {
pub patient_id: Uuid,
pub task_type: String,
pub title: String,
pub description: Option<String>,
pub due_date: String,
pub assigned_to: Option<Uuid>,
}
/// 更新随访任务请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct UpdateFollowUpTaskReq {
pub task_type: Option<String>,
pub title: Option<String>,
pub description: Option<String>,
pub due_date: Option<String>,
pub assigned_to: Option<Uuid>,
pub status: Option<String>,
pub version: i32,
}
/// 随访任务响应
#[derive(Debug, Serialize, ToSchema)]
pub struct FollowUpTaskResp {
pub id: Uuid,
pub patient_id: Uuid,
pub task_type: String,
pub title: String,
pub description: Option<String>,
pub due_date: String,
pub assigned_to: Option<Uuid>,
pub status: String,
pub created_at: String,
pub updated_at: String,
}
/// 创建随访记录请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateFollowUpRecordReq {
pub task_id: Uuid,
pub contact_method: String,
pub content: String,
pub outcome: Option<String>,
pub next_follow_up_date: Option<String>,
}
/// 随访记录列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct FollowUpRecordListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
pub task_id: Option<Uuid>,
pub patient_id: Option<Uuid>,
}
/// 随访记录响应
#[derive(Debug, Serialize, ToSchema)]
pub struct FollowUpRecordResp {
pub id: Uuid,
pub task_id: Uuid,
pub patient_id: Uuid,
pub contact_method: String,
pub content: String,
pub outcome: Option<String>,
pub next_follow_up_date: Option<String>,
pub created_by: Uuid,
pub created_at: String,
}
// ---------------------------------------------------------------------------
// Handler — 随访管理 (6 个端点)
// ---------------------------------------------------------------------------
/// GET /api/v1/health/follow-up/tasks — 随访任务列表
pub async fn list_tasks<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<FollowUpTaskListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<FollowUpTaskResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/follow-up/tasks — 创建随访任务
pub async fn create_task<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Json(_req): Json<CreateFollowUpTaskReq>,
) -> Result<Json<ApiResponse<FollowUpTaskResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// PUT /api/v1/health/follow-up/tasks/{id} — 更新随访任务
pub async fn update_task<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<UpdateFollowUpTaskReq>,
) -> Result<Json<ApiResponse<FollowUpTaskResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// DELETE /api/v1/health/follow-up/tasks/{id} — 删除随访任务
pub async fn delete_task<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/follow-up/records — 创建随访记录
pub async fn create_record<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Json(_req): Json<CreateFollowUpRecordReq>,
) -> Result<Json<ApiResponse<FollowUpRecordResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/follow-up/records — 随访记录列表
pub async fn list_records<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<FollowUpRecordListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<FollowUpRecordResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}

View File

@@ -0,0 +1,408 @@
use axum::Extension;
use axum::extract::{FromRef, Json, Path, Query, State};
use serde::{Deserialize, Serialize};
use utoipa::{IntoParams, ToSchema};
use uuid::Uuid;
use erp_core::error::AppError;
use erp_core::types::{ApiResponse, PaginatedResponse, TenantContext};
use crate::state::HealthState;
// ---------------------------------------------------------------------------
// DTO — 健康数据
// ---------------------------------------------------------------------------
/// 生命体征列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct VitalSignsListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
pub patient_id: Uuid,
}
/// 创建生命体征请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateVitalSignsReq {
pub patient_id: Uuid,
pub blood_pressure_systolic: Option<i32>,
pub blood_pressure_diastolic: Option<i32>,
pub heart_rate: Option<i32>,
pub temperature: Option<f64>,
pub blood_oxygen: Option<i32>,
pub weight: Option<f64>,
pub height: Option<f64>,
pub measured_at: Option<String>,
pub notes: Option<String>,
}
/// 更新生命体征请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct UpdateVitalSignsReq {
pub blood_pressure_systolic: Option<i32>,
pub blood_pressure_diastolic: Option<i32>,
pub heart_rate: Option<i32>,
pub temperature: Option<f64>,
pub blood_oxygen: Option<i32>,
pub weight: Option<f64>,
pub height: Option<f64>,
pub measured_at: Option<String>,
pub notes: Option<String>,
pub version: i32,
}
/// 生命体征响应
#[derive(Debug, Serialize, ToSchema)]
pub struct VitalSignsResp {
pub id: Uuid,
pub patient_id: Uuid,
pub blood_pressure_systolic: Option<i32>,
pub blood_pressure_diastolic: Option<i32>,
pub heart_rate: Option<i32>,
pub temperature: Option<f64>,
pub blood_oxygen: Option<i32>,
pub weight: Option<f64>,
pub height: Option<f64>,
pub measured_at: Option<String>,
pub notes: Option<String>,
pub created_at: String,
pub updated_at: String,
}
/// 化验报告列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct LabReportListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
pub patient_id: Option<Uuid>,
}
/// 创建化验报告请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateLabReportReq {
pub patient_id: Uuid,
pub report_type: String,
pub report_date: String,
pub indicators: serde_json::Value,
pub file_url: Option<String>,
pub notes: Option<String>,
}
/// 更新化验报告请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct UpdateLabReportReq {
pub report_type: Option<String>,
pub report_date: Option<String>,
pub indicators: Option<serde_json::Value>,
pub file_url: Option<String>,
pub notes: Option<String>,
pub version: i32,
}
/// 化验报告响应
#[derive(Debug, Serialize, ToSchema)]
pub struct LabReportResp {
pub id: Uuid,
pub patient_id: Uuid,
pub report_type: String,
pub report_date: String,
pub indicators: serde_json::Value,
pub file_url: Option<String>,
pub notes: Option<String>,
pub created_at: String,
pub updated_at: String,
}
/// 健康档案列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct HealthRecordListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
pub patient_id: Option<Uuid>,
}
/// 创建健康档案请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateHealthRecordReq {
pub patient_id: Uuid,
pub record_type: String,
pub title: String,
pub content: serde_json::Value,
pub record_date: String,
}
/// 更新健康档案请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct UpdateHealthRecordReq {
pub record_type: Option<String>,
pub title: Option<String>,
pub content: Option<serde_json::Value>,
pub record_date: Option<String>,
pub version: i32,
}
/// 健康档案响应
#[derive(Debug, Serialize, ToSchema)]
pub struct HealthRecordResp {
pub id: Uuid,
pub patient_id: Uuid,
pub record_type: String,
pub title: String,
pub content: serde_json::Value,
pub record_date: String,
pub created_at: String,
pub updated_at: String,
}
/// 趋势分析列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct TrendListParams {
pub patient_id: Option<Uuid>,
}
/// 生成趋势请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct GenerateTrendReq {
pub patient_id: Uuid,
pub indicator_name: String,
pub start_date: String,
pub end_date: String,
}
/// 趋势分析响应
#[derive(Debug, Serialize, ToSchema)]
pub struct TrendResp {
pub id: Uuid,
pub patient_id: Uuid,
pub indicator_name: String,
pub trend_data: serde_json::Value,
pub analysis_summary: Option<String>,
pub generated_at: String,
}
/// 指标时间序列查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct IndicatorTimeseriesParams {
pub patient_id: Uuid,
pub indicator_name: String,
pub start_date: Option<String>,
pub end_date: Option<String>,
}
/// 指标时间序列数据点
#[derive(Debug, Serialize, ToSchema)]
pub struct TimeseriesDataPoint {
pub date: String,
pub value: f64,
pub unit: Option<String>,
}
/// 指标时间序列响应
#[derive(Debug, Serialize, ToSchema)]
pub struct IndicatorTimeseriesResp {
pub indicator_name: String,
pub patient_id: Uuid,
pub data_points: Vec<TimeseriesDataPoint>,
}
// ---------------------------------------------------------------------------
// Handler — 健康数据 (15 个端点)
// ---------------------------------------------------------------------------
/// GET /api/v1/health/vital-signs — 生命体征列表
pub async fn list_vital_signs<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<VitalSignsListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<VitalSignsResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/vital-signs — 创建生命体征记录
pub async fn create_vital_signs<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Json(_req): Json<CreateVitalSignsReq>,
) -> Result<Json<ApiResponse<VitalSignsResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// PUT /api/v1/health/vital-signs/{id} — 更新生命体征记录
pub async fn update_vital_signs<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<UpdateVitalSignsReq>,
) -> Result<Json<ApiResponse<VitalSignsResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// DELETE /api/v1/health/vital-signs/{id} — 删除生命体征记录
pub async fn delete_vital_signs<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/lab-reports — 化验报告列表
pub async fn list_lab_reports<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<LabReportListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<LabReportResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/lab-reports — 创建化验报告
pub async fn create_lab_report<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Json(_req): Json<CreateLabReportReq>,
) -> Result<Json<ApiResponse<LabReportResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// PUT /api/v1/health/lab-reports/{id} — 更新化验报告
pub async fn update_lab_report<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<UpdateLabReportReq>,
) -> Result<Json<ApiResponse<LabReportResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// DELETE /api/v1/health/lab-reports/{id} — 删除化验报告
pub async fn delete_lab_report<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/records — 健康档案列表
pub async fn list_health_records<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<HealthRecordListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<HealthRecordResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/records — 创建健康档案
pub async fn create_health_record<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Json(_req): Json<CreateHealthRecordReq>,
) -> Result<Json<ApiResponse<HealthRecordResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// PUT /api/v1/health/records/{id} — 更新健康档案
pub async fn update_health_record<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<UpdateHealthRecordReq>,
) -> Result<Json<ApiResponse<HealthRecordResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// DELETE /api/v1/health/records/{id} — 删除健康档案
pub async fn delete_health_record<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/trends — 趋势分析列表
pub async fn list_trends<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<TrendListParams>,
) -> Result<Json<ApiResponse<Vec<TrendResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/trends/generate — 生成趋势分析
pub async fn generate_trend<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Json(_req): Json<GenerateTrendReq>,
) -> Result<Json<ApiResponse<TrendResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/trends/timeseries — 获取指标时间序列
pub async fn get_indicator_timeseries<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<IndicatorTimeseriesParams>,
) -> Result<Json<ApiResponse<IndicatorTimeseriesResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}

View File

@@ -0,0 +1,6 @@
pub mod appointment_handler;
pub mod consultation_handler;
pub mod doctor_handler;
pub mod follow_up_handler;
pub mod health_data_handler;
pub mod patient_handler;

View File

@@ -0,0 +1,311 @@
use axum::Extension;
use axum::extract::{FromRef, Json, Path, Query, State};
use serde::{Deserialize, Serialize};
use utoipa::{IntoParams, ToSchema};
use uuid::Uuid;
use erp_core::error::AppError;
use erp_core::types::{ApiResponse, PaginatedResponse, TenantContext};
use crate::state::HealthState;
// ---------------------------------------------------------------------------
// DTO — 患者管理
// ---------------------------------------------------------------------------
/// 患者列表查询参数
#[derive(Debug, Deserialize, IntoParams)]
pub struct PatientListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
/// 按姓名/身份证号模糊搜索
pub search: Option<String>,
/// 按标签筛选
pub tag_id: Option<Uuid>,
/// 按负责医生筛选
pub doctor_id: Option<Uuid>,
}
/// 创建患者请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreatePatientReq {
pub name: String,
pub id_card: Option<String>,
pub phone: Option<String>,
pub gender: Option<String>,
pub birth_date: Option<String>,
pub address: Option<String>,
pub emergency_contact: Option<String>,
pub emergency_phone: Option<String>,
pub medical_notes: Option<String>,
}
/// 更新患者请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct UpdatePatientReq {
pub name: Option<String>,
pub id_card: Option<String>,
pub phone: Option<String>,
pub gender: Option<String>,
pub birth_date: Option<String>,
pub address: Option<String>,
pub emergency_contact: Option<String>,
pub emergency_phone: Option<String>,
pub medical_notes: Option<String>,
pub version: i32,
}
/// 患者标签管理请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct ManagePatientTagsReq {
pub tag_ids: Vec<Uuid>,
}
/// 患者响应
#[derive(Debug, Serialize, ToSchema)]
pub struct PatientResp {
pub id: Uuid,
pub name: String,
pub id_card: Option<String>,
pub phone: Option<String>,
pub gender: Option<String>,
pub birth_date: Option<String>,
pub address: Option<String>,
pub emergency_contact: Option<String>,
pub emergency_phone: Option<String>,
pub medical_notes: Option<String>,
pub tags: Vec<PatientTagResp>,
pub created_at: String,
pub updated_at: String,
}
/// 患者标签响应
#[derive(Debug, Serialize, ToSchema)]
pub struct PatientTagResp {
pub id: Uuid,
pub name: String,
pub color: Option<String>,
}
/// 健康摘要响应
#[derive(Debug, Serialize, ToSchema)]
pub struct HealthSummaryResp {
pub patient_id: Uuid,
pub latest_vital_signs: Option<serde_json::Value>,
pub latest_lab_report: Option<serde_json::Value>,
pub upcoming_appointments: u64,
pub pending_follow_ups: u64,
}
/// 家庭成员请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateFamilyMemberReq {
pub name: String,
pub relationship: String,
pub phone: Option<String>,
pub id_card: Option<String>,
}
/// 更新家庭成员请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct UpdateFamilyMemberReq {
pub name: Option<String>,
pub relationship: Option<String>,
pub phone: Option<String>,
pub id_card: Option<String>,
}
/// 家庭成员响应
#[derive(Debug, Serialize, ToSchema)]
pub struct FamilyMemberResp {
pub id: Uuid,
pub patient_id: Uuid,
pub name: String,
pub relationship: String,
pub phone: Option<String>,
pub id_card: Option<String>,
}
/// 分配医生请求
#[derive(Debug, Deserialize, ToSchema)]
pub struct AssignDoctorReq {
pub doctor_id: Uuid,
}
// ---------------------------------------------------------------------------
// Handler — 患者管理 (13 个端点)
// ---------------------------------------------------------------------------
/// GET /api/v1/health/patients — 患者列表
pub async fn list_patients<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Query(_params): Query<PatientListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<PatientResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/patients — 创建患者
pub async fn create_patient<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Json(_req): Json<CreatePatientReq>,
) -> Result<Json<ApiResponse<PatientResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/patients/{id} — 获取患者详情
pub async fn get_patient<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<PatientResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// PUT /api/v1/health/patients/{id} — 更新患者
pub async fn update_patient<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<UpdatePatientReq>,
) -> Result<Json<ApiResponse<PatientResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// DELETE /api/v1/health/patients/{id} — 删除患者(软删除)
pub async fn delete_patient<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/patients/{id}/tags — 管理患者标签
pub async fn manage_patient_tags<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<ManagePatientTagsReq>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/patients/{id}/health-summary — 获取患者健康摘要
pub async fn get_health_summary<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<HealthSummaryResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// GET /api/v1/health/patients/{id}/family-members — 家庭成员列表
pub async fn list_family_members<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
) -> Result<Json<ApiResponse<Vec<FamilyMemberResp>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/patients/{id}/family-members — 创建家庭成员
pub async fn create_family_member<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<CreateFamilyMemberReq>,
) -> Result<Json<ApiResponse<FamilyMemberResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// PUT /api/v1/health/patients/{patient_id}/family-members/{member_id} — 更新家庭成员
pub async fn update_family_member<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path((_patient_id, _member_id)): Path<(Uuid, Uuid)>,
Json(_req): Json<UpdateFamilyMemberReq>,
) -> Result<Json<ApiResponse<FamilyMemberResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// DELETE /api/v1/health/patients/{patient_id}/family-members/{member_id} — 删除家庭成员
pub async fn delete_family_member<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path((_patient_id, _member_id)): Path<(Uuid, Uuid)>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// POST /api/v1/health/patients/{id}/doctors — 分配负责医生
pub async fn assign_doctor<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path(_id): Path<Uuid>,
Json(_req): Json<AssignDoctorReq>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}
/// DELETE /api/v1/health/patients/{patient_id}/doctors/{doctor_id} — 移除负责医生
pub async fn remove_doctor<S>(
State(_state): State<HealthState>,
Extension(_ctx): Extension<TenantContext>,
Path((_patient_id, _doctor_id)): Path<(Uuid, Uuid)>,
) -> Result<Json<ApiResponse<()>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
Err(AppError::Internal("Not implemented yet".into()))
}