Files
hms/crates/erp-health/src/dto/shift_dto.rs
iven 6d5a711d2c
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
fix: 修复测试发现的 7 个问题 + 全 workspace clippy 清零
功能修复:
1. 患者创建空名称验证:后端添加 name.trim().is_empty() 检查
2. 仪表盘统计容错:单个查询失败返回零值而非 500
3. FHIR 路由修复:从 /fhir 移到 /api/v1/fhir 保持一致
4. 冻结模块后端中间件:新增 frozen_module_middleware 拦截冻结路径
5. 积分端点权限码:health.health-data.list → health.points.list
6. 角色权限迁移:护士补充 devices.list,运营补充 points.list/manage
7. 测试结果文档:R01-R05 角色测试 + T00/T10 结果归档

Clippy 全 workspace 清零(14→0 errors):
- erp-core: 修复 empty doc line、collapsible if、redundant closure 等 9 处
- erp-health: 修复 too_many_arguments、unused var、unnecessary parens 等 58 处
- erp-ai: 修复 dead_code、unused import 等 11 处
- erp-plugin: 修复 too_many_arguments、wildcard pattern 等 11 处
- erp-server-migration: 修复 enum_variant_names 5 处
- erp-auth/config/workflow/message: 各 1-3 处

工程改进:
- lint-staged 配置迁移到 .lintstagedrc.js(函数式避免文件列表传给 clippy)
- cargo fmt 统一格式化
2026-05-07 23:43:14 +08:00

168 lines
4.6 KiB
Rust

use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
// ---------------------------------------------------------------------------
// Shift DTOs
// ---------------------------------------------------------------------------
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShiftResp {
pub id: Uuid,
pub tenant_id: Uuid,
pub shift_date: NaiveDate,
pub period: String,
pub nurse_id: Option<Uuid>,
pub status: String,
pub notes: Option<String>,
pub created_at: chrono::DateTime<chrono::Utc>,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub created_by: Option<Uuid>,
pub updated_by: Option<Uuid>,
pub version: i32,
/// 班次内患者分配摘要
pub patient_count: Option<i64>,
pub critical_count: Option<i64>,
pub attention_count: Option<i64>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateShiftReq {
pub shift_date: NaiveDate,
pub period: String,
pub nurse_id: Option<Uuid>,
pub notes: Option<String>,
}
impl CreateShiftReq {
pub fn sanitize(&mut self) {
self.period = erp_core::sanitize::sanitize_string(&self.period);
self.notes = self
.notes
.take()
.map(|n| erp_core::sanitize::sanitize_string(&n));
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateShiftReq {
pub nurse_id: Option<Uuid>,
pub status: Option<String>,
pub notes: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateShiftWithVersion {
pub version: i32,
pub data: UpdateShiftReq,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListShiftsParams {
pub shift_date: Option<NaiveDate>,
pub period: Option<String>,
pub nurse_id: Option<Uuid>,
pub status: Option<String>,
pub page: Option<u64>,
pub page_size: Option<u64>,
}
// ---------------------------------------------------------------------------
// PatientAssignment DTOs
// ---------------------------------------------------------------------------
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PatientAssignmentResp {
pub id: Uuid,
pub tenant_id: Uuid,
pub shift_id: Uuid,
pub patient_id: Uuid,
pub care_level: String,
pub notes: Option<String>,
pub created_at: chrono::DateTime<chrono::Utc>,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub version: i32,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreatePatientAssignmentReq {
pub patient_id: Uuid,
pub care_level: Option<String>,
pub notes: Option<String>,
}
impl CreatePatientAssignmentReq {
pub fn sanitize(&mut self) {
if let Some(ref mut cl) = self.care_level {
*cl = erp_core::sanitize::sanitize_string(cl);
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdatePatientAssignmentReq {
pub care_level: Option<String>,
pub notes: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdatePatientAssignmentWithVersion {
pub version: i32,
pub data: UpdatePatientAssignmentReq,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BatchAssignReq {
pub patient_ids: Vec<Uuid>,
pub care_level: Option<String>,
}
// ---------------------------------------------------------------------------
// HandoffLog DTOs
// ---------------------------------------------------------------------------
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HandoffLogResp {
pub id: Uuid,
pub tenant_id: Uuid,
pub from_shift_id: Uuid,
pub to_shift_id: Uuid,
pub patient_id: Uuid,
pub notes: Option<String>,
pub pending_items: Option<serde_json::Value>,
pub created_at: chrono::DateTime<chrono::Utc>,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub version: i32,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateHandoffReq {
pub from_shift_id: Uuid,
pub to_shift_id: Uuid,
pub patient_id: Uuid,
pub notes: Option<String>,
pub pending_items: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListHandoffParams {
pub to_shift_id: Option<Uuid>,
pub from_shift_id: Option<Uuid>,
pub patient_id: Option<Uuid>,
pub page: Option<u64>,
pub page_size: Option<u64>,
}