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

: Paediatric Admission Record Extraction - XML Representation

Active as of 2026-09-14

Raw xml | Download


<StructureMap xmlns="http://hl7.org/fhir">
  <id value="ExtractPaediatricAdmissionRecord"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap ExtractPaediatricAdmissionRecord</b></p><a name="ExtractPaediatricAdmissionRecord"> </a><a name="hcExtractPaediatricAdmissionRecord"> </a><pre class="fml">
<span style="color: #cc00cc">/// <b>url</b> = </span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractPaediatricAdmissionRecord'</span>
<span style="color: #cc00cc">/// <b>name</b> = </span><span style="color: blue">'ExtractPaediatricAdmissionRecord'</span>
<span style="color: #cc00cc">/// <b>title</b> = </span><span style="color: blue">'Paediatric Admission Record 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">'The three-page paediatric admission record out as: the anthropometry and vital signs each as their own Observation so a growth chart can graph them; the IMCI history and the ABCD examination as two panels, because a sign only means anything as part of the set the clinician worked through; the immunisation card as one dose-count panel rather than as Immunization resources, which the sheet gives no dates for; a Condition per admission diagnosis, primary first; a ServiceRequest per investigation ordered; a CarePlan for the supportive care; and a Consent from the carer\'s signature at the foot of the sheet.'</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/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/condition.html" title="Condition">http://hl7.org/fhir/StructureDefinition/Condition</a><span style="color: navy">&quot; </span><b>alias </b>Condition <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/servicerequest.html" title="ServiceRequest">http://hl7.org/fhir/StructureDefinition/ServiceRequest</a><span style="color: navy">&quot; </span><b>alias </b>ServiceRequest <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/careplan.html" title="CarePlan">http://hl7.org/fhir/StructureDefinition/CarePlan</a><span style="color: navy">&quot; </span><b>alias </b>CarePlan <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/consent.html" title="Consent">http://hl7.org/fhir/StructureDefinition/Consent</a><span style="color: navy">&quot; </span><b>alias </b>Consent <b>as </b><b>target</b>

<b>group </b>ExtractPaediatricAdmissionRecord<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">── Growth measurements ─────────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">One Observation each, all in the vital-signs category, because these are</span>
  <span style="color: navy">// </span><span style="color: green">exactly what a growth chart plots. Weight-for-height carries LOINC 77606-2</span>
  <span style="color: navy">// </span><span style="color: green">rather than a local code: the sheet calls it &quot;W/H score&quot; and means the</span>
  <span style="color: navy">// </span><span style="color: green">weight-for-length Z score for age and sex, which is what that term is.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'anthropometry'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'anthropometry/weight') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'29463-7'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Body weight'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;anthro_29463_7&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'anthropometry/height') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8302-2'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Body height'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;anthro_8302_2&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'anthropometry/muac') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'56072-2'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Circumference Mid upper arm - right'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;anthro_56072_2&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'anthropometry/head-circumference') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'9843-4'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Head Occipital-frontal circumference'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;anthro_9843_4&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'anthropometry/weight-for-height-z') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'77606-2'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Weight-for-length Per age and sex'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.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">q</span><b> then</b><span style="color: navy"> {
</span>          v<span style="color: navy"><b> -&gt; </b></span>q.value = <span style="color: maroon">v</span> <i>&quot;qValue&quot;</i><span style="color: navy">;</span>
          v<span style="color: navy"><b> -&gt; </b></span>q.unit = <span style="color: blue">'SD'</span> <i>&quot;qUnit&quot;</i><span style="color: navy">;</span>
          v<span style="color: navy"><b> -&gt; </b></span>q.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;qSystem&quot;</i><span style="color: navy">;</span>
          v<span style="color: navy"><b> -&gt; </b></span>q.code = <span style="color: blue">'1'</span> <i>&quot;qCode&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;quantity&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;weightForHeightZ&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;anthropometryGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Vital signs ─────────────────────────────────────────────────────────</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'vital-signs'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'vital-signs/temperature') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8310-5'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Body temperature'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vital_8310_5&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'vital-signs/respiratory-rate') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'9279-1'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Respiratory rate'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vital_9279_1&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'vital-signs/pulse') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8867-4'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Heart rate'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vital_8867_4&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'vital-signs/oxygen-saturation') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'59408-5'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Oxygen saturation in Arterial blood by Pulse oximetry'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vital_59408_5&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">bp</span><b> where </b><span style="color: navy">(</span>(linkId = 'vital-signs/blood-pressure') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      bp<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        bp<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          bp<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          bp<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'85354-9'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          bp<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Blood pressure panel with all children optional'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      bp.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'vital-signs/blood-pressure/systolic') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8480-6'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Systolic blood pressure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_8480_6&quot;</i><span style="color: navy">;</span>
      bp.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'vital-signs/blood-pressure/diastolic') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8462-4'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Diastolic blood pressure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_8462_4&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;bloodPressureObservation&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;vitalSignsGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── The IMCI history, as one panel ──────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">Coded to LOINC 10164-2, history of present illness. The signs are coded</span>
  <span style="color: navy">// </span><span style="color: green">components; the days and counts beside them are quantity components under</span>
  <span style="color: navy">// </span><span style="color: green">their own concept codes, so &quot;cough for four days&quot; survives as two facts</span>
  <span style="color: navy">// </span><span style="color: green">that belong together rather than as a sentence.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'history') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'10164-2'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'History of Present illness Narrative'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'History of the presenting illness'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">fever</span><b> where </b><span style="color: navy">(</span>linkId = 'history/fever'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      fever.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/fever/present') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-fever'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Fever'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_fever&quot;</i><span style="color: navy">;</span>
      fever.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/fever/duration') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-days-of-fever'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Days of fever'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_days_of_fever&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;HistoryFeverGroup&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">cough</span><b> where </b><span style="color: navy">(</span>linkId = 'history/cough'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      cough.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/cough/present') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-cough'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Cough'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_cough&quot;</i><span style="color: navy">;</span>
      cough.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/cough/duration') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-days-of-cough'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Days of cough'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_days_of_cough&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;HistoryCoughGroup&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/cough-over-2-weeks') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-cough-for-more-than-two-weeks'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Cough for more than two weeks'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_sign_cough_for_more_than_two_weeks&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/tb-contact') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-contact-with-tb-or-a-chronic-cough-in-the-last-12'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Contact with TB or a chronic cough in the last 12 months'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_sign_contact_with_tb_or_a_chronic_cough_in_the_last_12&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/difficulty-breathing') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-difficulty-breathing'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Difficulty breathing'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_sign_difficulty_breathing&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">diarrhoea</span><b> where </b><span style="color: navy">(</span>linkId = 'history/diarrhoea'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      diarrhoea.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/diarrhoea/present') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-diarrhoea'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Diarrhoea'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_diarrhoea&quot;</i><span style="color: navy">;</span>
      diarrhoea.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/diarrhoea/duration') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-days-of-diarrhoea'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Days of diarrhoea'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_days_of_diarrhoea&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;HistoryDiarrhoeaGroup&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/diarrhoea-over-14-days') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-diarrhoea-for-more-than-14-days'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Diarrhoea for more than 14 days'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_sign_diarrhoea_for_more_than_14_days&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/diarrhoea-bloody') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-bloody-diarrhoea'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Bloody diarrhoea'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_sign_bloody_diarrhoea&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">vomiting</span><b> where </b><span style="color: navy">(</span>linkId = 'history/vomiting'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      vomiting.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/vomiting/present') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-vomiting'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Vomiting'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_vomiting&quot;</i><span style="color: navy">;</span>
      vomiting.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/vomiting/episodes-24h') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-vomiting-episodes-in-the-last-24-hours'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Vomiting episodes in the last 24 hours'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_vomiting_episodes_in_the_last_24_hours&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;HistoryVomitingGroup&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/vomits-everything') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-vomits-everything'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Vomits everything'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_sign_vomits_everything&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/difficulty-feeding') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-difficulty-feeding'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Difficulty feeding'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_sign_difficulty_feeding&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">convulsions</span><b> where </b><span style="color: navy">(</span>linkId = 'history/convulsions'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      convulsions.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/convulsions/present') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-convulsions-during-this-illness'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Convulsions during this illness'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_convulsions_during_this_illness&quot;</i><span style="color: navy">;</span>
      convulsions.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/convulsions/count') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-number-of-convulsions-this-illness'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Number of convulsions this illness'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_number_of_convulsions_this_illness&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;HistoryConvulsionsGroup&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/partial-focal-fits') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-partial-or-focal-fits'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Partial or focal fits'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_sign_partial_or_focal_fits&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'history/length-of-illness') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-length-of-illness-in-days'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Length of illness in days'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_sign_length_of_illness_in_days&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'history/additional'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;historyPanel&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── The ABCD examination, as one panel ──────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">Coded to LOINC 8716-3, vital signs note, which is the nearest LOINC term</span>
  <span style="color: navy">// </span><span style="color: green">for &quot;what the clinician found on looking at the child&quot;. The graded findings</span>
  <span style="color: navy">// </span><span style="color: green">— jaundice, oedema, pallor, AVPU — are coded components; the timed ones —</span>
  <span style="color: navy">// </span><span style="color: green">capillary refill, skin pinch — are quantities under their LOINC and local</span>
  <span style="color: navy">// </span><span style="color: green">codes.</span>
  qr<b> where </b><span style="color: navy">(</span>item.where(linkId = 'general-examination').item.answer.value.exists() or item.where(linkId = 'abcd').item.item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetExamCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8716-3'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Vital signs note'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'Examination on admission'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'general-examination'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'general-examination/oral-thrush') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-oral-thrush'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Oral thrush'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_oral_thrush&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'general-examination'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'general-examination/lymph-node-over-1cm') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-lymph-node-greater-than-1-cm'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Lymph node greater than 1 cm'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_lymph_node_greater_than_1_cm&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp2&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'general-examination'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'general-examination/finger-clubbing') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-finger-clubbing'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Finger clubbing'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_finger_clubbing&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp3&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/airway'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/airway/stridor') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-stridor'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Stridor'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_stridor&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;exam_sub&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp4&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/breathing'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/breathing/central-cyanosis') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-central-cyanosis'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Central cyanosis'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_central_cyanosis&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;exam_sub2&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp5&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/breathing'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/breathing/indrawing') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-chest-indrawing'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Chest indrawing'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_chest_indrawing&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;exam_sub3&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp6&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/breathing'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/breathing/grunting') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-grunting'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Grunting'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_grunting&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;exam_sub4&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp7&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/breathing'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/breathing/acidotic-breathing') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-acidotic-breathing'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Acidotic breathing'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_acidotic_breathing&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;exam_sub5&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp8&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/breathing'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/breathing/wheeze') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-wheeze'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Wheeze'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_wheeze&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;exam_sub6&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp9&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/breathing'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/breathing/crackles') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-crackles'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Crackles'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_crackles&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;exam_sub7&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp10&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/circulation'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/circulation/sunken-eyes') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-sunken-eyes'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Sunken eyes'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_sunken_eyes&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;exam_sub8&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp11&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/disability'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/disability/stiff-neck') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-stiff-neck'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Stiff neck'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_stiff_neck&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;exam_sub9&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp12&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/disability'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/disability/bulging-fontanelle') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-bulging-fontanelle'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Bulging fontanelle'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_bulging_fontanelle&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;exam_sub10&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp13&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'infant-under-2-months'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'infant-under-2-months/irritable') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-irritable'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Irritable'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_irritable&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp14&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'infant-under-2-months'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'infant-under-2-months/reduced-movement-or-tone') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-reduced-movement-or-tone'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Reduced movement or tone'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_reduced_movement_or_tone&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp15&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'system-examination'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'system-examination/rickets-signs') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-wrist-or-rib-signs-of-rickets'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Wrist or rib signs of rickets'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_sign_wrist_or_rib_signs_of_rickets&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;exam_grp16&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'general-examination'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'general-examination/jaundice') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'grade-jaundice-grade'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Jaundice grade'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_grade_jaundice_grade&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;graded_grp&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'general-examination'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'general-examination/oedema') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'oedema-distribution'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Oedema distribution'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_oedema_distribution&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;graded_grp2&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/circulation'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/circulation/pallor') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'grade-pallor-or-anaemia-grade'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Pallor or anaemia grade'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_grade_pallor_or_anaemia_grade&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;graded_sub&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;graded_grp3&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/circulation'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/circulation/peripheral-pulse') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-peripheral-pulse'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Peripheral pulse'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_peripheral_pulse&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;graded_sub2&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;graded_grp4&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/circulation'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/circulation/skin-warm-at') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'sign-skin-warm-as-far-as'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Skin warm as far as'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_sign_skin_warm_as_far_as&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;graded_sub3&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;graded_grp5&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/disability'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/disability/avpu') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'triage-avpu-conscious-level'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'AVPU conscious level'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_triage_avpu_conscious_level&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;graded_sub4&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;graded_grp6&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/disability'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/disability/can-drink-or-breastfeed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'can-drink-or-breastfeed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Able to drink or breastfeed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_can_drink_or_breastfeed&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;graded_sub5&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;graded_grp7&quot;</i><span style="color: navy">;</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'newborn'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'newborn/umbilicus') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'umbilicus-appearance'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Umbilical stump appearance'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_umbilicus_appearance&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;graded_grp8&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">The two timed perfusion and turgor readings. Quantities, and both are</span>
    <span style="color: navy">// </span><span style="color: green">kept because they measure different things: capillary refill measures</span>
    <span style="color: navy">// </span><span style="color: green">perfusion at the nail bed and skin pinch measures turgor on the abdomen.</span>
    qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'abcd/circulation'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/circulation/capillary-refill') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'44971-0'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Capillary refill [Time]'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_44971_0&quot;</i><span style="color: navy">;</span>
        g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'abcd/circulation/skin-pinch') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'skin-pinch-time'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Skin pinch return time'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_skin_pinch_time&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;circulationTimed&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;abcdTimed&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;examinationPanel&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Immunisation, as a dose-count panel ─────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">Not Immunization resources. The sheet records how many doses of each</span>
  <span style="color: navy">// </span><span style="color: green">antigen the child has had, off a card, with no dates, no batch numbers and</span>
  <span style="color: navy">// </span><span style="color: green">no vaccine codes. An Immunization built from a count alone would claim a</span>
  <span style="color: navy">// </span><span style="color: green">date it does not have -- and seven of them would claim seven.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'immunisation') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'11369-6'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'History of Immunization note'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'Immunisation doses given, from the card'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'immunisation/bcg') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'bcg'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'BCG'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_bcg&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'immunisation/opv') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'bopv'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Bivalent oral poliovirus vaccine'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_bopv&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'immunisation/ipv') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'ipv'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Inactivated poliovirus vaccine'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_ipv&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'immunisation/penta') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'penta'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'DTP-HepB-Hib (pentavalent) vaccine'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_penta&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'immunisation/pneumo') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'pcv10'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Pneumococcal conjugate vaccine (PCV10)'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_pcv10&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'immunisation/rota') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'rota'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Rotavirus vaccine'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_rota&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'immunisation/measles') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'mr'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Measles-rubella vaccine'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_mr&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;immunisationPanel&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Maternal PMTCT status ───────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">Its own Observation and deliberately not a component of the history panel.</span>
  <span style="color: navy">// </span><span style="color: green">It is a fact about the mother that governs the child's management for</span>
  <span style="color: navy">// </span><span style="color: green">weeks, and it has to be findable without reading a panel.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'birth-history'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'birth-history/maternal-pmtct-status') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'maternal-pmtct-status'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Maternal PMTCT status'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">cv</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">cc</span><b> then</b><span style="color: navy"> {
