# appointment — 全部预约(含未到诊)
# 消费 transforms 输出表 appointment_all_rows(等同 source fact_appointment_out,project 直通)
canonical: appointment

emits:
  action: appointment_created
  subjectType: appointment
  occurredAtField: scheduledAt

primary:
  table: appointment_all_rows
  key: id

field_mapping:
  externalId:        id
  patientExternalId: patient_id
  clinicId:          organization_id
  scheduledAt:       appo_time
  arrivedAt:         in_time
  appointmentType:   appo_type
  doctorId:          appo_doc_id
  status:            appo_status

# host appo_status:1=正常预约 / 2=已改约 / 3=已取消 / 4=到诊 / 5=接诊 / 6=结算 /
#                  8=walk in变更 / 9=爽约
enum_mapping:
  status:
    "1": scheduled
    "2": scheduled
    "3": cancelled
    "4": arrived
    "5": arrived
    "6": arrived
    "8": scheduled    # walk in 改约,等同新建
    "9": no_show      # 爽约
