- 创建 erp-dialysis crate(DialysisState + DialysisError + DialysisModule) - 迁移 2 Entity + 2 Service + 2 Handler + 2 DTO 共 8 个文件 - Entity 移除跨 crate patient Relation(FK 列保留) - Service 内联 validation 逻辑,移除 patient 存在性检查(FK 约束保证) - erp-health 的 stats/consultation 中 dialysis 查询改为 raw SQL - ReviewLabReportReq 从 dialysis_dto 移至 health_data_dto(正确归属) - workspace 全量编译通过
115 lines
3.7 KiB
Rust
115 lines
3.7 KiB
Rust
use async_trait::async_trait;
|
|
use axum::Router;
|
|
use erp_core::error::AppResult;
|
|
use erp_core::module::{ErpModule, ModuleContext, ModuleType, PermissionDescriptor};
|
|
|
|
use crate::handler::{dialysis_handler, dialysis_prescription_handler};
|
|
use crate::state::DialysisState;
|
|
|
|
pub struct DialysisModule;
|
|
|
|
impl DialysisModule {
|
|
pub fn public_routes<S>() -> Router<S>
|
|
where
|
|
DialysisState: axum::extract::FromRef<S>,
|
|
S: Clone + Send + Sync + 'static,
|
|
{
|
|
Router::new()
|
|
}
|
|
|
|
pub fn protected_routes<S>() -> Router<S>
|
|
where
|
|
DialysisState: axum::extract::FromRef<S>,
|
|
S: Clone + Send + Sync + 'static,
|
|
{
|
|
Router::new()
|
|
// 透析记录
|
|
.route(
|
|
"/health/patients/{id}/dialysis-records",
|
|
axum::routing::get(dialysis_handler::list_dialysis_records),
|
|
)
|
|
.route(
|
|
"/health/dialysis-records",
|
|
axum::routing::post(dialysis_handler::create_dialysis_record),
|
|
)
|
|
.route(
|
|
"/health/dialysis-records/{id}",
|
|
axum::routing::get(dialysis_handler::get_dialysis_record)
|
|
.put(dialysis_handler::update_dialysis_record)
|
|
.delete(dialysis_handler::delete_dialysis_record),
|
|
)
|
|
.route(
|
|
"/health/dialysis-records/{id}/review",
|
|
axum::routing::put(dialysis_handler::review_dialysis_record),
|
|
)
|
|
// 透析方案
|
|
.route(
|
|
"/health/dialysis-prescriptions",
|
|
axum::routing::get(dialysis_prescription_handler::list_prescriptions)
|
|
.post(dialysis_prescription_handler::create_prescription),
|
|
)
|
|
.route(
|
|
"/health/dialysis-prescriptions/{id}",
|
|
axum::routing::get(dialysis_prescription_handler::get_prescription)
|
|
.put(dialysis_prescription_handler::update_prescription)
|
|
.delete(dialysis_prescription_handler::delete_prescription),
|
|
)
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl ErpModule for DialysisModule {
|
|
fn name(&self) -> &str {
|
|
"透析管理"
|
|
}
|
|
|
|
fn id(&self) -> &str {
|
|
"erp-dialysis"
|
|
}
|
|
|
|
fn version(&self) -> &str {
|
|
"0.1.0"
|
|
}
|
|
|
|
fn module_type(&self) -> ModuleType {
|
|
ModuleType::Builtin
|
|
}
|
|
|
|
fn permissions(&self) -> Vec<PermissionDescriptor> {
|
|
vec![
|
|
PermissionDescriptor {
|
|
code: "health.health-data.list".into(),
|
|
name: "查看透析记录".into(),
|
|
description: "查看透析记录列表和详情".into(),
|
|
module: "erp-dialysis".into(),
|
|
},
|
|
PermissionDescriptor {
|
|
code: "health.health-data.manage".into(),
|
|
name: "管理透析记录".into(),
|
|
description: "创建、编辑、审阅、删除透析记录".into(),
|
|
module: "erp-dialysis".into(),
|
|
},
|
|
PermissionDescriptor {
|
|
code: "health.dialysis-prescription.list".into(),
|
|
name: "查看透析处方".into(),
|
|
description: "查看透析处方列表和详情".into(),
|
|
module: "erp-dialysis".into(),
|
|
},
|
|
PermissionDescriptor {
|
|
code: "health.dialysis-prescription.manage".into(),
|
|
name: "管理透析处方".into(),
|
|
description: "创建、编辑、删除透析处方".into(),
|
|
module: "erp-dialysis".into(),
|
|
},
|
|
]
|
|
}
|
|
|
|
async fn on_startup(&self, _ctx: &ModuleContext) -> AppResult<()> {
|
|
Ok(())
|
|
}
|
|
|
|
fn as_any(&self) -> &dyn std::any::Any {
|
|
self
|
|
}
|
|
}
|