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

<StructureMap xmlns="http://hl7.org/fhir">
  <id value="ExtractSurgicalSafetyChecklist"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap ExtractSurgicalSafetyChecklist</b></p><a name="ExtractSurgicalSafetyChecklist"> </a><a name="hcExtractSurgicalSafetyChecklist"> </a><pre class="fml">
<span style="color: #cc00cc">/// <b>url</b> = </span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractSurgicalSafetyChecklist'</span>
<span style="color: #cc00cc">/// <b>name</b> = </span><span style="color: blue">'ExtractSurgicalSafetyChecklist'</span>
<span style="color: #cc00cc">/// <b>title</b> = </span><span style="color: blue">'Surgical Safety Checklist Extraction'</span>
<span style="color: #cc00cc">/// <b>status</b> = </span><span style="color: blue">'active'</span>
<span style="color: #cc00cc">/// <b>description</b> = </span><span style="color: blue">'The checklist out as one Observation per WHO phase, so a sign-out that never happened is a missing resource rather than a resource full of blanks -- which is the only shape that lets a compliance audit tell an unperformed phase from an unticked one. The ward\'s pre-operative preparation and post-operative checks become two further panels, every investigation ticked becomes a ServiceRequest, the vital signs before and after theatre become their own Observations tagged with which side of theatre they were taken on, and the instrument count gets an Observation of its own because a wrong count is a never event.'</span>

<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/questionnaireresponse.html" title="QuestionnaireResponse">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style="color: navy">&quot; </span><b>alias </b>QR <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/bundle.html" title="Bundle">http://hl7.org/fhir/StructureDefinition/Bundle</a><span style="color: navy">&quot; </span><b>alias </b>Bundle <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/observation.html" title="Observation">http://hl7.org/fhir/StructureDefinition/Observation</a><span style="color: navy">&quot; </span><b>alias </b>Observation <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/servicerequest.html" title="ServiceRequest">http://hl7.org/fhir/StructureDefinition/ServiceRequest</a><span style="color: navy">&quot; </span><b>alias </b>ServiceRequest <b>as </b><b>target</b>

<b>group </b>ExtractSurgicalSafetyChecklist<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">── The three WHO phases ────────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">One Observation each. This is the whole design decision on this form: a</span>
  <span style="color: navy">// </span><span style="color: green">single Observation with twenty-two components could not distinguish &quot;the</span>
  <span style="color: navy">// </span><span style="color: green">team did the sign-out and confirmed nothing&quot; from &quot;the team never did the</span>
  <span style="color: navy">// </span><span style="color: green">sign-out&quot;, and those are a documentation lapse and a safety failure</span>
  <span style="color: navy">// </span><span style="color: green">respectively.</span>
  <span style="color: navy">// </span><span style="color: green">Each phase is guarded on at least one of its own items being answered, and</span>
  <span style="color: navy">// </span><span style="color: green">carries `Observation.effective` from the phase's own completion time when</span>
  <span style="color: navy">// </span><span style="color: green">the team recorded one, so the interval between induction and incision is</span>
  <span style="color: navy">// </span><span style="color: green">recoverable.</span>
  qr.item<b> as </b><span style="color: maroon">wg</span><b> where </b><span style="color: navy">(</span>linkId = 'who-checklist'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    wg.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-in') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'surgical-safety-phase'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Surgical safety checklist phase'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'Sign in — before induction of anaesthesia'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>obs.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vc</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>vc.coding<b> as </b><span style="color: maroon">vcg</span><b> then</b><span style="color: navy"> {
</span>          g<span style="color: navy"><b> -&gt; </b></span>vcg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/answer-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>vcg.code = <span style="color: blue">'phase-sign-in'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>vcg.display = <span style="color: blue">'Sign in — before induction of anaesthesia'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;phaseValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">The phase's own completion time, not the form's authored time.</span>
      g.item<b> as </b><span style="color: maroon">ct</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-in/completed-at') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        ct.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: maroon">t</span> <i>&quot;phaseEffective&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;phaseTime&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-in/identity-site-procedure-consent') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-patient-confirmed-identity-site-procedure-and'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Patient confirmed identity, site, procedure and consent'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_patient_confirmed_identity_site_procedure_and&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-in/site-marked') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-site-marked'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Site marked'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_site_marked&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-in/anaesthesia-machine-and-medication-check') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-anaesthesia-machine-and-medication-check-complete'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Anaesthesia machine and medication check complete'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_anaesthesia_machine_and_medication_check_complete&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-in/pulse-oximeter-on-and-functioning') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-pulse-oximeter-on-the-patient-and-functioning'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Pulse oximeter on the patient and functioning'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_pulse_oximeter_on_the_patient_and_functioning&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-in/known-allergy-reviewed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-known-allergy-reviewed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Known allergy reviewed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_known_allergy_reviewed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-in/difficult-airway-or-aspiration-risk') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-difficult-airway-or-aspiration-risk-assessed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Difficult airway or aspiration risk assessed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_difficult_airway_or_aspiration_risk_assessed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-in/blood-loss-risk-over-500ml') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-risk-of-over-500-ml-blood-loss-assessed-access-and'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Risk of over 500 ml blood loss assessed, access and fluids planned'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_risk_of_over_500_ml_blood_loss_assessed_access_and&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;phase_sign_in&quot;</i><span style="color: navy">;</span>
    wg.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'surgical-safety-phase'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Surgical safety checklist phase'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'Time out — before skin incision'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>obs.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vc</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>vc.coding<b> as </b><span style="color: maroon">vcg</span><b> then</b><span style="color: navy"> {
</span>          g<span style="color: navy"><b> -&gt; </b></span>vcg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/answer-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>vcg.code = <span style="color: blue">'phase-time-out'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>vcg.display = <span style="color: blue">'Time out — before skin incision'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;phaseValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">The phase's own completion time, not the form's authored time.</span>
      g.item<b> as </b><span style="color: maroon">ct</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/completed-at') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        ct.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: maroon">t</span> <i>&quot;phaseEffective&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;phaseTime2&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/team-introductions') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-all-team-members-introduced-by-name-and-role'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'All team members introduced by name and role'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_all_team_members_introduced_by_name_and_role&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/confirm-patient-procedure-incision') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-patient-procedure-and-incision-site-confirmed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Patient, procedure and incision site confirmed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_patient_procedure_and_incision_site_confirmed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/antibiotic-prophylaxis-within-60-minutes') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-antibiotic-prophylaxis-given-within-the-last-60'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Antibiotic prophylaxis given within the last 60 minutes'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_antibiotic_prophylaxis_given_within_the_last_60&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/critical-steps-reviewed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-critical-or-non-routine-steps-reviewed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Critical or non-routine steps reviewed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_critical_or_non_routine_steps_reviewed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/case-duration-reviewed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-case-duration-reviewed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Case duration reviewed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_case_duration_reviewed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/anticipated-blood-loss-reviewed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-anticipated-blood-loss-reviewed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Anticipated blood loss reviewed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_anticipated_blood_loss_reviewed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/anaesthetist-patient-specific-concerns') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-anaesthetist-s-patient-specific-concerns-reviewed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Anaesthetist\'s patient-specific concerns reviewed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_anaesthetist_s_patient_specific_concerns_reviewed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/sterility-confirmed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-sterility-including-indicator-results-confirmed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Sterility, including indicator results, confirmed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_sterility_including_indicator_results_confirmed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/equipment-issues-reviewed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-equipment-issues-or-concerns-reviewed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Equipment issues or concerns reviewed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_equipment_issues_or_concerns_reviewed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/time-out/essential-imaging-displayed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-essential-imaging-displayed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Essential imaging displayed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_essential_imaging_displayed&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;phase_time_out&quot;</i><span style="color: navy">;</span>
    wg.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-out') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'surgical-safety-phase'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Surgical safety checklist phase'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'Sign out — before the patient leaves the operating room'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>obs.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vc</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>vc.coding<b> as </b><span style="color: maroon">vcg</span><b> then</b><span style="color: navy"> {
</span>          g<span style="color: navy"><b> -&gt; </b></span>vcg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/answer-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>vcg.code = <span style="color: blue">'phase-sign-out'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>vcg.display = <span style="color: blue">'Sign out — before the patient leaves the operating room'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;phaseValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">The phase's own completion time, not the form's authored time.</span>
      g.item<b> as </b><span style="color: maroon">ct</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-out/completed-at') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        ct.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: maroon">t</span> <i>&quot;phaseEffective&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;phaseTime3&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-out/procedure-name-recorded') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-name-of-the-procedure-verbally-confirmed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Name of the procedure verbally confirmed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_name_of_the_procedure_verbally_confirmed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-out/counts-complete') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-instrument-sponge-and-needle-counts-complete'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Instrument, sponge and needle counts complete'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_instrument_sponge_and_needle_counts_complete&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-out/specimen-labelling') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-specimen-labelling-read-aloud-including-the-patient'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Specimen labelling read aloud, including the patient name'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_specimen_labelling_read_aloud_including_the_patient&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-out/equipment-problems-addressed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-equipment-problems-to-be-addressed-identified'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Equipment problems to be addressed identified'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_equipment_problems_to_be_addressed_identified&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-out/recovery-key-concerns') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-key-concerns-for-recovery-and-management-reviewed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Key concerns for recovery and management reviewed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_who_check_key_concerns_for_recovery_and_management_reviewed&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;phase_sign_out&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;whoChecklistGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── The instrument, sponge and needle count ─────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">Lifted out of the sign-out panel into an Observation of its own. An</span>
  <span style="color: navy">// </span><span style="color: green">incorrect count is a never event and a retained item is a serious incident;</span>
  <span style="color: navy">// </span><span style="color: green">a fact that triggers an incident report has to be findable by its own code</span>
  <span style="color: navy">// </span><span style="color: green">and not only by reading a twenty-two-component panel.</span>
  qr.item<b> as </b><span style="color: maroon">wg</span><b> where </b><span style="color: navy">(</span>linkId = 'who-checklist'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    wg.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'who-checklist/sign-out'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'who-checklist/sign-out/counts-complete') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'instrument-count-complete'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Instrument, sponge and needle count complete'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">cv</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">vc</span><b> then</b><span style="color: navy"> {
