# treatment_planned — FRIDAY 治疗计划(消费 customer_treat_plan_item;头属性 organization_id/plan_name 由宿主 inline)
# 消费 transforms 输出表 treatment_planned_rows(item 过滤无诊所行 + normalize 术式名)
# 行粒度 = 计划行项(牙位 + 术式 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   # 宿主 inline 自计划头(行表原生无诊所)
  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: ""
