FHIR © HL7.org  |  FHIRsmith 4.0.1  |  Server Home  |  XIG Home  |  XIG Stats  | 

FHIR IG analytics

Packagesmart.who.int.ph4h
Resource TypeStructureMap
IdStructureMap-MedicationOverviewMinToMedicationOverviewLM.json
FHIR VersionR4
Sourcehttp://smart.who.int/ph4h/0.9.9/StructureMap-MedicationOverviewMinToMedicationOverviewLM.html
URLhttp://smart.who.int/ph4h/StructureMap/MedicationOverviewMinToMedicationOverviewLM
Version0.9.9
Statusdraft
Date2026-07-09T08:34:46+00:00
NameMedicationOverviewMinToMedicationOverviewLM
Authoritywho

Resources that use this resource

No resources found


Resources that this resource uses

No resources found


Narrative

Note: links and images are rebased to the (stated) source

Generated Narrative: StructureMap MedicationOverviewMinToMedicationOverviewLM

map "http://smart.who.int/ph4h/StructureMap/MedicationOverviewMinToMedicationOverviewLM" = "MedicationOverviewMinToMedicationOverviewLM"

uses "http://smart.who.int/ph4h/StructureDefinition/MedicationOverviewMin" alias MedicationOverviewMin as source
uses "http://smart.who.int/ph4h/StructureDefinition/MedicationTreatmentLineMin" alias MedicationTreatmentLineMin as source
uses "https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationOverviewLM" alias MedicationOverviewLM as target
uses "https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/PatientLM" alias PatientLM as target
uses "https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationTreatmentLineLM" alias MedicationTreatmentLineLM as target

// ---------------------------------------------------------------------------
// Top-level group: 1 patient + 0..* medication treatment lines
// ---------------------------------------------------------------------------
group MedicationOverviewMinToMedicationOverviewLM(source src : MedicationOverviewMin, target tgt : MedicationOverviewLM) {
  src -> tgt.patient as patient then MedicationOverviewMinToPatientLM(src, patient) "patient";
  src.m as line -> tgt.medicationTreatmentLine as tline then MedicationTreatmentLineMinToMedicationTreatmentLineLM(line, tline) "treatmentLine";
}

// ---------------------------------------------------------------------------
// MedicationOverviewMin demographic fields -> PatientLM
// ---------------------------------------------------------------------------
group MedicationOverviewMinToPatientLM(source src : MedicationOverviewMin, target tgt : PatientLM) {
  // Name: create HumanName, populate, assign
  src.n as n ->  create('HumanName') as hn,  hn.text = n,  tgt.name = hn "name";
  src.dob as dob -> tgt.dateOfBirth = dob "dateOfBirth";
  // Gender: create Coding, then CodeableConcept wrapping it, assign
  src.s as s ->  create('Coding') as gc,  gc.system = 'http://hl7.org/fhir/administrative-gender',  gc.code = s,  create('CodeableConcept') as g,  g.coding = gc,  tgt.gender = g "gender";
  // Identifier: create Identifier, populate, assign. Identifier.type is intentionally
  // NOT emitted: the Min 'dt' code carries no code system, which produced
  // unvalidatable type.coding warnings (no system / not in IdentifierType VS).
  // Identifier.type is optional (0..1); the value alone is sufficient here.
  src.id as id -> create('Identifier') as ident then {
    id -> ident.value = id "identifierValue";
    id -> tgt.identifier = ident "identifierAssign";
  } "identifier";
}

