# encounter — 已到诊预约即接诊事件(与 jvs-dw 同款:从预约拆已到诊)
# 消费 transforms 输出表 appointment_encounter_rows(status IN 4/5/6 且 in_time 非空)
# 首版只给"到诊事件"骨架;诊断/治疗/牙位后续从 EMR(med_emr + MongoDB med_emr_info)
# 经 appointmentId 挂到本 encounter(externalId = 预约 id)。
canonical: encounter

emits:
  action: doctor_encounter_started
  subjectType: encounter
  occurredAtField: startedAt

primary:
  table: appointment_encounter_rows
  key: id

field_mapping:
  externalId:        id                       # = 预约 id;EMR 侧 appointmentId 将据此回挂
  patientExternalId: patient_appointment_id
  clinicId:          organization_id
  startedAt:         in_time                  # 到诊时刻 = 接诊开始
  doctorId:          doctor_user_id
  createdAt:         created_gmt_at
  updatedAt:         updated_gmt_at
  # diagnoses / treatments / chiefComplaint:后续 EMR 接入再补(本表无结构化临床内容)
