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

: Admission Form Extraction - XML Representation

Active as of 2026-09-14

Raw xml | Download


<StructureMap xmlns="http://hl7.org/fhir">
  <id value="ExtractAdmissionForm"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap ExtractAdmissionForm</b></p><a name="ExtractAdmissionForm"> </a><a name="hcExtractAdmissionForm"> </a><pre class="fml">
<span style="color: #cc00cc">/// <b>url</b> = </span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractAdmissionForm'</span>
<span style="color: #cc00cc">/// <b>name</b> = </span><span style="color: blue">'ExtractAdmissionForm'</span>
<span style="color: #cc00cc">/// <b>title</b> = </span><span style="color: blue">'Admission Form 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 measurements and vitals on arrival as their own Observations under their real LOINC codes; the head-to-toe nursing assessment as one panel, because it is read as a picture of the patient on arrival and no single line means much alone; the chronic illness tick list as one Condition per illness with the reported onset; and one ServiceRequest per investigation and treatment ordered. The chronic illnesses carry verificationStatus \'unconfirmed\' -- a tick against a printed word on an admission sheet is a reported history, not a diagnosis.'</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>group </b>ExtractAdmissionForm<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">── On arrival ──────────────────────────────────────────────────────────</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'on-arrival'<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 = 'on-arrival/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;measure_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 = 'on-arrival/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;measure_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 = 'on-arrival/vitals/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;measure_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 = 'on-arrival/vitals/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;measure_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 = 'on-arrival/vitals/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;measure_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 = 'on-arrival/vitals/blood-pressure') 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">'85354-9'</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">'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>
      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;bpText&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;arrivalBloodPressure&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;onArrivalGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── How the patient got here ────────────────────────────────────────────</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'admission') 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">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-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">'admission-route-how-the-patient-arrived'</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">'How the patient arrived'</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 = 'admission/admitted-from') 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">'admission-route-admitted-from'</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">'Admitted from'</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_admission_route_admitted_from&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 = 'admission/arrival-mode') 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">'admission-route-mode-of-arrival'</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">'Mode of arrival'</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_admission_route_mode_of_arrival&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 = 'admission/accompanied-by') 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">'admission-route-accompanied-by'</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">'Accompanied by'</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_admission_route_accompanied_by&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 = 'admission/unit') 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">'admission-route-unit-admitted-to'</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">'Unit admitted to'</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_admission_route_unit_admitted_to&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 = 'admission/room') 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">'admission-route-room'</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">'Room'</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_admission_route_room&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 = 'admission/bed') 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">'admission-route-bed'</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">'Bed'</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_admission_route_bed&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;admissionRoute&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 = 'presenting-symptoms') 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>
      it<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'Presenting symptoms 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>
    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;narr_10154_3&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── The head-to-toe nursing assessment ──────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">One panel. The sheet gives one ruled line per system and it is read whole:</span>
  <span style="color: navy">// </span><span style="color: green">&quot;cool, clammy extremities&quot; beside &quot;confused&quot; is the finding, and neither</span>
  <span style="color: navy">// </span><span style="color: green">line alone says it.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'assessment') 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 = 'assessment/orientation') 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">'nursing-assessment-orientation-on-admission'</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">'Orientation on admission'</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_nursing_assessment_orientation_on_admission&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 = 'assessment/pain-and-location') 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">'nursing-assessment-pain-and-its-location'</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">'Pain and its location'</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_nursing_assessment_pain_and_its_location&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 = 'assessment/skin') 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">'nursing-assessment-skin-on-admission'</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 on admission'</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_nursing_assessment_skin_on_admission&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 = 'assessment/extremities') 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">'nursing-assessment-extremities-on-admission'</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">'Extremities on admission'</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_nursing_assessment_extremities_on_admission&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 = 'assessment/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">'nursing-assessment-eyes-on-admission'</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">'Eyes on admission'</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_nursing_assessment_eyes_on_admission&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 = 'assessment/hearing') 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">'nursing-assessment-hearing-on-admission'</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">'Hearing on admission'</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_nursing_assessment_hearing_on_admission&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 = 'assessment/mouth-and-teeth') 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">'nursing-assessment-mouth-and-teeth-on-admission'</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">'Mouth and teeth on admission'</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_nursing_assessment_mouth_and_teeth_on_admission&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 = 'assessment/lungs') 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">'nursing-assessment-lungs-on-admission'</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">'Lungs on admission'</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_nursing_assessment_lungs_on_admission&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 = 'assessment/cardiovascular') 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">'nursing-assessment-cardiovascular-examination-on-admission'</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">'Cardiovascular examination on admission'</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_nursing_assessment_cardiovascular_examination_on_admission&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 = 'assessment/gastrointestinal') 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">'nursing-assessment-gastrointestinal-examination-on-admission'</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">'Gastrointestinal examination on admission'</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_nursing_assessment_gastrointestinal_examination_on_admission&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 = 'assessment/genitourinary') 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">'nursing-assessment-genitourinary-examination-on-admission'</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">'Genitourinary examination on admission'</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_nursing_assessment_genitourinary_examination_on_admission&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 = 'assessment/nurse-summary'<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;nursingAssessment&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 = 'assessment/patient-description') 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">'10164-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">'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>
      it<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'The patient\'s own description of the 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>
    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;narr_10164_2&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 = 'assessment/present-medications') 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>
      it<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'Medications the patient was taking 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>
    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;narr_10160_0&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Chronic illness history ─────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">One Condition per ticked illness, verificationStatus 'unconfirmed'. A tick</span>
  <span style="color: navy">// </span><span style="color: green">against a printed word on a nursing admission sheet is a reported history.</span>
  <span style="color: navy">// </span><span style="color: green">Recording it as confirmed would put twelve unverified diagnoses on the</span>
  <span style="color: navy">// </span><span style="color: green">problem list of every patient admitted.</span>
  qr.item<b> as </b><span style="color: maroon">pg</span><b> where </b><span style="color: navy">(</span>linkId = 'past-history'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    pg.item<b> as </b><span style="color: maroon">row</span><b> where </b><span style="color: navy">(</span>(linkId = 'past-history/chronic') and item.where(linkId = 'past-history/chronic/illness').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>
      row<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>        row<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>          row<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>
          row<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>
          row<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>
      row<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>        row<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>          row<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>
          row<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'unconfirmed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          row<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Unconfirmed'</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>
      row<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>        row<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>          row<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>
          row<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>
          row<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>
      row.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'past-history/chronic/illness'<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">cv</span><span style="color: navy"><b> -&gt; </b></span>cond.code<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>
        <span style="color: navy">}</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;illnessRule&quot;</i><span style="color: navy">;</span>
      row.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'past-history/chronic/since') and answer.value.exists()<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>cond.onset = <span style="color: maroon">txt</span> <i>&quot;onsetString&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;sinceRule&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> <i>&quot;chronicIllness&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;pastHistoryGroup&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 = 'past-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 = 'past-history/surgeries') 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">'11348-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 Past illness 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>
        it<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'Surgeries and their dates, as reported 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>
      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;narr_11348_0&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 = 'past-history/previous-admissions') 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">'nursing-assessment-previous-admissions-reported-on-admission'</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">'Previous admissions reported on admission'</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;narr_nursing_assessment_previous_admissions_reported_on_admission&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;pastHistoryNarratives&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Family and social history ───────────────────────────────────────────</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'family-and-social') 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">'10157-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 family member diseases 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 = 'family-and-social/alcohol') 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">'nursing-assessment-takes-alcohol'</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">'Takes alcohol'</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_nursing_assessment_takes_alcohol&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 = 'family-and-social/cigarettes') 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">'nursing-assessment-smokes-cigarettes'</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">'Smokes cigarettes'</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_nursing_assessment_smokes_cigarettes&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 = 'family-and-social/family') 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">'nursing-assessment-family-circumstances'</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">'Family circumstances'</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_nursing_assessment_family_circumstances&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 = 'family-and-social/education') 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">'nursing-assessment-education'</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">'Education'</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_nursing_assessment_education&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 = 'family-and-social/occupation') 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">'nursing-assessment-occupation'</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">'Occupation'</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_nursing_assessment_occupation&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 = 'family-and-social/family-medical-history'<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>
  <span style="color: navy">}</span> <i>&quot;familyAndSocial&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Ordered on arrival ──────────────────────────────────────────────────</span>
  qr.item<b> as </b><span style="color: maroon">row</span><b> where </b><span style="color: navy">(</span>(linkId = 'investigation') and item.where(linkId = 'investigation/name').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">'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>
    row<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>
    row<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>
    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.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>
    row<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>      row<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>        row<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>
        row<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>
        row<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>
    row.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'investigation/name'<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> 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>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;nameRule&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>sr<b> then </b>SetAdmissionOrderer<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> <i>&quot;orderer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;investigationOrdered&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">row</span><b> where </b><span style="color: navy">(</span>(linkId = 'treatment') and item.where(linkId = 'treatment/name').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">'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>
    row<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>
    row<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>
    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.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>
    row.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'treatment/name'<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> 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>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;nameRule&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>sr<b> then </b>SetAdmissionOrderer<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> <i>&quot;orderer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;treatmentOrdered&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetAdmissionOrderer<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">sr</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><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 = '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/physician') and answer.value.exists()<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">ref</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">ref</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;physicianRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;signOffGroup&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><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">'admission-form'</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">'Admission form'</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/ExtractAdmissionForm"/>
  <version value="0.1.0"/>
  <name value="ExtractAdmissionForm"/>
  <title value="Admission Form 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 measurements and vitals on arrival as their own Observations under their real LOINC codes; the head-to-toe nursing assessment as one panel, because it is read as a picture of the patient on arrival and no single line means much alone; the chronic illness tick list as one Condition per illness with the reported onset; and one ServiceRequest per investigation and treatment ordered. The chronic illnesses carry verificationStatus 'unconfirmed' -- a tick against a printed word on an admission sheet is a reported history, not a diagnosis."/>
  <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>
  <group>
    <name value="ExtractAdmissionForm"/>
    <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="onArrivalGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'on-arrival'"/>
      </source>
      <rule>
        <name value="measure_8302_2"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'on-arrival/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="measure_29463_7"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'on-arrival/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="measure_8310_5"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'on-arrival/vitals/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="measure_8867_4"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'on-arrival/vitals/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="measure_9279_1"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'on-arrival/vitals/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="arrivalBloodPressure"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'on-arrival/vitals/blood-pressure') 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="85354-9"/>
                </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="Blood pressure panel with all children optional"/>
                </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="bpText"/>
            <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="── On arrival ──────────────────────────────────────────────────────────"/>
    </rule>
    <rule>
      <name value="admissionRoute"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition
                   value="(linkId = 'admission') 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="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-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="admission-route-how-the-patient-arrived"/>
              </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="How the patient arrived"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="comp_admission_route_admitted_from"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'admission/admitted-from') 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="admission-route-admitted-from"/>
                </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="Admitted from"/>
                </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_admission_route_mode_of_arrival"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'admission/arrival-mode') 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="admission-route-mode-of-arrival"/>
                </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="Mode of arrival"/>
                </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_admission_route_accompanied_by"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'admission/accompanied-by') 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="admission-route-accompanied-by"/>
                </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="Accompanied by"/>
                </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_admission_route_unit_admitted_to"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'admission/unit') 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="admission-route-unit-admitted-to"/>
                </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="Unit admitted to"/>
                </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_admission_route_room"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'admission/room') 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="admission-route-room"/>
                </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="Room"/>
                </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_admission_route_bed"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'admission/bed') 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="admission-route-bed"/>
                </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="Bed"/>
                </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="── How the patient got here ────────────────────────────────────────────"/>
    </rule>
    <rule>
      <name value="narr_10154_3"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="it"/>
        <condition
                   value="(linkId = 'presenting-symptoms') 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>
          <name value="codeText"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Presenting symptoms on admission"/>
            </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>
    <rule>
      <name value="nursingAssessment"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition
                   value="(linkId = 'assessment') 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="comp_nursing_assessment_orientation_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/orientation') 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="nursing-assessment-orientation-on-admission"/>
                </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="Orientation on admission"/>
                </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_nursing_assessment_pain_and_its_location"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/pain-and-location') 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="nursing-assessment-pain-and-its-location"/>
                </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="Pain and its location"/>
                </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_nursing_assessment_skin_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/skin') 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="nursing-assessment-skin-on-admission"/>
                </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 on admission"/>
                </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_nursing_assessment_extremities_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/extremities') 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="nursing-assessment-extremities-on-admission"/>
                </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="Extremities on admission"/>
                </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_nursing_assessment_eyes_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/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="nursing-assessment-eyes-on-admission"/>
                </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="Eyes on admission"/>
                </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_nursing_assessment_hearing_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/hearing') 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="nursing-assessment-hearing-on-admission"/>
                </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="Hearing on admission"/>
                </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_nursing_assessment_mouth_and_teeth_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/mouth-and-teeth') 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="nursing-assessment-mouth-and-teeth-on-admission"/>
                </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="Mouth and teeth on admission"/>
                </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_nursing_assessment_lungs_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/lungs') 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="nursing-assessment-lungs-on-admission"/>
                </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="Lungs on admission"/>
                </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_nursing_assessment_cardiovascular_examination_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/cardiovascular') 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="nursing-assessment-cardiovascular-examination-on-admission"/>
                </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="Cardiovascular examination on admission"/>
                </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_nursing_assessment_gastrointestinal_examination_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/gastrointestinal') 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="nursing-assessment-gastrointestinal-examination-on-admission"/>
                </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="Gastrointestinal examination on admission"/>
                </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_nursing_assessment_genitourinary_examination_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'assessment/genitourinary') 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="nursing-assessment-genitourinary-examination-on-admission"/>
                </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="Genitourinary examination on admission"/>
                </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 = 'assessment/nurse-summary'"/>
        </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 head-to-toe nursing assessment ──────────────────────────────────
