Commit Graph

76 Commits

Author SHA1 Message Date
iven
32df9c0655 feat(web): 随访模板管理页面 — CRUD + 路由 + 菜单迁移
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
- 新增 FollowUpTemplateList.tsx 页面(列表/新建/编辑/详情弹窗)
- 新增 followUpTemplates.ts API 客户端(list/get/create/update/delete)
- 注册路由 /health/follow-up-templates + 菜单标题 fallback
- 新增迁移 seed_follow_up_template_menu 注册菜单和权限
2026-05-03 09:31:43 +08:00
iven
e8ee441ae1 feat(health): Track 3 医疗阈值 — warning 种子 + 患者端只读 API
- 新增 6 条 warning 级别阈值种子数据(血压/心率/血糖参考范围)
- 新增 GET /health/critical-value-thresholds/public 患者端只读接口
- 扩展 indicator 验证支持 blood_sugar_fasting/postprandial 等新指标
2026-05-02 11:37:21 +08:00
iven
23cd62a70f feat(db): 健康模块字典种子数据 — 6 个字典 + 43 个条目
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
- health_department (11 科室)
- health_title (9 职称)
- health_device_type (8 设备类型)
- health_follow_up_type (5 随访类型)
- health_consultation_type (3 咨询类型)
- health_relationship (5 关系类型)
2026-05-02 11:34:35 +08:00
iven
f13a240000 fix(migration): 修复权限关联 — 使用 permission_id 外键关联
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
2026-05-01 18:38:03 +08:00
iven
a174f88b6f fix(migration): 修复表名 tenants → tenant(单数)
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
2026-05-01 18:36:26 +08:00
iven
5261468953 fix(migration): 修复行动收件箱菜单迁移 — 使用正确的 menus 表字段
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
2026-05-01 18:34:22 +08:00
iven
4cde4acddc feat(migration): 行动收件箱菜单种子数据 + 权限关联
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
2026-05-01 17:41:41 +08:00
iven
577d2a32b1 feat(db): 添加 ai_suggestion 和 ai_risk_threshold 表迁移
- ai_suggestion: AI 建议记录表,含 tenant_id、analysis_id、suggestion_type、
  risk_level、status、params、baseline_snapshot 等字段
- ai_risk_threshold: 租户级风险阈值配置表,按 metric_name + tenant_id 唯一索引
- 两表均包含标准审计字段和 version_lock 乐观锁
2026-05-01 08:04:51 +08:00
iven
32eef5ecf1 feat(db+test): 菜单权限关联迁移 + 适配 create_message 签名变更
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
- 新增迁移 m097:为 17 个已有菜单设置 permission 字段,新增透析管理/资讯管理 2 个菜单
- 修复 consultation/pii_encryption 测试适配 create_message(sender_id, sender_role) 分离参数
2026-04-30 10:37:43 +08:00
iven
26a9781d4f feat(health): 药物提醒后端 API + 后台任务统一 + dead code 清理
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
P1-3: medication_reminder 全栈实现
  - migration 000096: 创建 medication_reminder 表(含患者关联/提醒时间/频率)
  - entity + dto + service + handler: 完整 CRUD(乐观锁/软删除/审计日志)
  - 路由注册: GET /patients/{id}/medication-reminders, POST/PUT/DELETE
  - HealthError 新增 MedicationReminderNotFound

P2-4: 后台任务启动统一
  - appointment_reminder 迁移到 HealthModule::on_startup()(启动时立即执行 + 周期循环)
  - 删除 main.rs 中重复的 overdue_checker/points_expiration/appointment_reminder 调用
  - 所有 Health 后台任务现由模块 on_startup 统一管理

P2-5: Web dead code 清理
  - 删除 healthData.ts 中 getMiniTrend/getMiniToday(小程序专用端点,Web 无调用)
  - 删除 patients.ts 中 getHealthSummary(标记 TODO 未使用)
