Commit 5c50cfc3 by luoqi

docs(refactor): 记录前置审发现 — source_unit 需加 3 张表(facts/return_visits 也撞键)

实施期 pre-check:patient_facts.subject_id 跨品牌撞 631、patient_return_visits
.external_id 撞 611,均品牌级,合 tenant 会撞键。故 source_unit 必须加在
patients + patient_facts + patient_return_visits 三张表;fact-writer 版本链
findFirst 也须按 source_unit 过滤。transactions(撞0)、relations(UUID)免。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
parent a5b0184b
......@@ -61,8 +61,17 @@
## 4. 真正要改的(集中、最小)
### 4.1 Schema
- `patients.source_unit`(nullable)+ 唯一键 `(host, tenant, source_unit, external_id)`
- **不加** org_units 表;子表**不冗余** source_unit。
> ⚠️ **实施期前置审推翻"只改 patients"**:合 tenant 前实测跨品牌撞键 —— 不止 external_id,
> `patient_facts.subject_id`(撞 **631**,键 `(host,tenant,subject_id,version)`)和
> `patient_return_visits.external_id`(撞 **611**)也是品牌级,合 tenant 会**撞键失败/改坏 fact 版本链**。
> 故 **source_unit 必须加在 3 张表**(不是只 patients)。`patient_transactions.source_event_id` 撞 0(全局唯一,免)、`patient_relations` 按 patientId(UUID)免。
- **patients**:`source_unit`(NOT NULL 默认 '')+ 键 `(host,tenant,source_unit,external_id)`。✅ 已做(P0-1/2)
- **patient_facts**:`source_unit` + 键 `(host,tenant,source_unit,subject_id,version)`;
`fact-writer.writeDraft`**版本链 findFirst** 必须按 source_unit 过滤(否则取错品牌版本)。
- **patient_return_visits**:`source_unit` + 键 `(host,tenant,source_unit,external_id)`
- **不加** org_units 表。
### 4.2 摄入(`data/jvs-dw/manifest.yaml` + 解析)
```yaml
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment