SGHI FHIR Profile Implementation Guide
0.1.0 - ci-build

SGHI FHIR Profile Implementation Guide, published by Kathurima Kimathi. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/savannahghi/sil_fhir_profile_ig/ and changes regularly. See the Directory of published versions

: MOH 510 Immunisation Permanent Register Extraction - XML Representation

Active as of 2026-09-14

Raw xml | Download


<StructureMap xmlns="http://hl7.org/fhir">
  <id value="ExtractMOH510ImmunisationRegister"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap ExtractMOH510ImmunisationRegister</b></p><a name="ExtractMOH510ImmunisationRegister"> </a><a name="hcExtractMOH510ImmunisationRegister"> </a><pre class="fml">
<span style="color: #cc00cc">/// <b>url</b> = </span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractMOH510ImmunisationRegister'</span>
<span style="color: #cc00cc">/// <b>name</b> = </span><span style="color: blue">'ExtractMOH510ImmunisationRegister'</span>
<span style="color: #cc00cc">/// <b>title</b> = </span><span style="color: blue">'MOH 510 Immunisation Permanent Register Extraction'</span>
<span style="color: #cc00cc">/// <b>status</b> = </span><span style="color: blue">'active'</span>
<span style="color: #cc00cc">/// <b>description</b> = </span><span style="color: blue">'Extracts a transaction Bundle from a QuestionnaireResponse to the Kenya MOH 510 Immunisation Permanent Register: guardian RelatedPersons, growth-monitoring Observations, one Immunization per antigen dose for sections L-Y/AA-AB/AD, Vitamin A MedicationAdministrations for section Z, danger-signs and education Observations, and an Appointment for the next scheduled visit. It creates no Patient, Encounter or EpisodeOfCare -- the register is launched from inside a visit the EMR has already opened, so all three arrive as context on the QuestionnaireResponse and are referenced rather than minted. QuestionnaireResponse.subject and .encounter are therefore both required.'</span>
<span style="color: #cc00cc">/// <b>experimental</b> = </span><span style="color: blue">true</span>

<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/questionnaireresponse.html" title="QuestionnaireResponse">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style="color: navy">&quot; </span><b>alias </b>QR <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/bundle.html" title="Bundle">http://hl7.org/fhir/StructureDefinition/Bundle</a><span style="color: navy">&quot; </span><b>alias </b>Bundle <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/relatedperson.html" title="RelatedPerson">http://hl7.org/fhir/StructureDefinition/RelatedPerson</a><span style="color: navy">&quot; </span><b>alias </b>RelatedPerson <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/observation.html" title="Observation">http://hl7.org/fhir/StructureDefinition/Observation</a><span style="color: navy">&quot; </span><b>alias </b>Observation <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/immunization.html" title="Immunization">http://hl7.org/fhir/StructureDefinition/Immunization</a><span style="color: navy">&quot; </span><b>alias </b>Immunization <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/medicationadministration.html" title="MedicationAdministration">http://hl7.org/fhir/StructureDefinition/MedicationAdministration</a><span style="color: navy">&quot; </span><b>alias </b>MedicationAdministration <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/appointment.html" title="Appointment">http://hl7.org/fhir/StructureDefinition/Appointment</a><span style="color: navy">&quot; </span><b>alias </b>Appointment <b>as </b><b>target</b>

<b>group </b>ExtractMOH510ImmunisationRegister<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>bundle.type = <span style="color: blue">'transaction'</span> <i>&quot;setBundleType&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------- A-K</span>
  qr.item<b> as </b><span style="color: maroon">gReg</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-group-registration'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    <span style="color: navy">// </span><span style="color: green">No Patient is emitted. The child is registered before the register entry</span>
    <span style="color: navy">// </span><span style="color: green">is filled, so the patient already exists and arrives as</span>
    <span style="color: navy">// </span><span style="color: green">QuestionnaireResponse.subject -- every resource below references it.</span>
    <span style="color: navy">// </span><span style="color: green">Sections C (child number), D (name), E (sex), F (date of birth) and</span>
    <span style="color: navy">// </span><span style="color: green">J (address) are the paper form transcribing demographics the EMR already</span>
    <span style="color: navy">// </span><span style="color: green">holds, so they are deliberately not extracted: creating a Patient here</span>
    <span style="color: navy">// </span><span style="color: green">would mint a duplicate record, and a blind PUT would clobber fields the</span>
    <span style="color: navy">// </span><span style="color: green">form does not carry. Reconciling them belongs in registration, not here.</span>
    <span style="color: navy">// </span><span style="color: green">This makes QuestionnaireResponse.subject mandatory for extraction --</span>
    <span style="color: navy">// </span><span style="color: green">without it Immunization.patient (1..1) cannot be populated.</span>
    gReg.item<b> as </b><span style="color: maroon">itH</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-RG-H-father-name'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itH.answer first<b> as </b><span style="color: maroon">aH</span><b> then</b><span style="color: navy"> {
</span>        aH<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eFat</span><span style="color: navy">, </span> eFat.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'RelatedPerson'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">fat</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> fat<span style="color: navy">, </span> eFat<b> then </b>BuildRelatedPerson<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itH</span><span style="color: navy">, </span><span style="color: maroon">fat</span><span style="color: navy">, </span><span style="color: maroon">eFat</span><span style="color: navy">)</span> <i>&quot;fatherBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>fat.relationship<b> as </b><span style="color: maroon">relF</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>relF.coding<b> as </b><span style="color: maroon">relFc</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>relFc.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v3-RoleCode'</span> <i>&quot;fatRelSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>relFc.code = <span style="color: blue">'FTH'</span> <i>&quot;fatRelCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>relFc.display = <span style="color: blue">'father'</span> <i>&quot;fatRelDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;fatherRelCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;fatherRelationship&quot;</i><span style="color: navy">;</span>
          aH.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>fat.name<b> as </b><span style="color: maroon">nF</span><b> then</b><span style="color: navy"> {
</span>            v<span style="color: navy"><b> -&gt; </b></span>nF.text = <span style="color: maroon">v</span> <i>&quot;fatherNameText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;fatherName&quot;</i><span style="color: navy">;</span>
          gReg.item<b> as </b><span style="color: maroon">itKf</span><b> where </b><span style="color: navy">(</span>linkId = '42077-8'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>            itKf.answer first<b> as </b><span style="color: maroon">aKf</span><b> then</b><span style="color: navy"> {
</span>              aKf.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>fat.telecom<b> as </b><span style="color: maroon">tcF</span><b> then</b><span style="color: navy"> {
</span>                qr<span style="color: navy"><b> -&gt; </b></span>tcF.system = <span style="color: blue">'phone'</span> <i>&quot;fatPhoneSystem&quot;</i><span style="color: navy">;</span>
                v<span style="color: navy"><b> -&gt; </b></span>tcF.value = <span style="color: maroon">v</span> <i>&quot;fatPhoneValue&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;fatherTelecom&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;fatherPhoneAnswer&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;fatherPhoneRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;fatherResource&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;fatherAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;fatherRule&quot;</i><span style="color: navy">;</span>
    gReg.item<b> as </b><span style="color: maroon">itI</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-RG-I-mother-name'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itI.answer first<b> as </b><span style="color: maroon">aI</span><b> then</b><span style="color: navy"> {
</span>        aI<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eMot</span><span style="color: navy">, </span> eMot.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'RelatedPerson'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">mot</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> mot<span style="color: navy">, </span> eMot<b> then </b>BuildRelatedPerson<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itI</span><span style="color: navy">, </span><span style="color: maroon">mot</span><span style="color: navy">, </span><span style="color: maroon">eMot</span><span style="color: navy">)</span> <i>&quot;motherBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>mot.relationship<b> as </b><span style="color: maroon">relM</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>relM.coding<b> as </b><span style="color: maroon">relMc</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>relMc.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v3-RoleCode'</span> <i>&quot;motRelSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>relMc.code = <span style="color: blue">'MTH'</span> <i>&quot;motRelCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>relMc.display = <span style="color: blue">'mother'</span> <i>&quot;motRelDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;motherRelCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;motherRelationship&quot;</i><span style="color: navy">;</span>
          aI.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>mot.name<b> as </b><span style="color: maroon">nM</span><b> then</b><span style="color: navy"> {
</span>            v<span style="color: navy"><b> -&gt; </b></span>nM.text = <span style="color: maroon">v</span> <i>&quot;motherNameText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;motherName&quot;</i><span style="color: navy">;</span>
          gReg.item<b> as </b><span style="color: maroon">itKm</span><b> where </b><span style="color: navy">(</span>linkId = '42077-8'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>            itKm.answer first<b> as </b><span style="color: maroon">aKm</span><b> then</b><span style="color: navy"> {
</span>              aKm.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>mot.telecom<b> as </b><span style="color: maroon">tcM</span><b> then</b><span style="color: navy"> {
</span>                qr<span style="color: navy"><b> -&gt; </b></span>tcM.system = <span style="color: blue">'phone'</span> <i>&quot;motPhoneSystem&quot;</i><span style="color: navy">;</span>
                v<span style="color: navy"><b> -&gt; </b></span>tcM.value = <span style="color: maroon">v</span> <i>&quot;motPhoneValue&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;motherTelecom&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;motherPhoneAnswer&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;motherPhoneRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;motherResource&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;motherAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;motherRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;registrationGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">------------------------------------------------------ Growth monitoring</span>
  qr.item<b> as </b><span style="color: maroon">gGrow</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-group-growth'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    gGrow.item<b> as </b><span style="color: maroon">itW</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-GM-Q1-weight'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itW.answer first<b> as </b><span style="color: maroon">aW</span><b> then</b><span style="color: navy"> {
</span>        aW<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eW</span><span style="color: navy">, </span> eW.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obW</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obW<span style="color: navy">, </span> eW<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obW</span><span style="color: navy">, </span><span style="color: maroon">eW</span><span style="color: navy">)</span> <i>&quot;weightBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obW<b> then </b>VitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obW</span><span style="color: navy">)</span> <i>&quot;weightCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obW.code<b> as </b><span style="color: maroon">cdW</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdW.coding<b> as </b><span style="color: maroon">ccW</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccW.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;wSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccW.code = <span style="color: blue">'29463-7'</span> <i>&quot;wCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccW.display = <span style="color: blue">'Body weight'</span> <i>&quot;wDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;weightCodeCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;weightCode&quot;</i><span style="color: navy">;</span>
          aW.value<b> as </b><span style="color: maroon">dv</span><span style="color: navy"><b> -&gt; </b></span>obW.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">qW</span><b> then</b><span style="color: navy"> {
</span>            dv<span style="color: navy"><b> -&gt; </b></span>qW.value = <span style="color: maroon">dv</span> <i>&quot;wQtyValue&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>qW.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;wQtySystem&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>qW.code = <span style="color: blue">'kg'</span> <i>&quot;wQtyCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>qW.unit = <span style="color: blue">'kilogram'</span> <i>&quot;wQtyUnit&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;weightValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;weightObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;weightAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;weightRule&quot;</i><span style="color: navy">;</span>
    gGrow.item<b> as </b><span style="color: maroon">itH2</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-GM-Q2-height'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itH2.answer first<b> as </b><span style="color: maroon">aH2</span><b> then</b><span style="color: navy"> {
</span>        aH2<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eH2</span><span style="color: navy">, </span> eH2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obH2</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obH2<span style="color: navy">, </span> eH2<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obH2</span><span style="color: navy">, </span><span style="color: maroon">eH2</span><span style="color: navy">)</span> <i>&quot;heightBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obH2<b> then </b>VitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obH2</span><span style="color: navy">)</span> <i>&quot;heightCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obH2.code<b> as </b><span style="color: maroon">cdH2</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdH2.coding<b> as </b><span style="color: maroon">ccH2</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccH2.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;hSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccH2.code = <span style="color: blue">'8302-2'</span> <i>&quot;hCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccH2.display = <span style="color: blue">'Body height'</span> <i>&quot;hDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;heightCodeCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;heightCode&quot;</i><span style="color: navy">;</span>
          aH2.value<b> as </b><span style="color: maroon">dv</span><span style="color: navy"><b> -&gt; </b></span>obH2.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">qH2</span><b> then</b><span style="color: navy"> {
</span>            dv<span style="color: navy"><b> -&gt; </b></span>qH2.value = <span style="color: maroon">dv</span> <i>&quot;hQtyValue&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>qH2.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;hQtySystem&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>qH2.code = <span style="color: blue">'cm'</span> <i>&quot;hQtyCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>qH2.unit = <span style="color: blue">'centimeter'</span> <i>&quot;hQtyUnit&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;heightValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;heightObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;heightAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;heightRule&quot;</i><span style="color: navy">;</span>
    gGrow.item<b> as </b><span style="color: maroon">itMu</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-GM-Q3-muac'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itMu.answer first<b> as </b><span style="color: maroon">aMu</span><b> then</b><span style="color: navy"> {
</span>        aMu<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eMu</span><span style="color: navy">, </span> eMu.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obMu</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obMu<span style="color: navy">, </span> eMu<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obMu</span><span style="color: navy">, </span><span style="color: maroon">eMu</span><span style="color: navy">)</span> <i>&quot;muacBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obMu<b> then </b>VitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obMu</span><span style="color: navy">)</span> <i>&quot;muacCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obMu.code<b> as </b><span style="color: maroon">cdMu</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdMu.coding<b> as </b><span style="color: maroon">ccMu</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccMu.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;muSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccMu.code = <span style="color: blue">'9847-5'</span> <i>&quot;muCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccMu.display = <span style="color: blue">'Circumference site'</span> <i>&quot;muDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;muacCodeCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;muacCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obMu<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itMu</span><span style="color: navy">, </span><span style="color: maroon">obMu</span><span style="color: navy">)</span> <i>&quot;muacValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;muacObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;muacAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;muacRule&quot;</i><span style="color: navy">;</span>
    gGrow.item<b> as </b><span style="color: maroon">itWfa</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-GM-Q4-weight-category'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itWfa.answer first<b> as </b><span style="color: maroon">aWfa</span><b> then</b><span style="color: navy"> {
</span>        aWfa<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eWfa</span><span style="color: navy">, </span> eWfa.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obWfa</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obWfa<span style="color: navy">, </span> eWfa<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obWfa</span><span style="color: navy">, </span><span style="color: maroon">eWfa</span><span style="color: navy">)</span> <i>&quot;wfaBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obWfa<b> then </b>VitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obWfa</span><span style="color: navy">)</span> <i>&quot;wfaCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obWfa.code<b> as </b><span style="color: maroon">cdWfa</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdWfa.coding<b> as </b><span style="color: maroon">ccWfa</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccWfa.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;wfaSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccWfa.code = <span style="color: blue">'77606-2'</span> <i>&quot;wfaCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccWfa.display = <span style="color: blue">'Weight-for-age percentile'</span> <i>&quot;wfaDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;wfaCodeCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;wfaCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obWfa<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itWfa</span><span style="color: navy">, </span><span style="color: maroon">obWfa</span><span style="color: navy">)</span> <i>&quot;wfaValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;wfaObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;wfaAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;wfaRule&quot;</i><span style="color: navy">;</span>
    gGrow.item<b> as </b><span style="color: maroon">itHfa</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-GM-Q5-height-category'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itHfa.answer first<b> as </b><span style="color: maroon">aHfa</span><b> then</b><span style="color: navy"> {
</span>        aHfa<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eHfa</span><span style="color: navy">, </span> eHfa.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obHfa</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obHfa<span style="color: navy">, </span> eHfa<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obHfa</span><span style="color: navy">, </span><span style="color: maroon">eHfa</span><span style="color: navy">)</span> <i>&quot;hfaBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obHfa<b> then </b>VitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obHfa</span><span style="color: navy">)</span> <i>&quot;hfaCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obHfa.code<b> as </b><span style="color: maroon">cdHfa</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdHfa.coding<b> as </b><span style="color: maroon">ccHfa</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccHfa.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;hfaSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccHfa.code = <span style="color: blue">'59576-9'</span> <i>&quot;hfaCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccHfa.display = <span style="color: blue">'Height-for-age percentile'</span> <i>&quot;hfaDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;hfaCodeCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;hfaCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obHfa<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itHfa</span><span style="color: navy">, </span><span style="color: maroon">obHfa</span><span style="color: navy">)</span> <i>&quot;hfaValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;hfaObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;hfaAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;hfaRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;growthGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">------------------------------------------------------------- L-Y vaccines</span>
  qr.item<b> as </b><span style="color: maroon">gVax</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-group-vaccines'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    gVax.item<b> as </b><span style="color: maroon">itL</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-L-bcg'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itL.answer first<b> as </b><span style="color: maroon">aL</span><b> then</b><span style="color: navy"> {
</span>        aL<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eL</span><span style="color: navy">, </span> eL.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imL</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imL<span style="color: navy">, </span> eL<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itL</span><span style="color: navy">, </span><span style="color: maroon">aL</span><span style="color: navy">, </span><span style="color: maroon">imL</span><span style="color: navy">, </span><span style="color: maroon">eL</span><span style="color: navy">)</span> <i>&quot;bcgBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imL.vaccineCode<b> as </b><span style="color: maroon">vcL</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcL.coding<b> as </b><span style="color: maroon">vccL</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccL.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;bcgSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccL.code = <span style="color: blue">'bcg'</span> <i>&quot;bcgCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccL.display = <span style="color: blue">'BCG'</span> <i>&quot;bcgDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;bcgCoding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcL.text = <span style="color: blue">'BCG'</span> <i>&quot;bcgText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;bcgVaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imL.protocolApplied<b> as </b><span style="color: maroon">paL</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paL.series = <span style="color: blue">'BCG'</span> <i>&quot;bcgSeries&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paL.doseNumber = <span style="color: blue">'1'</span> <i>&quot;bcgDose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;bcgProtocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;bcgImmunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;bcgAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;bcgRule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itM</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-M-polio-birth'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itM.answer first<b> as </b><span style="color: maroon">aM</span><b> then</b><span style="color: navy"> {
</span>        aM<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eM</span><span style="color: navy">, </span> eM.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imM</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imM<span style="color: navy">, </span> eM<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itM</span><span style="color: navy">, </span><span style="color: maroon">aM</span><span style="color: navy">, </span><span style="color: maroon">imM</span><span style="color: navy">, </span><span style="color: maroon">eM</span><span style="color: navy">)</span> <i>&quot;opv0Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imM.vaccineCode<b> as </b><span style="color: maroon">vcM</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcM.coding<b> as </b><span style="color: maroon">vccM</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccM.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;opv0System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccM.code = <span style="color: blue">'bopv'</span> <i>&quot;opv0Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccM.display = <span style="color: blue">'Bivalent oral poliovirus vaccine'</span> <i>&quot;opv0Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;opv0Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcM.text = <span style="color: blue">'Polio birth dose (bOPV)'</span> <i>&quot;opv0Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;opv0VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imM.protocolApplied<b> as </b><span style="color: maroon">paM</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paM.series = <span style="color: blue">'Polio (bOPV)'</span> <i>&quot;opv0Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paM.doseNumber = <span style="color: blue">'0'</span> <i>&quot;opv0Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;opv0Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;opv0Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;opv0Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;opv0Rule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itN</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-N-opv1'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itN.answer first<b> as </b><span style="color: maroon">aN</span><b> then</b><span style="color: navy"> {
</span>        aN<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eN</span><span style="color: navy">, </span> eN.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imN</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imN<span style="color: navy">, </span> eN<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itN</span><span style="color: navy">, </span><span style="color: maroon">aN</span><span style="color: navy">, </span><span style="color: maroon">imN</span><span style="color: navy">, </span><span style="color: maroon">eN</span><span style="color: navy">)</span> <i>&quot;opv1Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imN.vaccineCode<b> as </b><span style="color: maroon">vcN</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcN.coding<b> as </b><span style="color: maroon">vccN</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccN.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;opv1System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccN.code = <span style="color: blue">'bopv'</span> <i>&quot;opv1Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccN.display = <span style="color: blue">'Bivalent oral poliovirus vaccine'</span> <i>&quot;opv1Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;opv1Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcN.text = <span style="color: blue">'OPV 1'</span> <i>&quot;opv1Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;opv1VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imN.protocolApplied<b> as </b><span style="color: maroon">paN</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paN.series = <span style="color: blue">'Polio (bOPV)'</span> <i>&quot;opv1Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paN.doseNumber = <span style="color: blue">'1'</span> <i>&quot;opv1Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;opv1Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;opv1Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;opv1Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;opv1Rule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itO</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-O-opv2'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itO.answer first<b> as </b><span style="color: maroon">aO</span><b> then</b><span style="color: navy"> {
</span>        aO<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eO</span><span style="color: navy">, </span> eO.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imO</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imO<span style="color: navy">, </span> eO<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itO</span><span style="color: navy">, </span><span style="color: maroon">aO</span><span style="color: navy">, </span><span style="color: maroon">imO</span><span style="color: navy">, </span><span style="color: maroon">eO</span><span style="color: navy">)</span> <i>&quot;opv2Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imO.vaccineCode<b> as </b><span style="color: maroon">vcO</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcO.coding<b> as </b><span style="color: maroon">vccO</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccO.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;opv2System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccO.code = <span style="color: blue">'bopv'</span> <i>&quot;opv2Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccO.display = <span style="color: blue">'Bivalent oral poliovirus vaccine'</span> <i>&quot;opv2Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;opv2Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcO.text = <span style="color: blue">'OPV 2'</span> <i>&quot;opv2Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;opv2VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imO.protocolApplied<b> as </b><span style="color: maroon">paO</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paO.series = <span style="color: blue">'Polio (bOPV)'</span> <i>&quot;opv2Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paO.doseNumber = <span style="color: blue">'2'</span> <i>&quot;opv2Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;opv2Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;opv2Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;opv2Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;opv2Rule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itP</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-P-opv3'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itP.answer first<b> as </b><span style="color: maroon">aP</span><b> then</b><span style="color: navy"> {
</span>        aP<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eP</span><span style="color: navy">, </span> eP.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imP</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imP<span style="color: navy">, </span> eP<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itP</span><span style="color: navy">, </span><span style="color: maroon">aP</span><span style="color: navy">, </span><span style="color: maroon">imP</span><span style="color: navy">, </span><span style="color: maroon">eP</span><span style="color: navy">)</span> <i>&quot;opv3Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imP.vaccineCode<b> as </b><span style="color: maroon">vcP</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcP.coding<b> as </b><span style="color: maroon">vccP</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccP.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;opv3System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccP.code = <span style="color: blue">'bopv'</span> <i>&quot;opv3Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccP.display = <span style="color: blue">'Bivalent oral poliovirus vaccine'</span> <i>&quot;opv3Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;opv3Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcP.text = <span style="color: blue">'OPV 3'</span> <i>&quot;opv3Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;opv3VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imP.protocolApplied<b> as </b><span style="color: maroon">paP</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paP.series = <span style="color: blue">'Polio (bOPV)'</span> <i>&quot;opv3Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paP.doseNumber = <span style="color: blue">'3'</span> <i>&quot;opv3Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;opv3Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;opv3Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;opv3Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;opv3Rule&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">IPV carries its own antigen code: the questionnaire reuses the OPV LOINC</span>
    <span style="color: navy">// </span><span style="color: green">code for both, which would collapse two distinct vaccines into one.</span>
    gVax.item<b> as </b><span style="color: maroon">itQ</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-Q-ipv'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itQ.answer first<b> as </b><span style="color: maroon">aQ</span><b> then</b><span style="color: navy"> {