</span>          cv<span style="color: navy"><b> -&gt; </b></span>cc.coding = <span style="color: maroon">cv</span> <i>&quot;valueCoding&quot;</i><span style="color: navy">;</span>
          cv.display<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: maroon">d</span> <i>&quot;valueText&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codedValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;pmtctValue&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;pmtctObservation&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'birth-history/narrative') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'11884-4'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Gestational age Estimated'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'Birth history'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;birthHistoryNarrative&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;birthHistoryGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── The narrative sections ──────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">One Observation each, carrying the text in `note` rather than in `value`.</span>
  <span style="color: navy">// </span><span style="color: green">Observation.value has no string choice in R5, and coercing a paragraph into</span>
  <span style="color: navy">// </span><span style="color: green">valueString where the spec offers none is how a resource stops validating.</span>
  qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'presenting-complaints') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'10154-3'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Chief complaint Narrative - Reported'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>      a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;narrative_presenting_complaints&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'growth-and-development') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'feeding-growth-and-development'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Growth and development'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>      a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;narrative_growth_and_development&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'nutritional-history') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'feeding-nutritional-history'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Nutritional history'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>      a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;narrative_nutritional_history&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'treatment-history') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'10160-0'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'History of Medication use Narrative'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>      a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;narrative_treatment_history&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'summary-of-problems') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'11450-4'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Problem list - Reported'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>      a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;narrative_summary_of_problems&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Review of systems, as one Observation with a note per system. Four</span>
  <span style="color: navy">// </span><span style="color: green">Observations of free text would be four resources nobody queries; one, with</span>
  <span style="color: navy">// </span><span style="color: green">the four sections as notes, is what a clinician actually reads.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'review-of-systems') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'10187-3'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Review of systems Narrative - Reported'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'review-of-systems/respiratory'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note2&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'review-of-systems/cardiovascular'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note3&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'review-of-systems/gastrointestinal-genitourinary'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note4&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'review-of-systems/cns'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note5&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;reviewOfSystemsObservation&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Examination by system, same shape and same reason.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'system-examination') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.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">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetExamCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'29545-1'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Physical findings note'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'system-examination/ent'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note6&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'system-examination/neurological'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note7&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'system-examination/chest'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note8&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'system-examination/abdomen'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note9&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'system-examination/cardiovascular'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note10&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'system-examination/bones-and-joints'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note11&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;systemExaminationObservation&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Admission diagnoses ─────────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">A Condition per diagnosis. The primary one carries</span>
  <span style="color: navy">// </span><span style="color: green">`Condition.category = problem-list-item` and a `Condition.note` saying it is</span>
  <span style="color: navy">// </span><span style="color: green">the admitting diagnosis; the secondaries carry the same category. R5 has no</span>
  <span style="color: navy">// </span><span style="color: green">rank on Condition, so primacy is expressed by the order in the bundle and</span>
  <span style="color: navy">// </span><span style="color: green">by the note, not by a field that does not exist.</span>
  <span style="color: navy">// </span><span style="color: green">Where the clinician picked an existing Condition off the problem list, the</span>
  <span style="color: navy">// </span><span style="color: green">map does not create a second one -- it would fork the problem list. The</span>
  <span style="color: navy">// </span><span style="color: green">reference travels on the primary Condition's `evidence` instead, so the</span>
  <span style="color: navy">// </span><span style="color: green">link is recorded without duplicating the diagnosis.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'admission-diagnoses'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'admission-diagnoses/primary-text') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Condition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cond</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> cond<span style="color: navy">, </span> entry<b> then </b>BuildConditionBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">cond</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>cond.clinicalStatus<b> as </b><span style="color: maroon">cs</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cs.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-clinical'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'active'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Active'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;clinicalStatus&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>cond.verificationStatus<b> as </b><span style="color: maroon">vs</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>vs.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-ver-status'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'provisional'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Provisional'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;verificationStatus&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>cond.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-category'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'problem-list-item'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Problem List Item'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> cond.code<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;diagnosisText&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span> cond.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Primary admission diagnosis'</span> <i>&quot;primaryNote&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>cond.recordedDate = <span style="color: maroon">t</span> <i>&quot;recordedDate&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>cond.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">The severity or type line -- severe / non-severe, bloody / non-bloody,</span>
      <span style="color: navy">// </span><span style="color: green">kwashiorkor / marasmus. Condition.severity is bound to a three-point</span>
      <span style="color: navy">// </span><span style="color: green">scale that none of those fit, so it rides as a note.</span>
      g.item<b> as </b><span style="color: maroon">sev</span><b> where </b><span style="color: navy">(</span>linkId = 'admission-diagnoses/primary-severity'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        sev.answer first<b> as </b><span style="color: maroon">sa</span><b> then</b><span style="color: navy"> {
</span>          sa.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> cond.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;severityNote&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;severityRule&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">ref</span><b> where </b><span style="color: navy">(</span>(linkId = 'admission-diagnoses/primary') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        ref.answer first<b> as </b><span style="color: maroon">ra</span><b> then</b><span style="color: navy"> {
</span>          ra.value<b> as </b><span style="color: maroon">existing</span><span style="color: navy"><b> -&gt; </b></span> cond.evidence<b> as </b><span style="color: maroon">ev</span><span style="color: navy">, </span> ev.reference = <span style="color: maroon">existing</span> <i>&quot;evidenceReference&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;existingConditionRule&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;primaryCondition&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">sec</span><b> where </b><span style="color: navy">(</span>linkId = 'admission-diagnoses/secondary'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      sec.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'admission-diagnoses/secondary/text') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Condition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cond</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> cond<span style="color: navy">, </span> entry<b> then </b>BuildConditionBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">cond</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cond.clinicalStatus<b> as </b><span style="color: maroon">cs</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cs.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-clinical'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'active'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Active'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;clinicalStatus&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cond.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-category'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'problem-list-item'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Problem List Item'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> cond.code<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;diagnosisText&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>cond.recordedDate = <span style="color: maroon">t</span> <i>&quot;recordedDate&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>cond.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        sec.item<b> as </b><span style="color: maroon">sv</span><b> where </b><span style="color: navy">(</span>linkId = 'admission-diagnoses/secondary/severity'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>          sv.answer first<b> as </b><span style="color: maroon">sa</span><b> then</b><span style="color: navy"> {
</span>            sa.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> cond.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;severityNote&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;severityRule&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;secondaryCondition&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;secondaryDiagnoses&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;admissionDiagnoses&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Investigations ordered ──────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">A ServiceRequest per line. `intent = 'order'` and `status = 'active'`,</span>
  <span style="color: navy">// </span><span style="color: green">because the sheet has no separate authorisation step: a clinician who wrote</span>
  <span style="color: navy">// </span><span style="color: green">it has ordered it. `code.text` carries what they wrote -- the hospital's</span>
  <span style="color: navy">// </span><span style="color: green">test catalogue is not coded, and inventing a LOINC order code from</span>
  <span style="color: navy">// </span><span style="color: green">&quot;Na+K, U&amp;C&quot; would be a guess with a clinical consequence.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'investigations'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigations/malaria') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          a<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            a<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Malaria is the one ordered from a pick list, so the answer's own</span>
        <span style="color: navy">// </span><span style="color: green">coding travels and code.text is the label beside it.</span>
        a.value<b> as </b><span style="color: maroon">cv</span><span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          cv<span style="color: navy"><b> -&gt; </b></span>cc.coding = <span style="color: maroon">cv</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          cv.display<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: maroon">d</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeFromAnswer&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>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&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>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on the paediatric admission record: Malaria test'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;createOrder&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;order_malaria&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigations/haematology') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          a<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            a<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&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>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&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>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on the paediatric admission record: Haematology'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;createOrder&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;order_haematology&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigations/microbiology') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          a<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            a<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&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>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&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>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on the paediatric admission record: Microbiology'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;createOrder&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;order_microbiology&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigations/x-ray') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          a<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            a<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'363679005'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Imaging'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&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>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&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>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on the paediatric admission record: X-ray'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;createOrder&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;order_x_ray&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigations/tb-test') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          a<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            a<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&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>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&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>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on the paediatric admission record: TB test'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;createOrder&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;order_tb_test&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigations/glucose') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          a<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            a<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&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>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&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>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on the paediatric admission record: Glucose'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;createOrder&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;order_glucose&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigations/chemistry') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          a<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            a<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&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>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&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>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on the paediatric admission record: Chemistry'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;createOrder&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;order_chemistry&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigations/hiv') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          a<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            a<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&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>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&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>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on the paediatric admission record: HIV test'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;createOrder&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;order_hiv&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigations/urine') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          a<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            a<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&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>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&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>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on the paediatric admission record: Urine'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;createOrder&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;order_urine&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigations/other') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          a<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            a<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            a<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: maroon">txt</span> <i>&quot;codeText&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>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&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>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        a<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on the paediatric admission record: Other investigation'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;createOrder&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;order_other&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;investigationsGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Supportive care ─────────────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">One CarePlan with an activity per tick. A CarePlan rather than seven</span>
  <span style="color: navy">// </span><span style="color: green">Observations, because &quot;keep warm&quot; is something to be done, not something</span>
  <span style="color: navy">// </span><span style="color: green">that was found -- and a plan is what a nurse picks up at handover.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'supportive-care') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CarePlan'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">plan</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> plan<span style="color: navy">, </span> entry<b> then </b>BuildCarePlanBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">plan</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    g<span style="color: navy"><b> -&gt; </b></span>plan.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
    g<span style="color: navy"><b> -&gt; </b></span>plan.intent = <span style="color: blue">'plan'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
    g<span style="color: navy"><b> -&gt; </b></span>plan.title = <span style="color: blue">'Supportive care on admission'</span> <i>&quot;title&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>plan.created = <span style="color: maroon">t</span> <i>&quot;created&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>plan.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
    qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>plan.custodian = <span style="color: maroon">src</span> <i>&quot;custodian&quot;</i><span style="color: navy">;</span>
    g<span style="color: navy"><b> -&gt; </b></span>plan.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>      g<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/document-type-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'paediatric-admission-record'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Paediatric admission record'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'supportive-care/keep-warm') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> plan.activity<b> as </b><span style="color: maroon">act</span><span style="color: navy">, </span> act.plannedActivityReference = <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">ref</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>ref.display = <span style="color: blue">'Keep warm'</span> <i>&quot;activityDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;care_keep_warm&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'supportive-care/oxygen') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> plan.activity<b> as </b><span style="color: maroon">act</span><span style="color: navy">, </span> act.plannedActivityReference = <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">ref</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>ref.display = <span style="color: blue">'Oxygen'</span> <i>&quot;activityDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;care_oxygen&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'supportive-care/iv-or-oral-fluids') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> plan.activity<b> as </b><span style="color: maroon">act</span><span style="color: navy">, </span> act.plannedActivityReference = <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">ref</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>ref.display = <span style="color: blue">'IV or oral fluids plan'</span> <i>&quot;activityDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;care_iv_or_oral_fluids&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'supportive-care/blood-transfusion') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> plan.activity<b> as </b><span style="color: maroon">act</span><span style="color: navy">, </span> act.plannedActivityReference = <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">ref</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>ref.display = <span style="color: blue">'Blood transfusion'</span> <i>&quot;activityDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;care_blood_transfusion&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'supportive-care/vitamin-a') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> plan.activity<b> as </b><span style="color: maroon">act</span><span style="color: navy">, </span> act.plannedActivityReference = <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">ref</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>ref.display = <span style="color: blue">'Vitamin A'</span> <i>&quot;activityDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;care_vitamin_a&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'supportive-care/nutrition-plan') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> plan.activity<b> as </b><span style="color: maroon">act</span><span style="color: navy">, </span> act.plannedActivityReference = <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">ref</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>ref.display = <span style="color: blue">'Nutrition or feeds plan'</span> <i>&quot;activityDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;care_nutrition_plan&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Review status. Not an activity -- it says how closely to watch the child</span>
    <span style="color: navy">// </span><span style="color: green">rather than what to do to them -- so it is a note on the plan.</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'supportive-care/review-status'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">cv</span><b> then</b><span style="color: navy"> {
</span>          cv.display<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -&gt; </b></span> plan.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">d</span> <i>&quot;reviewStatusNote&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;display&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;reviewStatusRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;supportiveCarePlan&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Consent for admission ───────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">A Consent, from the carer's signature at the foot of the sheet. Only when</span>
  <span style="color: navy">// </span><span style="color: green">the box was actually ticked: a Consent generated from an unanswered</span>
  <span style="color: navy">// </span><span style="color: green">question is a consent nobody gave.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'sign-off'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'sign-off/consent-for-admission') and (answer.value = true)<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Consent'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">consent</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> consent<span style="color: navy">, </span> entry<b> then </b>BuildConsentBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">consent</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>consent.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>consent.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/consentcategorycodes'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'acd'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Advance Directive'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>cat.text = <span style="color: blue">'Consent for admission and relevant management'</span> <i>&quot;categoryText&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>consent.decision = <span style="color: blue">'permit'</span> <i>&quot;decision&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> consent.period<b> as </b><span style="color: maroon">per</span><span style="color: navy">, </span> per.start = <span style="color: maroon">t</span> <i>&quot;consentPeriodStart&quot;</i><span style="color: navy">;</span>
      qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>consent.grantee = <span style="color: maroon">src</span> <i>&quot;grantee&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span> consent.provision<b> as </b><span style="color: maroon">prov</span><span style="color: navy">, </span> prov.code<b> as </b><span style="color: maroon">pc</span><span style="color: navy">, </span> pc.text = <span style="color: blue">'Taken on the paediatric admission record. The parent or guardian signed the sheet; this records that the signature was obtained, not the signature itself.'</span> <i>&quot;provenanceNote&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;createConsent&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;consentGroup&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</span>
<span style="color: navy">// </span><span style="color: green">Shared scaffolding. Repeated in each map rather than imported: the transform</span>
<span style="color: navy">// </span><span style="color: green">engine resolves `imports` against whatever StructureMaps happen to be on the</span>
<span style="color: navy">// </span><span style="color: green">server, and a form that stops extracting because a shared map was not</span>
<span style="color: navy">// </span><span style="color: green">uploaded is a worse failure than a duplicated group.</span>
<span style="color: navy">// </span><span style="color: green">Two notes on what the publisher's StructureMap validator says about this file.</span>
<span style="color: navy">// </span><span style="color: green">Source parameters below are left untyped on purpose. Writing `: Element` makes</span>
<span style="color: navy">// </span><span style="color: green">the validator compare QuestionnaireResponse.item against the literal 'Element'</span>
<span style="color: navy">// </span><span style="color: green">and report them as incompatible with each other, which is noise, not a finding.</span>
<span style="color: navy">// </span><span style="color: green">`evaluate(context, expression)` is flagged as &quot;takes 1 parameter but 2 were</span>
<span style="color: navy">// </span><span style="color: green">found&quot;. Leave it. The FML parser in the same jar refuses the one-argument form</span>
<span style="color: navy">// </span><span style="color: green">outright -- it wants a parameter, a comma, then the FHIRPath -- so the</span>
<span style="color: navy">// </span><span style="color: green">publisher is objecting to what its own compiler emits. Two arguments is the</span>
<span style="color: navy">// </span><span style="color: green">only form that compiles, and it is what the R5 transform engine executes.</span>
<span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</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>obs<b> then </b>SetResponseProvenance<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;responseProvenance&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><b> then </b>SetObservationFullUrl<span style="color: navy">(</span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;idAndFullUrl&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;requestMethod&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'Observation'</span> <i>&quot;requestUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;entryRequest&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;status&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><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><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;effective&quot;</i><span style="color: navy">;</span>
  qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>obs.performer = <span style="color: maroon">src</span> <i>&quot;performerFromSource&quot;</i><span style="color: navy">;</span>
  qr<b> where </b><span style="color: navy">(</span>source.exists().not()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    qr.author<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span>obs.performer = <span style="color: maroon">a</span> <i>&quot;performerFromAuthor&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;performerFallback&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">A stored response's id already reads &quot;QuestionnaireResponse/&lt;id&gt;&quot;, so it is</span>
  <span style="color: navy">// </span><span style="color: green">a relative reference as it stands. The hasValue() guard is what stops an</span>
  <span style="color: navy">// </span><span style="color: green">unsaved response -- one posted straight to $extract rather than saved first</span>
  <span style="color: navy">// </span><span style="color: green">-- from writing &quot;QuestionnaireResponse/null&quot; into the record.</span>
  qr.id<b> as </b><span style="color: maroon">qid</span><b> where </b><span style="color: navy">(</span>$this.hasValue()<span style="color: navy">)</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">ref</span><span style="color: navy">, </span> ref.reference = <span style="color: maroon">qid</span> <i>&quot;linkQuestionnaireResponse&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetObservationFullUrl<span style="color: navy">(</span><b>source</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>  obs.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/Observation/'</span><span style="color: navy">, </span><span style="color: maroon">id</span><span style="color: navy">)</span> <i>&quot;assignFullUrl&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">The two answer shapes a component can carry. Both read the answer through the</span>
<span style="color: navy">// </span><span style="color: green">untyped `.value` accessor: reading `valueCoding` or `valueQuantity` by its</span>
<span style="color: navy">// </span><span style="color: green">typed property name fails at transform time on HAPI R5 with &quot;Attempt to read</span>
<span style="color: navy">// </span><span style="color: green">invalid property ... on QuestionnaireResponse.item.answer&quot;.</span>
<b>group </b>SetComponentCodedValue<span style="color: navy">(</span><b>source</b> <span style="color: maroon">it</span>, <b>target</b> <span style="color: maroon">comp</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>    a.value<b> as </b><span style="color: maroon">cv</span><span style="color: navy"><b> -&gt; </b></span>comp.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">cc</span><b> then</b><span style="color: navy"> {
</span>      cv<span style="color: navy"><b> -&gt; </b></span>cc.coding = <span style="color: maroon">cv</span> <i>&quot;valueCoding&quot;</i><span style="color: navy">;</span>
      cv.display<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: maroon">d</span> <i>&quot;valueText&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;codedValue&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;componentAnswer&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetComponentValue<span style="color: navy">(</span><b>source</b> <span style="color: maroon">it</span>, <b>target</b> <span style="color: maroon">comp</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>    a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>comp.value = <span style="color: maroon">v</span> <i>&quot;plainValue&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;componentAnswer&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetSurveyCategory<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">coding</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorySystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'survey'</span> <i>&quot;categoryCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Survey'</span> <i>&quot;categoryDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;categoryCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetVitalSignsCategory<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">coding</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorySystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;categoryCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;categoryDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;categoryCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetExamCategory<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">coding</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorySystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'exam'</span> <i>&quot;categoryCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Exam'</span> <i>&quot;categoryDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;categoryCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>BuildConditionBase<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">r</span><span style="color: navy"> : </span>Condition, <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>r<b> then </b>SetResponseProvenance<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">r</span><span style="color: navy">)</span> <i>&quot;responseProvenance&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>r.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> then </b>SetConditionFullUrl<span style="color: navy">(</span><span style="color: maroon">r</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;idAndFullUrl&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;requestMethod&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'Condition'</span> <i>&quot;requestUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;entryRequest&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>r.subject = <span style="color: maroon">s</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetConditionFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">r</span><span style="color: navy"> : </span>Condition, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  r.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/Condition/'</span><span style="color: navy">, </span><span style="color: maroon">id</span><span style="color: navy">)</span> <i>&quot;assignFullUrl&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>BuildServiceRequestBase<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">r</span><span style="color: navy"> : </span>ServiceRequest, <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>r<b> then </b>SetResponseProvenance<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">r</span><span style="color: navy">)</span> <i>&quot;responseProvenance&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>r.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> then </b>SetServiceRequestFullUrl<span style="color: navy">(</span><span style="color: maroon">r</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;idAndFullUrl&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;requestMethod&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'ServiceRequest'</span> <i>&quot;requestUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;entryRequest&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>r.subject = <span style="color: maroon">s</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetServiceRequestFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">r</span><span style="color: navy"> : </span>ServiceRequest, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  r.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/ServiceRequest/'</span><span style="color: navy">, </span><span style="color: maroon">id</span><span style="color: navy">)</span> <i>&quot;assignFullUrl&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>BuildCarePlanBase<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">r</span><span style="color: navy"> : </span>CarePlan, <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>r<b> then </b>SetResponseProvenance<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">r</span><span style="color: navy">)</span> <i>&quot;responseProvenance&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>r.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> then </b>SetCarePlanFullUrl<span style="color: navy">(</span><span style="color: maroon">r</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;idAndFullUrl&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;requestMethod&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'CarePlan'</span> <i>&quot;requestUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;entryRequest&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>r.subject = <span style="color: maroon">s</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetCarePlanFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">r</span><span style="color: navy"> : </span>CarePlan, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  r.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/CarePlan/'</span><span style="color: navy">, </span><span style="color: maroon">id</span><span style="color: navy">)</span> <i>&quot;assignFullUrl&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>BuildConsentBase<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">r</span><span style="color: navy"> : </span>Consent, <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>r<b> then </b>SetResponseProvenance<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">r</span><span style="color: navy">)</span> <i>&quot;responseProvenance&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>r.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> then </b>SetConsentFullUrl<span style="color: navy">(</span><span style="color: maroon">r</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;idAndFullUrl&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;requestMethod&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'Consent'</span> <i>&quot;requestUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;entryRequest&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>r.subject = <span style="color: maroon">s</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetConsentFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">r</span><span style="color: navy"> : </span>Consent, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  r.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/Consent/'</span><span style="color: navy">, </span><span style="color: maroon">id</span><span style="color: navy">)</span> <i>&quot;assignFullUrl&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">── Provenance and tenancy ───────────────────────────────────────────────────</span>
<span style="color: navy">// </span><span style="color: green">Two tags on everything this map creates. The first says which questionnaire</span>
<span style="color: navy">// </span><span style="color: green">produced it, so a form that reopens mid-admission recalls its own earlier</span>
<span style="color: navy">// </span><span style="color: green">entries and not another form's. The second copies the tenant tags off the</span>
<span style="color: navy">// </span><span style="color: green">response, because nothing else on the path puts them there.</span>
<span style="color: navy">// </span><span style="color: green">The code is the form's document type, not the questionnaire's id: every</span>
<span style="color: navy">// </span><span style="color: green">environment mints its own ids, and there is only one set of maps, so an id</span>
<span style="color: navy">// </span><span style="color: green">here would tie the tag to whichever environment stamped it.</span>
<span style="color: navy">// </span><span style="color: green">── Provenance and tenancy ───────────────────────────────────────────────────</span>
<b>group </b>SetResponseProvenance<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">r</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>r.meta<b> as </b><span style="color: maroon">m</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>m.tag<b> as </b><span style="color: maroon">t</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>t.system = <span style="color: blue">'http://slade360edi.com/questionnaire-provenance'</span> <i>&quot;provenanceSystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>t.code = <span style="color: blue">'paediatric-admission-record'</span> <i>&quot;provenanceCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>t.display = <span style="color: blue">'Paediatric admission record'</span> <i>&quot;provenanceDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;provenanceTag&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;provenanceMeta&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Every tag the response carries, onto the resource. `meta` is 0..1, so this</span>
  <span style="color: navy">// </span><span style="color: green">lands on the same meta the rule above created rather than a second one.</span>
  qr.meta<b> as </b><span style="color: maroon">qm</span><b> then</b><span style="color: navy"> {
</span>    qm.tag<b> as </b><span style="color: maroon">qt</span><span style="color: navy"><b> -&gt; </b></span> r.meta<b> as </b><span style="color: maroon">m</span><span style="color: navy">, </span> m.tag = <span style="color: maroon">qt</span> <i>&quot;copyTag&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;tenantTags&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url
       value="https://fhir.slade360.co.ke/fhir/StructureMap/ExtractPaediatricAdmissionRecord"/>
  <version value="0.1.0"/>
  <name value="ExtractPaediatricAdmissionRecord"/>
  <title value="Paediatric Admission Record Extraction"/>
  <status value="active"/>
  <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="The three-page paediatric admission record out as: the anthropometry and vital signs each as their own Observation so a growth chart can graph them; the IMCI history and the ABCD examination as two panels, because a sign only means anything as part of the set the clinician worked through; the immunisation card as one dose-count panel rather than as Immunization resources, which the sheet gives no dates for; a Condition per admission diagnosis, primary first; a ServiceRequest per investigation ordered; a CarePlan for the supportive care; and a Consent from the carer's signature at the foot of the sheet."/>
  <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/Observation"/>
    <mode value="target"/>
    <alias value="Observation"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Condition"/>
    <mode value="target"/>
    <alias value="Condition"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/ServiceRequest"/>
    <mode value="target"/>
    <alias value="ServiceRequest"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/CarePlan"/>
    <mode value="target"/>
    <alias value="CarePlan"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Consent"/>
    <mode value="target"/>
    <alias value="Consent"/>
  </structure>
  <group>
    <name value="ExtractPaediatricAdmissionRecord"/>
    <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="anthropometryGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'anthropometry'"/>
      </source>
      <rule>
        <name value="anthro_29463_7"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'anthropometry/weight') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetVitalSignsCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="29463-7"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Body weight"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="set"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="v"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="anthro_8302_2"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'anthropometry/height') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetVitalSignsCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="8302-2"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Body height"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="set"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="v"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="anthro_56072_2"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'anthropometry/muac') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetVitalSignsCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="56072-2"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Circumference Mid upper arm - right"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="set"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="v"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="anthro_9843_4"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'anthropometry/head-circumference') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetVitalSignsCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="9843-4"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Head Occipital-frontal circumference"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="set"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="v"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="weightForHeightZ"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'anthropometry/weight-for-height-z') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetVitalSignsCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="77606-2"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Weight-for-length Per age and sex"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="quantity"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="value"/>
              <variable value="q"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Quantity"/>
              </parameter>
            </target>
            <rule>
              <name value="qValue"/>
              <source>
                <context value="v"/>
              </source>
              <target>
                <context value="q"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="qUnit"/>
              <source>
                <context value="v"/>
              </source>
              <target>
                <context value="q"/>
                <element value="unit"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="SD"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="qSystem"/>
              <source>
                <context value="v"/>
              </source>
              <target>
                <context value="q"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://unitsofmeasure.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="qCode"/>
              <source>
                <context value="v"/>
              </source>
              <target>
                <context value="q"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="1"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="── Growth measurements ─────────────────────────────────────────────────
One Observation each, all in the vital-signs category, because these are
exactly what a growth chart plots. Weight-for-height carries LOINC 77606-2
rather than a local code: the sheet calls it &quot;W/H score&quot; and means the
weight-for-length Z score for age and sex, which is what that term is."/>
    </rule>
    <rule>
      <name value="vitalSignsGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'vital-signs'"/>
      </source>
      <rule>
        <name value="vital_8310_5"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'vital-signs/temperature') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetVitalSignsCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="8310-5"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Body temperature"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="set"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="v"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="vital_9279_1"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'vital-signs/respiratory-rate') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetVitalSignsCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="9279-1"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Respiratory rate"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="set"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="v"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="vital_8867_4"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'vital-signs/pulse') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetVitalSignsCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="8867-4"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Heart rate"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="set"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="v"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="vital_59408_5"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'vital-signs/oxygen-saturation') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetVitalSignsCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="59408-5"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="Oxygen saturation in Arterial blood by Pulse oximetry"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="set"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="v"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="bloodPressureObservation"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="bp"/>
          <condition
                     value="(linkId = 'vital-signs/blood-pressure') and item.answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetVitalSignsCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="bp"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="bp"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="bp"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="bp"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="85354-9"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="bp"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="Blood pressure panel with all children optional"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="comp_8480_6"/>
          <source>
            <context value="bp"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'vital-signs/blood-pressure/systolic') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8480-6"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Systolic blood pressure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_8462_4"/>
          <source>
            <context value="bp"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'vital-signs/blood-pressure/diastolic') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8462-4"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Diastolic blood pressure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="── Vital signs ─────────────────────────────────────────────────────────"/>
    </rule>
    <rule>
      <name value="historyPanel"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition
                   value="(linkId = 'history') and item.answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetSurveyCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="g"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="10164-2"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="History of Present illness Narrative"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="codeText"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="History of the presenting illness"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="HistoryFeverGroup"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="fever"/>
          <condition value="linkId = 'history/fever'"/>
        </source>
        <rule>
          <name value="comp_sign_fever"/>
          <source>
            <context value="fever"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'history/fever/present') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-fever"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Fever"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_sign_days_of_fever"/>
          <source>
            <context value="fever"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'history/fever/duration') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-days-of-fever"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Days of fever"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="HistoryCoughGroup"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="cough"/>
          <condition value="linkId = 'history/cough'"/>
        </source>
        <rule>
          <name value="comp_sign_cough"/>
          <source>
            <context value="cough"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'history/cough/present') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-cough"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Cough"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_sign_days_of_cough"/>
          <source>
            <context value="cough"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'history/cough/duration') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-days-of-cough"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Days of cough"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="comp_sign_cough_for_more_than_two_weeks"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'history/cough-over-2-weeks') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="sign-cough-for-more-than-two-weeks"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Cough for more than two weeks"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name
              value="comp_sign_contact_with_tb_or_a_chronic_cough_in_the_last_12"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'history/tb-contact') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="sign-contact-with-tb-or-a-chronic-cough-in-the-last-12"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="Contact with TB or a chronic cough in the last 12 months"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_sign_difficulty_breathing"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'history/difficulty-breathing') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="sign-difficulty-breathing"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Difficulty breathing"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="HistoryDiarrhoeaGroup"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="diarrhoea"/>
          <condition value="linkId = 'history/diarrhoea'"/>
        </source>
        <rule>
          <name value="comp_sign_diarrhoea"/>
          <source>
            <context value="diarrhoea"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'history/diarrhoea/present') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-diarrhoea"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Diarrhoea"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_sign_days_of_diarrhoea"/>
          <source>
            <context value="diarrhoea"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'history/diarrhoea/duration') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-days-of-diarrhoea"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Days of diarrhoea"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="comp_sign_diarrhoea_for_more_than_14_days"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'history/diarrhoea-over-14-days') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="sign-diarrhoea-for-more-than-14-days"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Diarrhoea for more than 14 days"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_sign_bloody_diarrhoea"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'history/diarrhoea-bloody') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="sign-bloody-diarrhoea"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Bloody diarrhoea"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="HistoryVomitingGroup"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="vomiting"/>
          <condition value="linkId = 'history/vomiting'"/>
        </source>
        <rule>
          <name value="comp_sign_vomiting"/>
          <source>
            <context value="vomiting"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'history/vomiting/present') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-vomiting"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Vomiting"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_sign_vomiting_episodes_in_the_last_24_hours"/>
          <source>
            <context value="vomiting"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'history/vomiting/episodes-24h') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="sign-vomiting-episodes-in-the-last-24-hours"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="Vomiting episodes in the last 24 hours"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="comp_sign_vomits_everything"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'history/vomits-everything') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="sign-vomits-everything"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Vomits everything"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_sign_difficulty_feeding"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'history/difficulty-feeding') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="sign-difficulty-feeding"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Difficulty feeding"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="HistoryConvulsionsGroup"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="convulsions"/>
          <condition value="linkId = 'history/convulsions'"/>
        </source>
        <rule>
          <name value="comp_sign_convulsions_during_this_illness"/>
          <source>
            <context value="convulsions"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'history/convulsions/present') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="sign-convulsions-during-this-illness"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Convulsions during this illness"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_sign_number_of_convulsions_this_illness"/>
          <source>
            <context value="convulsions"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'history/convulsions/count') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="sign-number-of-convulsions-this-illness"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Number of convulsions this illness"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="comp_sign_partial_or_focal_fits"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'history/partial-focal-fits') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="sign-partial-or-focal-fits"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Partial or focal fits"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_sign_length_of_illness_in_days"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'history/length-of-illness') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="sign-length-of-illness-in-days"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Length of illness in days"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="note"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'history/additional'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="── The IMCI history, as one panel ──────────────────────────────────────
