# 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
  # doNotContact / deceased 不映射 — 走 PatientCanonicalSchema default false
