Files
hms/wiki/index.md
iven 40b5141832
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
docs: 全面更新 wiki 文档至当前实现状态
9 个 wiki 页面全部更新:
- index: 关键数字更新(15 crate/48 表/50 迁移/6 模块)
- erp-health: 从"规划中"更新为"已实现"(18 实体/14 权限)
- erp-server: 6 模块注册/8 环境变量/5 后台任务
- database: 50 迁移/48 表/健康模块迁移(m000042-m000050)
- frontend: 10 健康路由/12 共享组件/7 健康 API/3 单元测试
- miniprogram: 20 页面/10 服务/9 组件
- testing: 93 后端测试+3 前端测试/全链路验证结果
- erp-core: 新增 erp-health 集成契约
- architecture: 6 模块实现状态表/预约 CAS/PII 加密
2026-04-25 11:57:20 +08:00

87 lines
5.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# HMS 健康管理平台 — 知识库
> **Health Management System (HMS)** — 面向体检中心/医疗机构的综合健康管理平台。从 ERP 底座分叉,继承身份权限/工作流/消息/配置等基础能力,`erp-health` 原生模块承载医疗业务。
## 关键数字
| 指标 | 值 |
|------|-----|
| Rust crate | 15 个7 核心 + erp-health + 6 插件 + erp-plugin-prototype |
| 数据库表 | 30 基础表 + 18 健康业务表(已实现) |
| 数据库迁移 | 50 个 |
| 核心模块 | 5 基础 (auth/config/workflow/message/plugin) + 1 业务 (health) |
| Web 前端页面 | 30 路由(含 10 健康管理路由) |
| 健康模块组件 | 11 个共享组件StatusTag/PatientSelect/DoctorSelect/VitalSignsChart 等) |
| 微信小程序 | Taro 4.2 + React 1820 个页面 |
| 前端单元测试 | 3 个vitest+ 4 E2E specplaywright |
| 后端测试 | 36 个workspace+ 57 validation 纯函数测试 |
| API 文档 | `http://localhost:3000/api/docs/openapi.json` |
## 症状导航
| 症状 | 先查 | 再查 | 常见根因 |
|------|------|------|----------|
| API 返回 403 | 权限码检查 | [[wasm-plugin]] 权限系统 | 权限码不匹配 / 缺少 .list 权限 |
| API 返回 500 无日志 | [[erp-core]] 错误链 | 后端 tracing 输出 | AppError::Internal 静默 |
| 数据库连接失败 | [[infrastructure]] | PostgreSQL 服务状态 | 服务未启动 / 环境变量未设置 |
| 前端 401 刷新时 | [[frontend]] auth store | API client token 刷新 | token 过期未主动刷新 |
| 迁移执行失败 | [[database]] | PostgreSQL 日志 | 表冲突 / 唯一索引 + 软删除 / 缺失迁移文件 |
| 端口被占用 | [[infrastructure]] dev.ps1 | 端口 5174-5189 进程 | 残留 Vite 进程 |
| 预约创建 400 doctor_id is required | [[erp-health]] 预约并发控制 | AppointmentList.tsx | 医生字段为必填(后端 CAS 要求) |
| 预约超额 | [[erp-health]] 排班并发 | appointment CAS 操作 | 并发控制未走原子 CAS |
| 患者创建 422 birth_date trailing input | [[frontend]] 日期序列化 | DatePicker dayjs 对象 | 未格式化为 YYYY-MM-DD 字符串 |
| 跨租户数据泄漏 | [[architecture]] 多租户策略 | [[database]] tenant_id | 查询缺少 tenant_id 过滤 |
| 小程序页面空白 | [[miniprogram]] defineConstants | `process.env` 未替换 | 编译时未注入环境变量 |
| 小程序登录失败 `btoa is not defined` | [[miniprogram]] secure-storage | Web API 不可用 | 使用 `Taro.arrayBufferToBase64` 替代 |
| 微信登录 500 | [[database]] wechat_users 表结构 | Entity 字段与表不匹配 | 补 `created_by/updated_by/version` 列 |
| 迁移文件缺失报错 | [[database]] 迁移注册 | migration/src/lib.rs | 已应用的迁移文件被删除,需创建 stub |
## 模块导航
### 基础层(继承自 ERP 底座)
- [[erp-core]] — 错误体系 · 事件总线 · 模块 trait · 共享类型
- [[architecture]] — 架构决策 · 设计原则 · 技术选型
### 业务层(继承自 ERP 底座)
- erp-auth — 用户/角色/权限/组织/部门/岗位 · JWT · RBAC · 行级数据权限
- erp-config — 字典/菜单/设置/编号规则/主题/语言
- erp-workflow — BPMN 解析 · Token 驱动 · 任务分配
- erp-message — 消息 CRUD · 模板 · 订阅 · 通知面板
- erp-plugin — WASM 运行时 · 动态表 · 热更新HMS 保留但非主要扩展方式)
### 核心业务层HMS 专属)
- [[erp-health]] — **患者管理 · 健康数据 · 预约排班 · 随访管理 · 咨询管理**(原生 Rust 模块,已实现)
### 组装层
- [[erp-server]] — Axum 入口 · AppState · 6 模块注册 · 后台任务 · 优雅关闭
### 患者端
- [[miniprogram]] — **微信小程序** · Taro 4.2 · 微信登录 · 手机绑定 · 健康数据查看
### 基础设施
- [[infrastructure]] — 连接信息 · 环境变量 · 一键启动 (**单一真相源**)
- [[database]] — SeaORM 迁移 · 多租户表结构
- [[frontend]] — React 19 SPA · 健康管理页面13 页面 + 11 组件)
- [[testing]] — 验证清单 · 测试分布 · 性能基准
## 核心架构问答
**为什么 erp-health 用原生模块而非 WASM 插件?** 医疗业务需要 18 强类型实体、自定义 API趋势分析/统计报表)、文件上传(化验单/体检报告)、未来 AI 集成,超出 WASM 插件能力范围。详见 [[erp-health]]。
**模块间如何通信?** [[erp-core]] EventBus 发布/订阅 DomainEvent。erp-health 发布 `patient.created``appointment.confirmed` 等事件,订阅 `workflow.task.completed` 等。详见 [[architecture]]。
**多租户怎么隔离?** 共享数据库 + `tenant_id` 列过滤,中间件从 JWT 注入。详见 [[database]] [[architecture]]。
**患者/医护与 erp-auth 的关系?** 账号走 `users`erp-health 通过 `user_id` 外键关联扩展字段(科室、职称、档案等)。患者可先建档后绑定账号。
## 文档索引
| 类型 | 位置 |
|------|------|
| 健康模块设计规格 | `docs/superpowers/specs/2026-04-23-health-management-module-design.md` |
| QA 审计计划 | `plans/qa-review-brainstorm-floofy-finch.md` |
| 设计规格 | `docs/superpowers/specs/` |
| 实施计划 | `docs/superpowers/plans/` |
| 协作规则 | `CLAUDE.md` |
| 插件制作指南 | `.claude/skills/plugin-development/SKILL.md` |