2026-04-30 07:18:22 +08:00
iven
cac61637ce feat(health): Web 管理端设备数据集成补全 — Phase 2
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
- 新增告警三页面(仪表盘/列表/规则)+ 设备管理菜单种子数据
- 新增设备管理后端 API(GET /devices + DELETE /devices/{id})
- 新增设备数据查看组件 DeviceReadingsTab(原始数据 + 小时聚合)
- 新增设备管理页面 DeviceManage(列表/筛选/解绑)
- 患者详情页新增设备数据 Tab
2026-04-29 06:28:30 +08:00
iven
f6ccb8a35c fix(health): 设备数据管线 Phase 1 缺陷修复 + AI 产品策略讨论
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
- device_readings 批量插入添加 ON CONFLICT 去重唯一索引
- 小程序 BLEManager 增加离线缓存(Storage 持久化 + 启动重传)
- 新增 device_readings 90 天数据保留清理定时任务
- 小米手环适配器增加 RACP 历史心率读取支持
- SSE 告警按医生过滤已确认实现(patient_doctor_relation)
- 新增 AI 产品策略与设备数据医院场景讨论记录
2026-04-29 06:17:23 +08:00
iven
cf844a561f feat(ai+db): 趋势分析 prompt 升级为结构化统计摘要
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
- 新增迁移 000093:更新 health_trend_analysis prompt,使用统计字段
  替代原始数据点遍历,引导 AI 专注 slope/R²/异常点分析
- erp-ai handler: stream_trends 改用 get_trend_analysis_data()
  替代 get_vital_signs(),传递预计算趋势特征
- sanitizer: 新增 sanitize_trend_analysis() 方法
2026-04-28 19:57:51 +08:00
iven
83e243f03e feat(db): device_readings 新增 metric 字段用于多行拆分存储 2026-04-28 19:24:32 +08:00
iven
be8fca1d76 feat(core): EventBus dead-letter + consume_with_retry 辅助函数
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
- 新增 dead_letter_events 表 + Entity
- consume_with_retry: 幂等检查 + 成功标记 + 失败转入 dead-letter
- insert_dead_letter: 写入失败事件供后续排查和手动重试
2026-04-28 11:47:44 +08:00
iven
644efce760 feat(health): 新增 critical_alerts + critical_alert_responses 表 + Entity
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
危急值告警数据模型:status(pending/acknowledged/resolved/escalated)、
escalation_level 分级升级、乐观锁、软删除。
2026-04-28 11:34:37 +08:00
iven
298e439fb2 feat(health): 新增 blind_indexes 表 + Entity 支持 PII 盲索引搜索
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
2026-04-28 11:31:54 +08:00
iven
9dd6095e77 fix: P0/P1 安全与质量缺陷修复 — 10 项 QA 审查问题解决
Some checks failed
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
P0 安全修复:
- tenant_rls: SQL 拼接改为参数化查询防止注入
- follow_up_service: UUID SQL 拼接改为参数化原生查询
- RLS 策略: 新迁移移除空字符串绕过条件
- SSE 消息推送: token 键名 'token' → 'access_token' 修复
- rate_limit: 登录端点 Redis 不可达时 fail-close

P1 质量修复:
- 小程序缓存清理: preservedKeys 补全认证键名
- 小程序 token 刷新: 失败时清除所有认证数据
- 小程序 401: redirectTo → reLaunch 兼容 tabBar
- 集成测试: 信号量限制并行数据库创建(4个)
- change_password: 乐观锁 version 硬编码 → 动态递增

