# encounter — 已到诊预约即接诊事件
# 消费 transforms 输出表 appointment_encounter_rows(route_by_pattern 已过滤 appo_status IN 4,5,6)
canonical: encounter

emits:
  action: doctor_encounter_started
  subjectType: encounter
  occurredAtField: startedAt

primary:
  table: appointment_encounter_rows
  key: id

field_mapping:
  externalId:        id
  # W4 末 DW upsert:updatedAt 进 source_event_id 幂等键,host UPDATE → 新 transaction(否则永久 dedup 漏 update)
  updatedAt:         updated_date
  createdAt:         created_date
  patientExternalId: patient_id
  clinicId:          organization_id
  startedAt:         in_time
  doctorId:          appo_doc_id
  # 主诉:归 chief_complaint 字段(原 notes 装的就是主诉,纠正命名)。
  # notes 字段保留为通用备注,jvs-dw 暂无对应留 null;encounter_type 同理(host 无结构化)。
  chiefComplaint:    appo_complaint
