# text.div
Generated Narrative: StructureMap vn-sm-bhyt-xml9-birth-certificate

map "http://fhir.hl7.org.vn/core/StructureMap/vn-sm-bhyt-xml9-birth-certificate" = "BHYTXML9BirthCertificateLMStructureMap"

// Generated StructureMap scaffold for Bảng 9 giấy chứng sinh — XML9 Birth Certificate Logical Model. Source semantics come from the logical model mapping annotations in `BHYTXML9BirthCertificateLM.fsh` and remain aligned with the Python BHYT round-trip export adapter.

uses "http://fhir.hl7.org.vn/core/StructureDefinition/vn-core-bhyt-submission-bundle" alias BHYTSubmissionBundle as source // FHIR-native source bundle profile used by the repository round-trip adapter.
uses "http://fhir.hl7.org.vn/core/StructureDefinition/bhytXml9BirthCertificateLm" alias BHYTXML9BirthCertificateLM as target // Bảng 9 giấy chứng sinh — XML9 Birth Certificate Logical Model

// Rows are derived from birth-certificate DocumentReference/Composition, newborn Patient, mother/caregiver RelatedPerson and certifying Practitioner. Generated from logical-model `^mapping` annotations. Fields still missing a field-level `^mapping.map` entry remain outside this StructureMap and are tracked in `wiki/mappings/bhyt-output-data/machine/structuremap-coverage.json`.
group MapBHYTXML9BirthCertificateLM(source sourceBundle : BHYTSubmissionBundle, target targetRow : BHYTXML9BirthCertificateLM) {
  sourceBundle.entry as maLkSource -> targetRow.maLk "maLk"; // Target field: MA_LK - Mã liên kết hồ sơ FHIR path: VNCoreClaim.identifier[MALK].value
  sourceBundle.entry as maBhxhNndSource -> targetRow.maBhxhNnd "maBhxhNnd"; // Target field: MA_BHXH_NND - Mã BHXH người nuôi dưỡng FHIR path: VNCoreRelatedPerson.identifier[BHXH].value | VNCorePatient.contact.identifier.value
  sourceBundle.entry as maTheNndSource -> targetRow.maTheNnd "maTheNnd"; // Target field: MA_THE_NND - Mã thẻ người nuôi dưỡng FHIR path: VNCoreCoverage.subscriber.resolve().identifier[BHYT].value | VNCoreRelatedPerson.identifier.value
  sourceBundle.entry as hoTenNndSource -> targetRow.hoTenNnd "hoTenNnd"; // Target field: HO_TEN_NND - Họ tên người nuôi dưỡng FHIR path: VNCoreRelatedPerson.name.text | VNCorePatient.contact.name.text
  sourceBundle.entry as ngaySinhNndSource -> targetRow.ngaySinhNnd "ngaySinhNnd"; // Target field: NGAYSINH_NND - Ngày sinh người nuôi dưỡng FHIR path: VNCoreRelatedPerson.birthDate
  sourceBundle.entry as maDanTocNndSource -> targetRow.maDanTocNnd "maDanTocNnd"; // Target field: MA_DANTOC_NND - Mã dân tộc người nuôi dưỡng FHIR path: VNCoreRelatedPerson.extension[ethnicity].valueCodeableConcept.coding.code | VNCorePatient.contact.extension[ethnicity].valueCodeableConcept.coding.code
  sourceBundle.entry as ngayCapCccdNndSource -> targetRow.ngayCapCccdNnd "ngayCapCccdNnd"; // Target field: NGAYCAP_CCCD_NND - Ngày cấp CCCD người nuôi dưỡng FHIR path: VNCoreRelatedPerson.identifier[CCCD].period.start
  sourceBundle.entry as noiCapCccdNndSource -> targetRow.noiCapCccdNnd "noiCapCccdNnd"; // Target field: NOICAP_CCCD_NND - Nơi cấp CCCD người nuôi dưỡng FHIR path: VNCoreRelatedPerson.identifier[CCCD].assigner.display
  sourceBundle.entry as noiCuTruNndSource -> targetRow.noiCuTruNnd "noiCuTruNnd"; // Target field: NOI_CU_TRU_NND - Nơi cư trú người nuôi dưỡng FHIR path: VNCoreRelatedPerson.address.text | VNCorePatient.contact.address.text
  sourceBundle.entry as maQuocTichSource -> targetRow.maQuocTich "maQuocTich"; // Target field: MA_QUOCTICH - Mã quốc tịch FHIR path: VNCorePatient.extension[citizenship].extension[code].valueCodeableConcept.coding.code
  sourceBundle.entry as maTinhCuTruSource -> targetRow.maTinhCuTru "maTinhCuTru"; // Target field: MATINH_CU_TRU - Mã tỉnh cư trú FHIR path: VNCoreRelatedPerson.address.extension[province].valueCoding.code | VNCorePatient.address.extension[province].valueCoding.code
  sourceBundle.entry as maHuyenCuTruSource -> targetRow.maHuyenCuTru "maHuyenCuTru"; // Target field: MAHUYEN_CU_TRU - Mã huyện cư trú legacy FHIR path: VNCoreRelatedPerson.address.district | VNCorePatient.address.district
  sourceBundle.entry as maXaCuTruSource -> targetRow.maXaCuTru "maXaCuTru"; // Target field: MAXA_CU_TRU - Mã xã cư trú FHIR path: VNCoreRelatedPerson.address.extension[ward].valueCoding.code | VNCorePatient.address.extension[ward].valueCoding.code
  sourceBundle.entry as hoTenChaSource -> targetRow.hoTenCha "hoTenCha"; // Target field: HO_TEN_CHA - Họ tên cha FHIR path: VNCoreRelatedPerson.where(relationship.coding.code='FTH').name.text | VNCorePatient.contact.where(relationship.coding.code='FTH').name.text
  sourceBundle.entry as maTheTamSource -> targetRow.maTheTam "maTheTam"; // Target field: MA_THE_TAM - Mã thẻ tạm FHIR path: VNCoreCoverage.identifier.value Mapping note: Temporary card identifiers are kept as Coverage.identifier until a dedicated temporary-card slice is profiled.
  sourceBundle.entry as hoTenConSource -> targetRow.hoTenCon "hoTenCon"; // Target field: HO_TEN_CON - Họ tên con FHIR path: VNCorePatient.name.text
  sourceBundle.entry as gioiTinhConSource -> targetRow.gioiTinhCon "gioiTinhCon"; // Target field: GIOI_TINH_CON - Giới tính con FHIR path: VNCorePatient.gender
  sourceBundle.entry as soConSource -> targetRow.soCon "soCon"; // Target field: SO_CON - Số con FHIR path: VNCoreObservation.valueQuantity
  sourceBundle.entry as lanSinhSource -> targetRow.lanSinh "lanSinh"; // Target field: LAN_SINH - Lần sinh FHIR path: VNCoreObservation.valueInteger
  sourceBundle.entry as soConSongSource -> targetRow.soConSong "soConSong"; // Target field: SO_CON_SONG - Số con sống FHIR path: VNCoreObservation.valueQuantity
  sourceBundle.entry as canNangConSource -> targetRow.canNangCon "canNangCon"; // Target field: CAN_NANG_CON - Cân nặng con FHIR path: VNCoreObservation.valueQuantity | VNCorePatient.extension[birthWeight].valueQuantity
  sourceBundle.entry as ngaySinhConSource -> targetRow.ngaySinhCon "ngaySinhCon"; // Target field: NGAY_SINH_CON - Ngày sinh con FHIR path: VNCoreDocumentReference.date | content.attachment.creation | VNCorePatient.birthDate
  sourceBundle.entry as noiSinhConSource -> targetRow.noiSinhCon "noiSinhCon"; // Target field: NOI_SINH_CON - Nơi sinh con FHIR path: VNCorePatient.extension[birthPlace].valueAddress.text | VNCoreEncounter.location.location.resolve().name
  sourceBundle.entry as sinhConPhauThuatSource -> targetRow.sinhConPhauThuat "sinhConPhauThuat"; // Target field: SINHCON_PHAUTHUAT - Sinh con phẫu thuật FHIR path: VNCoreProcedure.code | VNCoreObservation.valueBoolean
  sourceBundle.entry as sinhConDuoi32TuanSource -> targetRow.sinhConDuoi32Tuan "sinhConDuoi32Tuan"; // Target field: SINHCON_DUOI32TUAN - Sinh con dưới 32 tuần FHIR path: VNCoreObservation.valueBoolean
  sourceBundle.entry as nguoiDoDeSource -> targetRow.nguoiDoDe "nguoiDoDe"; // Target field: NGUOI_DO_DE - Người đỡ đẻ FHIR path: VNCoreComposition.author.resolve().identifier.value | VNCorePractitioner.identifier.value
  sourceBundle.entry as nguoiGhiPhieuSource -> targetRow.nguoiGhiPhieu "nguoiGhiPhieu"; // Target field: NGUOI_GHI_PHIEU - Người ghi phiếu FHIR path: VNCoreDocumentReference.author.resolve().identifier.value | VNCorePractitioner.identifier.value
  sourceBundle.entry as ngayCtSource -> targetRow.ngayCt "ngayCt"; // Target field: NGAY_CT - Ngày cấp chứng từ FHIR path: VNCoreDocumentReference.date | VNCoreComposition.date
  sourceBundle.entry as soSource -> targetRow.so "so"; // Target field: SO - Số chứng từ FHIR path: VNCoreDocumentReference.identifier.value | VNCoreComposition.identifier.value
  sourceBundle.entry as quyenSoSource -> targetRow.quyenSo "quyenSo"; // Target field: QUYEN_SO - Quyển số FHIR path: VNCoreDocumentReference.identifier.value
}

