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-14 |
<StructureMap xmlns="http://hl7.org/fhir">
<id value="ExtractDischargeClearanceClinicalReadiness"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap ExtractDischargeClearanceClinicalReadiness</b></p><a name="ExtractDischargeClearanceClinicalReadiness"> </a><a name="hcExtractDischargeClearanceClinicalReadiness"> </a><pre class="fml">
<span style="color: #cc00cc">/// <b>url</b> = </span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractDischargeClearanceClinicalReadiness'</span>
<span style="color: #cc00cc">/// <b>name</b> = </span><span style="color: blue">'ExtractDischargeClearanceClinicalReadiness'</span>
<span style="color: #cc00cc">/// <b>title</b> = </span><span style="color: blue">'Discharge Clearance: Clinical Readiness 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">'Turns the discharging clinician\'s readiness attestation into four survey Observations: oral intake, mobility, pain control and the condition the patient is leaving in. Each is its own Observation because a clinician answers four separate questions and one flat resource would let an answer to one stand in for an answer to another. The handover sentence rides as a note on the condition Observation rather than becoming a fifth: it is prose about the discharge, and an Observation whose value is a paragraph answers no query. Nothing here writes to the Encounter -- closing the stay and recording the discharge disposition belong to the EMR\'s discharge workflow, and the condition a patient leaves in is a different axis from where they went. The signature the form collects is a typed name, which SGHIObservation cannot carry as a performer, so it stays in the response and out of the extracted resources.'</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>
<b>group </b>ExtractDischargeClearanceClinicalReadiness<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>
<span style="color: navy">// </span><span style="color: green">linkId 301989955559 — "Oral intake tolerated"</span>
qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = '301989955559') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span> a<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>BuildClearanceObs<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>"oralIntakeBase"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>obs.code<b> as </b><span style="color: maroon">oralIntakeCodeCc</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>oralIntakeCodeCc.coding<b> as </b><span style="color: maroon">oralIntakeCodeCoding</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>oralIntakeCodeCoding.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem'</span> <i>"oralIntakeCodeSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>oralIntakeCodeCoding.code = <span style="color: blue">'oral-intake-at-discharge'</span> <i>"oralIntakeCodeCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>oralIntakeCodeCoding.display = <span style="color: blue">'Oral intake tolerated at discharge'</span> <i>"oralIntakeCodeDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"oralIntakeCodeCodingRule"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"oralIntakeCode"</i><span style="color: navy">;</span>
a<span style="color: navy"><b> -> </b></span>obs<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">a</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>"oralIntakeValue"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"oralIntakeObs"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"oralIntakeAnswer"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"oralIntakeRule"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">linkId 507198101338 — "Mobility"</span>
qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = '507198101338') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span> a<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>BuildClearanceObs<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>"mobilityBase"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>obs.code<b> as </b><span style="color: maroon">mobilityCodeCc</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>mobilityCodeCc.coding<b> as </b><span style="color: maroon">mobilityCodeCoding</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>mobilityCodeCoding.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem'</span> <i>"mobilityCodeSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>mobilityCodeCoding.code = <span style="color: blue">'mobility-at-discharge'</span> <i>"mobilityCodeCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>mobilityCodeCoding.display = <span style="color: blue">'Mobility at discharge'</span> <i>"mobilityCodeDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"mobilityCodeCodingRule"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"mobilityCode"</i><span style="color: navy">;</span>
a<span style="color: navy"><b> -> </b></span>obs<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">a</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>"mobilityValue"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"mobilityObs"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"mobilityAnswer"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"mobilityRule"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">linkId 852812667233 — "Pain controlled"</span>
qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = '852812667233') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span> a<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>BuildClearanceObs<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>"painControlBase"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>obs.code<b> as </b><span style="color: maroon">painControlCodeCc</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>painControlCodeCc.coding<b> as </b><span style="color: maroon">painControlCodeCoding</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>painControlCodeCoding.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem'</span> <i>"painControlCodeSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>painControlCodeCoding.code = <span style="color: blue">'pain-control-at-discharge'</span> <i>"painControlCodeCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>painControlCodeCoding.display = <span style="color: blue">'Pain control at discharge'</span> <i>"painControlCodeDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"painControlCodeCodingRule"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"painControlCode"</i><span style="color: navy">;</span>
a<span style="color: navy"><b> -> </b></span>obs<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">a</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>"painControlValue"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"painControlObs"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"painControlAnswer"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"painControlRule"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">linkId 108099570999 — "Condition at discharge". This one carries the</span>
<span style="color: navy">// </span><span style="color: green">free-text handover as a note, so it is the Observation a reader lands on</span>
<span style="color: navy">// </span><span style="color: green">when they want the clinician's own words.</span>
qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = '108099570999') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span> a<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>BuildClearanceObs<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>"conditionBase"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>obs.code<b> as </b><span style="color: maroon">conditionCodeCc</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>conditionCodeCc.coding<b> as </b><span style="color: maroon">conditionCodeCoding</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>conditionCodeCoding.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem'</span> <i>"conditionCodeSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>conditionCodeCoding.code = <span style="color: blue">'patient-condition-at-discharge'</span> <i>"conditionCodeCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>conditionCodeCoding.display = <span style="color: blue">'Condition at discharge'</span> <i>"conditionCodeDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"conditionCodeCodingRule"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"conditionCode"</i><span style="color: navy">;</span>
a<span style="color: navy"><b> -> </b></span>obs<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">a</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">)</span> <i>"conditionValue"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">linkId 474741611141 — "Anything the next clinician should know"</span>
qr.item<b> as </b><span style="color: maroon">itNote</span><b> where </b><span style="color: navy">(</span>(linkId = '474741611141') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> itNote.answer first<b> as </b><span style="color: maroon">aNote</span><b> then</b><span style="color: navy"> {
</span> aNote.value<b> as </b><span style="color: maroon">nv</span><span style="color: navy"><b> -> </b></span>obs.note<b> as </b><span style="color: maroon">note</span><b> then</b><span style="color: navy"> {
</span> nv<span style="color: navy"><b> -> </b></span>note.text = <span style="color: maroon">nv</span> <i>"handoverNoteText"</i><span style="color: navy">;</span>
qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -> </b></span>note.time = <span style="color: maroon">t</span> <i>"handoverNoteTime"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"handoverNote"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"handoverNoteAnswer"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"handoverNoteRule"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"conditionObs"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"conditionAnswer"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"conditionRule"</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 clearance map rather than imported: the</span>
<span style="color: navy">// </span><span style="color: green">transform engine resolves `imports` against whatever StructureMaps happen to</span>
<span style="color: navy">// </span><span style="color: green">be on the server, and a clearance that stops extracting because a shared map</span>
<span style="color: navy">// </span><span style="color: green">was not uploaded is a worse failure than a duplicated group.</span>
<span style="color: navy">// </span><span style="color: green">Source parameters are left untyped on purpose. Writing `: Element` makes the</span>
<span style="color: navy">// </span><span style="color: green">publisher's StructureMap validator compare QuestionnaireResponse.item against</span>
<span style="color: navy">// </span><span style="color: green">the literal 'Element' and report them as incompatible, which is noise.</span>
<span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</span>
<b>group </b>BuildClearanceObs<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<span style="color: navy"><b> -> </b></span>obs.category<b> as </b><span style="color: maroon">categoryCc</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>categoryCc.coding<b> as </b><span style="color: maroon">categoryCoding</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>categoryCoding.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>categoryCoding.code = <span style="color: blue">'survey'</span> <i>"categoryCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>categoryCoding.display = <span style="color: blue">'Survey'</span> <i>"categoryDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"categoryCodingRule"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"category"</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>
<span style="color: navy">// </span><span style="color: green">`effective`, not `effectiveInstant`: the R5 transform engine writes choice</span>
<span style="color: navy">// </span><span style="color: green">elements by their base name and rejects the typed form.</span>
<span style="color: navy">// </span><span style="color: green">Advantage stamps `authored` when the clearances are submitted, not when each</span>
<span style="color: navy">// </span><span style="color: green">was signed, so a clearance signed at two in the morning and submitted at the</span>
<span style="color: navy">// </span><span style="color: green">handover carries the handover time. Sending the signature time on the</span>
<span style="color: navy">// </span><span style="color: green">response would fix it at the source; there is nothing on the response for a</span>
<span style="color: navy">// </span><span style="color: green">map to read it from.</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.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -> </b></span>obs.issued = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">t</span><span style="color: navy">, </span><span style="color: blue">'instant'</span><span style="color: navy">)</span> <i>"issued"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">The facility, not the person who signed: SGHIObservation admits only an</span>
<span style="color: navy">// </span><span style="color: green">Organization or a Patient as performer, and the form's signature is a typed</span>
<span style="color: navy">// </span><span style="color: green">name that resolves to neither.</span>
qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -> </b></span>obs.performer = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">perf</span><b> then</b><span style="color: navy"> {
</span> src.reference<b> as </b><span style="color: maroon">ref</span><span style="color: navy"><b> -> </b></span>perf.reference = <span style="color: maroon">ref</span> <i>"performerRef"</i><span style="color: navy">;</span>
src.display<b> as </b><span style="color: maroon">disp</span><span style="color: navy"><b> -> </b></span>perf.display = <span style="color: maroon">disp</span> <i>"performerDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"performer"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">One identifier per resource. Copying the response's own would give every</span>
<span style="color: navy">// </span><span style="color: green">Observation from a single form the same business identity.</span>
qr<span style="color: navy"><b> -> </b></span>obs.identifier<b> as </b><span style="color: maroon">ident</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>ident.use = <span style="color: blue">'official'</span> <i>"identifierUse"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>ident.type<b> as </b><span style="color: maroon">identifierTypeCc</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>identifierTypeCc.coding<b> as </b><span style="color: maroon">identifierTypeCoding</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>identifierTypeCoding.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/default-identifier-codesystem'</span> <i>"identifierTypeSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>identifierTypeCoding.code = <span style="color: blue">'default-id'</span> <i>"identifierTypeCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>identifierTypeCoding.display = <span style="color: blue">'Default Resource Identifier'</span> <i>"identifierTypeDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"identifierTypeCodingRule"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"identifierType"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>ident.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/default-identifier-codesystem'</span> <i>"identifierSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>ident.value = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>"identifierValue"</i><span style="color: navy">;</span>
qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -> </b></span>ident.assigner = <span style="color: maroon">src</span> <i>"identifierAssigner"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"identifier"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">No append: under this engine `qr.id` already resolves to the type-qualified</span>
<span style="color: navy">// </span><span style="color: green">relative reference, so prefixing it again produces a reference to nothing.</span>
qr<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><b> then</b><span style="color: navy"> {
</span> qr.id<b> as </b><span style="color: maroon">qid</span><span style="color: navy"><b> -> </b></span>ref.reference = <span style="color: maroon">qid</span> <i>"derivedFromRef"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"linkQuestionnaireResponse"</i><span style="color: navy">;</span>
<span style="color: navy">}
</span><b>group </b>SetCodedValue<span style="color: navy">(</span><b>source</b> <span style="color: maroon">a</span>, <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> a.value<b> as </b><span style="color: maroon">cv</span><span style="color: navy"><b> -> </b></span>obs.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">concept</span><b> then</b><span style="color: navy"> {
</span> cv<span style="color: navy"><b> -> </b></span>concept.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>concept.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><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/ExtractDischargeClearanceClinicalReadiness"/>
<version value="0.1.0"/>
<name value="ExtractDischargeClearanceClinicalReadiness"/>
<title value="Discharge Clearance: Clinical Readiness Extraction"/>
<status value="active"/>
<date value="2026-09-14T06:31:13+00:00"/>
<publisher value="Kathurima Kimathi"/>
<contact>
<name value="Kathurima Kimathi"/>
<telecom>
<system value="url"/>
<value value="https://www.linkedin.com/in/kathurima-kimathi/"/>
</telecom>
<telecom>
<system value="email"/>
<value value="kathurimakimathi415@gmail.com"/>
</telecom>
</contact>
<contact>
<name value="Oscar John"/>
<telecom>
<system value="email"/>
<value value="oscarjohnotieno@gmail.com"/>
<use value="work"/>
</telecom>
</contact>
<contact>
<name value="Kennedy Omondi"/>
<telecom>
<system value="email"/>
<value value="kennankole@gmail.com"/>
<use value="work"/>
</telecom>
</contact>
<description
value="Turns the discharging clinician's readiness attestation into four survey Observations: oral intake, mobility, pain control and the condition the patient is leaving in. Each is its own Observation because a clinician answers four separate questions and one flat resource would let an answer to one stand in for an answer to another. The handover sentence rides as a note on the condition Observation rather than becoming a fifth: it is prose about the discharge, and an Observation whose value is a paragraph answers no query. Nothing here writes to the Encounter -- closing the stay and recording the discharge disposition belong to the EMR's discharge workflow, and the condition a patient leaves in is a different axis from where they went. The signature the form collects is a typed name, which SGHIObservation cannot carry as a performer, so it stays in the response and out of the extracted resources."/>
<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="ExtractDischargeClearanceClinicalReadiness"/>
<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="oralIntakeRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition
value="(linkId = '301989955559') and answer.value.exists()"/>
</source>
<rule>
<name value="oralIntakeAnswer"/>
<source>
<context value="it"/>
<element value="answer"/>
<listMode value="first"/>
<variable value="a"/>
</source>
<rule>
<name value="oralIntakeObs"/>
<source>
<context value="a"/>
</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="oralIntakeBase"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
</target>
<target>
<context value="entry"/>
</target>
<dependent>
<name value="BuildClearanceObs"/>
<parameter>
<valueId value="qr"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
<parameter>
<valueId value="entry"/>
</parameter>
</dependent>
</rule>
<rule>
<name value="oralIntakeCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="code"/>
<variable value="oralIntakeCodeCc"/>
</target>
<rule>
<name value="oralIntakeCodeCodingRule"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="oralIntakeCodeCc"/>
<element value="coding"/>
<variable value="oralIntakeCodeCoding"/>
</target>
<rule>
<name value="oralIntakeCodeSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="oralIntakeCodeCoding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem"/>
</parameter>
</target>
</rule>
<rule>
<name value="oralIntakeCodeCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="oralIntakeCodeCoding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="oral-intake-at-discharge"/>
</parameter>
</target>
</rule>
<rule>
<name value="oralIntakeCodeDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="oralIntakeCodeCoding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Oral intake tolerated at discharge"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="oralIntakeValue"/>
<source>
<context value="a"/>
</source>
<target>
<context value="obs"/>
</target>
<dependent>
<name value="SetCodedValue"/>
<parameter>
<valueId value="a"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
</dependent>
</rule>
</rule>
</rule>
<documentation
value="linkId 301989955559 — "Oral intake tolerated""/>
</rule>
<rule>
<name value="mobilityRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition
value="(linkId = '507198101338') and answer.value.exists()"/>
</source>
<rule>
<name value="mobilityAnswer"/>
<source>
<context value="it"/>
<element value="answer"/>
<listMode value="first"/>
<variable value="a"/>
</source>
<rule>
<name value="mobilityObs"/>
<source>
<context value="a"/>
</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="mobilityBase"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
</target>
<target>
<context value="entry"/>
</target>
<dependent>
<name value="BuildClearanceObs"/>
<parameter>
<valueId value="qr"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
<parameter>
<valueId value="entry"/>
</parameter>
</dependent>
</rule>
<rule>
<name value="mobilityCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="code"/>
<variable value="mobilityCodeCc"/>
</target>
<rule>
<name value="mobilityCodeCodingRule"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="mobilityCodeCc"/>
<element value="coding"/>
<variable value="mobilityCodeCoding"/>
</target>
<rule>
<name value="mobilityCodeSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="mobilityCodeCoding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem"/>
</parameter>
</target>
</rule>
<rule>
<name value="mobilityCodeCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="mobilityCodeCoding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="mobility-at-discharge"/>
</parameter>
</target>
</rule>
<rule>
<name value="mobilityCodeDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="mobilityCodeCoding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Mobility at discharge"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="mobilityValue"/>
<source>
<context value="a"/>
</source>
<target>
<context value="obs"/>
</target>
<dependent>
<name value="SetCodedValue"/>
<parameter>
<valueId value="a"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
</dependent>
</rule>
</rule>
</rule>
<documentation value="linkId 507198101338 — "Mobility""/>
</rule>
<rule>
<name value="painControlRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition
value="(linkId = '852812667233') and answer.value.exists()"/>
</source>
<rule>
<name value="painControlAnswer"/>
<source>
<context value="it"/>
<element value="answer"/>
<listMode value="first"/>
<variable value="a"/>
</source>
<rule>
<name value="painControlObs"/>
<source>
<context value="a"/>
</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="painControlBase"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
</target>
<target>
<context value="entry"/>
</target>
<dependent>
<name value="BuildClearanceObs"/>
<parameter>
<valueId value="qr"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
<parameter>
<valueId value="entry"/>
</parameter>
</dependent>
</rule>
<rule>
<name value="painControlCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="code"/>
<variable value="painControlCodeCc"/>
</target>
<rule>
<name value="painControlCodeCodingRule"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="painControlCodeCc"/>
<element value="coding"/>
<variable value="painControlCodeCoding"/>
</target>
<rule>
<name value="painControlCodeSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="painControlCodeCoding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem"/>
</parameter>
</target>
</rule>
<rule>
<name value="painControlCodeCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="painControlCodeCoding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="pain-control-at-discharge"/>
</parameter>
</target>
</rule>
<rule>
<name value="painControlCodeDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="painControlCodeCoding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Pain control at discharge"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="painControlValue"/>
<source>
<context value="a"/>
</source>
<target>
<context value="obs"/>
</target>
<dependent>
<name value="SetCodedValue"/>
<parameter>
<valueId value="a"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
</dependent>
</rule>
</rule>
</rule>
<documentation
value="linkId 852812667233 — "Pain controlled""/>
</rule>
<rule>
<name value="conditionRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition
value="(linkId = '108099570999') and answer.value.exists()"/>
</source>
<rule>
<name value="conditionAnswer"/>
<source>
<context value="it"/>
<element value="answer"/>
<listMode value="first"/>
<variable value="a"/>
</source>
<rule>
<name value="conditionObs"/>
<source>
<context value="a"/>
</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="conditionBase"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
</target>
<target>
<context value="entry"/>
</target>
<dependent>
<name value="BuildClearanceObs"/>
<parameter>
<valueId value="qr"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
<parameter>
<valueId value="entry"/>
</parameter>
</dependent>
</rule>
<rule>
<name value="conditionCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="code"/>
<variable value="conditionCodeCc"/>
</target>
<rule>
<name value="conditionCodeCodingRule"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="conditionCodeCc"/>
<element value="coding"/>
<variable value="conditionCodeCoding"/>
</target>
<rule>
<name value="conditionCodeSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="conditionCodeCoding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem"/>
</parameter>
</target>
</rule>
<rule>
<name value="conditionCodeCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="conditionCodeCoding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="patient-condition-at-discharge"/>
</parameter>
</target>
</rule>
<rule>
<name value="conditionCodeDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="conditionCodeCoding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Condition at discharge"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="conditionValue"/>
<source>
<context value="a"/>
</source>
<target>
<context value="obs"/>
</target>
<dependent>
<name value="SetCodedValue"/>
<parameter>
<valueId value="a"/>
</parameter>
<parameter>
<valueId value="obs"/>
</parameter>
</dependent>
</rule>
<rule>
<name value="handoverNoteRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="itNote"/>
<condition
value="(linkId = '474741611141') and answer.value.exists()"/>
</source>
<rule>
<name value="handoverNoteAnswer"/>
<source>
<context value="itNote"/>
<element value="answer"/>
<listMode value="first"/>
<variable value="aNote"/>
</source>
<rule>
<name value="handoverNote"/>
<source>
<context value="aNote"/>
<element value="value"/>
<variable value="nv"/>
</source>
<target>
<context value="obs"/>
<element value="note"/>
<variable value="note"/>
</target>
<rule>
<name value="handoverNoteText"/>
<source>
<context value="nv"/>
</source>
<target>
<context value="note"/>
<element value="text"/>
<transform value="copy"/>
<parameter>
<valueId value="nv"/>
</parameter>
</target>
</rule>
<rule>
<name value="handoverNoteTime"/>
<source>
<context value="qr"/>
<element value="authored"/>
<variable value="t"/>
</source>
<target>
<context value="note"/>
<element value="time"/>
<transform value="copy"/>
<parameter>
<valueId value="t"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<documentation
value="linkId 474741611141 — "Anything the next clinician should know""/>
</rule>
</rule>
</rule>
<documentation
value="linkId 108099570999 — "Condition at discharge". This one carries the
free-text handover as a note, so it is the Observation a reader lands on
when they want the clinician's own words."/>
</rule>
</group>
<group>
<name value="BuildClearanceObs"/>
<documentation
value="─────────────────────────────────────────────────────────────────────────────
Shared scaffolding. Repeated in each clearance map rather than imported: the
transform engine resolves `imports` against whatever StructureMaps happen to
be on the server, and a clearance that stops extracting because a shared map
was not uploaded is a worse failure than a duplicated group.
Source parameters are left untyped on purpose. Writing `: Element` makes the
publisher's StructureMap validator compare QuestionnaireResponse.item against
the literal 'Element' and report them as incompatible, which is noise.
─────────────────────────────────────────────────────────────────────────────"/>
<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="category"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="category"/>
<variable value="categoryCc"/>
</target>
<rule>
<name value="categoryCodingRule"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="categoryCc"/>
<element value="coding"/>
<variable value="categoryCoding"/>
</target>
<rule>
<name value="categorySystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="categoryCoding"/>
<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="categoryCoding"/>
<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="categoryCoding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Survey"/>
</parameter>
</target>
</rule>
</rule>
</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>
<documentation
value="`effective`, not `effectiveInstant`: the R5 transform engine writes choice
elements by their base name and rejects the typed form.
Advantage stamps `authored` when the clearances are submitted, not when each
was signed, so a clearance signed at two in the morning and submitted at the
handover carries the handover time. Sending the signature time on the
response would fix it at the source; there is nothing on the response for a
map to read it from."/>
</rule>
<rule>
<name value="issued"/>
<source>
<context value="qr"/>
<element value="authored"/>
<variable value="t"/>
</source>
<target>
<context value="obs"/>
<element value="issued"/>
<transform value="cast"/>
<parameter>
<valueId value="t"/>
</parameter>
<parameter>
<valueString value="instant"/>
</parameter>
</target>
</rule>
<rule>
<name value="performer"/>
<source>
<context value="qr"/>
<element value="source"/>
<variable value="src"/>
</source>
<target>
<context value="obs"/>
<element value="performer"/>
<variable value="perf"/>
<transform value="create"/>
<parameter>
<valueString value="Reference"/>
</parameter>
</target>
<rule>
<name value="performerRef"/>
<source>
<context value="src"/>
<element value="reference"/>
<variable value="ref"/>
</source>
<target>
<context value="perf"/>
<element value="reference"/>
<transform value="copy"/>
<parameter>
<valueId value="ref"/>
</parameter>
</target>
</rule>
<rule>
<name value="performerDisplay"/>
<source>
<context value="src"/>
<element value="display"/>
<variable value="disp"/>
</source>
<target>
<context value="perf"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueId value="disp"/>
</parameter>
</target>
</rule>
<documentation
value="The facility, not the person who signed: SGHIObservation admits only an
Organization or a Patient as performer, and the form's signature is a typed
name that resolves to neither."/>
</rule>
<rule>
<name value="identifier"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="identifier"/>
<variable value="ident"/>
</target>
<rule>
<name value="identifierUse"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="ident"/>
<element value="use"/>
<transform value="copy"/>
<parameter>
<valueString value="official"/>
</parameter>
</target>
</rule>
<rule>
<name value="identifierType"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="ident"/>
<element value="type"/>
<variable value="identifierTypeCc"/>
</target>
<rule>
<name value="identifierTypeCodingRule"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="identifierTypeCc"/>
<element value="coding"/>
<variable value="identifierTypeCoding"/>
</target>
<rule>
<name value="identifierTypeSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="identifierTypeCoding"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="https://fhir.slade360.co.ke/fhir/CodeSystem/default-identifier-codesystem"/>
</parameter>
</target>
</rule>
<rule>
<name value="identifierTypeCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="identifierTypeCoding"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="default-id"/>
</parameter>
</target>
</rule>
<rule>
<name value="identifierTypeDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="identifierTypeCoding"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Default Resource Identifier"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="identifierSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="ident"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="https://fhir.slade360.co.ke/fhir/CodeSystem/default-identifier-codesystem"/>
</parameter>
</target>
</rule>
<rule>
<name value="identifierValue"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="ident"/>
<element value="value"/>
<transform value="uuid"/>
</target>
</rule>
<rule>
<name value="identifierAssigner"/>
<source>
<context value="qr"/>
<element value="source"/>
<variable value="src"/>
</source>
<target>
<context value="ident"/>
<element value="assigner"/>
<transform value="copy"/>
<parameter>
<valueId value="src"/>
</parameter>
</target>
</rule>
<documentation
value="One identifier per resource. Copying the response's own would give every
Observation from a single form the same business identity."/>
</rule>
<rule>
<name value="linkQuestionnaireResponse"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="obs"/>
<element value="derivedFrom"/>
<variable value="ref"/>
<transform value="create"/>
<parameter>
<valueString value="Reference"/>
</parameter>
</target>
<rule>
<name value="derivedFromRef"/>
<source>
<context value="qr"/>
<element value="id"/>
<variable value="qid"/>
</source>
<target>
<context value="ref"/>
<element value="reference"/>
<transform value="copy"/>
<parameter>
<valueId value="qid"/>
</parameter>
</target>
</rule>
<documentation
value="No append: under this engine `qr.id` already resolves to the type-qualified
relative reference, so prefixing it again produces a reference to nothing."/>
</rule>
</group>
<group>
<name value="SetCodedValue"/>
<input>
<name value="a"/>
<mode value="source"/>
</input>
<input>
<name value="obs"/>
<type value="Observation"/>
<mode value="target"/>
</input>
<rule>
<name value="codedValue"/>
<source>
<context value="a"/>
<element value="value"/>
<variable value="cv"/>
</source>
<target>
<context value="obs"/>
<element value="value"/>
<variable value="concept"/>
<transform value="create"/>
<parameter>
<valueString value="CodeableConcept"/>
</parameter>
</target>
<rule>
<name value="valueCoding"/>
<source>
<context value="cv"/>
</source>
<target>
<context value="concept"/>
<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="concept"/>
<element value="text"/>
<transform value="copy"/>
<parameter>
<valueId value="d"/>
</parameter>
</target>
</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>