// ---------------------------------------------------------------------------
// One MedicationTreatmentLineMin -> one MedicationTreatmentLineLM
// ---------------------------------------------------------------------------
group MedicationTreatmentLineMinToMedicationTreatmentLineLM(source src : MedicationTreatmentLineMin, target tgt : MedicationTreatmentLineLM) {
  // Status: the Min source carries no record status; default to 'active'.
  // LM.status is 1..1 and the downstream R4 MedicationStatement.status is
  // 1..1 required — without this rule, stage 2 emits status-less statements
  // that fail MEOW Bundle profile validation.
  src -> tgt.status = 'active' "status";
  // Medication: create Coding, then CodeableConcept wrapping it, assign.
  // The Min 'm' field is a bare code with no system; RACSEL production data uses
  // SNOMED CT, so tag it as SNOMED to satisfy validation.
  // NOTE: the ATC-coded example (e.g. L02BG03) is mislabelled by this fixed system.
  // If mixed code systems must be supported, the Min model should carry the system
  // alongside the code (e.g. an 'ms' field) rather than assuming SNOMED here.
  // Display intentionally NOT set: the Min 'm' field carries only a code, and
  // emitting the code as the display fails SNOMED display validation
  // ("Wrong Display Name"). Leaving it absent lets the term server supply it.
  src.m as med ->  create('Coding') as c,  c.system = 'http://snomed.info/sct',  c.code = med,  create('CodeableConcept') as cc,  cc.coding = c,  tgt.medication = cc "medication";
  // Effective period: create Period, populate, assign
  // (Period uses .start/.end — NOT .low/.high; those are Range properties.)
  src -> create('Period') as ep then {
    src.es as es -> ep.start = es "effStart";
    src.ee as ee -> ep.end = ee "effEnd";
    src -> tgt.effectivePeriod = ep "effAssign";
  } "effectivePeriod";
  // recordingMetadata is a BackboneElement defined inline in the LM — navigate.
  src.da as da -> tgt.recordingMetadata as rm then {
    da -> rm.recordedTime = da "recordedTime";
  } "dateAsserted";
  // Dosage as free text. Route to preparationInstructions (a plain string array)
  // rather than comment.commentText: comment is a BackboneElement with several
  // 1..1 sub-fields (author, date, commentText) that the Min source can't
  // populate, so creating a half-empty comment confuses matchbox's serializer.
  // preparationInstructions is a string field, no nested required structure.
  src.d as d -> tgt.preparationInstructions = d "dosage";
  src.r as r -> tgt.indicationText = r "reason";
  // Adherence (treatmentStatus): MEOW requires adherence 1..1 downstream, so always
  // emit it. Default the code to 'active' and override with the source 'a' when it is
  // present. System is medication-statement-status (see $adherenceStatusVS alias — the
  // R4 stand-in for the R5 adherence value set), which includes 'active'.
  src ->  create('Coding') as tsc,  tsc.system = 'http://hl7.org/fhir/CodeSystem/medication-statement-status',  tsc.code = 'active',  create('CodeableConcept') as ts,  ts.coding = tsc,  tgt.treatmentStatus = ts then {
    src.a as a -> tsc.code = a "adherenceValue";
  } "adherence";
}


Source1