测试: 516 全部通过 (含 153 集成测试)
2026-04-28 00:57:41 +08:00
iven
30f2452933 fix(core): 迁移修复 + 配置调整
- auth_state: 新增字段
- config/default.toml: 配置更新
- migration 078/082: 修复 SQL 语法
- state/main: 启动逻辑调整
2026-04-28 00:20:11 +08:00
iven
22ef5b6d1f feat(core): 审计日志哈希链 — prev_hash + record_hash + 完整性验证
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
- 迁移 087: audit_logs 表添加 prev_hash/record_hash 列 + 索引
- audit_service::record() 写入时查询前一条 record_hash 作为 prev_hash
- SHA256(id+action+resource_type+resource_id+created_at+prev_hash) 计算 record_hash
- verify_hash_chain() 验证链完整性,返回 (总记录数, 断链数)
2026-04-27 19:38:39 +08:00
iven
d5c9654370 fix(db): 修复迁移 084/085 SQL 语法 + RLS 动态表名查询
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
- 084/085: PostgreSQL DELETE 不支持 LIMIT,改用 ctid IN (SELECT ... LIMIT)
- 086: RLS 迁移改为动态查询 information_schema 获取含 tenant_id 的表,
  避免硬编码表名不一致问题
- 全量测试 490 个通过(含 27 个集成测试 + RLS 验证)
2026-04-27 18:52:03 +08:00
iven
b7b9f50d00 feat(db): RLS 策略迁移 — 80 张 tenant_id 表启用行级安全
- 所有含 tenant_id 的表(基础 34 + 健康 28 + 其他 18)启用 RLS
- 策略:未设置 app.current_tenant_id 时允许全部,设置后按 tenant_id 过滤
- down 方法完整回退(DROP POLICY + DISABLE ROW LEVEL SECURITY)
2026-04-27 18:40:07 +08:00
iven
3197dde33c feat(core): 事件归档 + 消费者幂等性 — 迁移 084/085 + 清理任务
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
- 迁移 084: domain_events_archive 归档表 + cleanup_old_published_events()
- 迁移 085: processed_events 去重表 + cleanup_old_processed_events()
- erp-core: is_event_processed() / mark_event_processed() 幂等性辅助
- erp-server: tasks::start_event_cleanup() 每 24h 归档 >90 天事件
2026-04-27 18:12:43 +08:00
iven
dc5879228e feat(health): 随访模板系统 — follow_up_template + template_field 全栈
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
新增随访模板和模板字段两张表及完整 CRUD:
- 迁移 083: follow_up_template + follow_up_template_field
- Entity: 模板(名称/类型/适用范围/状态) + 字段(标签/键名/类型/选项/校验)
- DTO: 创建时内嵌字段列表、更新支持全量替换字段
- Service: 随访类型+字段类型校验、级联软删除
- Handler: 5 端点 + RBAC 权限
- 路由: /api/v1/health/follow-up-templates
2026-04-27 14:40:28 +08:00
iven
a2c1b5ece8 feat(db): 注册透析处方迁移 + AI Prompt 种子数据(4 个默认模板)
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
- 注册遗漏的 m20260427_000081_create_dialysis_prescription 迁移
- 新增 000082 种子迁移:插入 4 个 AI Prompt 模板
  (化验单解读/趋势分析/体检方案/报告摘要)
