功能修复: 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 统一格式化
12 KiB
12 KiB
R04 Health Manager (健康管理师) 深度业务链路测试报告
测试日期: 2026-05-07 | 测试角色: health_manager_test | 角色: health_manager
权限码: 37 个 (health.patient.list/manage, health.follow-up.list/manage, 等)
测试概览
| 指标 | 数值 |
|---|---|
| 总测试项 | 42 |
| PASS | 31 |
| FAIL | 2 |
| ISSUE | 9 |
| 总通过率 | 73.8% (31/42) |
| 功能通过率 | 88.6% (31/35, 排除权限边界) |
链路 A: 患者标签与管理
| # | 测试项 | 方法+路径 | HTTP状态 | 结果 | 备注 |
|---|---|---|---|---|---|
| A1 | 查看患者列表 | GET /health/patients | 200 | PASS | 返回39条患者数据,分页正常 |
| A2 | 创建患者 | POST /health/patients | 200 | PASS | 成功创建 HM-Test-Patient-A2 |
| A3 | 查看患者标签 | GET /health/patient-tags | 200 | PASS | 返回2个标签 (AnnualCheckup, Chronic Disease) |
| A4a | 按名称搜索患者 | GET /health/patients?search=HM-Test | 200 | PASS | 精准搜索,返回1条 |
| A4b | 按性别筛选 | GET /health/patients?gender=female | 200 | PASS | 返回41条 (gender 筛选含 null 的记录) |
| A4c | 按状态筛选 | GET /health/patients?status=active | 200 | PASS | 返回41条 active 状态患者 |
链路 B: 随访管理
| # | 测试项 | 方法+路径 | HTTP状态 | 结果 | 备注 |
|---|---|---|---|---|---|
| B1 | 查看随访列表 | GET /health/follow-up-tasks | 200 | PASS | 返回23条随访任务,含 overdue/pending/completed |
| B2 | 创建随访 | POST /health/follow-up-tasks | 200 | PASS | 成功创建 phone 类型随访 |
| B3 | 查看随访模板 | GET /health/follow-up-templates | 200 | PASS | 返回1条模板 |
| B4 | 创建随访模板 | POST /health/follow-up-templates | 200 | PASS | 成功创建 online 类型模板 (visit 类型无效,需用 phone/outpatient/home_visit/online/wechat) |
| B5a | 更新随访状态 pending->in_progress | PUT /health/follow-up-tasks/{id} | 200 | PASS | 状态机: pending -> in_progress 合法 |
| B5b | 更新随访状态 in_progress->completed | PUT /health/follow-up-tasks/{id} | 200 | PASS | 状态机: in_progress -> completed 合法 |
链路 C: 咨询管理
| # | 测试项 | 方法+路径 | HTTP状态 | 结果 | 备注 |
|---|---|---|---|---|---|
| C1 | 查看咨询列表 | GET /health/consultation-sessions | 200 | PASS | 返回10条会话,含 active/closed 状态 |
| C2 | 创建咨询会话 | POST /health/consultation-sessions | 200 | PASS | 成功创建 customer_service 类型会话 |
| C3 | 更新咨询状态 | PUT /health/consultation-sessions/{id} | 405 | ISSUE | PUT/PATCH/close 均返回 405,咨询会话无更新路由 |
| C4 | 发送咨询消息 | POST /health/consultation-messages | 200 | PASS | 成功发送文本消息 |
链路 D: 告警监测
| # | 测试项 | 方法+路径 | HTTP状态 | 结果 | 备注 |
|---|---|---|---|---|---|
| D1 | 查看告警列表 | GET /health/alerts | 200 | PASS | 返回5条告警,含 active/resolved 状态 |
| D2 | 查看告警规则 | GET /health/alert-rules | 200 | PASS | 返回12条规则 |
| D3 | 创建告警规则 | POST /health/alert-rules | 200 | PASS | 成功创建血压告警规则 |
| D4 | 查看危急值告警 | GET /health/critical-alerts | 500 | FAIL | 返回内部服务器错误 |
| D5 | 查看危急值阈值 | GET /health/critical-value-thresholds | 200 | PASS | 返回14条阈值配置 |
| D6 | 确认告警 (active->acknowledged) | PUT /health/alerts/{id}/acknowledge | 400 | ISSUE | 现有告警状态为 "active",不在合法的 "pending" 状态,无法转换。状态机: pending->acknowledged->resolved,但种子数据使用 "active" 状态(不存在于状态机中) |
| D7 | 更新告警规则 | PUT /health/alert-rules/{id} | 200 | PASS | 成功更新规则名称和描述 |
链路 E: AI 分析
| # | 测试项 | 方法+路径 | HTTP状态 | 结果 | 备注 |
|---|---|---|---|---|---|
| E1 | 查看分析历史 | GET /ai/analysis/history | 200 | PASS | 返回10条分析记录,含 trend/lab_report/checkup_plan/report_summary |
| E2 | 查看 Prompt | GET /ai/prompts | 200 | PASS | 返回4条 Prompt 模板 |
| E3 | 查看 AI 建议 | GET /ai/suggestions | 200 | PASS | 返回2条建议 (medication/referral) |
| E4a | 批准建议 | POST /ai/suggestions/{id}/approve | 200 | PASS | pending->approved 状态转换成功 |
| E4b | 执行建议 | POST /ai/suggestions/{id}/execute | 200 | PASS | approved->executed 状态转换成功 |
| E5a | 查看用量概览 | GET /ai/usage/overview | 200 | PASS | 返回 total_count: 8 |
| E5b | 按类型查看用量 | GET /ai/usage/by-type | 200 | PASS | 返回4种分析类型的用量分布 |
链路 F: 知情同意 + 日常监测
| # | 测试项 | 方法+路径 | HTTP状态 | 结果 | 备注 |
|---|---|---|---|---|---|
| F1 | 查看知情同意列表 | GET /health/patients/{id}/consents | 200 | PASS | 按患者 ID 查询,返回空列表 |
| F2 | 创建知情同意 | POST /health/consents | 200 | PASS | health_data_collection 类型同意创建成功 |
| F3 | 撤回知情同意 | PUT /health/consents/{id}/revoke | 200 | PASS | granted->revoked 状态转换成功 |
| F4 | 查看日常监测 | GET /health/patients/{id}/daily-monitoring | 200 | PASS | 按患者 ID 查询 |
| F5 | 添加监测记录 | POST /health/daily-monitoring | 200 | PASS | 成功创建血压监测记录 |
| F6 | 更新监测记录 | PUT /health/daily-monitoring/{id} | 200 | PASS | 成功更新血压数值和体重 |
团队视图
| # | 测试项 | 方法+路径 | HTTP状态 | 结果 | 备注 |
|---|---|---|---|---|---|
| T1 | 查看行动收件箱 | GET /health/action-inbox | 200 | PASS | 返回37条行动项,含 alert/ai_suggestion 类型 |
| T2 | 查看团队行动项 | GET /health/action-inbox?team=true | 200 | PASS | team 参数生效,返回团队视角的行动项 |
补充测试
| # | 测试项 | 方法+路径 | HTTP状态 | 结果 | 备注 |
|---|---|---|---|---|---|
| S1 | 查看医生列表 | GET /health/doctors | 200 | PASS | 返回10条医生记录 |
| S2 | 查看设备列表 | GET /health/devices | 200 | PASS | 返回空列表(health.devices.list 权限生效) |
| S3 | 创建化验报告 | POST /health/patients/{id}/lab-reports | 200 | PASS | health-data.manage 权限覆盖化验报告创建 |
| S4 | 查看医生仪表盘 | GET /health/doctor/dashboard | 200 | PASS | 返回仪表盘统计数据 |
| S5 | 查看管理仪表盘 | GET /health/admin/statistics/dashboard | 500 | FAIL | 返回内部服务器错误 |
权限边界
| # | 测试项 | 方法+路径 | 预期状态 | 实际状态 | 结果 | 备注 |
|---|---|---|---|---|---|---|
| P1 | 管理 BLE 网关 | POST /health/ble-gateways | 403 | 403 | PASS | 权限拒绝正确 |
| P2 | 创建预约 | POST /health/appointments | 403 | 403 | PASS | 无 appointment.manage,拒绝正确 |
| P3 | 创建医生 | POST /health/doctors | 403 | 403 | PASS | 仅有 doctor.list,拒绝正确 |
| P4 | 管理文章 | GET/POST /health/articles | 403 | 403 | PASS | 无 article 权限,拒绝正确 |
| P5 | 用户管理 | POST /auth/users | 403 | 404 | ISSUE | 路由不存在(非本角色测试重点) |
| P6 | 配置管理 | GET /config/menus | 403 | 403 | PASS | 无 config 权限,拒绝正确 |
问题清单
CRITICAL (0)
无。
HIGH (2)
-
D4: GET /health/critical-alerts 返回 500
- 影响: 健康管理师无法查看危急值告警列表
- 端点:
GET /api/v1/health/critical-alerts - 预期: 200 + 告警列表
- 实际: 500 Internal Server Error
- 权限码: health.critical-alerts.list (已分配)
-
S5: GET /health/admin/statistics/dashboard 返回 500
- 影响: 健康管理师无法查看管理仪表盘
- 端点:
GET /api/v1/health/admin/statistics/dashboard - 预期: 200 + 仪表盘统计数据
- 实际: 500 Internal Server Error
- 权限码: health.dashboard.manage (已分配)
MEDIUM (3)
-
D6: 告警状态数据不一致
- 影响: 现有告警数据状态为 "active",但状态机只接受 "pending" 作为起始状态
- 种子数据使用了未在状态机中定义的 "active" 状态值
- 建议: 修复种子数据,将 "active" 改为 "pending"
-
C3: 咨询会话无更新/关闭路由
- 影响: 健康管理师无法关闭或更新咨询会话状态
- PUT/PATCH/{id}/close 均返回 405
- 建议: 增加 PUT 或 POST close 路由
-
E5: AI 使用量路由与预期不一致
- 影响: /ai/usage 返回 404,实际路由为 /ai/usage/overview 和 /ai/usage/by-type
- 非阻塞: 功能通过正确路由可用
LOW (4)
-
A4b: 性别筛选返回过多结果
- gender=female 筛选返回41条,但其中包含 gender=null 的记录
- 可能是筛选逻辑问题或 null 记录本应排除
-
F5: 日常监测创建时 indicator_type/value 字段未实际写入
- 创建时传入了 indicator_type 和 value JSON,但返回记录中具体字段(如 morning_bp_systolic)为 null
- 需要额外的 PUT 请求才能填充具体数值
-
B4: 随访模板 follow_up_type 枚举不包含 "visit"
- 允许值: phone, outpatient, home_visit, online, wechat
- 前端如有 visit 选项需对齐
-
A3: GET /health/tags 返回 404
- 实际路由为 /health/patient-tags,文档或前端可能引用错误路径
权限验证总结
| 权限码 | 测试结果 | 说明 |
|---|---|---|
| health.patient.list | PASS | 患者列表查看正常 |
| health.patient.manage | PASS | 创建患者正常 |
| health.follow-up.list | PASS | 随访列表查看正常 |
| health.follow-up.manage | PASS | 创建/更新随访状态正常 |
| health.follow-up-templates.list | PASS | 模板列表查看正常 |
| health.follow-up-templates.manage | PASS | 创建模板正常 |
| health.consultation.list | PASS | 咨询列表查看正常 |
| health.consultation.manage | PASS | 创建会话+发送消息正常 |
| health.health-data.list | PASS (via lab-reports) | 化验报告相关操作正常 |
| health.health-data.manage | PASS | 创建化验报告正常 |
| health.daily-monitoring.list | PASS | 日常监测查看正常 |
| health.daily-monitoring.manage | PASS | 创建/更新监测记录正常 |
| health.alerts.list | PASS | 告警列表查看正常 |
| health.alerts.manage | PASS | 告警确认接口可用(受数据状态限制) |
| health.alert-rules.list | PASS | 规则列表查看正常 |
| health.alert-rules.manage | PASS | 创建/更新规则正常 |
| health.action-inbox.list | PASS | 个人收件箱查看正常 |
| health.action-inbox.manage | PASS (via follow-up) | 通过业务操作间接验证 |
| health.action-inbox.team | PASS | 团队视角查看正常 |
| health.dashboard.manage | FAIL (500) | 仪表盘统计接口500错误 |
| health.devices.list | PASS | 设备列表查看正常 |
| health.consent.list | PASS | 知情同意列表正常 |
| health.consent.manage | PASS | 创建/撤回同意正常 |
| health.critical-alerts.list | FAIL (500) | 危急值告警接口500错误 |
| health.critical-value-thresholds.list | PASS | 危急值阈值查看正常 |
| health.doctor.list | PASS | 医生列表查看正常 |
| ai.analysis.list | PASS | 分析历史查看正常 |
| ai.analysis.manage | PASS (via history) | 查看已有分析正常 |
| ai.prompt.list | PASS | Prompt 列表查看正常 |
| ai.suggestion.list | PASS | 建议列表查看正常 |
| ai.suggestion.manage | PASS | 批准/执行建议正常 |
| ai.usage.list | PASS | 使用量统计正常 |
结论
Health Manager (健康管理师) 角色测试结果: PASS_WITH_ISSUES
- 37个权限码中,35个验证通过(94.6%)
- 2个权限对应接口存在 500 错误(critical-alerts, admin-statistics-dashboard)
- 6条业务链路中,5条完全通过,1条(告警监测 D4)受接口错误阻塞
- 所有权限边界验证通过(无权限操作正确返回 403)
- 建议优先修复 2 个 HIGH 级别的 500 错误
测试执行者: API Tester (自动化测试)
测试环境: localhost:3000, PostgreSQL 16
测试账号: health_manager_test / Admin@2026