</span>            cv<span style="color: navy"><b> -&gt; </b></span>vc.coding = <span style="color: maroon">cv</span> <i>&quot;valueCoding&quot;</i><span style="color: navy">;</span>
            cv.display<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -&gt; </b></span>vc.text = <span style="color: maroon">d</span> <i>&quot;valueText&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codedValue&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Anything other than a confirmed count is abnormal. Stated, not left</span>
        <span style="color: navy">// </span><span style="color: green">to a reader: this is the flag a theatre audit filters on.</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">cv</span><b> where </b><span style="color: navy">(</span>code != 'check-confirmed'<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.interpretation<b> as </b><span style="color: maroon">interp</span><b> then</b><span style="color: navy"> {
</span>            cv<span style="color: navy"><b> -&gt; </b></span>interp.coding<b> as </b><span style="color: maroon">icg</span><b> then</b><span style="color: navy"> {
</span>              cv<span style="color: navy"><b> -&gt; </b></span>icg.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              cv<span style="color: navy"><b> -&gt; </b></span>icg.code = <span style="color: blue">'A'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              cv<span style="color: navy"><b> -&gt; </b></span>icg.display = <span style="color: blue">'Abnormal'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;abnormal&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;countInterpretation&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;instrumentCountObservation&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;signOutSub&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;instrumentCountGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── The ward's pre-operative preparation ────────────────────────────────</span>
  qr.item<b> as </b><span style="color: maroon">pg</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    pg.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/preparation') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preoperative-preparation'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Pre-operative preparation completed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/preparation/fasting') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-fasting'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Fasting'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_fasting&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/preparation/dentures-removed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-dentures-removed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Dentures removed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_dentures_removed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/preparation/jewellery-removed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-jewellery-removed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Jewellery removed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_jewellery_removed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/preparation/artificial-limb-removed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-artificial-limb-removed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Artificial limb removed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_artificial_limb_removed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/preparation/nail-varnish-removed') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-nail-varnish-removed'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Nail varnish removed'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_nail_varnish_removed&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/preparation/shaving') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-shaving'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Shaving'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_shaving&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/preparation/bath') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-bath'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Bath'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_bath&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/preparation/theatre-gown') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-theatre-gown'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Theatre gown'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_theatre_gown&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/preparation/skin-cleaned') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-skin-cleaned'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Skin cleaned'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_skin_cleaned&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;preparationPanel&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Lines and tubes in place. A separate panel from the preparation checklist</span>
    <span style="color: navy">// </span><span style="color: green">because these are devices the theatre has to know about, not tasks the</span>
    <span style="color: navy">// </span><span style="color: green">ward has to have finished.</span>
    pg.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/lines') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetExamCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-lines-and-tubes-in-place-before-theatre'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Lines and tubes in place before theatre'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/lines/catheter') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-catheter'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Catheter'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_catheter&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/lines/nasogastric-tube') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-nasogastric-tube'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Nasogastric tube'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_nasogastric_tube&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/lines/intravenous-infusion') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-intravenous-infusion'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Intravenous infusion'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_intravenous_infusion&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative/lines/other'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;note&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;linesPanel&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Blood requested, and how many pints are actually available. Two facts, and</span>
    <span style="color: navy">// </span><span style="color: green">the second is the one that stops a case: a request with no units against</span>
    <span style="color: navy">// </span><span style="color: green">it is not blood in the fridge.</span>
    pg.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/blood') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-blood-requested-and-available-before-theatre'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Blood requested and available before theatre'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/blood/requested') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-blood-requested'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Blood requested'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_blood_requested&quot;</i><span style="color: navy">;</span>
      g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/blood/pints-available') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'preop-pints-available'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Pints available'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;comp_preop_pints_available&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;bloodPanel&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;preOperativeGroup&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── The post-operative checks ───────────────────────────────────────────</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetExamCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postoperative-check'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Post-operative check'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/wound') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-wound-checked'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Wound checked'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_wound_checked&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/drainage') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-drainage-checked'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Drainage checked'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_drainage_checked&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/vomit') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-vomiting-checked'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Vomiting checked'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_vomiting_checked&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/catheter') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-catheter-in-place'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Catheter in place'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_catheter_in_place&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/nasogastric-tube') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-nasogastric-tube-in-place'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Nasogastric tube in place'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_nasogastric_tube_in_place&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/infusion-therapy') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-infusion-therapy-running'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Infusion therapy running'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_infusion_therapy_running&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/oxygen-therapy') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-oxygen-therapy-running'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Oxygen therapy running'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_oxygen_therapy_running&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/analgesic-therapy') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-analgesic-therapy-given'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Analgesic therapy given'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_analgesic_therapy_given&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/pain') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-pain'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Pain'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_pain&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/level-of-consciousness') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-level-of-consciousness'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Level of consciousness'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_level_of_consciousness&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/checklist-complete') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'postop-check-list-operative-complete'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Check-list operative complete'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_postop_check_list_operative_complete&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;postOperativePanel&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Vital signs, before and after ───────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">The same six readings twice. Each Observation carries a note saying which</span>
  <span style="color: navy">// </span><span style="color: green">side of theatre it came from, because both sets have the same LOINC codes</span>
  <span style="color: navy">// </span><span style="color: green">and the response's authored time is one instant for the whole form -- so</span>
  <span style="color: navy">// </span><span style="color: green">without the note a ward could not tell the pre-operative pulse from the</span>
  <span style="color: navy">// </span><span style="color: green">post-operative one.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative/vitals'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/vitals/temperature') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8310-5'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Body temperature'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Taken before theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vital_8310_5&quot;</i><span style="color: navy">;</span>
      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/vitals/pulse') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8867-4'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Heart rate'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Taken before theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vital_8867_4&quot;</i><span style="color: navy">;</span>
      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/vitals/respiratory-rate') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'9279-1'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Respiratory rate'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Taken before theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vital_9279_1&quot;</i><span style="color: navy">;</span>
      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/vitals/oxygen-saturation') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'59408-5'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Oxygen saturation in Arterial blood by Pulse oximetry'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Taken before theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vital_59408_5&quot;</i><span style="color: navy">;</span>
      g2.item<b> as </b><span style="color: maroon">bp</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/vitals/blood-pressure') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        bp<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          bp<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            bp<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            bp<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'85354-9'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            bp<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Blood pressure panel with all children optional'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        bp.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/vitals/blood-pressure/systolic') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8480-6'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Systolic blood pressure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_8480_6&quot;</i><span style="color: navy">;</span>
        bp.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/vitals/blood-pressure/diastolic') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8462-4'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Diastolic blood pressure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_8462_4&quot;</i><span style="color: navy">;</span>
        bp<span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Taken before theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;bp&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vitalsSub&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;vitalsGrp&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'post-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'post-operative/vitals'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/vitals/temperature') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8310-5'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Body temperature'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Taken on return from theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vital_8310_52&quot;</i><span style="color: navy">;</span>
      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/vitals/pulse') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8867-4'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Heart rate'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Taken on return from theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vital_8867_42&quot;</i><span style="color: navy">;</span>
      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/vitals/respiratory-rate') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'9279-1'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Respiratory rate'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Taken on return from theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vital_9279_12&quot;</i><span style="color: navy">;</span>
      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/vitals/oxygen-saturation') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'59408-5'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Oxygen saturation in Arterial blood by Pulse oximetry'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>          a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: maroon">v</span> <i>&quot;set&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Taken on return from theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;vital_59408_52&quot;</i><span style="color: navy">;</span>
      g2.item<b> as </b><span style="color: maroon">bp</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/vitals/blood-pressure') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        bp<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>          bp<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            bp<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            bp<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'85354-9'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            bp<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Blood pressure panel with all children optional'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
        bp.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/vitals/blood-pressure/systolic') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8480-6'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Systolic blood pressure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_8480_62&quot;</i><span style="color: navy">;</span>
        bp.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/vitals/blood-pressure/diastolic') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>              it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'8462-4'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
              it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Diastolic blood pressure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;comp_8462_42&quot;</i><span style="color: navy">;</span>
        bp<span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Taken on return from theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;bp2&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vitalsSub2&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;vitalsGrp2&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Investigations ordered, before and after ─────────────────────────────</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative/investigations'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/investigations/fhg') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: blue">'Full haemogram'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&quot;</i><span style="color: navy">;</span>
        qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered before theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;order_fhg&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderSub&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;orderGrp&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative/investigations'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/investigations/coagulation') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: blue">'Coagulation profile'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&quot;</i><span style="color: navy">;</span>
        qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered before theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;order_coagulation&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderSub2&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;orderGrp2&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative/investigations'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/investigations/urinalysis') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: blue">'Urinalysis'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&quot;</i><span style="color: navy">;</span>
        qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered before theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;order_urinalysis&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderSub3&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;orderGrp3&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative/investigations'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/investigations/blood-group') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: blue">'Blood group'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&quot;</i><span style="color: navy">;</span>
        qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered before theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;order_blood_group&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderSub4&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;orderGrp4&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'pre-operative/investigations'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'pre-operative/investigations/x-ray') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'363679005'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Imaging'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: blue">'X-ray'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&quot;</i><span style="color: navy">;</span>
        qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered before theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;order_x_ray&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderSub5&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;orderGrp5&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'post-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'post-operative/investigations'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/investigations/fhg') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: blue">'Full haemogram'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&quot;</i><span style="color: navy">;</span>
        qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on return from theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;order_fhg2&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderSub6&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;orderGrp6&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'post-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'post-operative/investigations'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/investigations/coagulation') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: blue">'Coagulation profile'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&quot;</i><span style="color: navy">;</span>
        qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on return from theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;order_coagulation2&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderSub7&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;orderGrp7&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'post-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'post-operative/investigations'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/investigations/urinalysis') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'108252007'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Laboratory procedure'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: blue">'Urinalysis'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&quot;</i><span style="color: navy">;</span>
        qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on return from theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;order_urinalysis2&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderSub8&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;orderGrp8&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>linkId = 'post-operative'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    g.item<b> as </b><span style="color: maroon">g2</span><b> where </b><span style="color: navy">(</span>linkId = 'post-operative/investigations'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      g2.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'post-operative/investigations/x-ray') and (answer.value.ofType(Coding).code = 'Y')<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">sr</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> sr<span style="color: navy">, </span> entry<b> then </b>BuildServiceRequestBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">sr</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.status = <span style="color: blue">'active'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.intent = <span style="color: blue">'order'</span> <i>&quot;intent&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span>sr.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>            it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'363679005'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
            it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Imaging'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.code<b> as </b><span style="color: maroon">cr</span><span style="color: navy">, </span> cr.concept<b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.text = <span style="color: blue">'X-ray'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>sr.authoredOn = <span style="color: maroon">t</span> <i>&quot;authoredOn&quot;</i><span style="color: navy">;</span>
        qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>sr.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
        qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>sr.requester = <span style="color: maroon">src</span> <i>&quot;requester&quot;</i><span style="color: navy">;</span>
        it<span style="color: navy"><b> -&gt; </b></span> sr.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: blue">'Ordered on return from theatre'</span> <i>&quot;phaseNote&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;order_x_ray2&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderSub9&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;orderGrp9&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Allergy recorded on the checklist ───────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">Recorded as an Observation, not an AllergyIntolerance. The checklist asks</span>
  <span style="color: navy">// </span><span style="color: green">the team to *review* a known allergy, not to record a new one; the drug,</span>
  <span style="color: navy">// </span><span style="color: green">anaesthetic and other lines are what they read out, and creating an</span>
  <span style="color: navy">// </span><span style="color: green">AllergyIntolerance from a read-back would duplicate whatever the pharmacy</span>
  <span style="color: navy">// </span><span style="color: green">already holds.</span>
  qr.item<b> as </b><span style="color: maroon">g</span><b> where </b><span style="color: navy">(</span>(linkId = 'allergy') and item.answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span> obs<span style="color: navy">, </span> entry<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;base&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetSurveyCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
    g<span style="color: navy"><b> -&gt; </b></span>obs.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      g<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>        g<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'48765-2'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
        g<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'Allergies and adverse reactions Document'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      g<span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: blue">'Allergy reviewed at the surgical safety checklist'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'allergy/drug'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note2&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'allergy/anaesthesia'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note3&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>linkId = 'allergy/other'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>        a.value<b> as </b><span style="color: maroon">txt</span><span style="color: navy"><b> -&gt; </b></span> obs.note<b> as </b><span style="color: maroon">n</span><span style="color: navy">, </span> n.text = <span style="color: maroon">txt</span> <i>&quot;text&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;note4&quot;</i><span style="color: navy">;</span>
    g.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'allergy/none-known') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span>      it<span style="color: navy"><b> -&gt; </b></span>comp.code<b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>        it<span style="color: navy"><b> -&gt; </b></span>cc.coding<b> as </b><span style="color: maroon">cg</span><b> then</b><span style="color: navy"> {
</span>          it<span style="color: navy"><b> -&gt; </b></span>cg.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem'</span> <i>&quot;sys&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.code = <span style="color: blue">'who-check-no-known-allergies'</span> <i>&quot;cd&quot;</i><span style="color: navy">;</span>
          it<span style="color: navy"><b> -&gt; </b></span>cg.display = <span style="color: blue">'No known allergies'</span> <i>&quot;dsp&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      it<span style="color: navy"><b> -&gt; </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;comp_who_check_no_known_allergies&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;allergyObservation&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</span>
<span style="color: navy">// </span><span style="color: green">Shared scaffolding. Repeated in each map rather than imported: the transform</span>
<span style="color: navy">// </span><span style="color: green">engine resolves `imports` against whatever StructureMaps happen to be on the</span>
<span style="color: navy">// </span><span style="color: green">server, and a form that stops extracting because a shared map was not</span>
<span style="color: navy">// </span><span style="color: green">uploaded is a worse failure than a duplicated group.</span>
<span style="color: navy">// </span><span style="color: green">Two notes on what the publisher's StructureMap validator says about this file.</span>
<span style="color: navy">// </span><span style="color: green">Source parameters below are left untyped on purpose. Writing `: Element` makes</span>
<span style="color: navy">// </span><span style="color: green">the validator compare QuestionnaireResponse.item against the literal 'Element'</span>
<span style="color: navy">// </span><span style="color: green">and report them as incompatible with each other, which is noise, not a finding.</span>
<span style="color: navy">// </span><span style="color: green">`evaluate(context, expression)` is flagged as &quot;takes 1 parameter but 2 were</span>
<span style="color: navy">// </span><span style="color: green">found&quot;. Leave it. The FML parser in the same jar refuses the one-argument form</span>
<span style="color: navy">// </span><span style="color: green">outright -- it wants a parameter, a comma, then the FHIRPath -- so the</span>
<span style="color: navy">// </span><span style="color: green">publisher is objecting to what its own compiler emits. Two arguments is the</span>
<span style="color: navy">// </span><span style="color: green">only form that compiles, and it is what the R5 transform engine executes.</span>
<span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</span>
<b>group </b>BuildObsBase<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>obs<b> then </b>SetResponseProvenance<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>&quot;responseProvenance&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> then </b>SetObservationFullUrl<span style="color: navy">(</span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;idAndFullUrl&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;requestMethod&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'Observation'</span> <i>&quot;requestUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;entryRequest&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>obs.status = <span style="color: blue">'final'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
  qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -&gt; </b></span>obs.subject = <span style="color: maroon">s</span><span style="color: navy">;</span>
  qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>obs.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
  qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: maroon">t</span> <i>&quot;effective&quot;</i><span style="color: navy">;</span>
  qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>obs.performer = <span style="color: maroon">src</span> <i>&quot;performerFromSource&quot;</i><span style="color: navy">;</span>
  qr<b> where </b><span style="color: navy">(</span>source.exists().not()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    qr.author<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span>obs.performer = <span style="color: maroon">a</span> <i>&quot;performerFromAuthor&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;performerFallback&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">A stored response's id already reads &quot;QuestionnaireResponse/&lt;id&gt;&quot;, so it is</span>
  <span style="color: navy">// </span><span style="color: green">a relative reference as it stands. The hasValue() guard is what stops an</span>
  <span style="color: navy">// </span><span style="color: green">unsaved response -- one posted straight to $extract rather than saved first</span>
  <span style="color: navy">// </span><span style="color: green">-- from writing &quot;QuestionnaireResponse/null&quot; into the record.</span>
  qr.id<b> as </b><span style="color: maroon">qid</span><b> where </b><span style="color: navy">(</span>$this.hasValue()<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span> obs.derivedFrom = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ref</span><span style="color: navy">, </span> ref.reference = <span style="color: maroon">qid</span> <i>&quot;linkQuestionnaireResponse&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetObservationFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  obs.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/Observation/'</span><span style="color: navy">, </span><span style="color: maroon">id</span><span style="color: navy">)</span> <i>&quot;assignFullUrl&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">The two answer shapes a component can carry. Both read the answer through the</span>
<span style="color: navy">// </span><span style="color: green">untyped `.value` accessor: reading `valueCoding` or `valueQuantity` by its</span>
<span style="color: navy">// </span><span style="color: green">typed property name fails at transform time on HAPI R5 with &quot;Attempt to read</span>
<span style="color: navy">// </span><span style="color: green">invalid property ... on QuestionnaireResponse.item.answer&quot;.</span>
<b>group </b>SetComponentCodedValue<span style="color: navy">(</span><b>source</b> <span style="color: maroon">it</span>, <b>target</b> <span style="color: maroon">comp</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>    a.value<b> as </b><span style="color: maroon">cv</span><span style="color: navy"><b> -&gt; </b></span>comp.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>      cv<span style="color: navy"><b> -&gt; </b></span>cc.coding = <span style="color: maroon">cv</span> <i>&quot;valueCoding&quot;</i><span style="color: navy">;</span>
      cv.display<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: maroon">d</span> <i>&quot;valueText&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;codedValue&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;componentAnswer&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetComponentValue<span style="color: navy">(</span><b>source</b> <span style="color: maroon">it</span>, <b>target</b> <span style="color: maroon">comp</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span>    a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>comp.value = <span style="color: maroon">v</span> <i>&quot;plainValue&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;componentAnswer&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetSurveyCategory<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>obs.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorySystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'survey'</span> <i>&quot;categoryCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Survey'</span> <i>&quot;categoryDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;categoryCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetVitalSignsCategory<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>obs.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorySystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;categoryCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;categoryDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;categoryCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetExamCategory<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>obs.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorySystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'exam'</span> <i>&quot;categoryCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Exam'</span> <i>&quot;categoryDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;categoryCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>BuildServiceRequestBase<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">r</span><span style="color: navy"> : </span>ServiceRequest, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>r<b> then </b>SetResponseProvenance<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">r</span><span style="color: navy">)</span> <i>&quot;responseProvenance&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>r.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> then </b>SetServiceRequestFullUrl<span style="color: navy">(</span><span style="color: maroon">r</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;idAndFullUrl&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;requestMethod&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'ServiceRequest'</span> <i>&quot;requestUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;entryRequest&quot;</i><span style="color: navy">;</span>
  qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -&gt; </b></span>r.subject = <span style="color: maroon">s</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetServiceRequestFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">r</span><span style="color: navy"> : </span>ServiceRequest, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  r.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/ServiceRequest/'</span><span style="color: navy">, </span><span style="color: maroon">id</span><span style="color: navy">)</span> <i>&quot;assignFullUrl&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">── Provenance and tenancy ───────────────────────────────────────────────────</span>
<span style="color: navy">// </span><span style="color: green">Two tags on everything this map creates. The first says which questionnaire</span>
<span style="color: navy">// </span><span style="color: green">produced it, so a form that reopens mid-admission recalls its own earlier</span>
<span style="color: navy">// </span><span style="color: green">entries and not another form's. The second copies the tenant tags off the</span>
<span style="color: navy">// </span><span style="color: green">response, because nothing else on the path puts them there.</span>
<span style="color: navy">// </span><span style="color: green">The code is the form's document type, not the questionnaire's id: every</span>
<span style="color: navy">// </span><span style="color: green">environment mints its own ids, and there is only one set of maps, so an id</span>
<span style="color: navy">// </span><span style="color: green">here would tie the tag to whichever environment stamped it.</span>
<span style="color: navy">// </span><span style="color: green">── Provenance and tenancy ───────────────────────────────────────────────────</span>
<b>group </b>SetResponseProvenance<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">r</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>r.meta<b> as </b><span style="color: maroon">m</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>m.tag<b> as </b><span style="color: maroon">t</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>t.system = <span style="color: blue">'http://slade360edi.com/questionnaire-provenance'</span> <i>&quot;provenanceSystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>t.code = <span style="color: blue">'surgical-safety-checklist'</span> <i>&quot;provenanceCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>t.display = <span style="color: blue">'Surgical safety checklist'</span> <i>&quot;provenanceDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;provenanceTag&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;provenanceMeta&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Every tag the response carries, onto the resource. `meta` is 0..1, so this</span>
  <span style="color: navy">// </span><span style="color: green">lands on the same meta the rule above created rather than a second one.</span>
  qr.meta<b> as </b><span style="color: maroon">qm</span><b> then</b><span style="color: navy"> {
</span>    qm.tag<b> as </b><span style="color: maroon">qt</span><span style="color: navy"><b> -&gt; </b></span> r.meta<b> as </b><span style="color: maroon">m</span><span style="color: navy">, </span> m.tag = <span style="color: maroon">qt</span> <i>&quot;copyTag&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;tenantTags&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url value="https://fhir.slade360.co.ke/fhir/StructureMap/ExtractSurgicalSafetyChecklist"/>
  <version value="0.1.0"/>
  <name value="ExtractSurgicalSafetyChecklist"/>
  <title value="Surgical Safety Checklist Extraction"/>
  <status value="active"/>
  <date value="2026-09-14T06:31:13+00:00"/>
  <publisher value="Kathurima Kimathi"/>
  <contact>
    <name value="Kathurima Kimathi"/>
    <telecom>
      <system value="url"/>
      <value value="https://www.linkedin.com/in/kathurima-kimathi/"/>
    </telecom>
    <telecom>
      <system value="email"/>
      <value value="kathurimakimathi415@gmail.com"/>
    </telecom>
  </contact>
  <contact>
    <name value="Oscar John"/>
    <telecom>
      <system value="email"/>
      <value value="oscarjohnotieno@gmail.com"/>
      <use value="work"/>
    </telecom>
  </contact>
  <contact>
    <name value="Kennedy Omondi"/>
    <telecom>
      <system value="email"/>
      <value value="kennankole@gmail.com"/>
      <use value="work"/>
    </telecom>
  </contact>
  <description value="The checklist out as one Observation per WHO phase, so a sign-out that never happened is a missing resource rather than a resource full of blanks -- which is the only shape that lets a compliance audit tell an unperformed phase from an unticked one. The ward's pre-operative preparation and post-operative checks become two further panels, every investigation ticked becomes a ServiceRequest, the vital signs before and after theatre become their own Observations tagged with which side of theatre they were taken on, and the instrument count gets an Observation of its own because a wrong count is a never event."/>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"/>
    <mode value="source"/>
    <alias value="QR"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
    <mode value="target"/>
    <alias value="Bundle"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Observation"/>
    <mode value="target"/>
    <alias value="Observation"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/ServiceRequest"/>
    <mode value="target"/>
    <alias value="ServiceRequest"/>
  </structure>
  <group>
    <name value="ExtractSurgicalSafetyChecklist"/>
    <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="whoChecklistGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="wg"/>
        <condition value="linkId = 'who-checklist'"/>
      </source>
      <rule>
        <name value="phase_sign_in"/>
        <source>
          <context value="wg"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="(linkId = 'who-checklist/sign-in') and item.answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetSurveyCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="surgical-safety-phase"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Surgical safety checklist phase"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Sign in — before induction of anaesthesia"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="phaseValue"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="value"/>
            <variable value="vc"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CodeableConcept"/>
            </parameter>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="vc"/>
              <element value="coding"/>
              <variable value="vcg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="vcg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/answer-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="vcg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="phase-sign-in"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="vcg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Sign in — before induction of anaesthesia"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="phaseTime"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="ct"/>
            <condition value="(linkId = 'who-checklist/sign-in/completed-at') and answer.value.exists()"/>
          </source>
          <rule>
            <name value="answer"/>
            <source>
              <context value="ct"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="phaseEffective"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="t"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="effective"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="t"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <documentation value="The phase's own completion time, not the form's authored time."/>
        </rule>
        <rule>
          <name value="comp_who_check_patient_confirmed_identity_site_procedure_and"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-in/identity-site-procedure-consent') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-patient-confirmed-identity-site-procedure-and"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Patient confirmed identity, site, procedure and consent"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_site_marked"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-in/site-marked') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-site-marked"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Site marked"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_anaesthesia_machine_and_medication_check_complete"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-in/anaesthesia-machine-and-medication-check') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-anaesthesia-machine-and-medication-check-complete"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Anaesthesia machine and medication check complete"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_pulse_oximeter_on_the_patient_and_functioning"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-in/pulse-oximeter-on-and-functioning') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-pulse-oximeter-on-the-patient-and-functioning"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Pulse oximeter on the patient and functioning"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_known_allergy_reviewed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-in/known-allergy-reviewed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-known-allergy-reviewed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Known allergy reviewed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_difficult_airway_or_aspiration_risk_assessed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-in/difficult-airway-or-aspiration-risk') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-difficult-airway-or-aspiration-risk-assessed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Difficult airway or aspiration risk assessed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_risk_of_over_500_ml_blood_loss_assessed_access_and"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-in/blood-loss-risk-over-500ml') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-risk-of-over-500-ml-blood-loss-assessed-access-and"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Risk of over 500 ml blood loss assessed, access and fluids planned"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="phase_time_out"/>
        <source>
          <context value="wg"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="(linkId = 'who-checklist/time-out') and item.answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetSurveyCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="surgical-safety-phase"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Surgical safety checklist phase"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Time out — before skin incision"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="phaseValue"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="value"/>
            <variable value="vc"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CodeableConcept"/>
            </parameter>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="vc"/>
              <element value="coding"/>
              <variable value="vcg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="vcg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/answer-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="vcg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="phase-time-out"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="vcg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Time out — before skin incision"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="phaseTime2"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="ct"/>
            <condition value="(linkId = 'who-checklist/time-out/completed-at') and answer.value.exists()"/>
          </source>
          <rule>
            <name value="answer"/>
            <source>
              <context value="ct"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="phaseEffective"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="t"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="effective"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="t"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <documentation value="The phase's own completion time, not the form's authored time."/>
        </rule>
        <rule>
          <name value="comp_who_check_all_team_members_introduced_by_name_and_role"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/time-out/team-introductions') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-all-team-members-introduced-by-name-and-role"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="All team members introduced by name and role"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_patient_procedure_and_incision_site_confirmed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/time-out/confirm-patient-procedure-incision') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-patient-procedure-and-incision-site-confirmed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Patient, procedure and incision site confirmed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_antibiotic_prophylaxis_given_within_the_last_60"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/time-out/antibiotic-prophylaxis-within-60-minutes') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-antibiotic-prophylaxis-given-within-the-last-60"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Antibiotic prophylaxis given within the last 60 minutes"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_critical_or_non_routine_steps_reviewed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/time-out/critical-steps-reviewed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-critical-or-non-routine-steps-reviewed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Critical or non-routine steps reviewed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_case_duration_reviewed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/time-out/case-duration-reviewed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-case-duration-reviewed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Case duration reviewed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_anticipated_blood_loss_reviewed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/time-out/anticipated-blood-loss-reviewed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-anticipated-blood-loss-reviewed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Anticipated blood loss reviewed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_anaesthetist_s_patient_specific_concerns_reviewed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/time-out/anaesthetist-patient-specific-concerns') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-anaesthetist-s-patient-specific-concerns-reviewed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Anaesthetist's patient-specific concerns reviewed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_sterility_including_indicator_results_confirmed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/time-out/sterility-confirmed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-sterility-including-indicator-results-confirmed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Sterility, including indicator results, confirmed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_equipment_issues_or_concerns_reviewed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/time-out/equipment-issues-reviewed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-equipment-issues-or-concerns-reviewed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Equipment issues or concerns reviewed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_essential_imaging_displayed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/time-out/essential-imaging-displayed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-essential-imaging-displayed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Essential imaging displayed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="phase_sign_out"/>
        <source>
          <context value="wg"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="(linkId = 'who-checklist/sign-out') and item.answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetSurveyCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="surgical-safety-phase"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Surgical safety checklist phase"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Sign out — before the patient leaves the operating room"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="phaseValue"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="value"/>
            <variable value="vc"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CodeableConcept"/>
            </parameter>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="vc"/>
              <element value="coding"/>
              <variable value="vcg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="vcg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/answer-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="vcg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="phase-sign-out"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="vcg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Sign out — before the patient leaves the operating room"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="phaseTime3"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="ct"/>
            <condition value="(linkId = 'who-checklist/sign-out/completed-at') and answer.value.exists()"/>
          </source>
          <rule>
            <name value="answer"/>
            <source>
              <context value="ct"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="phaseEffective"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="t"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="effective"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="t"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <documentation value="The phase's own completion time, not the form's authored time."/>
        </rule>
        <rule>
          <name value="comp_who_check_name_of_the_procedure_verbally_confirmed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-out/procedure-name-recorded') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-name-of-the-procedure-verbally-confirmed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Name of the procedure verbally confirmed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_instrument_sponge_and_needle_counts_complete"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-out/counts-complete') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-instrument-sponge-and-needle-counts-complete"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Instrument, sponge and needle counts complete"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_specimen_labelling_read_aloud_including_the_patient"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-out/specimen-labelling') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-specimen-labelling-read-aloud-including-the-patient"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Specimen labelling read aloud, including the patient name"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_equipment_problems_to_be_addressed_identified"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-out/equipment-problems-addressed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-equipment-problems-to-be-addressed-identified"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Equipment problems to be addressed identified"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_who_check_key_concerns_for_recovery_and_management_reviewed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-out/recovery-key-concerns') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="who-check-key-concerns-for-recovery-and-management-reviewed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Key concerns for recovery and management reviewed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <documentation value="── The three WHO phases ────────────────────────────────────────────────&#xD;&#xA;One Observation each. This is the whole design decision on this form: a&#xD;&#xA;single Observation with twenty-two components could not distinguish &quot;the&#xD;&#xA;team did the sign-out and confirmed nothing&quot; from &quot;the team never did the&#xD;&#xA;sign-out&quot;, and those are a documentation lapse and a safety failure&#xD;&#xA;respectively.&#xD;&#xA;Each phase is guarded on at least one of its own items being answered, and&#xD;&#xA;carries `Observation.effective` from the phase's own completion time when&#xD;&#xA;the team recorded one, so the interval between induction and incision is&#xD;&#xA;recoverable."/>
    </rule>
    <rule>
      <name value="instrumentCountGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="wg"/>
        <condition value="linkId = 'who-checklist'"/>
      </source>
      <rule>
        <name value="signOutSub"/>
        <source>
          <context value="wg"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="linkId = 'who-checklist/sign-out'"/>
        </source>
        <rule>
          <name value="instrumentCountObservation"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'who-checklist/sign-out/counts-complete') and answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetSurveyCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="instrument-count-complete"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Instrument, sponge and needle count complete"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="codedValue"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="cv"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="value"/>
                <variable value="vc"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="CodeableConcept"/>
                </parameter>
              </target>
              <rule>
                <name value="valueCoding"/>
                <source>
                  <context value="cv"/>
                </source>
                <target>
                  <context value="vc"/>
                  <element value="coding"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="cv"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="valueText"/>
                <source>
                  <context value="cv"/>
                  <element value="display"/>
                  <variable value="d"/>
                </source>
                <target>
                  <context value="vc"/>
                  <element value="text"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="d"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="countInterpretation"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="abnormal"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="cv"/>
                <condition value="code != 'check-confirmed'"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="interpretation"/>
                <variable value="interp"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="cv"/>
                </source>
                <target>
                  <context value="interp"/>
                  <element value="coding"/>
                  <variable value="icg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="cv"/>
                  </source>
                  <target>
                    <context value="icg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="cv"/>
                  </source>
                  <target>
                    <context value="icg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="A"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="cv"/>
                  </source>
                  <target>
                    <context value="icg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Abnormal"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <documentation value="Anything other than a confirmed count is abnormal. Stated, not left&#xD;&#xA;to a reader: this is the flag a theatre audit filters on."/>
          </rule>
        </rule>
      </rule>
      <documentation value="── The instrument, sponge and needle count ─────────────────────────────&#xD;&#xA;Lifted out of the sign-out panel into an Observation of its own. An&#xD;&#xA;incorrect count is a never event and a retained item is a serious incident;&#xD;&#xA;a fact that triggers an incident report has to be findable by its own code&#xD;&#xA;and not only by reading a twenty-two-component panel."/>
    </rule>
    <rule>
      <name value="preOperativeGroup"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="pg"/>
        <condition value="linkId = 'pre-operative'"/>
      </source>
      <rule>
        <name value="preparationPanel"/>
        <source>
          <context value="pg"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="(linkId = 'pre-operative/preparation') and item.answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetSurveyCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="preoperative-preparation"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Pre-operative preparation completed"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_fasting"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/preparation/fasting') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-fasting"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Fasting"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_dentures_removed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/preparation/dentures-removed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-dentures-removed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Dentures removed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_jewellery_removed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/preparation/jewellery-removed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-jewellery-removed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Jewellery removed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_artificial_limb_removed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/preparation/artificial-limb-removed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-artificial-limb-removed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Artificial limb removed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_nail_varnish_removed"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/preparation/nail-varnish-removed') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-nail-varnish-removed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Nail varnish removed"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_shaving"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/preparation/shaving') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-shaving"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Shaving"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_bath"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/preparation/bath') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-bath"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Bath"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_theatre_gown"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/preparation/theatre-gown') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-theatre-gown"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Theatre gown"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_skin_cleaned"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/preparation/skin-cleaned') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-skin-cleaned"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Skin cleaned"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="linesPanel"/>
        <source>
          <context value="pg"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="(linkId = 'pre-operative/lines') and item.answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetExamCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="preop-lines-and-tubes-in-place-before-theatre"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Lines and tubes in place before theatre"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_catheter"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/lines/catheter') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-catheter"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Catheter"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_nasogastric_tube"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/lines/nasogastric-tube') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-nasogastric-tube"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Nasogastric tube"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_intravenous_infusion"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/lines/intravenous-infusion') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-intravenous-infusion"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Intravenous infusion"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="note"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="linkId = 'pre-operative/lines/other'"/>
          </source>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="text"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="txt"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="note"/>
                <variable value="n"/>
              </target>
              <target>
                <context value="n"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="txt"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <documentation value="Lines and tubes in place. A separate panel from the preparation checklist&#xD;&#xA;because these are devices the theatre has to know about, not tasks the&#xD;&#xA;ward has to have finished."/>
      </rule>
      <rule>
        <name value="bloodPanel"/>
        <source>
          <context value="pg"/>
          <element value="item"/>
          <variable value="g"/>
          <condition value="(linkId = 'pre-operative/blood') and item.answer.value.exists()"/>
        </source>
        <target>
          <context value="bundle"/>
          <element value="entry"/>
          <variable value="entry"/>
        </target>
        <target>
          <context value="entry"/>
          <element value="resource"/>
          <variable value="obs"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <rule>
          <name value="base"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <target>
            <context value="entry"/>
          </target>
          <dependent>
            <name value="BuildObsBase"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
            <parameter>
              <valueId value="entry"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="obs"/>
          </target>
          <dependent>
            <name value="SetSurveyCategory"/>
            <parameter>
              <valueId value="qr"/>
            </parameter>
            <parameter>
              <valueId value="obs"/>
            </parameter>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="preop-blood-requested-and-available-before-theatre"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="g"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Blood requested and available before theatre"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_blood_requested"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/blood/requested') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-blood-requested"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Blood requested"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentCodedValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="comp_preop_pints_available"/>
          <source>
            <context value="g"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/blood/pints-available') and answer.value.exists()"/>
          </source>
          <target>
            <context value="obs"/>
            <element value="component"/>
            <variable value="comp"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="preop-pints-available"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Pints available"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="value"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="comp"/>
            </target>
            <dependent>
              <name value="SetComponentValue"/>
              <parameter>
                <valueId value="it"/>
              </parameter>
              <parameter>
                <valueId value="comp"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
        <documentation value="Blood requested, and how many pints are actually available. Two facts, and&#xD;&#xA;the second is the one that stops a case: a request with no units against&#xD;&#xA;it is not blood in the fridge."/>
      </rule>
      <documentation value="── The ward's pre-operative preparation ────────────────────────────────"/>
    </rule>
    <rule>
      <name value="postOperativePanel"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="(linkId = 'post-operative') and item.answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetExamCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="g"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="postoperative-check"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Post-operative check"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_wound_checked"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/wound') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-wound-checked"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Wound checked"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_drainage_checked"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/drainage') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-drainage-checked"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Drainage checked"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_vomiting_checked"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/vomit') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-vomiting-checked"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Vomiting checked"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_catheter_in_place"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/catheter') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-catheter-in-place"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Catheter in place"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_nasogastric_tube_in_place"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/nasogastric-tube') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-nasogastric-tube-in-place"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Nasogastric tube in place"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_infusion_therapy_running"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/infusion-therapy') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-infusion-therapy-running"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Infusion therapy running"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_oxygen_therapy_running"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/oxygen-therapy') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-oxygen-therapy-running"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Oxygen therapy running"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_analgesic_therapy_given"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/analgesic-therapy') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-analgesic-therapy-given"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Analgesic therapy given"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_pain"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/pain') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-pain"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Pain"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_level_of_consciousness"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/level-of-consciousness') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-level-of-consciousness"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Level of consciousness"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="comp_postop_check_list_operative_complete"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'post-operative/checklist-complete') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="postop-check-list-operative-complete"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Check-list operative complete"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <documentation value="── The post-operative checks ───────────────────────────────────────────"/>
    </rule>
    <rule>
      <name value="vitalsGrp"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'pre-operative'"/>
      </source>
      <rule>
        <name value="vitalsSub"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'pre-operative/vitals'"/>
        </source>
        <rule>
          <name value="vital_8310_5"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/vitals/temperature') and answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8310-5"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Body temperature"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="set"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Taken before theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="vital_8867_4"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/vitals/pulse') and answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8867-4"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Heart rate"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="set"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Taken before theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="vital_9279_1"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/vitals/respiratory-rate') and answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="9279-1"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Respiratory rate"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="set"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Taken before theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="vital_59408_5"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/vitals/oxygen-saturation') and answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="59408-5"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Oxygen saturation in Arterial blood by Pulse oximetry"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="set"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Taken before theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="bp"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="bp"/>
            <condition value="(linkId = 'pre-operative/vitals/blood-pressure') and item.answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="bp"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="bp"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="bp"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="bp"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="85354-9"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="bp"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Blood pressure panel with all children optional"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="comp_8480_6"/>
            <source>
              <context value="bp"/>
              <element value="item"/>
              <variable value="it"/>
              <condition value="(linkId = 'pre-operative/vitals/blood-pressure/systolic') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="8480-6"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Systolic blood pressure"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
          <rule>
            <name value="comp_8462_4"/>
            <source>
              <context value="bp"/>
              <element value="item"/>
              <variable value="it"/>
              <condition value="(linkId = 'pre-operative/vitals/blood-pressure/diastolic') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="8462-4"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Diastolic blood pressure"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="bp"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Taken before theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation value="── Vital signs, before and after ───────────────────────────────────────&#xD;&#xA;The same six readings twice. Each Observation carries a note saying which&#xD;&#xA;side of theatre it came from, because both sets have the same LOINC codes&#xD;&#xA;and the response's authored time is one instant for the whole form -- so&#xD;&#xA;without the note a ward could not tell the pre-operative pulse from the&#xD;&#xA;post-operative one."/>
    </rule>
    <rule>
      <name value="vitalsGrp2"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'post-operative'"/>
      </source>
      <rule>
        <name value="vitalsSub2"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'post-operative/vitals'"/>
        </source>
        <rule>
          <name value="vital_8310_52"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'post-operative/vitals/temperature') and answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8310-5"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Body temperature"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="set"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Taken on return from theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="vital_8867_42"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'post-operative/vitals/pulse') and answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="8867-4"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Heart rate"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="set"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Taken on return from theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="vital_9279_12"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'post-operative/vitals/respiratory-rate') and answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="9279-1"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Respiratory rate"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="set"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Taken on return from theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="vital_59408_52"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'post-operative/vitals/oxygen-saturation') and answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="59408-5"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Oxygen saturation in Arterial blood by Pulse oximetry"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="answer"/>
            <source>
              <context value="it"/>
              <element value="answer"/>
              <listMode value="first"/>
              <variable value="a"/>
            </source>
            <rule>
              <name value="set"/>
              <source>
                <context value="a"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <target>
                <context value="obs"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Taken on return from theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="bp2"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="bp"/>
            <condition value="(linkId = 'post-operative/vitals/blood-pressure') and item.answer.value.exists()"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="obs"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obs"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obs"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="bp"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="code"/>
              <variable value="cc"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="bp"/>
              </source>
              <target>
                <context value="cc"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="bp"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="bp"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="85354-9"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="bp"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Blood pressure panel with all children optional"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="comp_8480_62"/>
            <source>
              <context value="bp"/>
              <element value="item"/>
              <variable value="it"/>
              <condition value="(linkId = 'post-operative/vitals/blood-pressure/systolic') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="8480-6"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Systolic blood pressure"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
          <rule>
            <name value="comp_8462_42"/>
            <source>
              <context value="bp"/>
              <element value="item"/>
              <variable value="it"/>
              <condition value="(linkId = 'post-operative/vitals/blood-pressure/diastolic') and answer.value.exists()"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="component"/>
              <variable value="comp"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
                <element value="code"/>
                <variable value="cc"/>
              </target>
              <rule>
                <name value="coding"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cc"/>
                  <element value="coding"/>
                  <variable value="cg"/>
                </target>
                <rule>
                  <name value="sys"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="cd"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="8462-4"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="dsp"/>
                  <source>
                    <context value="it"/>
                  </source>
                  <target>
                    <context value="cg"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Diastolic blood pressure"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="comp"/>
              </target>
              <dependent>
                <name value="SetComponentValue"/>
                <parameter>
                  <valueId value="it"/>
                </parameter>
                <parameter>
                  <valueId value="comp"/>
                </parameter>
              </dependent>
            </rule>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="bp"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Taken on return from theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="orderGrp"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'pre-operative'"/>
      </source>
      <rule>
        <name value="orderSub"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'pre-operative/investigations'"/>
        </source>
        <rule>
          <name value="order_fhg"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/investigations/fhg') and (answer.value.ofType(Coding).code = 'Y')"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Full haemogram"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Ordered before theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <documentation value="── Investigations ordered, before and after ─────────────────────────────"/>
    </rule>
    <rule>
      <name value="orderGrp2"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'pre-operative'"/>
      </source>
      <rule>
        <name value="orderSub2"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'pre-operative/investigations'"/>
        </source>
        <rule>
          <name value="order_coagulation"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/investigations/coagulation') and (answer.value.ofType(Coding).code = 'Y')"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Coagulation profile"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Ordered before theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="orderGrp3"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'pre-operative'"/>
      </source>
      <rule>
        <name value="orderSub3"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'pre-operative/investigations'"/>
        </source>
        <rule>
          <name value="order_urinalysis"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/investigations/urinalysis') and (answer.value.ofType(Coding).code = 'Y')"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Urinalysis"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Ordered before theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="orderGrp4"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'pre-operative'"/>
      </source>
      <rule>
        <name value="orderSub4"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'pre-operative/investigations'"/>
        </source>
        <rule>
          <name value="order_blood_group"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/investigations/blood-group') and (answer.value.ofType(Coding).code = 'Y')"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Blood group"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Ordered before theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="orderGrp5"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'pre-operative'"/>
      </source>
      <rule>
        <name value="orderSub5"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'pre-operative/investigations'"/>
        </source>
        <rule>
          <name value="order_x_ray"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'pre-operative/investigations/x-ray') and (answer.value.ofType(Coding).code = 'Y')"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="363679005"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Imaging"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="X-ray"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Ordered before theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="orderGrp6"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'post-operative'"/>
      </source>
      <rule>
        <name value="orderSub6"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'post-operative/investigations'"/>
        </source>
        <rule>
          <name value="order_fhg2"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'post-operative/investigations/fhg') and (answer.value.ofType(Coding).code = 'Y')"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Full haemogram"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Ordered on return from theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="orderGrp7"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'post-operative'"/>
      </source>
      <rule>
        <name value="orderSub7"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'post-operative/investigations'"/>
        </source>
        <rule>
          <name value="order_coagulation2"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'post-operative/investigations/coagulation') and (answer.value.ofType(Coding).code = 'Y')"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Coagulation profile"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Ordered on return from theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="orderGrp8"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'post-operative'"/>
      </source>
      <rule>
        <name value="orderSub8"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'post-operative/investigations'"/>
        </source>
        <rule>
          <name value="order_urinalysis2"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'post-operative/investigations/urinalysis') and (answer.value.ofType(Coding).code = 'Y')"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="108252007"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Laboratory procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Urinalysis"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Ordered on return from theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="orderGrp9"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="linkId = 'post-operative'"/>
      </source>
      <rule>
        <name value="orderSub9"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="g2"/>
          <condition value="linkId = 'post-operative/investigations'"/>
        </source>
        <rule>
          <name value="order_x_ray2"/>
          <source>
            <context value="g2"/>
            <element value="item"/>
            <variable value="it"/>
            <condition value="(linkId = 'post-operative/investigations/x-ray') and (answer.value.ofType(Coding).code = 'Y')"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entry"/>
          </target>
          <target>
            <context value="entry"/>
            <element value="resource"/>
            <variable value="sr"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ServiceRequest"/>
            </parameter>
          </target>
          <rule>
            <name value="base"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="sr"/>
            </target>
            <target>
              <context value="entry"/>
            </target>
            <dependent>
              <name value="BuildServiceRequestBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="sr"/>
              </parameter>
              <parameter>
                <valueId value="entry"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="category"/>
              <variable value="cat"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cat"/>
                <element value="coding"/>
                <variable value="cg"/>
              </target>
              <rule>
                <name value="sys"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://snomed.info/sct"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="cd"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="363679005"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="dsp"/>
                <source>
                  <context value="it"/>
                </source>
                <target>
                  <context value="cg"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Imaging"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="codeText"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="code"/>
              <variable value="cr"/>
            </target>
            <target>
              <context value="cr"/>
              <element value="concept"/>
              <variable value="cc"/>
            </target>
            <target>
              <context value="cc"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="X-ray"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="authoredOn"/>
            <source>
              <context value="qr"/>
              <element value="authored"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="authoredOn"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="t"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="encounter"/>
            <source>
              <context value="qr"/>
              <element value="encounter"/>
              <variable value="e"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="encounter"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="e"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="requester"/>
            <source>
              <context value="qr"/>
              <element value="source"/>
              <variable value="src"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="requester"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="src"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="phaseNote"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="sr"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Ordered on return from theatre"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="allergyObservation"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="g"/>
        <condition value="(linkId = 'allergy') and item.answer.value.exists()"/>
      </source>
      <target>
        <context value="bundle"/>
        <element value="entry"/>
        <variable value="entry"/>
      </target>
      <target>
        <context value="entry"/>
        <element value="resource"/>
        <variable value="obs"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Observation"/>
        </parameter>
      </target>
      <rule>
        <name value="base"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <target>
          <context value="entry"/>
        </target>
        <dependent>
          <name value="BuildObsBase"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
          <parameter>
            <valueId value="entry"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="category"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="obs"/>
        </target>
        <dependent>
          <name value="SetSurveyCategory"/>
          <parameter>
            <valueId value="qr"/>
          </parameter>
          <parameter>
            <valueId value="obs"/>
          </parameter>
        </dependent>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="g"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="code"/>
          <variable value="cc"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <variable value="cg"/>
          </target>
          <rule>
            <name value="sys"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="cd"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="48765-2"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dsp"/>
            <source>
              <context value="g"/>
            </source>
            <target>
              <context value="cg"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Allergies and adverse reactions Document"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="codeText"/>
          <source>
            <context value="g"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Allergy reviewed at the surgical safety checklist"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="note2"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'allergy/drug'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note3"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'allergy/anaesthesia'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="note4"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="linkId = 'allergy/other'"/>
        </source>
        <rule>
          <name value="answer"/>
          <source>
            <context value="it"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="text"/>
            <source>
              <context value="a"/>
              <element value="value"/>
              <variable value="txt"/>
            </source>
            <target>
              <context value="obs"/>
              <element value="note"/>
              <variable value="n"/>
            </target>
            <target>
              <context value="n"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="txt"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="comp_who_check_no_known_allergies"/>
        <source>
          <context value="g"/>
          <element value="item"/>
          <variable value="it"/>
          <condition value="(linkId = 'allergy/none-known') and answer.value.exists()"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="component"/>
          <variable value="comp"/>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
            <element value="code"/>
            <variable value="cc"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="it"/>
            </source>
            <target>
              <context value="cc"/>
              <element value="coding"/>
              <variable value="cg"/>
            </target>
            <rule>
              <name value="sys"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="cd"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="who-check-no-known-allergies"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="dsp"/>
              <source>
                <context value="it"/>
              </source>
              <target>
                <context value="cg"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="No known allergies"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="it"/>
          </source>
          <target>
            <context value="comp"/>
          </target>
          <dependent>
            <name value="SetComponentCodedValue"/>
            <parameter>
              <valueId value="it"/>
            </parameter>
            <parameter>
              <valueId value="comp"/>
            </parameter>
          </dependent>
        </rule>
      </rule>
      <documentation value="── Allergy recorded on the checklist ───────────────────────────────────&#xD;&#xA;Recorded as an Observation, not an AllergyIntolerance. The checklist asks&#xD;&#xA;the team to *review* a known allergy, not to record a new one; the drug,&#xD;&#xA;anaesthetic and other lines are what they read out, and creating an&#xD;&#xA;AllergyIntolerance from a read-back would duplicate whatever the pharmacy&#xD;&#xA;already holds."/>
    </rule>
  </group>
  <group>
    <name value="BuildObsBase"/>
    <documentation value="─────────────────────────────────────────────────────────────────────────────&#xD;&#xA;Shared scaffolding. Repeated in each map rather than imported: the transform&#xD;&#xA;engine resolves `imports` against whatever StructureMaps happen to be on the&#xD;&#xA;server, and a form that stops extracting because a shared map was not&#xD;&#xA;uploaded is a worse failure than a duplicated group.&#xD;&#xA;Two notes on what the publisher's StructureMap validator says about this file.&#xD;&#xA;Source parameters below are left untyped on purpose. Writing `: Element` makes&#xD;&#xA;the validator compare QuestionnaireResponse.item against the literal 'Element'&#xD;&#xA;and report them as incompatible with each other, which is noise, not a finding.&#xD;&#xA;`evaluate(context, expression)` is flagged as &quot;takes 1 parameter but 2 were&#xD;&#xA;found&quot;. Leave it. The FML parser in the same jar refuses the one-argument form&#xD;&#xA;outright -- it wants a parameter, a comma, then the FHIRPath -- so the&#xD;&#xA;publisher is objecting to what its own compiler emits. Two arguments is the&#xD;&#xA;only form that compiles, and it is what the R5 transform engine executes.&#xD;&#xA;─────────────────────────────────────────────────────────────────────────────"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="responseProvenance"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
      </target>
      <dependent>
        <name value="SetResponseProvenance"/>
        <parameter>
          <valueId value="qr"/>
        </parameter>
        <parameter>
          <valueId value="obs"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="idAndFullUrl"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
      <dependent>
        <name value="SetObservationFullUrl"/>
        <parameter>
          <valueId value="obs"/>
        </parameter>
        <parameter>
          <valueId value="entry"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="entryRequest"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="request"/>
        <variable value="request"/>
      </target>
      <rule>
        <name value="requestMethod"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="requestUrl"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="encounter"/>
      <source>
        <context value="qr"/>
        <element value="encounter"/>
        <variable value="e"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="encounter"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="e"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="effective"/>
      <source>
        <context value="qr"/>
        <element value="authored"/>
        <variable value="t"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="effective"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="t"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="performerFromSource"/>
      <source>
        <context value="qr"/>
        <element value="source"/>
        <variable value="src"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="performer"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="src"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="performerFallback"/>
      <source>
        <context value="qr"/>
        <condition value="source.exists().not()"/>
      </source>
      <rule>
        <name value="performerFromAuthor"/>
        <source>
          <context value="qr"/>
          <element value="author"/>
          <variable value="a"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="performer"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="a"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="linkQuestionnaireResponse"/>
      <source>
        <context value="qr"/>
        <element value="id"/>
        <variable value="qid"/>
        <condition value="$this.hasValue()"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="derivedFrom"/>
        <variable value="ref"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="ref"/>
        <element value="reference"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="qid"/>
        </parameter>
      </target>
      <documentation value="A stored response's id already reads &quot;QuestionnaireResponse/&lt;id&gt;&quot;, so it is&#xD;&#xA;a relative reference as it stands. The hasValue() guard is what stops an&#xD;&#xA;unsaved response -- one posted straight to $extract rather than saved first&#xD;&#xA;-- from writing &quot;QuestionnaireResponse/null&quot; into the record."/>
    </rule>
  </group>
  <group>
    <name value="SetObservationFullUrl"/>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="assignFullUrl"/>
      <source>
        <context value="obs"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://fhir.slade360.co.ke/fhir/Observation/"/>
        </parameter>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SetComponentCodedValue"/>
    <documentation value="The two answer shapes a component can carry. Both read the answer through the&#xD;&#xA;untyped `.value` accessor: reading `valueCoding` or `valueQuantity` by its&#xD;&#xA;typed property name fails at transform time on HAPI R5 with &quot;Attempt to read&#xD;&#xA;invalid property ... on QuestionnaireResponse.item.answer&quot;."/>
    <input>
      <name value="it"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="comp"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="componentAnswer"/>
      <source>
        <context value="it"/>
        <element value="answer"/>
        <listMode value="first"/>
        <variable value="a"/>
      </source>
      <rule>
        <name value="codedValue"/>
        <source>
          <context value="a"/>
          <element value="value"/>
          <variable value="cv"/>
        </source>
        <target>
          <context value="comp"/>
          <element value="value"/>
          <variable value="cc"/>
          <transform value="create"/>
          <parameter>
            <valueString value="CodeableConcept"/>
          </parameter>
        </target>
        <rule>
          <name value="valueCoding"/>
          <source>
            <context value="cv"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="coding"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="cv"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="valueText"/>
          <source>
            <context value="cv"/>
            <element value="display"/>
            <variable value="d"/>
          </source>
          <target>
            <context value="cc"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="d"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetComponentValue"/>
    <input>
      <name value="it"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="comp"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="componentAnswer"/>
      <source>
        <context value="it"/>
        <element value="answer"/>
        <listMode value="first"/>
        <variable value="a"/>
      </source>
      <rule>
        <name value="plainValue"/>
        <source>
          <context value="a"/>
          <element value="value"/>
          <variable value="v"/>
        </source>
        <target>
          <context value="comp"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="v"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetSurveyCategory"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="category"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="categoryCoding"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="categorySystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="survey"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Survey"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetVitalSignsCategory"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="category"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="categoryCoding"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="categorySystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="vital-signs"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Vital Signs"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetExamCategory"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="category"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="categoryCoding"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="categorySystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="exam"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Exam"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="BuildServiceRequestBase"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="r"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="responseProvenance"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
      </target>
      <dependent>
        <name value="SetResponseProvenance"/>
        <parameter>
          <valueId value="qr"/>
        </parameter>
        <parameter>
          <valueId value="r"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="idAndFullUrl"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
      <dependent>
        <name value="SetServiceRequestFullUrl"/>
        <parameter>
          <valueId value="r"/>
        </parameter>
        <parameter>
          <valueId value="entry"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="entryRequest"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="request"/>
        <variable value="request"/>
      </target>
      <rule>
        <name value="requestMethod"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="requestUrl"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="ServiceRequest"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="r"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SetServiceRequestFullUrl"/>
    <input>
      <name value="r"/>
      <type value="ServiceRequest"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="assignFullUrl"/>
      <source>
        <context value="r"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://fhir.slade360.co.ke/fhir/ServiceRequest/"/>
        </parameter>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SetResponseProvenance"/>
    <documentation value="── Provenance and tenancy ───────────────────────────────────────────────────&#xD;&#xA;Two tags on everything this map creates. The first says which questionnaire&#xD;&#xA;produced it, so a form that reopens mid-admission recalls its own earlier&#xD;&#xA;entries and not another form's. The second copies the tenant tags off the&#xD;&#xA;response, because nothing else on the path puts them there.&#xD;&#xA;The code is the form's document type, not the questionnaire's id: every&#xD;&#xA;environment mints its own ids, and there is only one set of maps, so an id&#xD;&#xA;here would tie the tag to whichever environment stamped it.&#xD;&#xA;── Provenance and tenancy ───────────────────────────────────────────────────"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="r"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="provenanceMeta"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="r"/>
        <element value="meta"/>
        <variable value="m"/>
      </target>
      <rule>
        <name value="provenanceTag"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="m"/>
          <element value="tag"/>
          <variable value="t"/>
        </target>
        <rule>
          <name value="provenanceSystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="t"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://slade360edi.com/questionnaire-provenance"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="provenanceCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="t"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="surgical-safety-checklist"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="provenanceDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="t"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Surgical safety checklist"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="tenantTags"/>
      <source>
        <context value="qr"/>
        <element value="meta"/>
        <variable value="qm"/>
      </source>
      <rule>
        <name value="copyTag"/>
        <source>
          <context value="qm"/>
          <element value="tag"/>
          <variable value="qt"/>
        </source>
        <target>
          <context value="r"/>
          <element value="meta"/>
          <variable value="m"/>
        </target>
        <target>
          <context value="m"/>
          <element value="tag"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="qt"/>
          </parameter>
        </target>
      </rule>
      <documentation value="Every tag the response carries, onto the resource. `meta` is 0..1, so this&#xD;&#xA;lands on the same meta the rule above created rather than a second one."/>
    </rule>
  </group>
</StructureMap>