2026-04-27 12:50:16 +08:00
iven
bab0d6619b feat(health): 用药记录实体 — CRUD 全栈
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
- 迁移 080: medication_record 表(18 字段 + 频率/给药途径校验)
- Entity/DTO/Service/Handler 全链路
- 端点: GET/POST/PUT/DELETE /health/medications + /health/patients/{id}/medications
- 软删除 + 乐观锁 + 审计日志
2026-04-27 11:45:49 +08:00
iven
67f2d07809 feat(health): 体征增加体温/SpO2/血糖类型字段
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
- 迁移 079: vital_signs 表新增 body_temperature/spo2/blood_sugar_type 列
- Entity/DTO/Service 全链路支持新字段
- blood_sugar_type: fasting/postprandial/random/ogtt
- daily_monitoring 兼容层补全新字段为 None
2026-04-27 11:31:40 +08:00
iven
7e66561a5f fix(health): 统一随访类型为 5 种 — phone/outpatient/home_visit/online/wechat
- validation.rs: face_to_face 替换为 outpatient,新增 home_visit/wechat
- FollowUpTaskList.tsx: 新增 online 选项,与后端对齐
- 迁移 078: follow_up_task + follow_up_record face_to_face → outpatient
2026-04-27 11:20:57 +08:00
iven
5b81a0051f docs: 修正测试策略 spec 的事实性错误
修正 spec review 发现的问题:
- C-1: TestDb 实际是本地 PostgreSQL 隔离,非 Testcontainers
- C-2: E2E 已有 4 spec/10 测试,非零测试
- 补充 6 个遗漏的 service(alert/daily_monitoring/critical_value_threshold 等)
- 增加 Phase 0 基础设施搭建
- 修正 CI 配置(增加 PostgreSQL service、验证链)
- 补充 5 个遗漏风险项和回退策略
- 统一"全量 80%"目标的准确含义
2026-04-27 00:21:02 +08:00
iven
ebc0f20e33 test(health): PII 加密集成测试 + 性能基准 + 编译修复
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
- 10 个集成测试: CRUD 加密流(8) + 多租户隔离(2)
- 3 个性能基准: encrypt avg 17μs, decrypt avg 14μs, 批量50条 877μs
- 8 个 key_manager 单元测试 + 4 个 masking 边界测试
- 迁移: 加宽 emergency_contact_phone/phone/license_number/result 列
- 修复: follow_up_service.create_record 返回密文改为解密返回
- 修复: consultation_service/patient_service HealthError::NotFound 引用
2026-04-26 13:10:53 +08:00
iven
731e080125 feat(health): dialysis/lab_report/diagnosis PII 加密
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
- 迁移 m000069-m000071: 三个表添加 key_version
- dialysis_record: symptoms(JSON) + complication_notes 加密
- lab_report: items(JSON) + doctor_notes 加密
- diagnosis: notes 加密
- JSON 字段: serialize → encrypt → Value::String(ciphertext)
- 解密失败时回退原始值(兼容未迁移明文数据)
2026-04-26 12:35:27 +08:00
iven
cb3653c92e feat(health): family_member + doctor_profile PII 加密
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
- 迁移 m000067: patient_family_member 添加 phone_hash + key_version
- 迁移 m000068: doctor_profile 添加 license_number_hash + key_version
- family_member: phone 加密 + HMAC 索引 + 列表脱敏
- doctor_profile: license_number 加密 + HMAC 搜索重写 + 详情解密
- 列表中 Tier 1 字段返回 None
2026-04-26 12:23:10 +08:00
iven
1b3caf0e69 feat(health): consultation_message + follow_up_record PII 加密
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
- 迁移 m000065/m000066: 添加 key_version 列
- consultation_message: content 加密写入 + 解密读取
- follow_up_record: result/patient_condition/medical_advice 加密
- Entity: 添加 key_version 字段
2026-04-26 12:17:49 +08:00
iven
e6f036eaf4 feat(health): patient_service 集成 PiiCrypto — 电话/过敏史/病史加密
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
- HealthState.crypto: HealthCrypto → PiiCrypto (erp-core)
- create_patient: 加密 phone/allergy/medical_history + HMAC 索引
- update_patient: 同上,同步加密
- model_to_resp_decrypted: 解密所有 Tier 1 字段
- model_to_resp (列表): Tier 1 字段返回 None
- list_patients 搜索: 新增 phone hash 精确搜索
- article handler: 适配新 list_articles 签名
- article 迁移: 添加 category_id 列
- error.rs: From<String> for HealthError
- 集成测试: HealthCrypto → PiiCrypto::dev_default()
2026-04-26 10:37:52 +08:00
iven
e0b299ccd4 feat(health): patient entity PII 伴生字段 + content_management 编译修复
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
- 迁移 m000064: patient 添加 emergency_contact_phone_hash + key_version
- patient Entity 补充对应字段
- 修复 content_management 迁移: exec_stmt → execute_unprepared
- 修复 article_service: 补全新字段 (status/slug/content_type 等)
- 修复 article_article_tag: 复合主键注解
2026-04-26 10:27:58 +08:00
iven
4ab189283e feat(health): P0 平台基座回顾 — 7项上线前必修
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
P0-1: 危急值告警消费者 — health_data.critical_alert 事件推送给责任医护
P0-2: 危急值阈值可配置化 — 硬编码改为数据库配置(critical_value_threshold表),支持科室/年龄差异化
P0-3: daily_monitoring合并后告警验证 — update_vital_signs也触发危急值检测
P0-4: 随访逾期通知+幂等保护 — 只通知本次新标记的逾期任务,避免重复
P0-5: 知情同意记录(consent) — 新增实体/迁移/Service/Handler,PIPL合规
P0-6: 审计日志补全 — 患者更新记录前后值(过敏史/病史/状态变更)
P0-7: EventBus持久化增强 — 两阶段提交(pending→published)+启动时outbox relay恢复
2026-04-26 03:37:31 +08:00
iven
e3177f262c feat(config): 菜单动态化改造 — 侧边栏从后端 API 加载
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
- 新增 seed 迁移插入完整菜单树(4 directory + 23 menu = 27 条)
- 新增 GET /api/v1/menus/user 端点(仅需登录,无需 menu.list 权限)
- MainLayout 从 API 动态获取菜单树替换硬编码数组
- 扩展图标映射表覆盖 22 个 Ant Design 图标
- Header 标题从动态菜单数据查找,保留 fallback
2026-04-26 01:55:01 +08:00
iven
b4735213c5 feat(health): Phase 1 业务改进 — 诊断编码/统计API/体征表合并/积分修复
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
1.1 Dashboard 统计: 新增 3 个统计端点 (patient/consultation/follow-up)
1.2 事件发布: follow_up.overdue + health_data.critical_alert 事件
1.3 体征表合并: vital_signs 添加 source 列, daily_monitoring 委托写入
1.4 实时预警: 创建体征时检测血压/心率/血糖异常并发布事件
1.5 诊断编码: 新建 diagnosis entity/service/handler + ICD-10 支持
1.6 积分过期: expire_points 定时任务 + 修复 r#type 列名问题

