功能修复: 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 统一格式化
103 lines
3.1 KiB
Rust
103 lines
3.1 KiB
Rust
//! 家庭成员健康代理 Handler — 同意管理 + 健康摘要查看
|
|
|
|
use axum::Extension;
|
|
use axum::extract::{Json, Path, Query, State};
|
|
use erp_core::error::AppError;
|
|
use erp_core::rbac::require_permission;
|
|
use erp_core::types::{ApiResponse, TenantContext};
|
|
use serde::Deserialize;
|
|
use uuid::Uuid;
|
|
|
|
use crate::dto::patient_dto::*;
|
|
use crate::service::family_proxy_service;
|
|
use crate::state::HealthState;
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct VersionQuery {
|
|
pub version: i32,
|
|
}
|
|
|
|
/// 授权家庭成员访问健康数据
|
|
pub async fn grant_family_access(
|
|
State(state): State<HealthState>,
|
|
Extension(ctx): Extension<TenantContext>,
|
|
Path((patient_id, family_member_id)): Path<(Uuid, Uuid)>,
|
|
Query(params): Query<VersionQuery>,
|
|
Json(req): Json<GrantFamilyAccessReq>,
|
|
) -> Result<Json<ApiResponse<FamilyMemberResp>>, AppError> {
|
|
require_permission(&ctx, "health.patient.manage")?;
|
|
let result = family_proxy_service::grant_family_access(
|
|
&state,
|
|
ctx.tenant_id,
|
|
patient_id,
|
|
family_member_id,
|
|
Some(ctx.user_id),
|
|
req,
|
|
params.version,
|
|
)
|
|
.await?;
|
|
Ok(Json(ApiResponse::ok(result)))
|
|
}
|
|
|
|
/// 撤销家庭成员健康数据访问
|
|
pub async fn revoke_family_access(
|
|
State(state): State<HealthState>,
|
|
Extension(ctx): Extension<TenantContext>,
|
|
Path((patient_id, family_member_id)): Path<(Uuid, Uuid)>,
|
|
Query(params): Query<VersionQuery>,
|
|
) -> Result<Json<ApiResponse<FamilyMemberResp>>, AppError> {
|
|
require_permission(&ctx, "health.patient.manage")?;
|
|
let result = family_proxy_service::revoke_family_access(
|
|
&state,
|
|
ctx.tenant_id,
|
|
patient_id,
|
|
family_member_id,
|
|
Some(ctx.user_id),
|
|
params.version,
|
|
)
|
|
.await?;
|
|
Ok(Json(ApiResponse::ok(result)))
|
|
}
|
|
|
|
/// 家庭成员查看关联患者列表
|
|
pub async fn list_my_family_patients(
|
|
State(state): State<HealthState>,
|
|
Extension(ctx): Extension<TenantContext>,
|
|
) -> Result<Json<ApiResponse<Vec<FamilyPatientSummaryResp>>>, AppError> {
|
|
let result =
|
|
family_proxy_service::list_family_patients(&state, ctx.tenant_id, ctx.user_id).await?;
|
|
Ok(Json(ApiResponse::ok(result)))
|
|
}
|
|
|
|
/// 家庭成员查看患者健康摘要
|
|
pub async fn get_family_health_summary(
|
|
State(state): State<HealthState>,
|
|
Extension(ctx): Extension<TenantContext>,
|
|
Path(patient_id): Path<Uuid>,
|
|
) -> Result<Json<ApiResponse<FamilyHealthSummaryResp>>, AppError> {
|
|
let result = family_proxy_service::get_family_health_summary(
|
|
&state,
|
|
ctx.tenant_id,
|
|
ctx.user_id,
|
|
patient_id,
|
|
)
|
|
.await?;
|
|
Ok(Json(ApiResponse::ok(result)))
|
|
}
|
|
|
|
/// 绑定家庭成员到系统用户(小程序扫码验证后调用)
|
|
pub async fn link_family_member_user(
|
|
State(state): State<HealthState>,
|
|
Extension(ctx): Extension<TenantContext>,
|
|
Path(family_member_id): Path<Uuid>,
|
|
) -> Result<Json<ApiResponse<FamilyMemberResp>>, AppError> {
|
|
let result = family_proxy_service::link_family_member_user(
|
|
&state,
|
|
ctx.tenant_id,
|
|
family_member_id,
|
|
ctx.user_id,
|
|
)
|
|
.await?;
|
|
Ok(Json(ApiResponse::ok(result)))
|
|
}
|