<?xml version="1.0" encoding="UTF-8"?>

<StructureMap xmlns="http://hl7.org/fhir">
  <id value="MedicationOverviewLMToMedicationOverviewBundle"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap MedicationOverviewLMToMedicationOverviewBundle</b></p><a name="MedicationOverviewLMToMedicationOverviewBundle"> </a><a name="hcMedicationOverviewLMToMedicationOverviewBundle"> </a><pre class="fml">
<b>map</b><span style="color: navy"> &quot;</span>http://smart.who.int/ph4h/StructureMap/MedicationOverviewLMToMedicationOverviewBundle<span style="color: navy">&quot; = &quot;</span>MedicationOverviewLMToMedicationOverviewBundle<span style="color: navy">&quot;

</span><b>uses</b><span style="color: navy"> &quot;</span><a href="file://E:\work\ImplementationGuides\ihe-pharm-meow\output/StructureDefinition-MedicationOverviewLM.html" title="Medication Overview (model)">https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationOverviewLM</a><span style="color: navy">&quot; </span><b>alias </b>MedicationOverviewLM <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="file://E:\work\ImplementationGuides\ihe-pharm-meow\output/StructureDefinition-PatientLM.html" title="Patient (model)">https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/PatientLM</a><span style="color: navy">&quot; </span><b>alias </b>PatientLM <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="file://E:\work\ImplementationGuides\ihe-pharm-meow\output/StructureDefinition-MedicationTreatmentLineLM.html" title="Medication Treatment Line (model)">https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationTreatmentLineLM</a><span style="color: navy">&quot; </span><b>alias </b>MedicationTreatmentLineLM <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="file://E:\work\ImplementationGuides\ihe-pharm-meow\output/StructureDefinition-PractitionerLM.html" title="Practitioner (model)">https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/PractitionerLM</a><span style="color: navy">&quot; </span><b>alias </b>PractitionerLM <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="file://E:\work\ImplementationGuides\ihe-pharm-meow\output/StructureDefinition-MedicationOverview.html" title="Medication Overview Bundle">https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationOverview</a><span style="color: navy">&quot; </span><b>alias </b>MedicationOverviewBundle <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="file://E:\work\ImplementationGuides\ihe-pharm-meow\output/StructureDefinition-MedicationOverviewComposition.html" title="Medication Overview Composition">https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationOverviewComposition</a><span style="color: navy">&quot; </span><b>alias </b>MedicationOverviewComposition <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="file://E:\work\ImplementationGuides\ihe-pharm-meow\output/StructureDefinition-MedicationTreatmentLine.html" title="Medication Treatment Line">https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationTreatmentLine</a><span style="color: navy">&quot; </span><b>alias </b>MedicationTreatmentLine <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/patient.html" title="Patient">http://hl7.org/fhir/StructureDefinition/Patient</a><span style="color: navy">&quot; </span><b>alias </b>Patient <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/practitioner.html" title="Practitioner">http://hl7.org/fhir/StructureDefinition/Practitioner</a><span style="color: navy">&quot; </span><b>alias </b>Practitioner <b>as </b><b>target</b>

