feat(pipeline): 实现健康档案 upsert 编排(T-213)

This commit is contained in:
ila
2026-07-16 01:06:43 +08:00
parent 8a5550057c
commit 3a30ebdc45
6 changed files with 640 additions and 7 deletions
+11
View File
@@ -350,3 +350,14 @@
- 安全:真实 PHIS payload 未复制入仓库;fixture 使用占位身份信息和假凭据,生产 DTO 不声明 `sxtAccount/sxtPassword`。
- 验证:`go test ./source -count=1`、`go test ./contract ./mapping -count=1`、`go test ./cache ./osi ./mapping -count=1`、`go test ./... -count=1`、`go vet ./...` 均通过。
- 下一步:T-213 健康档案 query-first upsert 应用编排。
## 2026-07-16 T-213 健康档案 query-first upsert 应用编排
- 状态:DONE。
- RED:`go test ./pipeline -count=1` 初次因 `HealthRecordUpsertService`、状态/动作、事件和注入端口均不存在而编译失败。
- GREEN:新增 `pipeline/health_record_upsert.go`;按身份证查询后仅在明确 0 条时创建,单条记录通过身份证、状态、机构、责任医生和 `phrId` 校验后更新,多条及不安全目标转 `manual_review`;查询/创建/更新失败按 `osi.Result.Retryable` 分类且不互相回退。
- 幂等:键为 `sha256(checkId + "|" + idCard)`;接口采用带 owner token 的原子 `Acquire/Complete/Release`,并发处理中直接 `retry/skip`,完成/释放校验 token,写入失败释放租约,明确成功后完成租约。
- 更新语义:查询目标单独建模 `UpdateTarget`,更新请求仅合并平台 `phrId`,源侧稳定 `checkId` 不被查询记录覆盖。
- 安全与边界:普通报告事件只含哈希 `trace_id`、业务状态、serviceId、响应码及脱敏 `phrId`,原始源标识只交给受控 PHIS 回写端口;`data:null`/缺失不得视为 0 条;幂等完成失败不发送 `done`,副作用失败通过 `NotificationError` 区分租约/报告/PHIS 回写错误并只暴露失败端补偿数据。持久化、重试调度、HTTP 和 PHIS 真实回写不在 T-213 实现。
- 验证:`go test ./pipeline -count=1`、`go test ./... -count=1`、`go build ./...`、`go vet ./...`、`git diff --check` 均通过。`bash ./init.sh` 在当前 PowerShell 调起的 Bash 环境失败(`go: command not found`),未误报通过;其内部等价 Go 命令已在 PowerShell 单独验证。
- 下一步:T-204 `POST /api/health-record/upsert` HTTP 适配;T-215 继续等待安全测试档案和写入授权。