# title
Bảng 9 giấy chứng sinh — XML9 Birth Certificate Logical Model — StructureMap

# publisher
Omi HealthTech / VN Core FHIR Community Initiative

# contact[].name
Omi HealthTech / VN Core FHIR Community Initiative

# description
Generated StructureMap scaffold for Bảng 9 giấy chứng sinh — XML9 Birth Certificate Logical Model. Source semantics come from the logical model mapping annotations in `BHYTXML9BirthCertificateLM.fsh` and remain aligned with the Python BHYT round-trip export adapter.

# purpose
Publish canonical, reviewable FHIR-to-BHYT XML mapping artifacts for XML1-XML12 without duplicating field-level mapping semantics across FSH, wiki, and export code.

# structure[].documentation
FHIR-native source bundle profile used by the repository round-trip adapter.

# structure[].documentation
Bảng 9 giấy chứng sinh — XML9 Birth Certificate Logical Model

# group[].documentation
Rows are derived from birth-certificate DocumentReference/Composition, newborn Patient, mother/caregiver RelatedPerson and certifying Practitioner. Generated from logical-model `^mapping` annotations. Fields still missing a field-level `^mapping.map` entry remain outside this StructureMap and are tracked in `wiki/mappings/bhyt-output-data/machine/structuremap-coverage.json`.

