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

<StructureMap xmlns="http://hl7.org/fhir">
  <id value="MeaslesCaseReportMap"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap MeaslesCaseReportMap</b></p><a name="MeaslesCaseReportMap"> </a><a name="hcMeaslesCaseReportMap"> </a><pre class="fml">
<b>map</b><span style="color: navy"> &quot;</span>http://example.org/StructureMap/MeaslesCaseReportMap<span style="color: navy">&quot; = &quot;</span>MeaslesCaseReportMap<span style="color: navy">&quot;

</span><span style="color: navy">// </span><span style="color: green">Measles Case Report QuestionnaireResponse to FHIR resources</span>
<span style="color: navy">// </span><span style="color: green">Maps to: Patient, Encounter, Condition (Measles), Immunization (MR/Measles), Specimen</span>

<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/questionnaireresponse.html" title="QuestionnaireResponse">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style="color: navy">&quot; </span><b>alias </b>QuestionnaireResponse <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/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/R4/patient.html" title="Patient">http://hl7.org/fhir/StructureDefinition/Patient</a><span style="color: navy">&quot; </span><b>alias </b>Patient <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/encounter.html" title="Encounter">http://hl7.org/fhir/StructureDefinition/Encounter</a><span style="color: navy">&quot; </span><b>alias </b>Encounter <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/condition.html" title="Condition">http://hl7.org/fhir/StructureDefinition/Condition</a><span style="color: navy">&quot; </span><b>alias </b>Condition <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/immunization.html" title="Immunization">http://hl7.org/fhir/StructureDefinition/Immunization</a><span style="color: navy">&quot; </span><b>alias </b>Immunization <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/specimen.html" title="Specimen">http://hl7.org/fhir/StructureDefinition/Specimen</a><span style="color: navy">&quot; </span><b>alias </b>Specimen <b>as </b><b>target</b>

<b>group </b>MeaslesCaseReportMap<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <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>  src<span style="color: navy"><b> -&gt; </b></span>bundle.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;bundleId&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>bundle.type = <span style="color: blue">'transaction'</span> <i>&quot;bundleType&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">e</span><b> then</b><span style="color: navy"> {
</span>    src<span style="color: navy"><b> -&gt; </b></span>e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Patient'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">patient</span><b> then </b>MapMeaslesPatient<span style="color: navy">(</span><span style="color: maroon">src</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">)</span> <i>&quot;execPatient&quot;</i><span style="color: navy">;</span>
    src<span style="color: navy"><b> -&gt; </b></span> e.request<b> as </b><span style="color: maroon">req</span><span style="color: navy">, </span> req.method = <span style="color: blue">'PUT'</span><span style="color: navy">, </span> req.url = <span style="color: navy">(</span>'Patient/' + %src.subject.reference<span style="color: navy">)</span> <i>&quot;patientReq&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;patientEntry&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">e</span><b> then</b><span style="color: navy"> {
</span>    src<span style="color: navy"><b> -&gt; </b></span>e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Encounter'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">encounter</span><b> then </b>MapMeaslesEncounter<span style="color: navy">(</span><span style="color: maroon">src</span><span style="color: navy">, </span><span style="color: maroon">encounter</span><span style="color: navy">)</span> <i>&quot;execEncounter&quot;</i><span style="color: navy">;</span>
    src<span style="color: navy"><b> -&gt; </b></span> e.request<b> as </b><span style="color: maroon">req</span><span style="color: navy">, </span> req.method = <span style="color: blue">'POST'</span><span style="color: navy">, </span> req.url = <span style="color: blue">'Encounter'</span> <i>&quot;encounterReq&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;encounterEntry&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">e</span><b> then</b><span style="color: navy"> {
</span>    src<span style="color: navy"><b> -&gt; </b></span>e.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">condition</span><b> then </b>MapMeaslesCondition<span style="color: navy">(</span><span style="color: maroon">src</span><span style="color: navy">, </span><span style="color: maroon">condition</span><span style="color: navy">)</span> <i>&quot;execCondition&quot;</i><span style="color: navy">;</span>
    src<span style="color: navy"><b> -&gt; </b></span> e.request<b> as </b><span style="color: maroon">req</span><span style="color: navy">, </span> req.method = <span style="color: blue">'POST'</span><span style="color: navy">, </span> req.url = <span style="color: blue">'Condition'</span> <i>&quot;conditionReq&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;conditionEntry&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">e</span><b> then</b><span style="color: navy"> {
</span>    src<span style="color: navy"><b> -&gt; </b></span>e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Immunization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">immunization</span><b> then </b>MapMeaslesImmunization<span style="color: navy">(</span><span style="color: maroon">src</span><span style="color: navy">, </span><span style="color: maroon">immunization</span><span style="color: navy">)</span> <i>&quot;execImmunization&quot;</i><span style="color: navy">;</span>
    src<span style="color: navy"><b> -&gt; </b></span> e.request<b> as </b><span style="color: maroon">req</span><span style="color: navy">, </span> req.method = <span style="color: blue">'POST'</span><span style="color: navy">, </span> req.url = <span style="color: blue">'Immunization'</span> <i>&quot;immunizationReq&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;immunizationEntry&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">e</span><b> then</b><span style="color: navy"> {
</span>    src<span style="color: navy"><b> -&gt; </b></span>e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Specimen'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">specimen</span><b> then </b>MapMeaslesSpecimen<span style="color: navy">(</span><span style="color: maroon">src</span><span style="color: navy">, </span><span style="color: maroon">specimen</span><span style="color: navy">)</span> <i>&quot;execSpecimen&quot;</i><span style="color: navy">;</span>
    src<span style="color: navy"><b> -&gt; </b></span> e.request<b> as </b><span style="color: maroon">req</span><span style="color: navy">, </span> req.method = <span style="color: blue">'POST'</span><span style="color: navy">, </span> req.url = <span style="color: blue">'Specimen'</span> <i>&quot;specimenReq&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;specimenEntry&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>MapMeaslesPatient<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>patient.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;patientId&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">demographics</span><b> where </b>linkId = '670954892057'<b> then</b><span style="color: navy"> {