</span>        aQ<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eQ</span><span style="color: navy">, </span> eQ.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imQ</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imQ<span style="color: navy">, </span> eQ<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itQ</span><span style="color: navy">, </span><span style="color: maroon">aQ</span><span style="color: navy">, </span><span style="color: maroon">imQ</span><span style="color: navy">, </span><span style="color: maroon">eQ</span><span style="color: navy">)</span> <i>&quot;ipvBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imQ.vaccineCode<b> as </b><span style="color: maroon">vcQ</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcQ.coding<b> as </b><span style="color: maroon">vccQ</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccQ.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;ipvSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccQ.code = <span style="color: blue">'ipv'</span> <i>&quot;ipvCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccQ.display = <span style="color: blue">'Inactivated poliovirus vaccine'</span> <i>&quot;ipvDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;ipvCoding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcQ.text = <span style="color: blue">'IPV'</span> <i>&quot;ipvText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;ipvVaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imQ.protocolApplied<b> as </b><span style="color: maroon">paQ</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paQ.series = <span style="color: blue">'Polio (IPV)'</span> <i>&quot;ipvSeries&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paQ.doseNumber = <span style="color: blue">'1'</span> <i>&quot;ipvDose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;ipvProtocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;ipvImmunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;ipvAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;ipvRule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itR</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-R-penta1'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itR.answer first<b> as </b><span style="color: maroon">aR</span><b> then</b><span style="color: navy"> {
</span>        aR<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eR</span><span style="color: navy">, </span> eR.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imR</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imR<span style="color: navy">, </span> eR<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itR</span><span style="color: navy">, </span><span style="color: maroon">aR</span><span style="color: navy">, </span><span style="color: maroon">imR</span><span style="color: navy">, </span><span style="color: maroon">eR</span><span style="color: navy">)</span> <i>&quot;penta1Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imR.vaccineCode<b> as </b><span style="color: maroon">vcR</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcR.coding<b> as </b><span style="color: maroon">vccR</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccR.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;penta1System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccR.code = <span style="color: blue">'penta'</span> <i>&quot;penta1Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccR.display = <span style="color: blue">'DTP-HepB-Hib (pentavalent) vaccine'</span> <i>&quot;penta1Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;penta1Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcR.text = <span style="color: blue">'Pentavalent 1'</span> <i>&quot;penta1Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;penta1VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imR.protocolApplied<b> as </b><span style="color: maroon">paR</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paR.series = <span style="color: blue">'Pentavalent'</span> <i>&quot;penta1Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paR.doseNumber = <span style="color: blue">'1'</span> <i>&quot;penta1Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;penta1Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;penta1Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;penta1Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;penta1Rule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itS</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-S-penta2'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itS.answer first<b> as </b><span style="color: maroon">aS</span><b> then</b><span style="color: navy"> {
</span>        aS<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eS</span><span style="color: navy">, </span> eS.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imS</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imS<span style="color: navy">, </span> eS<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itS</span><span style="color: navy">, </span><span style="color: maroon">aS</span><span style="color: navy">, </span><span style="color: maroon">imS</span><span style="color: navy">, </span><span style="color: maroon">eS</span><span style="color: navy">)</span> <i>&quot;penta2Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imS.vaccineCode<b> as </b><span style="color: maroon">vcS</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcS.coding<b> as </b><span style="color: maroon">vccS</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccS.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;penta2System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccS.code = <span style="color: blue">'penta'</span> <i>&quot;penta2Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccS.display = <span style="color: blue">'DTP-HepB-Hib (pentavalent) vaccine'</span> <i>&quot;penta2Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;penta2Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcS.text = <span style="color: blue">'Pentavalent 2'</span> <i>&quot;penta2Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;penta2VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imS.protocolApplied<b> as </b><span style="color: maroon">paS</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paS.series = <span style="color: blue">'Pentavalent'</span> <i>&quot;penta2Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paS.doseNumber = <span style="color: blue">'2'</span> <i>&quot;penta2Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;penta2Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;penta2Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;penta2Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;penta2Rule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itT</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-T-penta3'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itT.answer first<b> as </b><span style="color: maroon">aT</span><b> then</b><span style="color: navy"> {
</span>        aT<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eT</span><span style="color: navy">, </span> eT.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imT</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imT<span style="color: navy">, </span> eT<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itT</span><span style="color: navy">, </span><span style="color: maroon">aT</span><span style="color: navy">, </span><span style="color: maroon">imT</span><span style="color: navy">, </span><span style="color: maroon">eT</span><span style="color: navy">)</span> <i>&quot;penta3Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imT.vaccineCode<b> as </b><span style="color: maroon">vcT</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcT.coding<b> as </b><span style="color: maroon">vccT</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccT.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;penta3System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccT.code = <span style="color: blue">'penta'</span> <i>&quot;penta3Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccT.display = <span style="color: blue">'DTP-HepB-Hib (pentavalent) vaccine'</span> <i>&quot;penta3Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;penta3Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcT.text = <span style="color: blue">'Pentavalent 3'</span> <i>&quot;penta3Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;penta3VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imT.protocolApplied<b> as </b><span style="color: maroon">paT</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paT.series = <span style="color: blue">'Pentavalent'</span> <i>&quot;penta3Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paT.doseNumber = <span style="color: blue">'3'</span> <i>&quot;penta3Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;penta3Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;penta3Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;penta3Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;penta3Rule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itU</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-U-pcv1'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itU.answer first<b> as </b><span style="color: maroon">aU</span><b> then</b><span style="color: navy"> {
</span>        aU<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eU</span><span style="color: navy">, </span> eU.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imU</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imU<span style="color: navy">, </span> eU<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itU</span><span style="color: navy">, </span><span style="color: maroon">aU</span><span style="color: navy">, </span><span style="color: maroon">imU</span><span style="color: navy">, </span><span style="color: maroon">eU</span><span style="color: navy">)</span> <i>&quot;pcv1Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imU.vaccineCode<b> as </b><span style="color: maroon">vcU</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcU.coding<b> as </b><span style="color: maroon">vccU</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccU.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;pcv1System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccU.code = <span style="color: blue">'pcv10'</span> <i>&quot;pcv1Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccU.display = <span style="color: blue">'Pneumococcal conjugate vaccine (PCV10)'</span> <i>&quot;pcv1Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;pcv1Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcU.text = <span style="color: blue">'PCV10 1'</span> <i>&quot;pcv1Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;pcv1VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imU.protocolApplied<b> as </b><span style="color: maroon">paU</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paU.series = <span style="color: blue">'PCV10'</span> <i>&quot;pcv1Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paU.doseNumber = <span style="color: blue">'1'</span> <i>&quot;pcv1Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;pcv1Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;pcv1Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;pcv1Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;pcv1Rule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itV</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-V-pcv2'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itV.answer first<b> as </b><span style="color: maroon">aV</span><b> then</b><span style="color: navy"> {
</span>        aV<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eV</span><span style="color: navy">, </span> eV.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imV</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imV<span style="color: navy">, </span> eV<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itV</span><span style="color: navy">, </span><span style="color: maroon">aV</span><span style="color: navy">, </span><span style="color: maroon">imV</span><span style="color: navy">, </span><span style="color: maroon">eV</span><span style="color: navy">)</span> <i>&quot;pcv2Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imV.vaccineCode<b> as </b><span style="color: maroon">vcV</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcV.coding<b> as </b><span style="color: maroon">vccV</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccV.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;pcv2System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccV.code = <span style="color: blue">'pcv10'</span> <i>&quot;pcv2Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccV.display = <span style="color: blue">'Pneumococcal conjugate vaccine (PCV10)'</span> <i>&quot;pcv2Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;pcv2Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcV.text = <span style="color: blue">'PCV10 2'</span> <i>&quot;pcv2Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;pcv2VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imV.protocolApplied<b> as </b><span style="color: maroon">paV</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paV.series = <span style="color: blue">'PCV10'</span> <i>&quot;pcv2Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paV.doseNumber = <span style="color: blue">'2'</span> <i>&quot;pcv2Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;pcv2Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;pcv2Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;pcv2Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;pcv2Rule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itW2</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-W-pcv3'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itW2.answer first<b> as </b><span style="color: maroon">aW2</span><b> then</b><span style="color: navy"> {
</span>        aW2<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eW2</span><span style="color: navy">, </span> eW2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imW2</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imW2<span style="color: navy">, </span> eW2<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itW2</span><span style="color: navy">, </span><span style="color: maroon">aW2</span><span style="color: navy">, </span><span style="color: maroon">imW2</span><span style="color: navy">, </span><span style="color: maroon">eW2</span><span style="color: navy">)</span> <i>&quot;pcv3Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imW2.vaccineCode<b> as </b><span style="color: maroon">vcW2</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcW2.coding<b> as </b><span style="color: maroon">vccW2</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccW2.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;pcv3System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccW2.code = <span style="color: blue">'pcv10'</span> <i>&quot;pcv3Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccW2.display = <span style="color: blue">'Pneumococcal conjugate vaccine (PCV10)'</span> <i>&quot;pcv3Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;pcv3Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcW2.text = <span style="color: blue">'PCV10 3'</span> <i>&quot;pcv3Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;pcv3VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imW2.protocolApplied<b> as </b><span style="color: maroon">paW2</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paW2.series = <span style="color: blue">'PCV10'</span> <i>&quot;pcv3Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paW2.doseNumber = <span style="color: blue">'3'</span> <i>&quot;pcv3Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;pcv3Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;pcv3Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;pcv3Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;pcv3Rule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itX</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-X-rota1'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itX.answer first<b> as </b><span style="color: maroon">aX</span><b> then</b><span style="color: navy"> {
</span>        aX<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eX</span><span style="color: navy">, </span> eX.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imX</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imX<span style="color: navy">, </span> eX<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itX</span><span style="color: navy">, </span><span style="color: maroon">aX</span><span style="color: navy">, </span><span style="color: maroon">imX</span><span style="color: navy">, </span><span style="color: maroon">eX</span><span style="color: navy">)</span> <i>&quot;rota1Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imX.vaccineCode<b> as </b><span style="color: maroon">vcX</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcX.coding<b> as </b><span style="color: maroon">vccX</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccX.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;rota1System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccX.code = <span style="color: blue">'rota'</span> <i>&quot;rota1Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccX.display = <span style="color: blue">'Rotavirus vaccine'</span> <i>&quot;rota1Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;rota1Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcX.text = <span style="color: blue">'Rota 1'</span> <i>&quot;rota1Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;rota1VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imX.protocolApplied<b> as </b><span style="color: maroon">paX</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paX.series = <span style="color: blue">'Rotavirus'</span> <i>&quot;rota1Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paX.doseNumber = <span style="color: blue">'1'</span> <i>&quot;rota1Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;rota1Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;rota1Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;rota1Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;rota1Rule&quot;</i><span style="color: navy">;</span>
    gVax.item<b> as </b><span style="color: maroon">itY</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-Y-rota2'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itY.answer first<b> as </b><span style="color: maroon">aY</span><b> then</b><span style="color: navy"> {
</span>        aY<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eY</span><span style="color: navy">, </span> eY.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imY</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imY<span style="color: navy">, </span> eY<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itY</span><span style="color: navy">, </span><span style="color: maroon">aY</span><span style="color: navy">, </span><span style="color: maroon">imY</span><span style="color: navy">, </span><span style="color: maroon">eY</span><span style="color: navy">)</span> <i>&quot;rota2Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imY.vaccineCode<b> as </b><span style="color: maroon">vcY</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcY.coding<b> as </b><span style="color: maroon">vccY</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccY.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;rota2System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccY.code = <span style="color: blue">'rota'</span> <i>&quot;rota2Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccY.display = <span style="color: blue">'Rotavirus vaccine'</span> <i>&quot;rota2Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;rota2Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcY.text = <span style="color: blue">'Rota 2'</span> <i>&quot;rota2Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;rota2VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imY.protocolApplied<b> as </b><span style="color: maroon">paY</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paY.series = <span style="color: blue">'Rotavirus'</span> <i>&quot;rota2Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paY.doseNumber = <span style="color: blue">'2'</span> <i>&quot;rota2Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;rota2Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;rota2Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;rota2Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;rota2Rule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;vaccineGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">------------------------------------------------- Z Vitamin A supplements</span>
  qr.item<b> as </b><span style="color: maroon">gSup</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-group-supplementation'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    gSup.item<b> as </b><span style="color: maroon">itZ</span><b> where </b><span style="color: navy">(</span>linkId = '55876-9'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itZ.answer first<b> as </b><span style="color: maroon">aZ</span><b> then</b><span style="color: navy"> {