Coded to LOINC 10164-2, history of present illness. The signs are coded
components; the days and counts beside them are quantity components under
their own concept codes, so &quot;cough for four days&quot; survives as two facts
that belong together rather than as a sentence."/>
    </rule>
    <rule>
      <name value="examinationPanel"/>
      <source>
        <context value="qr"/>
        <condition
                   value="item.where(linkId = 'general-examination').item.answer.value.exists() or item.where(linkId = 'abcd').item.item.answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetExamCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="8716-3"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Vital signs note"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="codeText"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Examination on admission"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'general-examination'"/>
        </source>
        <rule>
          <name value="comp_sign_oral_thrush"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'general-examination/oral-thrush') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-oral-thrush"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Oral thrush"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp2"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'general-examination'"/>
        </source>
        <rule>
          <name value="comp_sign_lymph_node_greater_than_1_cm"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'general-examination/lymph-node-over-1cm') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-lymph-node-greater-than-1-cm"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Lymph node greater than 1 cm"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp3"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'general-examination'"/>
        </source>
        <rule>
          <name value="comp_sign_finger_clubbing"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'general-examination/finger-clubbing') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-finger-clubbing"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Finger clubbing"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp4"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="exam_sub"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/airway'"/>
          </source>
          <rule>
            <name value="comp_sign_stridor"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/airway/stridor') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-stridor"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Stridor"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp5"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="exam_sub2"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/breathing'"/>
          </source>
          <rule>
            <name value="comp_sign_central_cyanosis"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/breathing/central-cyanosis') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-central-cyanosis"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Central cyanosis"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp6"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="exam_sub3"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/breathing'"/>
          </source>
          <rule>
            <name value="comp_sign_chest_indrawing"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/breathing/indrawing') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-chest-indrawing"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Chest indrawing"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp7"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="exam_sub4"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/breathing'"/>
          </source>
          <rule>
            <name value="comp_sign_grunting"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/breathing/grunting') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-grunting"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Grunting"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp8"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="exam_sub5"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/breathing'"/>
          </source>
          <rule>
            <name value="comp_sign_acidotic_breathing"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/breathing/acidotic-breathing') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-acidotic-breathing"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Acidotic breathing"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp9"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="exam_sub6"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/breathing'"/>
          </source>
          <rule>
            <name value="comp_sign_wheeze"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/breathing/wheeze') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-wheeze"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Wheeze"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp10"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="exam_sub7"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/breathing'"/>
          </source>
          <rule>
            <name value="comp_sign_crackles"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/breathing/crackles') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-crackles"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Crackles"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp11"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="exam_sub8"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/circulation'"/>
          </source>
          <rule>
            <name value="comp_sign_sunken_eyes"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/circulation/sunken-eyes') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-sunken-eyes"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Sunken eyes"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp12"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="exam_sub9"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/disability'"/>
          </source>
          <rule>
            <name value="comp_sign_stiff_neck"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/disability/stiff-neck') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-stiff-neck"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Stiff neck"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp13"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="exam_sub10"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/disability'"/>
          </source>
          <rule>
            <name value="comp_sign_bulging_fontanelle"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/disability/bulging-fontanelle') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-bulging-fontanelle"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Bulging fontanelle"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp14"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'infant-under-2-months'"/>
        </source>
        <rule>
          <name value="comp_sign_irritable"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'infant-under-2-months/irritable') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-irritable"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Irritable"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp15"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'infant-under-2-months'"/>
        </source>
        <rule>
          <name value="comp_sign_reduced_movement_or_tone"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'infant-under-2-months/reduced-movement-or-tone') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-reduced-movement-or-tone"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Reduced movement or tone"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="exam_grp16"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'system-examination'"/>
        </source>
        <rule>
          <name value="comp_sign_wrist_or_rib_signs_of_rickets"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'system-examination/rickets-signs') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="sign-wrist-or-rib-signs-of-rickets"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Wrist or rib signs of rickets"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="graded_grp"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'general-examination'"/>
        </source>
        <rule>
          <name value="comp_grade_jaundice_grade"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'general-examination/jaundice') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="grade-jaundice-grade"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Jaundice grade"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="graded_grp2"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'general-examination'"/>
        </source>
        <rule>
          <name value="comp_oedema_distribution"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'general-examination/oedema') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="oedema-distribution"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Oedema distribution"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="graded_grp3"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="graded_sub"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/circulation'"/>
          </source>
          <rule>
            <name value="comp_grade_pallor_or_anaemia_grade"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/circulation/pallor') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="grade-pallor-or-anaemia-grade"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Pallor or anaemia grade"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="graded_grp4"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="graded_sub2"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/circulation'"/>
          </source>
          <rule>
            <name value="comp_sign_peripheral_pulse"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/circulation/peripheral-pulse') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-peripheral-pulse"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Peripheral pulse"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="graded_grp5"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="graded_sub3"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/circulation'"/>
          </source>
          <rule>
            <name value="comp_sign_skin_warm_as_far_as"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/circulation/skin-warm-at') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="sign-skin-warm-as-far-as"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Skin warm as far as"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="graded_grp6"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="graded_sub4"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/disability'"/>
          </source>
          <rule>
            <name value="comp_triage_avpu_conscious_level"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/disability/avpu') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="triage-avpu-conscious-level"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="AVPU conscious level"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="graded_grp7"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="graded_sub5"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/disability'"/>
          </source>
          <rule>
            <name value="comp_can_drink_or_breastfeed"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/disability/can-drink-or-breastfeed') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="can-drink-or-breastfeed"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Able to drink or breastfeed"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentCodedValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="graded_grp8"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'newborn'"/>
        </source>
        <rule>
          <name value="comp_umbilicus_appearance"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'newborn/umbilicus') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="umbilicus-appearance"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Umbilical stump appearance"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="abcdTimed"/>
        <source>
          <context value="qr"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'abcd'"/>
        </source>
        <rule>
          <name value="circulationTimed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="g2"/>
            <condition value="linkId = 'abcd/circulation'"/>
          </source>
          <rule>
            <name value="comp_44971_0"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/circulation/capillary-refill') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="44971-0"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Capillary refill [Time]"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
          <rule>
            <name value="comp_skin_pinch_time"/>
            <source>
              <context value="g2"/>
              <element value="item"/>
              <variable value="it"/>
              <condition
                         value="(linkId = 'abcd/circulation/skin-pinch') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="skin-pinch-time"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Skin pinch return time"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
        </rule>
        <documentation
                       value="The two timed perfusion and turgor readings. Quantities, and both are
