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

<StructureMap xmlns="http://hl7.org/fhir">
  <id value="ExtractInpatientPaediatricAdmissionAssessment"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap ExtractInpatientPaediatricAdmissionAssessment</b></p><a name="ExtractInpatientPaediatricAdmissionAssessment"> </a><a name="hcExtractInpatientPaediatricAdmissionAssessment"> </a><pre class="fml">
<span style="color: #cc00cc">/// <b>url</b> = </span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientPaediatricAdmissionAssessment'</span>
<span style="color: #cc00cc">/// <b>name</b> = </span><span style="color: blue">'ExtractInpatientPaediatricAdmissionAssessment'</span>
<span style="color: #cc00cc">/// <b>title</b> = </span><span style="color: blue">'Inpatient Paediatric Admission Assessment 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">'Weight, immunisation status and feeding become Observations; the guardian at the bedside becomes a RelatedPerson. Immunisation status is an Observation rather than an Immunization because the form records what the guardian says, not a dose given with a vaccine, a date and a batch -- an Immunization built from `Partially immunised` would be a fiction. The guardian is a new RelatedPerson rather than a patch to Patient.contact: repeated assessments would append a duplicate contact each time with nothing to deduplicate on, and moh-510-extractor already mints guardian RelatedPersons this way.'</span>

<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/questionnaireresponse.html" title="QuestionnaireResponse">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style="color: navy">&quot; </span><b>alias </b>QR <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/bundle.html" title="Bundle">http://hl7.org/fhir/StructureDefinition/Bundle</a><span style="color: navy">&quot; </span><b>alias </b>Bundle <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/observation.html" title="Observation">http://hl7.org/fhir/StructureDefinition/Observation</a><span style="color: navy">&quot; </span><b>alias </b>Observation <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R5/relatedperson.html" title="RelatedPerson">http://hl7.org/fhir/StructureDefinition/RelatedPerson</a><span style="color: navy">&quot; </span><b>alias </b>RelatedPerson <b>as </b><b>target</b>

<b>group </b>ExtractInpatientPaediatricAdmissionAssessment<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>bundle.type = <span style="color: blue">'transaction'</span> <i>&quot;setBundleType&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">itW</span><b> where </b><span style="color: navy">(</span>(linkId = 'weight') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itW.answer first<b> as </b><span style="color: maroon">aW</span><b> then</b><span style="color: navy"> {
</span>      aW<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entryW</span><span style="color: navy">, </span> entryW.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">obsW</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obsW<span style="color: navy">, </span> entryW<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obsW</span><span style="color: navy">, </span><span style="color: maroon">entryW</span><span style="color: navy">)</span> <i>&quot;weightBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obsW<b> then </b>SetVitalSignsCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obsW</span><span style="color: navy">)</span> <i>&quot;weightCategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obsW.code<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>code.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeSystem&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'29463-7'</span> <i>&quot;codeCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Body weight'</span> <i>&quot;codeDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeCoding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;weightCode&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Already a Quantity: the item is type `quantity` with a unitOption</span>
        <span style="color: navy">// </span><span style="color: green">pinning kg.</span>
        aW.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obsW.value = <span style="color: maroon">v</span> <i>&quot;weightValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;weightObservation&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;weightAnswer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;weightRule&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">itI</span><b> where </b><span style="color: navy">(</span>(linkId = 'immunisation') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itI.answer first<b> as </b><span style="color: maroon">aI</span><b> then</b><span style="color: navy"> {