修复: points_transaction.r#type → transaction_type 列重命名
修复: consultation_message.sender_type → sender_role SQL 列名
前端: 3 个统计 API 从伪实现改为真实调用
2026-04-26 00:54:56 +08:00
iven
e8a794ff69 fix(health): 穷尽审计修复 — 3 CRITICAL + 3 HIGH + 2 MEDIUM
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
CRITICAL:
- earn_points 日上限检查用 patient_id 比对 account_id 字段,上限永远不会触发
- verify_order 用 check_version(v, v) 旁路乐观锁,并发核销可能重复
- admin_checkin_event 同样的乐观锁旁路

HIGH:
- FIFO 消费循环改用数据库级 CAS 替代应用层 update_many
- 兑换流程账户余额/库存扣减全部改用 CAS 防并发超卖
- verify_order 改用 update_many + version filter 的原子操作

MEDIUM:
- points_checkin entity 补全 updated_at/updated_by/deleted_at/version 字段
- 新增迁移 m20260425_000055 添加列
- daily_checkin 打卡记录+积分获取+阶梯奖励合并为同一事务
- 删除废弃的 check_streak_bonus 独立函数(被 check_streak_bonus_in_txn 替代)
2026-04-25 19:44:46 +08:00
iven
eb937d3d02 feat(health): 日常监测后端 + 积分商城 PC 管理页面 (Chunk 3 V2 迭代)
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
后端 - 日常监测:
- 新增 daily_monitoring 表 (血压/体重/血糖/出入量/备注)
- Entity/DTO/Service/Handler 完整 CRUD
- 唯一约束 (patient_id, record_date) 防重复上报

