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()))
}