</span>        aZ<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eZ</span><span style="color: navy">, </span> eZ.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'MedicationAdministration'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">maZ</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> maZ<span style="color: navy">, </span> eZ<b> then </b>BuildMedAdmin<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itZ</span><span style="color: navy">, </span><span style="color: maroon">aZ</span><span style="color: navy">, </span><span style="color: maroon">maZ</span><span style="color: navy">, </span><span style="color: maroon">eZ</span><span style="color: navy">)</span> <i>&quot;vitA100Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>maZ.medication<b> as </b><span style="color: maroon">mcrZ</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>mcrZ.concept<b> as </b><span style="color: maroon">mccZ</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>mccZ.coding<b> as </b><span style="color: maroon">mcoZ</span><b> then</b><span style="color: navy"> {
</span>                qr<span style="color: navy"><b> -&gt; </b></span>mcoZ.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-supplement'</span> <i>&quot;vitA100System&quot;</i><span style="color: navy">;</span>
                qr<span style="color: navy"><b> -&gt; </b></span>mcoZ.code = <span style="color: blue">'vitamin-a-100000'</span> <i>&quot;vitA100Code&quot;</i><span style="color: navy">;</span>
                qr<span style="color: navy"><b> -&gt; </b></span>mcoZ.display = <span style="color: blue">'Vitamin A 100,000 IU'</span> <i>&quot;vitA100Display&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;vitA100Coding&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>mccZ.text = <span style="color: blue">'Vitamin A 100,000 IU (6-11 months)'</span> <i>&quot;vitA100Text&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;vitA100Concept&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;vitA100Medication&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>maZ.dosage<b> as </b><span style="color: maroon">dosZ</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>dosZ.dose<b> as </b><span style="color: maroon">dqZ</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>dqZ.value = <span style="color: blue">100000</span> <i>&quot;vitA100DoseValue&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>dqZ.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;vitA100DoseSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>dqZ.code = <span style="color: blue">'[IU]'</span> <i>&quot;vitA100DoseCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>dqZ.unit = <span style="color: blue">'international unit'</span> <i>&quot;vitA100DoseUnit&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;vitA100Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;vitA100Dosage&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;vitA100Resource&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vitA100Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vitA100Rule&quot;</i><span style="color: navy">;</span>
    gSup.item<b> as </b><span style="color: maroon">itZ2</span><b> where </b><span style="color: navy">(</span>linkId = '0v8mpdt'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itZ2.answer first<b> as </b><span style="color: maroon">aZ2</span><b> then</b><span style="color: navy"> {
</span>        aZ2<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eZ2</span><span style="color: navy">, </span> eZ2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'MedicationAdministration'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">maZ2</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> maZ2<span style="color: navy">, </span> eZ2<b> then </b>BuildMedAdmin<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itZ2</span><span style="color: navy">, </span><span style="color: maroon">aZ2</span><span style="color: navy">, </span><span style="color: maroon">maZ2</span><span style="color: navy">, </span><span style="color: maroon">eZ2</span><span style="color: navy">)</span> <i>&quot;vitA200Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>maZ2.medication<b> as </b><span style="color: maroon">mcrZ2</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>mcrZ2.concept<b> as </b><span style="color: maroon">mccZ2</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>mccZ2.coding<b> as </b><span style="color: maroon">mcoZ2</span><b> then</b><span style="color: navy"> {
</span>                qr<span style="color: navy"><b> -&gt; </b></span>mcoZ2.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-supplement'</span> <i>&quot;vitA200System&quot;</i><span style="color: navy">;</span>
                qr<span style="color: navy"><b> -&gt; </b></span>mcoZ2.code = <span style="color: blue">'vitamin-a-200000'</span> <i>&quot;vitA200Code&quot;</i><span style="color: navy">;</span>
                qr<span style="color: navy"><b> -&gt; </b></span>mcoZ2.display = <span style="color: blue">'Vitamin A 200,000 IU'</span> <i>&quot;vitA200Display&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;vitA200Coding&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>mccZ2.text = <span style="color: blue">'Vitamin A 200,000 IU (12 months onwards)'</span> <i>&quot;vitA200Text&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;vitA200Concept&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;vitA200Medication&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>maZ2.dosage<b> as </b><span style="color: maroon">dosZ2</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>dosZ2.dose<b> as </b><span style="color: maroon">dqZ2</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>dqZ2.value = <span style="color: blue">200000</span> <i>&quot;vitA200DoseValue&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>dqZ2.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;vitA200DoseSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>dqZ2.code = <span style="color: blue">'[IU]'</span> <i>&quot;vitA200DoseCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>dqZ2.unit = <span style="color: blue">'international unit'</span> <i>&quot;vitA200DoseUnit&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;vitA200Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;vitA200Dosage&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;vitA200Resource&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vitA200Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vitA200Rule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;supplementationGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">------------------------------------------------------ AA-AB MR1 + Yellow Fever</span>
  qr.item<b> as </b><span style="color: maroon">gMrYf</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-group-mr-yf'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    gMrYf.item<b> as </b><span style="color: maroon">itAa</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-AA-mr1'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itAa.answer first<b> as </b><span style="color: maroon">aAa</span><b> then</b><span style="color: navy"> {
</span>        aAa<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eAa</span><span style="color: navy">, </span> eAa.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imAa</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imAa<span style="color: navy">, </span> eAa<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itAa</span><span style="color: navy">, </span><span style="color: maroon">aAa</span><span style="color: navy">, </span><span style="color: maroon">imAa</span><span style="color: navy">, </span><span style="color: maroon">eAa</span><span style="color: navy">)</span> <i>&quot;mr1Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imAa.vaccineCode<b> as </b><span style="color: maroon">vcAa</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcAa.coding<b> as </b><span style="color: maroon">vccAa</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccAa.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;mr1System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccAa.code = <span style="color: blue">'mr'</span> <i>&quot;mr1Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccAa.display = <span style="color: blue">'Measles-rubella vaccine'</span> <i>&quot;mr1Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;mr1Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcAa.text = <span style="color: blue">'MR 1'</span> <i>&quot;mr1Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;mr1VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imAa.protocolApplied<b> as </b><span style="color: maroon">paAa</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paAa.series = <span style="color: blue">'Measles-Rubella'</span> <i>&quot;mr1Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paAa.doseNumber = <span style="color: blue">'1'</span> <i>&quot;mr1Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;mr1Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;mr1Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;mr1Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;mr1Rule&quot;</i><span style="color: navy">;</span>
    gMrYf.item<b> as </b><span style="color: maroon">itAb</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-AB-yf'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itAb.answer first<b> as </b><span style="color: maroon">aAb</span><b> then</b><span style="color: navy"> {
</span>        aAb<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eAb</span><span style="color: navy">, </span> eAb.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imAb</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imAb<span style="color: navy">, </span> eAb<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itAb</span><span style="color: navy">, </span><span style="color: maroon">aAb</span><span style="color: navy">, </span><span style="color: maroon">imAb</span><span style="color: navy">, </span><span style="color: maroon">eAb</span><span style="color: navy">)</span> <i>&quot;yfBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imAb.vaccineCode<b> as </b><span style="color: maroon">vcAb</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcAb.coding<b> as </b><span style="color: maroon">vccAb</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccAb.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;yfSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccAb.code = <span style="color: blue">'yf'</span> <i>&quot;yfCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccAb.display = <span style="color: blue">'Yellow fever vaccine'</span> <i>&quot;yfDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;yfCoding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcAb.text = <span style="color: blue">'Yellow Fever'</span> <i>&quot;yfText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;yfVaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imAb.protocolApplied<b> as </b><span style="color: maroon">paAb</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paAb.series = <span style="color: blue">'Yellow Fever'</span> <i>&quot;yfSeries&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paAb.doseNumber = <span style="color: blue">'1'</span> <i>&quot;yfDose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;yfProtocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;yfImmunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;yfAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;yfRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;mrYfGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">------------------------------------------------------------- AC FIC date</span>
  qr.item<b> as </b><span style="color: maroon">gFic</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-group-fic'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    gFic.item<b> as </b><span style="color: maroon">itAc</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-FIC-AC-date'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itAc.answer first<b> as </b><span style="color: maroon">aAc</span><b> then</b><span style="color: navy"> {
</span>        aAc<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eAc</span><span style="color: navy">, </span> eAc.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obAc</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obAc<span style="color: navy">, </span> eAc<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obAc</span><span style="color: navy">, </span><span style="color: maroon">eAc</span><span style="color: navy">)</span> <i>&quot;ficBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obAc<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obAc</span><span style="color: navy">)</span> <i>&quot;ficCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obAc.code<b> as </b><span style="color: maroon">cdAc</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdAc.coding<b> as </b><span style="color: maroon">ccAc</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccAc.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;ficSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccAc.code = <span style="color: blue">'11369-6'</span> <i>&quot;ficCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccAc.display = <span style="color: blue">'Immunisation completion status'</span> <i>&quot;ficDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;ficCodeCoding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>cdAc.text = <span style="color: blue">'Fully Immunised Child (FIC) completion date'</span> <i>&quot;ficCodeText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;ficCode&quot;</i><span style="color: navy">;</span>
          aAc.value<b> as </b><span style="color: maroon">dv</span><span style="color: navy"><b> -&gt; </b></span>obAc.value = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">dv</span><span style="color: navy">, </span><span style="color: blue">'dateTime'</span><span style="color: navy">)</span> <i>&quot;ficValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;ficObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;ficAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;ficRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;ficGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">------------------------------------------------------------------ AD MR2</span>
  qr.item<b> as </b><span style="color: maroon">gMr2</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-group-mr2'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    gMr2.item<b> as </b><span style="color: maroon">itAd</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-VAX-AD-mr2'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itAd.answer first<b> as </b><span style="color: maroon">aAd</span><b> then</b><span style="color: navy"> {
</span>        aAd<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eAd</span><span style="color: navy">, </span> eAd.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">imAd</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> imAd<span style="color: navy">, </span> eAd<b> then </b>BuildImm<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">itAd</span><span style="color: navy">, </span><span style="color: maroon">aAd</span><span style="color: navy">, </span><span style="color: maroon">imAd</span><span style="color: navy">, </span><span style="color: maroon">eAd</span><span style="color: navy">)</span> <i>&quot;mr2Base&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imAd.vaccineCode<b> as </b><span style="color: maroon">vcAd</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>vcAd.coding<b> as </b><span style="color: maroon">vccAd</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>vccAd.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;mr2System&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccAd.code = <span style="color: blue">'mr'</span> <i>&quot;mr2Code&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>vccAd.display = <span style="color: blue">'Measles-rubella vaccine'</span> <i>&quot;mr2Display&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;mr2Coding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vcAd.text = <span style="color: blue">'MR 2'</span> <i>&quot;mr2Text&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;mr2VaccineCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>imAd.protocolApplied<b> as </b><span style="color: maroon">paAd</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>paAd.series = <span style="color: blue">'Measles-Rubella'</span> <i>&quot;mr2Series&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>paAd.doseNumber = <span style="color: blue">'2'</span> <i>&quot;mr2Dose&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;mr2Protocol&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;mr2Immunization&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;mr2Answer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;mr2Rule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;mr2Group&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">------------------------------------------------------------- Danger signs</span>
  qr.item<b> as </b><span style="color: maroon">gDs</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-group-danger-signs'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    gDs.item<b> as </b><span style="color: maroon">itD1</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-DS-Q1-fever'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itD1.answer first<b> as </b><span style="color: maroon">aD1</span><b> then</b><span style="color: navy"> {
</span>        aD1<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eD1</span><span style="color: navy">, </span> eD1.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obD1</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obD1<span style="color: navy">, </span> eD1<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD1</span><span style="color: navy">, </span><span style="color: maroon">eD1</span><span style="color: navy">)</span> <i>&quot;feverBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD1<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD1</span><span style="color: navy">)</span> <i>&quot;feverCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD1.code<b> as </b><span style="color: maroon">cdD1</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdD1.coding<b> as </b><span style="color: maroon">ccD1</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccD1.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;feverSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD1.code = <span style="color: blue">'8310-5'</span> <i>&quot;feverCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD1.display = <span style="color: blue">'Body temperature'</span> <i>&quot;feverDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;feverCodeCoding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>cdD1.text = <span style="color: blue">'Fever reported'</span> <i>&quot;feverCodeText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;feverCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD1<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itD1</span><span style="color: navy">, </span><span style="color: maroon">obD1</span><span style="color: navy">)</span> <i>&quot;feverValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;feverObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;feverAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;feverRule&quot;</i><span style="color: navy">;</span>
    gDs.item<b> as </b><span style="color: maroon">itD2</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-DS-Q2-feeding'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itD2.answer first<b> as </b><span style="color: maroon">aD2</span><b> then</b><span style="color: navy"> {
</span>        aD2<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eD2</span><span style="color: navy">, </span> eD2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obD2</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obD2<span style="color: navy">, </span> eD2<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD2</span><span style="color: navy">, </span><span style="color: maroon">eD2</span><span style="color: navy">)</span> <i>&quot;feedingBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD2<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD2</span><span style="color: navy">)</span> <i>&quot;feedingCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD2.code<b> as </b><span style="color: maroon">cdD2</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdD2.coding<b> as </b><span style="color: maroon">ccD2</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccD2.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;feedingSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD2.code = <span style="color: blue">'75890-1'</span> <i>&quot;feedingCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD2.display = <span style="color: blue">'Feeding status'</span> <i>&quot;feedingDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;feedingCodeCoding&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Polarity is inverted relative to the other danger signs: &quot;Yes&quot;</span>
            <span style="color: navy">// </span><span style="color: green">here is reassuring, not alarming.</span>
            qr<span style="color: navy"><b> -&gt; </b></span>cdD2.text = <span style="color: blue">'Child is feeding'</span> <i>&quot;feedingCodeText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;feedingCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD2<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itD2</span><span style="color: navy">, </span><span style="color: maroon">obD2</span><span style="color: navy">)</span> <i>&quot;feedingValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;feedingObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;feedingAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;feedingRule&quot;</i><span style="color: navy">;</span>
    gDs.item<b> as </b><span style="color: maroon">itD3</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-DS-Q3-convulsions'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itD3.answer first<b> as </b><span style="color: maroon">aD3</span><b> then</b><span style="color: navy"> {
</span>        aD3<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eD3</span><span style="color: navy">, </span> eD3.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obD3</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obD3<span style="color: navy">, </span> eD3<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD3</span><span style="color: navy">, </span><span style="color: maroon">eD3</span><span style="color: navy">)</span> <i>&quot;convulsionsBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD3<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD3</span><span style="color: navy">)</span> <i>&quot;convulsionsCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD3.code<b> as </b><span style="color: maroon">cdD3</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdD3.coding<b> as </b><span style="color: maroon">ccD3</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccD3.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;convulsionsSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD3.code = <span style="color: blue">'31398-4'</span> <i>&quot;convulsionsCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD3.display = <span style="color: blue">'Convulsions'</span> <i>&quot;convulsionsDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;convulsionsCodeCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;convulsionsCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD3<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itD3</span><span style="color: navy">, </span><span style="color: maroon">obD3</span><span style="color: navy">)</span> <i>&quot;convulsionsValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;convulsionsObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;convulsionsAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;convulsionsRule&quot;</i><span style="color: navy">;</span>
    gDs.item<b> as </b><span style="color: maroon">itD4</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-DS-Q4-cough'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itD4.answer first<b> as </b><span style="color: maroon">aD4</span><b> then</b><span style="color: navy"> {
</span>        aD4<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eD4</span><span style="color: navy">, </span> eD4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obD4</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obD4<span style="color: navy">, </span> eD4<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD4</span><span style="color: navy">, </span><span style="color: maroon">eD4</span><span style="color: navy">)</span> <i>&quot;coughBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD4<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD4</span><span style="color: navy">)</span> <i>&quot;coughCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD4.code<b> as </b><span style="color: maroon">cdD4</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdD4.coding<b> as </b><span style="color: maroon">ccD4</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccD4.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;coughSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD4.code = <span style="color: blue">'28238-4'</span> <i>&quot;coughCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD4.display = <span style="color: blue">'Cough'</span> <i>&quot;coughDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coughCodeCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coughCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD4<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itD4</span><span style="color: navy">, </span><span style="color: maroon">obD4</span><span style="color: navy">)</span> <i>&quot;coughValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coughObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coughAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;coughRule&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">The questionnaire declares this SNOMED CT concept id under the LOINC</span>
    <span style="color: navy">// </span><span style="color: green">system; emitted here against the SNOMED CT system it actually belongs to.</span>
    gDs.item<b> as </b><span style="color: maroon">itD5</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-DS-Q5-diarrhoea'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itD5.answer first<b> as </b><span style="color: maroon">aD5</span><b> then</b><span style="color: navy"> {
</span>        aD5<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eD5</span><span style="color: navy">, </span> eD5.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obD5</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obD5<span style="color: navy">, </span> eD5<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD5</span><span style="color: navy">, </span><span style="color: maroon">eD5</span><span style="color: navy">)</span> <i>&quot;diarrhoeaBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD5<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD5</span><span style="color: navy">)</span> <i>&quot;diarrhoeaCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD5.code<b> as </b><span style="color: maroon">cdD5</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdD5.coding<b> as </b><span style="color: maroon">ccD5</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccD5.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;diarrhoeaSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD5.code = <span style="color: blue">'28229008'</span> <i>&quot;diarrhoeaCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD5.display = <span style="color: blue">'Diarrhoea'</span> <i>&quot;diarrhoeaDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;diarrhoeaCodeCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;diarrhoeaCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD5<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itD5</span><span style="color: navy">, </span><span style="color: maroon">obD5</span><span style="color: navy">)</span> <i>&quot;diarrhoeaValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;diarrhoeaObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;diarrhoeaAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;diarrhoeaRule&quot;</i><span style="color: navy">;</span>
    gDs.item<b> as </b><span style="color: maroon">itD6</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-DS-Q6-vomiting'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itD6.answer first<b> as </b><span style="color: maroon">aD6</span><b> then</b><span style="color: navy"> {
</span>        aD6<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eD6</span><span style="color: navy">, </span> eD6.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obD6</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obD6<span style="color: navy">, </span> eD6<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD6</span><span style="color: navy">, </span><span style="color: maroon">eD6</span><span style="color: navy">)</span> <i>&quot;vomitingBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD6<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD6</span><span style="color: navy">)</span> <i>&quot;vomitingCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD6.code<b> as </b><span style="color: maroon">cdD6</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdD6.coding<b> as </b><span style="color: maroon">ccD6</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccD6.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;vomitingSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD6.code = <span style="color: blue">'21522001'</span> <i>&quot;vomitingCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD6.display = <span style="color: blue">'Vomiting'</span> <i>&quot;vomitingDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;vomitingCodeCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;vomitingCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD6<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itD6</span><span style="color: navy">, </span><span style="color: maroon">obD6</span><span style="color: navy">)</span> <i>&quot;vomitingValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;vomitingObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vomitingAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vomitingRule&quot;</i><span style="color: navy">;</span>
    gDs.item<b> as </b><span style="color: maroon">itD7</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-DS-Q7-notes'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itD7.answer first<b> as </b><span style="color: maroon">aD7</span><b> then</b><span style="color: navy"> {
</span>        aD7<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eD7</span><span style="color: navy">, </span> eD7.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obD7</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obD7<span style="color: navy">, </span> eD7<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD7</span><span style="color: navy">, </span><span style="color: maroon">eD7</span><span style="color: navy">)</span> <i>&quot;dsNotesBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD7<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obD7</span><span style="color: navy">)</span> <i>&quot;dsNotesCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obD7.code<b> as </b><span style="color: maroon">cdD7</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdD7.coding<b> as </b><span style="color: maroon">ccD7</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccD7.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;dsNotesSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD7.code = <span style="color: blue">'48767-8'</span> <i>&quot;dsNotesCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccD7.display = <span style="color: blue">'Annotation comment'</span> <i>&quot;dsNotesDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;dsNotesCodeCoding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>cdD7.text = <span style="color: blue">'Danger signs clinical notes'</span> <i>&quot;dsNotesCodeText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;dsNotesCode&quot;</i><span style="color: navy">;</span>
          aD7.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obD7.value = <span style="color: maroon">v</span> <i>&quot;dsNotesValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;dsNotesObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;dsNotesAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;dsNotesRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;dangerSignsGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">---------------------------------------------------------- Patient education</span>
  qr.item<b> as </b><span style="color: maroon">gEd</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-group-education'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    gEd.item<b> as </b><span style="color: maroon">itE1</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-ED-Q1-education-given'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itE1.answer first<b> as </b><span style="color: maroon">aE1</span><b> then</b><span style="color: navy"> {
</span>        aE1<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eE1</span><span style="color: navy">, </span> eE1.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obE1</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obE1<span style="color: navy">, </span> eE1<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obE1</span><span style="color: navy">, </span><span style="color: maroon">eE1</span><span style="color: navy">)</span> <i>&quot;eduGivenBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obE1<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obE1</span><span style="color: navy">)</span> <i>&quot;eduGivenCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obE1.code<b> as </b><span style="color: maroon">cdE1</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdE1.coding<b> as </b><span style="color: maroon">ccE1</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccE1.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;eduGivenSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccE1.code = <span style="color: blue">'61144-2'</span> <i>&quot;eduGivenCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccE1.display = <span style="color: blue">'Patient education provided'</span> <i>&quot;eduGivenDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;eduGivenCodeCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;eduGivenCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obE1<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itE1</span><span style="color: navy">, </span><span style="color: maroon">obE1</span><span style="color: navy">)</span> <i>&quot;eduGivenValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;eduGivenObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;eduGivenAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;eduGivenRule&quot;</i><span style="color: navy">;</span>
    gEd.item<b> as </b><span style="color: maroon">itE2</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-ED-Q2-topics'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itE2.answer first<b> as </b><span style="color: maroon">aE2</span><b> then</b><span style="color: navy"> {
