# consult — PAC 咨询主体(fact_consult_out → consultation_record)
# 一次咨询/初诊事件;potential_cure=患者意向(主观意愿,非诊断)。范围随 DW 全量(全瑞尔)。
canonical: consultation

emits:
  action: consultation_created
  subjectType: consultation
  occurredAtField: occurredAt

primary:
  table: fact_consult_out
  key: consult_external_id
  dedup_by: consult_external_id

field_mapping:
  externalId:        consult_external_id
  # 无 updated_date → 用 appointment_date 作幂等键(同 consult 同日再拉 → dedup;编辑漏更新见 follow-up)
  updatedAt:         appointment_date
  patientExternalId: patient_id          # = patient_register_id(SQL alias;试点期实测 94.4% = patient_id)
  clinicId:          organization_id
  occurredAt:        appointment_date
  intentRaw:         potential_cure       # Python list 串 ['种植','洁牙'] → parser 解析意向
  taskDirector:      task_director        # 跟进人
  firstVisit:        first_visit          # 初诊标记(0/1)
  doctorId:          doctor_user_id
  appointmentExternalId: appo_id          # 关联预约