kept because they measure different things: capillary refill measures
perfusion at the nail bed and skin pinch measures turgor on the abdomen."/>
      </rule>
      <documentation
                     value="── The ABCD examination, as one panel ──────────────────────────────────
Coded to LOINC 8716-3, vital signs note, which is the nearest LOINC term
for &quot;what the clinician found on looking at the child&quot;. The graded findings
— jaundice, oedema, pallor, AVPU — are coded components; the timed ones —
capillary refill, skin pinch — are quantities under their LOINC and local
codes."/>
    </rule>
    <rule>
      <name value="immunisationPanel"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition
                   value="(linkId = 'immunisation') and item.answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetSurveyCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="g"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="11369-6"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="History of Immunization note"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="codeText"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Immunisation doses given, from the card"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="comp_bcg"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'immunisation/bcg') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="bcg"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="BCG"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_bopv"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'immunisation/opv') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="bopv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Bivalent oral poliovirus vaccine"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_ipv"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'immunisation/ipv') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="ipv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Inactivated poliovirus vaccine"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_penta"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'immunisation/penta') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="penta"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="DTP-HepB-Hib (pentavalent) vaccine"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_pcv10"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'immunisation/pneumo') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="pcv10"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="Pneumococcal conjugate vaccine (PCV10)"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_rota"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'immunisation/rota') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="rota"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Rotavirus vaccine"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_mr"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'immunisation/measles') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/kepi-antigen"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="mr"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Measles-rubella vaccine"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <documentation
                     value="── Immunisation, as a dose-count panel ─────────────────────────────────