</span>        aE2<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eE2</span><span style="color: navy">, </span> eE2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obE2</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obE2<span style="color: navy">, </span> eE2<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obE2</span><span style="color: navy">, </span><span style="color: maroon">eE2</span><span style="color: navy">)</span> <i>&quot;eduTopicsBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obE2<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obE2</span><span style="color: navy">)</span> <i>&quot;eduTopicsCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obE2.code<b> as </b><span style="color: maroon">cdE2</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdE2.coding<b> as </b><span style="color: maroon">ccE2</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccE2.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;eduTopicsSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccE2.code = <span style="color: blue">'61144-2'</span> <i>&quot;eduTopicsCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccE2.display = <span style="color: blue">'Education topics covered'</span> <i>&quot;eduTopicsDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;eduTopicsCodeCoding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>cdE2.text = <span style="color: blue">'Education topics covered'</span> <i>&quot;eduTopicsCodeText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;eduTopicsCode&quot;</i><span style="color: navy">;</span>
          aE2.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obE2.value = <span style="color: maroon">v</span> <i>&quot;eduTopicsValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;eduTopicsObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;eduTopicsAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;eduTopicsRule&quot;</i><span style="color: navy">;</span>
    gEd.item<b> as </b><span style="color: maroon">itE3</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-ED-Q3-next-visit'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itE3.answer first<b> as </b><span style="color: maroon">aE3</span><b> then</b><span style="color: navy"> {
</span>        aE3<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eE3</span><span style="color: navy">, </span> eE3.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obE3</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obE3<span style="color: navy">, </span> eE3<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obE3</span><span style="color: navy">, </span><span style="color: maroon">eE3</span><span style="color: navy">)</span> <i>&quot;nextVisitToldBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obE3<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obE3</span><span style="color: navy">)</span> <i>&quot;nextVisitToldCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obE3.code<b> as </b><span style="color: maroon">cdE3</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdE3.coding<b> as </b><span style="color: maroon">ccE3</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccE3.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;nextVisitToldSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccE3.code = <span style="color: blue">'57177-3'</span> <i>&quot;nextVisitToldCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccE3.display = <span style="color: blue">'Follow-up plan'</span> <i>&quot;nextVisitToldDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;nextVisitToldCodeCoding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>cdE3.text = <span style="color: blue">'Next visit date communicated to caregiver'</span> <i>&quot;nextVisitToldCodeText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;nextVisitToldCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obE3<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">itE3</span><span style="color: navy">, </span><span style="color: maroon">obE3</span><span style="color: navy">)</span> <i>&quot;nextVisitToldValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;nextVisitToldObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;nextVisitToldAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;nextVisitToldRule&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Appointment.start is an instant, so a date-only answer is carried on</span>
    <span style="color: navy">// </span><span style="color: green">requestedPeriod instead.</span>
    gEd.item<b> as </b><span style="color: maroon">itE4</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-ED-Q4-next-visit-date'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itE4.answer first<b> as </b><span style="color: maroon">aE4</span><b> then</b><span style="color: navy"> {
