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

: ExtractVitalSigns - XML Representation

Draft as of 2026-09-15

Raw xml | Download


<StructureMap xmlns="http://hl7.org/fhir">
  <id value="ExtractVitalSigns"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap ExtractVitalSigns</b></p><a name="ExtractVitalSigns"> </a><a name="hcExtractVitalSigns"> </a><pre class="fml">
<span style="color: #cc00cc">/// <b>url</b> = </span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractVitalSigns'</span>
<span style="color: #cc00cc">/// <b>name</b> = </span><span style="color: blue">'ExtractVitalSigns'</span>
<span style="color: #cc00cc">/// <b>status</b> = </span><span style="color: blue">'draft'</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>group </b>ExtractVitalSigns<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">Height</span>
  qr.item<b> as </b><span style="color: maroon">itH</span><b> where </b><span style="color: navy">(</span>linkId = '8302-2'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itH.answer first<b> as </b><span style="color: maroon">aH</span><b> then</b><span style="color: navy"> {
</span>      aH<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eH</span><span style="color: navy">, </span> eH.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">oH</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oH<span style="color: navy">, </span> eH<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oH</span><span style="color: navy">, </span><span style="color: maroon">eH</span><span style="color: navy">)</span> <i>&quot;heightBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oH.category<b> as </b><span style="color: maroon">catH</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catH.coding<b> as </b><span style="color: maroon">catHCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catHCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catHSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catHCoding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;catHCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catHCoding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;catHDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catHCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;categoryH&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oH.code<b> as </b><span style="color: maroon">codeH</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeH.coding<b> as </b><span style="color: maroon">codeHCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeHCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeHSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeHCoding.code = <span style="color: blue">'8302-2'</span> <i>&quot;codeHCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeHCoding.display = <span style="color: blue">'Body Height'</span> <i>&quot;codeHDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeHCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeH&quot;</i><span style="color: navy">;</span>
        aH.value<b> as </b><span style="color: maroon">hv</span><span style="color: navy"><b> -&gt; </b></span>oH.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vH</span><b> then</b><span style="color: navy"> {
</span>          hv<span style="color: navy"><b> -&gt; </b></span>vH.value = <span style="color: maroon">hv</span> <i>&quot;setVal&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vH.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setSys&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vH.code = <span style="color: blue">'cm'</span> <i>&quot;setCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vH.unit = <span style="color: blue">'centimeter'</span> <i>&quot;setUnit&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;valH&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;heightObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;heightAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;heightRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Weight</span>
  qr.item<b> as </b><span style="color: maroon">itW</span><b> where </b><span style="color: navy">(</span>linkId = '29463-7'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itW.answer first<b> as </b><span style="color: maroon">aW</span><b> then</b><span style="color: navy"> {
</span>      aW<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eW</span><span style="color: navy">, </span> eW.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">oW</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oW<span style="color: navy">, </span> eW<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oW</span><span style="color: navy">, </span><span style="color: maroon">eW</span><span style="color: navy">)</span> <i>&quot;weightBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oW.category<b> as </b><span style="color: maroon">catW</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catW.coding<b> as </b><span style="color: maroon">catWCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catWCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catWSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catWCoding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;catWCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catWCoding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;catWDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catWCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;categoryW&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oW.code<b> as </b><span style="color: maroon">codeW</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeW.coding<b> as </b><span style="color: maroon">codeWCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeWCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeWSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeWCoding.code = <span style="color: blue">'29463-7'</span> <i>&quot;codeWCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeWCoding.display = <span style="color: blue">'Body Weight'</span> <i>&quot;codeWDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeWCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeW&quot;</i><span style="color: navy">;</span>
        aW.value<b> as </b><span style="color: maroon">hv</span><span style="color: navy"><b> -&gt; </b></span>oW.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vW</span><b> then</b><span style="color: navy"> {
</span>          hv<span style="color: navy"><b> -&gt; </b></span>vW.value = <span style="color: maroon">hv</span> <i>&quot;setVal&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vW.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setSys&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vW.code = <span style="color: blue">'kg'</span> <i>&quot;setCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vW.unit = <span style="color: blue">'kilogram'</span> <i>&quot;setUnit&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;valW&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;weightObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;weightAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;weightRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">BMI</span>
  qr.item<b> as </b><span style="color: maroon">itBmi</span><b> where </b><span style="color: navy">(</span>linkId = '39156-5'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itBmi.answer first<b> as </b><span style="color: maroon">aBmi</span><b> then</b><span style="color: navy"> {
</span>      aBmi<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eBmi</span><span style="color: navy">, </span> eBmi.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">oBmi</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oBmi<span style="color: navy">, </span> eBmi<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oBmi</span><span style="color: navy">, </span><span style="color: maroon">eBmi</span><span style="color: navy">)</span> <i>&quot;bmiBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oBmi.category<b> as </b><span style="color: maroon">catBmi</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catBmi.coding<b> as </b><span style="color: maroon">catBmiCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catBmiCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catBmiSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catBmiCoding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;catBmiCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catBmiCoding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;catBmiDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catBmiCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;categoryBmi&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oBmi.code<b> as </b><span style="color: maroon">codeBmi</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeBmi.coding<b> as </b><span style="color: maroon">codeBmiCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeBmiCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeBmiSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeBmiCoding.code = <span style="color: blue">'39156-5'</span> <i>&quot;codeBmiCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeBmiCoding.display = <span style="color: blue">'Body mass index (BMI) [Ratio]'</span> <i>&quot;codeBmiDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeBmiCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeBmi&quot;</i><span style="color: navy">;</span>
        aBmi.value<b> as </b><span style="color: maroon">hv</span><span style="color: navy"><b> -&gt; </b></span>oBmi.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vBmi</span><b> then</b><span style="color: navy"> {
</span>          hv<span style="color: navy"><b> -&gt; </b></span>vBmi.value = <span style="color: maroon">hv</span> <i>&quot;setVal&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vBmi.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setSys&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vBmi.code = <span style="color: blue">'kg/m2'</span> <i>&quot;setCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vBmi.unit = <span style="color: blue">'kilogram per square meter'</span> <i>&quot;setUnit&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;valBmi&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Interpretation 39156-5_status</span>
        itBmi.item<b> as </b><span style="color: maroon">bmiStatusItem</span><b> where </b><span style="color: navy">(</span>linkId = '39156-5_status'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>          bmiStatusItem.answer first<b> as </b><span style="color: maroon">bmiStatusAns</span><span style="color: navy"><b> -&gt; </b></span>oBmi.interpretation<b> as </b><span style="color: maroon">iBmi</span><b> then</b><span style="color: navy"> {
</span>            bmiStatusAns.value<b> as </b><span style="color: maroon">statusText</span><span style="color: navy"><b> -&gt; </b></span>iBmi.text = <span style="color: maroon">statusText</span> <i>&quot;interpBmi&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;setInterpBmi&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;findBmiStatus&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;bmiObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;bmiAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;bmiRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Pulse</span>
  qr.item<b> as </b><span style="color: maroon">itP</span><b> where </b><span style="color: navy">(</span>linkId = '8889-8'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itP.answer first<b> as </b><span style="color: maroon">aP</span><b> then</b><span style="color: navy"> {
</span>      aP<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eP</span><span style="color: navy">, </span> eP.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">oP</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oP<span style="color: navy">, </span> eP<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oP</span><span style="color: navy">, </span><span style="color: maroon">eP</span><span style="color: navy">)</span> <i>&quot;pulseBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oP.category<b> as </b><span style="color: maroon">catP</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catP.coding<b> as </b><span style="color: maroon">catPCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catPCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catPSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catPCoding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;catPCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catPCoding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;catPDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catPCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;categoryP&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oP.code<b> as </b><span style="color: maroon">codeP</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeP.coding<b> as </b><span style="color: maroon">codePCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codePCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codePSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codePCoding.code = <span style="color: blue">'8889-8'</span> <i>&quot;codePCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codePCoding.display = <span style="color: blue">'Heart rate by Pulse oximetry'</span> <i>&quot;codePDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codePCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeP&quot;</i><span style="color: navy">;</span>
        aP.value<b> as </b><span style="color: maroon">hv</span><span style="color: navy"><b> -&gt; </b></span>oP.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vP</span><b> then</b><span style="color: navy"> {
</span>          hv<span style="color: navy"><b> -&gt; </b></span>vP.value = <span style="color: maroon">hv</span> <i>&quot;setVal&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vP.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setSys&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vP.code = <span style="color: blue">'/min'</span> <i>&quot;setCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vP.unit = <span style="color: blue">'per minute'</span> <i>&quot;setUnit&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;valP&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;pulseObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;pulseAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;pulseRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Blood Pressure</span>
  qr.item<b> as </b><span style="color: maroon">itBP</span><b> where </b><span style="color: navy">(</span>linkId = '55284-4'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eBP</span><span style="color: navy">, </span> eBP.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">oBP</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> oBP<span style="color: navy">, </span> eBP<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oBP</span><span style="color: navy">, </span><span style="color: maroon">eBP</span><span style="color: navy">)</span> <i>&quot;bpBase&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>oBP.category<b> as </b><span style="color: maroon">catBP</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span>catBP.coding<b> as </b><span style="color: maroon">catBPCoding</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catBPCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catBPSys&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>catBPCoding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;catBPCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>catBPCoding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;catBPDisplay&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;catBPCodingRule&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;categoryBP&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>oBP.code<b> as </b><span style="color: maroon">codeBP</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span>codeBP.coding<b> as </b><span style="color: maroon">codeBPCoding</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeBPCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeBPSys&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>codeBPCoding.code = <span style="color: blue">'55284-4'</span> <i>&quot;codeBPCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>codeBPCoding.display = <span style="color: blue">'Blood pressure systolic and diastolic'</span> <i>&quot;codeBPDisplay&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeBPCodingRule&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;codeBP&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Systolic 8480-6</span>
      itBP.item<b> as </b><span style="color: maroon">itSys</span><b> where </b><span style="color: navy">(</span>linkId = '8480-6'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        itSys.answer first<b> as </b><span style="color: maroon">aSys</span><span style="color: navy"><b> -&gt; </b></span>oBP.component<b> as </b><span style="color: maroon">cSys</span><b> then</b><span style="color: navy"> {
</span>          aSys<span style="color: navy"><b> -&gt; </b></span>cSys.code<b> as </b><span style="color: maroon">bpSysCC</span><b> then</b><span style="color: navy"> {
</span>            aSys<span style="color: navy"><b> -&gt; </b></span>bpSysCC.coding<b> as </b><span style="color: maroon">bpSysCoding</span><b> then</b><span style="color: navy"> {
</span>              aSys<span style="color: navy"><b> -&gt; </b></span>bpSysCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;bpSysCodingSystem&quot;</i><span style="color: navy">;</span>
              aSys<span style="color: navy"><b> -&gt; </b></span>bpSysCoding.code = <span style="color: blue">'8480-6'</span> <i>&quot;bpSysCodingCode&quot;</i><span style="color: navy">;</span>
              aSys<span style="color: navy"><b> -&gt; </b></span>bpSysCoding.display = <span style="color: blue">'Systolic blood pressure'</span> <i>&quot;bpSysCodingDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;bpSysCodingRule&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;bpSysCode&quot;</i><span style="color: navy">;</span>
          aSys.value<b> as </b><span style="color: maroon">hv</span><span style="color: navy"><b> -&gt; </b></span>cSys.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vSys</span><b> then</b><span style="color: navy"> {
</span>            hv<span style="color: navy"><b> -&gt; </b></span>vSys.value = <span style="color: maroon">hv</span> <i>&quot;setVal&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vSys.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vSys.code = <span style="color: blue">'mm[Hg]'</span> <i>&quot;setCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vSys.unit = <span style="color: blue">'millimeter of mercury'</span> <i>&quot;setUnit&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;bpSysVal&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;bpSysComponent&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;bpSysRule&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Diastolic 8462-4</span>
      itBP.item<b> as </b><span style="color: maroon">itDia</span><b> where </b><span style="color: navy">(</span>linkId = '8462-4'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        itDia.answer first<b> as </b><span style="color: maroon">aDia</span><span style="color: navy"><b> -&gt; </b></span>oBP.component<b> as </b><span style="color: maroon">cDia</span><b> then</b><span style="color: navy"> {
</span>          aDia<span style="color: navy"><b> -&gt; </b></span>cDia.code<b> as </b><span style="color: maroon">bpDiaCC</span><b> then</b><span style="color: navy"> {
</span>            aDia<span style="color: navy"><b> -&gt; </b></span>bpDiaCC.coding<b> as </b><span style="color: maroon">bpDiaCoding</span><b> then</b><span style="color: navy"> {
</span>              aDia<span style="color: navy"><b> -&gt; </b></span>bpDiaCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;bpDiaCodingSystem&quot;</i><span style="color: navy">;</span>
              aDia<span style="color: navy"><b> -&gt; </b></span>bpDiaCoding.code = <span style="color: blue">'8462-4'</span> <i>&quot;bpDiaCodingCode&quot;</i><span style="color: navy">;</span>
              aDia<span style="color: navy"><b> -&gt; </b></span>bpDiaCoding.display = <span style="color: blue">'Diastolic blood pressure'</span> <i>&quot;bpDiaCodingDisplay&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;bpDiaCodingRule&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;bpDiaCode&quot;</i><span style="color: navy">;</span>
          aDia.value<b> as </b><span style="color: maroon">hv</span><span style="color: navy"><b> -&gt; </b></span>cDia.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vDia</span><b> then</b><span style="color: navy"> {
</span>            hv<span style="color: navy"><b> -&gt; </b></span>vDia.value = <span style="color: maroon">hv</span> <i>&quot;setVal&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vDia.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vDia.code = <span style="color: blue">'mm[Hg]'</span> <i>&quot;setCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>vDia.unit = <span style="color: blue">'millimeter of mercury'</span> <i>&quot;setUnit&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;bpDiaVal&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;bpDiaComponent&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;bpDiaRule&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;bpObs&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;bpRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Temperature</span>
  qr.item<b> as </b><span style="color: maroon">itT</span><b> where </b><span style="color: navy">(</span>linkId = '8310-5'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itT.answer first<b> as </b><span style="color: maroon">aT</span><b> then</b><span style="color: navy"> {
</span>      aT<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eT</span><span style="color: navy">, </span> eT.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">oT</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oT<span style="color: navy">, </span> eT<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oT</span><span style="color: navy">, </span><span style="color: maroon">eT</span><span style="color: navy">)</span> <i>&quot;tempBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oT.category<b> as </b><span style="color: maroon">catT</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catT.coding<b> as </b><span style="color: maroon">catTCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catTCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catTSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catTCoding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;catTCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catTCoding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;catTDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catTCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;categoryT&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oT.code<b> as </b><span style="color: maroon">codeT</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeT.coding<b> as </b><span style="color: maroon">codeTCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeTCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeTSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeTCoding.code = <span style="color: blue">'8310-5'</span> <i>&quot;codeTCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeTCoding.display = <span style="color: blue">'Body Temperature'</span> <i>&quot;codeTDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeTCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeT&quot;</i><span style="color: navy">;</span>
        aT.value<b> as </b><span style="color: maroon">hv</span><span style="color: navy"><b> -&gt; </b></span>oT.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vT</span><b> then</b><span style="color: navy"> {
</span>          hv<span style="color: navy"><b> -&gt; </b></span>vT.value = <span style="color: maroon">hv</span> <i>&quot;setVal&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vT.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setSys&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vT.code = <span style="color: blue">'Cel'</span> <i>&quot;setCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vT.unit = <span style="color: blue">'degree Celsius'</span> <i>&quot;setUnit&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;valT&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Interpretation 8310-5_status</span>
        itT.item<b> as </b><span style="color: maroon">tStatusItem</span><b> where </b><span style="color: navy">(</span>linkId = '8310-5_status'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>          tStatusItem.answer first<b> as </b><span style="color: maroon">tStatusAns</span><span style="color: navy"><b> -&gt; </b></span>oT.interpretation<b> as </b><span style="color: maroon">iT</span><b> then</b><span style="color: navy"> {
</span>            tStatusAns.value<b> as </b><span style="color: maroon">statusText</span><span style="color: navy"><b> -&gt; </b></span>iT.text = <span style="color: maroon">statusText</span> <i>&quot;interpT&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;setInterpT&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;findTStatus&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;tempObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;tempAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;tempRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">SpO2</span>
  qr.item<b> as </b><span style="color: maroon">itO2</span><b> where </b><span style="color: navy">(</span>linkId = '20564-1'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itO2.answer first<b> as </b><span style="color: maroon">aO2</span><b> then</b><span style="color: navy"> {
</span>      aO2<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eO2</span><span style="color: navy">, </span> eO2.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">oO2</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oO2<span style="color: navy">, </span> eO2<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oO2</span><span style="color: navy">, </span><span style="color: maroon">eO2</span><span style="color: navy">)</span> <i>&quot;spo2Base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oO2.category<b> as </b><span style="color: maroon">catO2</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catO2.coding<b> as </b><span style="color: maroon">catO2Coding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catO2Coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catO2Sys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catO2Coding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;catO2Code&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catO2Coding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;catO2Display&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catO2CodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;categoryO2&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oO2.code<b> as </b><span style="color: maroon">codeO2</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeO2.coding<b> as </b><span style="color: maroon">codeO2Coding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeO2Coding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeO2Sys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeO2Coding.code = <span style="color: blue">'20564-1'</span> <i>&quot;codeO2Code&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeO2Coding.display = <span style="color: blue">'Oxygen saturation in Blood'</span> <i>&quot;codeO2Display&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeO2CodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeO2&quot;</i><span style="color: navy">;</span>
        aO2.value<b> as </b><span style="color: maroon">hv</span><span style="color: navy"><b> -&gt; </b></span>oO2.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vO2</span><b> then</b><span style="color: navy"> {
</span>          hv<span style="color: navy"><b> -&gt; </b></span>vO2.value = <span style="color: maroon">hv</span> <i>&quot;setVal&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vO2.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setSys&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vO2.code = <span style="color: blue">'%'</span> <i>&quot;setCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vO2.unit = <span style="color: blue">'%'</span> <i>&quot;setUnit&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;valO2&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Interpretation of SpO2 20564-1_status</span>
        itO2.item<b> as </b><span style="color: maroon">o2StatusItem</span><b> where </b><span style="color: navy">(</span>linkId = '20564-1_status'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>          o2StatusItem.answer first<b> as </b><span style="color: maroon">o2StatusAns</span><span style="color: navy"><b> -&gt; </b></span>oO2.interpretation<b> as </b><span style="color: maroon">iO2</span><b> then</b><span style="color: navy"> {
</span>            o2StatusAns.value<b> as </b><span style="color: maroon">statusText</span><span style="color: navy"><b> -&gt; </b></span>iO2.text = <span style="color: maroon">statusText</span> <i>&quot;interpO2&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;setInterpO2&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;findO2Status&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;spo2Obs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;spo2Ans&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;spo2Rule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Respiratory rate</span>
  qr.item<b> as </b><span style="color: maroon">itRR</span><b> where </b><span style="color: navy">(</span>linkId = '9279-1'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itRR.answer first<b> as </b><span style="color: maroon">aRR</span><b> then</b><span style="color: navy"> {
</span>      aRR<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eRR</span><span style="color: navy">, </span> eRR.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">oRR</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oRR<span style="color: navy">, </span> eRR<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oRR</span><span style="color: navy">, </span><span style="color: maroon">eRR</span><span style="color: navy">)</span> <i>&quot;rrBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oRR.category<b> as </b><span style="color: maroon">catRR</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catRR.coding<b> as </b><span style="color: maroon">catRRCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catRRCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catRRSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catRRCoding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;catRRCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catRRCoding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;catRRDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catRRCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;categoryRR&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oRR.code<b> as </b><span style="color: maroon">codeRR</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeRR.coding<b> as </b><span style="color: maroon">codeRRCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeRRCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeRRSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeRRCoding.code = <span style="color: blue">'9279-1'</span> <i>&quot;codeRRCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeRRCoding.display = <span style="color: blue">'Respiratory rate'</span> <i>&quot;codeRRDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeRRCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeRR&quot;</i><span style="color: navy">;</span>
        aRR.value<b> as </b><span style="color: maroon">hv</span><span style="color: navy"><b> -&gt; </b></span>oRR.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vRR</span><b> then</b><span style="color: navy"> {
</span>          hv<span style="color: navy"><b> -&gt; </b></span>vRR.value = <span style="color: maroon">hv</span> <i>&quot;setVal&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vRR.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setSys&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vRR.code = <span style="color: blue">'/min'</span> <i>&quot;setCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vRR.unit = <span style="color: blue">'per minute'</span> <i>&quot;setUnit&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;valRR&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;rrObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;rrAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;rrRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">MUAC</span>
  qr.item<b> as </b><span style="color: maroon">itMuac</span><b> where </b><span style="color: navy">(</span>linkId = '9847-5'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itMuac.answer first<b> as </b><span style="color: maroon">aMuac</span><b> then</b><span style="color: navy"> {
</span>      aMuac<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eMuac</span><span style="color: navy">, </span> eMuac.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">oMuac</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oMuac<span style="color: navy">, </span> eMuac<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oMuac</span><span style="color: navy">, </span><span style="color: maroon">eMuac</span><span style="color: navy">)</span> <i>&quot;muacBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oMuac.category<b> as </b><span style="color: maroon">catMuac</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catMuac.coding<b> as </b><span style="color: maroon">catMuacCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catMuacCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catMuacSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catMuacCoding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;catMuacCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catMuacCoding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;catMuacDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catMuacCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;categoryMuac&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oMuac.code<b> as </b><span style="color: maroon">codeMuac</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeMuac.coding<b> as </b><span style="color: maroon">codeMuacCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeMuacCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeMuacSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeMuacCoding.code = <span style="color: blue">'9847-5'</span> <i>&quot;codeMuacCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeMuacCoding.display = <span style="color: blue">'Circumference'</span> <i>&quot;codeMuacDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeMuacCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeMuac&quot;</i><span style="color: navy">;</span>
        aMuac.value<b> as </b><span style="color: maroon">hv</span><span style="color: navy"><b> -&gt; </b></span>oMuac.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vMuac</span><b> then</b><span style="color: navy"> {
</span>          hv<span style="color: navy"><b> -&gt; </b></span>vMuac.value = <span style="color: maroon">hv</span> <i>&quot;setVal&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vMuac.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setSys&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vMuac.code = <span style="color: blue">'mm'</span> <i>&quot;setCode&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>vMuac.unit = <span style="color: blue">'millimeter'</span> <i>&quot;setUnit&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;valMuac&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;muacObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;muacAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;muacRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Chief Complaint</span>
  qr.item<b> as </b><span style="color: maroon">itCC</span><b> where </b><span style="color: navy">(</span>linkId = '10154-3'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itCC.answer first<b> as </b><span style="color: maroon">aCC</span><b> then</b><span style="color: navy"> {
</span>      aCC<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eCC</span><span style="color: navy">, </span> eCC.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">oCC</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oCC<span style="color: navy">, </span> eCC<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oCC</span><span style="color: navy">, </span><span style="color: maroon">eCC</span><span style="color: navy">)</span> <i>&quot;chiefComplaintBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.category<b> as </b><span style="color: maroon">catCC</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catCC.coding<b> as </b><span style="color: maroon">catCCCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catCCCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catCCSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catCCCoding.code = <span style="color: blue">'social-history'</span> <i>&quot;catCCCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catCCCoding.display = <span style="color: blue">'Social History'</span> <i>&quot;catCCDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catCCCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;chiefComplaintCategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.code<b> as </b><span style="color: maroon">codeCC</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeCC.coding<b> as </b><span style="color: maroon">codeCCCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeCCCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeCCSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeCCCoding.code = <span style="color: blue">'10154-3'</span> <i>&quot;codeCCCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeCCCoding.display = <span style="color: blue">'Chief complaint Narrative - Reported'</span> <i>&quot;codeCCDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeCCCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;chiefComplaintCode&quot;</i><span style="color: navy">;</span>
        aCC.value<b> as </b><span style="color: maroon">textVal</span><span style="color: navy"><b> -&gt; </b></span>oCC.value = <span style="color: maroon">textVal</span> <i>&quot;chiefComplaintValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;chiefComplaintObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;chiefComplaintAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;chiefComplaintRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">History of Presenting Illness</span>
  qr.item<b> as </b><span style="color: maroon">hpiCC</span><b> where </b><span style="color: navy">(</span>linkId = '8684-3'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    hpiCC.answer first<b> as </b><span style="color: maroon">aCC</span><b> then</b><span style="color: navy"> {
</span>      aCC<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eCC</span><span style="color: navy">, </span> eCC.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">oCC</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oCC<span style="color: navy">, </span> eCC<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oCC</span><span style="color: navy">, </span><span style="color: maroon">eCC</span><span style="color: navy">)</span> <i>&quot;historyOfPIBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.category<b> as </b><span style="color: maroon">catHPI</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catHPI.coding<b> as </b><span style="color: maroon">catHPICoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catHPICoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catHPISys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catHPICoding.code = <span style="color: blue">'social-history'</span> <i>&quot;catHPICode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catHPICoding.display = <span style="color: blue">'Social History'</span> <i>&quot;catHPIDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catHPICodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;historyOfPICategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.code<b> as </b><span style="color: maroon">codeHPI</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeHPI.coding<b> as </b><span style="color: maroon">codeHPICoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeHPICoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeHPISys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeHPICoding.code = <span style="color: blue">'8684-3'</span> <i>&quot;codeHPICode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeHPICoding.display = <span style="color: blue">'History of Present illness'</span> <i>&quot;codeHPIDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeHPICodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;historyOfPICode&quot;</i><span style="color: navy">;</span>
        aCC.value<b> as </b><span style="color: maroon">textVal</span><span style="color: navy"><b> -&gt; </b></span>oCC.value = <span style="color: maroon">textVal</span> <i>&quot;historyOfPIValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;historyOfPIObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;historyOfPIAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;historyOfPIRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">History of Past Illness / Past Medical History</span>
  qr.item<b> as </b><span style="color: maroon">hPastCC</span><b> where </b><span style="color: navy">(</span>linkId = '11349-8'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    hPastCC.answer first<b> as </b><span style="color: maroon">aCC</span><b> then</b><span style="color: navy"> {
</span>      aCC<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eCC</span><span style="color: navy">, </span> eCC.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">oCC</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oCC<span style="color: navy">, </span> eCC<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oCC</span><span style="color: navy">, </span><span style="color: maroon">eCC</span><span style="color: navy">)</span> <i>&quot;historyOfPastIBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.category<b> as </b><span style="color: maroon">catPastI</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catPastI.coding<b> as </b><span style="color: maroon">catPastICoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catPastICoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catPastISys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catPastICoding.code = <span style="color: blue">'social-history'</span> <i>&quot;catPastICode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catPastICoding.display = <span style="color: blue">'Social History'</span> <i>&quot;catPastIDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catPastICodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;historyOfPastICategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.code<b> as </b><span style="color: maroon">codePastI</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codePastI.coding<b> as </b><span style="color: maroon">codePastICoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codePastICoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codePastISys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codePastICoding.code = <span style="color: blue">'11349-8'</span> <i>&quot;codePastICode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codePastICoding.display = <span style="color: blue">'History of Past illness'</span> <i>&quot;codePastIDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codePastICodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;historyOfPastICode&quot;</i><span style="color: navy">;</span>
        aCC.value<b> as </b><span style="color: maroon">textVal</span><span style="color: navy"><b> -&gt; </b></span>oCC.value = <span style="color: maroon">textVal</span> <i>&quot;historyOfPastIValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;historyOfPastIObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;historyOfPastIAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;historyOfPastIRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Family History</span>
  qr.item<b> as </b><span style="color: maroon">hFH</span><b> where </b><span style="color: navy">(</span>linkId = '8670-2'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    hFH.answer first<b> as </b><span style="color: maroon">aCC</span><b> then</b><span style="color: navy"> {
</span>      aCC<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eCC</span><span style="color: navy">, </span> eCC.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">oCC</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oCC<span style="color: navy">, </span> eCC<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oCC</span><span style="color: navy">, </span><span style="color: maroon">eCC</span><span style="color: navy">)</span> <i>&quot;familyFHIBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.category<b> as </b><span style="color: maroon">catFH</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catFH.coding<b> as </b><span style="color: maroon">catFHCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catFHCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catFHSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catFHCoding.code = <span style="color: blue">'social-history'</span> <i>&quot;catFHCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catFHCoding.display = <span style="color: blue">'Social History'</span> <i>&quot;catFHDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catFHCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;familyHICategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.code<b> as </b><span style="color: maroon">codeFH</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeFH.coding<b> as </b><span style="color: maroon">codeFHCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeFHCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeFHSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeFHCoding.code = <span style="color: blue">'8670-2'</span> <i>&quot;codeFHCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeFHCoding.display = <span style="color: blue">'History of family member diseases'</span> <i>&quot;codeFHDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeFHCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;familyHICode&quot;</i><span style="color: navy">;</span>
        aCC.value<b> as </b><span style="color: maroon">textVal</span><span style="color: navy"><b> -&gt; </b></span>oCC.value = <span style="color: maroon">textVal</span> <i>&quot;familyHIValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;familyHIObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;familyHIAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;familyHIRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Social History</span>
  qr.item<b> as </b><span style="color: maroon">hSH</span><b> where </b><span style="color: navy">(</span>linkId = '29762-2'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    hSH.answer first<b> as </b><span style="color: maroon">aCC</span><b> then</b><span style="color: navy"> {
</span>      aCC<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eCC</span><span style="color: navy">, </span> eCC.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">oCC</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oCC<span style="color: navy">, </span> eCC<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oCC</span><span style="color: navy">, </span><span style="color: maroon">eCC</span><span style="color: navy">)</span> <i>&quot;socialHistoryIBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.category<b> as </b><span style="color: maroon">catSH</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catSH.coding<b> as </b><span style="color: maroon">catSHCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catSHCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catSHSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catSHCoding.code = <span style="color: blue">'social-history'</span> <i>&quot;catSHCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catSHCoding.display = <span style="color: blue">'Social History'</span> <i>&quot;catSHDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catSHCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;socialHistoryCategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.code<b> as </b><span style="color: maroon">codeSH</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeSH.coding<b> as </b><span style="color: maroon">codeSHCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeSHCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeSHSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeSHCoding.code = <span style="color: blue">'29762-2'</span> <i>&quot;codeSHCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeSHCoding.display = <span style="color: blue">'Social history note'</span> <i>&quot;codeSHDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeSHCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;socialHistoryCode&quot;</i><span style="color: navy">;</span>
        aCC.value<b> as </b><span style="color: maroon">textVal</span><span style="color: navy"><b> -&gt; </b></span>oCC.value = <span style="color: maroon">textVal</span> <i>&quot;socialHistoryIValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;socialHistoryIObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;socialHistoryIAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;socialHistoryIRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Medication History</span>
  qr.item<b> as </b><span style="color: maroon">medicationH</span><b> where </b><span style="color: navy">(</span>linkId = '10160-0'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    medicationH.answer first<b> as </b><span style="color: maroon">aCC</span><b> then</b><span style="color: navy"> {
</span>      aCC<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eCC</span><span style="color: navy">, </span> eCC.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">oCC</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oCC<span style="color: navy">, </span> eCC<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oCC</span><span style="color: navy">, </span><span style="color: maroon">eCC</span><span style="color: navy">)</span> <i>&quot;medicationHIBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.category<b> as </b><span style="color: maroon">catMedH</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catMedH.coding<b> as </b><span style="color: maroon">catMedHCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catMedHCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catMedHSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catMedHCoding.code = <span style="color: blue">'therapy'</span> <i>&quot;catMedHCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catMedHCoding.display = <span style="color: blue">'Therapy'</span> <i>&quot;catMedHDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catMedHCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;medicationHCategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.code<b> as </b><span style="color: maroon">codeMedH</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeMedH.coding<b> as </b><span style="color: maroon">codeMedHCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeMedHCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeMedHSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeMedHCoding.code = <span style="color: blue">'10160-0'</span> <i>&quot;codeMedHCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeMedHCoding.display = <span style="color: blue">'History of Medication use Narrative'</span> <i>&quot;codeMedHDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeMedHCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;medicationHistoryCode&quot;</i><span style="color: navy">;</span>
        aCC.value<b> as </b><span style="color: maroon">textVal</span><span style="color: navy"><b> -&gt; </b></span>oCC.value = <span style="color: maroon">textVal</span> <i>&quot;medicationHistoryIValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;medicationHistoryIObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;medicationHistoryIAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;medicationHistoryIRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Risk Factors</span>
  qr.item<b> as </b><span style="color: maroon">riskF</span><b> where </b><span style="color: navy">(</span>linkId = '46467-7'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    riskF.answer first<b> as </b><span style="color: maroon">aCC</span><b> then</b><span style="color: navy"> {
</span>      aCC<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eCC</span><span style="color: navy">, </span> eCC.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">oCC</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oCC<span style="color: navy">, </span> eCC<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oCC</span><span style="color: navy">, </span><span style="color: maroon">eCC</span><span style="color: navy">)</span> <i>&quot;riskFactorsBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.category<b> as </b><span style="color: maroon">catRF</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>catRF.coding<b> as </b><span style="color: maroon">catRFCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>catRFCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catRFSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catRFCoding.code = <span style="color: blue">'social-history'</span> <i>&quot;catRFCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>catRFCoding.display = <span style="color: blue">'Social History'</span> <i>&quot;catRFDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;catRFCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;riskFactorsCategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCC.code<b> as </b><span style="color: maroon">codeRF</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeRF.coding<b> as </b><span style="color: maroon">codeRFCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeRFCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeRFSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeRFCoding.code = <span style="color: blue">'46467-7'</span> <i>&quot;codeRFCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeRFCoding.display = <span style="color: blue">'Risk factors'</span> <i>&quot;codeRFDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeRFCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;riskFactorsCode&quot;</i><span style="color: navy">;</span>
        aCC.value<b> as </b><span style="color: maroon">textVal</span><span style="color: navy"><b> -&gt; </b></span>oCC.value = <span style="color: maroon">textVal</span> <i>&quot;riskFactorsValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;riskFactorsObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;riskFactorsAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;riskFactorsRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">───────────────────────────────────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">Admissions observation templates.</span>
  <span style="color: navy">// </span><span style="color: green">These forms carry the design's own field ids as linkIds rather than the LOINC</span>
  <span style="color: navy">// </span><span style="color: green">codes the rules above match on, so the linkId and the Observation.code are</span>
  <span style="color: navy">// </span><span style="color: green">stated separately. Everything they produce is category `exam` - a reading</span>
  <span style="color: navy">// </span><span style="color: green">taken at the bedside as part of assessing the patient, not a lab result and</span>
  <span style="color: navy">// </span><span style="color: green">not a vital sign.</span>
  <span style="color: navy">// </span><span style="color: green">───────────────────────────────────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">Pain score - pain at rest</span>
  qr.item<b> as </b><span style="color: maroon">itPar</span><b> where </b><span style="color: navy">(</span>linkId = 'painAtRest'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itPar.answer first<b> as </b><span style="color: maroon">aPar</span><b> then</b><span style="color: navy"> {
</span>      aPar<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">ePar</span><span style="color: navy">, </span> ePar.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">oPar</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oPar<span style="color: navy">, </span> ePar<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oPar</span><span style="color: navy">, </span><span style="color: maroon">ePar</span><span style="color: navy">)</span> <i>&quot;painAtRestBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oPar<b> then </b>SetExamCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oPar</span><span style="color: navy">)</span> <i>&quot;painAtRestCategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oPar.code<b> as </b><span style="color: maroon">codePar</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codePar.coding<b> as </b><span style="color: maroon">codeParCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeParCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeParSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeParCoding.code = <span style="color: blue">'99302-2'</span> <i>&quot;codeParCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeParCoding.display = <span style="color: blue">'Verbal complaints while at rest'</span> <i>&quot;codeParDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeParCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codePar&quot;</i><span style="color: navy">;</span>
        aPar.value<b> as </b><span style="color: maroon">pv</span><span style="color: navy"><b> -&gt; </b></span>oPar.value = <span style="color: maroon">pv</span> <i>&quot;valPar&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oPar<b> then </b>SetPainBodySite<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oPar</span><span style="color: navy">)</span> <i>&quot;painAtRestSite&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;painAtRestObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;painAtRestAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;painAtRestRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Pain score - pain on movement</span>
  qr.item<b> as </b><span style="color: maroon">itPom</span><b> where </b><span style="color: navy">(</span>linkId = 'painOnMovement'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itPom.answer first<b> as </b><span style="color: maroon">aPom</span><b> then</b><span style="color: navy"> {
</span>      aPom<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">ePom</span><span style="color: navy">, </span> ePom.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">oPom</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oPom<span style="color: navy">, </span> ePom<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oPom</span><span style="color: navy">, </span><span style="color: maroon">ePom</span><span style="color: navy">)</span> <i>&quot;painOnMovementBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oPom<b> then </b>SetExamCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oPom</span><span style="color: navy">)</span> <i>&quot;painOnMovementCategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oPom.code<b> as </b><span style="color: maroon">codePom</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codePom.coding<b> as </b><span style="color: maroon">codePomCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codePomCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codePomSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codePomCoding.code = <span style="color: blue">'99294-1'</span> <i>&quot;codePomCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codePomCoding.display = <span style="color: blue">'Verbal complaints during movement'</span> <i>&quot;codePomDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codePomCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codePom&quot;</i><span style="color: navy">;</span>
        aPom.value<b> as </b><span style="color: maroon">pv</span><span style="color: navy"><b> -&gt; </b></span>oPom.value = <span style="color: maroon">pv</span> <i>&quot;valPom&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oPom<b> then </b>SetPainBodySite<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oPom</span><span style="color: navy">)</span> <i>&quot;painOnMovementSite&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;painOnMovementObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;painOnMovementAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;painOnMovementRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Blood glucose - capillary glucose</span>
  qr.item<b> as </b><span style="color: maroon">itCg</span><b> where </b><span style="color: navy">(</span>linkId = 'capillaryGlucose'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itCg.answer first<b> as </b><span style="color: maroon">aCg</span><b> then</b><span style="color: navy"> {
</span>      aCg<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eCg</span><span style="color: navy">, </span> eCg.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">oCg</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oCg<span style="color: navy">, </span> eCg<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oCg</span><span style="color: navy">, </span><span style="color: maroon">eCg</span><span style="color: navy">)</span> <i>&quot;capillaryGlucoseBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCg<b> then </b>SetExamCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oCg</span><span style="color: navy">)</span> <i>&quot;capillaryGlucoseCategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oCg.code<b> as </b><span style="color: maroon">codeCg</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeCg.coding<b> as </b><span style="color: maroon">codeCgCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeCgCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeCgSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeCgCoding.code = <span style="color: blue">'14743-9'</span> <i>&quot;codeCgCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeCgCoding.display = <span style="color: blue">'Glucose [Moles/volume] in Capillary blood by Glucometer'</span> <i>&quot;codeCgDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeCgCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeCg&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">The answer is already a Quantity - the item is type `quantity` with</span>
        <span style="color: navy">// </span><span style="color: green">questionnaire-unitOption pinning mmol/L - so copy it through whole. The</span>
        <span style="color: navy">// </span><span style="color: green">vitals rules above rebuild a Quantity because their answers are bare</span>
        <span style="color: navy">// </span><span style="color: green">decimals; rebuilding here would mean restating the unit, and restating a</span>
        <span style="color: navy">// </span><span style="color: green">unit the client actually sent turns a wrong unit into a wrong reading.</span>
        aCg.value<b> as </b><span style="color: maroon">gv</span><span style="color: navy"><b> -&gt; </b></span>oCg.value = <span style="color: maroon">gv</span> <i>&quot;valCg&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;capillaryGlucoseObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;capillaryGlucoseAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;capillaryGlucoseRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Blood glucose - insulin given against the reading.</span>
  <span style="color: navy">// </span><span style="color: green">4287-9 is &quot;Insulin regular [Mass] of Dose&quot;: PROPERTY Mass, SCALE_TYP Qn. The</span>
  <span style="color: navy">// </span><span style="color: green">form captures free text (&quot;4 units Actrapid&quot;), and insulin is dosed in</span>
  <span style="color: navy">// </span><span style="color: green">international units rather than by mass, so the answer lands in valueString</span>
  <span style="color: navy">// </span><span style="color: green">rather than the Quantity the code implies. It records what the nurse wrote,</span>
  <span style="color: navy">// </span><span style="color: green">which is the point; a mass in mg is not what anyone is charting.</span>
  qr.item<b> as </b><span style="color: maroon">itIns</span><b> where </b><span style="color: navy">(</span>linkId = 'insulinGiven'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itIns.answer first<b> as </b><span style="color: maroon">aIns</span><b> then</b><span style="color: navy"> {
</span>      aIns<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">eIns</span><span style="color: navy">, </span> eIns.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">oIns</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> oIns<span style="color: navy">, </span> eIns<b> then </b>BuildBaseObs<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oIns</span><span style="color: navy">, </span><span style="color: maroon">eIns</span><span style="color: navy">)</span> <i>&quot;insulinGivenBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oIns<b> then </b>SetExamCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">oIns</span><span style="color: navy">)</span> <i>&quot;insulinGivenCategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>oIns.code<b> as </b><span style="color: maroon">codeIns</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>codeIns.coding<b> as </b><span style="color: maroon">codeInsCoding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>codeInsCoding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeInsSys&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeInsCoding.code = <span style="color: blue">'4287-9'</span> <i>&quot;codeInsCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>codeInsCoding.display = <span style="color: blue">'Insulin regular [Mass] of Dose'</span> <i>&quot;codeInsDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeInsCodingRule&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;codeIns&quot;</i><span style="color: navy">;</span>
        aIns.value<b> as </b><span style="color: maroon">iv</span><span style="color: navy"><b> -&gt; </b></span>oIns.value = <span style="color: maroon">iv</span> <i>&quot;valIns&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;insulinGivenObs&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;insulinGivenAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;insulinGivenRule&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">Category `exam`, shared by every observation the admissions templates produce.</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">catCoding</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>catCoding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;examSys&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>catCoding.code = <span style="color: blue">'exam'</span> <i>&quot;examCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>catCoding.display = <span style="color: blue">'Exam'</span> <i>&quot;examDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;examCodingRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;examCategory&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">The pain form asks for one site covering both scores, so it lands on each of</span>
<span style="color: navy">// </span><span style="color: green">the two Observations. It is free text today, hence bodySite.text rather than a</span>
<span style="color: navy">// </span><span style="color: green">coding; swap to bodySite.coding once the picker's option list is coded.</span>
<b>group </b>SetPainBodySite<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.item<b> as </b><span style="color: maroon">siteItem</span><b> where </b><span style="color: navy">(</span>linkId = 'site'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    siteItem.answer first<b> as </b><span style="color: maroon">siteAns</span><b> then</b><span style="color: navy"> {
</span>      siteAns.value<b> as </b><span style="color: maroon">siteVal</span><span style="color: navy"><b> -&gt; </b></span>obs.bodySite<b> as </b><span style="color: maroon">bs</span><b> then</b><span style="color: navy"> {
</span>        siteVal<span style="color: navy"><b> -&gt; </b></span>bs.text = <span style="color: maroon">siteVal</span> <i>&quot;bodySiteText&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;bodySite&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;siteAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;siteRule&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>BuildBaseObs<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.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>
  <span style="color: navy">// </span><span style="color: green">`effective`, not `effectiveDateTime`: the R5 transform engine writes choice</span>
  <span style="color: navy">// </span><span style="color: green">elements by their base name and rejects the typed form with &quot;Attempt to write</span>
  <span style="color: navy">// </span><span style="color: green">to invalid property 'effectiveDateTime' on type Observation&quot;. The value is a</span>
  <span style="color: navy">// </span><span style="color: green">dateTime, so the engine picks effectiveDateTime itself.</span>
  <span style="color: navy">// </span><span style="color: green">The admissions templates ask for the time the reading was taken, which is the</span>
  <span style="color: navy">// </span><span style="color: green">clinically meaningful one - a nurse writing up at the end of a round would</span>
  <span style="color: navy">// </span><span style="color: green">otherwise stamp every reading with the moment they saved the form. Fall back</span>
  <span style="color: navy">// </span><span style="color: green">to `authored` for the forms that do not ask.</span>
  qr.item<b> as </b><span style="color: maroon">tItem</span><b> where </b><span style="color: navy">(</span>linkId = 'timeTaken'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    tItem.answer first<b> as </b><span style="color: maroon">tAns</span><b> then</b><span style="color: navy"> {
</span>      tAns.value<b> as </b><span style="color: maroon">tv</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: maroon">tv</span> <i>&quot;effectiveFromTimeTaken&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;timeTakenAns&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;timeTakenRule&quot;</i><span style="color: navy">;</span>
  qr<b> where </b><span style="color: navy">(</span>item.where(linkId = 'timeTaken').answer.value.exists().not()<span style="color: navy">)</span><b> then</b><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;effectiveFromAuthored&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;authoredFallback&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Performer from QuestionnaireResponse.source</span>
  qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>obs.performer = <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">perf</span><b> then</b><span style="color: navy"> {
</span>    src.reference<b> as </b><span style="color: maroon">ref</span><span style="color: navy"><b> -&gt; </b></span>perf.reference = <span style="color: maroon">ref</span> <i>&quot;perfRef&quot;</i><span style="color: navy">;</span>
    src.display<b> as </b><span style="color: maroon">disp</span><span style="color: navy"><b> -&gt; </b></span>perf.display = <span style="color: maroon">disp</span> <i>&quot;perfDisplay&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;performer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Observation id and fullUrl</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;setObsIdAndFullUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Bundle.entry.request (transaction POST Observation)</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;reqMethod&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;reqUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;entryRequest&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Link Observation -&gt; QuestionnaireResponse.</span>
  <span style="color: navy">// </span><span style="color: green">No append: under this engine `qr.id` already resolves to the type-qualified</span>
  <span style="color: navy">// </span><span style="color: green">relative reference (&quot;QuestionnaireResponse/xyz&quot;), so prefixing it again</span>
  <span style="color: navy">// </span><span style="color: green">produced &quot;QuestionnaireResponse/QuestionnaireResponse/xyz&quot; - a reference that</span>
  <span style="color: navy">// </span><span style="color: green">resolves to nothing.</span>
  qr<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">newRef</span><b> then</b><span style="color: navy"> {
</span>    qr.id<b> as </b><span style="color: maroon">qid</span><span style="color: navy"><b> -&gt; </b></span>newRef.reference = <span style="color: maroon">qid</span> <i>&quot;setQRRef&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;linkQR&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></pre></div>
  </text>
  <url
       value="https://fhir.slade360.co.ke/fhir/StructureMap/ExtractVitalSigns"/>
  <version value="0.1.0"/>
  <name value="ExtractVitalSigns"/>
  <status value="draft"/>
  <date value="2026-09-15T11:40:24+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>
  <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>
  <group>
    <name value="ExtractVitalSigns"/>
    <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="heightRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itH"/>
        <condition value="linkId = '8302-2'"/>
      </source>
      <rule>
        <name value="heightAns"/>
        <source>
          <context value="itH"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aH"/>
        </source>
        <rule>
          <name value="heightObs"/>
          <source>
            <context value="aH"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eH"/>
          </target>
          <target>
            <context value="eH"/>
            <element value="resource"/>
            <variable value="oH"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="heightBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oH"/>
            </target>
            <target>
              <context value="eH"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oH"/>
              </parameter>
              <parameter>
                <valueId value="eH"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="categoryH"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oH"/>
              <element value="category"/>
              <variable value="catH"/>
            </target>
            <rule>
              <name value="catHCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catH"/>
                <element value="coding"/>
                <variable value="catHCoding"/>
              </target>
              <rule>
                <name value="catHSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catHCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catHCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catHCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="vital-signs"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catHDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catHCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Vital Signs"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeH"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oH"/>
              <element value="code"/>
              <variable value="codeH"/>
            </target>
            <rule>
              <name value="codeHCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeH"/>
                <element value="coding"/>
                <variable value="codeHCoding"/>
              </target>
              <rule>
                <name value="codeHSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeHCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeHCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeHCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8302-2"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeHDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeHCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Body Height"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valH"/>
            <source>
              <context value="aH"/>
              <element value="value"/>
              <variable value="hv"/>
            </source>
            <target>
              <context value="oH"/>
              <element value="value"/>
              <variable value="vH"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Quantity"/>
              </parameter>
            </target>
            <rule>
              <name value="setVal"/>
              <source>
                <context value="hv"/>
              </source>
              <target>
                <context value="vH"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="hv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setSys"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vH"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://unitsofmeasure.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vH"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="cm"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setUnit"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vH"/>
                <element value="unit"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="centimeter"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation value="Height"/>
    </rule>
    <rule>
      <name value="weightRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itW"/>
        <condition value="linkId = '29463-7'"/>
      </source>
      <rule>
        <name value="weightAns"/>
        <source>
          <context value="itW"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aW"/>
        </source>
        <rule>
          <name value="weightObs"/>
          <source>
            <context value="aW"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eW"/>
          </target>
          <target>
            <context value="eW"/>
            <element value="resource"/>
            <variable value="oW"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="weightBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oW"/>
            </target>
            <target>
              <context value="eW"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oW"/>
              </parameter>
              <parameter>
                <valueId value="eW"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="categoryW"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oW"/>
              <element value="category"/>
              <variable value="catW"/>
            </target>
            <rule>
              <name value="catWCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catW"/>
                <element value="coding"/>
                <variable value="catWCoding"/>
              </target>
              <rule>
                <name value="catWSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catWCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catWCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catWCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="vital-signs"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catWDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catWCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Vital Signs"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeW"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oW"/>
              <element value="code"/>
              <variable value="codeW"/>
            </target>
            <rule>
              <name value="codeWCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeW"/>
                <element value="coding"/>
                <variable value="codeWCoding"/>
              </target>
              <rule>
                <name value="codeWSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeWCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeWCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeWCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="29463-7"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeWDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeWCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Body Weight"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valW"/>
            <source>
              <context value="aW"/>
              <element value="value"/>
              <variable value="hv"/>
            </source>
            <target>
              <context value="oW"/>
              <element value="value"/>
              <variable value="vW"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Quantity"/>
              </parameter>
            </target>
            <rule>
              <name value="setVal"/>
              <source>
                <context value="hv"/>
              </source>
              <target>
                <context value="vW"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="hv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setSys"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vW"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://unitsofmeasure.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vW"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="kg"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setUnit"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vW"/>
                <element value="unit"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="kilogram"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation value="Weight"/>
    </rule>
    <rule>
      <name value="bmiRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itBmi"/>
        <condition value="linkId = '39156-5'"/>
      </source>
      <rule>
        <name value="bmiAns"/>
        <source>
          <context value="itBmi"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aBmi"/>
        </source>
        <rule>
          <name value="bmiObs"/>
          <source>
            <context value="aBmi"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eBmi"/>
          </target>
          <target>
            <context value="eBmi"/>
            <element value="resource"/>
            <variable value="oBmi"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="bmiBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oBmi"/>
            </target>
            <target>
              <context value="eBmi"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oBmi"/>
              </parameter>
              <parameter>
                <valueId value="eBmi"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="categoryBmi"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oBmi"/>
              <element value="category"/>
              <variable value="catBmi"/>
            </target>
            <rule>
              <name value="catBmiCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catBmi"/>
                <element value="coding"/>
                <variable value="catBmiCoding"/>
              </target>
              <rule>
                <name value="catBmiSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catBmiCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catBmiCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catBmiCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="vital-signs"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catBmiDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catBmiCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Vital Signs"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeBmi"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oBmi"/>
              <element value="code"/>
              <variable value="codeBmi"/>
            </target>
            <rule>
              <name value="codeBmiCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeBmi"/>
                <element value="coding"/>
                <variable value="codeBmiCoding"/>
              </target>
              <rule>
                <name value="codeBmiSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeBmiCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeBmiCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeBmiCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="39156-5"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeBmiDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeBmiCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Body mass index (BMI) [Ratio]"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valBmi"/>
            <source>
              <context value="aBmi"/>
              <element value="value"/>
              <variable value="hv"/>
            </source>
            <target>
              <context value="oBmi"/>
              <element value="value"/>
              <variable value="vBmi"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Quantity"/>
              </parameter>
            </target>
            <rule>
              <name value="setVal"/>
              <source>
                <context value="hv"/>
              </source>
              <target>
                <context value="vBmi"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="hv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setSys"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vBmi"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://unitsofmeasure.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vBmi"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="kg/m2"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setUnit"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vBmi"/>
                <element value="unit"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="kilogram per square meter"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="findBmiStatus"/>
            <source>
              <context value="itBmi"/>
              <element value="item"/>
              <variable value="bmiStatusItem"/>
              <condition value="linkId = '39156-5_status'"/>
            </source>
            <rule>
              <name value="setInterpBmi"/>
              <source>
                <context value="bmiStatusItem"/>
                <element value="answer"/>
                <listMode value="first"/>
                <variable value="bmiStatusAns"/>
              </source>
              <target>
                <context value="oBmi"/>
                <element value="interpretation"/>
                <variable value="iBmi"/>
              </target>
              <rule>
                <name value="interpBmi"/>
                <source>
                  <context value="bmiStatusAns"/>
                  <element value="value"/>
                  <variable value="statusText"/>
                </source>
                <target>
                  <context value="iBmi"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="statusText"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <documentation value="Interpretation 39156-5_status"/>
          </rule>
        </rule>
      </rule>
      <documentation value="BMI"/>
    </rule>
    <rule>
      <name value="pulseRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itP"/>
        <condition value="linkId = '8889-8'"/>
      </source>
      <rule>
        <name value="pulseAns"/>
        <source>
          <context value="itP"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aP"/>
        </source>
        <rule>
          <name value="pulseObs"/>
          <source>
            <context value="aP"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eP"/>
          </target>
          <target>
            <context value="eP"/>
            <element value="resource"/>
            <variable value="oP"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="pulseBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oP"/>
            </target>
            <target>
              <context value="eP"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oP"/>
              </parameter>
              <parameter>
                <valueId value="eP"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="categoryP"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oP"/>
              <element value="category"/>
              <variable value="catP"/>
            </target>
            <rule>
              <name value="catPCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catP"/>
                <element value="coding"/>
                <variable value="catPCoding"/>
              </target>
              <rule>
                <name value="catPSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catPCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catPCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catPCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="vital-signs"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catPDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catPCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Vital Signs"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeP"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oP"/>
              <element value="code"/>
              <variable value="codeP"/>
            </target>
            <rule>
              <name value="codePCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeP"/>
                <element value="coding"/>
                <variable value="codePCoding"/>
              </target>
              <rule>
                <name value="codePSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codePCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codePCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codePCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8889-8"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codePDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codePCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Heart rate by Pulse oximetry"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valP"/>
            <source>
              <context value="aP"/>
              <element value="value"/>
              <variable value="hv"/>
            </source>
            <target>
              <context value="oP"/>
              <element value="value"/>
              <variable value="vP"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Quantity"/>
              </parameter>
            </target>
            <rule>
              <name value="setVal"/>
              <source>
                <context value="hv"/>
              </source>
              <target>
                <context value="vP"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="hv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setSys"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vP"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://unitsofmeasure.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vP"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="/min"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setUnit"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vP"/>
                <element value="unit"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="per minute"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation value="Pulse"/>
    </rule>
    <rule>
      <name value="bpRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itBP"/>
        <condition value="linkId = '55284-4'"/>
      </source>
      <rule>
        <name value="bpObs"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="eBP"/>
        </target>
        <target>
          <context value="eBP"/>
          <element value="resource"/>
          <variable value="oBP"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="bpBase"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="oBP"/>
          </target>
          <target>
            <context value="eBP"/>
          </target>
          <dependent>
            <name value="BuildBaseObs"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="oBP"/>
            </parameter>
            <parameter>
              <valueId value="eBP"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="categoryBP"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="oBP"/>
            <element value="category"/>
            <variable value="catBP"/>
          </target>
          <rule>
            <name value="catBPCodingRule"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="catBP"/>
              <element value="coding"/>
              <variable value="catBPCoding"/>
            </target>
            <rule>
              <name value="catBPSys"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catBPCoding"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="catBPCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catBPCoding"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="vital-signs"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="catBPDisplay"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catBPCoding"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Vital Signs"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="codeBP"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="oBP"/>
            <element value="code"/>
            <variable value="codeBP"/>
          </target>
          <rule>
            <name value="codeBPCodingRule"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="codeBP"/>
              <element value="coding"/>
              <variable value="codeBPCoding"/>
            </target>
            <rule>
              <name value="codeBPSys"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeBPCoding"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="codeBPCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeBPCoding"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="55284-4"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="codeBPDisplay"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeBPCoding"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Blood pressure systolic and diastolic"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="bpSysRule"/>
          <source>
            <context value="itBP"/>
            <element value="item"/>
            <variable value="itSys"/>
            <condition value="linkId = '8480-6'"/>
          </source>
          <rule>
            <name value="bpSysComponent"/>
            <source>
              <context value="itSys"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="aSys"/>
            </source>
            <target>
              <context value="oBP"/>
              <element value="component"/>
              <variable value="cSys"/>
            </target>
            <rule>
              <name value="bpSysCode"/>
              <source>
                <context value="aSys"/>
              </source>
              <target>
                <context value="cSys"/>
                <element value="code"/>
                <variable value="bpSysCC"/>
              </target>
              <rule>
                <name value="bpSysCodingRule"/>
                <source>
                  <context value="aSys"/>
                </source>
                <target>
                  <context value="bpSysCC"/>
                  <element value="coding"/>
                  <variable value="bpSysCoding"/>
                </target>
                <rule>
                  <name value="bpSysCodingSystem"/>
                  <source>
                    <context value="aSys"/>
                  </source>
                  <target>
                    <context value="bpSysCoding"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="bpSysCodingCode"/>
                  <source>
                    <context value="aSys"/>
                  </source>
                  <target>
                    <context value="bpSysCoding"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="8480-6"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="bpSysCodingDisplay"/>
                  <source>
                    <context value="aSys"/>
                  </source>
                  <target>
                    <context value="bpSysCoding"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Systolic blood pressure"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="bpSysVal"/>
              <source>
                <context value="aSys"/>
                <element value="value"/>
                <variable value="hv"/>
              </source>
              <target>
                <context value="cSys"/>
                <element value="value"/>
                <variable value="vSys"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Quantity"/>
                </parameter>
              </target>
              <rule>
                <name value="setVal"/>
                <source>
                  <context value="hv"/>
                </source>
                <target>
                  <context value="vSys"/>
                  <element value="value"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="hv"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vSys"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vSys"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="mm[Hg]"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setUnit"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vSys"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="millimeter of mercury"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <documentation value="Systolic 8480-6"/>
        </rule>
        <rule>
          <name value="bpDiaRule"/>
          <source>
            <context value="itBP"/>
            <element value="item"/>
            <variable value="itDia"/>
            <condition value="linkId = '8462-4'"/>
          </source>
          <rule>
            <name value="bpDiaComponent"/>
            <source>
              <context value="itDia"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="aDia"/>
            </source>
            <target>
              <context value="oBP"/>
              <element value="component"/>
              <variable value="cDia"/>
            </target>
            <rule>
              <name value="bpDiaCode"/>
              <source>
                <context value="aDia"/>
              </source>
              <target>
                <context value="cDia"/>
                <element value="code"/>
                <variable value="bpDiaCC"/>
              </target>
              <rule>
                <name value="bpDiaCodingRule"/>
                <source>
                  <context value="aDia"/>
                </source>
                <target>
                  <context value="bpDiaCC"/>
                  <element value="coding"/>
                  <variable value="bpDiaCoding"/>
                </target>
                <rule>
                  <name value="bpDiaCodingSystem"/>
                  <source>
                    <context value="aDia"/>
                  </source>
                  <target>
                    <context value="bpDiaCoding"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="bpDiaCodingCode"/>
                  <source>
                    <context value="aDia"/>
                  </source>
                  <target>
                    <context value="bpDiaCoding"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="8462-4"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="bpDiaCodingDisplay"/>
                  <source>
                    <context value="aDia"/>
                  </source>
                  <target>
                    <context value="bpDiaCoding"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Diastolic blood pressure"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="bpDiaVal"/>
              <source>
                <context value="aDia"/>
                <element value="value"/>
                <variable value="hv"/>
              </source>
              <target>
                <context value="cDia"/>
                <element value="value"/>
                <variable value="vDia"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Quantity"/>
                </parameter>
              </target>
              <rule>
                <name value="setVal"/>
                <source>
                  <context value="hv"/>
                </source>
                <target>
                  <context value="vDia"/>
                  <element value="value"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="hv"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vDia"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vDia"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="mm[Hg]"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setUnit"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="vDia"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="millimeter of mercury"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <documentation value="Diastolic 8462-4"/>
        </rule>
      </rule>
      <documentation value="Blood Pressure"/>
    </rule>
    <rule>
      <name value="tempRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itT"/>
        <condition value="linkId = '8310-5'"/>
      </source>
      <rule>
        <name value="tempAns"/>
        <source>
          <context value="itT"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aT"/>
        </source>
        <rule>
          <name value="tempObs"/>
          <source>
            <context value="aT"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eT"/>
          </target>
          <target>
            <context value="eT"/>
            <element value="resource"/>
            <variable value="oT"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="tempBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oT"/>
            </target>
            <target>
              <context value="eT"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oT"/>
              </parameter>
              <parameter>
                <valueId value="eT"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="categoryT"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oT"/>
              <element value="category"/>
              <variable value="catT"/>
            </target>
            <rule>
              <name value="catTCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catT"/>
                <element value="coding"/>
                <variable value="catTCoding"/>
              </target>
              <rule>
                <name value="catTSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catTCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catTCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catTCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="vital-signs"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catTDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catTCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Vital Signs"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeT"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oT"/>
              <element value="code"/>
              <variable value="codeT"/>
            </target>
            <rule>
              <name value="codeTCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeT"/>
                <element value="coding"/>
                <variable value="codeTCoding"/>
              </target>
              <rule>
                <name value="codeTSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeTCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeTCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeTCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8310-5"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeTDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeTCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Body Temperature"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valT"/>
            <source>
              <context value="aT"/>
              <element value="value"/>
              <variable value="hv"/>
            </source>
            <target>
              <context value="oT"/>
              <element value="value"/>
              <variable value="vT"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Quantity"/>
              </parameter>
            </target>
            <rule>
              <name value="setVal"/>
              <source>
                <context value="hv"/>
              </source>
              <target>
                <context value="vT"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="hv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setSys"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vT"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://unitsofmeasure.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vT"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Cel"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setUnit"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vT"/>
                <element value="unit"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="degree Celsius"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="findTStatus"/>
            <source>
              <context value="itT"/>
              <element value="item"/>
              <variable value="tStatusItem"/>
              <condition value="linkId = '8310-5_status'"/>
            </source>
            <rule>
              <name value="setInterpT"/>
              <source>
                <context value="tStatusItem"/>
                <element value="answer"/>
                <listMode value="first"/>
                <variable value="tStatusAns"/>
              </source>
              <target>
                <context value="oT"/>
                <element value="interpretation"/>
                <variable value="iT"/>
              </target>
              <rule>
                <name value="interpT"/>
                <source>
                  <context value="tStatusAns"/>
                  <element value="value"/>
                  <variable value="statusText"/>
                </source>
                <target>
                  <context value="iT"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="statusText"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <documentation value="Interpretation 8310-5_status"/>
          </rule>
        </rule>
      </rule>
      <documentation value="Temperature"/>
    </rule>
    <rule>
      <name value="spo2Rule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itO2"/>
        <condition value="linkId = '20564-1'"/>
      </source>
      <rule>
        <name value="spo2Ans"/>
        <source>
          <context value="itO2"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aO2"/>
        </source>
        <rule>
          <name value="spo2Obs"/>
          <source>
            <context value="aO2"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eO2"/>
          </target>
          <target>
            <context value="eO2"/>
            <element value="resource"/>
            <variable value="oO2"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="spo2Base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oO2"/>
            </target>
            <target>
              <context value="eO2"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oO2"/>
              </parameter>
              <parameter>
                <valueId value="eO2"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="categoryO2"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oO2"/>
              <element value="category"/>
              <variable value="catO2"/>
            </target>
            <rule>
              <name value="catO2CodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catO2"/>
                <element value="coding"/>
                <variable value="catO2Coding"/>
              </target>
              <rule>
                <name value="catO2Sys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catO2Coding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catO2Code"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catO2Coding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="vital-signs"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catO2Display"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catO2Coding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Vital Signs"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeO2"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oO2"/>
              <element value="code"/>
              <variable value="codeO2"/>
            </target>
            <rule>
              <name value="codeO2CodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeO2"/>
                <element value="coding"/>
                <variable value="codeO2Coding"/>
              </target>
              <rule>
                <name value="codeO2Sys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeO2Coding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeO2Code"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeO2Coding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="20564-1"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeO2Display"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeO2Coding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Oxygen saturation in Blood"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valO2"/>
            <source>
              <context value="aO2"/>
              <element value="value"/>
              <variable value="hv"/>
            </source>
            <target>
              <context value="oO2"/>
              <element value="value"/>
              <variable value="vO2"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Quantity"/>
              </parameter>
            </target>
            <rule>
              <name value="setVal"/>
              <source>
                <context value="hv"/>
              </source>
              <target>
                <context value="vO2"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="hv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setSys"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vO2"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://unitsofmeasure.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vO2"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="%"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setUnit"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vO2"/>
                <element value="unit"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="%"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="findO2Status"/>
            <source>
              <context value="itO2"/>
              <element value="item"/>
              <variable value="o2StatusItem"/>
              <condition value="linkId = '20564-1_status'"/>
            </source>
            <rule>
              <name value="setInterpO2"/>
              <source>
                <context value="o2StatusItem"/>
                <element value="answer"/>
                <listMode value="first"/>
                <variable value="o2StatusAns"/>
              </source>
              <target>
                <context value="oO2"/>
                <element value="interpretation"/>
                <variable value="iO2"/>
              </target>
              <rule>
                <name value="interpO2"/>
                <source>
                  <context value="o2StatusAns"/>
                  <element value="value"/>
                  <variable value="statusText"/>
                </source>
                <target>
                  <context value="iO2"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="statusText"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <documentation value="Interpretation of SpO2 20564-1_status"/>
          </rule>
        </rule>
      </rule>
      <documentation value="SpO2"/>
    </rule>
    <rule>
      <name value="rrRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itRR"/>
        <condition value="linkId = '9279-1'"/>
      </source>
      <rule>
        <name value="rrAns"/>
        <source>
          <context value="itRR"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aRR"/>
        </source>
        <rule>
          <name value="rrObs"/>
          <source>
            <context value="aRR"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eRR"/>
          </target>
          <target>
            <context value="eRR"/>
            <element value="resource"/>
            <variable value="oRR"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="rrBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oRR"/>
            </target>
            <target>
              <context value="eRR"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oRR"/>
              </parameter>
              <parameter>
                <valueId value="eRR"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="categoryRR"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oRR"/>
              <element value="category"/>
              <variable value="catRR"/>
            </target>
            <rule>
              <name value="catRRCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catRR"/>
                <element value="coding"/>
                <variable value="catRRCoding"/>
              </target>
              <rule>
                <name value="catRRSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catRRCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catRRCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catRRCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="vital-signs"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catRRDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catRRCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Vital Signs"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeRR"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oRR"/>
              <element value="code"/>
              <variable value="codeRR"/>
            </target>
            <rule>
              <name value="codeRRCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeRR"/>
                <element value="coding"/>
                <variable value="codeRRCoding"/>
              </target>
              <rule>
                <name value="codeRRSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeRRCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeRRCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeRRCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="9279-1"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeRRDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeRRCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Respiratory rate"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valRR"/>
            <source>
              <context value="aRR"/>
              <element value="value"/>
              <variable value="hv"/>
            </source>
            <target>
              <context value="oRR"/>
              <element value="value"/>
              <variable value="vRR"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Quantity"/>
              </parameter>
            </target>
            <rule>
              <name value="setVal"/>
              <source>
                <context value="hv"/>
              </source>
              <target>
                <context value="vRR"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="hv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setSys"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vRR"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://unitsofmeasure.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vRR"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="/min"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setUnit"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vRR"/>
                <element value="unit"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="per minute"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation value="Respiratory rate"/>
    </rule>
    <rule>
      <name value="muacRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itMuac"/>
        <condition value="linkId = '9847-5'"/>
      </source>
      <rule>
        <name value="muacAns"/>
        <source>
          <context value="itMuac"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aMuac"/>
        </source>
        <rule>
          <name value="muacObs"/>
          <source>
            <context value="aMuac"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eMuac"/>
          </target>
          <target>
            <context value="eMuac"/>
            <element value="resource"/>
            <variable value="oMuac"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="muacBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oMuac"/>
            </target>
            <target>
              <context value="eMuac"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oMuac"/>
              </parameter>
              <parameter>
                <valueId value="eMuac"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="categoryMuac"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oMuac"/>
              <element value="category"/>
              <variable value="catMuac"/>
            </target>
            <rule>
              <name value="catMuacCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catMuac"/>
                <element value="coding"/>
                <variable value="catMuacCoding"/>
              </target>
              <rule>
                <name value="catMuacSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catMuacCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catMuacCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catMuacCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="vital-signs"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catMuacDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catMuacCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Vital Signs"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeMuac"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oMuac"/>
              <element value="code"/>
              <variable value="codeMuac"/>
            </target>
            <rule>
              <name value="codeMuacCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeMuac"/>
                <element value="coding"/>
                <variable value="codeMuacCoding"/>
              </target>
              <rule>
                <name value="codeMuacSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeMuacCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeMuacCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeMuacCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="9847-5"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeMuacDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeMuacCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Circumference"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valMuac"/>
            <source>
              <context value="aMuac"/>
              <element value="value"/>
              <variable value="hv"/>
            </source>
            <target>
              <context value="oMuac"/>
              <element value="value"/>
              <variable value="vMuac"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Quantity"/>
              </parameter>
            </target>
            <rule>
              <name value="setVal"/>
              <source>
                <context value="hv"/>
              </source>
              <target>
                <context value="vMuac"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="hv"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setSys"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vMuac"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://unitsofmeasure.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setCode"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vMuac"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="mm"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setUnit"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="vMuac"/>
                <element value="unit"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="millimeter"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation value="MUAC"/>
    </rule>
    <rule>
      <name value="chiefComplaintRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itCC"/>
        <condition value="linkId = '10154-3'"/>
      </source>
      <rule>
        <name value="chiefComplaintAns"/>
        <source>
          <context value="itCC"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aCC"/>
        </source>
        <rule>
          <name value="chiefComplaintObs"/>
          <source>
            <context value="aCC"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eCC"/>
          </target>
          <target>
            <context value="eCC"/>
            <element value="resource"/>
            <variable value="oCC"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="chiefComplaintBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
            </target>
            <target>
              <context value="eCC"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oCC"/>
              </parameter>
              <parameter>
                <valueId value="eCC"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="chiefComplaintCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="category"/>
              <variable value="catCC"/>
            </target>
            <rule>
              <name value="catCCCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catCC"/>
                <element value="coding"/>
                <variable value="catCCCoding"/>
              </target>
              <rule>
                <name value="catCCSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catCCCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catCCCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catCCCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="social-history"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catCCDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catCCCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Social History"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="chiefComplaintCode"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="code"/>
              <variable value="codeCC"/>
            </target>
            <rule>
              <name value="codeCCCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeCC"/>
                <element value="coding"/>
                <variable value="codeCCCoding"/>
              </target>
              <rule>
                <name value="codeCCSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeCCCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeCCCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeCCCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10154-3"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeCCDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeCCCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="Chief complaint Narrative - Reported"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="chiefComplaintValue"/>
            <source>
              <context value="aCC"/>
              <element value="value"/>
              <variable value="textVal"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="textVal"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation value="Chief Complaint"/>
    </rule>
    <rule>
      <name value="historyOfPIRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="hpiCC"/>
        <condition value="linkId = '8684-3'"/>
      </source>
      <rule>
        <name value="historyOfPIAns"/>
        <source>
          <context value="hpiCC"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aCC"/>
        </source>
        <rule>
          <name value="historyOfPIObs"/>
          <source>
            <context value="aCC"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eCC"/>
          </target>
          <target>
            <context value="eCC"/>
            <element value="resource"/>
            <variable value="oCC"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="historyOfPIBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
            </target>
            <target>
              <context value="eCC"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oCC"/>
              </parameter>
              <parameter>
                <valueId value="eCC"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="historyOfPICategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="category"/>
              <variable value="catHPI"/>
            </target>
            <rule>
              <name value="catHPICodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catHPI"/>
                <element value="coding"/>
                <variable value="catHPICoding"/>
              </target>
              <rule>
                <name value="catHPISys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catHPICoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catHPICode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catHPICoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="social-history"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catHPIDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catHPICoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Social History"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="historyOfPICode"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="code"/>
              <variable value="codeHPI"/>
            </target>
            <rule>
              <name value="codeHPICodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeHPI"/>
                <element value="coding"/>
                <variable value="codeHPICoding"/>
              </target>
              <rule>
                <name value="codeHPISys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeHPICoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeHPICode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeHPICoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8684-3"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeHPIDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeHPICoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="History of Present illness"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="historyOfPIValue"/>
            <source>
              <context value="aCC"/>
              <element value="value"/>
              <variable value="textVal"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="textVal"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation value="History of Presenting Illness"/>
    </rule>
    <rule>
      <name value="historyOfPastIRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="hPastCC"/>
        <condition value="linkId = '11349-8'"/>
      </source>
      <rule>
        <name value="historyOfPastIAns"/>
        <source>
          <context value="hPastCC"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aCC"/>
        </source>
        <rule>
          <name value="historyOfPastIObs"/>
          <source>
            <context value="aCC"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eCC"/>
          </target>
          <target>
            <context value="eCC"/>
            <element value="resource"/>
            <variable value="oCC"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="historyOfPastIBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
            </target>
            <target>
              <context value="eCC"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oCC"/>
              </parameter>
              <parameter>
                <valueId value="eCC"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="historyOfPastICategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="category"/>
              <variable value="catPastI"/>
            </target>
            <rule>
              <name value="catPastICodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catPastI"/>
                <element value="coding"/>
                <variable value="catPastICoding"/>
              </target>
              <rule>
                <name value="catPastISys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catPastICoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catPastICode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catPastICoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="social-history"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catPastIDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catPastICoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Social History"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="historyOfPastICode"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="code"/>
              <variable value="codePastI"/>
            </target>
            <rule>
              <name value="codePastICodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codePastI"/>
                <element value="coding"/>
                <variable value="codePastICoding"/>
              </target>
              <rule>
                <name value="codePastISys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codePastICoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codePastICode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codePastICoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="11349-8"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codePastIDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codePastICoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="History of Past illness"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="historyOfPastIValue"/>
            <source>
              <context value="aCC"/>
              <element value="value"/>
              <variable value="textVal"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="textVal"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation value="History of Past Illness / Past Medical History"/>
    </rule>
    <rule>
      <name value="familyHIRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="hFH"/>
        <condition value="linkId = '8670-2'"/>
      </source>
      <rule>
        <name value="familyHIAns"/>
        <source>
          <context value="hFH"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aCC"/>
        </source>
        <rule>
          <name value="familyHIObs"/>
          <source>
            <context value="aCC"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eCC"/>
          </target>
          <target>
            <context value="eCC"/>
            <element value="resource"/>
            <variable value="oCC"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="familyFHIBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
            </target>
            <target>
              <context value="eCC"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oCC"/>
              </parameter>
              <parameter>
                <valueId value="eCC"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="familyHICategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="category"/>
              <variable value="catFH"/>
            </target>
            <rule>
              <name value="catFHCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catFH"/>
                <element value="coding"/>
                <variable value="catFHCoding"/>
              </target>
              <rule>
                <name value="catFHSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catFHCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catFHCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catFHCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="social-history"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catFHDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catFHCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Social History"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="familyHICode"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="code"/>
              <variable value="codeFH"/>
            </target>
            <rule>
              <name value="codeFHCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeFH"/>
                <element value="coding"/>
                <variable value="codeFHCoding"/>
              </target>
              <rule>
                <name value="codeFHSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeFHCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeFHCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeFHCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8670-2"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeFHDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeFHCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="History of family member diseases"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="familyHIValue"/>
            <source>
              <context value="aCC"/>
              <element value="value"/>
              <variable value="textVal"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="textVal"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation value="Family History"/>
    </rule>
    <rule>
      <name value="socialHistoryIRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="hSH"/>
        <condition value="linkId = '29762-2'"/>
      </source>
      <rule>
        <name value="socialHistoryIAns"/>
        <source>
          <context value="hSH"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aCC"/>
        </source>
        <rule>
          <name value="socialHistoryIObs"/>
          <source>
            <context value="aCC"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eCC"/>
          </target>
          <target>
            <context value="eCC"/>
            <element value="resource"/>
            <variable value="oCC"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="socialHistoryIBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
            </target>
            <target>
              <context value="eCC"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oCC"/>
              </parameter>
              <parameter>
                <valueId value="eCC"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="socialHistoryCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="category"/>
              <variable value="catSH"/>
            </target>
            <rule>
              <name value="catSHCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catSH"/>
                <element value="coding"/>
                <variable value="catSHCoding"/>
              </target>
              <rule>
                <name value="catSHSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catSHCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catSHCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catSHCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="social-history"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catSHDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catSHCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Social History"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="socialHistoryCode"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="code"/>
              <variable value="codeSH"/>
            </target>
            <rule>
              <name value="codeSHCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeSH"/>
                <element value="coding"/>
                <variable value="codeSHCoding"/>
              </target>
              <rule>
                <name value="codeSHSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeSHCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeSHCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeSHCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="29762-2"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeSHDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeSHCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Social history note"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="socialHistoryIValue"/>
            <source>
              <context value="aCC"/>
              <element value="value"/>
              <variable value="textVal"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="textVal"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation value="Social History"/>
    </rule>
    <rule>
      <name value="medicationHistoryIRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="medicationH"/>
        <condition value="linkId = '10160-0'"/>
      </source>
      <rule>
        <name value="medicationHistoryIAns"/>
        <source>
          <context value="medicationH"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aCC"/>
        </source>
        <rule>
          <name value="medicationHistoryIObs"/>
          <source>
            <context value="aCC"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eCC"/>
          </target>
          <target>
            <context value="eCC"/>
            <element value="resource"/>
            <variable value="oCC"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="medicationHIBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
            </target>
            <target>
              <context value="eCC"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oCC"/>
              </parameter>
              <parameter>
                <valueId value="eCC"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="medicationHCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="category"/>
              <variable value="catMedH"/>
            </target>
            <rule>
              <name value="catMedHCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catMedH"/>
                <element value="coding"/>
                <variable value="catMedHCoding"/>
              </target>
              <rule>
                <name value="catMedHSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catMedHCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catMedHCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catMedHCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="therapy"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catMedHDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catMedHCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Therapy"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="medicationHistoryCode"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="code"/>
              <variable value="codeMedH"/>
            </target>
            <rule>
              <name value="codeMedHCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeMedH"/>
                <element value="coding"/>
                <variable value="codeMedHCoding"/>
              </target>
              <rule>
                <name value="codeMedHSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeMedHCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeMedHCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeMedHCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10160-0"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeMedHDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeMedHCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="History of Medication use Narrative"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="medicationHistoryIValue"/>
            <source>
              <context value="aCC"/>
              <element value="value"/>
              <variable value="textVal"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="textVal"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation value="Medication History"/>
    </rule>
    <rule>
      <name value="riskFactorsRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="riskF"/>
        <condition value="linkId = '46467-7'"/>
      </source>
      <rule>
        <name value="riskFactorsAns"/>
        <source>
          <context value="riskF"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aCC"/>
        </source>
        <rule>
          <name value="riskFactorsObs"/>
          <source>
            <context value="aCC"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eCC"/>
          </target>
          <target>
            <context value="eCC"/>
            <element value="resource"/>
            <variable value="oCC"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="riskFactorsBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
            </target>
            <target>
              <context value="eCC"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oCC"/>
              </parameter>
              <parameter>
                <valueId value="eCC"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="riskFactorsCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="category"/>
              <variable value="catRF"/>
            </target>
            <rule>
              <name value="catRFCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="catRF"/>
                <element value="coding"/>
                <variable value="catRFCoding"/>
              </target>
              <rule>
                <name value="catRFSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catRFCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catRFCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catRFCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="social-history"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="catRFDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="catRFCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Social History"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="riskFactorsCode"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="code"/>
              <variable value="codeRF"/>
            </target>
            <rule>
              <name value="codeRFCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeRF"/>
                <element value="coding"/>
                <variable value="codeRFCoding"/>
              </target>
              <rule>
                <name value="codeRFSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeRFCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeRFCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeRFCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="46467-7"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeRFDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeRFCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Risk factors"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="riskFactorsValue"/>
            <source>
              <context value="aCC"/>
              <element value="value"/>
              <variable value="textVal"/>
            </source>
            <target>
              <context value="oCC"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="textVal"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation value="Risk Factors"/>
    </rule>
    <rule>
      <name value="painAtRestRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itPar"/>
        <condition value="linkId = 'painAtRest'"/>
      </source>
      <rule>
        <name value="painAtRestAns"/>
        <source>
          <context value="itPar"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aPar"/>
        </source>
        <rule>
          <name value="painAtRestObs"/>
          <source>
            <context value="aPar"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="ePar"/>
          </target>
          <target>
            <context value="ePar"/>
            <element value="resource"/>
            <variable value="oPar"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="painAtRestBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oPar"/>
            </target>
            <target>
              <context value="ePar"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oPar"/>
              </parameter>
              <parameter>
                <valueId value="ePar"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="painAtRestCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oPar"/>
            </target>
            <dependent>
              <name value="SetExamCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oPar"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="codePar"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oPar"/>
              <element value="code"/>
              <variable value="codePar"/>
            </target>
            <rule>
              <name value="codeParCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codePar"/>
                <element value="coding"/>
                <variable value="codeParCoding"/>
              </target>
              <rule>
                <name value="codeParSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeParCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeParCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeParCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="99302-2"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeParDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeParCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Verbal complaints while at rest"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valPar"/>
            <source>
              <context value="aPar"/>
              <element value="value"/>
              <variable value="pv"/>
            </source>
            <target>
              <context value="oPar"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="pv"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="painAtRestSite"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oPar"/>
            </target>
            <dependent>
              <name value="SetPainBodySite"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oPar"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="───────────────────────────────────────────────────────────────────────────
Admissions observation templates.
These forms carry the design's own field ids as linkIds rather than the LOINC
codes the rules above match on, so the linkId and the Observation.code are
stated separately. Everything they produce is category `exam` - a reading
taken at the bedside as part of assessing the patient, not a lab result and
not a vital sign.
───────────────────────────────────────────────────────────────────────────
Pain score - pain at rest"/>
    </rule>
    <rule>
      <name value="painOnMovementRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itPom"/>
        <condition value="linkId = 'painOnMovement'"/>
      </source>
      <rule>
        <name value="painOnMovementAns"/>
        <source>
          <context value="itPom"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aPom"/>
        </source>
        <rule>
          <name value="painOnMovementObs"/>
          <source>
            <context value="aPom"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="ePom"/>
          </target>
          <target>
            <context value="ePom"/>
            <element value="resource"/>
            <variable value="oPom"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="painOnMovementBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oPom"/>
            </target>
            <target>
              <context value="ePom"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oPom"/>
              </parameter>
              <parameter>
                <valueId value="ePom"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="painOnMovementCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oPom"/>
            </target>
            <dependent>
              <name value="SetExamCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oPom"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="codePom"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oPom"/>
              <element value="code"/>
              <variable value="codePom"/>
            </target>
            <rule>
              <name value="codePomCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codePom"/>
                <element value="coding"/>
                <variable value="codePomCoding"/>
              </target>
              <rule>
                <name value="codePomSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codePomCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codePomCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codePomCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="99294-1"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codePomDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codePomCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Verbal complaints during movement"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valPom"/>
            <source>
              <context value="aPom"/>
              <element value="value"/>
              <variable value="pv"/>
            </source>
            <target>
              <context value="oPom"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="pv"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="painOnMovementSite"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oPom"/>
            </target>
            <dependent>
              <name value="SetPainBodySite"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oPom"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <documentation value="Pain score - pain on movement"/>
    </rule>
    <rule>
      <name value="capillaryGlucoseRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itCg"/>
        <condition value="linkId = 'capillaryGlucose'"/>
      </source>
      <rule>
        <name value="capillaryGlucoseAns"/>
        <source>
          <context value="itCg"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aCg"/>
        </source>
        <rule>
          <name value="capillaryGlucoseObs"/>
          <source>
            <context value="aCg"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eCg"/>
          </target>
          <target>
            <context value="eCg"/>
            <element value="resource"/>
            <variable value="oCg"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="capillaryGlucoseBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCg"/>
            </target>
            <target>
              <context value="eCg"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oCg"/>
              </parameter>
              <parameter>
                <valueId value="eCg"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="capillaryGlucoseCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCg"/>
            </target>
            <dependent>
              <name value="SetExamCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oCg"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="codeCg"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oCg"/>
              <element value="code"/>
              <variable value="codeCg"/>
            </target>
            <rule>
              <name value="codeCgCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeCg"/>
                <element value="coding"/>
                <variable value="codeCgCoding"/>
              </target>
              <rule>
                <name value="codeCgSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeCgCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeCgCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeCgCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="14743-9"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeCgDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeCgCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="Glucose [Moles/volume] in Capillary blood by Glucometer"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valCg"/>
            <source>
              <context value="aCg"/>
              <element value="value"/>
              <variable value="gv"/>
            </source>
            <target>
              <context value="oCg"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="gv"/>
              </parameter>
            </target>
            <documentation
                           value="The answer is already a Quantity - the item is type `quantity` with
questionnaire-unitOption pinning mmol/L - so copy it through whole. The
vitals rules above rebuild a Quantity because their answers are bare
decimals; rebuilding here would mean restating the unit, and restating a
unit the client actually sent turns a wrong unit into a wrong reading."/>
          </rule>
        </rule>
      </rule>
      <documentation value="Blood glucose - capillary glucose"/>
    </rule>
    <rule>
      <name value="insulinGivenRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itIns"/>
        <condition value="linkId = 'insulinGiven'"/>
      </source>
      <rule>
        <name value="insulinGivenAns"/>
        <source>
          <context value="itIns"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aIns"/>
        </source>
        <rule>
          <name value="insulinGivenObs"/>
          <source>
            <context value="aIns"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="eIns"/>
          </target>
          <target>
            <context value="eIns"/>
            <element value="resource"/>
            <variable value="oIns"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="insulinGivenBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oIns"/>
            </target>
            <target>
              <context value="eIns"/>
            </target>
            <dependent>
              <name value="BuildBaseObs"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oIns"/>
              </parameter>
              <parameter>
                <valueId value="eIns"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="insulinGivenCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oIns"/>
            </target>
            <dependent>
              <name value="SetExamCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="oIns"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="codeIns"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="oIns"/>
              <element value="code"/>
              <variable value="codeIns"/>
            </target>
            <rule>
              <name value="codeInsCodingRule"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="codeIns"/>
                <element value="coding"/>
                <variable value="codeInsCoding"/>
              </target>
              <rule>
                <name value="codeInsSys"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeInsCoding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeInsCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeInsCoding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="4287-9"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeInsDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="codeInsCoding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Insulin regular [Mass] of Dose"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="valIns"/>
            <source>
              <context value="aIns"/>
              <element value="value"/>
              <variable value="iv"/>
            </source>
            <target>
              <context value="oIns"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="iv"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation
                     value="Blood glucose - insulin given against the reading.
4287-9 is &quot;Insulin regular [Mass] of Dose&quot;: PROPERTY Mass, SCALE_TYP Qn. The
form captures free text (&quot;4 units Actrapid&quot;), and insulin is dosed in
international units rather than by mass, so the answer lands in valueString
rather than the Quantity the code implies. It records what the nurse wrote,
which is the point; a mass in mg is not what anyone is charting."/>
    </rule>
  </group>
  <group>
    <name value="SetExamCategory"/>
    <documentation
                   value="Category `exam`, shared by every observation the admissions templates produce."/>
    <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="examCategory"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="examCodingRule"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="catCoding"/>
        </target>
        <rule>
          <name value="examSys"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="catCoding"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="examCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="catCoding"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="exam"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="examDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="catCoding"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Exam"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetPainBodySite"/>
    <documentation
                   value="The pain form asks for one site covering both scores, so it lands on each of
the two Observations. It is free text today, hence bodySite.text rather than a
coding; swap to bodySite.coding once the picker's option list is coded."/>
    <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="siteRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="siteItem"/>
        <condition value="linkId = 'site'"/>
      </source>
      <rule>
        <name value="siteAns"/>
        <source>
          <context value="siteItem"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="siteAns"/>
        </source>
        <rule>
          <name value="bodySite"/>
          <source>
            <context value="siteAns"/>
            <element value="value"/>
            <variable value="siteVal"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="bodySite"/>
            <variable value="bs"/>
          </target>
          <rule>
            <name value="bodySiteText"/>
            <source>
              <context value="siteVal"/>
            </source>
            <target>
              <context value="bs"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="siteVal"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="BuildBaseObs"/>
    <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="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="timeTakenRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="tItem"/>
        <condition value="linkId = 'timeTaken'"/>
      </source>
      <rule>
        <name value="timeTakenAns"/>
        <source>
          <context value="tItem"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="tAns"/>
        </source>
        <rule>
          <name value="effectiveFromTimeTaken"/>
          <source>
            <context value="tAns"/>
            <element value="value"/>
            <variable value="tv"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="effective"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="tv"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <documentation
                     value="`effective`, not `effectiveDateTime`: the R5 transform engine writes choice
elements by their base name and rejects the typed form with &quot;Attempt to write
to invalid property 'effectiveDateTime' on type Observation&quot;. The value is a
dateTime, so the engine picks effectiveDateTime itself.
The admissions templates ask for the time the reading was taken, which is the
clinically meaningful one - a nurse writing up at the end of a round would
otherwise stamp every reading with the moment they saved the form. Fall back
to `authored` for the forms that do not ask."/>
    </rule>
    <rule>
      <name value="authoredFallback"/>
      <source>
        <context value="qr"/>
        <condition
                   value="item.where(linkId = 'timeTaken').answer.value.exists().not()"/>
      </source>
      <rule>
        <name value="effectiveFromAuthored"/>
        <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>
    <rule>
      <name value="performer"/>
      <source>
        <context value="qr"/>
        <element value="source"/>
        <variable value="src"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="performer"/>
        <variable value="perf"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <rule>
        <name value="perfRef"/>
        <source>
          <context value="src"/>
          <element value="reference"/>
          <variable value="ref"/>
        </source>
        <target>
          <context value="perf"/>
          <element value="reference"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="ref"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="perfDisplay"/>
        <source>
          <context value="src"/>
          <element value="display"/>
          <variable value="disp"/>
        </source>
        <target>
          <context value="perf"/>
          <element value="display"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="disp"/>
          </parameter>
        </target>
      </rule>
      <documentation value="Performer from QuestionnaireResponse.source"/>
    </rule>
    <rule>
      <name value="setObsIdAndFullUrl"/>
      <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>
      <documentation value="Observation id and fullUrl"/>
    </rule>
    <rule>
      <name value="entryRequest"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="request"/>
        <variable value="request"/>
      </target>
      <rule>
        <name value="reqMethod"/>
        <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="reqUrl"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
      </rule>
      <documentation
                     value="Bundle.entry.request (transaction POST Observation)"/>
    </rule>
    <rule>
      <name value="linkQR"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="derivedFrom"/>
        <variable value="newRef"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <rule>
        <name value="setQRRef"/>
        <source>
          <context value="qr"/>
          <element value="id"/>
          <variable value="qid"/>
        </source>
        <target>
          <context value="newRef"/>
          <element value="reference"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="qid"/>
          </parameter>
        </target>
      </rule>
      <documentation
                     value="Link Observation -&gt; QuestionnaireResponse.
No append: under this engine `qr.id` already resolves to the type-qualified
relative reference (&quot;QuestionnaireResponse/xyz&quot;), so prefixing it again
produced &quot;QuestionnaireResponse/QuestionnaireResponse/xyz&quot; - a reference that
resolves to nothing."/>
    </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>
</StructureMap>