# emr — FRIDAY 病历自由文本(诊断/治疗已拆独立 fact,本资源只装自由文本)
# 直接消费 med_emr_info(数组列不映射即不入 canonical;dispose_text/examine_text 是导出侧
# 序列化的 JSON 字符串形态,与 jvs-dw examine/dispose "JSON 原文" 同语义)
canonical: emr

emits:
  action: emr_submitted
  subjectType: emr
  # occurred = clinic_time(就诊时刻,100% 填充);created_gmt_at 是录入时点,留幂等键用
  occurredAtField: submittedAt

primary:
  table: med_emr_info
  key: emr_sub_id      # 小病历号 uuid(两侧连接键 + 临床事实锚点)
  dedup_by: emr_sub_id

field_mapping:
  externalId:           emr_sub_id
  # updatedAt 进 source_event_id 幂等键,host UPDATE → 新 transaction(同 jvs-dw 纪律)
  updatedAt:            updated_gmt_at
  createdAt:            created_gmt_at
  patientExternalId:    patient_id
  clinicId:             organization_id
  submittedAt:          clinic_time       # 就诊时刻(100%)
  encounterExternalId:  appointment_id    # 56.5% 有值 → 挂预约/接诊链;临床事实锚用 emr_sub_id
  doctorId:             user_id
  doctorName:           user_name
  # SOAP 自由文本段落
  illnessDesc:          illness_desc      # 主诉
  preIllness:           pre_illness       # 现病史
  pastHistory:          past_hist         # 既往史
  generalCondition:     gen_cond          # 全身情况
  examFindings:         examine_text      # 检查所见(JSON 原文,带牙位)
  auxExamFindings:      auxi_exam         # 辅助检查(自由文本)
  disposal:             dispose_text      # 处置叙述(98% 填充,JSON 原文带牙位;actual 治疗主源是 treat[])
  doctorAdvice:         doc_order         # 医嘱