{
  "resourceType": "StructureMap",
  "id": "MedicationOverviewMinToMedicationOverviewLM",
  "text": {
    "status": "generated",
    "div": "<!-- snip (see above) -->"
  },
  "url": "http://smart.who.int/ph4h/StructureMap/MedicationOverviewMinToMedicationOverviewLM",
  "version": "0.9.9",
  "name": "MedicationOverviewMinToMedicationOverviewLM",
  "status": "draft",
  "date": "2026-07-09T08:34:46+00:00",
  "publisher": "WHO",
  "contact": [
    {
      "name": "WHO",
      "telecom": [
        {
          "system": "url",
          "value": "http://who.int"
        }
      ]
    }
  ],
  "structure": [
    {
      "url": "http://smart.who.int/ph4h/StructureDefinition/MedicationOverviewMin",
      "mode": "source",
      "alias": "MedicationOverviewMin"
    },
    {
      "url": "http://smart.who.int/ph4h/StructureDefinition/MedicationTreatmentLineMin",
      "mode": "source",
      "alias": "MedicationTreatmentLineMin"
    },
    {
      "url": "https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationOverviewLM",
      "mode": "target",
      "alias": "MedicationOverviewLM"
    },
    {
      "url": "https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/PatientLM",
      "mode": "target",
      "alias": "PatientLM"
    },
    {
      "url": "https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationTreatmentLineLM",
      "mode": "target",
      "alias": "MedicationTreatmentLineLM"
    }
  ],
  "group": [
    {
      "name": "MedicationOverviewMinToMedicationOverviewLM",
      "typeMode": "none",
      "documentation": "---------------------------------------------------------------------------\r\nTop-level group: 1 patient + 0..* medication treatment lines\r\n---------------------------------------------------------------------------",
      "input": [
        {
          "name": "src",
          "type": "MedicationOverviewMin",
          "mode": "source"
        },
        {
          "name": "tgt",
          "type": "MedicationOverviewLM",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "patient",
          "source": [
            {
              "context": "src"
            }
          ],
          "target": [
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "patient",
              "variable": "patient"
            }
          ],
          "dependent": [
            {
              "name": "MedicationOverviewMinToPatientLM",
              "variable": [
                "src",
                "patient"
              ]
            }
          ]
        },
        {
          "name": "treatmentLine",
          "source": [
            {
              "context": "src",
              "element": "m",
              "variable": "line"
            }
          ],
          "target": [
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "medicationTreatmentLine",
              "variable": "tline"
            }
          ],
          "dependent": [
            {
              "name": "MedicationTreatmentLineMinToMedicationTreatmentLineLM",
              "variable": [
                "line",
                "tline"
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "MedicationOverviewMinToPatientLM",
      "typeMode": "none",
      "documentation": "---------------------------------------------------------------------------\r\nMedicationOverviewMin demographic fields -> PatientLM\r\n---------------------------------------------------------------------------",
      "input": [
        {
          "name": "src",
          "type": "MedicationOverviewMin",
          "mode": "source"
        },
        {
          "name": "tgt",
          "type": "PatientLM",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "name",
          "source": [
            {
              "context": "src",
              "element": "n",
              "variable": "n"
            }
          ],
          "target": [
            {
              "contextType": "variable",
              "variable": "hn",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "HumanName"
                }
              ]
            },
            {
              "context": "hn",
              "contextType": "variable",
              "element": "text",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "n"
                }
              ]
            },
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "name",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "hn"
                }
              ]
            }
          ]
        },
        {
          "name": "dateOfBirth",
          "source": [
            {
              "context": "src",
              "element": "dob",
              "variable": "dob"
            }
          ],
          "target": [
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "dateOfBirth",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "dob"
                }
              ]
            }
          ]
        },
        {
          "name": "gender",
          "source": [
            {
              "context": "src",
              "element": "s",
              "variable": "s"
            }
          ],
          "target": [
            {
              "contextType": "variable",
              "variable": "gc",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "Coding"
                }
              ]
            },
            {
              "context": "gc",
              "contextType": "variable",
              "element": "system",
              "transform": "copy",
              "parameter": [
                {
                  "valueString": "http://hl7.org/fhir/administrative-gender"
                }
              ]
            },
            {
              "context": "gc",
              "contextType": "variable",
              "element": "code",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "s"
                }
              ]
            },
            {
              "contextType": "variable",
              "variable": "g",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "CodeableConcept"
                }
              ]
            },
            {
              "context": "g",
              "contextType": "variable",
              "element": "coding",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "gc"
                }
              ]
            },
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "gender",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "g"
                }
              ]
            }
          ]
        },
        {
          "name": "identifier",
          "source": [
            {
              "context": "src",
              "element": "id",
              "variable": "id"
            }
          ],
          "target": [
            {
              "contextType": "variable",
              "variable": "ident",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "Identifier"
                }
              ]
            }
          ],
          "rule": [
            {
              "name": "identifierValue",
              "source": [
                {
                  "context": "id"
                }
              ],
              "target": [
                {
                  "context": "ident",
                  "contextType": "variable",
                  "element": "value",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "id"
                    }
                  ]
                }
              ]
            },
            {
              "name": "identifierAssign",
              "source": [
                {
                  "context": "id"
                }
              ],
              "target": [
                {
                  "context": "tgt",
                  "contextType": "variable",
                  "element": "identifier",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "ident"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "MedicationTreatmentLineMinToMedicationTreatmentLineLM",
      "typeMode": "none",
      "documentation": "---------------------------------------------------------------------------\r\nOne MedicationTreatmentLineMin -> one MedicationTreatmentLineLM\r\n---------------------------------------------------------------------------",
      "input": [
        {
          "name": "src",
          "type": "MedicationTreatmentLineMin",
          "mode": "source"
        },
        {
          "name": "tgt",
          "type": "MedicationTreatmentLineLM",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "status",
          "source": [
            {
              "context": "src"
            }
          ],
          "target": [
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "status",
              "transform": "copy",
              "parameter": [
                {
                  "valueString": "active"
                }
              ]
            }
          ]
        },
        {
          "name": "medication",
          "source": [
            {
              "context": "src",
              "element": "m",
              "variable": "med"
            }
          ],
          "target": [
            {
              "contextType": "variable",
              "variable": "c",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "Coding"
                }
              ]
            },
            {
              "context": "c",
              "contextType": "variable",
              "element": "system",
              "transform": "copy",
              "parameter": [
                {
                  "valueString": "http://snomed.info/sct"
                }
              ]
            },
            {
              "context": "c",
              "contextType": "variable",
              "element": "code",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "med"
                }
              ]
            },
            {
              "contextType": "variable",
              "variable": "cc",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "CodeableConcept"
                }
              ]
            },
            {
              "context": "cc",
              "contextType": "variable",
              "element": "coding",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "c"
                }
              ]
            },
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "medication",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "cc"
                }
              ]
            }
          ]
        },
        {
          "name": "effectivePeriod",
          "source": [
            {
              "context": "src"
            }
          ],
          "target": [
            {
              "contextType": "variable",
              "variable": "ep",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "Period"
                }
              ]
            }
          ],
          "rule": [
            {
              "name": "effStart",
              "source": [
                {
                  "context": "src",
                  "element": "es",
                  "variable": "es"
                }
              ],
              "target": [
                {
                  "context": "ep",
                  "contextType": "variable",
                  "element": "start",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "es"
                    }
                  ]
                }
              ]
            },
            {
              "name": "effEnd",
              "source": [
                {
                  "context": "src",
                  "element": "ee",
                  "variable": "ee"
                }
              ],
              "target": [
                {
                  "context": "ep",
                  "contextType": "variable",
                  "element": "end",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "ee"
                    }
                  ]
                }
              ]
            },
            {
              "name": "effAssign",
              "source": [
                {
                  "context": "src"
                }
              ],
              "target": [
                {
                  "context": "tgt",
                  "contextType": "variable",
                  "element": "effectivePeriod",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "ep"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "dateAsserted",
          "source": [
            {
              "context": "src",
              "element": "da",
              "variable": "da"
            }
          ],
          "target": [
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "recordingMetadata",
              "variable": "rm"
            }
          ],
          "rule": [
            {
              "name": "recordedTime",
              "source": [
                {
                  "context": "da"
                }
              ],
              "target": [
                {
                  "context": "rm",
                  "contextType": "variable",
                  "element": "recordedTime",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "da"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "dosage",
          "source": [
            {
              "context": "src",
              "element": "d",
              "variable": "d"
            }
          ],
          "target": [
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "preparationInstructions",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "d"
                }
              ]
            }
          ]
        },
        {
          "name": "reason",
          "source": [
            {
              "context": "src",
              "element": "r",
              "variable": "r"
            }
          ],
          "target": [
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "indicationText",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "r"
                }
              ]
            }
          ]
        },
        {
          "name": "adherence",
          "source": [
            {
              "context": "src"
            }
          ],
          "target": [
            {
              "contextType": "variable",
              "variable": "tsc",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "Coding"
                }
              ]
            },
            {
              "context": "tsc",
              "contextType": "variable",
              "element": "system",
              "transform": "copy",
              "parameter": [
                {
                  "valueString": "http://hl7.org/fhir/CodeSystem/medication-statement-status"
                }
              ]
            },
            {
              "context": "tsc",
              "contextType": "variable",
              "element": "code",
              "transform": "copy",
              "parameter": [
                {
                  "valueString": "active"
                }
              ]
            },
            {
              "contextType": "variable",
              "variable": "ts",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "CodeableConcept"
                }
              ]
            },
            {
              "context": "ts",
              "contextType": "variable",
              "element": "coding",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "tsc"
                }
              ]
            },
            {
              "context": "tgt",
              "contextType": "variable",
              "element": "treatmentStatus",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "ts"
                }
              ]
            }
          ],
          "rule": [
            {
              "name": "adherenceValue",
              "source": [
                {
                  "context": "src",
                  "element": "a",
                  "variable": "a"
                }
              ],
              "target": [
                {
                  "context": "tsc",
                  "contextType": "variable",
                  "element": "code",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "a"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}