One panel. The sheet gives one ruled line per system and it is read whole:
&quot;cool, clammy extremities&quot; beside &quot;confused&quot; is the finding, and neither
line alone says it."/>
    </rule>
    <rule>
      <name value="narr_10164_2"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="it"/>
        <condition
                   value="(linkId = 'assessment/patient-description') 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="10164-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="History of Present illness Narrative"/>
              </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="The patient's own description of the illness"/>
            </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>
    <rule>
      <name value="narr_10160_0"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="it"/>
        <condition
                   value="(linkId = 'assessment/present-medications') 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>
          <name value="codeText"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="Medications the patient was taking on admission"/>
            </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>
    <rule>
      <name value="pastHistoryGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="pg"/>
        <condition value="linkId = 'past-history'"/>
      </source>
      <rule>
        <name value="chronicIllness"/>
        <source>
          <context value="pg"/>
          <element value="item"/>
          <variable value="row"/>
          <condition
                     value="(linkId = 'past-history/chronic') and item.where(linkId = 'past-history/chronic/illness').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="row"/>
          </source>
          <target>
            <context value="cond"/>
            <element value="clinicalStatus"/>
            <variable value="cs"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="row"/>
            </source>
            <target>
              <context value="cs"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="row"/>
              </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="row"/>
              </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="row"/>
              </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="row"/>
          </source>
          <target>
            <context value="cond"/>
            <element value="verificationStatus"/>
            <variable value="vs"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="row"/>
            </source>
            <target>
              <context value="vs"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="row"/>
              </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="row"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="unconfirmed"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="row"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Unconfirmed"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="row"/>
          </source>
          <target>
            <context value="cond"/>
            <element value="category"/>
            <variable value="cat"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="row"/>
            </source>
            <target>
              <context value="cat"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="row"/>
              </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="row"/>
              </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="row"/>
              </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="illnessRule"/>
          <source>
            <context value="row"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="linkId = 'past-history/chronic/illness'"/>
          </source>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="codeFromAnswer"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="cv"/>
              </source>
              <target>
                <context value="cond"/>
                <element value="code"/>
                <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>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="sinceRule"/>
          <source>
            <context value="row"/>
            <element value="item"/>
            <variable value="it"/>
            <condition
                       value="(linkId = 'past-history/chronic/since') and answer.value.exists()"/>
          </source>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="onsetString"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="txt"/>
              </source>
              <target>
                <context value="cond"/>
                <element value="onset"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="txt"/>
                </parameter>
              </target>
            </rule>
          </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>
      <documentation
                     value="── Chronic illness history ─────────────────────────────────────────────
