# image — 影像 metadata(EMR.file_url 拆行而来,PAC 不持文件本体)
# 消费 transforms 输出表 image_rows(split_json_array file_url + derive external_id)
canonical: image

emits:
  action: image_uploaded
  subjectType: image
  occurredAtField: uploadedAt

primary:
  table: image_rows
  key: image_external_id
  dedup_by: image_external_id   # 同一影像跨 emr 行重复兜底

field_mapping:
  externalId:           image_external_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
  uploadedAt:           captured_at
  encounterExternalId:  registration_id
  modality:             check_name
  doctorId:             user_id            # 接诊医生(从 emr 父级继承,影像拍摄/解读医生)
  doctorName:           doctor_name


# ── 字典分层(2026-07 重构):真影像类型在 _shared/dict;单据/化验类名目留本地 ──
dict_includes:
  - ../../_shared/dict/image-modality.yaml

enum_mapping:
  # host check_name → PAC modality:化验/表单/记录类(无影像语义)归 other(本 host 名目)
  modality:
    "牙周大表":                   other
    "血常规":                     other
    "拔牙术前清单":               other
    "全身检查":                   other
    "凝血四项":                   other
    "术前讨论记录":               other
    "个人健康状况登记表":         other
    "分析结果":                   other
    _default:                     other