Not Immunization resources. The sheet records how many doses of each
antigen the child has had, off a card, with no dates, no batch numbers and
no vaccine codes. An Immunization built from a count alone would claim a
date it does not have -- and seven of them would claim seven."/>
    </rule>
    <rule>
      <name value="birthHistoryGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'birth-history'"/>
      </source>
      <rule>
        <name value="pmtctObservation"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'birth-history/maternal-pmtct-status') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetSurveyCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="maternal-pmtct-status"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Maternal PMTCT status"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="pmtctValue"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="codedValue"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="cv"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="value"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <rule>
              <name value="valueCoding"/>
              <source>
                <context value="cv"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="cv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="valueText"/>
              <source>
                <context value="cv"/>
                <element value="display"/>
                <variable value="d"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="d"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="birthHistoryNarrative"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'birth-history/narrative') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetSurveyCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="11884-4"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Gestational age Estimated"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Birth history"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="── Maternal PMTCT status ───────────────────────────────────────────────
Its own Observation and deliberately not a component of the history panel.
It is a fact about the mother that governs the child's management for
weeks, and it has to be findable without reading a panel."/>
    </rule>
    <rule>
      <name value="narrative_presenting_complaints"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="it"/>
        <condition
                   value="(linkId = 'presenting-complaints') and answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetSurveyCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="it"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="10154-3"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Chief complaint Narrative - Reported"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="answer"/>
        <source>
          <context value="it"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="a"/>
        </source>
        <rule>
          <name value="text"/>
          <source>
            <context value="a"/>
            <element value="value"/>
            <variable value="txt"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="note"/>
            <variable value="n"/>
          </target>
          <target>
            <context value="n"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="txt"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <documentation
                     value="── The narrative sections ──────────────────────────────────────────────