</span>    <span style="color: navy">// </span><span style="color: green">Given name</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '873240407472'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> patient.name<b> as </b><span style="color: maroon">name</span><span style="color: navy">, </span> name.given = <span style="color: maroon">ans.valueString</span> <i>&quot;givenName&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;firstName&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Middle name</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '246751846436'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> patient.name<b> as </b><span style="color: maroon">name</span><span style="color: navy">, </span> name.given = <span style="color: maroon">ans.valueString</span> <i>&quot;middleName&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;middleName&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Family name</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '486402457213'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> patient.name<b> as </b><span style="color: maroon">name</span><span style="color: navy">, </span> name.family = <span style="color: maroon">ans.valueString</span> <i>&quot;familyName&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;familyName&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Gender</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '929966324957'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>patient.gender = <span style="color: navy">(</span>ans.valueCoding.code<span style="color: navy">)</span> <i>&quot;gender&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;gender&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Date of birth</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '257830485990'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>patient.birthDate = <span style="color: maroon">ans.valueDate</span> <i>&quot;birthDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;birthDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Residence (Urban/Rural) as address use</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = 'residence'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>patient.address<b> as </b><span style="color: maroon">addr</span><b> then</b><span style="color: navy"> {
</span>        ans.valueCoding<b> as </b><span style="color: maroon">val</span><b> where </b>code = 'Urban'<span style="color: navy"><b> -&gt; </b></span> addr.use = <span style="color: blue">'home'</span><span style="color: navy">, </span> addr.type = <span style="color: blue">'physical'</span> <i>&quot;urbanAddr&quot;</i><span style="color: navy">;</span>
        ans.valueCoding<b> as </b><span style="color: maroon">val</span><b> where </b>code = 'Rural'<span style="color: navy"><b> -&gt; </b></span> addr.use = <span style="color: blue">'home'</span><span style="color: navy">, </span> addr.type = <span style="color: blue">'physical'</span><span style="color: navy">, </span> addr.district = <span style="color: blue">'Rural'</span> <i>&quot;ruralAddr&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;residenceType&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;residence&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Parent / Guardian</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = 'parent'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>patient.contact<b> as </b><span style="color: maroon">contact</span><b> then</b><span style="color: navy"> {
</span>        ans<span style="color: navy"><b> -&gt; </b></span> contact.name<b> as </b><span style="color: maroon">cname</span><span style="color: navy">, </span> cname.text = <span style="color: maroon">ans.valueString</span> <i>&quot;contactName&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;parentContact&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;parent&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Phone</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '754217593839'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> patient.telecom<b> as </b><span style="color: maroon">tel</span><span style="color: navy">, </span> tel.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> tel.value = <span style="color: maroon">ans.valueString</span> <i>&quot;phone&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;phone&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">County/Sub-County/Ward address</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '242811643559'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> patient.address<b> as </b><span style="color: maroon">addr</span><span style="color: navy">, </span> addr.line = <span style="color: maroon">ans.valueString</span> <i>&quot;village&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;village&quot;</i><span style="color: navy">;</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '946232932304'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> patient.address<b> as </b><span style="color: maroon">addr</span><span style="color: navy">, </span> addr.district = <span style="color: maroon">ans.valueString</span> <i>&quot;landmark&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;landmark&quot;</i><span style="color: navy">;</span>
    demographics.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '424111786438'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> patient.address<b> as </b><span style="color: maroon">addr</span><span style="color: navy">, </span> addr.line = <span style="color: maroon">ans.valueString</span> <i>&quot;street&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;street&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;demographics&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>MapMeaslesEncounter<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">encounter</span><span style="color: navy"> : </span>Encounter<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>encounter.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;encounterId&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>encounter.status = <span style="color: blue">'finished'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>encounter.class<b> as </b><span style="color: maroon">cls</span><b> then</b><span style="color: navy"> {
</span>    src<span style="color: navy"><b> -&gt; </b></span>cls.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v3-ActCode'</span> <i>&quot;clsSys&quot;</i><span style="color: navy">;</span>
    src<span style="color: navy"><b> -&gt; </b></span>cls.code = <span style="color: blue">'AMB'</span> <i>&quot;clsCode&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;class&quot;</i><span style="color: navy">;</span>
  src.subject<b> as </b><span style="color: maroon">subj</span><span style="color: navy"><b> -&gt; </b></span> encounter.subject<b> as </b><span style="color: maroon">ref</span><span style="color: navy">, </span> ref.reference = <span style="color: navy">(</span>'Patient/' + subj.reference<span style="color: navy">)</span><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">EPID No from reporting site</span>
  src.item<b> as </b><span style="color: maroon">reportSite</span><b> where </b>linkId = '151479012557'<b> then</b><span style="color: navy"> {
</span>    reportSite.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '992818778559'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>encounter.identifier<b> as </b><span style="color: maroon">id</span><b> then</b><span style="color: navy"> {
</span>        ans<span style="color: navy"><b> -&gt; </b></span>id.system = <span style="color: blue">'http://example.org/identifier/epid'</span> <i>&quot;epidSys&quot;</i><span style="color: navy">;</span>
        ans<span style="color: navy"><b> -&gt; </b></span>id.value = <span style="color: maroon">ans.valueString</span> <i>&quot;epidValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;epidId&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;epidNo&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;reportSite&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Case information</span>
  src.item<b> as </b><span style="color: maroon">caseInfo</span><b> where </b>linkId = '216343227137'<b> then</b><span style="color: navy"> {
</span>    <span style="color: navy">// </span><span style="color: green">Date first seen at facility → period start</span>
    caseInfo.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '554231819382'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> encounter.period<b> as </b><span style="color: maroon">period</span><span style="color: navy">, </span> period.start = <span style="color: maroon">ans.valueDate</span> <i>&quot;periodStart&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;firstSeen&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">IP/OP number</span>
    caseInfo.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '755731625544'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>encounter.identifier<b> as </b><span style="color: maroon">id</span><b> then</b><span style="color: navy"> {
</span>        ans<span style="color: navy"><b> -&gt; </b></span>id.system = <span style="color: blue">'http://example.org/identifier/ip-op'</span> <i>&quot;ipopSys&quot;</i><span style="color: navy">;</span>
        ans<span style="color: navy"><b> -&gt; </b></span>id.value = <span style="color: maroon">ans.valueString</span> <i>&quot;ipopValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;ipopId&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;ipopNo&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Hospitalization</span>
    caseInfo.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '483042281962'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><b> where </b>valueCoding.code = 'yes'<span style="color: navy"><b> -&gt; </b></span>encounter.hospitalization<b> as </b><span style="color: maroon">hosp</span><b> then</b><span style="color: navy"> {
</span>        ans<span style="color: navy"><b> -&gt; </b></span> hosp.admitSource<b> as </b><span style="color: maroon">src</span><span style="color: navy">, </span> src.coding<b> as </b><span style="color: maroon">cod</span><span style="color: navy">, </span> cod.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/admit-source'</span><span style="color: navy">, </span> cod.code = <span style="color: blue">'hosp-trans'</span> <i>&quot;admitSource&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;hospitalization&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;hospitalized&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Date of admission</span>
    caseInfo.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '340908984116'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> encounter.period<b> as </b><span style="color: maroon">period</span><span style="color: navy">, </span> period.start = <span style="color: maroon">ans.valueDate</span> <i>&quot;admitDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;admitDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Outcome → disposition</span>
    caseInfo.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '508745697175'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>encounter.hospitalization<b> as </b><span style="color: maroon">hosp</span><b> then</b><span style="color: navy"> {
</span>        ans.valueCoding<b> as </b><span style="color: maroon">val</span><b> where </b>code = 'Alive'<span style="color: navy"><b> -&gt; </b></span> hosp.dischargeDisposition<b> as </b><span style="color: maroon">disp</span><span style="color: navy">, </span> disp.coding<b> as </b><span style="color: maroon">cod</span><span style="color: navy">, </span> cod.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/discharge-disposition'</span><span style="color: navy">, </span> cod.code = <span style="color: blue">'home'</span> <i>&quot;alive&quot;</i><span style="color: navy">;</span>
        ans.valueCoding<b> as </b><span style="color: maroon">val</span><b> where </b>code = 'Dead'<span style="color: navy"><b> -&gt; </b></span> hosp.dischargeDisposition<b> as </b><span style="color: maroon">disp</span><span style="color: navy">, </span> disp.coding<b> as </b><span style="color: maroon">cod</span><span style="color: navy">, </span> cod.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/discharge-disposition'</span><span style="color: navy">, </span> cod.code = <span style="color: blue">'exp'</span> <i>&quot;dead&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;outcomeDisp&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;outcome&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;caseInfo&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Case type (Case or Line List) as type</span>
  src.item<b> as </b><span style="color: maroon">clinicalHistory</span><b> where </b>linkId = '477144604557'<b> then</b><span style="color: navy"> {
</span>    clinicalHistory.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '865158268604'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>encounter.type<b> as </b><span style="color: maroon">type</span><b> then</b><span style="color: navy"> {
</span>        ans<span style="color: navy"><b> -&gt; </b></span> type.coding<b> as </b><span style="color: maroon">cod</span><span style="color: navy">, </span> cod.system = <span style="color: blue">'http://example.org/CodeSystem/measles-case-type'</span><span style="color: navy">, </span> cod.code = <span style="color: navy">(</span>ans.valueCoding.code<span style="color: navy">)</span><span style="color: navy">, </span> cod.display = <span style="color: navy">(</span>ans.valueCoding.display<span style="color: navy">)</span> <i>&quot;caseType&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;encounterType&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;caseOrLineList&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;clinicalHistory&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>MapMeaslesCondition<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">condition</span><span style="color: navy"> : </span>Condition<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>condition.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;conditionId&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Measles SNOMED code</span>
  src<span style="color: navy"><b> -&gt; </b></span>condition.code<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>    src<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>      src<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;snomedSys&quot;</i><span style="color: navy">;</span>
      src<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'14189004'</span> <i>&quot;measlesCode&quot;</i><span style="color: navy">;</span>
      src<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Measles'</span> <i>&quot;measlesDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;measlesCoding&quot;</i><span style="color: navy">;</span>
    src<span style="color: navy"><b> -&gt; </b></span>code.text = <span style="color: blue">'Measles'</span> <i>&quot;measlesText&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;codeBlock&quot;</i><span style="color: navy">;</span>
  src.subject<b> as </b><span style="color: maroon">subj</span><span style="color: navy"><b> -&gt; </b></span> condition.subject<b> as </b><span style="color: maroon">ref</span><span style="color: navy">, </span> ref.reference = <span style="color: navy">(</span>'Patient/' + subj.reference<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">clinicalHistory</span><b> where </b>linkId = '477144604557'<b> then</b><span style="color: navy"> {
</span>    <span style="color: navy">// </span><span style="color: green">Date of onset of illness</span>
    clinicalHistory.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '728034137219'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>condition.onset = <span style="color: maroon">ans.valueDate</span> <i>&quot;onsetDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;onsetDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Clinical symptoms as body site / note</span>
    clinicalHistory.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '745196148424'<b> then</b><span style="color: navy"> {
</span>      item.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> condition.note<b> as </b><span style="color: maroon">note</span><span style="color: navy">, </span> note.text = <span style="color: navy">(</span>ans.valueCoding.display<span style="color: navy">)</span> <i>&quot;symptomNote&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;symptoms&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Date of rash onset</span>
    clinicalHistory.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '576528567552'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>condition.extension<b> as </b><span style="color: maroon">ext</span><b> then</b><span style="color: navy"> {
</span>        ans<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'http://example.org/StructureDefinition/rashOnsetDate'</span> <i>&quot;extUrl&quot;</i><span style="color: navy">;</span>
        ans<span style="color: navy"><b> -&gt; </b></span>ext.valueDate = <span style="color: maroon">ans.valueDate</span> <i>&quot;extValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;rashOnset&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;rashDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Type of rash</span>
    clinicalHistory.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '704922081985'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> condition.note<b> as </b><span style="color: maroon">note</span><span style="color: navy">, </span> note.text = <span style="color: navy">(</span>'Rash type: ' + ans.valueCoding.display<span style="color: navy">)</span> <i>&quot;rashTypeNote&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;rashType&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Home visited for contact investigation</span>
    clinicalHistory.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '207408507040'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> condition.note<b> as </b><span style="color: maroon">note</span><span style="color: navy">, </span> note.text = <span style="color: navy">(</span>iif(ans.valueCoding.code = 'yes', 'Home visited for contact investigation: Yes', 'Home visited for contact investigation: No')<span style="color: navy">)</span> <i>&quot;contactInvestNote&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;homeVisited&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Date of home visit</span>
    clinicalHistory.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '566661890668'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>condition.extension<b> as </b><span style="color: maroon">ext</span><b> then</b><span style="color: navy"> {
</span>        ans<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'http://example.org/StructureDefinition/contactInvestigationDate'</span> <i>&quot;extUrl&quot;</i><span style="color: navy">;</span>
        ans<span style="color: navy"><b> -&gt; </b></span>ext.valueDate = <span style="color: maroon">ans.valueDate</span> <i>&quot;extValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;homeVisitExt&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;homeVisitDate&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;clinicalHistory&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Outcome → clinical status from case info</span>
  src.item<b> as </b><span style="color: maroon">caseInfo</span><b> where </b>linkId = '216343227137'<b> then</b><span style="color: navy"> {
</span>    caseInfo.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '508745697175'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>condition.clinicalStatus<b> as </b><span style="color: maroon">status</span><b> then</b><span style="color: navy"> {
</span>        ans.valueCoding<b> as </b><span style="color: maroon">val</span><b> where </b>code = 'Dead'<span style="color: navy"><b> -&gt; </b></span> status.coding<b> as </b><span style="color: maroon">cod</span><span style="color: navy">, </span> cod.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-clinical'</span><span style="color: navy">, </span> cod.code = <span style="color: blue">'inactive'</span> <i>&quot;deadStatus&quot;</i><span style="color: navy">;</span>
        ans.valueCoding<b> as </b><span style="color: maroon">val</span><b> where </b>code = 'Alive'<span style="color: navy"><b> -&gt; </b></span> status.coding<b> as </b><span style="color: maroon">cod</span><span style="color: navy">, </span> cod.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-clinical'</span><span style="color: navy">, </span> cod.code = <span style="color: blue">'active'</span> <i>&quot;aliveStatus&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;clinicalStatus&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;outcome&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;caseInfoStatus&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>MapMeaslesImmunization<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">immunization</span><span style="color: navy"> : </span>Immunization<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>immunization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;immunizationId&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>immunization.status = <span style="color: blue">'completed'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">MR / Measles vaccine code</span>
  src<span style="color: navy"><b> -&gt; </b></span>immunization.vaccineCode<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>    src<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>      src<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://hl7.org/fhir/sid/cvx'</span> <i>&quot;cvxSys&quot;</i><span style="color: navy">;</span>
      src<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'05'</span> <i>&quot;measlesCode&quot;</i><span style="color: navy">;</span>
      src<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Measles-Rubella (MR) Vaccine'</span> <i>&quot;mrDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;mrCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;vaccineCode&quot;</i><span style="color: navy">;</span>
  src.subject<b> as </b><span style="color: maroon">subj</span><span style="color: navy"><b> -&gt; </b></span> immunization.patient<b> as </b><span style="color: maroon">ref</span><span style="color: navy">, </span> ref.reference = <span style="color: navy">(</span>'Patient/' + subj.reference<span style="color: navy">)</span> <i>&quot;patient&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">vaccination</span><b> where </b>linkId = '736291402384'<b> then</b><span style="color: navy"> {
</span>    <span style="color: navy">// </span><span style="color: green">Vaccination status</span>
    vaccination.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '517772812375'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><b> where </b>valueCoding.code = 'no'<span style="color: navy"><b> -&gt; </b></span>immunization.status = <span style="color: blue">'not-done'</span> <i>&quot;notVaccinated&quot;</i><span style="color: navy">;</span>
      item.answer first<b> as </b><span style="color: maroon">ans</span><b> where </b>valueCoding.code = 'unknown'<span style="color: navy"><b> -&gt; </b></span> immunization.statusReason<b> as </b><span style="color: maroon">reason</span><span style="color: navy">, </span> reason.text = <span style="color: blue">'Unknown vaccination status'</span> <i>&quot;unknownStatus&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;vaccinationStatus&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Number of doses</span>
    vaccination.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '886125589225'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>immunization.protocolApplied<b> as </b><span style="color: maroon">protocol</span><b> then</b><span style="color: navy"> {
</span>        ans<span style="color: navy"><b> -&gt; </b></span>protocol.doseNumber = <span style="color: maroon">ans.valueInteger</span> <i>&quot;doseNumber&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;protocol&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;doses&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">MR vaccination in last 30 days</span>
    vaccination.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '308128177300'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>immunization.extension<b> as </b><span style="color: maroon">ext</span><b> then</b><span style="color: navy"> {
</span>        ans<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'http://example.org/StructureDefinition/vaccineLast30Days'</span> <i>&quot;extUrl&quot;</i><span style="color: navy">;</span>
        ans<span style="color: navy"><b> -&gt; </b></span>ext.valueCoding = <span style="color: maroon">ans.valueCoding</span> <i>&quot;extValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;last30DaysExt&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;last30Days&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Date of last vaccination</span>
    vaccination.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '544290619304'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>immunization.occurrenceDateTime = <span style="color: maroon">ans.valueDate</span> <i>&quot;lastVaccDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;lastVaccDate&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;vaccination&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>MapMeaslesSpecimen<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">specimen</span><span style="color: navy"> : </span>Specimen<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>specimen.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;specimenId&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Blood/Urine/Respiratory type (default to blood serum for measles serology)</span>
  src<span style="color: navy"><b> -&gt; </b></span>specimen.type<b> as </b><span style="color: maroon">type</span><b> then</b><span style="color: navy"> {
</span>    src<span style="color: navy"><b> -&gt; </b></span>type.coding<b> as </b><span style="color: maroon">coding</span><b> then</b><span style="color: navy"> {
</span>      src<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://snomed.info/sct'</span> <i>&quot;snomedSys&quot;</i><span style="color: navy">;</span>
      src<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'119364003'</span> <i>&quot;serumCode&quot;</i><span style="color: navy">;</span>
      src<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Serum specimen'</span> <i>&quot;serumDisplay&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;serumCoding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;specimenType&quot;</i><span style="color: navy">;</span>
  src.subject<b> as </b><span style="color: maroon">subj</span><span style="color: navy"><b> -&gt; </b></span> specimen.subject<b> as </b><span style="color: maroon">ref</span><span style="color: navy">, </span> ref.reference = <span style="color: navy">(</span>'Patient/' + subj.reference<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">specimenCollection</span><b> where </b>linkId = '271053545237'<b> then</b><span style="color: navy"> {
</span>    <span style="color: navy">// </span><span style="color: green">Specimen type(s) selected</span>
    specimenCollection.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '412689284625'<b> then</b><span style="color: navy"> {
</span>      item.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> specimen.note<b> as </b><span style="color: maroon">note</span><span style="color: navy">, </span> note.text = <span style="color: navy">(</span>'Specimen collected: ' + ans.valueCoding.display<span style="color: navy">)</span> <i>&quot;specimenNote&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;specimenTypes&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Date of specimen collection</span>
    specimenCollection.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '8962468583341'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> specimen.collection<b> as </b><span style="color: maroon">coll</span><span style="color: navy">, </span> coll.collectedDateTime = <span style="color: maroon">ans.valueDate</span> <i>&quot;collectionDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;collectionDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Date specimen sent to lab</span>
    specimenCollection.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '718251724172'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>specimen.processing<b> as </b><span style="color: maroon">proc</span><b> then</b><span style="color: navy"> {
</span>        ans<span style="color: navy"><b> -&gt; </b></span>proc.description = <span style="color: blue">'Specimen sent to lab'</span> <i>&quot;procDesc&quot;</i><span style="color: navy">;</span>
        ans<span style="color: navy"><b> -&gt; </b></span>proc.timeDateTime = <span style="color: maroon">ans.valueDate</span> <i>&quot;procTime&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;sentToLab&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;sentToLabDate&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">Other specimen types</span>
    specimenCollection.item<b> as </b><span style="color: maroon">item</span><b> where </b>linkId = '340507649387'<b> then</b><span style="color: navy"> {
</span>      item.answer first<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> specimen.note<b> as </b><span style="color: maroon">note</span><span style="color: navy">, </span> note.text = <span style="color: navy">(</span>'Other specimen type: ' + ans.valueString<span style="color: navy">)</span> <i>&quot;otherSpecimenNote&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;otherSpecimen&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;specimenCollection&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url value="http://example.org/StructureMap/MeaslesCaseReportMap"/>
  <version value="0.1.0"/>
  <name value="MeaslesCaseReportMap"/>
  <status value="draft"/>
  <date value="2026-05-04T06:19:40+00:00"/>
  <publisher value="Kenya National Public Health Institute"/>
  <contact>
    <name value="Kenya National Public Health Institute"/>
    <telecom>
      <system value="url"/>
      <value value="https://www.nphi.go.ke/"/>
    </telecom>
  </contact>
  <contact>
    <name value="Kenya National Public Health Institute"/>
    <telecom>
      <system value="url"/>
      <value value="https://www.nphi.go.ke/"/>
      <use value="work"/>
    </telecom>
  </contact>
  <description value="Measles Case Report QuestionnaireResponse to FHIR resources&#xD;&#xA;Maps to: Patient, Encounter, Condition (Measles), Immunization (MR/Measles), Specimen"/>
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166"/>
      <code value="KE"/>
      <display value="Kenya"/>
    </coding>
  </jurisdiction>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"/>
    <mode value="source"/>
    <alias value="QuestionnaireResponse"/>
  </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/Patient"/>
    <mode value="target"/>
    <alias value="Patient"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Encounter"/>
    <mode value="target"/>
    <alias value="Encounter"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Condition"/>
    <mode value="target"/>
    <alias value="Condition"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Immunization"/>
    <mode value="target"/>
    <alias value="Immunization"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Specimen"/>
    <mode value="target"/>
    <alias value="Specimen"/>
  </structure>
  <group>
    <name value="MeaslesCaseReportMap"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="QuestionnaireResponse"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="bundleId"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="bundleType"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="type"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="transaction"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="patientEntry"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <rule>
        <name value="execPatient"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="patient"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Patient"/>
          </parameter>
        </target>
        <dependent>
          <name value="MapMeaslesPatient"/>
          <variable value="src"/>
          <variable value="patient"/>
        </dependent>
      </rule>
      <rule>
        <name value="patientReq"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="request"/>
          <variable value="req"/>
        </target>
        <target>
          <context value="req"/>
          <contextType value="variable"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="PUT"/>
          </parameter>
        </target>
        <target>
          <context value="req"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="'Patient/' + %src.subject.reference"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="encounterEntry"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <rule>
        <name value="execEncounter"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="encounter"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Encounter"/>
          </parameter>
        </target>
        <dependent>
          <name value="MapMeaslesEncounter"/>
          <variable value="src"/>
          <variable value="encounter"/>
        </dependent>
      </rule>
      <rule>
        <name value="encounterReq"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="request"/>
          <variable value="req"/>
        </target>
        <target>
          <context value="req"/>
          <contextType value="variable"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
        <target>
          <context value="req"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Encounter"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="conditionEntry"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <rule>
        <name value="execCondition"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="condition"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Condition"/>
          </parameter>
        </target>
        <dependent>
          <name value="MapMeaslesCondition"/>
          <variable value="src"/>
          <variable value="condition"/>
        </dependent>
      </rule>
      <rule>
        <name value="conditionReq"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="request"/>
          <variable value="req"/>
        </target>
        <target>
          <context value="req"/>
          <contextType value="variable"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
        <target>
          <context value="req"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Condition"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="immunizationEntry"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <rule>
        <name value="execImmunization"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="immunization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Immunization"/>
          </parameter>
        </target>
        <dependent>
          <name value="MapMeaslesImmunization"/>
          <variable value="src"/>
          <variable value="immunization"/>
        </dependent>
      </rule>
      <rule>
        <name value="immunizationReq"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="request"/>
          <variable value="req"/>
        </target>
        <target>
          <context value="req"/>
          <contextType value="variable"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
        <target>
          <context value="req"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Immunization"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="specimenEntry"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <rule>
        <name value="execSpecimen"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="specimen"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Specimen"/>
          </parameter>
        </target>
        <dependent>
          <name value="MapMeaslesSpecimen"/>
          <variable value="src"/>
          <variable value="specimen"/>
        </dependent>
      </rule>
      <rule>
        <name value="specimenReq"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="request"/>
          <variable value="req"/>
        </target>
        <target>
          <context value="req"/>
          <contextType value="variable"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
        <target>
          <context value="req"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Specimen"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="MapMeaslesPatient"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="QuestionnaireResponse"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="patientId"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="patient"/>
        <contextType value="variable"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="demographics"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="demographics"/>
        <condition value="linkId = '670954892057'"/>
      </source>
      <rule>
        <name value="firstName"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '873240407472'"/>
        </source>
        <rule>
          <name value="givenName"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="name"/>
            <variable value="name"/>
          </target>
          <target>
            <context value="name"/>
            <contextType value="variable"/>
            <element value="given"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueString"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="middleName"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '246751846436'"/>
        </source>
        <rule>
          <name value="middleName"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="name"/>
            <variable value="name"/>
          </target>
          <target>
            <context value="name"/>
            <contextType value="variable"/>
            <element value="given"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueString"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="familyName"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '486402457213'"/>
        </source>
        <rule>
          <name value="familyName"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="name"/>
            <variable value="name"/>
          </target>
          <target>
            <context value="name"/>
            <contextType value="variable"/>
            <element value="family"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueString"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="gender"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '929966324957'"/>
        </source>
        <rule>
          <name value="gender"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="gender"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="ans.valueCoding.code"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="birthDate"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '257830485990'"/>
        </source>
        <rule>
          <name value="birthDate"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="birthDate"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueDate"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="residence"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = 'residence'"/>
        </source>
        <rule>
          <name value="residenceType"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="address"/>
            <variable value="addr"/>
          </target>
          <rule>
            <name value="urbanAddr"/>
            <source>
              <context value="ans"/>
              <element value="valueCoding"/>
              <variable value="val"/>
              <condition value="code = 'Urban'"/>
            </source>
            <target>
              <context value="addr"/>
              <contextType value="variable"/>
              <element value="use"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="home"/>
              </parameter>
            </target>
            <target>
              <context value="addr"/>
              <contextType value="variable"/>
              <element value="type"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="physical"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="ruralAddr"/>
            <source>
              <context value="ans"/>
              <element value="valueCoding"/>
              <variable value="val"/>
              <condition value="code = 'Rural'"/>
            </source>
            <target>
              <context value="addr"/>
              <contextType value="variable"/>
              <element value="use"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="home"/>
              </parameter>
            </target>
            <target>
              <context value="addr"/>
              <contextType value="variable"/>
              <element value="type"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="physical"/>
              </parameter>
            </target>
            <target>
              <context value="addr"/>
              <contextType value="variable"/>
              <element value="district"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Rural"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="parent"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = 'parent'"/>
        </source>
        <rule>
          <name value="parentContact"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="contact"/>
            <variable value="contact"/>
          </target>
          <rule>
            <name value="contactName"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="contact"/>
              <contextType value="variable"/>
              <element value="name"/>
              <variable value="cname"/>
            </target>
            <target>
              <context value="cname"/>
              <contextType value="variable"/>
              <element value="text"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ans.valueString"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="phone"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '754217593839'"/>
        </source>
        <rule>
          <name value="phone"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="telecom"/>
            <variable value="tel"/>
          </target>
          <target>
            <context value="tel"/>
            <contextType value="variable"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="phone"/>
            </parameter>
          </target>
          <target>
            <context value="tel"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueString"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="village"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '242811643559'"/>
        </source>
        <rule>
          <name value="village"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="address"/>
            <variable value="addr"/>
          </target>
          <target>
            <context value="addr"/>
            <contextType value="variable"/>
            <element value="line"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueString"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="landmark"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '946232932304'"/>
        </source>
        <rule>
          <name value="landmark"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="address"/>
            <variable value="addr"/>
          </target>
          <target>
            <context value="addr"/>
            <contextType value="variable"/>
            <element value="district"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueString"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="street"/>
        <source>
          <context value="demographics"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '424111786438'"/>
        </source>
        <rule>
          <name value="street"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="address"/>
            <variable value="addr"/>
          </target>
          <target>
            <context value="addr"/>
            <contextType value="variable"/>
            <element value="line"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueString"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="MapMeaslesEncounter"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="QuestionnaireResponse"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="encounterId"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="finished"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="class"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="class"/>
        <variable value="cls"/>
      </target>
      <rule>
        <name value="clsSys"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="cls"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="http://terminology.hl7.org/CodeSystem/v3-ActCode"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="clsCode"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="cls"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="AMB"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="src"/>
        <element value="subject"/>
        <variable value="subj"/>
      </source>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="subject"/>
        <variable value="ref"/>
      </target>
      <target>
        <context value="ref"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'Patient/' + subj.reference"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="reportSite"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="reportSite"/>
        <condition value="linkId = '151479012557'"/>
      </source>
      <rule>
        <name value="epidNo"/>
        <source>
          <context value="reportSite"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '992818778559'"/>
        </source>
        <rule>
          <name value="epidId"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="encounter"/>
            <contextType value="variable"/>
            <element value="identifier"/>
            <variable value="id"/>
          </target>
          <rule>
            <name value="epidSys"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="id"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://example.org/identifier/epid"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="epidValue"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="id"/>
              <contextType value="variable"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ans.valueString"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="caseInfo"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="caseInfo"/>
        <condition value="linkId = '216343227137'"/>
      </source>
      <rule>
        <name value="firstSeen"/>
        <source>
          <context value="caseInfo"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '554231819382'"/>
        </source>
        <rule>
          <name value="periodStart"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="encounter"/>
            <contextType value="variable"/>
            <element value="period"/>
            <variable value="period"/>
          </target>
          <target>
            <context value="period"/>
            <contextType value="variable"/>
            <element value="start"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueDate"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="ipopNo"/>
        <source>
          <context value="caseInfo"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '755731625544'"/>
        </source>
        <rule>
          <name value="ipopId"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="encounter"/>
            <contextType value="variable"/>
            <element value="identifier"/>
            <variable value="id"/>
          </target>
          <rule>
            <name value="ipopSys"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="id"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://example.org/identifier/ip-op"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="ipopValue"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="id"/>
              <contextType value="variable"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ans.valueString"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="hospitalized"/>
        <source>
          <context value="caseInfo"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '483042281962'"/>
        </source>
        <rule>
          <name value="hospitalization"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
            <condition value="valueCoding.code = 'yes'"/>
          </source>
          <target>
            <context value="encounter"/>
            <contextType value="variable"/>
            <element value="hospitalization"/>
            <variable value="hosp"/>
          </target>
          <rule>
            <name value="admitSource"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="hosp"/>
              <contextType value="variable"/>
              <element value="admitSource"/>
              <variable value="src"/>
            </target>
            <target>
              <context value="src"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="cod"/>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://terminology.hl7.org/CodeSystem/admit-source"/>
              </parameter>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="hosp-trans"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="admitDate"/>
        <source>
          <context value="caseInfo"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '340908984116'"/>
        </source>
        <rule>
          <name value="admitDate"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="encounter"/>
            <contextType value="variable"/>
            <element value="period"/>
            <variable value="period"/>
          </target>
          <target>
            <context value="period"/>
            <contextType value="variable"/>
            <element value="start"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueDate"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="outcome"/>
        <source>
          <context value="caseInfo"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '508745697175'"/>
        </source>
        <rule>
          <name value="outcomeDisp"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="encounter"/>
            <contextType value="variable"/>
            <element value="hospitalization"/>
            <variable value="hosp"/>
          </target>
          <rule>
            <name value="alive"/>
            <source>
              <context value="ans"/>
              <element value="valueCoding"/>
              <variable value="val"/>
              <condition value="code = 'Alive'"/>
            </source>
            <target>
              <context value="hosp"/>
              <contextType value="variable"/>
              <element value="dischargeDisposition"/>
              <variable value="disp"/>
            </target>
            <target>
              <context value="disp"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="cod"/>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://terminology.hl7.org/CodeSystem/discharge-disposition"/>
              </parameter>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="home"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="dead"/>
            <source>
              <context value="ans"/>
              <element value="valueCoding"/>
              <variable value="val"/>
              <condition value="code = 'Dead'"/>
            </source>
            <target>
              <context value="hosp"/>
              <contextType value="variable"/>
              <element value="dischargeDisposition"/>
              <variable value="disp"/>
            </target>
            <target>
              <context value="disp"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="cod"/>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://terminology.hl7.org/CodeSystem/discharge-disposition"/>
              </parameter>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="exp"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="clinicalHistory"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="clinicalHistory"/>
        <condition value="linkId = '477144604557'"/>
      </source>
      <rule>
        <name value="caseOrLineList"/>
        <source>
          <context value="clinicalHistory"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '865158268604'"/>
        </source>
        <rule>
          <name value="encounterType"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="encounter"/>
            <contextType value="variable"/>
            <element value="type"/>
            <variable value="type"/>
          </target>
          <rule>
            <name value="caseType"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="type"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="cod"/>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://example.org/CodeSystem/measles-case-type"/>
              </parameter>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="ans.valueCoding.code"/>
              </parameter>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="ans.valueCoding.display"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="MapMeaslesCondition"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="QuestionnaireResponse"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="condition"/>
      <type value="Condition"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="conditionId"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="condition"/>
        <contextType value="variable"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="codeBlock"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="condition"/>
        <contextType value="variable"/>
        <element value="code"/>
        <variable value="code"/>
      </target>
      <rule>
        <name value="measlesCoding"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="code"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="snomedSys"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://snomed.info/sct"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="measlesCode"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="14189004"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="measlesDisplay"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Measles"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="measlesText"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="code"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Measles"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="src"/>
        <element value="subject"/>
        <variable value="subj"/>
      </source>
      <target>
        <context value="condition"/>
        <contextType value="variable"/>
        <element value="subject"/>
        <variable value="ref"/>
      </target>
      <target>
        <context value="ref"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'Patient/' + subj.reference"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="clinicalHistory"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="clinicalHistory"/>
        <condition value="linkId = '477144604557'"/>
      </source>
      <rule>
        <name value="onsetDate"/>
        <source>
          <context value="clinicalHistory"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '728034137219'"/>
        </source>
        <rule>
          <name value="onsetDate"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="condition"/>
            <contextType value="variable"/>
            <element value="onset"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueDate"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="symptoms"/>
        <source>
          <context value="clinicalHistory"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '745196148424'"/>
        </source>
        <rule>
          <name value="symptomNote"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="condition"/>
            <contextType value="variable"/>
            <element value="note"/>
            <variable value="note"/>
          </target>
          <target>
            <context value="note"/>
            <contextType value="variable"/>
            <element value="text"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="ans.valueCoding.display"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="rashDate"/>
        <source>
          <context value="clinicalHistory"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '576528567552'"/>
        </source>
        <rule>
          <name value="rashOnset"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="condition"/>
            <contextType value="variable"/>
            <element value="extension"/>
            <variable value="ext"/>
          </target>
          <rule>
            <name value="extUrl"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="ext"/>
              <contextType value="variable"/>
              <element value="url"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://example.org/StructureDefinition/rashOnsetDate"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="extValue"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="ext"/>
              <contextType value="variable"/>
              <element value="valueDate"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ans.valueDate"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="rashType"/>
        <source>
          <context value="clinicalHistory"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '704922081985'"/>
        </source>
        <rule>
          <name value="rashTypeNote"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="condition"/>
            <contextType value="variable"/>
            <element value="note"/>
            <variable value="note"/>
          </target>
          <target>
            <context value="note"/>
            <contextType value="variable"/>
            <element value="text"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'Rash type: ' + ans.valueCoding.display"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="homeVisited"/>
        <source>
          <context value="clinicalHistory"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '207408507040'"/>
        </source>
        <rule>
          <name value="contactInvestNote"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="condition"/>
            <contextType value="variable"/>
            <element value="note"/>
            <variable value="note"/>
          </target>
          <target>
            <context value="note"/>
            <contextType value="variable"/>
            <element value="text"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="iif(ans.valueCoding.code = 'yes', 'Home visited for contact investigation: Yes', 'Home visited for contact investigation: No')"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="homeVisitDate"/>
        <source>
          <context value="clinicalHistory"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '566661890668'"/>
        </source>
        <rule>
          <name value="homeVisitExt"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="condition"/>
            <contextType value="variable"/>
            <element value="extension"/>
            <variable value="ext"/>
          </target>
          <rule>
            <name value="extUrl"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="ext"/>
              <contextType value="variable"/>
              <element value="url"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://example.org/StructureDefinition/contactInvestigationDate"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="extValue"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="ext"/>
              <contextType value="variable"/>
              <element value="valueDate"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ans.valueDate"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="caseInfoStatus"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="caseInfo"/>
        <condition value="linkId = '216343227137'"/>
      </source>
      <rule>
        <name value="outcome"/>
        <source>
          <context value="caseInfo"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '508745697175'"/>
        </source>
        <rule>
          <name value="clinicalStatus"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="condition"/>
            <contextType value="variable"/>
            <element value="clinicalStatus"/>
            <variable value="status"/>
          </target>
          <rule>
            <name value="deadStatus"/>
            <source>
              <context value="ans"/>
              <element value="valueCoding"/>
              <variable value="val"/>
              <condition value="code = 'Dead'"/>
            </source>
            <target>
              <context value="status"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="cod"/>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://terminology.hl7.org/CodeSystem/condition-clinical"/>
              </parameter>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="inactive"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="aliveStatus"/>
            <source>
              <context value="ans"/>
              <element value="valueCoding"/>
              <variable value="val"/>
              <condition value="code = 'Alive'"/>
            </source>
            <target>
              <context value="status"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="cod"/>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://terminology.hl7.org/CodeSystem/condition-clinical"/>
              </parameter>
            </target>
            <target>
              <context value="cod"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="MapMeaslesImmunization"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="QuestionnaireResponse"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="immunization"/>
      <type value="Immunization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="immunizationId"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="immunization"/>
        <contextType value="variable"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="immunization"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="completed"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="vaccineCode"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="immunization"/>
        <contextType value="variable"/>
        <element value="vaccineCode"/>
        <variable value="code"/>
      </target>
      <rule>
        <name value="mrCoding"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="code"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="cvxSys"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://hl7.org/fhir/sid/cvx"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="measlesCode"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="05"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="mrDisplay"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Measles-Rubella (MR) Vaccine"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="patient"/>
      <source>
        <context value="src"/>
        <element value="subject"/>
        <variable value="subj"/>
      </source>
      <target>
        <context value="immunization"/>
        <contextType value="variable"/>
        <element value="patient"/>
        <variable value="ref"/>
      </target>
      <target>
        <context value="ref"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'Patient/' + subj.reference"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="vaccination"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="vaccination"/>
        <condition value="linkId = '736291402384'"/>
      </source>
      <rule>
        <name value="vaccinationStatus"/>
        <source>
          <context value="vaccination"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '517772812375'"/>
        </source>
        <rule>
          <name value="notVaccinated"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
            <condition value="valueCoding.code = 'no'"/>
          </source>
          <target>
            <context value="immunization"/>
            <contextType value="variable"/>
            <element value="status"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="not-done"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="unknownStatus"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
            <condition value="valueCoding.code = 'unknown'"/>
          </source>
          <target>
            <context value="immunization"/>
            <contextType value="variable"/>
            <element value="statusReason"/>
            <variable value="reason"/>
          </target>
          <target>
            <context value="reason"/>
            <contextType value="variable"/>
            <element value="text"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Unknown vaccination status"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="doses"/>
        <source>
          <context value="vaccination"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '886125589225'"/>
        </source>
        <rule>
          <name value="protocol"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="immunization"/>
            <contextType value="variable"/>
            <element value="protocolApplied"/>
            <variable value="protocol"/>
          </target>
          <rule>
            <name value="doseNumber"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="protocol"/>
              <contextType value="variable"/>
              <element value="doseNumber"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ans.valueInteger"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="last30Days"/>
        <source>
          <context value="vaccination"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '308128177300'"/>
        </source>
        <rule>
          <name value="last30DaysExt"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="immunization"/>
            <contextType value="variable"/>
            <element value="extension"/>
            <variable value="ext"/>
          </target>
          <rule>
            <name value="extUrl"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="ext"/>
              <contextType value="variable"/>
              <element value="url"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://example.org/StructureDefinition/vaccineLast30Days"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="extValue"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="ext"/>
              <contextType value="variable"/>
              <element value="valueCoding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ans.valueCoding"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="lastVaccDate"/>
        <source>
          <context value="vaccination"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '544290619304'"/>
        </source>
        <rule>
          <name value="lastVaccDate"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="immunization"/>
            <contextType value="variable"/>
            <element value="occurrenceDateTime"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueDate"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="MapMeaslesSpecimen"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="QuestionnaireResponse"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="specimen"/>
      <type value="Specimen"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="specimenId"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="specimen"/>
        <contextType value="variable"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="specimenType"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="specimen"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <rule>
        <name value="serumCoding"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="type"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <rule>
          <name value="snomedSys"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://snomed.info/sct"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="serumCode"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="119364003"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="serumDisplay"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Serum specimen"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="src"/>
        <element value="subject"/>
        <variable value="subj"/>
      </source>
      <target>
        <context value="specimen"/>
        <contextType value="variable"/>
        <element value="subject"/>
        <variable value="ref"/>
      </target>
      <target>
        <context value="ref"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'Patient/' + subj.reference"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="specimenCollection"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="specimenCollection"/>
        <condition value="linkId = '271053545237'"/>
      </source>
      <rule>
        <name value="specimenTypes"/>
        <source>
          <context value="specimenCollection"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '412689284625'"/>
        </source>
        <rule>
          <name value="specimenNote"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="specimen"/>
            <contextType value="variable"/>
            <element value="note"/>
            <variable value="note"/>
          </target>
          <target>
            <context value="note"/>
            <contextType value="variable"/>
            <element value="text"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'Specimen collected: ' + ans.valueCoding.display"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="collectionDate"/>
        <source>
          <context value="specimenCollection"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '8962468583341'"/>
        </source>
        <rule>
          <name value="collectionDate"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="specimen"/>
            <contextType value="variable"/>
            <element value="collection"/>
            <variable value="coll"/>
          </target>
          <target>
            <context value="coll"/>
            <contextType value="variable"/>
            <element value="collectedDateTime"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="ans.valueDate"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="sentToLabDate"/>
        <source>
          <context value="specimenCollection"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '718251724172'"/>
        </source>
        <rule>
          <name value="sentToLab"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="specimen"/>
            <contextType value="variable"/>
            <element value="processing"/>
            <variable value="proc"/>
          </target>
          <rule>
            <name value="procDesc"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="proc"/>
              <contextType value="variable"/>
              <element value="description"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Specimen sent to lab"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="procTime"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="proc"/>
              <contextType value="variable"/>
              <element value="timeDateTime"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ans.valueDate"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="otherSpecimen"/>
        <source>
          <context value="specimenCollection"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="linkId = '340507649387'"/>
        </source>
        <rule>
          <name value="otherSpecimenNote"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <listMode value="first"/>
            <variable value="ans"/>
          </source>
          <target>
            <context value="specimen"/>
            <contextType value="variable"/>
            <element value="note"/>
            <variable value="note"/>
          </target>
          <target>
            <context value="note"/>
            <contextType value="variable"/>
            <element value="text"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'Other specimen type: ' + ans.valueString"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
</StructureMap>