EMM3Extraction
type: StructureMap
node role: treeRoot
id:
  v: EMM3Extraction
text:
  status:
    v: generated
  div:
    v: Generated Narrative: StructureMap EMM3Extraction #xD; map "http://fhir.mn/core/StructureMap/EMM3Extraction" = "EMM3Extraction"#xD; #xD; uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source#xD; uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target#xD; #xD; group EMM3Extraction(source src : QuestionnaireResponse, target bnd : Bundle) {#xD; // We're taking a QuestionnaireResponse and creating a transaction Bundle#xD; src -> bnd.id = uuid() "bundleid";#xD; src -> bnd.type = 'transaction' "bundletype";#xD; // Navigate into the demographic group of the form to extract Patient#xD; src.item as item where linkId = 'demographics' -> bnd.entry as entry, entry.resource = create('Patient') as patient then ExtractPatient(item, patient) "extractpatient";#xD; }#xD; #xD; group ExtractPatient(source item, target patient : Patient) {#xD; // Find the family name item and map its string answer to Patient.name.family#xD; item.item as i where linkId = 'demographics.family-name' then {#xD; i.answer as ans then {#xD; ans.value : string as v -> patient.name as n, n.family = v "patientfamilyname";#xD; };#xD; };#xD; // Find the given name item and map its string answer to Patient.name.given#xD; item.item as i where linkId = 'demographics.given-name' then {#xD; i.answer as ans then {#xD; ans.value : string as v -> patient.name as n, n.given = v "patientgivenname";#xD; };#xD; };#xD; }#xD; #xD;
url:
  v: http://fhir.mn/core/StructureMap/EMM3Extraction
  l: EMM3Extraction
version:
  v: 0.1.0
name:
  v: EMM3Extraction
status:
  v: draft
date:
  v: 2026-09-08T10:09:36+08:00
publisher:
  v: Эрүүл мэндийн хөгжлийн төв (Health Development Center, Mongolia)
contact:
  name:
    v: Эрүүл мэндийн хөгжлийн төв (Health Development Center, Mongolia)
  telecom:
    system:
      v: url
    value:
      v: https://hdc.gov.mn
contact:
  name:
    v: Эрүүл мэндийн хөгжлийн төв (Health Development Center)
  telecom:
    system:
      v: url
    value:
      v: https://hdc.gov.mn
jurisdiction:
  coding:
    system:
      v: urn:iso:std:iso:3166
      l: 3166
    code:
      v: MN
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse
    l: QuestionnaireResponse
  mode:
    v: source
  alias:
    v: QuestionnaireResponse
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/Bundle
    l: Bundle
  mode:
    v: target
  alias:
    v: Bundle
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/Patient
    l: Patient
  mode:
    v: target
  alias:
    v: Patient
group:
  name:
    v: EMM3Extraction
  type mode:
    v: none
  input:
    name:
      v: src
    type:
      v: QuestionnaireResponse
    mode:
      v: source
  input:
    name:
      v: bnd
    type:
      v: Bundle
    mode:
      v: target
  rule:
    name:
      v: bundleid
    source:
      context:
        v: src
    target:
      context:
        v: bnd
      context type:
        v: variable
      element:
        v: id
      transform:
        v: uuid
  rule:
    name:
      v: bundletype
    source:
      context:
        v: src
    target:
      context:
        v: bnd
      context type:
        v: variable
      element:
        v: type
      transform:
        v: copy
      parameter:
        value: String
  rule:
    name:
      v: extractpatient
    source:
      context:
        v: src
      element:
        v: item
      variable:
        v: item
      condition:
        v: linkId = 'demographics'
    target:
      context:
        v: bnd
      context type:
        v: variable
      element:
        v: entry
      variable:
        v: entry
    target:
      context:
        v: entry
      context type:
        v: variable
      element:
        v: resource
      variable:
        v: patient
      transform:
        v: create
      parameter:
        value: String
    dependent:
      name:
        v: ExtractPatient
      variable:
        v: item
      variable:
        v: patient
group:
  name:
    v: ExtractPatient
  type mode:
    v: none
  input:
    name:
      v: item
    mode:
      v: source
  input:
    name:
      v: patient
    type:
      v: Patient
    mode:
      v: target
  rule:
    name:
      v: item
    source:
      context:
        v: item
      element:
        v: item
      variable:
        v: i
      condition:
        v: linkId = 'demographics.family-name'
    rule:
      name:
        v: answer
  rule:
    name:
      v: item
    source:
      context:
        v: item
      element:
        v: item
      variable:
        v: i

String
v: transaction

String
v: Patient

v: i

v: answer

v: ans

v: patientfamilyname

context:
  v: ans
type:
  v: string
element:
  v: value
variable:
  v: v

context:
  v: patient
context type:
  v: variable
element:
  v: name
variable:
  v: n

context:
  v: n
context type:
  v: variable
element:
  v: family
transform:
  v: copy
parameter:
  value: Id
    v: v

v: linkId = 'demographics.given-name'

name:
  v: answer
source:
  context:
    v: i
  element:
    v: answer
  variable:
    v: ans
rule:
  name:
    v: patientgivenname
  source:
    context:
      v: ans
    type:
      v: string
    element:
      v: value
    variable:
      v: v
  target:
    context:
      v: patient
    context type:
      v: variable
    element:
      v: name
    variable:
      v: n
  target:
    context:
      v: n
    context type:
      v: variable
    element:
      v: given
    transform:
      v: copy
    parameter:
      value: Id
        v: v