前端 - 积分商城管理 (3 页面):
- PointsRuleList: 积分规则增删改 + 启用禁用
- PointsProductList: 商品管理 + 库存 + 类型筛选
- PointsOrderList: 订单列表 + 扫码核销
- API 模块 points.ts 对接 6 个管理端接口
- 侧边栏新增积分规则/商品管理/订单管理入口
2026-04-25 17:24:32 +08:00
iven
4ab67ba559 feat(health): 积分商城后端完整实现 (Chunk 2 V2 迭代)
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
- 新增 8 张数据库表: points_account/rule/transaction/product/order/checkin + offline_event/registration
- SeaORM Entity: 8 个实体,含完整 Relation 定义
- DTO: 积分规则/商品/订单/签到/线下活动请求响应类型
- Service: FIFO 积分消费、每日打卡(连续奖励)、商品兑换(QR码核销)、线下活动报名
- Handler: 16 个 API 端点 (患者端10 + 管理端6)
- 权限: health.points.list / health.points.manage
- 12个月滚动过期机制
- 审计日志全量覆盖
2026-04-25 16:51:38 +08:00
iven
f0e7c4424a feat(db): 添加 ai_prompts / ai_analysis_results / ai_usage_logs 迁移
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-25 13:51:50 +08:00
iven
16c63925ce feat(health): V2 血透专科数据模型 — dialysis_record + lab_report 审阅流程
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
- 新增 dialysis_record 表和完整 CRUD API(透析日期/体重/血压/超滤量/透析类型/症状)
- ALTER lab_report 增加 source/status/reviewed_by/reviewed_at 字段
- 重命名 lab_report: indicators→items, doctor_interpretation→doctor_notes
- 新增透析记录审阅端点 PUT /dialysis-records/{id}/review
- 新增化验报告审阅端点 PUT /patients/{id}/lab-reports/{rid}/review
- 化验报告 items JSON 支持 V2 结构(name/value/unit/reference/is_abnormal)
- 迁移 m000051 含完整 up/down 回滚
- 94 个后端测试全部通过,API 全链路验证通过
2026-04-25 13:45:11 +08:00
iven
355e8da272 fix(health): 全链路流通性验证修复
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
- 创建 stub migration 解决缺失文件报错
- PatientList/PatientDetail: DatePicker dayjs 对象序列化为 YYYY-MM-DD
- AppointmentList: 预约类型与后端验证对齐(outpatient/recheck/health_checkup/consultation/dialysis)
- AppointmentList: 医生字段改为必填(后端 CAS 排班要求), destroyOnClose→destroyOnHidden
- Home.tsx: 补充审计日志 action 翻译(created/login_failed 等)

全链路验证通过: 医生CRUD→排班→预约创建+状态流转→随访生命周期→咨询会话+消息→患者详情+健康数据
2026-04-25 11:31:54 +08:00
iven
0bf1822fa9 fix: QA 第二轮修复 — PatientDetail 重构/测试覆盖/id_number 列宽/小程序 URL 规范化
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
- refactor(web): PatientDetail.tsx 拆分为 4 个子组件(737→334行)
- refactor(web): 提取 usePaginatedData hook 消除重复分页状态
- feat(db): patient.id_number varchar(20)→varchar(255) 容纳加密值
- test(health): 添加预约模块集成测试(创建/列表/租户隔离)
- test(plugin): 添加 6 个 SQL 注入 sanitize 测试
- fix(miniprogram): 7 个 service 文件 URL 构建规范化(params 对象)
- fix(miniprogram): 跨平台字段名对齐(birth_date/start_time/end_time)
2026-04-25 10:22:44 +08:00
iven
07f4ba41ba fix(health): 穷尽审计修复 — 权限同步/编译错误/前端bug/审计日志
Some checks failed
CI / frontend-build (push) Has been cancelled
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / security-audit (push) Has been cancelled
审计发现并修复的问题:

HIGH:
- H1: ConsultationDetail 使用 getSession(id) 替代错误的列表搜索
- H2: SessionResp 添加 version/updated_at 字段
- H3: 移除 FollowUpRecordList 调用不存在的导出端点
- H4: 新增 articles.ts 前端 API 模块