</span>        aE4<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eE4</span><span style="color: navy">, </span> eE4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Appointment'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">appt</span><b> then</b><span style="color: navy"> {
</span>          <span style="color: navy">// </span><span style="color: green">One proposed appointment per (child, requested date).</span>
          aE4.value<b> as </b><span style="color: maroon">dvAp</span><span style="color: navy"><b> -&gt; </b></span>appt.identifier<b> as </b><span style="color: maroon">idAp</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>idAp.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell'</span> <i>&quot;apptCellSystem&quot;</i><span style="color: navy">;</span>
            dvAp<span style="color: navy"><b> -&gt; </b></span>idAp.value = <b>append</b><span style="color: navy">(</span><span style="color: blue">'IMM-ED-Q4-next-visit-date@'</span><span style="color: navy">, </span><span style="color: maroon">dvAp</span><span style="color: navy">)</span> <i>&quot;apptCellValue&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;apptCellIdentifier&quot;</i><span style="color: navy">;</span>
          qr.subject<b> as </b><span style="color: maroon">subjAp</span><b> then</b><span style="color: navy"> {
</span>            subjAp.reference<b> as </b><span style="color: maroon">prefAp</span><b> then</b><span style="color: navy"> {
</span>              aE4.value<b> as </b><span style="color: maroon">dvAp2</span><span style="color: navy"><b> -&gt; </b></span>eE4.request<b> as </b><span style="color: maroon">rqAp</span><b> then</b><span style="color: navy"> {
</span>                qr<span style="color: navy"><b> -&gt; </b></span>rqAp.method = <span style="color: blue">'POST'</span> <i>&quot;apptReqMethod&quot;</i><span style="color: navy">;</span>
                qr<span style="color: navy"><b> -&gt; </b></span>rqAp.url = <span style="color: blue">'Appointment'</span> <i>&quot;apptReqUrl&quot;</i><span style="color: navy">;</span>
                qr<span style="color: navy"><b> -&gt; </b></span>rqAp.ifNoneExist = <b>append</b><span style="color: navy">(</span><span style="color: blue">'actor='</span><span style="color: navy">, </span><span style="color: maroon">prefAp</span><span style="color: navy">, </span><span style="color: blue">'&amp;identifier=https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell|IMM-ED-Q4-next-visit-date@'</span><span style="color: navy">, </span><span style="color: maroon">dvAp2</span><span style="color: navy">)</span> <i>&quot;apptIfNoneExist&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;apptReq&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;apptPatientRef&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;apptSubject&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>appt.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;apptId&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>appt.status = <span style="color: blue">'proposed'</span> <i>&quot;apptStatus&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>appt.description = <span style="color: blue">'Next scheduled immunisation visit (MOH 510)'</span> <i>&quot;apptDescription&quot;</i><span style="color: navy">;</span>
          qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -&gt; </b></span>appt.subject = <span style="color: maroon">s</span> <i>&quot;apptSubject&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>appt.participant<b> as </b><span style="color: maroon">prt</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>prt.status = <span style="color: blue">'needs-action'</span> <i>&quot;apptParticipantStatus&quot;</i><span style="color: navy">;</span>
            qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -&gt; </b></span>prt.actor = <span style="color: maroon">s</span> <i>&quot;apptParticipantActor&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;apptParticipant&quot;</i><span style="color: navy">;</span>
          aE4.value<b> as </b><span style="color: maroon">dv</span><span style="color: navy"><b> -&gt; </b></span>appt.requestedPeriod<b> as </b><span style="color: maroon">rp</span><b> then</b><span style="color: navy"> {
</span>            dv<span style="color: navy"><b> -&gt; </b></span>rp.start = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">dv</span><span style="color: navy">, </span><span style="color: blue">'dateTime'</span><span style="color: navy">)</span> <i>&quot;apptRequestedStart&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;apptRequestedPeriod&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;appointmentResource&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;nextVisitDateAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;nextVisitDateRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;educationGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------- AE Remarks</span>
  qr.item<b> as </b><span style="color: maroon">gRem</span><b> where </b><span style="color: navy">(</span>linkId = 'IMM-group-remarks'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    gRem.item<b> as </b><span style="color: maroon">itAe</span><b> where </b><span style="color: navy">(</span>linkId = '48767-8'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      itAe.answer first<b> as </b><span style="color: maroon">aAe</span><b> then</b><span style="color: navy"> {
</span>        aAe<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eAe</span><span style="color: navy">, </span> eAe.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obAe</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span> obAe<span style="color: navy">, </span> eAe<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obAe</span><span style="color: navy">, </span><span style="color: maroon">eAe</span><span style="color: navy">)</span> <i>&quot;remarksBase&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obAe<b> then </b>SurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obAe</span><span style="color: navy">)</span> <i>&quot;remarksCategory&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>obAe.code<b> as </b><span style="color: maroon">cdAe</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>cdAe.coding<b> as </b><span style="color: maroon">ccAe</span><b> then</b><span style="color: navy"> {
</span>              qr<span style="color: navy"><b> -&gt; </b></span>ccAe.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;remarksSystem&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccAe.code = <span style="color: blue">'48767-8'</span> <i>&quot;remarksCode&quot;</i><span style="color: navy">;</span>
              qr<span style="color: navy"><b> -&gt; </b></span>ccAe.display = <span style="color: blue">'Annotation comment'</span> <i>&quot;remarksDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;remarksCodeCoding&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>cdAe.text = <span style="color: blue">'MOH 510 register remarks'</span> <i>&quot;remarksCodeText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;remarksCode&quot;</i><span style="color: navy">;</span>
          aAe.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obAe.value = <span style="color: maroon">v</span> <i>&quot;remarksValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;remarksObservation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;remarksAnswer&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;remarksRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;remarksGroup&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">---------------------------------------------------------------- helper groups</span>
<span style="color: navy">// </span><span style="color: green">Plain POST, deliberately not a conditional create. These are per-visit facts,</span>
<span style="color: navy">// </span><span style="color: green">so the key would have to be (cell, visit) -- and qr.authored carries a</span>
<span style="color: navy">// </span><span style="color: green">&quot;+03:00&quot; offset that cannot go into an ifNoneExist query string unencoded.</span>
<span style="color: navy">// </span><span style="color: green">Consequence: extracting the SAME response twice duplicates its Observations.</span>
<span style="color: navy">// </span><span style="color: green">Populate never fills these sections, so the populate/extract loop is</span>
<span style="color: navy">// </span><span style="color: green">unaffected; only a repeated submission of one response is.</span>
<b>group </b>BuildObsBase<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">rq</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>rq.method = <span style="color: blue">'POST'</span> <i>&quot;obsReqMethod&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>rq.url = <span style="color: blue">'Observation'</span> <i>&quot;obsReqUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;obsReq&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;obsId&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>obs.status = <span style="color: blue">'final'</span> <i>&quot;obsStatus&quot;</i><span style="color: navy">;</span>
  qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -&gt; </b></span>obs.subject = <span style="color: maroon">s</span> <i>&quot;obsSubject&quot;</i><span style="color: navy">;</span>
  qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>obs.encounter = <span style="color: maroon">e</span> <i>&quot;obsEncounter&quot;</i><span style="color: navy">;</span>
  qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: maroon">t</span> <i>&quot;obsEffective&quot;</i><span style="color: navy">;</span>
  <span style="color: #b36b00" title="This element was not defined prior to R5">// qr.id is already type-qualified (&quot;QuestionnaireResponse/1008&quot;) when the</span>
  <span style="color: navy">// </span><span style="color: green">response is read from the server, so prepending the type -- or using</span>
  <span style="color: navy">// </span><span style="color: green">reference() -- yields a doubled reference.</span>
  qr.id<b> as </b><span style="color: maroon">qid</span><span style="color: navy"><b> -&gt; </b></span>obs.derivedFrom = <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">dr</span><b> then</b><span style="color: navy"> {
</span>    qid<span style="color: navy"><b> -&gt; </b></span>dr.reference = <span style="color: maroon">qid</span> <i>&quot;obsDerivedRef&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;obsDerivedFrom&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">A register cell -- (child, column) -- is the natural key for everything below.</span>
<span style="color: navy">// </span><span style="color: green">The paper form has exactly one BCG box per child, so re-submitting a</span>
<span style="color: navy">// </span><span style="color: green">pre-populated form must not add a second one. Each resource therefore carries</span>
<span style="color: navy">// </span><span style="color: green">its linkId as a business identifier and is emitted as a conditional create.</span>
<b>group </b>BuildImm<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>source</b> <span style="color: maroon">it</span>, <b>source</b> <span style="color: maroon">a</span>, <b>target</b> <span style="color: maroon">imm</span><span style="color: navy"> : </span>Immunization, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  it.linkId<b> as </b><span style="color: maroon">lk</span><span style="color: navy"><b> -&gt; </b></span>imm.identifier<b> as </b><span style="color: maroon">idc</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>idc.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell'</span> <i>&quot;immCellSystem&quot;</i><span style="color: navy">;</span>
    lk<span style="color: navy"><b> -&gt; </b></span>idc.value = <span style="color: maroon">lk</span> <i>&quot;immCellValue&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;immCellIdentifier&quot;</i><span style="color: navy">;</span>
  qr.subject<b> as </b><span style="color: maroon">subjImm</span><b> then</b><span style="color: navy"> {
</span>    subjImm.reference<b> as </b><span style="color: maroon">pref</span><b> then</b><span style="color: navy"> {
</span>      it.linkId<b> as </b><span style="color: maroon">lk2</span><span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">rq</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span>rq.method = <span style="color: blue">'POST'</span> <i>&quot;immReqMethod&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>rq.url = <span style="color: blue">'Immunization'</span> <i>&quot;immReqUrl&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>rq.ifNoneExist = <b>append</b><span style="color: navy">(</span><span style="color: blue">'patient='</span><span style="color: navy">, </span><span style="color: maroon">pref</span><span style="color: navy">, </span><span style="color: blue">'&amp;identifier=https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell|'</span><span style="color: navy">, </span><span style="color: maroon">lk2</span><span style="color: navy">)</span> <i>&quot;immIfNoneExist&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;immReq&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;immPatientRef&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;immSubject&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>imm.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;immId&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>imm.status = <span style="color: blue">'completed'</span> <i>&quot;immStatus&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Register entries are transcribed from the child's card, so the recording</span>
  <span style="color: navy">// </span><span style="color: green">facility is not necessarily the administering one.</span>
  qr<span style="color: navy"><b> -&gt; </b></span>imm.primarySource = <span style="color: blue">false</span> <i>&quot;immPrimarySource&quot;</i><span style="color: navy">;</span>
  qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -&gt; </b></span>imm.patient = <span style="color: maroon">s</span> <i>&quot;immPatient&quot;</i><span style="color: navy">;</span>
  qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>imm.encounter = <span style="color: maroon">e</span> <i>&quot;immEncounter&quot;</i><span style="color: navy">;</span>
  a.value<b> as </b><span style="color: maroon">dv</span><span style="color: navy"><b> -&gt; </b></span>imm.occurrence = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">dv</span><span style="color: navy">, </span><span style="color: blue">'dateTime'</span><span style="color: navy">)</span> <i>&quot;immOccurrence&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>BuildMedAdmin<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>source</b> <span style="color: maroon">it</span>, <b>source</b> <span style="color: maroon">a</span>, <b>target</b> <span style="color: maroon">ma</span><span style="color: navy"> : </span>MedicationAdministration, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  it.linkId<b> as </b><span style="color: maroon">lk</span><span style="color: navy"><b> -&gt; </b></span>ma.identifier<b> as </b><span style="color: maroon">idc</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>idc.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell'</span> <i>&quot;maCellSystem&quot;</i><span style="color: navy">;</span>
    lk<span style="color: navy"><b> -&gt; </b></span>idc.value = <span style="color: maroon">lk</span> <i>&quot;maCellValue&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;maCellIdentifier&quot;</i><span style="color: navy">;</span>
  qr.subject<b> as </b><span style="color: maroon">subjMa</span><b> then</b><span style="color: navy"> {
</span>    subjMa.reference<b> as </b><span style="color: maroon">pref</span><b> then</b><span style="color: navy"> {
</span>      it.linkId<b> as </b><span style="color: maroon">lk2</span><span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">rq</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span>rq.method = <span style="color: blue">'POST'</span> <i>&quot;maReqMethod&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>rq.url = <span style="color: blue">'MedicationAdministration'</span> <i>&quot;maReqUrl&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>rq.ifNoneExist = <b>append</b><span style="color: navy">(</span><span style="color: blue">'subject='</span><span style="color: navy">, </span><span style="color: maroon">pref</span><span style="color: navy">, </span><span style="color: blue">'&amp;identifier=https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell|'</span><span style="color: navy">, </span><span style="color: maroon">lk2</span><span style="color: navy">)</span> <i>&quot;maIfNoneExist&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;maReq&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;maPatientRef&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;maSubject&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>ma.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;maId&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>ma.status = <span style="color: blue">'completed'</span> <i>&quot;maStatus&quot;</i><span style="color: navy">;</span>
  qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -&gt; </b></span>ma.subject = <span style="color: maroon">s</span> <i>&quot;maSubject&quot;</i><span style="color: navy">;</span>
  qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>ma.encounter = <span style="color: maroon">e</span> <i>&quot;maEncounter&quot;</i><span style="color: navy">;</span>
  a.value<b> as </b><span style="color: maroon">dv</span><span style="color: navy"><b> -&gt; </b></span>ma.occurence = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">dv</span><span style="color: navy">, </span><span style="color: blue">'dateTime'</span><span style="color: navy">)</span> <i>&quot;maOccurence&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>BuildRelatedPerson<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>source</b> <span style="color: maroon">it</span>, <b>target</b> <span style="color: maroon">rp</span><span style="color: navy"> : </span>RelatedPerson, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  it.linkId<b> as </b><span style="color: maroon">lk</span><span style="color: navy"><b> -&gt; </b></span>rp.identifier<b> as </b><span style="color: maroon">idc</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>idc.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell'</span> <i>&quot;rpCellSystem&quot;</i><span style="color: navy">;</span>
    lk<span style="color: navy"><b> -&gt; </b></span>idc.value = <span style="color: maroon">lk</span> <i>&quot;rpCellValue&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;rpCellIdentifier&quot;</i><span style="color: navy">;</span>
  qr.subject<b> as </b><span style="color: maroon">subjRp</span><b> then</b><span style="color: navy"> {
</span>    subjRp.reference<b> as </b><span style="color: maroon">pref</span><b> then</b><span style="color: navy"> {
</span>      it.linkId<b> as </b><span style="color: maroon">lk2</span><span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">rq</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span>rq.method = <span style="color: blue">'POST'</span> <i>&quot;rpReqMethod&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>rq.url = <span style="color: blue">'RelatedPerson'</span> <i>&quot;rpReqUrl&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>rq.ifNoneExist = <b>append</b><span style="color: navy">(</span><span style="color: blue">'patient='</span><span style="color: navy">, </span><span style="color: maroon">pref</span><span style="color: navy">, </span><span style="color: blue">'&amp;identifier=https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell|'</span><span style="color: navy">, </span><span style="color: maroon">lk2</span><span style="color: navy">)</span> <i>&quot;rpIfNoneExist&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;rpReq&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;rpPatientRef&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;rpSubject&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>rp.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;rpId&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>rp.active = <span style="color: blue">true</span> <i>&quot;rpActive&quot;</i><span style="color: navy">;</span>
  qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -&gt; </b></span>rp.patient = <span style="color: maroon">s</span> <i>&quot;rpPatient&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>VitalSignsCategory<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>obs.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">c</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>c.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;vsCatSystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>c.code = <span style="color: blue">'vital-signs'</span> <i>&quot;vsCatCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>c.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;vsCatDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vsCatCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;vsCat&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SurveyCategory<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>obs.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">c</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>c.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;svCatSystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>c.code = <span style="color: blue">'survey'</span> <i>&quot;svCatCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>c.display = <span style="color: blue">'Survey'</span> <i>&quot;svCatDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;svCatCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;svCat&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetCodedValue<span style="color: navy">(</span><b>source</b> <span style="color: maroon">it</span><span style="color: navy"> : </span>Element, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation<span style="color: navy">)</span><span style="color: navy"> {
</span>  it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <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">c</span><b> then</b><span style="color: navy"> {
</span>    a.value<b> as </b><span style="color: maroon">coding</span><span style="color: navy"><b> -&gt; </b></span>c.coding = <span style="color: maroon">coding</span><b> as </b><span style="color: maroon">nc</span> <i>&quot;copyCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;setCodedValue&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url
       value="https://fhir.slade360.co.ke/fhir/StructureMap/ExtractMOH510ImmunisationRegister"/>
  <version value="0.1.0"/>
  <name value="ExtractMOH510ImmunisationRegister"/>
  <title value="MOH 510 Immunisation Permanent Register Extraction"/>
  <status value="active"/>
  <experimental value="true"/>
  <date value="2026-09-14T06:31:13+00:00"/>
  <publisher value="Kathurima Kimathi"/>
  <contact>
    <name value="Kathurima Kimathi"/>
    <telecom>
      <system value="url"/>
      <value value="https://www.linkedin.com/in/kathurima-kimathi/"/>
    </telecom>
    <telecom>
      <system value="email"/>
      <value value="kathurimakimathi415@gmail.com"/>
    </telecom>
  </contact>
  <contact>
    <name value="Oscar John"/>
    <telecom>
      <system value="email"/>
      <value value="oscarjohnotieno@gmail.com"/>
      <use value="work"/>
    </telecom>
  </contact>
  <contact>
    <name value="Kennedy Omondi"/>
    <telecom>
      <system value="email"/>
      <value value="kennankole@gmail.com"/>
      <use value="work"/>
    </telecom>
  </contact>
  <description
               value="Extracts a transaction Bundle from a QuestionnaireResponse to the Kenya MOH 510 Immunisation Permanent Register: guardian RelatedPersons, growth-monitoring Observations, one Immunization per antigen dose for sections L-Y/AA-AB/AD, Vitamin A MedicationAdministrations for section Z, danger-signs and education Observations, and an Appointment for the next scheduled visit. It creates no Patient, Encounter or EpisodeOfCare -- the register is launched from inside a visit the EMR has already opened, so all three arrive as context on the QuestionnaireResponse and are referenced rather than minted. QuestionnaireResponse.subject and .encounter are therefore both required."/>
  <structure>
    <url
         value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"/>
    <mode value="source"/>
    <alias value="QR"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
    <mode value="target"/>
    <alias value="Bundle"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/RelatedPerson"/>
    <mode value="target"/>
    <alias value="RelatedPerson"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Observation"/>
    <mode value="target"/>
    <alias value="Observation"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Immunization"/>
    <mode value="target"/>
    <alias value="Immunization"/>
  </structure>
  <structure>
    <url
         value="http://hl7.org/fhir/StructureDefinition/MedicationAdministration"/>
    <mode value="target"/>
    <alias value="MedicationAdministration"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Appointment"/>
    <mode value="target"/>
    <alias value="Appointment"/>
  </structure>
  <group>
    <name value="ExtractMOH510ImmunisationRegister"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="setBundleType"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="type"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="transaction"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="registrationGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="gReg"/>
        <condition value="linkId = 'IMM-group-registration'"/>
      </source>
      <rule>
        <name value="fatherRule"/>
        <source>
          <context value="gReg"/>
          <element value="item"/>
          <variable value="itH"/>
          <condition value="linkId = 'IMM-RG-H-father-name'"/>
        </source>
        <rule>
          <name value="fatherAnswer"/>
          <source>
            <context value="itH"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aH"/>
          </source>
          <rule>
            <name value="fatherResource"/>
            <source>
              <context value="aH"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eFat"/>
            </target>
            <target>
              <context value="eFat"/>
              <element value="resource"/>
              <variable value="fat"/>
              <transform value="create"/>
              <parameter>
                <valueString value="RelatedPerson"/>
              </parameter>
            </target>
            <rule>
              <name value="fatherBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="fat"/>
              </target>
              <target>
                <context value="eFat"/>
              </target>
              <dependent>
                <name value="BuildRelatedPerson"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itH"/>
                </parameter>
                <parameter>
                  <valueId value="fat"/>
                </parameter>
                <parameter>
                  <valueId value="eFat"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="fatherRelationship"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="fat"/>
                <element value="relationship"/>
                <variable value="relF"/>
              </target>
              <rule>
                <name value="fatherRelCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="relF"/>
                  <element value="coding"/>
                  <variable value="relFc"/>
                </target>
                <rule>
                  <name value="fatRelSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="relFc"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="http://terminology.hl7.org/CodeSystem/v3-RoleCode"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="fatRelCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="relFc"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="FTH"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="fatRelDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="relFc"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="father"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="fatherName"/>
              <source>
                <context value="aH"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="fat"/>
                <element value="name"/>
                <variable value="nF"/>
              </target>
              <rule>
                <name value="fatherNameText"/>
                <source>
                  <context value="v"/>
                </source>
                <target>
                  <context value="nF"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="v"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="fatherPhoneRule"/>
              <source>
                <context value="gReg"/>
                <element value="item"/>
                <variable value="itKf"/>
                <condition value="linkId = '42077-8'"/>
              </source>
              <rule>
                <name value="fatherPhoneAnswer"/>
                <source>
                  <context value="itKf"/>
                  <element value="answer"/>
                  <listMode value="first"/>
                  <variable value="aKf"/>
                </source>
                <rule>
                  <name value="fatherTelecom"/>
                  <source>
                    <context value="aKf"/>
                    <element value="value"/>
                    <variable value="v"/>
                  </source>
                  <target>
                    <context value="fat"/>
                    <element value="telecom"/>
                    <variable value="tcF"/>
                  </target>
                  <rule>
                    <name value="fatPhoneSystem"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="tcF"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="phone"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="fatPhoneValue"/>
                    <source>
                      <context value="v"/>
                    </source>
                    <target>
                      <context value="tcF"/>
                      <element value="value"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueId value="v"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
        <documentation
                       value="No Patient is emitted. The child is registered before the register entry
is filled, so the patient already exists and arrives as
QuestionnaireResponse.subject -- every resource below references it.
Sections C (child number), D (name), E (sex), F (date of birth) and
J (address) are the paper form transcribing demographics the EMR already
holds, so they are deliberately not extracted: creating a Patient here
would mint a duplicate record, and a blind PUT would clobber fields the
form does not carry. Reconciling them belongs in registration, not here.
This makes QuestionnaireResponse.subject mandatory for extraction --
without it Immunization.patient (1..1) cannot be populated."/>
      </rule>
      <rule>
        <name value="motherRule"/>
        <source>
          <context value="gReg"/>
          <element value="item"/>
          <variable value="itI"/>
          <condition value="linkId = 'IMM-RG-I-mother-name'"/>
        </source>
        <rule>
          <name value="motherAnswer"/>
          <source>
            <context value="itI"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aI"/>
          </source>
          <rule>
            <name value="motherResource"/>
            <source>
              <context value="aI"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eMot"/>
            </target>
            <target>
              <context value="eMot"/>
              <element value="resource"/>
              <variable value="mot"/>
              <transform value="create"/>
              <parameter>
                <valueString value="RelatedPerson"/>
              </parameter>
            </target>
            <rule>
              <name value="motherBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="mot"/>
              </target>
              <target>
                <context value="eMot"/>
              </target>
              <dependent>
                <name value="BuildRelatedPerson"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itI"/>
                </parameter>
                <parameter>
                  <valueId value="mot"/>
                </parameter>
                <parameter>
                  <valueId value="eMot"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="motherRelationship"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="mot"/>
                <element value="relationship"/>
                <variable value="relM"/>
              </target>
              <rule>
                <name value="motherRelCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="relM"/>
                  <element value="coding"/>
                  <variable value="relMc"/>
                </target>
                <rule>
                  <name value="motRelSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="relMc"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="http://terminology.hl7.org/CodeSystem/v3-RoleCode"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="motRelCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="relMc"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="MTH"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="motRelDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="relMc"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="mother"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="motherName"/>
              <source>
                <context value="aI"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="mot"/>
                <element value="name"/>
                <variable value="nM"/>
              </target>
              <rule>
                <name value="motherNameText"/>
                <source>
                  <context value="v"/>
                </source>
                <target>
                  <context value="nM"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="v"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="motherPhoneRule"/>
              <source>
                <context value="gReg"/>
                <element value="item"/>
                <variable value="itKm"/>
                <condition value="linkId = '42077-8'"/>
              </source>
              <rule>
                <name value="motherPhoneAnswer"/>
                <source>
                  <context value="itKm"/>
                  <element value="answer"/>
                  <listMode value="first"/>
                  <variable value="aKm"/>
                </source>
                <rule>
                  <name value="motherTelecom"/>
                  <source>
                    <context value="aKm"/>
                    <element value="value"/>
                    <variable value="v"/>
                  </source>
                  <target>
                    <context value="mot"/>
                    <element value="telecom"/>
                    <variable value="tcM"/>
                  </target>
                  <rule>
                    <name value="motPhoneSystem"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="tcM"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="phone"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="motPhoneValue"/>
                    <source>
                      <context value="v"/>
                    </source>
                    <target>
                      <context value="tcM"/>
                      <element value="value"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueId value="v"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="---------------------------------------------------------------- A-K"/>
    </rule>
    <rule>
      <name value="growthGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="gGrow"/>
        <condition value="linkId = 'IMM-group-growth'"/>
      </source>
      <rule>
        <name value="weightRule"/>
        <source>
          <context value="gGrow"/>
          <element value="item"/>
          <variable value="itW"/>
          <condition value="linkId = 'IMM-GM-Q1-weight'"/>
        </source>
        <rule>
          <name value="weightAnswer"/>
          <source>
            <context value="itW"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aW"/>
          </source>
          <rule>
            <name value="weightObservation"/>
            <source>
              <context value="aW"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eW"/>
            </target>
            <target>
              <context value="eW"/>
              <element value="resource"/>
              <variable value="obW"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="weightBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obW"/>
              </target>
              <target>
                <context value="eW"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obW"/>
                </parameter>
                <parameter>
                  <valueId value="eW"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="weightCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obW"/>
              </target>
              <dependent>
                <name value="VitalSignsCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obW"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="weightCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obW"/>
                <element value="code"/>
                <variable value="cdW"/>
              </target>
              <rule>
                <name value="weightCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdW"/>
                  <element value="coding"/>
                  <variable value="ccW"/>
                </target>
                <rule>
                  <name value="wSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccW"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="wCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccW"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="29463-7"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="wDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccW"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Body weight"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="weightValue"/>
              <source>
                <context value="aW"/>
                <element value="value"/>
                <variable value="dv"/>
              </source>
              <target>
                <context value="obW"/>
                <element value="value"/>
                <variable value="qW"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Quantity"/>
                </parameter>
              </target>
              <rule>
                <name value="wQtyValue"/>
                <source>
                  <context value="dv"/>
                </source>
                <target>
                  <context value="qW"/>
                  <element value="value"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="dv"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="wQtySystem"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="qW"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="wQtyCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="qW"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="kg"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="wQtyUnit"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="qW"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="kilogram"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="heightRule"/>
        <source>
          <context value="gGrow"/>
          <element value="item"/>
          <variable value="itH2"/>
          <condition value="linkId = 'IMM-GM-Q2-height'"/>
        </source>
        <rule>
          <name value="heightAnswer"/>
          <source>
            <context value="itH2"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aH2"/>
          </source>
          <rule>
            <name value="heightObservation"/>
            <source>
              <context value="aH2"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eH2"/>
            </target>
            <target>
              <context value="eH2"/>
              <element value="resource"/>
              <variable value="obH2"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="heightBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obH2"/>
              </target>
              <target>
                <context value="eH2"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obH2"/>
                </parameter>
                <parameter>
                  <valueId value="eH2"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="heightCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obH2"/>
              </target>
              <dependent>
                <name value="VitalSignsCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obH2"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="heightCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obH2"/>
                <element value="code"/>
                <variable value="cdH2"/>
              </target>
              <rule>
                <name value="heightCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdH2"/>
                  <element value="coding"/>
                  <variable value="ccH2"/>
                </target>
                <rule>
                  <name value="hSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccH2"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="hCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccH2"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="8302-2"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="hDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccH2"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Body height"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="heightValue"/>
              <source>
                <context value="aH2"/>
                <element value="value"/>
                <variable value="dv"/>
              </source>
              <target>
                <context value="obH2"/>
                <element value="value"/>
                <variable value="qH2"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Quantity"/>
                </parameter>
              </target>
              <rule>
                <name value="hQtyValue"/>
                <source>
                  <context value="dv"/>
                </source>
                <target>
                  <context value="qH2"/>
                  <element value="value"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="dv"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="hQtySystem"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="qH2"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="hQtyCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="qH2"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="cm"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="hQtyUnit"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="qH2"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="centimeter"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="muacRule"/>
        <source>
          <context value="gGrow"/>
          <element value="item"/>
          <variable value="itMu"/>
          <condition value="linkId = 'IMM-GM-Q3-muac'"/>
        </source>
        <rule>
          <name value="muacAnswer"/>
          <source>
            <context value="itMu"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aMu"/>
          </source>
          <rule>
            <name value="muacObservation"/>
            <source>
              <context value="aMu"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eMu"/>
            </target>
            <target>
              <context value="eMu"/>
              <element value="resource"/>
              <variable value="obMu"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="muacBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obMu"/>
              </target>
              <target>
                <context value="eMu"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obMu"/>
                </parameter>
                <parameter>
                  <valueId value="eMu"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="muacCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obMu"/>
              </target>
              <dependent>
                <name value="VitalSignsCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obMu"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="muacCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obMu"/>
                <element value="code"/>
                <variable value="cdMu"/>
              </target>
              <rule>
                <name value="muacCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdMu"/>
                  <element value="coding"/>
                  <variable value="ccMu"/>
                </target>
                <rule>
                  <name value="muSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccMu"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="muCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccMu"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="9847-5"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="muDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccMu"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Circumference site"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="muacValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obMu"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itMu"/>
                </parameter>
                <parameter>
                  <valueId value="obMu"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="wfaRule"/>
        <source>
          <context value="gGrow"/>
          <element value="item"/>
          <variable value="itWfa"/>
          <condition value="linkId = 'IMM-GM-Q4-weight-category'"/>
        </source>
        <rule>
          <name value="wfaAnswer"/>
          <source>
            <context value="itWfa"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aWfa"/>
          </source>
          <rule>
            <name value="wfaObservation"/>
            <source>
              <context value="aWfa"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eWfa"/>
            </target>
            <target>
              <context value="eWfa"/>
              <element value="resource"/>
              <variable value="obWfa"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="wfaBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obWfa"/>
              </target>
              <target>
                <context value="eWfa"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obWfa"/>
                </parameter>
                <parameter>
                  <valueId value="eWfa"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="wfaCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obWfa"/>
              </target>
              <dependent>
                <name value="VitalSignsCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obWfa"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="wfaCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obWfa"/>
                <element value="code"/>
                <variable value="cdWfa"/>
              </target>
              <rule>
                <name value="wfaCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdWfa"/>
                  <element value="coding"/>
                  <variable value="ccWfa"/>
                </target>
                <rule>
                  <name value="wfaSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccWfa"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="wfaCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccWfa"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="77606-2"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="wfaDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccWfa"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Weight-for-age percentile"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="wfaValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obWfa"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itWfa"/>
                </parameter>
                <parameter>
                  <valueId value="obWfa"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="hfaRule"/>
        <source>
          <context value="gGrow"/>
          <element value="item"/>
          <variable value="itHfa"/>
          <condition value="linkId = 'IMM-GM-Q5-height-category'"/>
        </source>
        <rule>
          <name value="hfaAnswer"/>
          <source>
            <context value="itHfa"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aHfa"/>
          </source>
          <rule>
            <name value="hfaObservation"/>
            <source>
              <context value="aHfa"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eHfa"/>
            </target>
            <target>
              <context value="eHfa"/>
              <element value="resource"/>
              <variable value="obHfa"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="hfaBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obHfa"/>
              </target>
              <target>
                <context value="eHfa"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obHfa"/>
                </parameter>
                <parameter>
                  <valueId value="eHfa"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="hfaCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obHfa"/>
              </target>
              <dependent>
                <name value="VitalSignsCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obHfa"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="hfaCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obHfa"/>
                <element value="code"/>
                <variable value="cdHfa"/>
              </target>
              <rule>
                <name value="hfaCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdHfa"/>
                  <element value="coding"/>
                  <variable value="ccHfa"/>
                </target>
                <rule>
                  <name value="hfaSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccHfa"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="hfaCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccHfa"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="59576-9"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="hfaDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccHfa"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Height-for-age percentile"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="hfaValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obHfa"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itHfa"/>
                </parameter>
                <parameter>
                  <valueId value="obHfa"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="------------------------------------------------------ Growth monitoring"/>
    </rule>
    <rule>
      <name value="vaccineGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="gVax"/>
        <condition value="linkId = 'IMM-group-vaccines'"/>
      </source>
      <rule>
        <name value="bcgRule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itL"/>
          <condition value="linkId = 'IMM-VAX-L-bcg'"/>
        </source>
        <rule>
          <name value="bcgAnswer"/>
          <source>
            <context value="itL"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aL"/>
          </source>
          <rule>
            <name value="bcgImmunization"/>
            <source>
              <context value="aL"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eL"/>
            </target>
            <target>
              <context value="eL"/>
              <element value="resource"/>
              <variable value="imL"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="bcgBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imL"/>
              </target>
              <target>
                <context value="eL"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itL"/>
                </parameter>
                <parameter>
                  <valueId value="aL"/>
                </parameter>
                <parameter>
                  <valueId value="imL"/>
                </parameter>
                <parameter>
                  <valueId value="eL"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="bcgVaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imL"/>
                <element value="vaccineCode"/>
                <variable value="vcL"/>
              </target>
              <rule>
                <name value="bcgCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcL"/>
                  <element value="coding"/>
                  <variable value="vccL"/>
                </target>
                <rule>
                  <name value="bcgSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccL"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="bcgCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccL"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="bcg"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="bcgDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccL"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="BCG"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="bcgText"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcL"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="BCG"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="bcgProtocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imL"/>
                <element value="protocolApplied"/>
                <variable value="paL"/>
              </target>
              <rule>
                <name value="bcgSeries"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paL"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="BCG"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="bcgDose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paL"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="opv0Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itM"/>
          <condition value="linkId = 'IMM-VAX-M-polio-birth'"/>
        </source>
        <rule>
          <name value="opv0Answer"/>
          <source>
            <context value="itM"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aM"/>
          </source>
          <rule>
            <name value="opv0Immunization"/>
            <source>
              <context value="aM"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eM"/>
            </target>
            <target>
              <context value="eM"/>
              <element value="resource"/>
              <variable value="imM"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="opv0Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imM"/>
              </target>
              <target>
                <context value="eM"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itM"/>
                </parameter>
                <parameter>
                  <valueId value="aM"/>
                </parameter>
                <parameter>
                  <valueId value="imM"/>
                </parameter>
                <parameter>
                  <valueId value="eM"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="opv0VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imM"/>
                <element value="vaccineCode"/>
                <variable value="vcM"/>
              </target>
              <rule>
                <name value="opv0Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcM"/>
                  <element value="coding"/>
                  <variable value="vccM"/>
                </target>
                <rule>
                  <name value="opv0System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccM"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="opv0Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccM"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="bopv"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="opv0Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccM"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Bivalent oral poliovirus vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="opv0Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcM"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Polio birth dose (bOPV)"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="opv0Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imM"/>
                <element value="protocolApplied"/>
                <variable value="paM"/>
              </target>
              <rule>
                <name value="opv0Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paM"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Polio (bOPV)"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="opv0Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paM"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="0"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="opv1Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itN"/>
          <condition value="linkId = 'IMM-VAX-N-opv1'"/>
        </source>
        <rule>
          <name value="opv1Answer"/>
          <source>
            <context value="itN"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aN"/>
          </source>
          <rule>
            <name value="opv1Immunization"/>
            <source>
              <context value="aN"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eN"/>
            </target>
            <target>
              <context value="eN"/>
              <element value="resource"/>
              <variable value="imN"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="opv1Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imN"/>
              </target>
              <target>
                <context value="eN"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itN"/>
                </parameter>
                <parameter>
                  <valueId value="aN"/>
                </parameter>
                <parameter>
                  <valueId value="imN"/>
                </parameter>
                <parameter>
                  <valueId value="eN"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="opv1VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imN"/>
                <element value="vaccineCode"/>
                <variable value="vcN"/>
              </target>
              <rule>
                <name value="opv1Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcN"/>
                  <element value="coding"/>
                  <variable value="vccN"/>
                </target>
                <rule>
                  <name value="opv1System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccN"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="opv1Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccN"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="bopv"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="opv1Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccN"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Bivalent oral poliovirus vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="opv1Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcN"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="OPV 1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="opv1Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imN"/>
                <element value="protocolApplied"/>
                <variable value="paN"/>
              </target>
              <rule>
                <name value="opv1Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paN"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Polio (bOPV)"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="opv1Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paN"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="opv2Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itO"/>
          <condition value="linkId = 'IMM-VAX-O-opv2'"/>
        </source>
        <rule>
          <name value="opv2Answer"/>
          <source>
            <context value="itO"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aO"/>
          </source>
          <rule>
            <name value="opv2Immunization"/>
            <source>
              <context value="aO"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eO"/>
            </target>
            <target>
              <context value="eO"/>
              <element value="resource"/>
              <variable value="imO"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="opv2Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imO"/>
              </target>
              <target>
                <context value="eO"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itO"/>
                </parameter>
                <parameter>
                  <valueId value="aO"/>
                </parameter>
                <parameter>
                  <valueId value="imO"/>
                </parameter>
                <parameter>
                  <valueId value="eO"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="opv2VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imO"/>
                <element value="vaccineCode"/>
                <variable value="vcO"/>
              </target>
              <rule>
                <name value="opv2Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcO"/>
                  <element value="coding"/>
                  <variable value="vccO"/>
                </target>
                <rule>
                  <name value="opv2System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccO"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="opv2Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccO"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="bopv"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="opv2Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccO"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Bivalent oral poliovirus vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="opv2Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcO"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="OPV 2"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="opv2Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imO"/>
                <element value="protocolApplied"/>
                <variable value="paO"/>
              </target>
              <rule>
                <name value="opv2Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paO"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Polio (bOPV)"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="opv2Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paO"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="2"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="opv3Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itP"/>
          <condition value="linkId = 'IMM-VAX-P-opv3'"/>
        </source>
        <rule>
          <name value="opv3Answer"/>
          <source>
            <context value="itP"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aP"/>
          </source>
          <rule>
            <name value="opv3Immunization"/>
            <source>
              <context value="aP"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eP"/>
            </target>
            <target>
              <context value="eP"/>
              <element value="resource"/>
              <variable value="imP"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="opv3Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imP"/>
              </target>
              <target>
                <context value="eP"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itP"/>
                </parameter>
                <parameter>
                  <valueId value="aP"/>
                </parameter>
                <parameter>
                  <valueId value="imP"/>
                </parameter>
                <parameter>
                  <valueId value="eP"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="opv3VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imP"/>
                <element value="vaccineCode"/>
                <variable value="vcP"/>
              </target>
              <rule>
                <name value="opv3Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcP"/>
                  <element value="coding"/>
                  <variable value="vccP"/>
                </target>
                <rule>
                  <name value="opv3System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccP"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="opv3Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccP"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="bopv"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="opv3Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccP"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Bivalent oral poliovirus vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="opv3Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcP"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="OPV 3"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="opv3Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imP"/>
                <element value="protocolApplied"/>
                <variable value="paP"/>
              </target>
              <rule>
                <name value="opv3Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paP"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Polio (bOPV)"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="opv3Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paP"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="3"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="ipvRule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itQ"/>
          <condition value="linkId = 'IMM-VAX-Q-ipv'"/>
        </source>
        <rule>
          <name value="ipvAnswer"/>
          <source>
            <context value="itQ"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aQ"/>
          </source>
          <rule>
            <name value="ipvImmunization"/>
            <source>
              <context value="aQ"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eQ"/>
            </target>
            <target>
              <context value="eQ"/>
              <element value="resource"/>
              <variable value="imQ"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="ipvBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imQ"/>
              </target>
              <target>
                <context value="eQ"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itQ"/>
                </parameter>
                <parameter>
                  <valueId value="aQ"/>
                </parameter>
                <parameter>
                  <valueId value="imQ"/>
                </parameter>
                <parameter>
                  <valueId value="eQ"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="ipvVaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imQ"/>
                <element value="vaccineCode"/>
                <variable value="vcQ"/>
              </target>
              <rule>
                <name value="ipvCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcQ"/>
                  <element value="coding"/>
                  <variable value="vccQ"/>
                </target>
                <rule>
                  <name value="ipvSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccQ"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="ipvCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccQ"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="ipv"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="ipvDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccQ"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Inactivated poliovirus vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="ipvText"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcQ"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="IPV"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="ipvProtocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imQ"/>
                <element value="protocolApplied"/>
                <variable value="paQ"/>
              </target>
              <rule>
                <name value="ipvSeries"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paQ"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Polio (IPV)"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="ipvDose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paQ"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
        <documentation
                       value="IPV carries its own antigen code: the questionnaire reuses the OPV LOINC
code for both, which would collapse two distinct vaccines into one."/>
      </rule>
      <rule>
        <name value="penta1Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itR"/>
          <condition value="linkId = 'IMM-VAX-R-penta1'"/>
        </source>
        <rule>
          <name value="penta1Answer"/>
          <source>
            <context value="itR"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aR"/>
          </source>
          <rule>
            <name value="penta1Immunization"/>
            <source>
              <context value="aR"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eR"/>
            </target>
            <target>
              <context value="eR"/>
              <element value="resource"/>
              <variable value="imR"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="penta1Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imR"/>
              </target>
              <target>
                <context value="eR"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itR"/>
                </parameter>
                <parameter>
                  <valueId value="aR"/>
                </parameter>
                <parameter>
                  <valueId value="imR"/>
                </parameter>
                <parameter>
                  <valueId value="eR"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="penta1VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imR"/>
                <element value="vaccineCode"/>
                <variable value="vcR"/>
              </target>
              <rule>
                <name value="penta1Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcR"/>
                  <element value="coding"/>
                  <variable value="vccR"/>
                </target>
                <rule>
                  <name value="penta1System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccR"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="penta1Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccR"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="penta"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="penta1Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccR"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="DTP-HepB-Hib (pentavalent) vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="penta1Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcR"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Pentavalent 1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="penta1Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imR"/>
                <element value="protocolApplied"/>
                <variable value="paR"/>
              </target>
              <rule>
                <name value="penta1Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paR"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Pentavalent"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="penta1Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paR"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="penta2Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itS"/>
          <condition value="linkId = 'IMM-VAX-S-penta2'"/>
        </source>
        <rule>
          <name value="penta2Answer"/>
          <source>
            <context value="itS"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aS"/>
          </source>
          <rule>
            <name value="penta2Immunization"/>
            <source>
              <context value="aS"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eS"/>
            </target>
            <target>
              <context value="eS"/>
              <element value="resource"/>
              <variable value="imS"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="penta2Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imS"/>
              </target>
              <target>
                <context value="eS"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itS"/>
                </parameter>
                <parameter>
                  <valueId value="aS"/>
                </parameter>
                <parameter>
                  <valueId value="imS"/>
                </parameter>
                <parameter>
                  <valueId value="eS"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="penta2VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imS"/>
                <element value="vaccineCode"/>
                <variable value="vcS"/>
              </target>
              <rule>
                <name value="penta2Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcS"/>
                  <element value="coding"/>
                  <variable value="vccS"/>
                </target>
                <rule>
                  <name value="penta2System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccS"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="penta2Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccS"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="penta"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="penta2Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccS"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="DTP-HepB-Hib (pentavalent) vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="penta2Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcS"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Pentavalent 2"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="penta2Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imS"/>
                <element value="protocolApplied"/>
                <variable value="paS"/>
              </target>
              <rule>
                <name value="penta2Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paS"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Pentavalent"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="penta2Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paS"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="2"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="penta3Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itT"/>
          <condition value="linkId = 'IMM-VAX-T-penta3'"/>
        </source>
        <rule>
          <name value="penta3Answer"/>
          <source>
            <context value="itT"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aT"/>
          </source>
          <rule>
            <name value="penta3Immunization"/>
            <source>
              <context value="aT"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eT"/>
            </target>
            <target>
              <context value="eT"/>
              <element value="resource"/>
              <variable value="imT"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="penta3Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imT"/>
              </target>
              <target>
                <context value="eT"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itT"/>
                </parameter>
                <parameter>
                  <valueId value="aT"/>
                </parameter>
                <parameter>
                  <valueId value="imT"/>
                </parameter>
                <parameter>
                  <valueId value="eT"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="penta3VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imT"/>
                <element value="vaccineCode"/>
                <variable value="vcT"/>
              </target>
              <rule>
                <name value="penta3Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcT"/>
                  <element value="coding"/>
                  <variable value="vccT"/>
                </target>
                <rule>
                  <name value="penta3System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccT"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="penta3Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccT"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="penta"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="penta3Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccT"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="DTP-HepB-Hib (pentavalent) vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="penta3Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcT"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Pentavalent 3"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="penta3Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imT"/>
                <element value="protocolApplied"/>
                <variable value="paT"/>
              </target>
              <rule>
                <name value="penta3Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paT"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Pentavalent"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="penta3Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paT"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="3"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="pcv1Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itU"/>
          <condition value="linkId = 'IMM-VAX-U-pcv1'"/>
        </source>
        <rule>
          <name value="pcv1Answer"/>
          <source>
            <context value="itU"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aU"/>
          </source>
          <rule>
            <name value="pcv1Immunization"/>
            <source>
              <context value="aU"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eU"/>
            </target>
            <target>
              <context value="eU"/>
              <element value="resource"/>
              <variable value="imU"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="pcv1Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imU"/>
              </target>
              <target>
                <context value="eU"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itU"/>
                </parameter>
                <parameter>
                  <valueId value="aU"/>
                </parameter>
                <parameter>
                  <valueId value="imU"/>
                </parameter>
                <parameter>
                  <valueId value="eU"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="pcv1VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imU"/>
                <element value="vaccineCode"/>
                <variable value="vcU"/>
              </target>
              <rule>
                <name value="pcv1Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcU"/>
                  <element value="coding"/>
                  <variable value="vccU"/>
                </target>
                <rule>
                  <name value="pcv1System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccU"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="pcv1Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccU"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="pcv10"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="pcv1Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccU"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="Pneumococcal conjugate vaccine (PCV10)"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="pcv1Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcU"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="PCV10 1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="pcv1Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imU"/>
                <element value="protocolApplied"/>
                <variable value="paU"/>
              </target>
              <rule>
                <name value="pcv1Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paU"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="PCV10"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="pcv1Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paU"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="pcv2Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itV"/>
          <condition value="linkId = 'IMM-VAX-V-pcv2'"/>
        </source>
        <rule>
          <name value="pcv2Answer"/>
          <source>
            <context value="itV"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aV"/>
          </source>
          <rule>
            <name value="pcv2Immunization"/>
            <source>
              <context value="aV"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eV"/>
            </target>
            <target>
              <context value="eV"/>
              <element value="resource"/>
              <variable value="imV"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="pcv2Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imV"/>
              </target>
              <target>
                <context value="eV"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itV"/>
                </parameter>
                <parameter>
                  <valueId value="aV"/>
                </parameter>
                <parameter>
                  <valueId value="imV"/>
                </parameter>
                <parameter>
                  <valueId value="eV"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="pcv2VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imV"/>
                <element value="vaccineCode"/>
                <variable value="vcV"/>
              </target>
              <rule>
                <name value="pcv2Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcV"/>
                  <element value="coding"/>
                  <variable value="vccV"/>
                </target>
                <rule>
                  <name value="pcv2System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccV"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="pcv2Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccV"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="pcv10"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="pcv2Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccV"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="Pneumococcal conjugate vaccine (PCV10)"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="pcv2Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcV"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="PCV10 2"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="pcv2Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imV"/>
                <element value="protocolApplied"/>
                <variable value="paV"/>
              </target>
              <rule>
                <name value="pcv2Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paV"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="PCV10"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="pcv2Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paV"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="2"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="pcv3Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itW2"/>
          <condition value="linkId = 'IMM-VAX-W-pcv3'"/>
        </source>
        <rule>
          <name value="pcv3Answer"/>
          <source>
            <context value="itW2"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aW2"/>
          </source>
          <rule>
            <name value="pcv3Immunization"/>
            <source>
              <context value="aW2"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eW2"/>
            </target>
            <target>
              <context value="eW2"/>
              <element value="resource"/>
              <variable value="imW2"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="pcv3Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imW2"/>
              </target>
              <target>
                <context value="eW2"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itW2"/>
                </parameter>
                <parameter>
                  <valueId value="aW2"/>
                </parameter>
                <parameter>
                  <valueId value="imW2"/>
                </parameter>
                <parameter>
                  <valueId value="eW2"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="pcv3VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imW2"/>
                <element value="vaccineCode"/>
                <variable value="vcW2"/>
              </target>
              <rule>
                <name value="pcv3Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcW2"/>
                  <element value="coding"/>
                  <variable value="vccW2"/>
                </target>
                <rule>
                  <name value="pcv3System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccW2"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="pcv3Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccW2"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="pcv10"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="pcv3Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccW2"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="Pneumococcal conjugate vaccine (PCV10)"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="pcv3Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcW2"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="PCV10 3"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="pcv3Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imW2"/>
                <element value="protocolApplied"/>
                <variable value="paW2"/>
              </target>
              <rule>
                <name value="pcv3Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paW2"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="PCV10"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="pcv3Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paW2"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="3"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="rota1Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itX"/>
          <condition value="linkId = 'IMM-VAX-X-rota1'"/>
        </source>
        <rule>
          <name value="rota1Answer"/>
          <source>
            <context value="itX"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aX"/>
          </source>
          <rule>
            <name value="rota1Immunization"/>
            <source>
              <context value="aX"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eX"/>
            </target>
            <target>
              <context value="eX"/>
              <element value="resource"/>
              <variable value="imX"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="rota1Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imX"/>
              </target>
              <target>
                <context value="eX"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itX"/>
                </parameter>
                <parameter>
                  <valueId value="aX"/>
                </parameter>
                <parameter>
                  <valueId value="imX"/>
                </parameter>
                <parameter>
                  <valueId value="eX"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="rota1VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imX"/>
                <element value="vaccineCode"/>
                <variable value="vcX"/>
              </target>
              <rule>
                <name value="rota1Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcX"/>
                  <element value="coding"/>
                  <variable value="vccX"/>
                </target>
                <rule>
                  <name value="rota1System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccX"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="rota1Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccX"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="rota"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="rota1Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccX"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Rotavirus vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="rota1Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcX"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Rota 1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="rota1Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imX"/>
                <element value="protocolApplied"/>
                <variable value="paX"/>
              </target>
              <rule>
                <name value="rota1Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paX"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Rotavirus"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="rota1Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paX"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="rota2Rule"/>
        <source>
          <context value="gVax"/>
          <element value="item"/>
          <variable value="itY"/>
          <condition value="linkId = 'IMM-VAX-Y-rota2'"/>
        </source>
        <rule>
          <name value="rota2Answer"/>
          <source>
            <context value="itY"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aY"/>
          </source>
          <rule>
            <name value="rota2Immunization"/>
            <source>
              <context value="aY"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eY"/>
            </target>
            <target>
              <context value="eY"/>
              <element value="resource"/>
              <variable value="imY"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="rota2Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imY"/>
              </target>
              <target>
                <context value="eY"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itY"/>
                </parameter>
                <parameter>
                  <valueId value="aY"/>
                </parameter>
                <parameter>
                  <valueId value="imY"/>
                </parameter>
                <parameter>
                  <valueId value="eY"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="rota2VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imY"/>
                <element value="vaccineCode"/>
                <variable value="vcY"/>
              </target>
              <rule>
                <name value="rota2Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcY"/>
                  <element value="coding"/>
                  <variable value="vccY"/>
                </target>
                <rule>
                  <name value="rota2System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccY"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="rota2Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccY"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="rota"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="rota2Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccY"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Rotavirus vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="rota2Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcY"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Rota 2"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="rota2Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imY"/>
                <element value="protocolApplied"/>
                <variable value="paY"/>
              </target>
              <rule>
                <name value="rota2Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paY"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Rotavirus"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="rota2Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paY"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="2"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="------------------------------------------------------------- L-Y vaccines"/>
    </rule>
    <rule>
      <name value="supplementationGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="gSup"/>
        <condition value="linkId = 'IMM-group-supplementation'"/>
      </source>
      <rule>
        <name value="vitA100Rule"/>
        <source>
          <context value="gSup"/>
          <element value="item"/>
          <variable value="itZ"/>
          <condition value="linkId = '55876-9'"/>
        </source>
        <rule>
          <name value="vitA100Answer"/>
          <source>
            <context value="itZ"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aZ"/>
          </source>
          <rule>
            <name value="vitA100Resource"/>
            <source>
              <context value="aZ"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eZ"/>
            </target>
            <target>
              <context value="eZ"/>
              <element value="resource"/>
              <variable value="maZ"/>
              <transform value="create"/>
              <parameter>
                <valueString value="MedicationAdministration"/>
              </parameter>
            </target>
            <rule>
              <name value="vitA100Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="maZ"/>
              </target>
              <target>
                <context value="eZ"/>
              </target>
              <dependent>
                <name value="BuildMedAdmin"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itZ"/>
                </parameter>
                <parameter>
                  <valueId value="aZ"/>
                </parameter>
                <parameter>
                  <valueId value="maZ"/>
                </parameter>
                <parameter>
                  <valueId value="eZ"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="vitA100Medication"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="maZ"/>
                <element value="medication"/>
                <variable value="mcrZ"/>
              </target>
              <rule>
                <name value="vitA100Concept"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="mcrZ"/>
                  <element value="concept"/>
                  <variable value="mccZ"/>
                </target>
                <rule>
                  <name value="vitA100Coding"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="mccZ"/>
                    <element value="coding"/>
                    <variable value="mcoZ"/>
                  </target>
                  <rule>
                    <name value="vitA100System"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="mcoZ"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-supplement"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="vitA100Code"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="mcoZ"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="vitamin-a-100000"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="vitA100Display"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="mcoZ"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="Vitamin A 100,000 IU"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
                <rule>
                  <name value="vitA100Text"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="mccZ"/>
                    <element value="text"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="Vitamin A 100,000 IU (6-11 months)"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="vitA100Dosage"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="maZ"/>
                <element value="dosage"/>
                <variable value="dosZ"/>
              </target>
              <rule>
                <name value="vitA100Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="dosZ"/>
                  <element value="dose"/>
                  <variable value="dqZ"/>
                </target>
                <rule>
                  <name value="vitA100DoseValue"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="dqZ"/>
                    <element value="value"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueInteger value="100000"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="vitA100DoseSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="dqZ"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://unitsofmeasure.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="vitA100DoseCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="dqZ"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="[IU]"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="vitA100DoseUnit"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="dqZ"/>
                    <element value="unit"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="international unit"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="vitA200Rule"/>
        <source>
          <context value="gSup"/>
          <element value="item"/>
          <variable value="itZ2"/>
          <condition value="linkId = '0v8mpdt'"/>
        </source>
        <rule>
          <name value="vitA200Answer"/>
          <source>
            <context value="itZ2"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aZ2"/>
          </source>
          <rule>
            <name value="vitA200Resource"/>
            <source>
              <context value="aZ2"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eZ2"/>
            </target>
            <target>
              <context value="eZ2"/>
              <element value="resource"/>
              <variable value="maZ2"/>
              <transform value="create"/>
              <parameter>
                <valueString value="MedicationAdministration"/>
              </parameter>
            </target>
            <rule>
              <name value="vitA200Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="maZ2"/>
              </target>
              <target>
                <context value="eZ2"/>
              </target>
              <dependent>
                <name value="BuildMedAdmin"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itZ2"/>
                </parameter>
                <parameter>
                  <valueId value="aZ2"/>
                </parameter>
                <parameter>
                  <valueId value="maZ2"/>
                </parameter>
                <parameter>
                  <valueId value="eZ2"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="vitA200Medication"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="maZ2"/>
                <element value="medication"/>
                <variable value="mcrZ2"/>
              </target>
              <rule>
                <name value="vitA200Concept"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="mcrZ2"/>
                  <element value="concept"/>
                  <variable value="mccZ2"/>
                </target>
                <rule>
                  <name value="vitA200Coding"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="mccZ2"/>
                    <element value="coding"/>
                    <variable value="mcoZ2"/>
                  </target>
                  <rule>
                    <name value="vitA200System"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="mcoZ2"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-supplement"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="vitA200Code"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="mcoZ2"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="vitamin-a-200000"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="vitA200Display"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="mcoZ2"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="Vitamin A 200,000 IU"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
                <rule>
                  <name value="vitA200Text"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="mccZ2"/>
                    <element value="text"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="Vitamin A 200,000 IU (12 months onwards)"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="vitA200Dosage"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="maZ2"/>
                <element value="dosage"/>
                <variable value="dosZ2"/>
              </target>
              <rule>
                <name value="vitA200Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="dosZ2"/>
                  <element value="dose"/>
                  <variable value="dqZ2"/>
                </target>
                <rule>
                  <name value="vitA200DoseValue"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="dqZ2"/>
                    <element value="value"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueInteger value="200000"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="vitA200DoseSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="dqZ2"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://unitsofmeasure.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="vitA200DoseCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="dqZ2"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="[IU]"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="vitA200DoseUnit"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="dqZ2"/>
                    <element value="unit"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="international unit"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="------------------------------------------------- Z Vitamin A supplements"/>
    </rule>
    <rule>
      <name value="mrYfGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="gMrYf"/>
        <condition value="linkId = 'IMM-group-mr-yf'"/>
      </source>
      <rule>
        <name value="mr1Rule"/>
        <source>
          <context value="gMrYf"/>
          <element value="item"/>
          <variable value="itAa"/>
          <condition value="linkId = 'IMM-VAX-AA-mr1'"/>
        </source>
        <rule>
          <name value="mr1Answer"/>
          <source>
            <context value="itAa"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aAa"/>
          </source>
          <rule>
            <name value="mr1Immunization"/>
            <source>
              <context value="aAa"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eAa"/>
            </target>
            <target>
              <context value="eAa"/>
              <element value="resource"/>
              <variable value="imAa"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="mr1Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imAa"/>
              </target>
              <target>
                <context value="eAa"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itAa"/>
                </parameter>
                <parameter>
                  <valueId value="aAa"/>
                </parameter>
                <parameter>
                  <valueId value="imAa"/>
                </parameter>
                <parameter>
                  <valueId value="eAa"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="mr1VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imAa"/>
                <element value="vaccineCode"/>
                <variable value="vcAa"/>
              </target>
              <rule>
                <name value="mr1Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcAa"/>
                  <element value="coding"/>
                  <variable value="vccAa"/>
                </target>
                <rule>
                  <name value="mr1System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccAa"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="mr1Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccAa"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="mr"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="mr1Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccAa"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Measles-rubella vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="mr1Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcAa"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="MR 1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="mr1Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imAa"/>
                <element value="protocolApplied"/>
                <variable value="paAa"/>
              </target>
              <rule>
                <name value="mr1Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paAa"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Measles-Rubella"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="mr1Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paAa"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="yfRule"/>
        <source>
          <context value="gMrYf"/>
          <element value="item"/>
          <variable value="itAb"/>
          <condition value="linkId = 'IMM-VAX-AB-yf'"/>
        </source>
        <rule>
          <name value="yfAnswer"/>
          <source>
            <context value="itAb"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aAb"/>
          </source>
          <rule>
            <name value="yfImmunization"/>
            <source>
              <context value="aAb"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eAb"/>
            </target>
            <target>
              <context value="eAb"/>
              <element value="resource"/>
              <variable value="imAb"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="yfBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imAb"/>
              </target>
              <target>
                <context value="eAb"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itAb"/>
                </parameter>
                <parameter>
                  <valueId value="aAb"/>
                </parameter>
                <parameter>
                  <valueId value="imAb"/>
                </parameter>
                <parameter>
                  <valueId value="eAb"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="yfVaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imAb"/>
                <element value="vaccineCode"/>
                <variable value="vcAb"/>
              </target>
              <rule>
                <name value="yfCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcAb"/>
                  <element value="coding"/>
                  <variable value="vccAb"/>
                </target>
                <rule>
                  <name value="yfSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccAb"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="yfCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccAb"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="yf"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="yfDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccAb"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Yellow fever vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="yfText"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcAb"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Yellow Fever"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="yfProtocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imAb"/>
                <element value="protocolApplied"/>
                <variable value="paAb"/>
              </target>
              <rule>
                <name value="yfSeries"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paAb"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Yellow Fever"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="yfDose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paAb"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="------------------------------------------------------ AA-AB MR1 + Yellow Fever"/>
    </rule>
    <rule>
      <name value="ficGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="gFic"/>
        <condition value="linkId = 'IMM-group-fic'"/>
      </source>
      <rule>
        <name value="ficRule"/>
        <source>
          <context value="gFic"/>
          <element value="item"/>
          <variable value="itAc"/>
          <condition value="linkId = 'IMM-FIC-AC-date'"/>
        </source>
        <rule>
          <name value="ficAnswer"/>
          <source>
            <context value="itAc"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aAc"/>
          </source>
          <rule>
            <name value="ficObservation"/>
            <source>
              <context value="aAc"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eAc"/>
            </target>
            <target>
              <context value="eAc"/>
              <element value="resource"/>
              <variable value="obAc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="ficBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obAc"/>
              </target>
              <target>
                <context value="eAc"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obAc"/>
                </parameter>
                <parameter>
                  <valueId value="eAc"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="ficCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obAc"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obAc"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="ficCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obAc"/>
                <element value="code"/>
                <variable value="cdAc"/>
              </target>
              <rule>
                <name value="ficCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdAc"/>
                  <element value="coding"/>
                  <variable value="ccAc"/>
                </target>
                <rule>
                  <name value="ficSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccAc"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="ficCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccAc"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="11369-6"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="ficDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccAc"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Immunisation completion status"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="ficCodeText"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdAc"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="Fully Immunised Child (FIC) completion date"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="ficValue"/>
              <source>
                <context value="aAc"/>
                <element value="value"/>
                <variable value="dv"/>
              </source>
              <target>
                <context value="obAc"/>
                <element value="value"/>
                <transform value="cast"/>
                <parameter>
                  <valueId value="dv"/>
                </parameter>
                <parameter>
                  <valueString value="dateTime"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="------------------------------------------------------------- AC FIC date"/>
    </rule>
    <rule>
      <name value="mr2Group"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="gMr2"/>
        <condition value="linkId = 'IMM-group-mr2'"/>
      </source>
      <rule>
        <name value="mr2Rule"/>
        <source>
          <context value="gMr2"/>
          <element value="item"/>
          <variable value="itAd"/>
          <condition value="linkId = 'IMM-VAX-AD-mr2'"/>
        </source>
        <rule>
          <name value="mr2Answer"/>
          <source>
            <context value="itAd"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aAd"/>
          </source>
          <rule>
            <name value="mr2Immunization"/>
            <source>
              <context value="aAd"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eAd"/>
            </target>
            <target>
              <context value="eAd"/>
              <element value="resource"/>
              <variable value="imAd"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
            <rule>
              <name value="mr2Base"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imAd"/>
              </target>
              <target>
                <context value="eAd"/>
              </target>
              <dependent>
                <name value="BuildImm"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="itAd"/>
                </parameter>
                <parameter>
                  <valueId value="aAd"/>
                </parameter>
                <parameter>
                  <valueId value="imAd"/>
                </parameter>
                <parameter>
                  <valueId value="eAd"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="mr2VaccineCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imAd"/>
                <element value="vaccineCode"/>
                <variable value="vcAd"/>
              </target>
              <rule>
                <name value="mr2Coding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcAd"/>
                  <element value="coding"/>
                  <variable value="vccAd"/>
                </target>
                <rule>
                  <name value="mr2System"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccAd"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="mr2Code"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccAd"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="mr"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="mr2Display"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="vccAd"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Measles-rubella vaccine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="mr2Text"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vcAd"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="MR 2"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="mr2Protocol"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="imAd"/>
                <element value="protocolApplied"/>
                <variable value="paAd"/>
              </target>
              <rule>
                <name value="mr2Series"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paAd"/>
                  <element value="series"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Measles-Rubella"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="mr2Dose"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="paAd"/>
                  <element value="doseNumber"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="2"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="------------------------------------------------------------------ AD MR2"/>
    </rule>
    <rule>
      <name value="dangerSignsGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="gDs"/>
        <condition value="linkId = 'IMM-group-danger-signs'"/>
      </source>
      <rule>
        <name value="feverRule"/>
        <source>
          <context value="gDs"/>
          <element value="item"/>
          <variable value="itD1"/>
          <condition value="linkId = 'IMM-DS-Q1-fever'"/>
        </source>
        <rule>
          <name value="feverAnswer"/>
          <source>
            <context value="itD1"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aD1"/>
          </source>
          <rule>
            <name value="feverObservation"/>
            <source>
              <context value="aD1"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eD1"/>
            </target>
            <target>
              <context value="eD1"/>
              <element value="resource"/>
              <variable value="obD1"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="feverBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD1"/>
              </target>
              <target>
                <context value="eD1"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD1"/>
                </parameter>
                <parameter>
                  <valueId value="eD1"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="feverCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD1"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD1"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="feverCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD1"/>
                <element value="code"/>
                <variable value="cdD1"/>
              </target>
              <rule>
                <name value="feverCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdD1"/>
                  <element value="coding"/>
                  <variable value="ccD1"/>
                </target>
                <rule>
                  <name value="feverSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD1"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="feverCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD1"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="8310-5"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="feverDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD1"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Body temperature"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="feverCodeText"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdD1"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Fever reported"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="feverValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD1"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itD1"/>
                </parameter>
                <parameter>
                  <valueId value="obD1"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="feedingRule"/>
        <source>
          <context value="gDs"/>
          <element value="item"/>
          <variable value="itD2"/>
          <condition value="linkId = 'IMM-DS-Q2-feeding'"/>
        </source>
        <rule>
          <name value="feedingAnswer"/>
          <source>
            <context value="itD2"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aD2"/>
          </source>
          <rule>
            <name value="feedingObservation"/>
            <source>
              <context value="aD2"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eD2"/>
            </target>
            <target>
              <context value="eD2"/>
              <element value="resource"/>
              <variable value="obD2"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="feedingBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD2"/>
              </target>
              <target>
                <context value="eD2"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD2"/>
                </parameter>
                <parameter>
                  <valueId value="eD2"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="feedingCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD2"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD2"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="feedingCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD2"/>
                <element value="code"/>
                <variable value="cdD2"/>
              </target>
              <rule>
                <name value="feedingCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdD2"/>
                  <element value="coding"/>
                  <variable value="ccD2"/>
                </target>
                <rule>
                  <name value="feedingSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD2"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="feedingCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD2"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="75890-1"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="feedingDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD2"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Feeding status"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="feedingCodeText"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdD2"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Child is feeding"/>
                  </parameter>
                </target>
                <documentation
                               value="Polarity is inverted relative to the other danger signs: &quot;Yes&quot;
here is reassuring, not alarming."/>
              </rule>
            </rule>
            <rule>
              <name value="feedingValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD2"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itD2"/>
                </parameter>
                <parameter>
                  <valueId value="obD2"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="convulsionsRule"/>
        <source>
          <context value="gDs"/>
          <element value="item"/>
          <variable value="itD3"/>
          <condition value="linkId = 'IMM-DS-Q3-convulsions'"/>
        </source>
        <rule>
          <name value="convulsionsAnswer"/>
          <source>
            <context value="itD3"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aD3"/>
          </source>
          <rule>
            <name value="convulsionsObservation"/>
            <source>
              <context value="aD3"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eD3"/>
            </target>
            <target>
              <context value="eD3"/>
              <element value="resource"/>
              <variable value="obD3"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="convulsionsBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD3"/>
              </target>
              <target>
                <context value="eD3"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD3"/>
                </parameter>
                <parameter>
                  <valueId value="eD3"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="convulsionsCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD3"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD3"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="convulsionsCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD3"/>
                <element value="code"/>
                <variable value="cdD3"/>
              </target>
              <rule>
                <name value="convulsionsCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdD3"/>
                  <element value="coding"/>
                  <variable value="ccD3"/>
                </target>
                <rule>
                  <name value="convulsionsSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD3"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="convulsionsCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD3"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="31398-4"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="convulsionsDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD3"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Convulsions"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="convulsionsValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD3"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itD3"/>
                </parameter>
                <parameter>
                  <valueId value="obD3"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="coughRule"/>
        <source>
          <context value="gDs"/>
          <element value="item"/>
          <variable value="itD4"/>
          <condition value="linkId = 'IMM-DS-Q4-cough'"/>
        </source>
        <rule>
          <name value="coughAnswer"/>
          <source>
            <context value="itD4"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aD4"/>
          </source>
          <rule>
            <name value="coughObservation"/>
            <source>
              <context value="aD4"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eD4"/>
            </target>
            <target>
              <context value="eD4"/>
              <element value="resource"/>
              <variable value="obD4"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="coughBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD4"/>
              </target>
              <target>
                <context value="eD4"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD4"/>
                </parameter>
                <parameter>
                  <valueId value="eD4"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="coughCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD4"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD4"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="coughCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD4"/>
                <element value="code"/>
                <variable value="cdD4"/>
              </target>
              <rule>
                <name value="coughCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdD4"/>
                  <element value="coding"/>
                  <variable value="ccD4"/>
                </target>
                <rule>
                  <name value="coughSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD4"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="coughCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD4"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="28238-4"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="coughDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD4"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Cough"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="coughValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD4"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itD4"/>
                </parameter>
                <parameter>
                  <valueId value="obD4"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="diarrhoeaRule"/>
        <source>
          <context value="gDs"/>
          <element value="item"/>
          <variable value="itD5"/>
          <condition value="linkId = 'IMM-DS-Q5-diarrhoea'"/>
        </source>
        <rule>
          <name value="diarrhoeaAnswer"/>
          <source>
            <context value="itD5"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aD5"/>
          </source>
          <rule>
            <name value="diarrhoeaObservation"/>
            <source>
              <context value="aD5"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eD5"/>
            </target>
            <target>
              <context value="eD5"/>
              <element value="resource"/>
              <variable value="obD5"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="diarrhoeaBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD5"/>
              </target>
              <target>
                <context value="eD5"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD5"/>
                </parameter>
                <parameter>
                  <valueId value="eD5"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="diarrhoeaCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD5"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD5"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="diarrhoeaCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD5"/>
                <element value="code"/>
                <variable value="cdD5"/>
              </target>
              <rule>
                <name value="diarrhoeaCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdD5"/>
                  <element value="coding"/>
                  <variable value="ccD5"/>
                </target>
                <rule>
                  <name value="diarrhoeaSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD5"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://snomed.info/sct"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="diarrhoeaCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD5"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="28229008"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="diarrhoeaDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD5"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Diarrhoea"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="diarrhoeaValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD5"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itD5"/>
                </parameter>
                <parameter>
                  <valueId value="obD5"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
        <documentation
                       value="The questionnaire declares this SNOMED CT concept id under the LOINC
system; emitted here against the SNOMED CT system it actually belongs to."/>
      </rule>
      <rule>
        <name value="vomitingRule"/>
        <source>
          <context value="gDs"/>
          <element value="item"/>
          <variable value="itD6"/>
          <condition value="linkId = 'IMM-DS-Q6-vomiting'"/>
        </source>
        <rule>
          <name value="vomitingAnswer"/>
          <source>
            <context value="itD6"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aD6"/>
          </source>
          <rule>
            <name value="vomitingObservation"/>
            <source>
              <context value="aD6"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eD6"/>
            </target>
            <target>
              <context value="eD6"/>
              <element value="resource"/>
              <variable value="obD6"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="vomitingBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD6"/>
              </target>
              <target>
                <context value="eD6"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD6"/>
                </parameter>
                <parameter>
                  <valueId value="eD6"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="vomitingCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD6"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD6"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="vomitingCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD6"/>
                <element value="code"/>
                <variable value="cdD6"/>
              </target>
              <rule>
                <name value="vomitingCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdD6"/>
                  <element value="coding"/>
                  <variable value="ccD6"/>
                </target>
                <rule>
                  <name value="vomitingSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD6"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://snomed.info/sct"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="vomitingCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD6"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="21522001"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="vomitingDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD6"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Vomiting"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="vomitingValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD6"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itD6"/>
                </parameter>
                <parameter>
                  <valueId value="obD6"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="dsNotesRule"/>
        <source>
          <context value="gDs"/>
          <element value="item"/>
          <variable value="itD7"/>
          <condition value="linkId = 'IMM-DS-Q7-notes'"/>
        </source>
        <rule>
          <name value="dsNotesAnswer"/>
          <source>
            <context value="itD7"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aD7"/>
          </source>
          <rule>
            <name value="dsNotesObservation"/>
            <source>
              <context value="aD7"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eD7"/>
            </target>
            <target>
              <context value="eD7"/>
              <element value="resource"/>
              <variable value="obD7"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="dsNotesBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD7"/>
              </target>
              <target>
                <context value="eD7"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD7"/>
                </parameter>
                <parameter>
                  <valueId value="eD7"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="dsNotesCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD7"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obD7"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="dsNotesCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obD7"/>
                <element value="code"/>
                <variable value="cdD7"/>
              </target>
              <rule>
                <name value="dsNotesCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdD7"/>
                  <element value="coding"/>
                  <variable value="ccD7"/>
                </target>
                <rule>
                  <name value="dsNotesSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD7"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsNotesCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD7"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="48767-8"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsNotesDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccD7"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Annotation comment"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="dsNotesCodeText"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdD7"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Danger signs clinical notes"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="dsNotesValue"/>
              <source>
                <context value="aD7"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obD7"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="------------------------------------------------------------- Danger signs"/>
    </rule>
    <rule>
      <name value="educationGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="gEd"/>
        <condition value="linkId = 'IMM-group-education'"/>
      </source>
      <rule>
        <name value="eduGivenRule"/>
        <source>
          <context value="gEd"/>
          <element value="item"/>
          <variable value="itE1"/>
          <condition value="linkId = 'IMM-ED-Q1-education-given'"/>
        </source>
        <rule>
          <name value="eduGivenAnswer"/>
          <source>
            <context value="itE1"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aE1"/>
          </source>
          <rule>
            <name value="eduGivenObservation"/>
            <source>
              <context value="aE1"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eE1"/>
            </target>
            <target>
              <context value="eE1"/>
              <element value="resource"/>
              <variable value="obE1"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="eduGivenBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE1"/>
              </target>
              <target>
                <context value="eE1"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obE1"/>
                </parameter>
                <parameter>
                  <valueId value="eE1"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="eduGivenCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE1"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obE1"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="eduGivenCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE1"/>
                <element value="code"/>
                <variable value="cdE1"/>
              </target>
              <rule>
                <name value="eduGivenCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdE1"/>
                  <element value="coding"/>
                  <variable value="ccE1"/>
                </target>
                <rule>
                  <name value="eduGivenSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccE1"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="eduGivenCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccE1"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="61144-2"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="eduGivenDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccE1"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Patient education provided"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="eduGivenValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE1"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itE1"/>
                </parameter>
                <parameter>
                  <valueId value="obE1"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="eduTopicsRule"/>
        <source>
          <context value="gEd"/>
          <element value="item"/>
          <variable value="itE2"/>
          <condition value="linkId = 'IMM-ED-Q2-topics'"/>
        </source>
        <rule>
          <name value="eduTopicsAnswer"/>
          <source>
            <context value="itE2"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aE2"/>
          </source>
          <rule>
            <name value="eduTopicsObservation"/>
            <source>
              <context value="aE2"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eE2"/>
            </target>
            <target>
              <context value="eE2"/>
              <element value="resource"/>
              <variable value="obE2"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="eduTopicsBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE2"/>
              </target>
              <target>
                <context value="eE2"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obE2"/>
                </parameter>
                <parameter>
                  <valueId value="eE2"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="eduTopicsCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE2"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obE2"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="eduTopicsCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE2"/>
                <element value="code"/>
                <variable value="cdE2"/>
              </target>
              <rule>
                <name value="eduTopicsCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdE2"/>
                  <element value="coding"/>
                  <variable value="ccE2"/>
                </target>
                <rule>
                  <name value="eduTopicsSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccE2"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="eduTopicsCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccE2"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="61144-2"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="eduTopicsDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccE2"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Education topics covered"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="eduTopicsCodeText"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdE2"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Education topics covered"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="eduTopicsValue"/>
              <source>
                <context value="aE2"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obE2"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="nextVisitToldRule"/>
        <source>
          <context value="gEd"/>
          <element value="item"/>
          <variable value="itE3"/>
          <condition value="linkId = 'IMM-ED-Q3-next-visit'"/>
        </source>
        <rule>
          <name value="nextVisitToldAnswer"/>
          <source>
            <context value="itE3"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aE3"/>
          </source>
          <rule>
            <name value="nextVisitToldObservation"/>
            <source>
              <context value="aE3"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eE3"/>
            </target>
            <target>
              <context value="eE3"/>
              <element value="resource"/>
              <variable value="obE3"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="nextVisitToldBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE3"/>
              </target>
              <target>
                <context value="eE3"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obE3"/>
                </parameter>
                <parameter>
                  <valueId value="eE3"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="nextVisitToldCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE3"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obE3"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="nextVisitToldCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE3"/>
                <element value="code"/>
                <variable value="cdE3"/>
              </target>
              <rule>
                <name value="nextVisitToldCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdE3"/>
                  <element value="coding"/>
                  <variable value="ccE3"/>
                </target>
                <rule>
                  <name value="nextVisitToldSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccE3"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="nextVisitToldCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccE3"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="57177-3"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="nextVisitToldDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccE3"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Follow-up plan"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="nextVisitToldCodeText"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdE3"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="Next visit date communicated to caregiver"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="nextVisitToldValue"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obE3"/>
              </target>
              <dependent>
                <name value="SetCodedValue"/>
                <parameter>
                  <valueId value="itE3"/>
                </parameter>
                <parameter>
                  <valueId value="obE3"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="nextVisitDateRule"/>
        <source>
          <context value="gEd"/>
          <element value="item"/>
          <variable value="itE4"/>
          <condition value="linkId = 'IMM-ED-Q4-next-visit-date'"/>
        </source>
        <rule>
          <name value="nextVisitDateAnswer"/>
          <source>
            <context value="itE4"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aE4"/>
          </source>
          <rule>
            <name value="appointmentResource"/>
            <source>
              <context value="aE4"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eE4"/>
            </target>
            <target>
              <context value="eE4"/>
              <element value="resource"/>
              <variable value="appt"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Appointment"/>
              </parameter>
            </target>
            <rule>
              <name value="apptCellIdentifier"/>
              <source>
                <context value="aE4"/>
                <element value="value"/>
                <variable value="dvAp"/>
              </source>
              <target>
                <context value="appt"/>
                <element value="identifier"/>
                <variable value="idAp"/>
              </target>
              <rule>
                <name value="apptCellSystem"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="idAp"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="apptCellValue"/>
                <source>
                  <context value="dvAp"/>
                </source>
                <target>
                  <context value="idAp"/>
                  <element value="value"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="IMM-ED-Q4-next-visit-date@"/>
                  </parameter>
                  <parameter>
                    <valueId value="dvAp"/>
                  </parameter>
                </target>
              </rule>
              <documentation
                             value="One proposed appointment per (child, requested date)."/>
            </rule>
            <rule>
              <name value="apptSubject"/>
              <source>
                <context value="qr"/>
                <element value="subject"/>
                <variable value="subjAp"/>
              </source>
              <rule>
                <name value="apptPatientRef"/>
                <source>
                  <context value="subjAp"/>
                  <element value="reference"/>
                  <variable value="prefAp"/>
                </source>
                <rule>
                  <name value="apptReq"/>
                  <source>
                    <context value="aE4"/>
                    <element value="value"/>
                    <variable value="dvAp2"/>
                  </source>
                  <target>
                    <context value="eE4"/>
                    <element value="request"/>
                    <variable value="rqAp"/>
                  </target>
                  <rule>
                    <name value="apptReqMethod"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="rqAp"/>
                      <element value="method"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="POST"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="apptReqUrl"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="rqAp"/>
                      <element value="url"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="Appointment"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="apptIfNoneExist"/>
                    <source>
                      <context value="qr"/>
                    </source>
                    <target>
                      <context value="rqAp"/>
                      <element value="ifNoneExist"/>
                      <transform value="append"/>
                      <parameter>
                        <valueString value="actor="/>
                      </parameter>
                      <parameter>
                        <valueId value="prefAp"/>
                      </parameter>
                      <parameter>
                        <valueString
                                     value="&amp;identifier=https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell|IMM-ED-Q4-next-visit-date@"/>
                      </parameter>
                      <parameter>
                        <valueId value="dvAp2"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="apptId"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="appt"/>
                <element value="id"/>
                <transform value="uuid"/>
              </target>
            </rule>
            <rule>
              <name value="apptStatus"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="appt"/>
                <element value="status"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="proposed"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="apptDescription"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="appt"/>
                <element value="description"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="Next scheduled immunisation visit (MOH 510)"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="apptSubject"/>
              <source>
                <context value="qr"/>
                <element value="subject"/>
                <variable value="s"/>
              </source>
              <target>
                <context value="appt"/>
                <element value="subject"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="s"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="apptParticipant"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="appt"/>
                <element value="participant"/>
                <variable value="prt"/>
              </target>
              <rule>
                <name value="apptParticipantStatus"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="prt"/>
                  <element value="status"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="needs-action"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="apptParticipantActor"/>
                <source>
                  <context value="qr"/>
                  <element value="subject"/>
                  <variable value="s"/>
                </source>
                <target>
                  <context value="prt"/>
                  <element value="actor"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="s"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="apptRequestedPeriod"/>
              <source>
                <context value="aE4"/>
                <element value="value"/>
                <variable value="dv"/>
              </source>
              <target>
                <context value="appt"/>
                <element value="requestedPeriod"/>
                <variable value="rp"/>
              </target>
              <rule>
                <name value="apptRequestedStart"/>
                <source>
                  <context value="dv"/>
                </source>
                <target>
                  <context value="rp"/>
                  <element value="start"/>
                  <transform value="cast"/>
                  <parameter>
                    <valueId value="dv"/>
                  </parameter>
                  <parameter>
                    <valueString value="dateTime"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
        <documentation
                       value="Appointment.start is an instant, so a date-only answer is carried on
requestedPeriod instead."/>
      </rule>
      <documentation
                     value="---------------------------------------------------------- Patient education"/>
    </rule>
    <rule>
      <name value="remarksGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="gRem"/>
        <condition value="linkId = 'IMM-group-remarks'"/>
      </source>
      <rule>
        <name value="remarksRule"/>
        <source>
          <context value="gRem"/>
          <element value="item"/>
          <variable value="itAe"/>
          <condition value="linkId = '48767-8'"/>
        </source>
        <rule>
          <name value="remarksAnswer"/>
          <source>
            <context value="itAe"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="aAe"/>
          </source>
          <rule>
            <name value="remarksObservation"/>
            <source>
              <context value="aAe"/>
            </source>
            <target>
              <context value="bundle"/>
              <element value="entry"/>
              <variable value="eAe"/>
            </target>
            <target>
              <context value="eAe"/>
              <element value="resource"/>
              <variable value="obAe"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="remarksBase"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obAe"/>
              </target>
              <target>
                <context value="eAe"/>
              </target>
              <dependent>
                <name value="BuildObsBase"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obAe"/>
                </parameter>
                <parameter>
                  <valueId value="eAe"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="remarksCategory"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obAe"/>
              </target>
              <dependent>
                <name value="SurveyCategory"/>
                <parameter>
                  <valueId value="qr"/>
                </parameter>
                <parameter>
                  <valueId value="obAe"/>
                </parameter>
              </dependent>
            </rule>
            <rule>
              <name value="remarksCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="obAe"/>
                <element value="code"/>
                <variable value="cdAe"/>
              </target>
              <rule>
                <name value="remarksCodeCoding"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdAe"/>
                  <element value="coding"/>
                  <variable value="ccAe"/>
                </target>
                <rule>
                  <name value="remarksSystem"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccAe"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="remarksCode"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccAe"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="48767-8"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="remarksDisplay"/>
                  <source>
                    <context value="qr"/>
                  </source>
                  <target>
                    <context value="ccAe"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Annotation comment"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="remarksCodeText"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="cdAe"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="MOH 510 register remarks"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="remarksValue"/>
              <source>
                <context value="aAe"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obAe"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="---------------------------------------------------------------- AE Remarks"/>
    </rule>
  </group>
  <group>
    <name value="BuildObsBase"/>
    <documentation
                   value="---------------------------------------------------------------- helper groups
Plain POST, deliberately not a conditional create. These are per-visit facts,
so the key would have to be (cell, visit) -- and qr.authored carries a
&quot;+03:00&quot; offset that cannot go into an ifNoneExist query string unencoded.
Consequence: extracting the SAME response twice duplicates its Observations.
Populate never fills these sections, so the populate/extract loop is
unaffected; only a repeated submission of one response is."/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="obsReq"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="request"/>
        <variable value="rq"/>
      </target>
      <rule>
        <name value="obsReqMethod"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="rq"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="obsReqUrl"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="rq"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="obsId"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="obsStatus"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="obsSubject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="obsEncounter"/>
      <source>
        <context value="qr"/>
        <element value="encounter"/>
        <variable value="e"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="encounter"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="e"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="obsEffective"/>
      <source>
        <context value="qr"/>
        <element value="authored"/>
        <variable value="t"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="effective"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="t"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="obsDerivedFrom"/>
      <source>
        <context value="qr"/>
        <element value="id"/>
        <variable value="qid"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="derivedFrom"/>
        <variable value="dr"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <rule>
        <name value="obsDerivedRef"/>
        <source>
          <context value="qid"/>
        </source>
        <target>
          <context value="dr"/>
          <element value="reference"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="qid"/>
          </parameter>
        </target>
      </rule>
      <documentation
                     value="qr.id is already type-qualified (&quot;QuestionnaireResponse/1008&quot;) when the
response is read from the server, so prepending the type -- or using
reference() -- yields a doubled reference."/>
    </rule>
  </group>
  <group>
    <name value="BuildImm"/>
    <documentation
                   value="A register cell -- (child, column) -- is the natural key for everything below.
The paper form has exactly one BCG box per child, so re-submitting a
pre-populated form must not add a second one. Each resource therefore carries
its linkId as a business identifier and is emitted as a conditional create."/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="it"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="a"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="imm"/>
      <type value="Immunization"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="immCellIdentifier"/>
      <source>
        <context value="it"/>
        <element value="linkId"/>
        <variable value="lk"/>
      </source>
      <target>
        <context value="imm"/>
        <element value="identifier"/>
        <variable value="idc"/>
      </target>
      <rule>
        <name value="immCellSystem"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="idc"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="immCellValue"/>
        <source>
          <context value="lk"/>
        </source>
        <target>
          <context value="idc"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="lk"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="immSubject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="subjImm"/>
      </source>
      <rule>
        <name value="immPatientRef"/>
        <source>
          <context value="subjImm"/>
          <element value="reference"/>
          <variable value="pref"/>
        </source>
        <rule>
          <name value="immReq"/>
          <source>
            <context value="it"/>
            <element value="linkId"/>
            <variable value="lk2"/>
          </source>
          <target>
            <context value="entry"/>
            <element value="request"/>
            <variable value="rq"/>
          </target>
          <rule>
            <name value="immReqMethod"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rq"/>
              <element value="method"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="POST"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="immReqUrl"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rq"/>
              <element value="url"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Immunization"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="immIfNoneExist"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rq"/>
              <element value="ifNoneExist"/>
              <transform value="append"/>
              <parameter>
                <valueString value="patient="/>
              </parameter>
              <parameter>
                <valueId value="pref"/>
              </parameter>
              <parameter>
                <valueString
                             value="&amp;identifier=https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell|"/>
              </parameter>
              <parameter>
                <valueId value="lk2"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="immId"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="imm"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="immStatus"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="imm"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="completed"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="immPrimarySource"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="imm"/>
        <element value="primarySource"/>
        <transform value="copy"/>
        <parameter>
          <valueBoolean value="false"/>
        </parameter>
      </target>
      <documentation
                     value="Register entries are transcribed from the child's card, so the recording
facility is not necessarily the administering one."/>
    </rule>
    <rule>
      <name value="immPatient"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="imm"/>
        <element value="patient"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="immEncounter"/>
      <source>
        <context value="qr"/>
        <element value="encounter"/>
        <variable value="e"/>
      </source>
      <target>
        <context value="imm"/>
        <element value="encounter"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="e"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="immOccurrence"/>
      <source>
        <context value="a"/>
        <element value="value"/>
        <variable value="dv"/>
      </source>
      <target>
        <context value="imm"/>
        <element value="occurrence"/>
        <transform value="cast"/>
        <parameter>
          <valueId value="dv"/>
        </parameter>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="BuildMedAdmin"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="it"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="a"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="ma"/>
      <type value="MedicationAdministration"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="maCellIdentifier"/>
      <source>
        <context value="it"/>
        <element value="linkId"/>
        <variable value="lk"/>
      </source>
      <target>
        <context value="ma"/>
        <element value="identifier"/>
        <variable value="idc"/>
      </target>
      <rule>
        <name value="maCellSystem"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="idc"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="maCellValue"/>
        <source>
          <context value="lk"/>
        </source>
        <target>
          <context value="idc"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="lk"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="maSubject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="subjMa"/>
      </source>
      <rule>
        <name value="maPatientRef"/>
        <source>
          <context value="subjMa"/>
          <element value="reference"/>
          <variable value="pref"/>
        </source>
        <rule>
          <name value="maReq"/>
          <source>
            <context value="it"/>
            <element value="linkId"/>
            <variable value="lk2"/>
          </source>
          <target>
            <context value="entry"/>
            <element value="request"/>
            <variable value="rq"/>
          </target>
          <rule>
            <name value="maReqMethod"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rq"/>
              <element value="method"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="POST"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="maReqUrl"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rq"/>
              <element value="url"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="MedicationAdministration"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="maIfNoneExist"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rq"/>
              <element value="ifNoneExist"/>
              <transform value="append"/>
              <parameter>
                <valueString value="subject="/>
              </parameter>
              <parameter>
                <valueId value="pref"/>
              </parameter>
              <parameter>
                <valueString
                             value="&amp;identifier=https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell|"/>
              </parameter>
              <parameter>
                <valueId value="lk2"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="maId"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="ma"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="maStatus"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="ma"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="completed"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="maSubject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="ma"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="maEncounter"/>
      <source>
        <context value="qr"/>
        <element value="encounter"/>
        <variable value="e"/>
      </source>
      <target>
        <context value="ma"/>
        <element value="encounter"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="e"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="maOccurence"/>
      <source>
        <context value="a"/>
        <element value="value"/>
        <variable value="dv"/>
      </source>
      <target>
        <context value="ma"/>
        <element value="occurence"/>
        <transform value="cast"/>
        <parameter>
          <valueId value="dv"/>
        </parameter>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="BuildRelatedPerson"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="it"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="rp"/>
      <type value="RelatedPerson"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="rpCellIdentifier"/>
      <source>
        <context value="it"/>
        <element value="linkId"/>
        <variable value="lk"/>
      </source>
      <target>
        <context value="rp"/>
        <element value="identifier"/>
        <variable value="idc"/>
      </target>
      <rule>
        <name value="rpCellSystem"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="idc"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="rpCellValue"/>
        <source>
          <context value="lk"/>
        </source>
        <target>
          <context value="idc"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="lk"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="rpSubject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="subjRp"/>
      </source>
      <rule>
        <name value="rpPatientRef"/>
        <source>
          <context value="subjRp"/>
          <element value="reference"/>
          <variable value="pref"/>
        </source>
        <rule>
          <name value="rpReq"/>
          <source>
            <context value="it"/>
            <element value="linkId"/>
            <variable value="lk2"/>
          </source>
          <target>
            <context value="entry"/>
            <element value="request"/>
            <variable value="rq"/>
          </target>
          <rule>
            <name value="rpReqMethod"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rq"/>
              <element value="method"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="POST"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="rpReqUrl"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rq"/>
              <element value="url"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="RelatedPerson"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="rpIfNoneExist"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rq"/>
              <element value="ifNoneExist"/>
              <transform value="append"/>
              <parameter>
                <valueString value="patient="/>
              </parameter>
              <parameter>
                <valueId value="pref"/>
              </parameter>
              <parameter>
                <valueString
                             value="&amp;identifier=https://fhir.slade360.co.ke/fhir/Identifier/moh510-register-cell|"/>
              </parameter>
              <parameter>
                <valueId value="lk2"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="rpId"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="rp"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="rpActive"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="rp"/>
        <element value="active"/>
        <transform value="copy"/>
        <parameter>
          <valueBoolean value="true"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="rpPatient"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="rp"/>
        <element value="patient"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="VitalSignsCategory"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="vsCat"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="vsCatCoding"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="c"/>
        </target>
        <rule>
          <name value="vsCatSystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="c"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="vsCatCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="c"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="vital-signs"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="vsCatDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="c"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Vital Signs"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SurveyCategory"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="svCat"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="svCatCoding"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="c"/>
        </target>
        <rule>
          <name value="svCatSystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="c"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="svCatCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="c"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="survey"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="svCatDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="c"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Survey"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetCodedValue"/>
    <input>
      <name value="it"/>
      <type value="Element"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="setCodedValue"/>
      <source>
        <context value="it"/>
        <element value="answer"/>
        <variable value="a"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="value"/>
        <variable value="c"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <rule>
        <name value="copyCoding"/>
        <source>
          <context value="a"/>
          <element value="value"/>
          <variable value="coding"/>
        </source>
        <target>
          <context value="c"/>
          <element value="coding"/>
          <variable value="nc"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="coding"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
</StructureMap>