One Observation each, carrying the text in `note` rather than in `value`.
Observation.value has no string choice in R5, and coercing a paragraph into
valueString where the spec offers none is how a resource stops validating."/>
    </rule>
    <rule>
      <name value="narrative_growth_and_development"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="it"/>
        <condition
                   value="(linkId = 'growth-and-development') and answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetSurveyCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="it"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="feeding-growth-and-development"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Growth and development"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="answer"/>
        <source>
          <context value="it"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="a"/>
        </source>
        <rule>
          <name value="text"/>
          <source>
            <context value="a"/>
            <element value="value"/>
            <variable value="txt"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="note"/>
            <variable value="n"/>
          </target>
          <target>
            <context value="n"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="txt"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="narrative_nutritional_history"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="it"/>
        <condition
                   value="(linkId = 'nutritional-history') and answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetSurveyCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="it"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="feeding-nutritional-history"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Nutritional history"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="answer"/>
        <source>
          <context value="it"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="a"/>
        </source>
        <rule>
          <name value="text"/>
          <source>
            <context value="a"/>
            <element value="value"/>
            <variable value="txt"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="note"/>
            <variable value="n"/>
          </target>
          <target>
            <context value="n"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="txt"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="narrative_treatment_history"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="it"/>
        <condition
                   value="(linkId = 'treatment-history') and answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetSurveyCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="it"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="10160-0"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="History of Medication use Narrative"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="answer"/>
        <source>
          <context value="it"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="a"/>
        </source>
        <rule>
          <name value="text"/>
          <source>
            <context value="a"/>
            <element value="value"/>
            <variable value="txt"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="note"/>
            <variable value="n"/>
          </target>
          <target>
            <context value="n"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="txt"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="narrative_summary_of_problems"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="it"/>
        <condition
                   value="(linkId = 'summary-of-problems') and answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetSurveyCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="it"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="11450-4"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Problem list - Reported"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="answer"/>
        <source>
          <context value="it"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="a"/>
        </source>
        <rule>
          <name value="text"/>
          <source>
            <context value="a"/>
            <element value="value"/>
            <variable value="txt"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="note"/>
            <variable value="n"/>
          </target>
          <target>
            <context value="n"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="txt"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="reviewOfSystemsObservation"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition
                   value="(linkId = 'review-of-systems') and item.answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetSurveyCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="g"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="10187-3"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Review of systems Narrative - Reported"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note2"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'review-of-systems/respiratory'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note3"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'review-of-systems/cardiovascular'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note4"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="linkId = 'review-of-systems/gastrointestinal-genitourinary'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note5"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'review-of-systems/cns'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="Review of systems, as one Observation with a note per system. Four
Observations of free text would be four resources nobody queries; one, with
the four sections as notes, is what a clinician actually reads."/>
    </rule>
    <rule>
      <name value="systemExaminationObservation"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition
                   value="(linkId = 'system-examination') and item.answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetExamCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="g"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="29545-1"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Physical findings note"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note6"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'system-examination/ent'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note7"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'system-examination/neurological'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note8"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'system-examination/chest'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note9"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'system-examination/abdomen'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note10"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'system-examination/cardiovascular'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note11"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'system-examination/bones-and-joints'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="Examination by system, same shape and same reason."/>
    </rule>
    <rule>
      <name value="admissionDiagnoses"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'admission-diagnoses'"/>
      </source>
      <rule>
        <name value="primaryCondition"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'admission-diagnoses/primary-text') and answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="cond"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Condition"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="cond"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildConditionBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="cond"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="clinicalStatus"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cond"/>
            <element value="clinicalStatus"/>
            <variable value="cs"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cs"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="http://terminology.hl7.org/CodeSystem/condition-clinical"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="active"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Active"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="verificationStatus"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cond"/>
            <element value="verificationStatus"/>
            <variable value="vs"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="vs"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="http://terminology.hl7.org/CodeSystem/condition-ver-status"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="provisional"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Provisional"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cond"/>
            <element value="category"/>
            <variable value="cat"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cat"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="http://terminology.hl7.org/CodeSystem/condition-category"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="problem-list-item"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Problem List Item"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="diagnosisText"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="cond"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="primaryNote"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cond"/>
            <element value="note"/>
            <variable value="n"/>
          </target>
          <target>
            <context value="n"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Primary admission diagnosis"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="recordedDate"/>
          <source>
            <context value="qr"/>
            <element value="authored"/>
            <variable value="t"/>
          </source>
          <target>
            <context value="cond"/>
            <element value="recordedDate"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="t"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="encounter"/>
          <source>
            <context value="qr"/>
            <element value="encounter"/>
            <variable value="e"/>
          </source>
          <target>
            <context value="cond"/>
            <element value="encounter"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="e"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="severityRule"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="sev"/>
            <condition
                       value="linkId = 'admission-diagnoses/primary-severity'"/>
          </source>
          <rule>
            <name value="answer"/>
            <source>
              <context value="sev"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="sa"/>
            </source>
            <rule>
              <name value="severityNote"/>
              <source>
                <context value="sa"/>
                <element value="value"/>
                <variable value="txt"/>
              </source>
              <target>
                <context value="cond"/>
                <element value="note"/>
                <variable value="n"/>
              </target>
              <target>
                <context value="n"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="txt"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <documentation
                         value="The severity or type line -- severe / non-severe, bloody / non-bloody,
