# treatment_actual — FRIDAY 本次治疗(med_emr_info.treat[] 拆行)
# 语义(用户确认,2026-07-18):treat[] = 本次治疗(actual);病历无计划字段(全字段枚举证实),
# 治疗计划走独立表 customer_treat_plan(见 treatment_planned.yaml)。
# 覆盖率注:treat 填充 25%(dispose 98% 是处置叙述 → emr_record.disposal 全文保留不丢);
# 若实践发现漏召,Phase 2 评估 dispose keyword 路由补 actual。
canonical: treatment

emits:
  action: treatment_completed
  subjectType: treatment
  occurredAtField: occurredAt
  kind: actual

primary:
  table: treatment_actual_rows
  key: treat_external_id
  dedup_by: treat_external_id

field_mapping:
  externalId:                  treat_external_id
  updatedAt:                   updated_gmt_at
  createdAt:                   created_gmt_at
  patientExternalId:           patient_id
  clinicId:                    organization_id
  occurredAt:                  clinic_time      # 就诊时刻(100% 填充)
  sourceEncounterExternalId:   emr_sub_id       # 同诊聚合锚
  category:                    category_raw     # 归一治疗名 → 共享字典翻 11 类闭集
  subtype:                     value            # 原始 treat 文本留作 subtype(chain milestone fallback)
  toothPosition:               tooth_position
  doctorId:                    user_id
  doctorName:                  user_name

# ── 字典分层:临床核心词 + keyword/strip(actual 语义变体)全在共享文件;FRIDAY 尚无宿主特有词 ──
# (测试库 treat 一半键盘乱敲 → 高频宿主词等生产数据回来后按 mapping-miss 巡检补这里)
dict_includes:
  - ../../_shared/dict/treatment-category-core.yaml
  - ../../_shared/dict/treatment-category-actual-rules.yaml

enum_mapping:
  category:
    # 拆线 = 术后护理 = 外科治疗动作(jvs-dw 2026-06-11 一线判例:归 review 不算治疗会误召;
    # 判例与 route 分流语境耦合 → 留宿主本地,不入共享层)。FRIDAY 实测 50 行。
    拆线: surgical
    # 长尾兜底:未命中 → category='',parser 跳过该 fact(数据损失换质量,jvs-dw 同款纪律)
    _default: ""
