# patient — 主档 upsert(不进 transaction,无 emits)
# 直接消费 source table fact_client_out(transforms 不需要,fact_client_out 形态干净)
canonical: patient

primary:
  table: fact_client_out
  key: patient_id

field_mapping:
  externalId:           patient_id    # Int64 → ColdImportService 入库时 String 化
  # W4 末 DW upsert:updatedAt 进 source_event_id 幂等键,host UPDATE → 新 transaction(否则永久 dedup 漏 update)
  updatedAt:         last_visit_time
  createdAt:         first_visit_time
  name:                 client_name
  gender:               client_gender
  birthDate:            birthday
  medicalRecordNumber:  file_num       # 病历号(辅助标识,客服沟通用)
  notes:                follow_content
  # 专属客服(当前任务负责人)— 路由/指派属性,非画像特征。upsert 时并入 patients.preferences.dedicatedCs。
  #   时效:"当前"会换 → 存当前值(upsert 覆盖);用于详情页展示 + 推送人匹配。
  dedicatedCsName:      current_task_director
  dedicatedCsId:        current_task_director_id
  # doNotContact / deceased 不映射 — 走 PatientCanonicalSchema default false