<span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------------------</span>
<span style="color: navy">// </span><span style="color: green">Top-level group: assemble MedicationOverview Bundle (document)</span>
<span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------------------</span>
<b>group </b>MedicationOverviewLMToMedicationOverviewBundle<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>MedicationOverviewLM, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>MedicationOverviewBundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>tgt.type = <span style="color: blue">'document'</span> <i>&quot;bundleType&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>tgt.timestamp = <span style="color: navy">(</span>now()<span style="color: navy">)</span> <i>&quot;bundleTimestamp&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Generate fixed UUIDs once; reuse them across entries and Reference targets.</span>
  src<span style="color: navy"><b> -&gt; </b></span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">bid</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cid</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">pid</span><b> then</b><span style="color: navy"> {
</span>    <span style="color: navy">// </span><span style="color: green">Bundle.identifier (UUID identifier per RFC 4122)</span>
    src<span style="color: navy"><b> -&gt; </b></span> tgt.identifier<b> as </b><span style="color: maroon">id</span><span style="color: navy">, </span> id.system = <span style="color: blue">'urn:ietf:rfc:4122'</span><span style="color: navy">, </span> id.value = <span style="color: maroon">bid</span> <i>&quot;bundleIdentifier&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Composition entry. The Composition group ALSO emits the treatment-line bundle</span>
    <span style="color: navy">// </span><span style="color: green">entries (passing tgt in), so each section.entry reference can share the same</span>
    <span style="color: navy">// </span><span style="color: green">UUID as its bundle entry — making the lines reachable from the Composition.</span>
    src<span style="color: navy"><b> -&gt; </b></span> tgt.entry<b> as </b><span style="color: maroon">ce</span><span style="color: navy">, </span> ce.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">cid</span><span style="color: navy">)</span><span style="color: navy">, </span> ce.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'MedicationOverviewComposition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      src<b> then </b>MedicationOverviewLMToComposition<span style="color: navy">(</span><span style="color: maroon">src</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">, </span><span style="color: maroon">pid</span><span style="color: navy">, </span><span style="color: maroon">tgt</span><span style="color: navy">)</span> <i>&quot;compositionContent&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;compositionEntry&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Patient entry</span>
    src.patient<b> as </b><span style="color: maroon">pref</span><span style="color: navy"><b> -&gt; </b></span> tgt.entry<b> as </b><span style="color: maroon">pe</span><span style="color: navy">, </span> pe.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">pid</span><span style="color: navy">)</span><span style="color: navy">, </span> pe.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Patient'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">pat</span><b> then</b><span style="color: navy"> {
</span>      pref<b> then </b>PatientLMToPatient<span style="color: navy">(</span><span style="color: maroon">pref</span><span style="color: navy">, </span><span style="color: maroon">pat</span><span style="color: navy">)</span> <i>&quot;patientContent&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;patientEntry&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;setEntries&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------------------</span>
<span style="color: navy">// </span><span style="color: green">MedicationOverviewLM -&gt; MedicationOverviewComposition</span>
<span style="color: navy">// </span><span style="color: green">Receives the Patient entry's UUID (pid) so subject can reference it.</span>
<span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------------------</span>
<b>group </b>MedicationOverviewLMToComposition<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>MedicationOverviewLM, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>MedicationOverviewComposition, <b>source</b> <span style="color: maroon">pid</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>MedicationOverviewBundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>tgt.status = <span style="color: blue">'final'</span> <i>&quot;compStatus&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Composition.type — LOINC 56445-0 &quot;Medication summary Document&quot;</span>
  src<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> cc.code = <span style="color: blue">'56445-0'</span><span style="color: navy">, </span> cc.display = <span style="color: blue">'Medication summary Document'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ct</span><span style="color: navy">, </span> ct.coding = <span style="color: maroon">cc</span><span style="color: navy">, </span> tgt.type = <span style="color: maroon">ct</span> <i>&quot;compType&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Composition.subject -&gt; Patient entry by uuid</span>
  src<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subj</span><span style="color: navy">, </span> subj.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">pid</span><span style="color: navy">)</span><span style="color: navy">, </span> tgt.subject = <span style="color: maroon">subj</span> <i>&quot;compSubject&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>tgt.date = <span style="color: navy">(</span>now()<span style="color: navy">)</span> <i>&quot;compDate&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>tgt.title = <span style="color: blue">'Medication Overview'</span> <i>&quot;compTitle&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Composition.author is 1..* (required). The Min source carries no author, so</span>
  <span style="color: navy">// </span><span style="color: green">emit a display-only placeholder Reference to satisfy the cardinality.</span>
  <span style="color: navy">// </span><span style="color: green">TODO: replace with the real authoring Organization/Device once the source</span>
  <span style="color: navy">// </span><span style="color: green">(or a config value) provides it.</span>
  src<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">au</span><span style="color: navy">, </span> au.display = <span style="color: blue">'Medication Overview generator'</span><span style="color: navy">, </span> tgt.author = <span style="color: maroon">au</span> <i>&quot;compAuthor&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Section: MedRecordTreatmentLine</span>
  src<span style="color: navy"><b> -&gt; </b></span>tgt.section<b> as </b><span style="color: maroon">sect</span><b> then</b><span style="color: navy"> {
</span>    src<span style="color: navy"><b> -&gt; </b></span>sect.title = <span style="color: blue">'Medication Treatment Lines'</span> <i>&quot;sectTitle&quot;</i><span style="color: navy">;</span>
    src<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">scc</span><span style="color: navy">, </span> scc.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> scc.code = <span style="color: blue">'10160-0'</span><span style="color: navy">, </span> scc.display = <span style="color: blue">'History of Medication use Narrative'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sc</span><span style="color: navy">, </span> sc.coding = <span style="color: maroon">scc</span><span style="color: navy">, </span> sect.code = <span style="color: maroon">sc</span> <i>&quot;sectCode&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">One UUID per line, shared by the section.entry reference AND the bundle entry,</span>
    <span style="color: navy">// </span><span style="color: green">so each treatment line is reachable by forward traversal from the Composition</span>
    <span style="color: navy">// </span><span style="color: green">(mirrors the ICVP ICVPLMToIPS pattern). This is why the group receives the</span>
    <span style="color: navy">// </span><span style="color: green">Bundle: the line entries are created here, not in the top-level group.</span>
    src.medicationTreatmentLine<b> as </b><span style="color: maroon">lref</span><span style="color: navy"><b> -&gt; </b></span><b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">tid</span><b> then</b><span style="color: navy"> {
</span>      lref<span style="color: navy"><b> -&gt; </b></span> sect.entry<b> as </b><span style="color: maroon">se</span><span style="color: navy">, </span> se.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">tid</span><span style="color: navy">)</span> <i>&quot;sectEntry&quot;</i><span style="color: navy">;</span>
      lref<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">te</span><span style="color: navy">, </span> te.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">tid</span><span style="color: navy">)</span><span style="color: navy">, </span> te.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'MedicationTreatmentLine'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ms</span><b> then</b><span style="color: navy"> {
</span>        lref<b> then </b>MedicationTreatmentLineLMToMedicationStatement<span style="color: navy">(</span><span style="color: maroon">lref</span><span style="color: navy">, </span><span style="color: maroon">ms</span><span style="color: navy">, </span><span style="color: maroon">pid</span><span style="color: navy">)</span> <i>&quot;lineContent&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;lineEntry&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;treatmentLines&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;sectionTreatmentLines&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Attester from verification BackboneElement</span>
  src.verification<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>tgt.attester<b> as </b><span style="color: maroon">att</span><b> then</b><span style="color: navy"> {
</span>    v<span style="color: navy"><b> -&gt; </b></span>att.mode = <span style="color: blue">'professional'</span> <i>&quot;attMode&quot;</i><span style="color: navy">;</span>
    v.verificationTime<b> as </b><span style="color: maroon">vt</span><span style="color: navy"><b> -&gt; </b></span>att.time = <span style="color: maroon">vt</span> <i>&quot;attTime&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">practicioner is Reference(PractitionerLM) in the LM — copy the reference</span>
    <span style="color: navy">// </span><span style="color: green">as-is ((pr.name.text) was invalid: References have no name).</span>
    v.practicioner<b> as </b><span style="color: maroon">pr</span><span style="color: navy"><b> -&gt; </b></span>att.party = <span style="color: maroon">pr</span> <i>&quot;attParty&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;attester&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Comment -&gt; R4 Composition has NO `note` element (R5-only). Use the</span>
  <span style="color: navy">// </span><span style="color: green">cross-version extension, mirroring the r4 profile's approach for adherence.</span>
  src.comment<b> as </b><span style="color: maroon">cm</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/5.0/StructureDefinition/extension-Composition.note'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Annotation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">nt</span><b> then</b><span style="color: navy"> {
</span>    cm.commentText<b> as </b><span style="color: maroon">ctxt</span><span style="color: navy"><b> -&gt; </b></span>nt.text = <span style="color: maroon">ctxt</span> <i>&quot;noteText&quot;</i><span style="color: navy">;</span>
    cm.date<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -&gt; </b></span>nt.time = <span style="color: maroon">d</span> <i>&quot;noteTime&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">author is a Reference in the LM; Annotation.author[x] resolves by type.</span>
    cm.author<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span>nt.author = <span style="color: maroon">a</span> <i>&quot;noteAuthor&quot;</i><span style="color: navy">;</span>
    cm<span style="color: navy"><b> -&gt; </b></span> ext.value = <span style="color: maroon">nt</span><span style="color: navy">, </span> tgt.extension = <span style="color: maroon">ext</span> <i>&quot;noteAssign&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;noteFromComment&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------------------</span>
<span style="color: navy">// </span><span style="color: green">PatientLM -&gt; FHIR Patient</span>
<span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------------------</span>
<b>group </b>PatientLMToPatient<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>PatientLM, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Patient<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.identifier<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <span style="color: maroon">id</span> <i>&quot;patIdentifier&quot;</i><span style="color: navy">;</span>
  src.name<b> as </b><span style="color: maroon">n</span><span style="color: navy"><b> -&gt; </b></span>tgt.name = <span style="color: maroon">n</span> <i>&quot;patName&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">gender: navigate instead of a FHIRPath evaluate — validator can't scope</span>
  <span style="color: navy">// </span><span style="color: green">rule variables inside (…) expressions.</span>
  src.gender<b> as </b><span style="color: maroon">g</span><b> then</b><span style="color: navy"> {
</span>    g.coding<b> as </b><span style="color: maroon">gc</span><b> then</b><span style="color: navy"> {
</span>      gc.code<b> as </b><span style="color: maroon">gcode</span><span style="color: navy"><b> -&gt; </b></span>tgt.gender = <span style="color: maroon">gcode</span> <i>&quot;patGenderCode&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;patGenderCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;patGender&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">dateOfBirth is dateTime in LM; birthDate is date — silent truncation expected.</span>
  src.dateOfBirth<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -&gt; </b></span>tgt.birthDate = <span style="color: maroon">d</span> <i>&quot;patBirthDate&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------------------</span>
<span style="color: navy">// </span><span style="color: green">MedicationTreatmentLineLM -&gt; MedicationTreatmentLine (profile on MedicationStatement, R4)</span>
<span style="color: navy">// </span><span style="color: green">Receives the Patient entry's UUID (pid) so MS.subject can reference it.</span>
<span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------------------</span>
<b>group </b>MedicationTreatmentLineLMToMedicationStatement<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>MedicationTreatmentLineLM, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>MedicationTreatmentLine, <b>source</b> <span style="color: maroon">pid</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  src.identifier<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <span style="color: maroon">id</span><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">subject -&gt; Patient entry by uuid (MS.subject is 1..1)</span>
  src<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subj</span><span style="color: navy">, </span> subj.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">pid</span><span style="color: navy">)</span><span style="color: navy">, </span> tgt.subject = <span style="color: maroon">subj</span> <i>&quot;subject&quot;</i><span style="color: navy">;</span>
  src.status<b> as </b><span style="color: maroon">st</span><span style="color: navy"><b> -&gt; </b></span>tgt.status = <span style="color: maroon">st</span><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">medication[x] choice -&gt; R4 medication[x] (no CodeableReference in R4;</span>
  <span style="color: navy">// </span><span style="color: green">the engine resolves medicationReference/medicationCodeableConcept by value type)</span>
  src.medication<span style="color: navy"> : </span>Reference<b> as </b><span style="color: maroon">mr</span><span style="color: navy"><b> -&gt; </b></span>tgt.medication = <span style="color: maroon">mr</span> <i>&quot;medicationRef&quot;</i><span style="color: navy">;</span>
  src.medication<span style="color: navy"> : </span>CodeableConcept<b> as </b><span style="color: maroon">mc</span><span style="color: navy"><b> -&gt; </b></span>tgt.medication = <span style="color: maroon">mc</span> <i>&quot;medicationCC&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">effective[x] on R4 MedicationStatement — address the choice by base name.</span>
  src.effectivePeriod<b> as </b><span style="color: maroon">ep</span><span style="color: navy"><b> -&gt; </b></span>tgt.effective = <span style="color: maroon">ep</span><span style="color: navy">;</span>
  src.recordingMetadata<b> as </b><span style="color: maroon">rm</span><b> then</b><span style="color: navy"> {
</span>    rm.recordedTime<b> as </b><span style="color: maroon">rt</span><span style="color: navy"><b> -&gt; </b></span>tgt.dateAsserted = <span style="color: maroon">rt</span> <i>&quot;dateAsserted&quot;</i><span style="color: navy">;</span>
    rm.recorder<b> as </b><span style="color: maroon">rc</span><span style="color: navy"><b> -&gt; </b></span>tgt.informationSource = <span style="color: maroon">rc</span> <i>&quot;informationSource&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">reason -&gt; R4 reasonCode (0..* CodeableConcept; no CodeableReference in R4)</span>
  src.indication<b> as </b><span style="color: maroon">ind</span><span style="color: navy"><b> -&gt; </b></span>tgt.reasonCode = <span style="color: maroon">ind</span> <i>&quot;reasonIndication&quot;</i><span style="color: navy">;</span>
  src.indicationText<b> as </b><span style="color: maroon">it</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">it</span><span style="color: navy">, </span> tgt.reasonCode = <span style="color: maroon">cc</span> <i>&quot;reasonIndicationText&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">intendedUse: no R4 MedicationStatement element and no extension slice in the</span>
  <span style="color: navy">// </span><span style="color: green">r4 MEOW profile — intentionally not mapped (stays LM-only).</span>
  src.usageInstructions<b> as </b><span style="color: maroon">ui</span><span style="color: navy"><b> -&gt; </b></span>tgt.dosage = <span style="color: maroon">ui</span> <i>&quot;dosage&quot;</i><span style="color: navy">;</span>
  src.preparationInstructions<b> as </b><span style="color: maroon">pi</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Dosage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">dos</span><span style="color: navy">, </span> dos.text = <span style="color: maroon">pi</span><span style="color: navy">, </span> tgt.dosage = <span style="color: maroon">dos</span> <i>&quot;prepInstructions&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">note = comment</span>
  src.comment<b> as </b><span style="color: maroon">cm</span><span style="color: navy"><b> -&gt; </b></span><b>create</b><span style="color: navy">(</span><span style="color: blue">'Annotation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">nt</span><b> then</b><span style="color: navy"> {
</span>    cm.commentText<b> as </b><span style="color: maroon">ct</span><span style="color: navy"><b> -&gt; </b></span>nt.text = <span style="color: maroon">ct</span> <i>&quot;lineNoteText&quot;</i><span style="color: navy">;</span>
    cm.date<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -&gt; </b></span>nt.time = <span style="color: maroon">d</span> <i>&quot;lineNoteTime&quot;</i><span style="color: navy">;</span>
    cm.author<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span>nt.author = <span style="color: maroon">a</span> <i>&quot;lineNoteAuthor&quot;</i><span style="color: navy">;</span>
    cm<span style="color: navy"><b> -&gt; </b></span>tgt.note = <span style="color: maroon">nt</span> <i>&quot;lineNoteAssign&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;lineNote&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">adherence -&gt; R4 has no MS.adherence; the r4 profile slices the R5</span>
  <span style="color: navy">// </span><span style="color: green">cross-version extension (1..1 in the profile, sub-extensions code/reason).</span>
  src.treatmentStatus<b> as </b><span style="color: maroon">ts</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/5.0/StructureDefinition/extension-MedicationStatement.adherence'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">e1</span><span style="color: navy">, </span> e1.url = <span style="color: blue">'code'</span><span style="color: navy">, </span> e1.value = <span style="color: maroon">ts</span><span style="color: navy">, </span> ext.extension = <span style="color: maroon">e1</span><span style="color: navy">, </span> tgt.extension = <span style="color: maroon">ext</span> <i>&quot;extAdherence&quot;</i><span style="color: navy">;</span>
  src.treatmentStatusReasonCode<b> as </b><span style="color: maroon">tsr</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/5.0/StructureDefinition/extension-MedicationStatement.adherence'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">e1</span><span style="color: navy">, </span> e1.url = <span style="color: blue">'reason'</span><span style="color: navy">, </span> e1.value = <span style="color: maroon">tsr</span><span style="color: navy">, </span> ext.extension = <span style="color: maroon">e1</span><span style="color: navy">, </span> tgt.extension = <span style="color: maroon">ext</span> <i>&quot;extAdherenceReason&quot;</i><span style="color: navy">;</span>
  src.category<b> as </b><span style="color: maroon">cat</span><span style="color: navy"><b> -&gt; </b></span>tgt.category = <span style="color: maroon">cat</span><span style="color: navy">;</span>
  src.derivedFrom<b> as </b><span style="color: maroon">df</span><b> then</b><span style="color: navy"> {
</span>    df.request<b> as </b><span style="color: maroon">rq</span><span style="color: navy"><b> -&gt; </b></span>tgt.derivedFrom = <span style="color: maroon">rq</span> <i>&quot;derivedFromRequest&quot;</i><span style="color: navy">;</span>
    df.statement<b> as </b><span style="color: maroon">stm</span><span style="color: navy"><b> -&gt; </b></span>tgt.derivedFrom = <span style="color: maroon">stm</span> <i>&quot;derivedFromStatement&quot;</i><span style="color: navy">;</span>
    df.dispensation<b> as </b><span style="color: maroon">dsp</span><span style="color: navy"><b> -&gt; </b></span>tgt.derivedFrom = <span style="color: maroon">dsp</span> <i>&quot;derivedFromDispensation&quot;</i><span style="color: navy">;</span>
    df.administration<b> as </b><span style="color: maroon">adm</span><span style="color: navy"><b> -&gt; </b></span>tgt.derivedFrom = <span style="color: maroon">adm</span> <i>&quot;derivedFromAdministration&quot;</i><span style="color: navy">;</span>
    df.other<b> as </b><span style="color: maroon">oth</span><span style="color: navy"><b> -&gt; </b></span>tgt.derivedFrom = <span style="color: maroon">oth</span> <i>&quot;derivedFromOther&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Extension: artifact-version</span>
  src.version<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/artifact-version'</span><span style="color: navy">, </span> ext.value = <span style="color: maroon">v</span><span style="color: navy">, </span> tgt.extension = <span style="color: maroon">ext</span> <i>&quot;extVersion&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Extension: VerificationInformation</span>
  src.verificationInformation<b> as </b><span style="color: maroon">vi</span><span style="color: navy"><b> -&gt; </b></span><b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ext</span><b> then</b><span style="color: navy"> {
</span>    vi<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/ihe-ext-medicationstatement-verificationinformation'</span> <i>&quot;viUrl&quot;</i><span style="color: navy">;</span>
    vi.verifier<b> as </b><span style="color: maroon">vr</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">e1</span><span style="color: navy">, </span> e1.url = <span style="color: blue">'verifier'</span><span style="color: navy">, </span> e1.value = <span style="color: maroon">vr</span><span style="color: navy">, </span> ext.extension = <span style="color: maroon">e1</span> <i>&quot;viVerifier&quot;</i><span style="color: navy">;</span>
    vi.verificationTime<b> as </b><span style="color: maroon">vt</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">e2</span><span style="color: navy">, </span> e2.url = <span style="color: blue">'verificationTime'</span><span style="color: navy">, </span> e2.value = <span style="color: maroon">vt</span><span style="color: navy">, </span> ext.extension = <span style="color: maroon">e2</span> <i>&quot;viTime&quot;</i><span style="color: navy">;</span>
    vi<span style="color: navy"><b> -&gt; </b></span>tgt.extension = <span style="color: maroon">ext</span> <i>&quot;viAssign&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;extVerification&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Extension: Substitution</span>
  src.substitution<b> as </b><span style="color: maroon">sub</span><span style="color: navy"><b> -&gt; </b></span><b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ext</span><b> then</b><span style="color: navy"> {
</span>    sub<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/ihe-ext-medicationstatement-substitution'</span> <i>&quot;subUrl&quot;</i><span style="color: navy">;</span>
    sub.substitutionType<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">e1</span><span style="color: navy">, </span> e1.url = <span style="color: blue">'substitutionType'</span><span style="color: navy">, </span> e1.value = <span style="color: maroon">t</span><span style="color: navy">, </span> ext.extension = <span style="color: maroon">e1</span> <i>&quot;subType&quot;</i><span style="color: navy">;</span>
    sub.substitutionTypeReason<b> as </b><span style="color: maroon">r</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">e2</span><span style="color: navy">, </span> e2.url = <span style="color: blue">'substitutionTypeReason'</span><span style="color: navy">, </span> e2.value = <span style="color: maroon">r</span><span style="color: navy">, </span> ext.extension = <span style="color: maroon">e2</span> <i>&quot;subReason&quot;</i><span style="color: navy">;</span>
    sub.substitutionTypeReasonText<b> as </b><span style="color: maroon">rt</span><span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">e3</span><span style="color: navy">, </span> e3.url = <span style="color: blue">'substitutionTypeReasonText'</span><span style="color: navy">, </span> e3.value = <span style="color: maroon">rt</span><span style="color: navy">, </span> ext.extension = <span style="color: maroon">e3</span> <i>&quot;subReasonText&quot;</i><span style="color: navy">;</span>
    sub<span style="color: navy"><b> -&gt; </b></span>tgt.extension = <span style="color: maroon">ext</span> <i>&quot;subAssign&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;extSubstitution&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------------------</span>
<span style="color: navy">// </span><span style="color: green">PractitionerLM -&gt; FHIR Practitioner</span>
<span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------------------</span>
<b>group </b>PractitionerLMToPractitioner<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>PractitionerLM, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.identifier<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <span style="color: maroon">id</span> <i>&quot;practIdentifier&quot;</i><span style="color: navy">;</span>
  src.name<b> as </b><span style="color: maroon">n</span><span style="color: navy"><b> -&gt; </b></span>tgt.name = <span style="color: maroon">n</span> <i>&quot;practName&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url value="http://smart.who.int/ph4h/StructureMap/MedicationOverviewLMToMedicationOverviewBundle"/>
  <version value="0.9.9"/>
  <name value="MedicationOverviewLMToMedicationOverviewBundle"/>
  <status value="draft"/>
  <date value="2026-07-09T08:34:46+00:00"/>
  <publisher value="WHO"/>
  <contact>
    <name value="WHO"/>
    <telecom>
      <system value="url"/>
      <value value="http://who.int"/>
    </telecom>
  </contact>
  <structure>
    <url value="https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationOverviewLM"/>
    <mode value="source"/>
    <alias value="MedicationOverviewLM"/>
  </structure>
  <structure>
    <url value="https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/PatientLM"/>
    <mode value="source"/>
    <alias value="PatientLM"/>
  </structure>
  <structure>
    <url value="https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationTreatmentLineLM"/>
    <mode value="source"/>
    <alias value="MedicationTreatmentLineLM"/>
  </structure>
  <structure>
    <url value="https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/PractitionerLM"/>
    <mode value="source"/>
    <alias value="PractitionerLM"/>
  </structure>
  <structure>
    <url value="https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationOverview"/>
    <mode value="target"/>
    <alias value="MedicationOverviewBundle"/>
  </structure>
  <structure>
    <url value="https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationOverviewComposition"/>
    <mode value="target"/>
    <alias value="MedicationOverviewComposition"/>
  </structure>
  <structure>
    <url value="https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/MedicationTreatmentLine"/>
    <mode value="target"/>
    <alias value="MedicationTreatmentLine"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Patient"/>
    <mode value="target"/>
    <alias value="Patient"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Practitioner"/>
    <mode value="target"/>
    <alias value="Practitioner"/>
  </structure>
  <group>
    <name value="MedicationOverviewLMToMedicationOverviewBundle"/>
    <typeMode value="none"/>
    <documentation value="---------------------------------------------------------------------------&#xD;&#xA;Top-level group: assemble MedicationOverview Bundle (document)&#xD;&#xA;---------------------------------------------------------------------------"/>
    <input>
      <name value="src"/>
      <type value="MedicationOverviewLM"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="MedicationOverviewBundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="bundleType"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="type"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="document"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="bundleTimestamp"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="timestamp"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="now()"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="setEntries"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="bid"/>
        <transform value="uuid"/>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="cid"/>
        <transform value="uuid"/>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="pid"/>
        <transform value="uuid"/>
      </target>
      <rule>
        <name value="bundleIdentifier"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="id"/>
        </target>
        <target>
          <context value="id"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="urn:ietf:rfc:4122"/>
          </parameter>
        </target>
        <target>
          <context value="id"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="bid"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="compositionEntry"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="ce"/>
        </target>
        <target>
          <context value="ce"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="cid"/>
          </parameter>
        </target>
        <target>
          <context value="ce"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="comp"/>
          <transform value="create"/>
          <parameter>
            <valueString value="MedicationOverviewComposition"/>
          </parameter>
        </target>
        <rule>
          <name value="compositionContent"/>
          <source>
            <context value="src"/>
          </source>
          <dependent>
            <name value="MedicationOverviewLMToComposition"/>
            <variable value="src"/>
            <variable value="comp"/>
            <variable value="pid"/>
            <variable value="tgt"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="patientEntry"/>
        <source>
          <context value="src"/>
          <element value="patient"/>
          <variable value="pref"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="pe"/>
        </target>
        <target>
          <context value="pe"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="pid"/>
          </parameter>
        </target>
        <target>
          <context value="pe"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="pat"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Patient"/>
          </parameter>
        </target>
        <rule>
          <name value="patientContent"/>
          <source>
            <context value="pref"/>
          </source>
          <dependent>
            <name value="PatientLMToPatient"/>
            <variable value="pref"/>
            <variable value="pat"/>
          </dependent>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="MedicationOverviewLMToComposition"/>
    <typeMode value="none"/>
    <documentation value="---------------------------------------------------------------------------&#xD;&#xA;MedicationOverviewLM -&gt; MedicationOverviewComposition&#xD;&#xA;Receives the Patient entry's UUID (pid) so subject can reference it.&#xD;&#xA;---------------------------------------------------------------------------"/>
    <input>
      <name value="src"/>
      <type value="MedicationOverviewLM"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="MedicationOverviewComposition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="pid"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="MedicationOverviewBundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="compStatus"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="compType"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coding"/>
        </parameter>
      </target>
      <target>
        <context value="cc"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://loinc.org"/>
        </parameter>
      </target>
      <target>
        <context value="cc"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="56445-0"/>
        </parameter>
      </target>
      <target>
        <context value="cc"/>
        <contextType value="variable"/>
        <element value="display"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Medication summary Document"/>
        </parameter>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="ct"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <target>
        <context value="ct"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="cc"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="type"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="ct"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="compSubject"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="subj"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="subj"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="pid"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="subj"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="compDate"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="date"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="now()"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="compTitle"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="title"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Medication Overview"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="compAuthor"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="au"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="au"/>
        <contextType value="variable"/>
        <element value="display"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Medication Overview generator"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="author"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="au"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="sectionTreatmentLines"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="section"/>
        <variable value="sect"/>
      </target>
      <rule>
        <name value="sectTitle"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="sect"/>
          <contextType value="variable"/>
          <element value="title"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Medication Treatment Lines"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="sectCode"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <contextType value="variable"/>
          <variable value="scc"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Coding"/>
          </parameter>
        </target>
        <target>
          <context value="scc"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="http://loinc.org"/>
          </parameter>
        </target>
        <target>
          <context value="scc"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="10160-0"/>
          </parameter>
        </target>
        <target>
          <context value="scc"/>
          <contextType value="variable"/>
          <element value="display"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="History of Medication use Narrative"/>
          </parameter>
        </target>
        <target>
          <contextType value="variable"/>
          <variable value="sc"/>
          <transform value="create"/>
          <parameter>
            <valueString value="CodeableConcept"/>
          </parameter>
        </target>
        <target>
          <context value="sc"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="scc"/>
          </parameter>
        </target>
        <target>
          <context value="sect"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="sc"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="treatmentLines"/>
        <source>
          <context value="src"/>
          <element value="medicationTreatmentLine"/>
          <variable value="lref"/>
        </source>
        <target>
          <contextType value="variable"/>
          <variable value="tid"/>
          <transform value="uuid"/>
        </target>
        <rule>
          <name value="sectEntry"/>
          <source>
            <context value="lref"/>
          </source>
          <target>
            <context value="sect"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="se"/>
          </target>
          <target>
            <context value="se"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="tid"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="lineEntry"/>
          <source>
            <context value="lref"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="te"/>
          </target>
          <target>
            <context value="te"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="tid"/>
            </parameter>
          </target>
          <target>
            <context value="te"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="ms"/>
            <transform value="create"/>
            <parameter>
              <valueString value="MedicationTreatmentLine"/>
            </parameter>
          </target>
          <rule>
            <name value="lineContent"/>
            <source>
              <context value="lref"/>
            </source>
            <dependent>
              <name value="MedicationTreatmentLineLMToMedicationStatement"/>
              <variable value="lref"/>
              <variable value="ms"/>
              <variable value="pid"/>
            </dependent>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="attester"/>
      <source>
        <context value="src"/>
        <element value="verification"/>
        <variable value="v"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="attester"/>
        <variable value="att"/>
      </target>
      <rule>
        <name value="attMode"/>
        <source>
          <context value="v"/>
        </source>
        <target>
          <context value="att"/>
          <contextType value="variable"/>
          <element value="mode"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="professional"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="attTime"/>
        <source>
          <context value="v"/>
          <element value="verificationTime"/>
          <variable value="vt"/>
        </source>
        <target>
          <context value="att"/>
          <contextType value="variable"/>
          <element value="time"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="vt"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="attParty"/>
        <source>
          <context value="v"/>
          <element value="practicioner"/>
          <variable value="pr"/>
        </source>
        <target>
          <context value="att"/>
          <contextType value="variable"/>
          <element value="party"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="pr"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="noteFromComment"/>
      <source>
        <context value="src"/>
        <element value="comment"/>
        <variable value="cm"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="ext"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Extension"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://hl7.org/fhir/5.0/StructureDefinition/extension-Composition.note"/>
        </parameter>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="nt"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Annotation"/>
        </parameter>
      </target>
      <rule>
        <name value="noteText"/>
        <source>
          <context value="cm"/>
          <element value="commentText"/>
          <variable value="ctxt"/>
        </source>
        <target>
          <context value="nt"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="ctxt"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="noteTime"/>
        <source>
          <context value="cm"/>
          <element value="date"/>
          <variable value="d"/>
        </source>
        <target>
          <context value="nt"/>
          <contextType value="variable"/>
          <element value="time"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="d"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="noteAuthor"/>
        <source>
          <context value="cm"/>
          <element value="author"/>
          <variable value="a"/>
        </source>
        <target>
          <context value="nt"/>
          <contextType value="variable"/>
          <element value="author"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="a"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="noteAssign"/>
        <source>
          <context value="cm"/>
        </source>
        <target>
          <context value="ext"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="nt"/>
          </parameter>
        </target>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="ext"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="PatientLMToPatient"/>
    <typeMode value="none"/>
    <documentation value="---------------------------------------------------------------------------&#xD;&#xA;PatientLM -&gt; FHIR Patient&#xD;&#xA;---------------------------------------------------------------------------"/>
    <input>
      <name value="src"/>
      <type value="PatientLM"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="patIdentifier"/>
      <source>
        <context value="src"/>
        <element value="identifier"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="patName"/>
      <source>
        <context value="src"/>
        <element value="name"/>
        <variable value="n"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="name"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="n"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="patGender"/>
      <source>
        <context value="src"/>
        <element value="gender"/>
        <variable value="g"/>
      </source>
      <rule>
        <name value="patGenderCoding"/>
        <source>
          <context value="g"/>
          <element value="coding"/>
          <variable value="gc"/>
        </source>
        <rule>
          <name value="patGenderCode"/>
          <source>
            <context value="gc"/>
            <element value="code"/>
            <variable value="gcode"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="gender"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="gcode"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="patBirthDate"/>
      <source>
        <context value="src"/>
        <element value="dateOfBirth"/>
        <variable value="d"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="birthDate"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="d"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="MedicationTreatmentLineLMToMedicationStatement"/>
    <typeMode value="none"/>
    <documentation value="---------------------------------------------------------------------------&#xD;&#xA;MedicationTreatmentLineLM -&gt; MedicationTreatmentLine (profile on MedicationStatement, R4)&#xD;&#xA;Receives the Patient entry's UUID (pid) so MS.subject can reference it.&#xD;&#xA;---------------------------------------------------------------------------"/>
    <input>
      <name value="src"/>
      <type value="MedicationTreatmentLineLM"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="MedicationTreatmentLine"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="pid"/>
      <mode value="source"/>
    </input>
    <rule>
      <name value="identifier"/>
      <source>
        <context value="src"/>
        <element value="identifier"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="subj"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="subj"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="pid"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="subj"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
        <element value="status"/>
        <variable value="st"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="st"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="medicationRef"/>
      <source>
        <context value="src"/>
        <type value="Reference"/>
        <element value="medication"/>
        <variable value="mr"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="medication"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="mr"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="medicationCC"/>
      <source>
        <context value="src"/>
        <type value="CodeableConcept"/>
        <element value="medication"/>
        <variable value="mc"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="medication"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="mc"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="effectivePeriod"/>
      <source>
        <context value="src"/>
        <element value="effectivePeriod"/>
        <variable value="ep"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="effective"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="ep"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="recordingMetadata"/>
      <source>
        <context value="src"/>
        <element value="recordingMetadata"/>
        <variable value="rm"/>
      </source>
      <rule>
        <name value="dateAsserted"/>
        <source>
          <context value="rm"/>
          <element value="recordedTime"/>
          <variable value="rt"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="dateAsserted"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="rt"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="informationSource"/>
        <source>
          <context value="rm"/>
          <element value="recorder"/>
          <variable value="rc"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="informationSource"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="rc"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="reasonIndication"/>
      <source>
        <context value="src"/>
        <element value="indication"/>
        <variable value="ind"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="reasonCode"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="ind"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="reasonIndicationText"/>
      <source>
        <context value="src"/>
        <element value="indicationText"/>
        <variable value="it"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <target>
        <context value="cc"/>
        <contextType value="variable"/>
        <element value="text"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="it"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="reasonCode"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="cc"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="dosage"/>
      <source>
        <context value="src"/>
        <element value="usageInstructions"/>
        <variable value="ui"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="dosage"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="ui"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="prepInstructions"/>
      <source>
        <context value="src"/>
        <element value="preparationInstructions"/>
        <variable value="pi"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="dos"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Dosage"/>
        </parameter>
      </target>
      <target>
        <context value="dos"/>
        <contextType value="variable"/>
        <element value="text"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="pi"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="dosage"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="dos"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="lineNote"/>
      <source>
        <context value="src"/>
        <element value="comment"/>
        <variable value="cm"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="nt"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Annotation"/>
        </parameter>
      </target>
      <rule>
        <name value="lineNoteText"/>
        <source>
          <context value="cm"/>
          <element value="commentText"/>
          <variable value="ct"/>
        </source>
        <target>
          <context value="nt"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="ct"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="lineNoteTime"/>
        <source>
          <context value="cm"/>
          <element value="date"/>
          <variable value="d"/>
        </source>
        <target>
          <context value="nt"/>
          <contextType value="variable"/>
          <element value="time"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="d"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="lineNoteAuthor"/>
        <source>
          <context value="cm"/>
          <element value="author"/>
          <variable value="a"/>
        </source>
        <target>
          <context value="nt"/>
          <contextType value="variable"/>
          <element value="author"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="a"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="lineNoteAssign"/>
        <source>
          <context value="cm"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="note"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="nt"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="extAdherence"/>
      <source>
        <context value="src"/>
        <element value="treatmentStatus"/>
        <variable value="ts"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="ext"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Extension"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://hl7.org/fhir/5.0/StructureDefinition/extension-MedicationStatement.adherence"/>
        </parameter>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="e1"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Extension"/>
        </parameter>
      </target>
      <target>
        <context value="e1"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <target>
        <context value="e1"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="ts"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="e1"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="ext"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="extAdherenceReason"/>
      <source>
        <context value="src"/>
        <element value="treatmentStatusReasonCode"/>
        <variable value="tsr"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="ext"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Extension"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://hl7.org/fhir/5.0/StructureDefinition/extension-MedicationStatement.adherence"/>
        </parameter>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="e1"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Extension"/>
        </parameter>
      </target>
      <target>
        <context value="e1"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="reason"/>
        </parameter>
      </target>
      <target>
        <context value="e1"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="tsr"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="e1"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="ext"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="category"/>
      <source>
        <context value="src"/>
        <element value="category"/>
        <variable value="cat"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="category"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="cat"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="derivedFrom"/>
      <source>
        <context value="src"/>
        <element value="derivedFrom"/>
        <variable value="df"/>
      </source>
      <rule>
        <name value="derivedFromRequest"/>
        <source>
          <context value="df"/>
          <element value="request"/>
          <variable value="rq"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="derivedFrom"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="rq"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="derivedFromStatement"/>
        <source>
          <context value="df"/>
          <element value="statement"/>
          <variable value="stm"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="derivedFrom"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="stm"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="derivedFromDispensation"/>
        <source>
          <context value="df"/>
          <element value="dispensation"/>
          <variable value="dsp"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="derivedFrom"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="dsp"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="derivedFromAdministration"/>
        <source>
          <context value="df"/>
          <element value="administration"/>
          <variable value="adm"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="derivedFrom"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="adm"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="derivedFromOther"/>
        <source>
          <context value="df"/>
          <element value="other"/>
          <variable value="oth"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="derivedFrom"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="oth"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="extVersion"/>
      <source>
        <context value="src"/>
        <element value="version"/>
        <variable value="v"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="ext"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Extension"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://hl7.org/fhir/StructureDefinition/artifact-version"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="v"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="ext"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="extVerification"/>
      <source>
        <context value="src"/>
        <element value="verificationInformation"/>
        <variable value="vi"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="ext"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Extension"/>
        </parameter>
      </target>
      <rule>
        <name value="viUrl"/>
        <source>
          <context value="vi"/>
        </source>
        <target>
          <context value="ext"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/ihe-ext-medicationstatement-verificationinformation"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="viVerifier"/>
        <source>
          <context value="vi"/>
          <element value="verifier"/>
          <variable value="vr"/>
        </source>
        <target>
          <contextType value="variable"/>
          <variable value="e1"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Extension"/>
          </parameter>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="verifier"/>
          </parameter>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="vr"/>
          </parameter>
        </target>
        <target>
          <context value="ext"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="e1"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="viTime"/>
        <source>
          <context value="vi"/>
          <element value="verificationTime"/>
          <variable value="vt"/>
        </source>
        <target>
          <contextType value="variable"/>
          <variable value="e2"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Extension"/>
          </parameter>
        </target>
        <target>
          <context value="e2"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="verificationTime"/>
          </parameter>
        </target>
        <target>
          <context value="e2"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="vt"/>
          </parameter>
        </target>
        <target>
          <context value="ext"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="e2"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="viAssign"/>
        <source>
          <context value="vi"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="ext"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="extSubstitution"/>
      <source>
        <context value="src"/>
        <element value="substitution"/>
        <variable value="sub"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="ext"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Extension"/>
        </parameter>
      </target>
      <rule>
        <name value="subUrl"/>
        <source>
          <context value="sub"/>
        </source>
        <target>
          <context value="ext"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="https://profiles.ihe.net/PHARM/MEOW/StructureDefinition/ihe-ext-medicationstatement-substitution"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="subType"/>
        <source>
          <context value="sub"/>
          <element value="substitutionType"/>
          <variable value="t"/>
        </source>
        <target>
          <contextType value="variable"/>
          <variable value="e1"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Extension"/>
          </parameter>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="substitutionType"/>
          </parameter>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="t"/>
          </parameter>
        </target>
        <target>
          <context value="ext"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="e1"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="subReason"/>
        <source>
          <context value="sub"/>
          <element value="substitutionTypeReason"/>
          <variable value="r"/>
        </source>
        <target>
          <contextType value="variable"/>
          <variable value="e2"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Extension"/>
          </parameter>
        </target>
        <target>
          <context value="e2"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="substitutionTypeReason"/>
          </parameter>
        </target>
        <target>
          <context value="e2"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="r"/>
          </parameter>
        </target>
        <target>
          <context value="ext"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="e2"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="subReasonText"/>
        <source>
          <context value="sub"/>
          <element value="substitutionTypeReasonText"/>
          <variable value="rt"/>
        </source>
        <target>
          <contextType value="variable"/>
          <variable value="e3"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Extension"/>
          </parameter>
        </target>
        <target>
          <context value="e3"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="substitutionTypeReasonText"/>
          </parameter>
        </target>
        <target>
          <context value="e3"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="rt"/>
          </parameter>
        </target>
        <target>
          <context value="ext"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="e3"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="subAssign"/>
        <source>
          <context value="sub"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="ext"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="PractitionerLMToPractitioner"/>
    <typeMode value="none"/>
    <documentation value="---------------------------------------------------------------------------&#xD;&#xA;PractitionerLM -&gt; FHIR Practitioner&#xD;&#xA;---------------------------------------------------------------------------"/>
    <input>
      <name value="src"/>
      <type value="PractitionerLM"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="practIdentifier"/>
      <source>
        <context value="src"/>
        <element value="identifier"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="practName"/>
      <source>
        <context value="src"/>
        <element value="name"/>
        <variable value="n"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="name"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="n"/>
        </parameter>
      </target>
    </rule>
  </group>
</StructureMap>