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="ExtractInpatientAdmissionNote"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap ExtractInpatientAdmissionNote</b></p><a name="ExtractInpatientAdmissionNote"> </a><a name="hcExtractInpatientAdmissionNote"> </a><pre class="fml">
<span style="color: #cc00cc">/// <b>url</b> = </span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientAdmissionNote'</span>
<span style="color: #cc00cc">/// <b>name</b> = </span><span style="color: blue">'ExtractInpatientAdmissionNote'</span>
<span style="color: #cc00cc">/// <b>title</b> = </span><span style="color: blue">'Inpatient Admission Note 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 a response to the inpatient admission note into a Composition with one section per heading, plus a Condition for the impression -- the one line on this form that belongs on the problem list. The Condition is verificationStatus `provisional` because an admitting impression is exactly that; the team confirms or replaces it as the stay goes on. Its code carries the clinician\'s wording as text rather than an ICD-11 coding, because the form asks for prose and guessing a diagnosis code from prose is not something a map should do.'</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/composition.html" title="Composition">http://hl7.org/fhir/StructureDefinition/Composition</a><span style="color: navy">" </span><b>alias </b>Composition <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> "</span><a href="http://hl7.org/fhir/R5/condition.html" title="Condition">http://hl7.org/fhir/StructureDefinition/Condition</a><span style="color: navy">" </span><b>alias </b>Condition <b>as </b><b>target</b>
<b>group </b>ExtractInpatientAdmissionNote<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<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">'Composition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">comp</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span> comp<span style="color: navy">, </span> entry<b> then </b>BuildNoteBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">comp</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>"noteBase"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>comp.name = <span style="color: blue">'InpatientAdmissionNote'</span> <i>"noteName"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>comp.title = <span style="color: blue">'Admission note'</span> <i>"noteTitle"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>comp.type<b> as </b><span style="color: maroon">ty</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>ty.coding<b> as </b><span style="color: maroon">sghi</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>sghi.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-document-type-codesystem'</span> <i>"sghiSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>sghi.code = <span style="color: blue">'admission-note'</span> <i>"sghiCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>sghi.display = <span style="color: blue">'Admission note'</span> <i>"sghiDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"sghiCoding"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>ty.coding<b> as </b><span style="color: maroon">loinc</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>loinc.system = <span style="color: blue">'http://loinc.org'</span> <i>"loincSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>loinc.code = <span style="color: blue">'34117-2'</span> <i>"loincCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>loinc.display = <span style="color: blue">'History and physical note'</span> <i>"loincDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"loincCoding"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>ty.text = <span style="color: blue">'Admission note'</span> <i>"typeText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"noteType"</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 = 'history') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span>comp.section<b> as </b><span style="color: maroon">sec</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>sec.title = <span style="color: blue">'History'</span> <i>"historyTitle"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>sec<b> then </b>AddSectionText<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">sec</span><span style="color: navy">)</span> <i>"historyText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"historyRule"</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 = 'exam') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span>comp.section<b> as </b><span style="color: maroon">sec</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>sec.title = <span style="color: blue">'Examination'</span> <i>"examTitle"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>sec<b> then </b>AddSectionText<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">sec</span><span style="color: navy">)</span> <i>"examText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"examRule"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">The impression is both a section of the note and a Condition. It stays in</span>
<span style="color: navy">// </span><span style="color: green">the document so the note reads whole, and it also lands on the problem</span>
<span style="color: navy">// </span><span style="color: green">list so the rest of the stay can hang off it.</span>
qr.item<b> as </b><span style="color: maroon">it</span><b> where </b><span style="color: navy">(</span>(linkId = 'impression') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span>comp.section<b> as </b><span style="color: maroon">sec</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>sec.title = <span style="color: blue">'Impression'</span> <i>"impressionTitle"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>sec<b> then </b>AddSectionText<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">sec</span><span style="color: navy">)</span> <i>"impressionText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"impressionSectionRule"</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 = 'plan') and answer.value.exists()<span style="color: navy">)</span><span style="color: navy"><b> -> </b></span>comp.section<b> as </b><span style="color: maroon">sec</span><b> then</b><span style="color: navy"> {
</span> it<span style="color: navy"><b> -> </b></span>sec.title = <span style="color: blue">'Initial plan'</span> <i>"planTitle"</i><span style="color: navy">;</span>
it<span style="color: navy"><b> -> </b></span>sec<b> then </b>AddSectionText<span style="color: navy">(</span><span style="color: maroon">it</span><span style="color: navy">, </span><span style="color: maroon">sec</span><span style="color: navy">)</span> <i>"planText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"planRule"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"composition"</i><span style="color: navy">;</span>
qr.item<b> as </b><span style="color: maroon">itImp</span><b> where </b><span style="color: navy">(</span>(linkId = 'impression') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> itImp.answer first<b> as </b><span style="color: maroon">aImp</span><b> then</b><span style="color: navy"> {
</span> aImp<span style="color: navy"><b> -> </b></span> bundle.entry<b> as </b><span style="color: maroon">entryC</span><span style="color: navy">, </span> entryC.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Condition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cond</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span> cond<span style="color: navy">, </span> entryC<b> then </b>BuildConditionBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">cond</span><span style="color: navy">, </span><span style="color: maroon">entryC</span><span style="color: navy">)</span> <i>"conditionBase"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>cond.verificationStatus<b> as </b><span style="color: maroon">vs</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>vs.coding<b> as </b><span style="color: maroon">vsc</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>vsc.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-ver-status'</span> <i>"verSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>vsc.code = <span style="color: blue">'provisional'</span> <i>"verCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>vsc.display = <span style="color: blue">'Provisional'</span> <i>"verDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"verCoding"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"verificationStatus"</i><span style="color: navy">;</span>
aImp.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -> </b></span>cond.code<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span> v<span style="color: navy"><b> -> </b></span>code.text = <span style="color: maroon">v</span> <i>"codeText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"conditionCode"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"condition"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"impressionAnswer"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"impressionConditionRule"</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 note scaffolding. Repeated in each note 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 note that stops extracting because a shared map was</span>
<span style="color: navy">// </span><span style="color: green">not 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>BuildNoteBase<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">comp</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>comp.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> then </b>SetCompositionFullUrl<span style="color: navy">(</span><span style="color: maroon">comp</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">'Composition'</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>comp.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>comp.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>comp.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">Composition.date is 1..1. `authored` is only 0..1 on the response, so when a</span>
<span style="color: navy">// </span><span style="color: green">client sends none the extraction time stands in. It is a poor substitute for</span>
<span style="color: navy">// </span><span style="color: green">when the note was written, but a document with no date at all is worse, and</span>
<span style="color: navy">// </span><span style="color: green">extraction happens moments after submission in practice.</span>
qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -> </b></span>comp.date = <span style="color: maroon">t</span> <i>"date"</i><span style="color: navy">;</span>
qr<b> where </b><span style="color: navy">(</span>authored.exists().not()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>comp.date = evaluate<span style="color: navy">(</span>qr<span style="color: navy">, </span>now()<span style="color: navy">)</span> <i>"dateFromExtractionTime"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"dateFallback"</i><span style="color: navy">;</span>
<span style="color: navy">// </span><span style="color: green">Composition.author is 1..1 minimum. R5 QuestionnaireResponse carries both</span>
<span style="color: navy">// </span><span style="color: green">`author` (who recorded the answers) and `source` (who supplied them); the</span>
<span style="color: navy">// </span><span style="color: green">author is the one who wrote the note, so it wins, and `source` only stands</span>
<span style="color: navy">// </span><span style="color: green">in when the client did not send an author. If the response carries neither,</span>
<span style="color: navy">// </span><span style="color: green">the note comes out unauthored -- there is nothing on a QuestionnaireResponse</span>
<span style="color: navy">// </span><span style="color: green">to invent one from, and guessing at who wrote a clinical note is not a thing</span>
<span style="color: navy">// </span><span style="color: green">a map should do.</span>
qr.author<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -> </b></span>comp.author = <span style="color: maroon">a</span> <i>"authorFromAuthor"</i><span style="color: navy">;</span>
qr<b> where </b><span style="color: navy">(</span>author.exists().not()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -> </b></span>comp.author = <span style="color: maroon">src</span> <i>"authorFromSource"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"authorFallback"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>comp.relatesTo<b> as </b><span style="color: maroon">rel</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>rel.type = <span style="color: blue">'derived-from'</span> <i>"relatesToType"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>rel.resourceReference = <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>"relatesToRef"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"relatesToTarget"</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>AddSectionText<span style="color: navy">(</span><b>source</b> <span style="color: maroon">it</span>, <b>target</b> <span style="color: maroon">sec</span><span style="color: navy">)</span><span style="color: navy"> {
</span> it.answer first<b> as </b><span style="color: maroon">a</span><b> then</b><span style="color: navy"> {
</span> a.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -> </b></span>sec.text<b> as </b><span style="color: maroon">narrative</span><b> then</b><span style="color: navy"> {
</span> v<span style="color: navy"><b> -> </b></span>narrative.status = <span style="color: blue">'generated'</span> <i>"narrativeStatus"</i><span style="color: navy">;</span>
v<span style="color: navy"><b> -> </b></span>narrative.div = <b>create</b><span style="color: navy">(</span><span style="color: blue">'xhtml'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">xhtml</span><b> then</b><span style="color: navy"> {
</span> v<span style="color: navy"><b> -> </b></span>xhtml.value = evaluate<span style="color: navy">(</span>a<span style="color: navy">, </span>'<div xmlns="http://www.w3.org/1999/xhtml"><p>' + value.toString().escape('html') + '</p></div>'<span style="color: navy">)</span> <i>"narrativeDiv"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"narrativeXhtml"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"sectionText"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"sectionAnswer"</i><span style="color: navy">;</span>
<span style="color: navy">}
</span><b>group </b>SetCompositionFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">comp</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span> comp.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/Composition/'</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><span style="color: navy">// </span><span style="color: green">Everything a Condition extracted from one of these forms shares. The caller</span>
<span style="color: navy">// </span><span style="color: green">supplies verificationStatus and code, because those are the two things that</span>
<span style="color: navy">// </span><span style="color: green">differ between an admitting impression and a stated cause of death.</span>
<b>group </b>BuildConditionBase<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">cond</span><span style="color: navy"> : </span>Condition, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>cond.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> then </b>SetConditionFullUrl<span style="color: navy">(</span><span style="color: maroon">cond</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">'Condition'</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>cond.clinicalStatus<b> as </b><span style="color: maroon">cs</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>cs.coding<b> as </b><span style="color: maroon">csc</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>csc.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-clinical'</span> <i>"clinSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>csc.code = <span style="color: blue">'active'</span> <i>"clinCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>csc.display = <span style="color: blue">'Active'</span> <i>"clinDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"clinCoding"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"clinicalStatus"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>cond.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">catc</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>catc.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-category'</span> <i>"catSystem"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>catc.code = <span style="color: blue">'encounter-diagnosis'</span> <i>"catCode"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>catc.display = <span style="color: blue">'Encounter Diagnosis'</span> <i>"catDisplay"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"catCoding"</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>cond.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>cond.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>cond.recordedDate = <span style="color: maroon">t</span> <i>"recordedDate"</i><span style="color: navy">;</span>
qr.author<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -> </b></span>cond.participant<b> as </b><span style="color: maroon">part</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>part.actor = <span style="color: maroon">a</span> <i>"participantActor"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"participantFromAuthor"</i><span style="color: navy">;</span>
qr<b> where </b><span style="color: navy">(</span>author.exists().not()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span> qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -> </b></span>cond.participant<b> as </b><span style="color: maroon">part2</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>part2.actor = <span style="color: maroon">src</span> <i>"participantActorFromSource"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"participantFromSource"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"participantFallback"</i><span style="color: navy">;</span>
qr<span style="color: navy"><b> -> </b></span>cond.evidence<b> as </b><span style="color: maroon">ev</span><b> then</b><span style="color: navy"> {
</span> qr<span style="color: navy"><b> -> </b></span>ev.reference = <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>"evidenceRef"</i><span style="color: navy">;</span>
<span style="color: navy">}</span> <i>"evidenceTarget"</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>SetConditionFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">cond</span><span style="color: navy"> : </span>Condition, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span> cond.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/Condition/'</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/ExtractInpatientAdmissionNote"/>
<version value="0.1.0"/>
<name value="ExtractInpatientAdmissionNote"/>
<title value="Inpatient Admission Note 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 a response to the inpatient admission note into a Composition with one section per heading, plus a Condition for the impression -- the one line on this form that belongs on the problem list. The Condition is verificationStatus `provisional` because an admitting impression is exactly that; the team confirms or replaces it as the stay goes on. Its code carries the clinician's wording as text rather than an ICD-11 coding, because the form asks for prose and guessing a diagnosis code from prose is not something a map should do."/>
<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/Composition"/>
<mode value="target"/>
<alias value="Composition"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/StructureDefinition/Condition"/>
<mode value="target"/>
<alias value="Condition"/>
</structure>
<group>
<name value="ExtractInpatientAdmissionNote"/>
<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="composition"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="bundle"/>
<element value="entry"/>
<variable value="entry"/>
</target>
<target>
<context value="entry"/>
<element value="resource"/>
<variable value="comp"/>
<transform value="create"/>
<parameter>
<valueString value="Composition"/>
</parameter>
</target>
<rule>
<name value="noteBase"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="comp"/>
</target>
<target>
<context value="entry"/>
</target>
<dependent>
<name value="BuildNoteBase"/>
<parameter>
<valueId value="qr"/>
</parameter>
<parameter>
<valueId value="comp"/>
</parameter>
<parameter>
<valueId value="entry"/>
</parameter>
</dependent>
</rule>
<rule>
<name value="noteName"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="comp"/>
<element value="name"/>
<transform value="copy"/>
<parameter>
<valueString value="InpatientAdmissionNote"/>
</parameter>
</target>
</rule>
<rule>
<name value="noteTitle"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="comp"/>
<element value="title"/>
<transform value="copy"/>
<parameter>
<valueString value="Admission note"/>
</parameter>
</target>
</rule>
<rule>
<name value="noteType"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="comp"/>
<element value="type"/>
<variable value="ty"/>
</target>
<rule>
<name value="sghiCoding"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="ty"/>
<element value="coding"/>
<variable value="sghi"/>
</target>
<rule>
<name value="sghiSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="sghi"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-document-type-codesystem"/>
</parameter>
</target>
</rule>
<rule>
<name value="sghiCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="sghi"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="admission-note"/>
</parameter>
</target>
</rule>
<rule>
<name value="sghiDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="sghi"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Admission note"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="loincCoding"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="ty"/>
<element value="coding"/>
<variable value="loinc"/>
</target>
<rule>
<name value="loincSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="loinc"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString value="http://loinc.org"/>
</parameter>
</target>
</rule>
<rule>
<name value="loincCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="loinc"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="34117-2"/>
</parameter>
</target>
</rule>
<rule>
<name value="loincDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="loinc"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="History and physical note"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="typeText"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="ty"/>
<element value="text"/>
<transform value="copy"/>
<parameter>
<valueString value="Admission note"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="historyRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition value="(linkId = 'history') and answer.value.exists()"/>
</source>
<target>
<context value="comp"/>
<element value="section"/>
<variable value="sec"/>
</target>
<rule>
<name value="historyTitle"/>
<source>
<context value="it"/>
</source>
<target>
<context value="sec"/>
<element value="title"/>
<transform value="copy"/>
<parameter>
<valueString value="History"/>
</parameter>
</target>
</rule>
<rule>
<name value="historyText"/>
<source>
<context value="it"/>
</source>
<target>
<context value="sec"/>
</target>
<dependent>
<name value="AddSectionText"/>
<parameter>
<valueId value="it"/>
</parameter>
<parameter>
<valueId value="sec"/>
</parameter>
</dependent>
</rule>
</rule>
<rule>
<name value="examRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition value="(linkId = 'exam') and answer.value.exists()"/>
</source>
<target>
<context value="comp"/>
<element value="section"/>
<variable value="sec"/>
</target>
<rule>
<name value="examTitle"/>
<source>
<context value="it"/>
</source>
<target>
<context value="sec"/>
<element value="title"/>
<transform value="copy"/>
<parameter>
<valueString value="Examination"/>
</parameter>
</target>
</rule>
<rule>
<name value="examText"/>
<source>
<context value="it"/>
</source>
<target>
<context value="sec"/>
</target>
<dependent>
<name value="AddSectionText"/>
<parameter>
<valueId value="it"/>
</parameter>
<parameter>
<valueId value="sec"/>
</parameter>
</dependent>
</rule>
</rule>
<rule>
<name value="impressionSectionRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition
value="(linkId = 'impression') and answer.value.exists()"/>
</source>
<target>
<context value="comp"/>
<element value="section"/>
<variable value="sec"/>
</target>
<rule>
<name value="impressionTitle"/>
<source>
<context value="it"/>
</source>
<target>
<context value="sec"/>
<element value="title"/>
<transform value="copy"/>
<parameter>
<valueString value="Impression"/>
</parameter>
</target>
</rule>
<rule>
<name value="impressionText"/>
<source>
<context value="it"/>
</source>
<target>
<context value="sec"/>
</target>
<dependent>
<name value="AddSectionText"/>
<parameter>
<valueId value="it"/>
</parameter>
<parameter>
<valueId value="sec"/>
</parameter>
</dependent>
</rule>
<documentation
value="The impression is both a section of the note and a Condition. It stays in
the document so the note reads whole, and it also lands on the problem
list so the rest of the stay can hang off it."/>
</rule>
<rule>
<name value="planRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="it"/>
<condition value="(linkId = 'plan') and answer.value.exists()"/>
</source>
<target>
<context value="comp"/>
<element value="section"/>
<variable value="sec"/>
</target>
<rule>
<name value="planTitle"/>
<source>
<context value="it"/>
</source>
<target>
<context value="sec"/>
<element value="title"/>
<transform value="copy"/>
<parameter>
<valueString value="Initial plan"/>
</parameter>
</target>
</rule>
<rule>
<name value="planText"/>
<source>
<context value="it"/>
</source>
<target>
<context value="sec"/>
</target>
<dependent>
<name value="AddSectionText"/>
<parameter>
<valueId value="it"/>
</parameter>
<parameter>
<valueId value="sec"/>
</parameter>
</dependent>
</rule>
</rule>
</rule>
<rule>
<name value="impressionConditionRule"/>
<source>
<context value="qr"/>
<element value="item"/>
<variable value="itImp"/>
<condition value="(linkId = 'impression') and answer.value.exists()"/>
</source>
<rule>
<name value="impressionAnswer"/>
<source>
<context value="itImp"/>
<element value="answer"/>
<listMode value="first"/>
<variable value="aImp"/>
</source>
<rule>
<name value="condition"/>
<source>
<context value="aImp"/>
</source>
<target>
<context value="bundle"/>
<element value="entry"/>
<variable value="entryC"/>
</target>
<target>
<context value="entryC"/>
<element value="resource"/>
<variable value="cond"/>
<transform value="create"/>
<parameter>
<valueString value="Condition"/>
</parameter>
</target>
<rule>
<name value="conditionBase"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="cond"/>
</target>
<target>
<context value="entryC"/>
</target>
<dependent>
<name value="BuildConditionBase"/>
<parameter>
<valueId value="qr"/>
</parameter>
<parameter>
<valueId value="cond"/>
</parameter>
<parameter>
<valueId value="entryC"/>
</parameter>
</dependent>
</rule>
<rule>
<name value="verificationStatus"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="cond"/>
<element value="verificationStatus"/>
<variable value="vs"/>
</target>
<rule>
<name value="verCoding"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="vs"/>
<element value="coding"/>
<variable value="vsc"/>
</target>
<rule>
<name value="verSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="vsc"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="http://terminology.hl7.org/CodeSystem/condition-ver-status"/>
</parameter>
</target>
</rule>
<rule>
<name value="verCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="vsc"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="provisional"/>
</parameter>
</target>
</rule>
<rule>
<name value="verDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="vsc"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Provisional"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="conditionCode"/>
<source>
<context value="aImp"/>
<element value="value"/>
<variable value="v"/>
</source>
<target>
<context value="cond"/>
<element value="code"/>
<variable value="code"/>
</target>
<rule>
<name value="codeText"/>
<source>
<context value="v"/>
</source>
<target>
<context value="code"/>
<element value="text"/>
<transform value="copy"/>
<parameter>
<valueId value="v"/>
</parameter>
</target>
</rule>
</rule>
</rule>
</rule>
</rule>
</group>
<group>
<name value="BuildNoteBase"/>
<documentation
value="─────────────────────────────────────────────────────────────────────────────
Shared note scaffolding. Repeated in each note map rather than imported: the
transform engine resolves `imports` against whatever StructureMaps happen to
be on the server, and a note 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="comp"/>
<type value="Composition"/>
<mode value="target"/>
</input>
<input>
<name value="entry"/>
<mode value="target"/>
</input>
<rule>
<name value="idAndFullUrl"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="comp"/>
<element value="id"/>
<transform value="uuid"/>
</target>
<dependent>
<name value="SetCompositionFullUrl"/>
<parameter>
<valueId value="comp"/>
</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="Composition"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="status"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="comp"/>
<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="comp"/>
<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="comp"/>
<element value="encounter"/>
<transform value="copy"/>
<parameter>
<valueId value="e"/>
</parameter>
</target>
</rule>
<rule>
<name value="date"/>
<source>
<context value="qr"/>
<element value="authored"/>
<variable value="t"/>
</source>
<target>
<context value="comp"/>
<element value="date"/>
<transform value="copy"/>
<parameter>
<valueId value="t"/>
</parameter>
</target>
<documentation
value="Composition.date is 1..1. `authored` is only 0..1 on the response, so when a
client sends none the extraction time stands in. It is a poor substitute for
when the note was written, but a document with no date at all is worse, and
extraction happens moments after submission in practice."/>
</rule>
<rule>
<name value="dateFallback"/>
<source>
<context value="qr"/>
<condition value="authored.exists().not()"/>
</source>
<rule>
<name value="dateFromExtractionTime"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="comp"/>
<element value="date"/>
<transform value="evaluate"/>
<parameter>
<valueId value="qr"/>
</parameter>
<parameter>
<valueString value="now()"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="authorFromAuthor"/>
<source>
<context value="qr"/>
<element value="author"/>
<variable value="a"/>
</source>
<target>
<context value="comp"/>
<element value="author"/>
<transform value="copy"/>
<parameter>
<valueId value="a"/>
</parameter>
</target>
<documentation
value="Composition.author is 1..1 minimum. R5 QuestionnaireResponse carries both
`author` (who recorded the answers) and `source` (who supplied them); the
author is the one who wrote the note, so it wins, and `source` only stands
in when the client did not send an author. If the response carries neither,
the note comes out unauthored -- there is nothing on a QuestionnaireResponse
to invent one from, and guessing at who wrote a clinical note is not a thing
a map should do."/>
</rule>
<rule>
<name value="authorFallback"/>
<source>
<context value="qr"/>
<condition value="author.exists().not()"/>
</source>
<rule>
<name value="authorFromSource"/>
<source>
<context value="qr"/>
<element value="source"/>
<variable value="src"/>
</source>
<target>
<context value="comp"/>
<element value="author"/>
<transform value="copy"/>
<parameter>
<valueId value="src"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="linkQuestionnaireResponse"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="comp"/>
<element value="relatesTo"/>
<variable value="rel"/>
</target>
<rule>
<name value="relatesToType"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="rel"/>
<element value="type"/>
<transform value="copy"/>
<parameter>
<valueString value="derived-from"/>
</parameter>
</target>
</rule>
<rule>
<name value="relatesToTarget"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="rel"/>
<element value="resourceReference"/>
<variable value="ref"/>
<transform value="create"/>
<parameter>
<valueString value="Reference"/>
</parameter>
</target>
<rule>
<name value="relatesToRef"/>
<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>
</rule>
</rule>
</group>
<group>
<name value="AddSectionText"/>
<input>
<name value="it"/>
<mode value="source"/>
</input>
<input>
<name value="sec"/>
<mode value="target"/>
</input>
<rule>
<name value="sectionAnswer"/>
<source>
<context value="it"/>
<element value="answer"/>
<listMode value="first"/>
<variable value="a"/>
</source>
<rule>
<name value="sectionText"/>
<source>
<context value="a"/>
<element value="value"/>
<variable value="v"/>
</source>
<target>
<context value="sec"/>
<element value="text"/>
<variable value="narrative"/>
</target>
<rule>
<name value="narrativeStatus"/>
<source>
<context value="v"/>
</source>
<target>
<context value="narrative"/>
<element value="status"/>
<transform value="copy"/>
<parameter>
<valueString value="generated"/>
</parameter>
</target>
</rule>
<rule>
<name value="narrativeXhtml"/>
<source>
<context value="v"/>
</source>
<target>
<context value="narrative"/>
<element value="div"/>
<variable value="xhtml"/>
<transform value="create"/>
<parameter>
<valueString value="xhtml"/>
</parameter>
</target>
<rule>
<name value="narrativeDiv"/>
<source>
<context value="v"/>
</source>
<target>
<context value="xhtml"/>
<element value="value"/>
<transform value="evaluate"/>
<parameter>
<valueId value="a"/>
</parameter>
<parameter>
<valueString
value="'<div xmlns="http://www.w3.org/1999/xhtml"><p>' + value.toString().escape('html') + '</p></div>'"/>
</parameter>
</target>
</rule>
</rule>
</rule>
</rule>
</group>
<group>
<name value="SetCompositionFullUrl"/>
<input>
<name value="comp"/>
<type value="Composition"/>
<mode value="source"/>
</input>
<input>
<name value="entry"/>
<mode value="target"/>
</input>
<rule>
<name value="assignFullUrl"/>
<source>
<context value="comp"/>
<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/Composition/"/>
</parameter>
<parameter>
<valueId value="id"/>
</parameter>
</target>
</rule>
</group>
<group>
<name value="BuildConditionBase"/>
<documentation
value="Everything a Condition extracted from one of these forms shares. The caller
supplies verificationStatus and code, because those are the two things that
differ between an admitting impression and a stated cause of death."/>
<input>
<name value="qr"/>
<type value="QR"/>
<mode value="source"/>
</input>
<input>
<name value="cond"/>
<type value="Condition"/>
<mode value="target"/>
</input>
<input>
<name value="entry"/>
<mode value="target"/>
</input>
<rule>
<name value="idAndFullUrl"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="cond"/>
<element value="id"/>
<transform value="uuid"/>
</target>
<dependent>
<name value="SetConditionFullUrl"/>
<parameter>
<valueId value="cond"/>
</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="Condition"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="clinicalStatus"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="cond"/>
<element value="clinicalStatus"/>
<variable value="cs"/>
</target>
<rule>
<name value="clinCoding"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="cs"/>
<element value="coding"/>
<variable value="csc"/>
</target>
<rule>
<name value="clinSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="csc"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="http://terminology.hl7.org/CodeSystem/condition-clinical"/>
</parameter>
</target>
</rule>
<rule>
<name value="clinCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="csc"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="active"/>
</parameter>
</target>
</rule>
<rule>
<name value="clinDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="csc"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Active"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="category"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="cond"/>
<element value="category"/>
<variable value="cat"/>
</target>
<rule>
<name value="catCoding"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="cat"/>
<element value="coding"/>
<variable value="catc"/>
</target>
<rule>
<name value="catSystem"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="catc"/>
<element value="system"/>
<transform value="copy"/>
<parameter>
<valueString
value="http://terminology.hl7.org/CodeSystem/condition-category"/>
</parameter>
</target>
</rule>
<rule>
<name value="catCode"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="catc"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="encounter-diagnosis"/>
</parameter>
</target>
</rule>
<rule>
<name value="catDisplay"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="catc"/>
<element value="display"/>
<transform value="copy"/>
<parameter>
<valueString value="Encounter Diagnosis"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="subject"/>
<source>
<context value="qr"/>
<element value="subject"/>
<variable value="s"/>
</source>
<target>
<context value="cond"/>
<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="cond"/>
<element value="encounter"/>
<transform value="copy"/>
<parameter>
<valueId value="e"/>
</parameter>
</target>
</rule>
<rule>
<name value="recordedDate"/>
<source>
<context value="qr"/>
<element value="authored"/>
<variable value="t"/>
</source>
<target>
<context value="cond"/>
<element value="recordedDate"/>
<transform value="copy"/>
<parameter>
<valueId value="t"/>
</parameter>
</target>
</rule>
<rule>
<name value="participantFromAuthor"/>
<source>
<context value="qr"/>
<element value="author"/>
<variable value="a"/>
</source>
<target>
<context value="cond"/>
<element value="participant"/>
<variable value="part"/>
</target>
<rule>
<name value="participantActor"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="part"/>
<element value="actor"/>
<transform value="copy"/>
<parameter>
<valueId value="a"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="participantFallback"/>
<source>
<context value="qr"/>
<condition value="author.exists().not()"/>
</source>
<rule>
<name value="participantFromSource"/>
<source>
<context value="qr"/>
<element value="source"/>
<variable value="src"/>
</source>
<target>
<context value="cond"/>
<element value="participant"/>
<variable value="part2"/>
</target>
<rule>
<name value="participantActorFromSource"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="part2"/>
<element value="actor"/>
<transform value="copy"/>
<parameter>
<valueId value="src"/>
</parameter>
</target>
</rule>
</rule>
</rule>
<rule>
<name value="linkQuestionnaireResponse"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="cond"/>
<element value="evidence"/>
<variable value="ev"/>
</target>
<rule>
<name value="evidenceTarget"/>
<source>
<context value="qr"/>
</source>
<target>
<context value="ev"/>
<element value="reference"/>
<variable value="ref"/>
<transform value="create"/>
<parameter>
<valueString value="Reference"/>
</parameter>
</target>
<rule>
<name value="evidenceRef"/>
<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>
</rule>
</rule>
</group>
<group>
<name value="SetConditionFullUrl"/>
<input>
<name value="cond"/>
<type value="Condition"/>
<mode value="source"/>
</input>
<input>
<name value="entry"/>
<mode value="target"/>
</input>
<rule>
<name value="assignFullUrl"/>
<source>
<context value="cond"/>
<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/Condition/"/>
</parameter>
<parameter>
<valueId value="id"/>
</parameter>
</target>
</rule>
</group>
</StructureMap>