MEDIUM:
- M1: article delete 添加乐观锁 (expected_version)
- M2: 取消预约排班释放传播错误 (log::warn -> ?)
- M3: FollowUpTaskList 日期格式 Dayjs -> string
- M4: 补充 15 个缺失审计日志

LOW:
- L1: 替换 follow_up_service 中的 .unwrap()
- L2: PatientListItem 添加 version 字段

CRITICAL (新发现):
- 权限未同步: 健康模块 14 个权限从未写入数据库,添加启动时自动同步
- migration 表名错误: patients -> patient
- 编译错误: health_trend entity 未导入, ToPrimitive trait 未导入
- HealthError 缺少 From<AppError> 实现
2026-04-25 08:58:58 +08:00
iven
6c70e2a783 feat(health): 身份证号 AES-256-GCM 加密 + HMAC 索引 + 字段级脱敏
- crypto.rs: AES-256-GCM 加密/解密 + HMAC-SHA256 索引
- create/update: id_number 加密存储, id_number_hash 索引
- list: 不返回 id_number, 手机号掩码
- detail: 解密后身份证掩码(前3后4), 手机号掩码
- 搜索: 改用 HMAC 精确匹配(不再模糊搜索加密列)
- 迁移 m000048: 添加 patients.id_number_hash 列
2026-04-25 00:21:49 +08:00
iven
a0ca156e2c fix(health): 精准审计修复 6 个真实问题 — 安全/一致性/性能
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
P0: consultation handler sender_role 从请求体移除,改为服务端推导(防伪造)
P1: 所有软删除操作统一使用 check_version 乐观锁(6个函数)
P1: 修复 health_trend 索引缺少 tenant_id 前导列 + follow_up_record 补 (tenant_id, executed_date) 索引
P2: Decimal->f64 使用 ToPrimitive::to_f64 替代脆弱的 to_string().parse()
P2: 预约取消释放槽位+状态更新包裹进同一事务
2026-04-24 08:36:22 +08:00
iven
ef6d76ef6c fix(miniprogram+auth): 二次审计修复 — 3 HIGH + 2 MEDIUM
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
HIGH:
- wechat_users 迁移补充 created_by/updated_by/version 标准字段
- Entity 同步更新,bind_phone 创建记录时填充新字段
- appointment create 移除 schedule_id 空字符串,改为可选
- appointment list 用 useRef 替代 useCallback 的 loading 依赖,消除 stale closure

MEDIUM:
- report 页 patientId 从顶层读取改为 useDidShow 内动态获取,就诊人切换后正确刷新
- profile/reports 同上修复
- profile/followups 移除 useDidShow 非法的第二参数
2026-04-24 08:05:58 +08:00
iven
4867202437 fix(health): 四次审计修复 — 6 CRITICAL + 8 HIGH + 4 MEDIUM
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
CRITICAL:
- C-1: consultation sender_id 改为从 JWT ctx.user_id 注入,防伪造
- C-2: consultation session 更新改为 CAS 原子操作,防并发丢失
- C-3: 随访记录创建包裹在事务中,保证记录/任务/后续任务一致性
- C-4/C-5/C-6: 唯一索引改为 partial index WHERE deleted_at IS NULL

HIGH:
- H-1: manage_patient_tags 添加 tag_ids 租户归属校验
- H-2: assign_doctor 添加重复关联检查
- H-3: calendar_view 限制日期范围最多 90 天
- H-4: export_sessions 添加 10000 条上限
- H-5: patient_tag_relation/patient_doctor_relation 添加 version 字段
- H-6: create_schedule 添加医生存在性检查
- H-7: 预约取消排班释放错误改为日志记录
- H-8: follow_up_task.related_appointment_id 添加 FK 约束

MEDIUM:
- M-2: 修复 search LIKE 双重 % 包裹问题
- M-3: article_service 错误类型改为 ArticleNotFound
- M-4: patient.created 事件移除 PII(姓名)
- M-6: lab_report 添加 (tenant_id, report_type) 索引
2026-04-24 07:50:14 +08:00