SGHI FHIR Profile Implementation Guide
0.1.0 - ci-build

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

: Medical Report Extraction - TTL Representation

Active as of 2026-09-14

Raw ttl | Download

@prefix fhir: <http://hl7.org/fhir/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

<http://hl7.org/fhir/StructureMap/ExtractMedicalReport> a fhir:StructureMap ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:id [ fhir:v "ExtractMedicalReport"] ; # 
  fhir:text [
     fhir:status [ fhir:v "generated" ] ;
     fhir:div [ fhir:v "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: StructureMap ExtractMedicalReport</b></p><a name=\"ExtractMedicalReport\"> </a><a name=\"hcExtractMedicalReport\"> </a><pre class=\"fml\">\r\n<span style=\"color: #cc00cc\">/// <b>url</b> = </span><span style=\"color: blue\">'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractMedicalReport'</span>\r\n<span style=\"color: #cc00cc\">/// <b>name</b> = </span><span style=\"color: blue\">'ExtractMedicalReport'</span>\r\n<span style=\"color: #cc00cc\">/// <b>title</b> = </span><span style=\"color: blue\">'Medical Report Extraction'</span>\r\n<span style=\"color: #cc00cc\">/// <b>status</b> = </span><span style=\"color: blue\">'active'</span>\r\n<span style=\"color: #cc00cc\">/// <b>description</b> = </span><span style=\"color: blue\">'A medical report is written once, read as a whole, and handed to whoever asked for it -- an insurer, a court, another hospital -- so it extracts as a Composition under LOINC 34133-9 with one section per printed heading, plus a Condition per diagnosis line so the report does not become the only place the diagnosis is written down. Each section names an Observation carrying its text: Narrative.div is an XhtmlType this engine cannot build from FML, and referencing an Observation is the better shape anyway, because the text becomes something a query can reach rather than a blob inside a document. The stay itself lands in Composition.event.period, which is what makes the report answer \\'when was this admission\\'.'</span>\r\n\r\n<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>\r\n<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>\r\n<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>\r\n<b>uses</b><span style=\"color: navy\"> &quot;</span><a href=\"http://hl7.org/fhir/R5/composition.html\" title=\"Composition\">http://hl7.org/fhir/StructureDefinition/Composition</a><span style=\"color: navy\">&quot; </span><b>alias </b>Composition <b>as </b><b>target</b>\r\n<b>uses</b><span style=\"color: navy\"> &quot;</span><a href=\"http://hl7.org/fhir/R5/condition.html\" title=\"Condition\">http://hl7.org/fhir/StructureDefinition/Condition</a><span style=\"color: navy\">&quot; </span><b>alias </b>Condition <b>as </b><b>target</b>\r\n\r\n<b>group </b>ExtractMedicalReport<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\"> {\r\n</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>\r\n  qr<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\">'Composition'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">comp</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    qr<span style=\"color: navy\"><b> -&gt; </b></span> comp<span style=\"color: navy\">, </span> entry<b> then </b>BuildCompositionBase<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">comp</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>\r\n    qr<span style=\"color: navy\"><b> -&gt; </b></span>comp.status = <span style=\"color: blue\">'final'</span> <i>&quot;status&quot;</i><span style=\"color: navy\">;</span>\r\n    qr<span style=\"color: navy\"><b> -&gt; </b></span>comp.title = <span style=\"color: blue\">'Medical report'</span> <i>&quot;title&quot;</i><span style=\"color: navy\">;</span>\r\n    qr.authored<b> as </b><span style=\"color: maroon\">t</span><span style=\"color: navy\"><b> -&gt; </b></span>comp.date = <span style=\"color: maroon\">t</span> <i>&quot;date&quot;</i><span style=\"color: navy\">;</span>\r\n    qr.encounter<b> as </b><span style=\"color: maroon\">e</span><span style=\"color: navy\"><b> -&gt; </b></span>comp.encounter = <span style=\"color: maroon\">e</span><span style=\"color: navy\">;</span>\r\n    qr<span style=\"color: navy\"><b> -&gt; </b></span>comp.type<b> as </b><span style=\"color: maroon\">tp</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      qr<span style=\"color: navy\"><b> -&gt; </b></span>tp.coding<b> as </b><span style=\"color: maroon\">cg</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        qr<span style=\"color: navy\"><b> -&gt; </b></span>cg.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style=\"color: navy\">;</span>\r\n        qr<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'34133-9'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n        qr<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'Summary of episode note'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;type&quot;</i><span style=\"color: navy\">;</span>\r\n    qr<span style=\"color: navy\"><b> -&gt; </b></span>comp.category<b> as </b><span style=\"color: maroon\">cat</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      qr<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\"> {\r\n</span>        qr<span style=\"color: navy\"><b> -&gt; </b></span>cg.system = <span style=\"color: blue\">'https://fhir.slade360.co.ke/fhir/CodeSystem/document-type-codesystem'</span> <i>&quot;sys&quot;</i><span style=\"color: navy\">;</span>\r\n        qr<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'medical-report'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n        qr<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'Medical report'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;category&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">The doctor who signed it is the author, and the form's own signature</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">block is what says so -- not qr.source, which is whoever keyed it in.</span>\r\n    qr.item<b> as </b><span style=\"color: maroon\">g</span><b> where </b><span style=\"color: navy\">(</span>linkId = 'sign-off'<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      g.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'sign-off/doctor') and answer.value.exists()<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          a.value<b> as </b><span style=\"color: maroon\">ref</span><span style=\"color: navy\"><b> -&gt; </b></span>comp.author = <span style=\"color: maroon\">ref</span> <i>&quot;author&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;authorRule&quot;</i><span style=\"color: navy\">;</span>\r\n      g.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'sign-off/purpose') and answer.value.exists()<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          a.value<b> as </b><span style=\"color: maroon\">txt</span><span style=\"color: navy\"><b> -&gt; </b></span> comp.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;purposeNote&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;purposeRule&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;signOffGroup&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">── The admission the report is about ─────────────────────────────────</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">Composition.event.period is a Period of dateTimes and the form asks for</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">dates, hence the casts: a DateType into a dateTime element fails at</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">transform time rather than at compile time.</span>\r\n    qr.item<b> as </b><span style=\"color: maroon\">g</span><b> where </b><span style=\"color: navy\">(</span>linkId = 'stay'<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      g<span style=\"color: navy\"><b> -&gt; </b></span>comp.event<b> as </b><span style=\"color: maroon\">ev</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        g<span style=\"color: navy\"><b> -&gt; </b></span>ev.period<b> as </b><span style=\"color: maroon\">per</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          g.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'stay/admitted-on') and answer.value.exists()<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              a.value<b> as </b><span style=\"color: maroon\">v</span><span style=\"color: navy\"><b> -&gt; </b></span>per.start = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">v</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'dateTime'</span><span style=\"color: navy\">)</span> <i>&quot;start&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;admittedRule&quot;</i><span style=\"color: navy\">;</span>\r\n          g.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'stay/discharged-on') and answer.value.exists()<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              a.value<b> as </b><span style=\"color: maroon\">v</span><span style=\"color: navy\"><b> -&gt; </b></span>per.end = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">v</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'dateTime'</span><span style=\"color: navy\">)</span> <i>&quot;end&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;dischargedRule&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;period&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;event&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;stayGroup&quot;</i><span style=\"color: navy\">;</span>\r\n    qr.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'clinical-summary') and answer.value.exists()<span style=\"color: navy\">)</span><span style=\"color: navy\"><b> -&gt; </b></span>comp.section<b> as </b><span style=\"color: maroon\">sec</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.title = <span style=\"color: blue\">'Clinical summary'</span> <i>&quot;title&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.code<b> as </b><span style=\"color: maroon\">sc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        it<span style=\"color: navy\"><b> -&gt; </b></span>sc.coding<b> as </b><span style=\"color: maroon\">cg</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'11329-0'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'History general Narrative - Reported'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span> bundle.entry<b> as </b><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">, </span> sentry.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\">sobs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        qr<span style=\"color: navy\"><b> -&gt; </b></span> sobs<span style=\"color: navy\">, </span> sentry<b> then </b>BuildObsBase<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">)</span> <i>&quot;base&quot;</i><span style=\"color: navy\">;</span>\r\n        qr<span style=\"color: navy\"><b> -&gt; </b></span>sobs<b> then </b>SetSurveyCategory<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;category&quot;</i><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span>sobs.code<b> as </b><span style=\"color: maroon\">scc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.coding<b> as </b><span style=\"color: maroon\">scg</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.code = <span style=\"color: blue\">'11329-0'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.display = <span style=\"color: blue\">'History general Narrative - Reported'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.text = <span style=\"color: blue\">'Clinical summary on the Medical report'</span> <i>&quot;codeText&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n        it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          a.value<b> as </b><span style=\"color: maroon\">txt</span><span style=\"color: navy\"><b> -&gt; </b></span> sobs.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>\r\n        <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span> sec.entry = <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\">sref</span><span style=\"color: navy\">, </span> sref.reference = <b>reference</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;linkEntry&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;sectionObservation&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;section_clinical_summary&quot;</i><span style=\"color: navy\">;</span>\r\n    qr.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'past-medical-surgical-history') and answer.value.exists()<span style=\"color: navy\">)</span><span style=\"color: navy\"><b> -&gt; </b></span>comp.section<b> as </b><span style=\"color: maroon\">sec</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.title = <span style=\"color: blue\">'Past medical and surgical history'</span> <i>&quot;title&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.code<b> as </b><span style=\"color: maroon\">sc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        it<span style=\"color: navy\"><b> -&gt; </b></span>sc.coding<b> as </b><span style=\"color: maroon\">cg</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'11348-0'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'History of Past illness note'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span> bundle.entry<b> as </b><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">, </span> sentry.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\">sobs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        qr<span style=\"color: navy\"><b> -&gt; </b></span> sobs<span style=\"color: navy\">, </span> sentry<b> then </b>BuildObsBase<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">)</span> <i>&quot;base&quot;</i><span style=\"color: navy\">;</span>\r\n        qr<span style=\"color: navy\"><b> -&gt; </b></span>sobs<b> then </b>SetSurveyCategory<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;category&quot;</i><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span>sobs.code<b> as </b><span style=\"color: maroon\">scc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.coding<b> as </b><span style=\"color: maroon\">scg</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.code = <span style=\"color: blue\">'11348-0'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.display = <span style=\"color: blue\">'History of Past illness note'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.text = <span style=\"color: blue\">'Past medical and surgical history on the Medical report'</span> <i>&quot;codeText&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n        it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          a.value<b> as </b><span style=\"color: maroon\">txt</span><span style=\"color: navy\"><b> -&gt; </b></span> sobs.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>\r\n        <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span> sec.entry = <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\">sref</span><span style=\"color: navy\">, </span> sref.reference = <b>reference</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;linkEntry&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;sectionObservation&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;section_past_medical_surgical_history&quot;</i><span style=\"color: navy\">;</span>\r\n    qr.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'investigations') and answer.value.exists()<span style=\"color: navy\">)</span><span style=\"color: navy\"><b> -&gt; </b></span>comp.section<b> as </b><span style=\"color: maroon\">sec</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.title = <span style=\"color: blue\">'Investigations'</span> <i>&quot;title&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.code<b> as </b><span style=\"color: maroon\">sc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        it<span style=\"color: navy\"><b> -&gt; </b></span>sc.coding<b> as </b><span style=\"color: maroon\">cg</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'30954-2'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'Relevant diagnostic tests/laboratory data note'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span> bundle.entry<b> as </b><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">, </span> sentry.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\">sobs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        qr<span style=\"color: navy\"><b> -&gt; </b></span> sobs<span style=\"color: navy\">, </span> sentry<b> then </b>BuildObsBase<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">)</span> <i>&quot;base&quot;</i><span style=\"color: navy\">;</span>\r\n        qr<span style=\"color: navy\"><b> -&gt; </b></span>sobs<b> then </b>SetSurveyCategory<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;category&quot;</i><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span>sobs.code<b> as </b><span style=\"color: maroon\">scc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.coding<b> as </b><span style=\"color: maroon\">scg</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.code = <span style=\"color: blue\">'30954-2'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.display = <span style=\"color: blue\">'Relevant diagnostic tests/laboratory data note'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.text = <span style=\"color: blue\">'Investigations on the Medical report'</span> <i>&quot;codeText&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n        it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          a.value<b> as </b><span style=\"color: maroon\">txt</span><span style=\"color: navy\"><b> -&gt; </b></span> sobs.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>\r\n        <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span> sec.entry = <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\">sref</span><span style=\"color: navy\">, </span> sref.reference = <b>reference</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;linkEntry&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;sectionObservation&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;section_investigations&quot;</i><span style=\"color: navy\">;</span>\r\n    qr.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'interventions') and answer.value.exists()<span style=\"color: navy\">)</span><span style=\"color: navy\"><b> -&gt; </b></span>comp.section<b> as </b><span style=\"color: maroon\">sec</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.title = <span style=\"color: blue\">'Interventions'</span> <i>&quot;title&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.code<b> as </b><span style=\"color: maroon\">sc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        it<span style=\"color: navy\"><b> -&gt; </b></span>sc.coding<b> as </b><span style=\"color: maroon\">cg</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'62387-6'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'Interventions Narrative'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span> bundle.entry<b> as </b><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">, </span> sentry.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\">sobs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        qr<span style=\"color: navy\"><b> -&gt; </b></span> sobs<span style=\"color: navy\">, </span> sentry<b> then </b>BuildObsBase<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">)</span> <i>&quot;base&quot;</i><span style=\"color: navy\">;</span>\r\n        qr<span style=\"color: navy\"><b> -&gt; </b></span>sobs<b> then </b>SetSurveyCategory<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;category&quot;</i><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span>sobs.code<b> as </b><span style=\"color: maroon\">scc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.coding<b> as </b><span style=\"color: maroon\">scg</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.code = <span style=\"color: blue\">'62387-6'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.display = <span style=\"color: blue\">'Interventions Narrative'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.text = <span style=\"color: blue\">'Interventions on the Medical report'</span> <i>&quot;codeText&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n        it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          a.value<b> as </b><span style=\"color: maroon\">txt</span><span style=\"color: navy\"><b> -&gt; </b></span> sobs.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>\r\n        <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span> sec.entry = <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\">sref</span><span style=\"color: navy\">, </span> sref.reference = <b>reference</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;linkEntry&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;sectionObservation&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;section_interventions&quot;</i><span style=\"color: navy\">;</span>\r\n    qr.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'treatment') and answer.value.exists()<span style=\"color: navy\">)</span><span style=\"color: navy\"><b> -&gt; </b></span>comp.section<b> as </b><span style=\"color: maroon\">sec</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.title = <span style=\"color: blue\">'Treatment'</span> <i>&quot;title&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.code<b> as </b><span style=\"color: maroon\">sc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        it<span style=\"color: navy\"><b> -&gt; </b></span>sc.coding<b> as </b><span style=\"color: maroon\">cg</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'18776-5'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'Plan of care note'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span> bundle.entry<b> as </b><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">, </span> sentry.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\">sobs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        qr<span style=\"color: navy\"><b> -&gt; </b></span> sobs<span style=\"color: navy\">, </span> sentry<b> then </b>BuildObsBase<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">)</span> <i>&quot;base&quot;</i><span style=\"color: navy\">;</span>\r\n        qr<span style=\"color: navy\"><b> -&gt; </b></span>sobs<b> then </b>SetSurveyCategory<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;category&quot;</i><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span>sobs.code<b> as </b><span style=\"color: maroon\">scc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.coding<b> as </b><span style=\"color: maroon\">scg</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.code = <span style=\"color: blue\">'18776-5'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.display = <span style=\"color: blue\">'Plan of care note'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.text = <span style=\"color: blue\">'Treatment on the Medical report'</span> <i>&quot;codeText&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n        it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          a.value<b> as </b><span style=\"color: maroon\">txt</span><span style=\"color: navy\"><b> -&gt; </b></span> sobs.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>\r\n        <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span> sec.entry = <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\">sref</span><span style=\"color: navy\">, </span> sref.reference = <b>reference</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;linkEntry&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;sectionObservation&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;section_treatment&quot;</i><span style=\"color: navy\">;</span>\r\n    qr.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'discharge-instructions-and-medications') and answer.value.exists()<span style=\"color: navy\">)</span><span style=\"color: navy\"><b> -&gt; </b></span>comp.section<b> as </b><span style=\"color: maroon\">sec</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.title = <span style=\"color: blue\">'Discharge instructions and medications'</span> <i>&quot;title&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span>sec.code<b> as </b><span style=\"color: maroon\">sc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        it<span style=\"color: navy\"><b> -&gt; </b></span>sc.coding<b> as </b><span style=\"color: maroon\">cg</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'8653-8'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'Hospital Discharge instructions'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n      it<span style=\"color: navy\"><b> -&gt; </b></span> bundle.entry<b> as </b><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">, </span> sentry.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\">sobs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        qr<span style=\"color: navy\"><b> -&gt; </b></span> sobs<span style=\"color: navy\">, </span> sentry<b> then </b>BuildObsBase<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sentry</span><span style=\"color: navy\">)</span> <i>&quot;base&quot;</i><span style=\"color: navy\">;</span>\r\n        qr<span style=\"color: navy\"><b> -&gt; </b></span>sobs<b> then </b>SetSurveyCategory<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;category&quot;</i><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span>sobs.code<b> as </b><span style=\"color: maroon\">scc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.coding<b> as </b><span style=\"color: maroon\">scg</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;sys&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.code = <span style=\"color: blue\">'8653-8'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>scg.display = <span style=\"color: blue\">'Hospital Discharge instructions'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>scc.text = <span style=\"color: blue\">'Discharge instructions and medications on the Medical report'</span> <i>&quot;codeText&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n        it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          a.value<b> as </b><span style=\"color: maroon\">txt</span><span style=\"color: navy\"><b> -&gt; </b></span> sobs.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>\r\n        <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span> sec.entry = <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\">sref</span><span style=\"color: navy\">, </span> sref.reference = <b>reference</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">sobs</span><span style=\"color: navy\">)</span> <i>&quot;linkEntry&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;sectionObservation&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;section_discharge_instructions_and_medications&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;medicalReportComposition&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">── The diagnoses ───────────────────────────────────────────────────────</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">One Condition per line. Where the writer picked a Condition the patient</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">already has, the reference travels as evidence rather than forking the</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">problem list -- a report written for an insurer should not add a second</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">copy of a diagnosis that is already on the record.</span>\r\n  qr.item<b> as </b><span style=\"color: maroon\">g</span><b> where </b><span style=\"color: navy\">(</span>linkId = 'diagnosis'<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    g.item<b> as </b><span style=\"color: maroon\">d</span><b> where </b><span style=\"color: navy\">(</span>linkId = 'diagnosis/entry'<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      d.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'diagnosis/entry/text') and answer.value.exists()<span style=\"color: navy\">)</span><span style=\"color: navy\"><b> -&gt; </b></span> bundle.entry<b> as </b><span style=\"color: maroon\">entry</span><span style=\"color: navy\">, </span> entry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Condition'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">cond</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        qr<span style=\"color: navy\"><b> -&gt; </b></span> cond<span style=\"color: navy\">, </span> entry<b> then </b>BuildConditionBase<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">cond</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">entry</span><span style=\"color: navy\">)</span> <i>&quot;base&quot;</i><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span>cond.clinicalStatus<b> as </b><span style=\"color: maroon\">cs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          it<span style=\"color: navy\"><b> -&gt; </b></span>cs.coding<b> as </b><span style=\"color: maroon\">cg</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            it<span style=\"color: navy\"><b> -&gt; </b></span>cg.system = <span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/condition-clinical'</span> <i>&quot;sys&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'active'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'Active'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;clinicalStatus&quot;</i><span style=\"color: navy\">;</span>\r\n        it<span style=\"color: navy\"><b> -&gt; </b></span>cond.category<b> as </b><span style=\"color: maroon\">cat</span><b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>            it<span style=\"color: navy\"><b> -&gt; </b></span>cg.system = <span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/condition-category'</span> <i>&quot;sys&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'encounter-diagnosis'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n            it<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'Encounter Diagnosis'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;category&quot;</i><span style=\"color: navy\">;</span>\r\n        it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          a.value<b> as </b><span style=\"color: maroon\">txt</span><span style=\"color: navy\"><b> -&gt; </b></span> cond.code<b> as </b><span style=\"color: maroon\">cc</span><span style=\"color: navy\">, </span> cc.text = <span style=\"color: maroon\">txt</span> <i>&quot;codeText&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n        qr.authored<b> as </b><span style=\"color: maroon\">t</span><span style=\"color: navy\"><b> -&gt; </b></span>cond.recordedDate = <span style=\"color: maroon\">t</span> <i>&quot;recordedDate&quot;</i><span style=\"color: navy\">;</span>\r\n        qr.encounter<b> as </b><span style=\"color: maroon\">e</span><span style=\"color: navy\"><b> -&gt; </b></span>cond.encounter = <span style=\"color: maroon\">e</span><span style=\"color: navy\">;</span>\r\n        d.item<b> as </b><span style=\"color: maroon\">ex</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'diagnosis/entry/condition') and answer.value.exists()<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          ex.answer first<b> as </b><span style=\"color: maroon\">ea</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            ea.value<b> as </b><span style=\"color: maroon\">existing</span><span style=\"color: navy\"><b> -&gt; </b></span> cond.evidence<b> as </b><span style=\"color: maroon\">ev</span><span style=\"color: navy\">, </span> ev.reference = <span style=\"color: maroon\">existing</span> <i>&quot;evidenceReference&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;existingRule&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;diagnosisCondition&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;diagnosisRows&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;diagnosisGroup&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">── The wards ───────────────────────────────────────────────────────────</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Observations rather than anything on the Composition. Which ward a patient</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">was admitted to and which one they left from is a fact about the stay that</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">gets asked in aggregate, and there is nowhere on a Composition to put it</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">where a query would find it.</span>\r\n  qr.item<b> as </b><span style=\"color: maroon\">g</span><b> where </b><span style=\"color: navy\">(</span>linkId = 'stay'<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    g.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'stay/ward-of-admission') 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\"> {\r\n</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>\r\n      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>\r\n      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\"> {\r\n</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\"> {\r\n</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>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'discharge-ward-of-admission'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'Ward of admission'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n      it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n      <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;narr_discharge_ward_of_admission&quot;</i><span style=\"color: navy\">;</span>\r\n    g.item<b> as </b><span style=\"color: maroon\">it</span><b> where </b><span style=\"color: navy\">(</span>(linkId = 'stay/ward-of-discharge') 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\"> {\r\n</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>\r\n      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>\r\n      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\"> {\r\n</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\"> {\r\n</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>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.code = <span style=\"color: blue\">'discharge-ward-of-discharge'</span> <i>&quot;cd&quot;</i><span style=\"color: navy\">;</span>\r\n          it<span style=\"color: navy\"><b> -&gt; </b></span>cg.display = <span style=\"color: blue\">'Ward of discharge'</span> <i>&quot;dsp&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n      it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n      <span style=\"color: navy\">}</span><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;narr_discharge_ward_of_discharge&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;wardGroup&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">─────────────────────────────────────────────────────────────────────────────</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">Shared scaffolding. Repeated in each map rather than imported: the transform</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">engine resolves `imports` against whatever StructureMaps happen to be on the</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">server, and a form that stops extracting because a shared map was not</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">uploaded is a worse failure than a duplicated group.</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">Two notes on what the publisher's StructureMap validator says about this file.</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">Source parameters below are left untyped on purpose. Writing `: Element` makes</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">the validator compare QuestionnaireResponse.item against the literal 'Element'</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">and report them as incompatible with each other, which is noise, not a finding.</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">`evaluate(context, expression)` is flagged as &quot;takes 1 parameter but 2 were</span>\r\n<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>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">outright -- it wants a parameter, a comma, then the FHIRPath -- so the</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">publisher is objecting to what its own compiler emits. Two arguments is the</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">only form that compiles, and it is what the R5 transform engine executes.</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">─────────────────────────────────────────────────────────────────────────────</span>\r\n<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\"> {\r\n</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>\r\n  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>\r\n  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\"> {\r\n</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>\r\n    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>\r\n  <span style=\"color: navy\">}</span> <i>&quot;entryRequest&quot;</i><span style=\"color: navy\">;</span>\r\n  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>\r\n  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>\r\n  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>\r\n  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>\r\n  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>\r\n  qr<b> where </b><span style=\"color: navy\">(</span>source.exists().not()<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n  <span style=\"color: navy\">}</span> <i>&quot;performerFallback&quot;</i><span style=\"color: navy\">;</span>\r\n  <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>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">a relative reference as it stands. The hasValue() guard is what stops an</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">unsaved response -- one posted straight to $extract rather than saved first</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">-- from writing &quot;QuestionnaireResponse/null&quot; into the record.</span>\r\n  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>\r\n<span style=\"color: navy\">}\r\n\r\n</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\"> {\r\n</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>\r\n<span style=\"color: navy\">}\r\n\r\n</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>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">untyped `.value` accessor: reading `valueCoding` or `valueQuantity` by its</span>\r\n<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>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">invalid property ... on QuestionnaireResponse.item.answer&quot;.</span>\r\n<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\"> {\r\n</span>  it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</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>\r\n      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>\r\n    <span style=\"color: navy\">}</span> <i>&quot;codedValue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;componentAnswer&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</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\"> {\r\n</span>  it.answer first<b> as </b><span style=\"color: maroon\">a</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n  <span style=\"color: navy\">}</span> <i>&quot;componentAnswer&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</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\"> {\r\n</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\"> {\r\n</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\"> {\r\n</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>\r\n      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>\r\n      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>\r\n    <span style=\"color: navy\">}</span> <i>&quot;categoryCoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;category&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><b>group </b>BuildCompositionBase<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>Composition, <b>target</b> <span style=\"color: maroon\">entry</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</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>\r\n  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>SetCompositionFullUrl<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>\r\n  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\"> {\r\n</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>\r\n    qr<span style=\"color: navy\"><b> -&gt; </b></span>request.url = <span style=\"color: blue\">'Composition'</span> <i>&quot;requestUrl&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;entryRequest&quot;</i><span style=\"color: navy\">;</span>\r\n  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>\r\n<span style=\"color: navy\">}\r\n\r\n</span><b>group </b>SetCompositionFullUrl<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">r</span><span style=\"color: navy\"> : </span>Composition, <b>target</b> <span style=\"color: maroon\">entry</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</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/Composition/'</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>\r\n<span style=\"color: navy\">}\r\n\r\n</span><b>group </b>BuildConditionBase<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">qr</span><span style=\"color: navy\"> : </span>QR, <b>target</b> <span style=\"color: maroon\">r</span><span style=\"color: navy\"> : </span>Condition, <b>target</b> <span style=\"color: maroon\">entry</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</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>\r\n  qr<span style=\"color: navy\"><b> -&gt; </b></span>r.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span><b> then </b>SetConditionFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">r</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">entry</span><span style=\"color: navy\">)</span> <i>&quot;idAndFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n  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\"> {\r\n</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>\r\n    qr<span style=\"color: navy\"><b> -&gt; </b></span>request.url = <span style=\"color: blue\">'Condition'</span> <i>&quot;requestUrl&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;entryRequest&quot;</i><span style=\"color: navy\">;</span>\r\n  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>\r\n<span style=\"color: navy\">}\r\n\r\n</span><b>group </b>SetConditionFullUrl<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">r</span><span style=\"color: navy\"> : </span>Condition, <b>target</b> <span style=\"color: maroon\">entry</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  r.id<b> as </b><span style=\"color: maroon\">id</span><span style=\"color: navy\"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'https://fhir.slade360.co.ke/fhir/Condition/'</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">id</span><span style=\"color: navy\">)</span> <i>&quot;assignFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">── Provenance and tenancy ───────────────────────────────────────────────────</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">Two tags on everything this map creates. The first says which questionnaire</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">produced it, so a form that reopens mid-admission recalls its own earlier</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">entries and not another form's. The second copies the tenant tags off the</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">response, because nothing else on the path puts them there.</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">The code is the form's document type, not the questionnaire's id: every</span>\r\n<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>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">here would tie the tag to whichever environment stamped it.</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">── Provenance and tenancy ───────────────────────────────────────────────────</span>\r\n<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\"> {\r\n</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\"> {\r\n</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\"> {\r\n</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>\r\n      qr<span style=\"color: navy\"><b> -&gt; </b></span>t.code = <span style=\"color: blue\">'medical-report'</span> <i>&quot;provenanceCode&quot;</i><span style=\"color: navy\">;</span>\r\n      qr<span style=\"color: navy\"><b> -&gt; </b></span>t.display = <span style=\"color: blue\">'Medical report'</span> <i>&quot;provenanceDisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;provenanceTag&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;provenanceMeta&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Every tag the response carries, onto the resource. `meta` is 0..1, so this</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">lands on the same meta the rule above created rather than a second one.</span>\r\n  qr.meta<b> as </b><span style=\"color: maroon\">qm</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n  <span style=\"color: navy\">}</span> <i>&quot;tenantTags&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span></pre></div>"^^rdf:XMLLiteral ]
  ] ; # 
  fhir:url [ fhir:v "https://fhir.slade360.co.ke/fhir/StructureMap/ExtractMedicalReport"^^xsd:anyURI] ; # 
  fhir:version [ fhir:v "0.1.0"] ; # 
  fhir:name [ fhir:v "ExtractMedicalReport"] ; # 
  fhir:title [ fhir:v "Medical Report Extraction"] ; # 
  fhir:status [ fhir:v "active"] ; # 
  fhir:date [ fhir:v "2026-09-14T06:31:13+00:00"^^xsd:dateTime] ; # 
  fhir:publisher [ fhir:v "Kathurima Kimathi"] ; # 
  fhir:contact ( [
     fhir:name [ fhir:v "Kathurima Kimathi" ] ;
     fhir:telecom ( [
       fhir:system [ fhir:v "url" ] ;
       fhir:value [ fhir:v "https://www.linkedin.com/in/kathurima-kimathi/" ]
     ] [
       fhir:system [ fhir:v "email" ] ;
       fhir:value [ fhir:v "kathurimakimathi415@gmail.com" ]
     ] )
  ] [
     fhir:name [ fhir:v "Oscar John" ] ;
     fhir:telecom ( [
       fhir:system [ fhir:v "email" ] ;
       fhir:value [ fhir:v "oscarjohnotieno@gmail.com" ] ;
       fhir:use [ fhir:v "work" ]
     ] )
  ] [
     fhir:name [ fhir:v "Kennedy Omondi" ] ;
     fhir:telecom ( [
       fhir:system [ fhir:v "email" ] ;
       fhir:value [ fhir:v "kennankole@gmail.com" ] ;
       fhir:use [ fhir:v "work" ]
     ] )
  ] ) ; # 
  fhir:description [ fhir:v "A medical report is written once, read as a whole, and handed to whoever asked for it -- an insurer, a court, another hospital -- so it extracts as a Composition under LOINC 34133-9 with one section per printed heading, plus a Condition per diagnosis line so the report does not become the only place the diagnosis is written down. Each section names an Observation carrying its text: Narrative.div is an XhtmlType this engine cannot build from FML, and referencing an Observation is the better shape anyway, because the text becomes something a query can reach rather than a blob inside a document. The stay itself lands in Composition.event.period, which is what makes the report answer 'when was this admission'."] ; # 
  fhir:structure ( [
     fhir:url [
       fhir:v "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"^^xsd:anyURI ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse>
     ] ;
     fhir:mode [ fhir:v "source" ] ;
     fhir:alias [ fhir:v "QR" ]
  ] [
     fhir:url [
       fhir:v "http://hl7.org/fhir/StructureDefinition/Bundle"^^xsd:anyURI ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/Bundle>
     ] ;
     fhir:mode [ fhir:v "target" ] ;
     fhir:alias [ fhir:v "Bundle" ]
  ] [
     fhir:url [
       fhir:v "http://hl7.org/fhir/StructureDefinition/Observation"^^xsd:anyURI ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/Observation>
     ] ;
     fhir:mode [ fhir:v "target" ] ;
     fhir:alias [ fhir:v "Observation" ]
  ] [
     fhir:url [
       fhir:v "http://hl7.org/fhir/StructureDefinition/Composition"^^xsd:anyURI ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/Composition>
     ] ;
     fhir:mode [ fhir:v "target" ] ;
     fhir:alias [ fhir:v "Composition" ]
  ] [
     fhir:url [
       fhir:v "http://hl7.org/fhir/StructureDefinition/Condition"^^xsd:anyURI ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/Condition>
     ] ;
     fhir:mode [ fhir:v "target" ] ;
     fhir:alias [ fhir:v "Condition" ]
  ] ) ; # 
  fhir:group ( [
     fhir:name [ fhir:v "ExtractMedicalReport" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "qr" ] ;
       fhir:type [ fhir:v "QR" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "bundle" ] ;
       fhir:type [ fhir:v "Bundle" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "setBundleType" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "bundle" ] ;
         fhir:element [ fhir:v "type" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:string ;
             fhir:v "transaction"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "medicalReportComposition" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "bundle" ] ;
         fhir:element [ fhir:v "entry" ] ;
         fhir:variable [ fhir:v "entry" ]
       ] [
         fhir:context [ fhir:v "entry" ] ;
         fhir:element [ fhir:v "resource" ] ;
         fhir:variable [ fhir:v "comp" ] ;
         fhir:transform [ fhir:v "create" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:string ;
             fhir:v "Composition"
           ]
         ] )
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "base" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ]
         ] [
           fhir:context [ fhir:v "entry" ]
         ] ) ;
         fhir:dependent ( [
           fhir:name [ fhir:v "BuildCompositionBase" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:id ;
               fhir:v "qr"
             ]
           ] [
             fhir:value [
               a fhir:id ;
               fhir:v "comp"
             ]
           ] [
             fhir:value [
               a fhir:id ;
               fhir:v "entry"
             ]
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "status" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "status" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "final"
             ]
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "title" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "title" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "Medical report"
             ]
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "date" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "authored" ] ;
           fhir:variable [ fhir:v "t" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "date" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:id ;
               fhir:v "t"
             ]
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "encounter" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "encounter" ] ;
           fhir:variable [ fhir:v "e" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "encounter" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:id ;
               fhir:v "e"
             ]
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "type" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "type" ] ;
           fhir:variable [ fhir:v "tp" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "coding" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "tp" ] ;
             fhir:element [ fhir:v "coding" ] ;
             fhir:variable [ fhir:v "cg" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "sys" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cg" ] ;
               fhir:element [ fhir:v "system" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "http://loinc.org"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "cd" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cg" ] ;
               fhir:element [ fhir:v "code" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "34133-9"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "dsp" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cg" ] ;
               fhir:element [ fhir:v "display" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "Summary of episode note"
                 ]
               ] )
             ] )
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "category" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "category" ] ;
           fhir:variable [ fhir:v "cat" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "coding" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "cat" ] ;
             fhir:element [ fhir:v "coding" ] ;
             fhir:variable [ fhir:v "cg" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "sys" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cg" ] ;
               fhir:element [ fhir:v "system" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "https://fhir.slade360.co.ke/fhir/CodeSystem/document-type-codesystem"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "cd" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cg" ] ;
               fhir:element [ fhir:v "code" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "medical-report"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "dsp" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cg" ] ;
               fhir:element [ fhir:v "display" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "Medical report"
                 ]
               ] )
             ] )
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "signOffGroup" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "g" ] ;
           fhir:condition [ fhir:v "linkId = 'sign-off'" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "authorRule" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "g" ] ;
             fhir:element [ fhir:v "item" ] ;
             fhir:variable [ fhir:v "it" ] ;
             fhir:condition [ fhir:v "(linkId = 'sign-off/doctor') and answer.value.exists()" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "answer" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ] ;
               fhir:element [ fhir:v "answer" ] ;
               fhir:listMode [ fhir:v "first" ] ;
               fhir:variable [ fhir:v "a" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "author" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "a" ] ;
                 fhir:element [ fhir:v "value" ] ;
                 fhir:variable [ fhir:v "ref" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "comp" ] ;
                 fhir:element [ fhir:v "author" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:id ;
                     fhir:v "ref"
                   ]
                 ] )
               ] )
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "purposeRule" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "g" ] ;
             fhir:element [ fhir:v "item" ] ;
             fhir:variable [ fhir:v "it" ] ;
             fhir:condition [ fhir:v "(linkId = 'sign-off/purpose') and answer.value.exists()" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "answer" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ] ;
               fhir:element [ fhir:v "answer" ] ;
               fhir:listMode [ fhir:v "first" ] ;
               fhir:variable [ fhir:v "a" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "purposeNote" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "a" ] ;
                 fhir:element [ fhir:v "value" ] ;
                 fhir:variable [ fhir:v "txt" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "comp" ] ;
                 fhir:element [ fhir:v "note" ] ;
                 fhir:variable [ fhir:v "n" ]
               ] [
                 fhir:context [ fhir:v "n" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:id ;
                     fhir:v "txt"
                   ]
                 ] )
               ] )
             ] )
           ] )
         ] ) ;
         fhir:documentation [ fhir:v "The doctor who signed it is the author, and the form's own signature\r\nblock is what says so -- not qr.source, which is whoever keyed it in." ]
       ] [
         fhir:name [ fhir:v "stayGroup" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "g" ] ;
           fhir:condition [ fhir:v "linkId = 'stay'" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "event" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "g" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "comp" ] ;
             fhir:element [ fhir:v "event" ] ;
             fhir:variable [ fhir:v "ev" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "period" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "g" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "ev" ] ;
               fhir:element [ fhir:v "period" ] ;
               fhir:variable [ fhir:v "per" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "admittedRule" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "g" ] ;
                 fhir:element [ fhir:v "item" ] ;
                 fhir:variable [ fhir:v "it" ] ;
                 fhir:condition [ fhir:v "(linkId = 'stay/admitted-on') and answer.value.exists()" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "answer" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ] ;
                   fhir:element [ fhir:v "answer" ] ;
                   fhir:listMode [ fhir:v "first" ] ;
                   fhir:variable [ fhir:v "a" ]
                 ] ) ;
                 fhir:rule ( [
                   fhir:name [ fhir:v "start" ] ;
                   fhir:source ( [
                     fhir:context [ fhir:v "a" ] ;
                     fhir:element [ fhir:v "value" ] ;
                     fhir:variable [ fhir:v "v" ]
                   ] ) ;
                   fhir:target ( [
                     fhir:context [ fhir:v "per" ] ;
                     fhir:element [ fhir:v "start" ] ;
                     fhir:transform [ fhir:v "cast" ] ;
                     fhir:parameter ( [
                       fhir:value [
                         a fhir:id ;
                         fhir:v "v"
                       ]
                     ] [
                       fhir:value [
                         a fhir:string ;
                         fhir:v "dateTime"
                       ]
                     ] )
                   ] )
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "dischargedRule" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "g" ] ;
                 fhir:element [ fhir:v "item" ] ;
                 fhir:variable [ fhir:v "it" ] ;
                 fhir:condition [ fhir:v "(linkId = 'stay/discharged-on') and answer.value.exists()" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "answer" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ] ;
                   fhir:element [ fhir:v "answer" ] ;
                   fhir:listMode [ fhir:v "first" ] ;
                   fhir:variable [ fhir:v "a" ]
                 ] ) ;
                 fhir:rule ( [
                   fhir:name [ fhir:v "end" ] ;
                   fhir:source ( [
                     fhir:context [ fhir:v "a" ] ;
                     fhir:element [ fhir:v "value" ] ;
                     fhir:variable [ fhir:v "v" ]
                   ] ) ;
                   fhir:target ( [
                     fhir:context [ fhir:v "per" ] ;
                     fhir:element [ fhir:v "end" ] ;
                     fhir:transform [ fhir:v "cast" ] ;
                     fhir:parameter ( [
                       fhir:value [
                         a fhir:id ;
                         fhir:v "v"
                       ]
                     ] [
                       fhir:value [
                         a fhir:string ;
                         fhir:v "dateTime"
                       ]
                     ] )
                   ] )
                 ] )
               ] )
             ] )
           ] )
         ] ) ;
         fhir:documentation [ fhir:v "── The admission the report is about ─────────────────────────────────\r\nComposition.event.period is a Period of dateTimes and the form asks for\r\ndates, hence the casts: a DateType into a dateTime element fails at\r\ntransform time rather than at compile time." ]
       ] [
         fhir:name [ fhir:v "section_clinical_summary" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "it" ] ;
           fhir:condition [ fhir:v "(linkId = 'clinical-summary') and answer.value.exists()" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "section" ] ;
           fhir:variable [ fhir:v "sec" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "title" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "title" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Clinical summary"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "code" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "code" ] ;
             fhir:variable [ fhir:v "sc" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "coding" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sc" ] ;
               fhir:element [ fhir:v "coding" ] ;
               fhir:variable [ fhir:v "cg" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "sys" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "system" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "http://loinc.org"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "cd" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "code" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "11329-0"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "dsp" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "display" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "History general Narrative - Reported"
                   ]
                 ] )
               ] )
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "sectionObservation" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "bundle" ] ;
             fhir:element [ fhir:v "entry" ] ;
             fhir:variable [ fhir:v "sentry" ]
           ] [
             fhir:context [ fhir:v "sentry" ] ;
             fhir:element [ fhir:v "resource" ] ;
             fhir:variable [ fhir:v "sobs" ] ;
             fhir:transform [ fhir:v "create" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Observation"
               ]
             ] )
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "base" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] [
               fhir:context [ fhir:v "sentry" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "BuildObsBase" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sentry"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "category" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "SetSurveyCategory" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "code" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ] ;
               fhir:element [ fhir:v "code" ] ;
               fhir:variable [ fhir:v "scc" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "coding" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "coding" ] ;
                 fhir:variable [ fhir:v "scg" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "sys" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "system" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "http://loinc.org"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "cd" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "code" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "11329-0"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "dsp" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "display" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "History general Narrative - Reported"
                     ]
                   ] )
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "codeText" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Clinical summary on the Medical report"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "answer" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ] ;
               fhir:element [ fhir:v "answer" ] ;
               fhir:listMode [ fhir:v "first" ] ;
               fhir:variable [ fhir:v "a" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "text" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "a" ] ;
                 fhir:element [ fhir:v "value" ] ;
                 fhir:variable [ fhir:v "txt" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "sobs" ] ;
                 fhir:element [ fhir:v "note" ] ;
                 fhir:variable [ fhir:v "n" ]
               ] [
                 fhir:context [ fhir:v "n" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:id ;
                     fhir:v "txt"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "linkEntry" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sec" ] ;
               fhir:element [ fhir:v "entry" ] ;
               fhir:variable [ fhir:v "sref" ] ;
               fhir:transform [ fhir:v "create" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "Reference"
                 ]
               ] )
             ] [
               fhir:context [ fhir:v "sref" ] ;
               fhir:element [ fhir:v "reference" ] ;
               fhir:transform [ fhir:v "reference" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "section_past_medical_surgical_history" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "it" ] ;
           fhir:condition [ fhir:v "(linkId = 'past-medical-surgical-history') and answer.value.exists()" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "section" ] ;
           fhir:variable [ fhir:v "sec" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "title" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "title" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Past medical and surgical history"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "code" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "code" ] ;
             fhir:variable [ fhir:v "sc" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "coding" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sc" ] ;
               fhir:element [ fhir:v "coding" ] ;
               fhir:variable [ fhir:v "cg" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "sys" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "system" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "http://loinc.org"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "cd" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "code" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "11348-0"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "dsp" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "display" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "History of Past illness note"
                   ]
                 ] )
               ] )
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "sectionObservation" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "bundle" ] ;
             fhir:element [ fhir:v "entry" ] ;
             fhir:variable [ fhir:v "sentry" ]
           ] [
             fhir:context [ fhir:v "sentry" ] ;
             fhir:element [ fhir:v "resource" ] ;
             fhir:variable [ fhir:v "sobs" ] ;
             fhir:transform [ fhir:v "create" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Observation"
               ]
             ] )
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "base" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] [
               fhir:context [ fhir:v "sentry" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "BuildObsBase" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sentry"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "category" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "SetSurveyCategory" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "code" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ] ;
               fhir:element [ fhir:v "code" ] ;
               fhir:variable [ fhir:v "scc" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "coding" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "coding" ] ;
                 fhir:variable [ fhir:v "scg" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "sys" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "system" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "http://loinc.org"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "cd" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "code" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "11348-0"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "dsp" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "display" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "History of Past illness note"
                     ]
                   ] )
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "codeText" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Past medical and surgical history on the Medical report"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "answer" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ] ;
               fhir:element [ fhir:v "answer" ] ;
               fhir:listMode [ fhir:v "first" ] ;
               fhir:variable [ fhir:v "a" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "text" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "a" ] ;
                 fhir:element [ fhir:v "value" ] ;
                 fhir:variable [ fhir:v "txt" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "sobs" ] ;
                 fhir:element [ fhir:v "note" ] ;
                 fhir:variable [ fhir:v "n" ]
               ] [
                 fhir:context [ fhir:v "n" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:id ;
                     fhir:v "txt"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "linkEntry" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sec" ] ;
               fhir:element [ fhir:v "entry" ] ;
               fhir:variable [ fhir:v "sref" ] ;
               fhir:transform [ fhir:v "create" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "Reference"
                 ]
               ] )
             ] [
               fhir:context [ fhir:v "sref" ] ;
               fhir:element [ fhir:v "reference" ] ;
               fhir:transform [ fhir:v "reference" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "section_investigations" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "it" ] ;
           fhir:condition [ fhir:v "(linkId = 'investigations') and answer.value.exists()" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "section" ] ;
           fhir:variable [ fhir:v "sec" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "title" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "title" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Investigations"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "code" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "code" ] ;
             fhir:variable [ fhir:v "sc" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "coding" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sc" ] ;
               fhir:element [ fhir:v "coding" ] ;
               fhir:variable [ fhir:v "cg" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "sys" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "system" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "http://loinc.org"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "cd" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "code" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "30954-2"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "dsp" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "display" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Relevant diagnostic tests/laboratory data note"
                   ]
                 ] )
               ] )
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "sectionObservation" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "bundle" ] ;
             fhir:element [ fhir:v "entry" ] ;
             fhir:variable [ fhir:v "sentry" ]
           ] [
             fhir:context [ fhir:v "sentry" ] ;
             fhir:element [ fhir:v "resource" ] ;
             fhir:variable [ fhir:v "sobs" ] ;
             fhir:transform [ fhir:v "create" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Observation"
               ]
             ] )
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "base" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] [
               fhir:context [ fhir:v "sentry" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "BuildObsBase" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sentry"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "category" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "SetSurveyCategory" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "code" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ] ;
               fhir:element [ fhir:v "code" ] ;
               fhir:variable [ fhir:v "scc" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "coding" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "coding" ] ;
                 fhir:variable [ fhir:v "scg" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "sys" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "system" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "http://loinc.org"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "cd" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "code" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "30954-2"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "dsp" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "display" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "Relevant diagnostic tests/laboratory data note"
                     ]
                   ] )
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "codeText" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Investigations on the Medical report"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "answer" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ] ;
               fhir:element [ fhir:v "answer" ] ;
               fhir:listMode [ fhir:v "first" ] ;
               fhir:variable [ fhir:v "a" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "text" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "a" ] ;
                 fhir:element [ fhir:v "value" ] ;
                 fhir:variable [ fhir:v "txt" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "sobs" ] ;
                 fhir:element [ fhir:v "note" ] ;
                 fhir:variable [ fhir:v "n" ]
               ] [
                 fhir:context [ fhir:v "n" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:id ;
                     fhir:v "txt"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "linkEntry" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sec" ] ;
               fhir:element [ fhir:v "entry" ] ;
               fhir:variable [ fhir:v "sref" ] ;
               fhir:transform [ fhir:v "create" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "Reference"
                 ]
               ] )
             ] [
               fhir:context [ fhir:v "sref" ] ;
               fhir:element [ fhir:v "reference" ] ;
               fhir:transform [ fhir:v "reference" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "section_interventions" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "it" ] ;
           fhir:condition [ fhir:v "(linkId = 'interventions') and answer.value.exists()" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "section" ] ;
           fhir:variable [ fhir:v "sec" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "title" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "title" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Interventions"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "code" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "code" ] ;
             fhir:variable [ fhir:v "sc" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "coding" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sc" ] ;
               fhir:element [ fhir:v "coding" ] ;
               fhir:variable [ fhir:v "cg" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "sys" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "system" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "http://loinc.org"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "cd" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "code" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "62387-6"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "dsp" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "display" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Interventions Narrative"
                   ]
                 ] )
               ] )
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "sectionObservation" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "bundle" ] ;
             fhir:element [ fhir:v "entry" ] ;
             fhir:variable [ fhir:v "sentry" ]
           ] [
             fhir:context [ fhir:v "sentry" ] ;
             fhir:element [ fhir:v "resource" ] ;
             fhir:variable [ fhir:v "sobs" ] ;
             fhir:transform [ fhir:v "create" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Observation"
               ]
             ] )
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "base" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] [
               fhir:context [ fhir:v "sentry" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "BuildObsBase" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sentry"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "category" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "SetSurveyCategory" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "code" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ] ;
               fhir:element [ fhir:v "code" ] ;
               fhir:variable [ fhir:v "scc" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "coding" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "coding" ] ;
                 fhir:variable [ fhir:v "scg" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "sys" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "system" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "http://loinc.org"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "cd" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "code" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "62387-6"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "dsp" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "display" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "Interventions Narrative"
                     ]
                   ] )
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "codeText" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Interventions on the Medical report"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "answer" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ] ;
               fhir:element [ fhir:v "answer" ] ;
               fhir:listMode [ fhir:v "first" ] ;
               fhir:variable [ fhir:v "a" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "text" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "a" ] ;
                 fhir:element [ fhir:v "value" ] ;
                 fhir:variable [ fhir:v "txt" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "sobs" ] ;
                 fhir:element [ fhir:v "note" ] ;
                 fhir:variable [ fhir:v "n" ]
               ] [
                 fhir:context [ fhir:v "n" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:id ;
                     fhir:v "txt"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "linkEntry" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sec" ] ;
               fhir:element [ fhir:v "entry" ] ;
               fhir:variable [ fhir:v "sref" ] ;
               fhir:transform [ fhir:v "create" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "Reference"
                 ]
               ] )
             ] [
               fhir:context [ fhir:v "sref" ] ;
               fhir:element [ fhir:v "reference" ] ;
               fhir:transform [ fhir:v "reference" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "section_treatment" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "it" ] ;
           fhir:condition [ fhir:v "(linkId = 'treatment') and answer.value.exists()" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "section" ] ;
           fhir:variable [ fhir:v "sec" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "title" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "title" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Treatment"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "code" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "code" ] ;
             fhir:variable [ fhir:v "sc" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "coding" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sc" ] ;
               fhir:element [ fhir:v "coding" ] ;
               fhir:variable [ fhir:v "cg" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "sys" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "system" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "http://loinc.org"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "cd" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "code" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "18776-5"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "dsp" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "display" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Plan of care note"
                   ]
                 ] )
               ] )
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "sectionObservation" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "bundle" ] ;
             fhir:element [ fhir:v "entry" ] ;
             fhir:variable [ fhir:v "sentry" ]
           ] [
             fhir:context [ fhir:v "sentry" ] ;
             fhir:element [ fhir:v "resource" ] ;
             fhir:variable [ fhir:v "sobs" ] ;
             fhir:transform [ fhir:v "create" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Observation"
               ]
             ] )
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "base" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] [
               fhir:context [ fhir:v "sentry" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "BuildObsBase" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sentry"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "category" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "SetSurveyCategory" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "code" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ] ;
               fhir:element [ fhir:v "code" ] ;
               fhir:variable [ fhir:v "scc" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "coding" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "coding" ] ;
                 fhir:variable [ fhir:v "scg" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "sys" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "system" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "http://loinc.org"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "cd" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "code" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "18776-5"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "dsp" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "display" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "Plan of care note"
                     ]
                   ] )
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "codeText" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Treatment on the Medical report"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "answer" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ] ;
               fhir:element [ fhir:v "answer" ] ;
               fhir:listMode [ fhir:v "first" ] ;
               fhir:variable [ fhir:v "a" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "text" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "a" ] ;
                 fhir:element [ fhir:v "value" ] ;
                 fhir:variable [ fhir:v "txt" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "sobs" ] ;
                 fhir:element [ fhir:v "note" ] ;
                 fhir:variable [ fhir:v "n" ]
               ] [
                 fhir:context [ fhir:v "n" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:id ;
                     fhir:v "txt"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "linkEntry" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sec" ] ;
               fhir:element [ fhir:v "entry" ] ;
               fhir:variable [ fhir:v "sref" ] ;
               fhir:transform [ fhir:v "create" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "Reference"
                 ]
               ] )
             ] [
               fhir:context [ fhir:v "sref" ] ;
               fhir:element [ fhir:v "reference" ] ;
               fhir:transform [ fhir:v "reference" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "section_discharge_instructions_and_medications" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "it" ] ;
           fhir:condition [ fhir:v "(linkId = 'discharge-instructions-and-medications') and answer.value.exists()" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "section" ] ;
           fhir:variable [ fhir:v "sec" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "title" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "title" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Discharge instructions and medications"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "code" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "sec" ] ;
             fhir:element [ fhir:v "code" ] ;
             fhir:variable [ fhir:v "sc" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "coding" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sc" ] ;
               fhir:element [ fhir:v "coding" ] ;
               fhir:variable [ fhir:v "cg" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "sys" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "system" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "http://loinc.org"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "cd" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "code" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "8653-8"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "dsp" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "display" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Hospital Discharge instructions"
                   ]
                 ] )
               ] )
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "sectionObservation" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "bundle" ] ;
             fhir:element [ fhir:v "entry" ] ;
             fhir:variable [ fhir:v "sentry" ]
           ] [
             fhir:context [ fhir:v "sentry" ] ;
             fhir:element [ fhir:v "resource" ] ;
             fhir:variable [ fhir:v "sobs" ] ;
             fhir:transform [ fhir:v "create" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Observation"
               ]
             ] )
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "base" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] [
               fhir:context [ fhir:v "sentry" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "BuildObsBase" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sentry"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "category" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "SetSurveyCategory" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "code" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sobs" ] ;
               fhir:element [ fhir:v "code" ] ;
               fhir:variable [ fhir:v "scc" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "coding" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "coding" ] ;
                 fhir:variable [ fhir:v "scg" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "sys" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "system" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "http://loinc.org"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "cd" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "code" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "8653-8"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "dsp" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "scg" ] ;
                   fhir:element [ fhir:v "display" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "Hospital Discharge instructions"
                     ]
                   ] )
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "codeText" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "scc" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Discharge instructions and medications on the Medical report"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "answer" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ] ;
               fhir:element [ fhir:v "answer" ] ;
               fhir:listMode [ fhir:v "first" ] ;
               fhir:variable [ fhir:v "a" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "text" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "a" ] ;
                 fhir:element [ fhir:v "value" ] ;
                 fhir:variable [ fhir:v "txt" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "sobs" ] ;
                 fhir:element [ fhir:v "note" ] ;
                 fhir:variable [ fhir:v "n" ]
               ] [
                 fhir:context [ fhir:v "n" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:id ;
                     fhir:v "txt"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "linkEntry" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "sec" ] ;
               fhir:element [ fhir:v "entry" ] ;
               fhir:variable [ fhir:v "sref" ] ;
               fhir:transform [ fhir:v "create" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:string ;
                   fhir:v "Reference"
                 ]
               ] )
             ] [
               fhir:context [ fhir:v "sref" ] ;
               fhir:element [ fhir:v "reference" ] ;
               fhir:transform [ fhir:v "reference" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "sobs"
                 ]
               ] )
             ] )
           ] )
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "diagnosisGroup" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:element [ fhir:v "item" ] ;
         fhir:variable [ fhir:v "g" ] ;
         fhir:condition [ fhir:v "linkId = 'diagnosis'" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "diagnosisRows" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "g" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "d" ] ;
           fhir:condition [ fhir:v "linkId = 'diagnosis/entry'" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "diagnosisCondition" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "d" ] ;
             fhir:element [ fhir:v "item" ] ;
             fhir:variable [ fhir:v "it" ] ;
             fhir:condition [ fhir:v "(linkId = 'diagnosis/entry/text') and answer.value.exists()" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "bundle" ] ;
             fhir:element [ fhir:v "entry" ] ;
             fhir:variable [ fhir:v "entry" ]
           ] [
             fhir:context [ fhir:v "entry" ] ;
             fhir:element [ fhir:v "resource" ] ;
             fhir:variable [ fhir:v "cond" ] ;
             fhir:transform [ fhir:v "create" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Condition"
               ]
             ] )
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "base" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cond" ]
             ] [
               fhir:context [ fhir:v "entry" ]
             ] ) ;
             fhir:dependent ( [
               fhir:name [ fhir:v "BuildConditionBase" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "qr"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "cond"
                 ]
               ] [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "entry"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "clinicalStatus" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cond" ] ;
               fhir:element [ fhir:v "clinicalStatus" ] ;
               fhir:variable [ fhir:v "cs" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "coding" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cs" ] ;
                 fhir:element [ fhir:v "coding" ] ;
                 fhir:variable [ fhir:v "cg" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "sys" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "cg" ] ;
                   fhir:element [ fhir:v "system" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "http://terminology.hl7.org/CodeSystem/condition-clinical"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "cd" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "cg" ] ;
                   fhir:element [ fhir:v "code" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "active"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "dsp" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "cg" ] ;
                   fhir:element [ fhir:v "display" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "Active"
                     ]
                   ] )
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "category" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cond" ] ;
               fhir:element [ fhir:v "category" ] ;
               fhir:variable [ fhir:v "cat" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "coding" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cat" ] ;
                 fhir:element [ fhir:v "coding" ] ;
                 fhir:variable [ fhir:v "cg" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "sys" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "cg" ] ;
                   fhir:element [ fhir:v "system" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "http://terminology.hl7.org/CodeSystem/condition-category"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "cd" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "cg" ] ;
                   fhir:element [ fhir:v "code" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "encounter-diagnosis"
                     ]
                   ] )
                 ] )
               ] [
                 fhir:name [ fhir:v "dsp" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "it" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "cg" ] ;
                   fhir:element [ fhir:v "display" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:string ;
                       fhir:v "Encounter Diagnosis"
                     ]
                   ] )
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "answer" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ] ;
               fhir:element [ fhir:v "answer" ] ;
               fhir:listMode [ fhir:v "first" ] ;
               fhir:variable [ fhir:v "a" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "codeText" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "a" ] ;
                 fhir:element [ fhir:v "value" ] ;
                 fhir:variable [ fhir:v "txt" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cond" ] ;
                 fhir:element [ fhir:v "code" ] ;
                 fhir:variable [ fhir:v "cc" ]
               ] [
                 fhir:context [ fhir:v "cc" ] ;
                 fhir:element [ fhir:v "text" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:id ;
                     fhir:v "txt"
                   ]
                 ] )
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "recordedDate" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ] ;
               fhir:element [ fhir:v "authored" ] ;
               fhir:variable [ fhir:v "t" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cond" ] ;
               fhir:element [ fhir:v "recordedDate" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "t"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "encounter" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "qr" ] ;
               fhir:element [ fhir:v "encounter" ] ;
               fhir:variable [ fhir:v "e" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cond" ] ;
               fhir:element [ fhir:v "encounter" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "e"
                 ]
               ] )
             ] )
           ] [
             fhir:name [ fhir:v "existingRule" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "d" ] ;
               fhir:element [ fhir:v "item" ] ;
               fhir:variable [ fhir:v "ex" ] ;
               fhir:condition [ fhir:v "(linkId = 'diagnosis/entry/condition') and answer.value.exists()" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "answer" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "ex" ] ;
                 fhir:element [ fhir:v "answer" ] ;
                 fhir:listMode [ fhir:v "first" ] ;
                 fhir:variable [ fhir:v "ea" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "evidenceReference" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "ea" ] ;
                   fhir:element [ fhir:v "value" ] ;
                   fhir:variable [ fhir:v "existing" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "cond" ] ;
                   fhir:element [ fhir:v "evidence" ] ;
                   fhir:variable [ fhir:v "ev" ]
                 ] [
                   fhir:context [ fhir:v "ev" ] ;
                   fhir:element [ fhir:v "reference" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:id ;
                       fhir:v "existing"
                     ]
                   ] )
                 ] )
               ] )
             ] )
           ] )
         ] )
       ] ) ;
       fhir:documentation [ fhir:v "── The diagnoses ───────────────────────────────────────────────────────\r\nOne Condition per line. Where the writer picked a Condition the patient\r\nalready has, the reference travels as evidence rather than forking the\r\nproblem list -- a report written for an insurer should not add a second\r\ncopy of a diagnosis that is already on the record." ]
     ] [
       fhir:name [ fhir:v "wardGroup" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:element [ fhir:v "item" ] ;
         fhir:variable [ fhir:v "g" ] ;
         fhir:condition [ fhir:v "linkId = 'stay'" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "narr_discharge_ward_of_admission" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "g" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "it" ] ;
           fhir:condition [ fhir:v "(linkId = 'stay/ward-of-admission') and answer.value.exists()" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "bundle" ] ;
           fhir:element [ fhir:v "entry" ] ;
           fhir:variable [ fhir:v "entry" ]
         ] [
           fhir:context [ fhir:v "entry" ] ;
           fhir:element [ fhir:v "resource" ] ;
           fhir:variable [ fhir:v "obs" ] ;
           fhir:transform [ fhir:v "create" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "Observation"
             ]
           ] )
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "base" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "obs" ]
           ] [
             fhir:context [ fhir:v "entry" ]
           ] ) ;
           fhir:dependent ( [
             fhir:name [ fhir:v "BuildObsBase" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:id ;
                 fhir:v "qr"
               ]
             ] [
               fhir:value [
                 a fhir:id ;
                 fhir:v "obs"
               ]
             ] [
               fhir:value [
                 a fhir:id ;
                 fhir:v "entry"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "category" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "obs" ]
           ] ) ;
           fhir:dependent ( [
             fhir:name [ fhir:v "SetSurveyCategory" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:id ;
                 fhir:v "qr"
               ]
             ] [
               fhir:value [
                 a fhir:id ;
                 fhir:v "obs"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "code" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "obs" ] ;
             fhir:element [ fhir:v "code" ] ;
             fhir:variable [ fhir:v "cc" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "coding" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cc" ] ;
               fhir:element [ fhir:v "coding" ] ;
               fhir:variable [ fhir:v "cg" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "sys" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "system" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "cd" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "code" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "discharge-ward-of-admission"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "dsp" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "display" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Ward of admission"
                   ]
                 ] )
               ] )
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "answer" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ] ;
             fhir:element [ fhir:v "answer" ] ;
             fhir:listMode [ fhir:v "first" ] ;
             fhir:variable [ fhir:v "a" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "text" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "a" ] ;
               fhir:element [ fhir:v "value" ] ;
               fhir:variable [ fhir:v "txt" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "obs" ] ;
               fhir:element [ fhir:v "note" ] ;
               fhir:variable [ fhir:v "n" ]
             ] [
               fhir:context [ fhir:v "n" ] ;
               fhir:element [ fhir:v "text" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "txt"
                 ]
               ] )
             ] )
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "narr_discharge_ward_of_discharge" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "g" ] ;
           fhir:element [ fhir:v "item" ] ;
           fhir:variable [ fhir:v "it" ] ;
           fhir:condition [ fhir:v "(linkId = 'stay/ward-of-discharge') and answer.value.exists()" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "bundle" ] ;
           fhir:element [ fhir:v "entry" ] ;
           fhir:variable [ fhir:v "entry" ]
         ] [
           fhir:context [ fhir:v "entry" ] ;
           fhir:element [ fhir:v "resource" ] ;
           fhir:variable [ fhir:v "obs" ] ;
           fhir:transform [ fhir:v "create" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "Observation"
             ]
           ] )
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "base" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "obs" ]
           ] [
             fhir:context [ fhir:v "entry" ]
           ] ) ;
           fhir:dependent ( [
             fhir:name [ fhir:v "BuildObsBase" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:id ;
                 fhir:v "qr"
               ]
             ] [
               fhir:value [
                 a fhir:id ;
                 fhir:v "obs"
               ]
             ] [
               fhir:value [
                 a fhir:id ;
                 fhir:v "entry"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "category" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "obs" ]
           ] ) ;
           fhir:dependent ( [
             fhir:name [ fhir:v "SetSurveyCategory" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:id ;
                 fhir:v "qr"
               ]
             ] [
               fhir:value [
                 a fhir:id ;
                 fhir:v "obs"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "code" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "obs" ] ;
             fhir:element [ fhir:v "code" ] ;
             fhir:variable [ fhir:v "cc" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "coding" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "it" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "cc" ] ;
               fhir:element [ fhir:v "coding" ] ;
               fhir:variable [ fhir:v "cg" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "sys" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "system" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "cd" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "code" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "discharge-ward-of-discharge"
                   ]
                 ] )
               ] )
             ] [
               fhir:name [ fhir:v "dsp" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "it" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "cg" ] ;
                 fhir:element [ fhir:v "display" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:string ;
                     fhir:v "Ward of discharge"
                   ]
                 ] )
               ] )
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "answer" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "it" ] ;
             fhir:element [ fhir:v "answer" ] ;
             fhir:listMode [ fhir:v "first" ] ;
             fhir:variable [ fhir:v "a" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "text" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "a" ] ;
               fhir:element [ fhir:v "value" ] ;
               fhir:variable [ fhir:v "txt" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "obs" ] ;
               fhir:element [ fhir:v "note" ] ;
               fhir:variable [ fhir:v "n" ]
             ] [
               fhir:context [ fhir:v "n" ] ;
               fhir:element [ fhir:v "text" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:id ;
                   fhir:v "txt"
                 ]
               ] )
             ] )
           ] )
         ] )
       ] ) ;
       fhir:documentation [ fhir:v "── The wards ───────────────────────────────────────────────────────────\r\nObservations rather than anything on the Composition. Which ward a patient\r\nwas admitted to and which one they left from is a fact about the stay that\r\ngets asked in aggregate, and there is nowhere on a Composition to put it\r\nwhere a query would find it." ]
     ] )
  ] [
     fhir:name [ fhir:v "BuildObsBase" ] ;
     fhir:documentation [ fhir:v "─────────────────────────────────────────────────────────────────────────────\r\nShared scaffolding. Repeated in each map rather than imported: the transform\r\nengine resolves `imports` against whatever StructureMaps happen to be on the\r\nserver, and a form that stops extracting because a shared map was not\r\nuploaded is a worse failure than a duplicated group.\r\nTwo notes on what the publisher's StructureMap validator says about this file.\r\nSource parameters below are left untyped on purpose. Writing `: Element` makes\r\nthe validator compare QuestionnaireResponse.item against the literal 'Element'\r\nand report them as incompatible with each other, which is noise, not a finding.\r\n`evaluate(context, expression)` is flagged as \"takes 1 parameter but 2 were\r\nfound\". Leave it. The FML parser in the same jar refuses the one-argument form\r\noutright -- it wants a parameter, a comma, then the FHIRPath -- so the\r\npublisher is objecting to what its own compiler emits. Two arguments is the\r\nonly form that compiles, and it is what the R5 transform engine executes.\r\n─────────────────────────────────────────────────────────────────────────────" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "qr" ] ;
       fhir:type [ fhir:v "QR" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "obs" ] ;
       fhir:type [ fhir:v "Observation" ] ;
       fhir:mode [ fhir:v "target" ]
     ] [
       fhir:name [ fhir:v "entry" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "responseProvenance" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "obs" ]
       ] ) ;
       fhir:dependent ( [
         fhir:name [ fhir:v "SetResponseProvenance" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "qr"
           ]
         ] [
           fhir:value [
             a fhir:id ;
             fhir:v "obs"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "idAndFullUrl" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "obs" ] ;
         fhir:element [ fhir:v "id" ] ;
         fhir:transform [ fhir:v "uuid" ]
       ] ) ;
       fhir:dependent ( [
         fhir:name [ fhir:v "SetObservationFullUrl" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "obs"
           ]
         ] [
           fhir:value [
             a fhir:id ;
             fhir:v "entry"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "entryRequest" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "entry" ] ;
         fhir:element [ fhir:v "request" ] ;
         fhir:variable [ fhir:v "request" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "requestMethod" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "request" ] ;
           fhir:element [ fhir:v "method" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "POST"
             ]
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "requestUrl" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "request" ] ;
           fhir:element [ fhir:v "url" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "Observation"
             ]
           ] )
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "status" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "obs" ] ;
         fhir:element [ fhir:v "status" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:string ;
             fhir:v "final"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "subject" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:element [ fhir:v "subject" ] ;
         fhir:variable [ fhir:v "s" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "obs" ] ;
         fhir:element [ fhir:v "subject" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "s"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "encounter" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:element [ fhir:v "encounter" ] ;
         fhir:variable [ fhir:v "e" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "obs" ] ;
         fhir:element [ fhir:v "encounter" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "e"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "effective" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:element [ fhir:v "authored" ] ;
         fhir:variable [ fhir:v "t" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "obs" ] ;
         fhir:element [ fhir:v "effective" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "t"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "performerFromSource" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:element [ fhir:v "source" ] ;
         fhir:variable [ fhir:v "src" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "obs" ] ;
         fhir:element [ fhir:v "performer" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "src"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "performerFallback" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:condition [ fhir:v "source.exists().not()" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "performerFromAuthor" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ] ;
           fhir:element [ fhir:v "author" ] ;
           fhir:variable [ fhir:v "a" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "obs" ] ;
           fhir:element [ fhir:v "performer" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:id ;
               fhir:v "a"
             ]
           ] )
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "linkQuestionnaireResponse" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:element [ fhir:v "id" ] ;
         fhir:variable [ fhir:v "qid" ] ;
         fhir:condition [ fhir:v "$this.hasValue()" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "obs" ] ;
         fhir:element [ fhir:v "derivedFrom" ] ;
         fhir:variable [ fhir:v "ref" ] ;
         fhir:transform [ fhir:v "create" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:string ;
             fhir:v "Reference"
           ]
         ] )
       ] [
         fhir:context [ fhir:v "ref" ] ;
         fhir:element [ fhir:v "reference" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "qid"
           ]
         ] )
       ] ) ;
       fhir:documentation [ fhir:v "A stored response's id already reads \"QuestionnaireResponse/<id>\", so it is\r\na relative reference as it stands. The hasValue() guard is what stops an\r\nunsaved response -- one posted straight to $extract rather than saved first\r\n-- from writing \"QuestionnaireResponse/null\" into the record." ]
     ] )
  ] [
     fhir:name [ fhir:v "SetObservationFullUrl" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "obs" ] ;
       fhir:type [ fhir:v "Observation" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "entry" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "assignFullUrl" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "obs" ] ;
         fhir:element [ fhir:v "id" ] ;
         fhir:variable [ fhir:v "id" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "entry" ] ;
         fhir:element [ fhir:v "fullUrl" ] ;
         fhir:transform [ fhir:v "append" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:string ;
             fhir:v "https://fhir.slade360.co.ke/fhir/Observation/"
           ]
         ] [
           fhir:value [
             a fhir:id ;
             fhir:v "id"
           ]
         ] )
       ] )
     ] )
  ] [
     fhir:name [ fhir:v "SetComponentCodedValue" ] ;
     fhir:documentation [ fhir:v "The two answer shapes a component can carry. Both read the answer through the\r\nuntyped `.value` accessor: reading `valueCoding` or `valueQuantity` by its\r\ntyped property name fails at transform time on HAPI R5 with \"Attempt to read\r\ninvalid property ... on QuestionnaireResponse.item.answer\"." ] ;
     fhir:input ( [
       fhir:name [ fhir:v "it" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "comp" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "componentAnswer" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "it" ] ;
         fhir:element [ fhir:v "answer" ] ;
         fhir:listMode [ fhir:v "first" ] ;
         fhir:variable [ fhir:v "a" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "codedValue" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "a" ] ;
           fhir:element [ fhir:v "value" ] ;
           fhir:variable [ fhir:v "cv" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "value" ] ;
           fhir:variable [ fhir:v "cc" ] ;
           fhir:transform [ fhir:v "create" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "CodeableConcept"
             ]
           ] )
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "valueCoding" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "cv" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "cc" ] ;
             fhir:element [ fhir:v "coding" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:id ;
                 fhir:v "cv"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "valueText" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "cv" ] ;
             fhir:element [ fhir:v "display" ] ;
             fhir:variable [ fhir:v "d" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "cc" ] ;
             fhir:element [ fhir:v "text" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:id ;
                 fhir:v "d"
               ]
             ] )
           ] )
         ] )
       ] )
     ] )
  ] [
     fhir:name [ fhir:v "SetComponentValue" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "it" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "comp" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "componentAnswer" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "it" ] ;
         fhir:element [ fhir:v "answer" ] ;
         fhir:listMode [ fhir:v "first" ] ;
         fhir:variable [ fhir:v "a" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "plainValue" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "a" ] ;
           fhir:element [ fhir:v "value" ] ;
           fhir:variable [ fhir:v "v" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "comp" ] ;
           fhir:element [ fhir:v "value" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:id ;
               fhir:v "v"
             ]
           ] )
         ] )
       ] )
     ] )
  ] [
     fhir:name [ fhir:v "SetSurveyCategory" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "qr" ] ;
       fhir:type [ fhir:v "QR" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "obs" ] ;
       fhir:type [ fhir:v "Observation" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "category" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "obs" ] ;
         fhir:element [ fhir:v "category" ] ;
         fhir:variable [ fhir:v "cat" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "categoryCoding" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "cat" ] ;
           fhir:element [ fhir:v "coding" ] ;
           fhir:variable [ fhir:v "coding" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "categorySystem" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "coding" ] ;
             fhir:element [ fhir:v "system" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "http://terminology.hl7.org/CodeSystem/observation-category"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "categoryCode" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "coding" ] ;
             fhir:element [ fhir:v "code" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "survey"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "categoryDisplay" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "coding" ] ;
             fhir:element [ fhir:v "display" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Survey"
               ]
             ] )
           ] )
         ] )
       ] )
     ] )
  ] [
     fhir:name [ fhir:v "BuildCompositionBase" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "qr" ] ;
       fhir:type [ fhir:v "QR" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "r" ] ;
       fhir:type [ fhir:v "Composition" ] ;
       fhir:mode [ fhir:v "target" ]
     ] [
       fhir:name [ fhir:v "entry" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "responseProvenance" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "r" ]
       ] ) ;
       fhir:dependent ( [
         fhir:name [ fhir:v "SetResponseProvenance" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "qr"
           ]
         ] [
           fhir:value [
             a fhir:id ;
             fhir:v "r"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "idAndFullUrl" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "r" ] ;
         fhir:element [ fhir:v "id" ] ;
         fhir:transform [ fhir:v "uuid" ]
       ] ) ;
       fhir:dependent ( [
         fhir:name [ fhir:v "SetCompositionFullUrl" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "r"
           ]
         ] [
           fhir:value [
             a fhir:id ;
             fhir:v "entry"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "entryRequest" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "entry" ] ;
         fhir:element [ fhir:v "request" ] ;
         fhir:variable [ fhir:v "request" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "requestMethod" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "request" ] ;
           fhir:element [ fhir:v "method" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "POST"
             ]
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "requestUrl" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "request" ] ;
           fhir:element [ fhir:v "url" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "Composition"
             ]
           ] )
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "subject" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:element [ fhir:v "subject" ] ;
         fhir:variable [ fhir:v "s" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "r" ] ;
         fhir:element [ fhir:v "subject" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "s"
           ]
         ] )
       ] )
     ] )
  ] [
     fhir:name [ fhir:v "SetCompositionFullUrl" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "r" ] ;
       fhir:type [ fhir:v "Composition" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "entry" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "assignFullUrl" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "r" ] ;
         fhir:element [ fhir:v "id" ] ;
         fhir:variable [ fhir:v "id" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "entry" ] ;
         fhir:element [ fhir:v "fullUrl" ] ;
         fhir:transform [ fhir:v "append" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:string ;
             fhir:v "https://fhir.slade360.co.ke/fhir/Composition/"
           ]
         ] [
           fhir:value [
             a fhir:id ;
             fhir:v "id"
           ]
         ] )
       ] )
     ] )
  ] [
     fhir:name [ fhir:v "BuildConditionBase" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "qr" ] ;
       fhir:type [ fhir:v "QR" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "r" ] ;
       fhir:type [ fhir:v "Condition" ] ;
       fhir:mode [ fhir:v "target" ]
     ] [
       fhir:name [ fhir:v "entry" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "responseProvenance" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "r" ]
       ] ) ;
       fhir:dependent ( [
         fhir:name [ fhir:v "SetResponseProvenance" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "qr"
           ]
         ] [
           fhir:value [
             a fhir:id ;
             fhir:v "r"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "idAndFullUrl" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "r" ] ;
         fhir:element [ fhir:v "id" ] ;
         fhir:transform [ fhir:v "uuid" ]
       ] ) ;
       fhir:dependent ( [
         fhir:name [ fhir:v "SetConditionFullUrl" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "r"
           ]
         ] [
           fhir:value [
             a fhir:id ;
             fhir:v "entry"
           ]
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "entryRequest" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "entry" ] ;
         fhir:element [ fhir:v "request" ] ;
         fhir:variable [ fhir:v "request" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "requestMethod" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "request" ] ;
           fhir:element [ fhir:v "method" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "POST"
             ]
           ] )
         ] )
       ] [
         fhir:name [ fhir:v "requestUrl" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "request" ] ;
           fhir:element [ fhir:v "url" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:string ;
               fhir:v "Condition"
             ]
           ] )
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "subject" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:element [ fhir:v "subject" ] ;
         fhir:variable [ fhir:v "s" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "r" ] ;
         fhir:element [ fhir:v "subject" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:id ;
             fhir:v "s"
           ]
         ] )
       ] )
     ] )
  ] [
     fhir:name [ fhir:v "SetConditionFullUrl" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "r" ] ;
       fhir:type [ fhir:v "Condition" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "entry" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "assignFullUrl" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "r" ] ;
         fhir:element [ fhir:v "id" ] ;
         fhir:variable [ fhir:v "id" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "entry" ] ;
         fhir:element [ fhir:v "fullUrl" ] ;
         fhir:transform [ fhir:v "append" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:string ;
             fhir:v "https://fhir.slade360.co.ke/fhir/Condition/"
           ]
         ] [
           fhir:value [
             a fhir:id ;
             fhir:v "id"
           ]
         ] )
       ] )
     ] )
  ] [
     fhir:name [ fhir:v "SetResponseProvenance" ] ;
     fhir:documentation [ fhir:v "── Provenance and tenancy ───────────────────────────────────────────────────\r\nTwo tags on everything this map creates. The first says which questionnaire\r\nproduced it, so a form that reopens mid-admission recalls its own earlier\r\nentries and not another form's. The second copies the tenant tags off the\r\nresponse, because nothing else on the path puts them there.\r\nThe code is the form's document type, not the questionnaire's id: every\r\nenvironment mints its own ids, and there is only one set of maps, so an id\r\nhere would tie the tag to whichever environment stamped it.\r\n── Provenance and tenancy ───────────────────────────────────────────────────" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "qr" ] ;
       fhir:type [ fhir:v "QR" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "r" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "provenanceMeta" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "r" ] ;
         fhir:element [ fhir:v "meta" ] ;
         fhir:variable [ fhir:v "m" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "provenanceTag" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qr" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "m" ] ;
           fhir:element [ fhir:v "tag" ] ;
           fhir:variable [ fhir:v "t" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "provenanceSystem" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "t" ] ;
             fhir:element [ fhir:v "system" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "http://slade360edi.com/questionnaire-provenance"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "provenanceCode" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "t" ] ;
             fhir:element [ fhir:v "code" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "medical-report"
               ]
             ] )
           ] )
         ] [
           fhir:name [ fhir:v "provenanceDisplay" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "qr" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "t" ] ;
             fhir:element [ fhir:v "display" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:string ;
                 fhir:v "Medical report"
               ]
             ] )
           ] )
         ] )
       ] )
     ] [
       fhir:name [ fhir:v "tenantTags" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "qr" ] ;
         fhir:element [ fhir:v "meta" ] ;
         fhir:variable [ fhir:v "qm" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "copyTag" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "qm" ] ;
           fhir:element [ fhir:v "tag" ] ;
           fhir:variable [ fhir:v "qt" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "r" ] ;
           fhir:element [ fhir:v "meta" ] ;
           fhir:variable [ fhir:v "m" ]
         ] [
           fhir:context [ fhir:v "m" ] ;
           fhir:element [ fhir:v "tag" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:id ;
               fhir:v "qt"
             ]
           ] )
         ] )
       ] ) ;
       fhir:documentation [ fhir:v "Every tag the response carries, onto the resource. `meta` is 0..1, so this\r\nlands on the same meta the rule above created rather than a second one." ]
     ] )
  ] ) . #