</span>      aI<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entryI</span><span style="color: navy">, </span> entryI.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">obsI</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obsI<span style="color: navy">, </span> entryI<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obsI</span><span style="color: navy">, </span><span style="color: maroon">entryI</span><span style="color: navy">)</span> <i>&quot;immunisationBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obsI<b> then </b>SetSocialHistoryCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obsI</span><span style="color: navy">)</span> <i>&quot;immunisationCategory&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obsI.code<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>code.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;codeSystem&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'11370-4'</span> <i>&quot;codeCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Immunization status - Reported'</span> <i>&quot;codeDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeCoding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;immunisationCode&quot;</i><span style="color: navy">;</span>
        aI<span style="color: navy"><b> -&gt; </b></span>obsI<b> then </b>SetCodedValue<span style="color: navy">(</span><span style="color: maroon">aI</span><span style="color: navy">, </span><span style="color: maroon">obsI</span><span style="color: navy">)</span> <i>&quot;immunisationValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;immunisationObservation&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;immunisationAnswer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;immunisationRule&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">itF</span><b> where </b><span style="color: navy">(</span>(linkId = 'feeding') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itF.answer first<b> as </b><span style="color: maroon">aF</span><b> then</b><span style="color: navy"> {
</span>      aF<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entryF</span><span style="color: navy">, </span> entryF.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">obsF</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span> obsF<span style="color: navy">, </span> entryF<b> then </b>BuildObsBase<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obsF</span><span style="color: navy">, </span><span style="color: maroon">entryF</span><span style="color: navy">)</span> <i>&quot;feedingBase&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obsF<b> then </b>SetSocialHistoryCategory<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">obsF</span><span style="color: navy">)</span> <i>&quot;feedingCategory&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">No LOINC concept for a free-text account of how a child is fed, so a</span>
        <span style="color: navy">// </span><span style="color: green">local code. See SGHIInpatientClinicalConceptCodeSystem.</span>
        qr<span style="color: navy"><b> -&gt; </b></span>obsF.code<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>code.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span>            qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem'</span> <i>&quot;codeSystem&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'feeding'</span> <i>&quot;codeCode&quot;</i><span style="color: navy">;</span>
            qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Feeding'</span> <i>&quot;codeDisplay&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;codeCoding&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>code.text = <span style="color: blue">'Feeding'</span> <i>&quot;codeText&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;feedingCode&quot;</i><span style="color: navy">;</span>
        aF.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>obsF.value = <span style="color: maroon">v</span> <i>&quot;feedingValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;feedingObservation&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;feedingAnswer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;feedingRule&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">── Guardian ───────────────────────────────────────────────────────────────</span>
  <span style="color: navy">// </span><span style="color: green">RelatedPerson has no element that points back at the response it came from,</span>
  <span style="color: navy">// </span><span style="color: green">so this resource is the one thing the map emits with no link home. A</span>
  <span style="color: navy">// </span><span style="color: green">Provenance would carry it, but that is a wider change than this form.</span>
  qr.item<b> as </b><span style="color: maroon">itG</span><b> where </b><span style="color: navy">(</span>(linkId = 'guardianName') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    itG.answer first<b> as </b><span style="color: maroon">aG</span><b> then</b><span style="color: navy"> {
</span>      aG<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">entryG</span><span style="color: navy">, </span> entryG.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'RelatedPerson'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">rp</span><b> then</b><span style="color: navy"> {
</span>        qr<span style="color: navy"><b> -&gt; </b></span>rp.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> then </b>SetRelatedPersonFullUrl<span style="color: navy">(</span><span style="color: maroon">rp</span><span style="color: navy">, </span><span style="color: maroon">entryG</span><span style="color: navy">)</span> <i>&quot;idAndFullUrl&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>entryG.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
</span>          qr<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;requestMethod&quot;</i><span style="color: navy">;</span>
          qr<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'RelatedPerson'</span> <i>&quot;requestUrl&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;entryRequest&quot;</i><span style="color: navy">;</span>
        qr<span style="color: navy"><b> -&gt; </b></span>rp.active = <span style="color: blue">true</span> <i>&quot;active&quot;</i><span style="color: navy">;</span>
        qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -&gt; </b></span>rp.patient = <span style="color: maroon">s</span> <i>&quot;patient&quot;</i><span style="color: navy">;</span>
        aG.value<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>rp.name<b> as </b><span style="color: maroon">name</span><b> then</b><span style="color: navy"> {
</span>          v<span style="color: navy"><b> -&gt; </b></span>name.text = <span style="color: maroon">v</span> <i>&quot;nameText&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;guardianName&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">The relationship is written as the guardian described it on the day.</span>
        <span style="color: navy">// </span><span style="color: green">v3-RoleCode has concepts for mother and father, but the form accepts</span>
        <span style="color: navy">// </span><span style="color: green">anything from &quot;Aunt&quot; to &quot;Neighbour&quot;, so matching free text against a</span>
        <span style="color: navy">// </span><span style="color: green">code system here would guess.</span>
        qr.item<b> as </b><span style="color: maroon">itR</span><b> where </b><span style="color: navy">(</span>(linkId = 'guardianRel') and answer.value.exists()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>          itR.answer first<b> as </b><span style="color: maroon">aR</span><b> then</b><span style="color: navy"> {
</span>            aR.value<b> as </b><span style="color: maroon">rv</span><span style="color: navy"><b> -&gt; </b></span>rp.relationship<b> as </b><span style="color: maroon">rel</span><b> then</b><span style="color: navy"> {
</span>              rv<span style="color: navy"><b> -&gt; </b></span>rel.text = <span style="color: maroon">rv</span> <i>&quot;relationshipText&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;guardianRelationship&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;guardianRelAnswer&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;guardianRelRule&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;relatedPerson&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;guardianNameAnswer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;guardianRule&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</span>
<span style="color: navy">// </span><span style="color: green">Shared scaffolding. Repeated in each map rather than imported: the transform</span>
<span style="color: navy">// </span><span style="color: green">engine resolves `imports` against whatever StructureMaps happen to be on the</span>
<span style="color: navy">// </span><span style="color: green">server, and a form that stops extracting because a shared map was not</span>
<span style="color: navy">// </span><span style="color: green">uploaded is a worse failure than a duplicated group.</span>
<span style="color: navy">// </span><span style="color: green">─────────────────────────────────────────────────────────────────────────────</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 with each other, which is</span>
<span style="color: navy">// </span><span style="color: green">noise, not a finding. Untyped, it says only that it cannot check the paths.</span>
<b>group </b>BuildObsBase<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> then </b>SetObservationFullUrl<span style="color: navy">(</span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">entry</span><span style="color: navy">)</span> <i>&quot;idAndFullUrl&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>entry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;requestMethod&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'Observation'</span> <i>&quot;requestUrl&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;entryRequest&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>obs.status = <span style="color: blue">'final'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
  qr.subject<b> as </b><span style="color: maroon">s</span><span style="color: navy"><b> -&gt; </b></span>obs.subject = <span style="color: maroon">s</span><span style="color: navy">;</span>
  qr.encounter<b> as </b><span style="color: maroon">e</span><span style="color: navy"><b> -&gt; </b></span>obs.encounter = <span style="color: maroon">e</span><span style="color: navy">;</span>
  qr.authored<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: maroon">t</span> <i>&quot;effective&quot;</i><span style="color: navy">;</span>
  qr.source<b> as </b><span style="color: maroon">src</span><span style="color: navy"><b> -&gt; </b></span>obs.performer = <span style="color: maroon">src</span> <i>&quot;performerFromSource&quot;</i><span style="color: navy">;</span>
  qr<b> where </b><span style="color: navy">(</span>source.exists().not()<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    qr.author<b> as </b><span style="color: maroon">a</span><span style="color: navy"><b> -&gt; </b></span>obs.performer = <span style="color: maroon">a</span> <i>&quot;performerFromAuthor&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;performerFallback&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>obs.derivedFrom = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ref</span><b> then</b><span style="color: navy"> {
</span>    qr.id<b> as </b><span style="color: maroon">qid</span><span style="color: navy"><b> -&gt; </b></span>ref.reference = <span style="color: maroon">qid</span> <i>&quot;derivedFromRef&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;linkQuestionnaireResponse&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">A coded answer becomes the Observation's value, coding and display intact, so</span>
<span style="color: navy">// </span><span style="color: green">the record says both what was picked and how it read on screen.</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> -&gt; </b></span>obs.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><b> then</b><span style="color: navy"> {
</span>    cv<span style="color: navy"><b> -&gt; </b></span>cc.coding = <span style="color: maroon">cv</span> <i>&quot;valueCoding&quot;</i><span style="color: navy">;</span>
    cv.display<b> as </b><span style="color: maroon">d</span><span style="color: navy"><b> -&gt; </b></span>cc.text = <span style="color: maroon">d</span> <i>&quot;valueText&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;codedValue&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetVitalSignsCategory<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>obs.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorySystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'vital-signs'</span> <i>&quot;categoryCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Vital Signs'</span> <i>&quot;categoryDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;categoryCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetSocialHistoryCategory<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QR, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>obs.category<b> as </b><span style="color: maroon">cat</span><b> then</b><span style="color: navy"> {
</span>    qr<span style="color: navy"><b> -&gt; </b></span>cat.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span>      qr<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorySystem&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'social-history'</span> <i>&quot;categoryCode&quot;</i><span style="color: navy">;</span>
      qr<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Social History'</span> <i>&quot;categoryDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;categoryCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;category&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetObservationFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  obs.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/Observation/'</span><span style="color: navy">, </span><span style="color: maroon">id</span><span style="color: navy">)</span> <i>&quot;assignFullUrl&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SetRelatedPersonFullUrl<span style="color: navy">(</span><b>source</b> <span style="color: maroon">rp</span><span style="color: navy"> : </span>RelatedPerson, <b>target</b> <span style="color: maroon">entry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  rp.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'https://fhir.slade360.co.ke/fhir/RelatedPerson/'</span><span style="color: navy">, </span><span style="color: maroon">id</span><span style="color: navy">)</span> <i>&quot;assignFullUrl&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url value="https://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientPaediatricAdmissionAssessment"/>
  <version value="0.1.0"/>
  <name value="ExtractInpatientPaediatricAdmissionAssessment"/>
  <title value="Inpatient Paediatric Admission Assessment 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="Weight, immunisation status and feeding become Observations; the guardian at the bedside becomes a RelatedPerson. Immunisation status is an Observation rather than an Immunization because the form records what the guardian says, not a dose given with a vaccine, a date and a batch -- an Immunization built from `Partially immunised` would be a fiction. The guardian is a new RelatedPerson rather than a patch to Patient.contact: repeated assessments would append a duplicate contact each time with nothing to deduplicate on, and moh-510-extractor already mints guardian RelatedPersons this way."/>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"/>
    <mode value="source"/>
    <alias value="QR"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
    <mode value="target"/>
    <alias value="Bundle"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Observation"/>
    <mode value="target"/>
    <alias value="Observation"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/RelatedPerson"/>
    <mode value="target"/>
    <alias value="RelatedPerson"/>
  </structure>
  <group>
    <name value="ExtractInpatientPaediatricAdmissionAssessment"/>
    <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="weightRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itW"/>
        <condition value="(linkId = 'weight') and answer.value.exists()"/>
      </source>
      <rule>
        <name value="weightAnswer"/>
        <source>
          <context value="itW"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aW"/>
        </source>
        <rule>
          <name value="weightObservation"/>
          <source>
            <context value="aW"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entryW"/>
          </target>
          <target>
            <context value="entryW"/>
            <element value="resource"/>
            <variable value="obsW"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="weightBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obsW"/>
            </target>
            <target>
              <context value="entryW"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obsW"/>
              </parameter>
              <parameter>
                <valueId value="entryW"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="weightCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obsW"/>
            </target>
            <dependent>
              <name value="SetVitalSignsCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obsW"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="weightCode"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obsW"/>
              <element value="code"/>
              <variable value="code"/>
            </target>
            <rule>
              <name value="codeCoding"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="code"/>
                <element value="coding"/>
                <variable value="coding"/>
              </target>
              <rule>
                <name value="codeSystem"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="coding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="coding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="29463-7"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="coding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Body weight"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="weightValue"/>
            <source>
              <context value="aW"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obsW"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="v"/>
              </parameter>
            </target>
            <documentation value="Already a Quantity: the item is type `quantity` with a unitOption&#xD;&#xA;pinning kg."/>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="immunisationRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itI"/>
        <condition value="(linkId = 'immunisation') and answer.value.exists()"/>
      </source>
      <rule>
        <name value="immunisationAnswer"/>
        <source>
          <context value="itI"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aI"/>
        </source>
        <rule>
          <name value="immunisationObservation"/>
          <source>
            <context value="aI"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entryI"/>
          </target>
          <target>
            <context value="entryI"/>
            <element value="resource"/>
            <variable value="obsI"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="immunisationBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obsI"/>
            </target>
            <target>
              <context value="entryI"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obsI"/>
              </parameter>
              <parameter>
                <valueId value="entryI"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="immunisationCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obsI"/>
            </target>
            <dependent>
              <name value="SetSocialHistoryCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obsI"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="immunisationCode"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obsI"/>
              <element value="code"/>
              <variable value="code"/>
            </target>
            <rule>
              <name value="codeCoding"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="code"/>
                <element value="coding"/>
                <variable value="coding"/>
              </target>
              <rule>
                <name value="codeSystem"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="coding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://loinc.org"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="coding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="11370-4"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="coding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Immunization status - Reported"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="immunisationValue"/>
            <source>
              <context value="aI"/>
            </source>
            <target>
              <context value="obsI"/>
            </target>
            <dependent>
              <name value="SetCodedValue"/>
              <parameter>
                <valueId value="aI"/>
              </parameter>
              <parameter>
                <valueId value="obsI"/>
              </parameter>
            </dependent>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="feedingRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itF"/>
        <condition value="(linkId = 'feeding') and answer.value.exists()"/>
      </source>
      <rule>
        <name value="feedingAnswer"/>
        <source>
          <context value="itF"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aF"/>
        </source>
        <rule>
          <name value="feedingObservation"/>
          <source>
            <context value="aF"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entryF"/>
          </target>
          <target>
            <context value="entryF"/>
            <element value="resource"/>
            <variable value="obsF"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <rule>
            <name value="feedingBase"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obsF"/>
            </target>
            <target>
              <context value="entryF"/>
            </target>
            <dependent>
              <name value="BuildObsBase"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obsF"/>
              </parameter>
              <parameter>
                <valueId value="entryF"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="feedingCategory"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obsF"/>
            </target>
            <dependent>
              <name value="SetSocialHistoryCategory"/>
              <parameter>
                <valueId value="qr"/>
              </parameter>
              <parameter>
                <valueId value="obsF"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="feedingCode"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="obsF"/>
              <element value="code"/>
              <variable value="code"/>
            </target>
            <rule>
              <name value="codeCoding"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="code"/>
                <element value="coding"/>
                <variable value="coding"/>
              </target>
              <rule>
                <name value="codeSystem"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="coding"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeCode"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="coding"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="feeding"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeDisplay"/>
                <source>
                  <context value="qr"/>
                </source>
                <target>
                  <context value="coding"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Feeding"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="codeText"/>
              <source>
                <context value="qr"/>
              </source>
              <target>
                <context value="code"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Feeding"/>
                </parameter>
              </target>
            </rule>
            <documentation value="No LOINC concept for a free-text account of how a child is fed, so a&#xD;&#xA;local code. See SGHIInpatientClinicalConceptCodeSystem."/>
          </rule>
          <rule>
            <name value="feedingValue"/>
            <source>
              <context value="aF"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="obsF"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="v"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="guardianRule"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="itG"/>
        <condition value="(linkId = 'guardianName') and answer.value.exists()"/>
      </source>
      <rule>
        <name value="guardianNameAnswer"/>
        <source>
          <context value="itG"/>
          <element value="answer"/>
          <listMode value="first"/>
          <variable value="aG"/>
        </source>
        <rule>
          <name value="relatedPerson"/>
          <source>
            <context value="aG"/>
          </source>
          <target>
            <context value="bundle"/>
            <element value="entry"/>
            <variable value="entryG"/>
          </target>
          <target>
            <context value="entryG"/>
            <element value="resource"/>
            <variable value="rp"/>
            <transform value="create"/>
            <parameter>
              <valueString value="RelatedPerson"/>
            </parameter>
          </target>
          <rule>
            <name value="idAndFullUrl"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rp"/>
              <element value="id"/>
              <transform value="uuid"/>
            </target>
            <dependent>
              <name value="SetRelatedPersonFullUrl"/>
              <parameter>
                <valueId value="rp"/>
              </parameter>
              <parameter>
                <valueId value="entryG"/>
              </parameter>
            </dependent>
          </rule>
          <rule>
            <name value="entryRequest"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="entryG"/>
              <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="RelatedPerson"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="active"/>
            <source>
              <context value="qr"/>
            </source>
            <target>
              <context value="rp"/>
              <element value="active"/>
              <transform value="copy"/>
              <parameter>
                <valueBoolean value="true"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="patient"/>
            <source>
              <context value="qr"/>
              <element value="subject"/>
              <variable value="s"/>
            </source>
            <target>
              <context value="rp"/>
              <element value="patient"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="s"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="guardianName"/>
            <source>
              <context value="aG"/>
              <element value="value"/>
              <variable value="v"/>
            </source>
            <target>
              <context value="rp"/>
              <element value="name"/>
              <variable value="name"/>
            </target>
            <rule>
              <name value="nameText"/>
              <source>
                <context value="v"/>
              </source>
              <target>
                <context value="name"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="v"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="guardianRelRule"/>
            <source>
              <context value="qr"/>
              <element value="item"/>
              <variable value="itR"/>
              <condition value="(linkId = 'guardianRel') and answer.value.exists()"/>
            </source>
            <rule>
              <name value="guardianRelAnswer"/>
              <source>
                <context value="itR"/>
                <element value="answer"/>
                <listMode value="first"/>
                <variable value="aR"/>
              </source>
              <rule>
                <name value="guardianRelationship"/>
                <source>
                  <context value="aR"/>
                  <element value="value"/>
                  <variable value="rv"/>
                </source>
                <target>
                  <context value="rp"/>
                  <element value="relationship"/>
                  <variable value="rel"/>
                </target>
                <rule>
                  <name value="relationshipText"/>
                  <source>
                    <context value="rv"/>
                  </source>
                  <target>
                    <context value="rel"/>
                    <element value="text"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="rv"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <documentation value="The relationship is written as the guardian described it on the day.&#xD;&#xA;v3-RoleCode has concepts for mother and father, but the form accepts&#xD;&#xA;anything from &quot;Aunt&quot; to &quot;Neighbour&quot;, so matching free text against a&#xD;&#xA;code system here would guess."/>
          </rule>
        </rule>
      </rule>
      <documentation value="── Guardian ───────────────────────────────────────────────────────────────&#xD;&#xA;RelatedPerson has no element that points back at the response it came from,&#xD;&#xA;so this resource is the one thing the map emits with no link home. A&#xD;&#xA;Provenance would carry it, but that is a wider change than this form."/>
    </rule>
  </group>
  <group>
    <name value="BuildObsBase"/>
    <documentation value="─────────────────────────────────────────────────────────────────────────────&#xD;&#xA;Shared scaffolding. Repeated in each map rather than imported: the transform&#xD;&#xA;engine resolves `imports` against whatever StructureMaps happen to be on the&#xD;&#xA;server, and a form that stops extracting because a shared map was not&#xD;&#xA;uploaded is a worse failure than a duplicated group.&#xD;&#xA;─────────────────────────────────────────────────────────────────────────────&#xD;&#xA;Source parameters are left untyped on purpose. Writing `: Element` makes the&#xD;&#xA;publisher's StructureMap validator compare QuestionnaireResponse.item against&#xD;&#xA;the literal 'Element' and report them as incompatible with each other, which is&#xD;&#xA;noise, not a finding. Untyped, it says only that it cannot check the paths."/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="idAndFullUrl"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
      <dependent>
        <name value="SetObservationFullUrl"/>
        <parameter>
          <valueId value="obs"/>
        </parameter>
        <parameter>
          <valueId value="entry"/>
        </parameter>
      </dependent>
    </rule>
    <rule>
      <name value="entryRequest"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="request"/>
        <variable value="request"/>
      </target>
      <rule>
        <name value="requestMethod"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="requestUrl"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="request"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="qr"/>
        <element value="subject"/>
        <variable value="s"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="s"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="encounter"/>
      <source>
        <context value="qr"/>
        <element value="encounter"/>
        <variable value="e"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="encounter"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="e"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="effective"/>
      <source>
        <context value="qr"/>
        <element value="authored"/>
        <variable value="t"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="effective"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="t"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="performerFromSource"/>
      <source>
        <context value="qr"/>
        <element value="source"/>
        <variable value="src"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="performer"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="src"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="performerFallback"/>
      <source>
        <context value="qr"/>
        <condition value="source.exists().not()"/>
      </source>
      <rule>
        <name value="performerFromAuthor"/>
        <source>
          <context value="qr"/>
          <element value="author"/>
          <variable value="a"/>
        </source>
        <target>
          <context value="obs"/>
          <element value="performer"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="a"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="linkQuestionnaireResponse"/>
      <source>
        <context value="qr"/>
      </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>
    </rule>
  </group>
  <group>
    <name value="SetCodedValue"/>
    <documentation value="A coded answer becomes the Observation's value, coding and display intact, so&#xD;&#xA;the record says both what was picked and how it read on screen."/>
    <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="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <rule>
        <name value="valueCoding"/>
        <source>
          <context value="cv"/>
        </source>
        <target>
          <context value="cc"/>
          <element value="coding"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="cv"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="valueText"/>
        <source>
          <context value="cv"/>
          <element value="display"/>
          <variable value="d"/>
        </source>
        <target>
          <context value="cc"/>
          <element value="text"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="d"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetVitalSignsCategory"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="category"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="categoryCoding"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="categorySystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="vital-signs"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Vital Signs"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetSocialHistoryCategory"/>
    <input>
      <name value="qr"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="category"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="obs"/>
        <element value="category"/>
        <variable value="cat"/>
      </target>
      <rule>
        <name value="categoryCoding"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="cat"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="categorySystem"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://terminology.hl7.org/CodeSystem/observation-category"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryCode"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="social-history"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="categoryDisplay"/>
          <source>
            <context value="qr"/>
          </source>
          <target>
            <context value="coding"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Social History"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="SetObservationFullUrl"/>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="assignFullUrl"/>
      <source>
        <context value="obs"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="entry"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://fhir.slade360.co.ke/fhir/Observation/"/>
        </parameter>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SetRelatedPersonFullUrl"/>
    <input>
      <name value="rp"/>
      <type value="RelatedPerson"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="entry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="assignFullUrl"/>
      <source>
        <context value="rp"/>
        <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/RelatedPerson/"/>
        </parameter>
        <parameter>
          <valueId value="id"/>
        </parameter>
      </target>
    </rule>
  </group>
</StructureMap>