# treatment_planned — FRIDAY 治疗计划(customer_treat_plan + _item 独立表;用户确认此表为治疗计划)
# 消费 transforms 输出表 treatment_planned_rows(行表 lookup 头表拿 organization_id/plan_name)
# 行粒度 = 计划行项(牙位 + 术式 mode_name + 价格区间);externalId = 行表主键(host 稳定)
canonical: treatment

emits:
  action: treatment_planned
  subjectType: treatment
  occurredAtField: occurredAt
  kind: planned

primary:
  table: treatment_planned_rows
  key: id
  dedup_by: id

field_mapping:
  externalId:                  id
  updatedAt:                   updated_gmt_at
  createdAt:                   created_gmt_at
  patientExternalId:           customer_id
  clinicId:                    organization_id   # lookup 自头表(行表无诊所)
  occurredAt:                  created_gmt_at    # 计划制定时点
  category:                    mode_norm         # 归一术式名 → 共享字典翻 11 类闭集
  subtype:                     mode_name         # 原始术式名
  toothPosition:               tooth_position
  planName:                    plan_name         # 方案名(passthrough,展示用)

# ── 字典分层:planned 语义变体(不剥"建议/拟"措辞,只剥条件词)──
dict_includes:
  - ../../_shared/dict/treatment-category-core.yaml
  - ../../_shared/dict/treatment-category-planned-rules.yaml

enum_mapping:
  category:
    _default: ""
