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
| Active as of 2026-09-15 |
<StructureMap xmlns="http://hl7.org/fhir">
<id value="GlasgowCommaScaleExtract"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap GlasgowCommaScaleExtract</b></p><a name="GlasgowCommaScaleExtract"> </a><a name="hcGlasgowCommaScaleExtract"> </a><pre class="fml">
<span style="color: #cc00cc">/// <b>url</b> = </span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/StructureMap/GlasgowCommaScaleExtract'</span>
<span style="color: #cc00cc">/// <b>name</b> = </span><span style="color: blue">'GlasgowCommaScaleExtract'</span>
<span style="color: #cc00cc">/// <b>title</b> = </span><span style="color: blue">'Glasgow Coma Scale Extraction'</span>
<span style="color: #cc00cc">/// <b>status</b> = </span><span style="color: blue">'active'</span>
<span style="color: #cc00cc">/// <b>description</b> = </span><span style="color: blue">'One Observation for the Glasgow Coma Scale, carrying the total as its value, the eye, verbal and motor sub-scores as components, and the severity band the total falls in as its interpretation. The total prefers the calculated total the form submits and falls back to summing the answer weights itself, so the score still extracts from a client that does not evaluate SDC expressions.'</span>
<b>uses</b><span style="color: navy"> "</span><a href="http://hl7.org/fhir/R5/questionnaireresponse.html" title="QuestionnaireResponse">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style="color: navy">" </span><b>alias </b>QR <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> "</span><a href="http://hl7.org/fhir/R5/bundle.html" title="Bundle">http://hl7.org/fhir/StructureDefinition/Bundle</a><span style="color: navy">" </span><b>alias </b>Bundle <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> "</span><a href="http://hl7.org/fhir/R5/observation.html" title="Observation">http://hl7.org/fhir/StructureDefinition/Observation</a><span style="color: navy">" </span><b>alias </b>Observation <b>as </b><b>target</b>
<span style="color: navy">// </span><span style="color: green">This map used to emit the three sub-scores as three loose Observations and no</span>
<span style="color: navy">// </span><span style="color: green">total, which left nothing to band and nothing to read as "the GCS". It now</span>
<span style="color: navy">// </span><span style="color: green">produces the same shape as ExtractInpatientCriticalCareAssessment: one</span>
<span style="color: navy">// </span><span style="color: green">Observation with three components. Nothing was consuming the old shape --</span>
<span style="color: navy">// </span><span style="color: green">the questionnaire typed its three items `group` and hung an answerValueSet off</span>
<span style="color: navy">// </span><span style="color: green">them, and a group carries no answer, so no conformant response ever put a value</span>
<span style="color: navy">// </span><span style="color: green">into those Observations. The questionnaire is fixed alongside this map.</span>
<b>group </b>GlasgowCommaScaleExtract<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>bundle.type = <span style="color: blue">'transaction'</span> <i>"setBundleType"</i><span style="color: navy">;</span>
qr<b> where </b><span style="color: navy">(</span>item.where(linkId in ('eye-opening' | 'verbal-response' | 'motor-response')).answer.value.ofType(Coding).exists()<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span> bundle.entry<b> as </b><span style="color: maroon">entry</span><span style="color: navy">, </span> entry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </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>"base"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </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>"category"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>obs.code<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>code.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>coding.system = <span style="color: blue">'http://loinc.org'</span> <i>"codeSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>coding.code = <span style="color: blue">'9269-2'</span> <i>"codeCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>coding.display = <span style="color: blue">'Glasgow coma score total'</span> <i>"codeDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"codeCoding"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"code"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">The submitted total wins; otherwise sum the answers. The form's total item</span>
<span style="color: navy">// </span><span style="color: green">carries the same sum as an SDC calculatedExpression, so the two paths are</span>
<span style="color: navy">// </span><span style="color: green">the same arithmetic and cannot disagree; the fallback is there for a client</span>
<span style="color: navy">// </span><span style="color: green">that does not evaluate SDC.</span>
<span style="color: navy">// </span><span style="color: green">One lookup covers all three sub-scores. Eye runs 1 to 4, verbal 1 to 5 and</span>
<span style="color: navy">// </span><span style="color: green">motor 1 to 6, and no LOINC answer code appears in more than one of the</span>
<span style="color: navy">// </span><span style="color: green">three lists, so a code determines its weight on its own.</span>
<span style="color: navy">// </span><span style="color: green">Guarded on all three sub-scores being present. A GCS of 7 summed from eye</span>
<span style="color: navy">// </span><span style="color: green">and motor alone reads as a comatose patient; the components still extract,</span>
<span style="color: navy">// </span><span style="color: green">but the total does not, because a partial GCS is not a GCS.</span>
qr<b> where </b><span style="color: navy">(</span>item.where(linkId in ('eye-opening' | 'verbal-response' | 'motor-response')).answer.value.ofType(Coding).count() = 3<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>obs.value = evaluate<span style="color: navy">(</span>qr<span style="color: navy">, </span>iif(item.where(linkId = 'gcs-total').answer.value.exists(), item.where(linkId = 'gcs-total').answer.value, item.where(linkId in ('eye-opening' | 'verbal-response' | 'motor-response')).answer.value.ofType(Coding).code.select(iif($this in ('LA6553-7' | 'LA6557-8' | 'LA6562-8'), 1, iif($this in ('LA6554-5' | 'LA6558-6' | 'LA6563-6'), 2, iif($this in ('LA6555-2' | 'LA6559-4' | 'LA6564-4'), 3, iif($this in ('LA6556-0' | 'LA6560-2' | 'LA6565-1'), 4, iif($this in ('LA6561-0' | 'LA6566-9'), 5, iif($this = 'LA6567-7', 6, 0))))))).aggregate($this + $total, 0))<span style="color: navy">)</span> <i>"totalValue"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"totalRule"</i><span style="color: navy">;</span>
qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'eye-opening') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>comp.code<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>code.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>coding.system = <span style="color: blue">'http://loinc.org'</span> <i>"codeSystem"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>coding.code = <span style="color: blue">'9267-6'</span> <i>"codeCode"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>coding.display = <span style="color: blue">'Glasgow coma score eye opening'</span> <i>"codeDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"codeCoding"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"eyeCode"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>"eyeValue"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"eyeRule"</i><span style="color: navy">;</span>
qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'verbal-response') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>comp.code<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>code.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>coding.system = <span style="color: blue">'http://loinc.org'</span> <i>"codeSystem"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>coding.code = <span style="color: blue">'9270-0'</span> <i>"codeCode"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>coding.display = <span style="color: blue">'Glasgow coma score verbal'</span> <i>"codeDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"codeCoding"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"verbalCode"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>"verbalValue"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"verbalRule"</i><span style="color: navy">;</span>
qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'motor-response') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span>obs.component<b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>comp.code<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>code.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>coding.system = <span style="color: blue">'http://loinc.org'</span> <i>"codeSystem"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>coding.code = <span style="color: blue">'9268-4'</span> <i>"codeCode"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>coding.display = <span style="color: blue">'Glasgow coma score motor'</span> <i>"codeDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"codeCoding"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"motorCode"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>comp<b> then </b>SetComponentCodedValue<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">)</span> <i>"motorValue"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"motorRule"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>obs<b> then </b>AddGlasgowInterpretation<span style="color: navy">(</span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>"interpretation"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"glasgowRule"</i><span style="color: navy">;</span>
<span style="color: navy">}
</span><span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</span>
<span style="color: navy">// </span><span style="color: green">The band</span>
<span style="color: navy">// </span><span style="color: green">Teasdale and Jennett's three tiers, as every ward and ambulance service reads</span>
<span style="color: navy">// </span><span style="color: green">them: 13-15 mild, 9-12 moderate, 3-8 severe. Lower is worse, and the scale</span>
<span style="color: navy">// </span><span style="color: green">bottoms out at 3, not 0.</span>
<span style="color: navy">// </span><span style="color: green">This is an Observation.interpretation and not a RiskAssessment. A Glasgow Coma</span>
<span style="color: navy">// </span><span style="color: green">Score says what a patient's consciousness is now; RiskAssessment models the</span>
<span style="color: navy">// </span><span style="color: green">likelihood of a future outcome. Braden and Morse do predict one -- a pressure</span>
<span style="color: navy">// </span><span style="color: green">injury, a fall -- and keep their RiskAssessments; this does not.</span>
<span style="color: navy">// </span><span style="color: green">The published wording is "mild, moderate and severe brain injury", which is</span>
<span style="color: navy">// </span><span style="color: green">how the scale was introduced and how trauma services still say it. It is</span>
<span style="color: navy">// </span><span style="color: green">written as impairment of consciousness here because the same scale is read on</span>
<span style="color: navy">// </span><span style="color: green">a patient in a diabetic coma or a post-ictal state, where nothing has injured</span>
<span style="color: navy">// </span><span style="color: green">the brain and the tier still means what it means.</span>
<span style="color: navy">// </span><span style="color: green">The coding comes from SGHIObservationInterpretation, the value set this IG</span>
<span style="color: navy">// </span><span style="color: green">binds Observation.interpretation to, which offers LL, L, N, H, HH and A.</span>
<span style="color: navy">// </span><span style="color: green">Mild and moderate both take L. The low axis has two rungs, and the threshold</span>
<span style="color: navy">// </span><span style="color: green">worth spending LL on is 8 -- the point below which a patient stops reliably</span>
<span style="color: navy">// </span><span style="color: green">protecting their own airway. That is what a consumer escalates on. Nothing is</span>
<span style="color: navy">// </span><span style="color: green">minted to separate mild from moderate: the tier is a published function of a</span>
<span style="color: navy">// </span><span style="color: green">number this same Observation already carries in its value, so a consumer that</span>
<span style="color: navy">// </span><span style="color: green">needs the exact tier reads the score rather than a second code.</span>
<span style="color: navy">// </span><span style="color: green">A Glasgow Coma Score of 15 is normal and still reads L, because the published</span>
<span style="color: navy">// </span><span style="color: green">band is 13-15 and one code has to cover it. Flagging a normal score is the</span>
<span style="color: navy">// </span><span style="color: green">safe direction to be wrong in; missing a deficit is not.</span>
<span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</span>
<b>group </b>AddGlasgowInterpretation<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">tgt</span><span style="color: navy"> : </span>Observation<span style="color: navy">)</span><span style="color: navy"> {
</span> obs<b> where </b><span style="color: navy">(</span>value.ofType(integer) <= 8<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span>tgt.interpretation<b> as </b><span style="color: maroon">interp</span><b> then</b><span style="color: navy"> {
</span> obs<span style="color: navy"><b> -> </b></span>interp.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span> obs<span style="color: navy"><b> -> </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation'</span> <i>"interpSystem"</i><span style="color: navy">;</span>
obs<span style="color: navy"><b> -> </b></span>coding.code = <span style="color: blue">'LL'</span> <i>"interpCode"</i><span style="color: navy">;</span>
obs<span style="color: navy"><b> -> </b></span>coding.display = <span style="color: blue">'Critical low'</span> <i>"interpDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"interpCoding"</i><span style="color: navy">;</span>
obs<span style="color: navy"><b> -> </b></span>interp.text = <span style="color: blue">'Severe impairment of consciousness (GCS 3-8)'</span> <i>"interpText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"glasgowSevere"</i><span style="color: navy">;</span>
obs<b> where </b><span style="color: navy">(</span>(value.ofType(integer) >= 9) and (value.ofType(integer) <= 12)<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span>tgt.interpretation<b> as </b><span style="color: maroon">interp</span><b> then</b><span style="color: navy"> {
</span> obs<span style="color: navy"><b> -> </b></span>interp.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span> obs<span style="color: navy"><b> -> </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation'</span> <i>"interpSystem"</i><span style="color: navy">;</span>
obs<span style="color: navy"><b> -> </b></span>coding.code = <span style="color: blue">'L'</span> <i>"interpCode"</i><span style="color: navy">;</span>
obs<span style="color: navy"><b> -> </b></span>coding.display = <span style="color: blue">'Low'</span> <i>"interpDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"interpCoding"</i><span style="color: navy">;</span>
obs<span style="color: navy"><b> -> </b></span>interp.text = <span style="color: blue">'Moderate impairment of consciousness (GCS 9-12)'</span> <i>"interpText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"glasgowModerate"</i><span style="color: navy">;</span>
obs<b> where </b><span style="color: navy">(</span>value.ofType(integer) >= 13<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span>tgt.interpretation<b> as </b><span style="color: maroon">interp</span><b> then</b><span style="color: navy"> {
</span> obs<span style="color: navy"><b> -> </b></span>interp.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span> obs<span style="color: navy"><b> -> </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation'</span> <i>"interpSystem"</i><span style="color: navy">;</span>
obs<span style="color: navy"><b> -> </b></span>coding.code = <span style="color: blue">'L'</span> <i>"interpCode"</i><span style="color: navy">;</span>
obs<span style="color: navy"><b> -> </b></span>coding.display = <span style="color: blue">'Low'</span> <i>"interpDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"interpCoding"</i><span style="color: navy">;</span>
obs<span style="color: navy"><b> -> </b></span>interp.text = <span style="color: blue">'Mild impairment of consciousness (GCS 13-15)'</span> <i>"interpText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"glasgowMild"</i><span style="color: navy">;</span>
<span style="color: navy">}
</span><span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</span>
<span style="color: navy">// </span><span style="color: green">Shared scaffolding. Repeated in each map rather than imported: the transform</span>
<span style="color: navy">// </span><span style="color: green">engine resolves `imports` against whatever StructureMaps happen to be on the</span>
<span style="color: navy">// </span><span style="color: green">server, and a form that stops extracting because a shared map was not</span>
<span style="color: navy">// </span><span style="color: green">uploaded is a worse failure than a duplicated group.</span>
<span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</span>
<span style="color: navy">// </span><span style="color: green">Two notes on what the publisher's StructureMap validator says about this file.</span>
<span style="color: navy">// </span><span style="color: green">Source parameters below are left untyped on purpose. Writing `: Element` makes</span>
<span style="color: navy">// </span><span style="color: green">the validator compare QuestionnaireResponse.item against the literal 'Element'</span>
<span style="color: navy">// </span><span style="color: green">and report them as incompatible with each other, which is noise, not a finding.</span>
<span style="color: navy">// </span><span style="color: green">Untyped, it says only that it cannot check the paths.</span>
<span style="color: navy">// </span><span style="color: green">`evaluate(context, expression)` is flagged as "takes 1 parameter but 2 were</span>
<span style="color: navy">// </span><span style="color: green">found". Leave it. The FML parser in the same jar refuses the one-argument form</span>
<span style="color: navy">// </span><span style="color: green">outright -- it wants a parameter, a comma, then the FHIRPath -- so the publisher</span>
<span style="color: navy">// </span><span style="color: green">is objecting to what its own compiler emits. Two arguments is the only form that</span>
<span style="color: navy">// </span><span style="color: green">compiles, and it is what the R5 transform engine executes.</span>
<b>group </b>BuildObsBase<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </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>"idAndFullUrl"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>entry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>request.method = <span style="color: blue">'POST'</span> <i>"requestMethod"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>request.url = <span style="color: blue">'Observation'</span> <i>"requestUrl"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"entryRequest"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>obs.status = <span style="color: blue">'final'</span> <i>"status"</i><span style="color: navy">;</span>
qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -> </b></span>obs.subject = <span style="color: maroon">s</span><span style="color: navy">;</span>
qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -> </b></span>obs.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -> </b></span>obs.effective = <span style="color: maroon">t</span> <i>"effective"</i><span style="color: navy">;</span>
qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -> </b></span>obs.performer = <span style="color: maroon">src</span> <i>"performerFromSource"</i><span style="color: navy">;</span>
qr<b> where </b><span style="color: navy">(</span>source.exists().not()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> qr.author<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -> </b></span>obs.performer = <span style="color: maroon">a</span> <i>"performerFromAuthor"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"performerFallback"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">A stored response's id already reads "QuestionnaireResponse/<id>", so it is a</span>
<span style="color: navy">// </span><span style="color: green">relative reference as it stands. The hasValue() guard is what stops an</span>
<span style="color: navy">// </span><span style="color: green">unsaved response -- one posted straight to $extract rather than saved first --</span>
<span style="color: navy">// </span><span style="color: green">from writing "QuestionnaireResponse/null" into the record.</span>
qr.id<b> as </b><span style="color: maroon">qid</span><b> where </b><span style="color: navy">(</span>$this.hasValue()<span style="color: navy">)</span><span style="color: navy"><b> -> </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>"linkQuestionnaireResponse"</i><span style="color: navy">;</span>
<span style="color: navy">}
</span><b>group </b>SetComponentCodedValue<span style="color: navy">(</span><b>source</b> <span style="color: maroon">it</span>, <b>target</b> <span style="color: maroon">comp</span><span style="color: navy">)</span><span style="color: navy"> {
</span> it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span> a.value<b> as </b><span style="color: maroon">cv</span><span style="color: navy"><b> -> </b></span>comp.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span> cv<span style="color: navy"><b> -> </b></span>cc.coding = <span style="color: maroon">cv</span> <i>"valueCoding"</i><span style="color: navy">;</span>
cv.display<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -> </b></span>cc.text = <span style="color: maroon">d</span> <i>"valueText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"codedValue"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"componentAnswer"</i><span style="color: navy">;</span>
<span style="color: navy">}
</span><b>group </b>SetSurveyCategory<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation<span style="color: navy">)</span><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>obs.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>cat.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>"categorySystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>coding.code = <span style="color: blue">'survey'</span> <i>"categoryCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>coding.display = <span style="color: blue">'Survey'</span> <i>"categoryDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"categoryCoding"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"category"</i><span style="color: navy">;</span>
<span style="color: navy">}
</span><b>group </b>SetObservationFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span> obs.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -> </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>"assignFullUrl"</i><span style="color: navy">;</span>
<span style="color: navy">}
</span></pre></div>
</text>
<url
value="https://fhir.slade360.co.ke/fhir/StructureMap/GlasgowCommaScaleExtract"/>
<version value="0.1.0"/>
<name value="GlasgowCommaScaleExtract"/>
<title value="Glasgow Coma Scale Extraction"/>
<status value="active"/>
<date value="2026-09-15T11:40:24+00:00"/>
<publisher value="Kathurima Kimathi"/>
<contact>
<name value="Kathurima Kimathi"/>
<telecom>
<system value="url"/>
<value value="https://www.linkedin.com/in/kathurima-kimathi/"/>
</telecom>
<telecom>
<system value="email"/>
<value value="kathurimakimathi415@gmail.com"/>
</telecom>
</contact>
<contact>
<name value="Oscar John"/>
<telecom>
<system value="email"/>
<value value="oscarjohnotieno@gmail.com"/>
<use value="work"/>
</telecom>
</contact>
<contact>
<name value="Kennedy Omondi"/>
<telecom>
<system value="email"/>
<value value="kennankole@gmail.com"/>
<use value="work"/>
</telecom>
</contact>
<description
value="One Observation for the Glasgow Coma Scale, carrying the total as its value, the eye, verbal and motor sub-scores as components, and the severity band the total falls in as its interpretation. The total prefers the calculated total the form submits and falls back to summing the answer weights itself, so the score still extracts from a client that does not evaluate SDC expressions."/>
<structure>
<url
value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"/>
<mode value="source"/>
<alias value="QR"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
<mode value="target"/>
<alias value="Bundle"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/StructureDefinition/Observation"/>
<mode value="target"/>
<alias value="Observation"/>
</structure>
<group>
<name value="GlasgowCommaScaleExtract"/>
<documentation
value="This map used to emit the three sub-scores as three loose Observations and no
total, which left nothing to band and nothing to read as "the GCS". It now
produces the same shape as ExtractInpatientCriticalCareAssessment: one
Observation with three components. Nothing was consuming the old shape --
the questionnaire typed its three items `group` and hung an answerValueSet off
them, and a group carries no answer, so no conformant response ever put a value
into those Observations. The questionnaire is fixed alongside this map."/>
<input>
<name value="qr"/>
<type value="QR"/>
<mode value="source"/>
</input>
<input>
<name value="bundle"/>
<type value="Bundle"/>
<mode value="target"/>
</input>
<rule>
<name value="setBundleType"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="bundle"/>
<element value="type"/>
<transform value="copy"/>
<parameter>
<valueString value="transaction"/>
</parameter>
</target>
</rule>
<rule>
<name value="glasgowRule"/>
<source>
<context value="qr"/>
<condition
value="item.where(linkId in ('eye-opening' | 'verbal-response' | 'motor-response')).answer.value.ofType(Coding).exists()"/>
</source>
<target>
<context value="bundle"/>
<element value="entry"/>
<variable value="entry"/>
</target>
<target>
<context value="entry"/>
<element value="resource"/>
<variable value="obs"/>
<transform value="create"/>
<parameter>
<valueString value="Observation"/>
</parameter>
</target>
<rule>
<name value="base"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
</target>
<target>
<context value="entry"/>
</target>
<dependent>
<name value="BuildObsBase"/>
<parameter>
<valueId value="qr"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
<parameter>
<valueId value="entry"/>
</parameter>
</dependent>
</rule>
<rule>
<name value="category"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
</target>
<dependent>
<name value="SetSurveyCategory"/>
<parameter>
<valueId value="qr"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
</dependent>
</rule>
<rule>
<name value="code"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="code"/>
<variable value="code"/>
</target>
<rule>
<name value="codeCoding"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="code"/>
<element value="coding"/>
<variable value="coding"/>
</target>
<rule>
<name value="codeSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="coding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString value="http://loinc.org"/>
</parameter>
</target>
</rule>
<rule>
<name value="codeCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="coding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="9269-2"/>
</parameter>
</target>
</rule>
<rule>
<name value="codeDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="coding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Glasgow coma score total"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="totalRule"/>
<source>
<context value="qr"/>
<condition
value="item.where(linkId in ('eye-opening' | 'verbal-response' | 'motor-response')).answer.value.ofType(Coding).count() = 3"/>
</source>
<rule>
<name value="totalValue"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="value"/>
<transform value="evaluate"/>
<parameter>
<valueId value="qr"/>
</parameter>
<parameter>
<valueString
value="iif(item.where(linkId = 'gcs-total').answer.value.exists(), item.where(linkId = 'gcs-total').answer.value, item.where(linkId in ('eye-opening' | 'verbal-response' | 'motor-response')).answer.value.ofType(Coding).code.select(iif($this in ('LA6553-7' | 'LA6557-8' | 'LA6562-8'), 1, iif($this in ('LA6554-5' | 'LA6558-6' | 'LA6563-6'), 2, iif($this in ('LA6555-2' | 'LA6559-4' | 'LA6564-4'), 3, iif($this in ('LA6556-0' | 'LA6560-2' | 'LA6565-1'), 4, iif($this in ('LA6561-0' | 'LA6566-9'), 5, iif($this = 'LA6567-7', 6, 0))))))).aggregate($this + $total, 0))"/>
</parameter>
</target>
</rule>
<documentation
value="The submitted total wins; otherwise sum the answers. The form's total item
carries the same sum as an SDC calculatedExpression, so the two paths are
the same arithmetic and cannot disagree; the fallback is there for a client
that does not evaluate SDC.
One lookup covers all three sub-scores. Eye runs 1 to 4, verbal 1 to 5 and
motor 1 to 6, and no LOINC answer code appears in more than one of the
three lists, so a code determines its weight on its own.
Guarded on all three sub-scores being present. A GCS of 7 summed from eye
and motor alone reads as a comatose patient; the components still extract,
but the total does not, because a partial GCS is not a GCS."/>
</rule>
<rule>
<name value="eyeRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition
value="(linkId = 'eye-opening') and answer.value.exists()"/>
</source>
<target>
<context value="obs"/>
<element value="component"/>
<variable value="comp"/>
</target>
<rule>
<name value="eyeCode"/>
<source>
<context value="it"/>
</source>
<target>
<context value="comp"/>
<element value="code"/>
<variable value="code"/>
</target>
<rule>
<name value="codeCoding"/>
<source>
<context value="it"/>
</source>
<target>
<context value="code"/>
<element value="coding"/>
<variable value="coding"/>
</target>
<rule>
<name value="codeSystem"/>
<source>
<context value="it"/>
</source>
<target>
<context value="coding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString value="http://loinc.org"/>
</parameter>
</target>
</rule>
<rule>
<name value="codeCode"/>
<source>
<context value="it"/>
</source>
<target>
<context value="coding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="9267-6"/>
</parameter>
</target>
</rule>
<rule>
<name value="codeDisplay"/>
<source>
<context value="it"/>
</source>
<target>
<context value="coding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Glasgow coma score eye opening"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="eyeValue"/>
<source>
<context value="it"/>
</source>
<target>
<context value="comp"/>
</target>
<dependent>
<name value="SetComponentCodedValue"/>
<parameter>
<valueId value="it"/>
</parameter>
<parameter>
<valueId value="comp"/>
</parameter>
</dependent>
</rule>
</rule>
<rule>
<name value="verbalRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition
value="(linkId = 'verbal-response') and answer.value.exists()"/>
</source>
<target>
<context value="obs"/>
<element value="component"/>
<variable value="comp"/>
</target>
<rule>
<name value="verbalCode"/>
<source>
<context value="it"/>
</source>
<target>
<context value="comp"/>
<element value="code"/>
<variable value="code"/>
</target>
<rule>
<name value="codeCoding"/>
<source>
<context value="it"/>
</source>
<target>
<context value="code"/>
<element value="coding"/>
<variable value="coding"/>
</target>
<rule>
<name value="codeSystem"/>
<source>
<context value="it"/>
</source>
<target>
<context value="coding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString value="http://loinc.org"/>
</parameter>
</target>
</rule>
<rule>
<name value="codeCode"/>
<source>
<context value="it"/>
</source>
<target>
<context value="coding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="9270-0"/>
</parameter>
</target>
</rule>
<rule>
<name value="codeDisplay"/>
<source>
<context value="it"/>
</source>
<target>
<context value="coding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Glasgow coma score verbal"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="verbalValue"/>
<source>
<context value="it"/>
</source>
<target>
<context value="comp"/>
</target>
<dependent>
<name value="SetComponentCodedValue"/>
<parameter>
<valueId value="it"/>
</parameter>
<parameter>
<valueId value="comp"/>
</parameter>
</dependent>
</rule>
</rule>
<rule>
<name value="motorRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition
value="(linkId = 'motor-response') and answer.value.exists()"/>
</source>
<target>
<context value="obs"/>
<element value="component"/>
<variable value="comp"/>
</target>
<rule>
<name value="motorCode"/>
<source>
<context value="it"/>
</source>
<target>
<context value="comp"/>
<element value="code"/>
<variable value="code"/>
</target>
<rule>
<name value="codeCoding"/>
<source>
<context value="it"/>
</source>
<target>
<context value="code"/>
<element value="coding"/>
<variable value="coding"/>
</target>
<rule>
<name value="codeSystem"/>
<source>
<context value="it"/>
</source>
<target>
<context value="coding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString value="http://loinc.org"/>
</parameter>
</target>
</rule>
<rule>
<name value="codeCode"/>
<source>
<context value="it"/>
</source>
<target>
<context value="coding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="9268-4"/>
</parameter>
</target>
</rule>
<rule>
<name value="codeDisplay"/>
<source>
<context value="it"/>
</source>
<target>
<context value="coding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Glasgow coma score motor"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="motorValue"/>
<source>
<context value="it"/>
</source>
<target>
<context value="comp"/>
</target>
<dependent>
<name value="SetComponentCodedValue"/>
<parameter>
<valueId value="it"/>
</parameter>
<parameter>
<valueId value="comp"/>
</parameter>
</dependent>
</rule>
</rule>
<rule>
<name value="interpretation"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
</target>
<dependent>
<name value="AddGlasgowInterpretation"/>
<parameter>
<valueId value="obs"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
</dependent>
</rule>
</rule>
</group>
<group>
<name value="AddGlasgowInterpretation"/>
<documentation
value="─────────────────────────────────────────────────────────────────────────────
The band
Teasdale and Jennett's three tiers, as every ward and ambulance service reads
them: 13-15 mild, 9-12 moderate, 3-8 severe. Lower is worse, and the scale
bottoms out at 3, not 0.
This is an Observation.interpretation and not a RiskAssessment. A Glasgow Coma
Score says what a patient's consciousness is now; RiskAssessment models the
likelihood of a future outcome. Braden and Morse do predict one -- a pressure
injury, a fall -- and keep their RiskAssessments; this does not.
The published wording is "mild, moderate and severe brain injury", which is
how the scale was introduced and how trauma services still say it. It is
written as impairment of consciousness here because the same scale is read on
a patient in a diabetic coma or a post-ictal state, where nothing has injured
the brain and the tier still means what it means.
The coding comes from SGHIObservationInterpretation, the value set this IG
binds Observation.interpretation to, which offers LL, L, N, H, HH and A.
Mild and moderate both take L. The low axis has two rungs, and the threshold
worth spending LL on is 8 -- the point below which a patient stops reliably
protecting their own airway. That is what a consumer escalates on. Nothing is
minted to separate mild from moderate: the tier is a published function of a
number this same Observation already carries in its value, so a consumer that
needs the exact tier reads the score rather than a second code.
A Glasgow Coma Score of 15 is normal and still reads L, because the published
band is 13-15 and one code has to cover it. Flagging a normal score is the
safe direction to be wrong in; missing a deficit is not.
─────────────────────────────────────────────────────────────────────────────"/>
<input>
<name value="obs"/>
<type value="Observation"/>
<mode value="source"/>
</input>
<input>
<name value="tgt"/>
<type value="Observation"/>
<mode value="target"/>
</input>
<rule>
<name value="glasgowSevere"/>
<source>
<context value="obs"/>
<condition value="value.ofType(integer) <= 8"/>
</source>
<target>
<context value="tgt"/>
<element value="interpretation"/>
<variable value="interp"/>
</target>
<rule>
<name value="interpCoding"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="interp"/>
<element value="coding"/>
<variable value="coding"/>
</target>
<rule>
<name value="interpSystem"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="coding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation"/>
</parameter>
</target>
</rule>
<rule>
<name value="interpCode"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="coding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="LL"/>
</parameter>
</target>
</rule>
<rule>
<name value="interpDisplay"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="coding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Critical low"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="interpText"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="interp"/>
<element value="text"/>
<transform value="copy"/>
<parameter>
<valueString
value="Severe impairment of consciousness (GCS 3-8)"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="glasgowModerate"/>
<source>
<context value="obs"/>
<condition
value="(value.ofType(integer) >= 9) and (value.ofType(integer) <= 12)"/>
</source>
<target>
<context value="tgt"/>
<element value="interpretation"/>
<variable value="interp"/>
</target>
<rule>
<name value="interpCoding"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="interp"/>
<element value="coding"/>
<variable value="coding"/>
</target>
<rule>
<name value="interpSystem"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="coding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation"/>
</parameter>
</target>
</rule>
<rule>
<name value="interpCode"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="coding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="L"/>
</parameter>
</target>
</rule>
<rule>
<name value="interpDisplay"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="coding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Low"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="interpText"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="interp"/>
<element value="text"/>
<transform value="copy"/>
<parameter>
<valueString
value="Moderate impairment of consciousness (GCS 9-12)"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="glasgowMild"/>
<source>
<context value="obs"/>
<condition value="value.ofType(integer) >= 13"/>
</source>
<target>
<context value="tgt"/>
<element value="interpretation"/>
<variable value="interp"/>
</target>
<rule>
<name value="interpCoding"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="interp"/>
<element value="coding"/>
<variable value="coding"/>
</target>
<rule>
<name value="interpSystem"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="coding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation"/>
</parameter>
</target>
</rule>
<rule>
<name value="interpCode"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="coding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="L"/>
</parameter>
</target>
</rule>
<rule>
<name value="interpDisplay"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="coding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Low"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="interpText"/>
<source>
<context value="obs"/>
</source>
<target>
<context value="interp"/>
<element value="text"/>
<transform value="copy"/>
<parameter>
<valueString
value="Mild impairment of consciousness (GCS 13-15)"/>
</parameter>
</target>
</rule>
</rule>
</group>
<group>
<name value="BuildObsBase"/>
<documentation
value="─────────────────────────────────────────────────────────────────────────────
Shared scaffolding. Repeated in each map rather than imported: the transform
engine resolves `imports` against whatever StructureMaps happen to be on the
server, and a form that stops extracting because a shared map was not
uploaded is a worse failure than a duplicated group.
─────────────────────────────────────────────────────────────────────────────
Two notes on what the publisher's StructureMap validator says about this file.
Source parameters below are left untyped on purpose. Writing `: Element` makes
the validator compare QuestionnaireResponse.item against the literal 'Element'
and report them as incompatible with each other, which is noise, not a finding.
Untyped, it says only that it cannot check the paths.
`evaluate(context, expression)` is flagged as "takes 1 parameter but 2 were
found". Leave it. The FML parser in the same jar refuses the one-argument form
outright -- it wants a parameter, a comma, then the FHIRPath -- so the publisher
is objecting to what its own compiler emits. Two arguments is the only form that
compiles, and it is what the R5 transform engine executes."/>
<input>
<name value="qr"/>
<type value="QR"/>
<mode value="source"/>
</input>
<input>
<name value="obs"/>
<type value="Observation"/>
<mode value="target"/>
</input>
<input>
<name value="entry"/>
<mode value="target"/>
</input>
<rule>
<name value="idAndFullUrl"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="id"/>
<transform value="uuid"/>
</target>
<dependent>
<name value="SetObservationFullUrl"/>
<parameter>
<valueId value="obs"/>
</parameter>
<parameter>
<valueId value="entry"/>
</parameter>
</dependent>
</rule>
<rule>
<name value="entryRequest"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="entry"/>
<element value="request"/>
<variable value="request"/>
</target>
<rule>
<name value="requestMethod"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="request"/>
<element value="method"/>
<transform value="copy"/>
<parameter>
<valueString value="POST"/>
</parameter>
</target>
</rule>
<rule>
<name value="requestUrl"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="request"/>
<element value="url"/>
<transform value="copy"/>
<parameter>
<valueString value="Observation"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="status"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="status"/>
<transform value="copy"/>
<parameter>
<valueString value="final"/>
</parameter>
</target>
</rule>
<rule>
<name value="subject"/>
<source>
<context value="qr"/>
<element value="subject"/>
<variable value="s"/>
</source>
<target>
<context value="obs"/>
<element value="subject"/>
<transform value="copy"/>
<parameter>
<valueId value="s"/>
</parameter>
</target>
</rule>
<rule>
<name value="encounter"/>
<source>
<context value="qr"/>
<element value="encounter"/>
<variable value="e"/>
</source>
<target>
<context value="obs"/>
<element value="encounter"/>
<transform value="copy"/>
<parameter>
<valueId value="e"/>
</parameter>
</target>
</rule>
<rule>
<name value="effective"/>
<source>
<context value="qr"/>
<element value="authored"/>
<variable value="t"/>
</source>
<target>
<context value="obs"/>
<element value="effective"/>
<transform value="copy"/>
<parameter>
<valueId value="t"/>
</parameter>
</target>
</rule>
<rule>
<name value="performerFromSource"/>
<source>
<context value="qr"/>
<element value="source"/>
<variable value="src"/>
</source>
<target>
<context value="obs"/>
<element value="performer"/>
<transform value="copy"/>
<parameter>
<valueId value="src"/>
</parameter>
</target>
</rule>
<rule>
<name value="performerFallback"/>
<source>
<context value="qr"/>
<condition value="source.exists().not()"/>
</source>
<rule>
<name value="performerFromAuthor"/>
<source>
<context value="qr"/>
<element value="author"/>
<variable value="a"/>
</source>
<target>
<context value="obs"/>
<element value="performer"/>
<transform value="copy"/>
<parameter>
<valueId value="a"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="linkQuestionnaireResponse"/>
<source>
<context value="qr"/>
<element value="id"/>
<variable value="qid"/>
<condition value="$this.hasValue()"/>
</source>
<target>
<context value="obs"/>
<element value="derivedFrom"/>
<variable value="ref"/>
<transform value="create"/>
<parameter>
<valueString value="Reference"/>
</parameter>
</target>
<target>
<context value="ref"/>
<element value="reference"/>
<transform value="copy"/>
<parameter>
<valueId value="qid"/>
</parameter>
</target>
<documentation
value="A stored response's id already reads "QuestionnaireResponse/<id>", so it is a
relative reference as it stands. The hasValue() guard is what stops an
unsaved response -- one posted straight to $extract rather than saved first --
from writing "QuestionnaireResponse/null" into the record."/>
</rule>
</group>
<group>
<name value="SetComponentCodedValue"/>
<input>
<name value="it"/>
<mode value="source"/>
</input>
<input>
<name value="comp"/>
<mode value="target"/>
</input>
<rule>
<name value="componentAnswer"/>
<source>
<context value="it"/>
<element value="answer"/>
<listMode value="first"/>
<variable value="a"/>
</source>
<rule>
<name value="codedValue"/>
<source>
<context value="a"/>
<element value="value"/>
<variable value="cv"/>
</source>
<target>
<context value="comp"/>
<element value="value"/>
<variable value="cc"/>
<transform value="create"/>
<parameter>
<valueString value="CodeableConcept"/>
</parameter>
</target>
<rule>
<name value="valueCoding"/>
<source>
<context value="cv"/>
</source>
<target>
<context value="cc"/>
<element value="coding"/>
<transform value="copy"/>
<parameter>
<valueId value="cv"/>
</parameter>
</target>
</rule>
<rule>
<name value="valueText"/>
<source>
<context value="cv"/>
<element value="display"/>
<variable value="d"/>
</source>
<target>
<context value="cc"/>
<element value="text"/>
<transform value="copy"/>
<parameter>
<valueId value="d"/>
</parameter>
</target>
</rule>
</rule>
</rule>
</group>
<group>
<name value="SetSurveyCategory"/>
<input>
<name value="qr"/>
<type value="QR"/>
<mode value="source"/>
</input>
<input>
<name value="obs"/>
<type value="Observation"/>
<mode value="target"/>
</input>
<rule>
<name value="category"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="category"/>
<variable value="cat"/>
</target>
<rule>
<name value="categoryCoding"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="cat"/>
<element value="coding"/>
<variable value="coding"/>
</target>
<rule>
<name value="categorySystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="coding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="http://terminology.hl7.org/CodeSystem/observation-category"/>
</parameter>
</target>
</rule>
<rule>
<name value="categoryCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="coding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="survey"/>
</parameter>
</target>
</rule>
<rule>
<name value="categoryDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="coding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Survey"/>
</parameter>
</target>
</rule>
</rule>
</rule>
</group>
<group>
<name value="SetObservationFullUrl"/>
<input>
<name value="obs"/>
<type value="Observation"/>
<mode value="source"/>
</input>
<input>
<name value="entry"/>
<mode value="target"/>
</input>
<rule>
<name value="assignFullUrl"/>
<source>
<context value="obs"/>
<element value="id"/>
<variable value="id"/>
</source>
<target>
<context value="entry"/>
<element value="fullUrl"/>
<transform value="append"/>
<parameter>
<valueString value="https://fhir.slade360.co.ke/fhir/Observation/"/>
</parameter>
<parameter>
<valueId value="id"/>
</parameter>
</target>
</rule>
</group>
</StructureMap>