Монгол Улсын үндэсний цөм FHIR удирдамж (Mongolian National Core IG)
0.1.0 - draft Mongolia

Монгол Улсын үндэсний цөм FHIR удирдамж (Mongolian National Core IG) - Local Development build (v0.1.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

StructureMap: EMM3Extraction

Official URL: http://fhir.mn/core/StructureMap/EMM3Extraction Version: 0.1.0
Draft as of 2026-09-08 Computable Name: EMM3Extraction

map "http://fhir.mn/core/StructureMap/EMM3Extraction" = "EMM3Extraction"

uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target
uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target

group EMM3Extraction(source src : QuestionnaireResponse, target bnd : Bundle) {
  // We're taking a QuestionnaireResponse and creating a transaction Bundle
  src -> bnd.id = uuid() "bundleid";
  src -> bnd.type = 'transaction' "bundletype";
  // Navigate into the demographic group of the form to extract Patient
  src.item as item where linkId = 'demographics' ->  bnd.entry as entry,  entry.resource = create('Patient') as patient then ExtractPatient(item, patient) "extractpatient";
}

group ExtractPatient(source item, target patient : Patient) {
  // Find the family name item and map its string answer to Patient.name.family
  item.item as i where linkId = 'demographics.family-name' then {
    i.answer as ans then {
      ans.value : string as v ->  patient.name as n,  n.family = v "patientfamilyname";
    };
  };
  // Find the given name item and map its string answer to Patient.name.given
  item.item as i where linkId = 'demographics.given-name' then {
    i.answer as ans then {
      ans.value : string as v ->  patient.name as n,  n.given = v "patientgivenname";
    };
  };
}