kwashiorkor / marasmus. Condition.severity is bound to a three-point
scale that none of those fit, so it rides as a note."/>
        </rule>
        <rule>
          <name value="existingConditionRule"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="ref"/>
            <condition
                       value="(linkId = 'admission-diagnoses/primary') and answer.value.exists()"/>
          </source>
          <rule>
            <name value="answer"/>
            <source>
              <context value="ref"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="ra"/>
            </source>
            <rule>
              <name value="evidenceReference"/>
              <source>
                <context value="ra"/>
                <element value="value"/>
                <variable value="existing"/>
              </source>
              <target>
                <context value="cond"/>
                <element value="evidence"/>
                <variable value="ev"/>
              </target>
              <target>
                <context value="ev"/>
                <element value="reference"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="existing"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="secondaryDiagnoses"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="sec"/>
          <condition value="linkId = 'admission-diagnoses/secondary'"/>
        </source>
        <rule>
          <name value="secondaryCondition"/>
          <source>
            <context value="sec"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'admission-diagnoses/secondary/text') and answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="cond"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Condition"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="cond"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildConditionBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="cond"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="clinicalStatus"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cond"/>
              <element value="clinicalStatus"/>
              <variable value="cs"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cs"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/condition-clinical"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="active"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Active"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cond"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/condition-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="problem-list-item"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Problem List Item"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="diagnosisText"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="codeText"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="txt"/>
              </source>
              <target>
                <context value="cond"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <target>
                <context value="cc"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="txt"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="recordedDate"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="cond"/>
              <element value="recordedDate"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="cond"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="severityRule"/>
            <source>
              <context value="sec"/>
              <element value="item"/>
              <variable value="sv"/>
              <condition
                         value="linkId = 'admission-diagnoses/secondary/severity'"/>
            </source>
            <rule>
              <name value="answer"/>
              <source>
                <context value="sv"/>
                <element value="answer"/>
                <listMode value="first"/>
                <variable value="sa"/>
              </source>
              <rule>
                <name value="severityNote"/>
                <source>
                  <context value="sa"/>
                  <element value="value"/>
                  <variable value="txt"/>
                </source>
                <target>
                  <context value="cond"/>
                  <element value="note"/>
                  <variable value="n"/>
                </target>
                <target>
                  <context value="n"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="txt"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="── Admission diagnoses ─────────────────────────────────────────────────
A Condition per diagnosis. The primary one carries
`Condition.category = problem-list-item` and a `Condition.note` saying it is
the admitting diagnosis; the secondaries carry the same category. R5 has no
rank on Condition, so primacy is expressed by the order in the bundle and
by the note, not by a field that does not exist.
Where the clinician picked an existing Condition off the problem list, the
map does not create a second one -- it would fork the problem list. The
reference travels on the primary Condition's `evidence` instead, so the
link is recorded without duplicating the diagnosis."/>
    </rule>
    <rule>
      <name value="investigationsGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'investigations'"/>
      </source>
      <rule>
        <name value="order_malaria"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'investigations/malaria') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="createOrder"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="a"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeFromAnswer"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="cv"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="cv"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="cv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="text"/>
              <source>
                <context value="cv"/>
                <element value="display"/>
                <variable value="d"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="d"/>
                </parameter>
              </target>
            </rule>
            <documentation
                           value="Malaria is the one ordered from a pick list, so the answer's own
coding travels and code.text is the label beside it."/>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="provenanceNote"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Ordered on the paediatric admission record: Malaria test"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="order_haematology"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'investigations/haematology') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="createOrder"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="a"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="provenanceNote"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Ordered on the paediatric admission record: Haematology"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="order_microbiology"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'investigations/microbiology') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="createOrder"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="a"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="provenanceNote"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Ordered on the paediatric admission record: Microbiology"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="order_x_ray"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'investigations/x-ray') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="createOrder"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="a"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="363679005"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Imaging"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="provenanceNote"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Ordered on the paediatric admission record: X-ray"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="order_tb_test"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'investigations/tb-test') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="createOrder"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="a"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="provenanceNote"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Ordered on the paediatric admission record: TB test"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="order_glucose"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'investigations/glucose') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="createOrder"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="a"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="provenanceNote"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Ordered on the paediatric admission record: Glucose"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="order_chemistry"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'investigations/chemistry') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="createOrder"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="a"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="provenanceNote"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Ordered on the paediatric admission record: Chemistry"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="order_hiv"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'investigations/hiv') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="createOrder"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="a"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="provenanceNote"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Ordered on the paediatric admission record: HIV test"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="order_urine"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'investigations/urine') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="createOrder"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="a"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="provenanceNote"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Ordered on the paediatric admission record: Urine"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="order_other"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'investigations/other') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="createOrder"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="a"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="a"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="provenanceNote"/>
            <source>
              <context value="a"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Ordered on the paediatric admission record: Other investigation"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="── Investigations ordered ──────────────────────────────────────────────
A ServiceRequest per line. `intent = 'order'` and `status = 'active'`,
because the sheet has no separate authorisation step: a clinician who wrote
it has ordered it. `code.text` carries what they wrote -- the hospital's
test catalogue is not coded, and inventing a LOINC order code from
&quot;Na+K, U&amp;C&quot; would be a guess with a clinical consequence."/>
    </rule>
    <rule>
      <name value="supportiveCarePlan"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition
                   value="(linkId = 'supportive-care') and item.answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="plan"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CarePlan"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="plan"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildCarePlanBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="plan"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="status"/>
        <source>
          <context value="g"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="status"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="active"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="intent"/>
        <source>
          <context value="g"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="intent"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="plan"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="title"/>
        <source>
          <context value="g"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="title"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Supportive care on admission"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="created"/>
        <source>
          <context value="qr"/>
          <element value="authored"/>
          <variable value="t"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="created"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="t"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="encounter"/>
        <source>
          <context value="qr"/>
          <element value="encounter"/>
          <variable value="e"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="encounter"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="e"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="custodian"/>
        <source>
          <context value="qr"/>
          <element value="source"/>
          <variable value="src"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="custodian"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="src"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="g"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="category"/>
          <variable value="cat"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="cat"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="https://fhir.slade360.co.ke/fhir/CodeSystem/document-type-codesystem"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="paediatric-admission-record"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Paediatric admission record"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="care_keep_warm"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'supportive-care/keep-warm') and (answer.value.ofType(Coding).code = 'Y')"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="activity"/>
          <variable value="act"/>
        </target>
        <target>
          <context value="act"/>
          <element value="plannedActivityReference"/>
          <variable value="ref"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <rule>
          <name value="activityDisplay"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="ref"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Keep warm"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="care_oxygen"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'supportive-care/oxygen') and (answer.value.ofType(Coding).code = 'Y')"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="activity"/>
          <variable value="act"/>
        </target>
        <target>
          <context value="act"/>
          <element value="plannedActivityReference"/>
          <variable value="ref"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <rule>
          <name value="activityDisplay"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="ref"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Oxygen"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="care_iv_or_oral_fluids"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'supportive-care/iv-or-oral-fluids') and (answer.value.ofType(Coding).code = 'Y')"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="activity"/>
          <variable value="act"/>
        </target>
        <target>
          <context value="act"/>
          <element value="plannedActivityReference"/>
          <variable value="ref"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <rule>
          <name value="activityDisplay"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="ref"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="IV or oral fluids plan"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="care_blood_transfusion"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'supportive-care/blood-transfusion') and (answer.value.ofType(Coding).code = 'Y')"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="activity"/>
          <variable value="act"/>
        </target>
        <target>
          <context value="act"/>
          <element value="plannedActivityReference"/>
          <variable value="ref"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <rule>
          <name value="activityDisplay"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="ref"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Blood transfusion"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="care_vitamin_a"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'supportive-care/vitamin-a') and (answer.value.ofType(Coding).code = 'Y')"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="activity"/>
          <variable value="act"/>
        </target>
        <target>
          <context value="act"/>
          <element value="plannedActivityReference"/>
          <variable value="ref"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <rule>
          <name value="activityDisplay"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="ref"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Vitamin A"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="care_nutrition_plan"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'supportive-care/nutrition-plan') and (answer.value.ofType(Coding).code = 'Y')"/>
        </source>
        <target>
          <context value="plan"/>
          <element value="activity"/>
          <variable value="act"/>
        </target>
        <target>
          <context value="act"/>
          <element value="plannedActivityReference"/>
          <variable value="ref"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <rule>
          <name value="activityDisplay"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="ref"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Nutrition or feeds plan"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="reviewStatusRule"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'supportive-care/review-status'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="display"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="cv"/>
            </source>
            <rule>
              <name value="reviewStatusNote"/>
              <source>
                <context value="cv"/>
                <element value="display"/>
                <variable value="d"/>
              </source>
              <target>
                <context value="plan"/>
                <element value="note"/>
                <variable value="n"/>
              </target>
              <target>
                <context value="n"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="d"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <documentation
                       value="Review status. Not an activity -- it says how closely to watch the child
rather than what to do to them -- so it is a note on the plan."/>
      </rule>
      <documentation
                     value="── Supportive care ─────────────────────────────────────────────────────
One CarePlan with an activity per tick. A CarePlan rather than seven
Observations, because &quot;keep warm&quot; is something to be done, not something
that was found -- and a plan is what a nurse picks up at handover."/>
    </rule>
    <rule>
      <name value="consentGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'sign-off'"/>
      </source>
      <rule>
        <name value="createConsent"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'sign-off/consent-for-admission') and (answer.value = true)"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="consent"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Consent"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="consent"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildConsentBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="consent"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="status"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="consent"/>
            <element value="status"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="active"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="consent"/>
            <element value="category"/>
            <variable value="cat"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cat"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="http://terminology.hl7.org/CodeSystem/consentcategorycodes"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="acd"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Advance Directive"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="categoryText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cat"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Consent for admission and relevant management"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="decision"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="consent"/>
            <element value="decision"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="permit"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="consentPeriodStart"/>
          <source>
            <context value="qr"/>
            <element value="authored"/>
            <variable value="t"/>
          </source>
          <target>
            <context value="consent"/>
            <element value="period"/>
            <variable value="per"/>
          </target>
          <target>
            <context value="per"/>
            <element value="start"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="t"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="grantee"/>
          <source>
            <context value="qr"/>
            <element value="source"/>
            <variable value="src"/>
          </source>
          <target>
            <context value="consent"/>
            <element value="grantee"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="src"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="provenanceNote"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="consent"/>
            <element value="provision"/>
            <variable value="prov"/>
          </target>
          <target>
            <context value="prov"/>
            <element value="code"/>
            <variable value="pc"/>
          </target>
          <target>
            <context value="pc"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="Taken on the paediatric admission record. The parent or guardian signed the sheet; this records that the signature was obtained, not the signature itself."/>
            </parameter>
          </target>
        </rule>
      </rule>
      <documentation
                     value="── Consent for admission ───────────────────────────────────────────────