# group[].input[].documentation
Bảng 9 giấy chứng sinh — XML9 Birth Certificate Logical Model

# group[].rule[].documentation
Target field: MA_LK - Mã liên kết hồ sơ FHIR path: VNCoreClaim.identifier[MALK].value

# group[].rule[].documentation
Target field: MA_BHXH_NND - Mã BHXH người nuôi dưỡng FHIR path: VNCoreRelatedPerson.identifier[BHXH].value | VNCorePatient.contact.identifier.value

# group[].rule[].documentation
Target field: HO_TEN_NND - Họ tên người nuôi dưỡng FHIR path: VNCoreRelatedPerson.name.text | VNCorePatient.contact.name.text

# group[].rule[].documentation
Target field: NGAYSINH_NND - Ngày sinh người nuôi dưỡng FHIR path: VNCoreRelatedPerson.birthDate

# group[].rule[].documentation
Target field: NGAYCAP_CCCD_NND - Ngày cấp CCCD người nuôi dưỡng FHIR path: VNCoreRelatedPerson.identifier[CCCD].period.start

# group[].rule[].documentation
Target field: NOICAP_CCCD_NND - Nơi cấp CCCD người nuôi dưỡng FHIR path: VNCoreRelatedPerson.identifier[CCCD].assigner.display

# group[].rule[].documentation
Target field: NOI_CU_TRU_NND - Nơi cư trú người nuôi dưỡng FHIR path: VNCoreRelatedPerson.address.text | VNCorePatient.contact.address.text

# group[].rule[].documentation
Target field: MAHUYEN_CU_TRU - Mã huyện cư trú legacy FHIR path: VNCoreRelatedPerson.address.district | VNCorePatient.address.district

# group[].rule[].documentation
Target field: MA_THE_TAM - Mã thẻ tạm FHIR path: VNCoreCoverage.identifier.value Mapping note: Temporary card identifiers are kept as Coverage.identifier until a dedicated temporary-card slice is profiled.

# group[].rule[].documentation
Target field: HO_TEN_CON - Họ tên con FHIR path: VNCorePatient.name.text

# group[].rule[].documentation
Target field: GIOI_TINH_CON - Giới tính con FHIR path: VNCorePatient.gender

# group[].rule[].documentation
Target field: SO_CON - Số con FHIR path: VNCoreObservation.valueQuantity

# group[].rule[].documentation
Target field: LAN_SINH - Lần sinh FHIR path: VNCoreObservation.valueInteger

# group[].rule[].documentation
Target field: SO_CON_SONG - Số con sống FHIR path: VNCoreObservation.valueQuantity

# group[].rule[].documentation
Target field: NGAY_SINH_CON - Ngày sinh con FHIR path: VNCoreDocumentReference.date | content.attachment.creation | VNCorePatient.birthDate

# group[].rule[].documentation
Target field: SINHCON_PHAUTHUAT - Sinh con phẫu thuật FHIR path: VNCoreProcedure.code | VNCoreObservation.valueBoolean

# group[].rule[].documentation
Target field: SINHCON_DUOI32TUAN - Sinh con dưới 32 tuần FHIR path: VNCoreObservation.valueBoolean

# group[].rule[].documentation
Target field: NGAY_CT - Ngày cấp chứng từ FHIR path: VNCoreDocumentReference.date | VNCoreComposition.date

# group[].rule[].documentation
Target field: SO - Số chứng từ FHIR path: VNCoreDocumentReference.identifier.value | VNCoreComposition.identifier.value

# group[].rule[].documentation
Target field: QUYEN_SO - Quyển số FHIR path: VNCoreDocumentReference.identifier.value