One Condition per ticked illness, verificationStatus 'unconfirmed'. A tick
against a printed word on a nursing admission sheet is a reported history.
Recording it as confirmed would put twelve unverified diagnoses on the
problem list of every patient admitted."/>
    </rule>
    <rule>
      <name value="pastHistoryNarratives"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'past-history'"/>
      </source>
      <rule>
        <name value="narr_11348_0"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'past-history/surgeries') 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="11348-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 Past illness note"/>
                </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="Surgeries and their dates, as reported on admission"/>
              </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>
      <rule>
        <name
              value="narr_nursing_assessment_previous_admissions_reported_on_admission"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'past-history/previous-admissions') 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="nursing-assessment-previous-admissions-reported-on-admission"/>
                </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="Previous admissions reported on admission"/>
                </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>
    <rule>
      <name value="familyAndSocial"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition
                   value="(linkId = 'family-and-social') 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="10157-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 family member diseases note"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="comp_nursing_assessment_takes_alcohol"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'family-and-social/alcohol') 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="nursing-assessment-takes-alcohol"/>
                </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="Takes alcohol"/>
                </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_nursing_assessment_smokes_cigarettes"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'family-and-social/cigarettes') 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="nursing-assessment-smokes-cigarettes"/>
                </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="Smokes cigarettes"/>
                </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_nursing_assessment_family_circumstances"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'family-and-social/family') 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="nursing-assessment-family-circumstances"/>
                </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="Family circumstances"/>
                </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_nursing_assessment_education"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'family-and-social/education') 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="nursing-assessment-education"/>
                </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="Education"/>
                </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_nursing_assessment_occupation"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'family-and-social/occupation') 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="nursing-assessment-occupation"/>
                </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="Occupation"/>
                </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="note2"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="linkId = 'family-and-social/family-medical-history'"/>
        </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="── Family and social history ───────────────────────────────────────────"/>
    </rule>
    <rule>
      <name value="investigationOrdered"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="row"/>
        <condition
                   value="(linkId = 'investigation') and item.where(linkId = 'investigation/name').answer.value.exists()"/>
      </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="row"/>
        </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="row"/>
        </source>
        <target>
          <context value="sr"/>
          <element value="intent"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="order"/>
          </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="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="category"/>
        <source>
          <context value="row"/>
        </source>
        <target>
          <context value="sr"/>
          <element value="category"/>
          <variable value="cat"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="row"/>
          </source>
          <target>
            <context value="cat"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="row"/>
            </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="row"/>
            </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="row"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Laboratory procedure"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="nameRule"/>
        <source>
          <context value="row"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'investigation/name'"/>
        </source>
        <rule>
          <name value="answer"/>
          <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="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>
      </rule>
      <rule>
        <name value="orderer"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="sr"/>
        </target>
        <dependent>
          <name value="SetAdmissionOrderer"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="sr"/>
          </parameter>
        </dependent>
      </rule>
      <documentation
                     value="── Ordered on arrival ──────────────────────────────────────────────────"/>
    </rule>
    <rule>
      <name value="treatmentOrdered"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="row"/>
        <condition
                   value="(linkId = 'treatment') and item.where(linkId = 'treatment/name').answer.value.exists()"/>
      </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="row"/>
        </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="row"/>
        </source>
        <target>
          <context value="sr"/>
          <element value="intent"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="order"/>
          </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="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="nameRule"/>
        <source>
          <context value="row"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'treatment/name'"/>
        </source>
        <rule>
          <name value="answer"/>
          <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="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>
      </rule>
      <rule>
        <name value="orderer"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="sr"/>
        </target>
        <dependent>
          <name value="SetAdmissionOrderer"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="sr"/>
          </parameter>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetAdmissionOrderer"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="sr"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="signOffGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'sign-off'"/>
      </source>
      <rule>
        <name value="physicianRule"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition
                     value="(linkId = 'sign-off/physician') and answer.value.exists()"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="requester"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="ref"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ref"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </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="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="admission-form"/>
            </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="Admission form"/>
            </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>