A Consent, from the carer's signature at the foot of the sheet. Only when
the box was actually ticked: a Consent generated from an unanswered
question is a consent nobody gave."/>
    </rule>
  </group>
  <group>
    <name value="BuildObsBase"/>
    <documentation
                   value="─────────────────────────────────────────────────────────────────────────────
Shared scaffolding. Repeated in each map rather than imported: the transform
engine resolves `imports` against whatever StructureMaps happen to be on the
server, and a form that stops extracting because a shared map was not
uploaded is a worse failure than a duplicated group.
Two notes on what the publisher's StructureMap validator says about this file.
Source parameters below are left untyped on purpose. Writing `: Element` makes
the validator compare QuestionnaireResponse.item against the literal 'Element'
and report them as incompatible with each other, which is noise, not a finding.
`evaluate(context, expression)` is flagged as &quot;takes 1 parameter but 2 were
found&quot;. Leave it. The FML parser in the same jar refuses the one-argument form
outright -- it wants a parameter, a comma, then the FHIRPath -- so the
publisher is objecting to what its own compiler emits. Two arguments is the
only form that compiles, and it is what the R5 transform engine executes.
─────────────────────────────────────────────────────────────────────────────"/>
    <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="responseProvenance"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
      </target>
      <dependent>
        <name value="SetResponseProvenance"/>
        <parameter>
          <valueId value="qr"/>
        </parameter>
        <parameter>
          <valueId value="obs"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="idAndFullUrl"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
      <dependent>
        <name value="SetObservationFullUrl"/>
        <parameter>
          <valueId value="obs"/>
        </parameter>
        <parameter>
          <valueId value="entry"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="entryRequest"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="request"/>
        <variable value="request"/>
      </target>
      <rule>
        <name value="requestMethod"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="requestUrl"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="status"/>
      <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="subject"/>
      <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="encounter"/>
      <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="effective"/>
      <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="performerFromSource"/>
      <source>
        <context value="qr"/>
        <element value="source"/>
        <variable value="src"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="performer"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="src"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="performerFallback"/>
      <source>
        <context value="qr"/>
        <condition value="source.exists().not()"/>
      </source>
      <rule>
        <name value="performerFromAuthor"/>
        <source>
          <context value="qr"/>
          <element value="author"/>
          <variable value="a"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="performer"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="a"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="linkQuestionnaireResponse"/>
      <source>
        <context value="qr"/>
        <element value="id"/>
        <variable value="qid"/>
        <condition value="$this.hasValue()"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="derivedFrom"/>
        <variable value="ref"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="ref"/>
        <element value="reference"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="qid"/>
        </parameter>
      </target>
      <documentation
                     value="A stored response's id already reads &quot;QuestionnaireResponse/&lt;id&gt;&quot;, so it is
a relative reference as it stands. The hasValue() guard is what stops an
unsaved response -- one posted straight to $extract rather than saved first
-- from writing &quot;QuestionnaireResponse/null&quot; into the record."/>
    </rule>
  </group>
  <group>
    <name value="SetObservationFullUrl"/>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="assignFullUrl"/>
      <source>
        <context value="obs"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://fhir.slade360.co.ke/fhir/Observation/"/>
        </parameter>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SetComponentCodedValue"/>
    <documentation
                   value="The two answer shapes a component can carry. Both read the answer through the
untyped `.value` accessor: reading `valueCoding` or `valueQuantity` by its
typed property name fails at transform time on HAPI R5 with &quot;Attempt to read
invalid property ... on QuestionnaireResponse.item.answer&quot;."/>
    <input>
      <name value="it"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="comp"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="componentAnswer"/>
      <source>
        <context value="it"/>
        <element value="answer"/>
        <listMode value="first"/>
        <variable value="a"/>
      </source>
      <rule>
        <name value="codedValue"/>
        <source>
          <context value="a"/>
          <element value="value"/>
          <variable value="cv"/>
        </source>
        <target>
          <context value="comp"/>
          <element value="value"/>
          <variable value="cc"/>
          <transform value="create"/>
          <parameter>
            <valueString value="CodeableConcept"/>
          </parameter>
        </target>
        <rule>
          <name value="valueCoding"/>
          <source>
            <context value="cv"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="cv"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="valueText"/>
          <source>
            <context value="cv"/>
            <element value="display"/>
            <variable value="d"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="d"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetComponentValue"/>
    <input>
      <name value="it"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="comp"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="componentAnswer"/>
      <source>
        <context value="it"/>
        <element value="answer"/>
        <listMode value="first"/>
        <variable value="a"/>
      </source>
      <rule>
        <name value="plainValue"/>
        <source>
          <context value="a"/>
          <element value="value"/>
          <variable value="v"/>
        </source>
        <target>
          <context value="comp"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="v"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetSurveyCategory"/>
    <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="category"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="categoryCoding"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="categorySystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="survey"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Survey"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetVitalSignsCategory"/>
    <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="category"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="categoryCoding"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="categorySystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="vital-signs"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Vital Signs"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetExamCategory"/>
    <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="category"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="categoryCoding"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="categorySystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="exam"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Exam"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="BuildConditionBase"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="r"/>
      <type value="Condition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="responseProvenance"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
      </target>
      <dependent>
        <name value="SetResponseProvenance"/>
        <parameter>
          <valueId value="qr"/>
        </parameter>
        <parameter>
          <valueId value="r"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="idAndFullUrl"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
      <dependent>
        <name value="SetConditionFullUrl"/>
        <parameter>
          <valueId value="r"/>
        </parameter>
        <parameter>
          <valueId value="entry"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="entryRequest"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="request"/>
        <variable value="request"/>
      </target>
      <rule>
        <name value="requestMethod"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="requestUrl"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Condition"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="r"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SetConditionFullUrl"/>
    <input>
      <name value="r"/>
      <type value="Condition"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="assignFullUrl"/>
      <source>
        <context value="r"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://fhir.slade360.co.ke/fhir/Condition/"/>
        </parameter>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="BuildServiceRequestBase"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="r"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="responseProvenance"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
      </target>
      <dependent>
        <name value="SetResponseProvenance"/>
        <parameter>
          <valueId value="qr"/>
        </parameter>
        <parameter>
          <valueId value="r"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="idAndFullUrl"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
      <dependent>
        <name value="SetServiceRequestFullUrl"/>
        <parameter>
          <valueId value="r"/>
        </parameter>
        <parameter>
          <valueId value="entry"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="entryRequest"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="request"/>
        <variable value="request"/>
      </target>
      <rule>
        <name value="requestMethod"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="requestUrl"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="ServiceRequest"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="r"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SetServiceRequestFullUrl"/>
    <input>
      <name value="r"/>
      <type value="ServiceRequest"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="assignFullUrl"/>
      <source>
        <context value="r"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString
                       value="https://fhir.slade360.co.ke/fhir/ServiceRequest/"/>
        </parameter>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="BuildCarePlanBase"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="r"/>
      <type value="CarePlan"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="responseProvenance"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
      </target>
      <dependent>
        <name value="SetResponseProvenance"/>
        <parameter>
          <valueId value="qr"/>
        </parameter>
        <parameter>
          <valueId value="r"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="idAndFullUrl"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
      <dependent>
        <name value="SetCarePlanFullUrl"/>
        <parameter>
          <valueId value="r"/>
        </parameter>
        <parameter>
          <valueId value="entry"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="entryRequest"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="request"/>
        <variable value="request"/>
      </target>
      <rule>
        <name value="requestMethod"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="requestUrl"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="CarePlan"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="r"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SetCarePlanFullUrl"/>
    <input>
      <name value="r"/>
      <type value="CarePlan"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="assignFullUrl"/>
      <source>
        <context value="r"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://fhir.slade360.co.ke/fhir/CarePlan/"/>
        </parameter>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="BuildConsentBase"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="r"/>
      <type value="Consent"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="responseProvenance"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
      </target>
      <dependent>
        <name value="SetResponseProvenance"/>
        <parameter>
          <valueId value="qr"/>
        </parameter>
        <parameter>
          <valueId value="r"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="idAndFullUrl"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
      <dependent>
        <name value="SetConsentFullUrl"/>
        <parameter>
          <valueId value="r"/>
        </parameter>
        <parameter>
          <valueId value="entry"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="entryRequest"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="request"/>
        <variable value="request"/>
      </target>
      <rule>
        <name value="requestMethod"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="requestUrl"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Consent"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="r"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SetConsentFullUrl"/>
    <input>
      <name value="r"/>
      <type value="Consent"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="assignFullUrl"/>
      <source>
        <context value="r"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://fhir.slade360.co.ke/fhir/Consent/"/>
        </parameter>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SetResponseProvenance"/>
    <documentation
                   value="── Provenance and tenancy ───────────────────────────────────────────────────
Two tags on everything this map creates. The first says which questionnaire
produced it, so a form that reopens mid-admission recalls its own earlier
entries and not another form's. The second copies the tenant tags off the
response, because nothing else on the path puts them there.
The code is the form's document type, not the questionnaire's id: every
environment mints its own ids, and there is only one set of maps, so an id
here would tie the tag to whichever environment stamped it.
── Provenance and tenancy ───────────────────────────────────────────────────"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="r"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="provenanceMeta"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
        <element value="meta"/>
        <variable value="m"/>
      </target>
      <rule>
        <name value="provenanceTag"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="m"/>
          <element value="tag"/>
          <variable value="t"/>
        </target>
        <rule>
          <name value="provenanceSystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="t"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="http://slade360edi.com/questionnaire-provenance"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="provenanceCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="t"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="paediatric-admission-record"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="provenanceDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="t"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Paediatric admission record"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="tenantTags"/>
      <source>
        <context value="qr"/>
        <element value="meta"/>
        <variable value="qm"/>
      </source>
      <rule>
        <name value="copyTag"/>
        <source>
          <context value="qm"/>
          <element value="tag"/>
          <variable value="qt"/>
        </source>
        <target>
          <context value="r"/>
          <element value="meta"/>
          <variable value="m"/>
        </target>
        <target>
          <context value="m"/>
          <element value="tag"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="qt"/>
          </parameter>
        </target>
      </rule>
      <documentation
                     value="Every tag the response carries, onto the resource. `meta` is 0..1, so this
lands on the same meta the rule above created rather than a second one."/>
    </rule>
  </group>
</StructureMap>