Guia de implementação do Sumário Internacional do Paciente: Release 1 - BR Realm | STU1
1.0.0 - STU1 Brazil flag

This page is part of the IPS Brasil (v1.0.0: Release) based on FHIR (HL7® FHIR® Standard) R4. This is the current published version. For a full list of available versions, see the Directory of published versions

: Mapeamento de Bundle da RNDS para o IPS - XML Representation

Draft as of 2024-12-23

Raw xml | Download


<StructureMap xmlns="http://hl7.org/fhir">
  <id value="StructureMapBRIPS"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap StructureMapBRIPS</b></p><a name="StructureMapBRIPS"> </a><a name="hcStructureMapBRIPS"> </a><a name="StructureMapBRIPS-pt-BR"> </a><pre class="fml">
<b>map</b><span style="color: navy"> &quot;</span>https://ips.saude.gov.br/fhir/StructureMap/StructureMapBRIPS<span style="color: navy">&quot; = &quot;</span>StructureMapBRIPS<span style="color: navy">&quot;

</span><span style="color: navy">// </span><span style="color: green">Mapeamento de Bundle da RNDS para o IPS</span>

<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>TLeft <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/uv/ips/STU1.1/StructureDefinition-Bundle-uv-ips.html" title="Bundle - IPS">http://hl7.org/fhir/uv/ips/StructureDefinition/Bundle-uv-ips</a><span style="color: navy">&quot; </span><b>alias </b>TRight <b>as </b><b>target</b>

<b>group </b>RNDSIPSBundle<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>TLeft, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>TRight<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.id<b> as </b><span style="color: maroon">RNDSID</span><span style="color: navy"><b> -&gt; </b></span>tgt<b> as </b><span style="color: maroon">IPS</span><b> then</b><span style="color: navy"> {
</span>    RNDSID<span style="color: navy"><b> -&gt; </b></span>tgt.identifier<b> as </b><span style="color: maroon">IPSIdentifier</span><b> then</b><span style="color: navy"> {
</span>      RNDSID<span style="color: navy"><b> -&gt; </b></span> IPS.type = <span style="color: blue">'document'</span><span style="color: navy">, </span> IPS.timestamp = <span style="color: navy">(</span>now()<span style="color: navy">)</span><span style="color: navy">, </span> IPSIdentifier.system = <span style="color: blue">'urn:ietf:rfc:3986'</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid</span><span style="color: navy">, </span> IPSIdentifier.value = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid</span><span style="color: navy">)</span> <i>&quot;SetDocumentTypeAndTimestampAndIdentifier&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;SetMetaData&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;SetBundleMetaData&quot;</i><span style="color: navy">;</span>
  src.entry<b> default </b>&quot;empty&quot;<b> as </b><span style="color: maroon">RNDSEntry</span><span style="color: navy"><b> -&gt; </b></span> tgt.entry<b> as </b><span style="color: maroon">IPSEntry</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryCondition</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryAllergyIntolerance</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryMedicationStatement</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSPatientReference</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSPractitionerReference</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSConditionNoKnownProblemsReference</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSMedicationStatementNoKnownMedicationsReference</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSAllergyIntoleranceNoKnownAllergiesReference</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSVitalSignsNoKnownVitalSignsReference</span><b> then</b><span style="color: navy"> {
</span>    RNDSEntry<b> where </b>(RNDSEntry = 'empty')<span style="color: navy"><b> -&gt; </b></span>IPSEntry<b> then</b><span style="color: navy"> {
</span>      RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid</span><span style="color: navy">, </span> IPSEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid</span><span style="color: navy">)</span> <i>&quot;SetFullUrl&quot;</i><span style="color: navy">;</span>
      RNDSEntry<span style="color: navy"><b> -&gt; </b></span><b>create</b><span style="color: navy">(</span><span style="color: blue">'Composition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSComposition</span><b> then</b><span style="color: navy"> {
</span>        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSComposition.status = <span style="color: blue">'final'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'60591-5'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'Patient Summary Document'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSComposition.type = <span style="color: maroon">cc</span><span style="color: navy">, </span> IPSComposition.date = <span style="color: navy">(</span>now()<span style="color: navy">)</span><span style="color: navy">, </span> IPSComposition.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><span style="color: navy">, </span> <span style="color: navy">(</span>today()<span style="color: navy">)</span><b> as </b><span style="color: maroon">today</span><span style="color: navy">, </span> IPSComposition.title = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient Summary as of:'</span><span style="color: navy">, </span><span style="color: maroon">today</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSComposition.confidentiality = <span style="color: blue">'N'</span><span style="color: navy">, </span> IPSComposition.text<b> as </b><span style="color: maroon">IPSCompositionText</span><span style="color: navy">, </span> IPSCompositionText.status = <span style="color: blue">'generated'</span><span style="color: navy">, </span> IPSCompositionText.div = <b>append</b><span style="color: navy">(</span><span style="color: blue">'&lt;div xmlns=\&quot;http://www.w3.org/1999/xhtml\&quot;&gt;Title: International Patient Summary from Brazil, code: http://loinc.org#60591-5, status: generated, confidentiality: N&lt;/div&gt;'</span><span style="color: navy">)</span> <i>&quot;SetCompositionFirstOrderFields&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSComposition.subject<b> as </b><span style="color: maroon">IPSCompositionSubject</span><span style="color: navy">, </span> IPSComposition.author<b> as </b><span style="color: maroon">IPSCompositionAuthor</span><span style="color: navy">, </span> IPSComposition.custodian<b> as </b><span style="color: maroon">IPSCompositionCustodian</span><span style="color: navy">, </span> IPSComposition.section<b> as </b><span style="color: maroon">IPSCompositionSectionActiveProblems</span><span style="color: navy">, </span> IPSComposition.section<b> as </b><span style="color: maroon">IPSCompositionMedication</span><span style="color: navy">, </span> IPSComposition.section<b> as </b><span style="color: maroon">IPSCompositionAllergiesAndIntolerances</span><span style="color: navy">, </span> IPSComposition.section<b> as </b><span style="color: maroon">IPSCompositionVitalSigns</span><b> then</b><span style="color: navy"> {
</span>          RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSCompositionSubject.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPatientReference</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSCompositionAuthor.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPractitionerReference</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSCompositionCustodian.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPractitionerReference</span><span style="color: navy">)</span> <i>&quot;SetReferences&quot;</i><span style="color: navy">;</span>
          RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSCompositionSectionActiveProblems.title = <span style="color: blue">'Active Problems'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'11450-4'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'Problem list Reported'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSCompositionSectionActiveProblems.code = <span style="color: maroon">cc</span><span style="color: navy">, </span> IPSCompositionSectionActiveProblems.entry<b> as </b><span style="color: maroon">IPSCompositionSectionActiveProblemsEntry</span><span style="color: navy">, </span> IPSCompositionSectionActiveProblemsEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSConditionNoKnownProblemsReference</span><span style="color: navy">)</span> <i>&quot;SetActiveProblems&quot;</i><span style="color: navy">;</span>
          RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSCompositionMedication.title = <span style="color: blue">'Medications'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'10160-0'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'History of Medication use Narrative'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSCompositionMedication.code = <span style="color: maroon">cc</span><span style="color: navy">, </span> IPSCompositionMedication.entry<b> as </b><span style="color: maroon">IPSCompositionSectionMedicationEntry</span><span style="color: navy">, </span> IPSCompositionSectionMedicationEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSMedicationStatementNoKnownMedicationsReference</span><span style="color: navy">)</span> <i>&quot;SetTitleMedications&quot;</i><span style="color: navy">;</span>
          RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSCompositionAllergiesAndIntolerances.title = <span style="color: blue">'Allergies and Intolerances'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'48765-2'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'Allergies and adverse reactions Document'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSCompositionAllergiesAndIntolerances.code = <span style="color: maroon">cc</span><span style="color: navy">, </span> IPSCompositionAllergiesAndIntolerances.entry<b> as </b><span style="color: maroon">IPSCompositionSectionAllergiesAndIntolerancesEntry</span><span style="color: navy">, </span> IPSCompositionSectionAllergiesAndIntolerancesEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSAllergyIntoleranceNoKnownAllergiesReference</span><span style="color: navy">)</span> <i>&quot;SetAllergiesAndIntolerances&quot;</i><span style="color: navy">;</span>
          RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSCompositionVitalSigns.title = <span style="color: blue">'Vital Signs'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'8716-3'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'Vital signs'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSCompositionVitalSigns.code = <span style="color: maroon">cc</span><span style="color: navy">, </span> IPSCompositionVitalSigns.entry<b> as </b><span style="color: maroon">IPSCompositionVitalSignsEntry</span><span style="color: navy">, </span> IPSCompositionVitalSignsEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSVitalSignsNoKnownVitalSignsReference</span><span style="color: navy">)</span> <i>&quot;SetVitalSigns&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;SetSubjectAuthorCustodianSection&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSEntry.resource = <span style="color: maroon">IPSComposition</span> <i>&quot;SetResourceComposition&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;SetComposition&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;SetEmptyComposition&quot;</i><span style="color: navy">;</span>
    RNDSEntry<b> where </b>(RNDSEntry = 'empty')<span style="color: navy"><b> -&gt; </b></span>IPSEntryCondition<b> then</b><span style="color: navy"> {
</span>      RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid</span><span style="color: navy">, </span> IPSEntryCondition.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid</span><span style="color: navy">)</span> <i>&quot;SetFullUrl&quot;</i><span style="color: navy">;</span>
      RNDSEntry<span style="color: navy"><b> -&gt; </b></span><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">IPSCondition</span><b> then</b><span style="color: navy"> {
</span>        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-clinical'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'active'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSCondition.clinicalStatus = <span style="color: maroon">cc</span> <i>&quot;SetClinicalStatus&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'no-problem-info'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'No information about problems'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSCondition.code = <span style="color: maroon">cc</span> <i>&quot;SetCode&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-ver-status'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'confirmed'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'Confirmed'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSCondition.verificationStatus = <span style="color: maroon">cc</span> <i>&quot;SetCode&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSCondition.subject<b> as </b><span style="color: maroon">IPSConditionSubject</span><span style="color: navy">, </span> IPSConditionSubject.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPatientReference</span><span style="color: navy">)</span> <i>&quot;SetSubject&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSEntryCondition.resource<b> as </b><span style="color: maroon">IPSEntryConditionResource</span><span style="color: navy">, </span> IPSEntryConditionResource.text<b> as </b><span style="color: maroon">IPSEntryConditionResourceText</span><span style="color: navy">, </span> IPSEntryConditionResourceText.status = <span style="color: blue">'generated'</span><span style="color: navy">, </span> IPSCondition.code<b> as </b><span style="color: maroon">IPSConditionCode</span><span style="color: navy">, </span> IPSConditionCode.coding<b> as </b><span style="color: maroon">IPSConditionCodeCoding</span><span style="color: navy">, </span> IPSConditionCodeCoding.code<b> as </b><span style="color: maroon">IPSConditionCodeCodingCode</span><span style="color: navy">, </span> IPSCondition.clinicalStatus<b> as </b><span style="color: maroon">IPSConditionClinicalStatus</span><span style="color: navy">, </span> IPSConditionClinicalStatus.coding<b> as </b><span style="color: maroon">IPSConditionClinicalStatusCoding</span><span style="color: navy">, </span> IPSConditionClinicalStatusCoding.code<b> as </b><span style="color: maroon">IPSConditionClinicalStatusCodingCode</span><span style="color: navy">, </span> IPSCondition.verificationStatus<b> as </b><span style="color: maroon">IPSConditionVerificationStatus</span><span style="color: navy">, </span> IPSConditionVerificationStatus.coding<b> as </b><span style="color: maroon">IPSConditionVerificationStatusCoding</span><span style="color: navy">, </span> IPSConditionVerificationStatusCoding.code<b> as </b><span style="color: maroon">IPSConditionVerificationStatusCodingCode</span><span style="color: navy">, </span> IPSEntryConditionResourceText.div = <b>append</b><span style="color: navy">(</span><span style="color: blue">'&lt;div xmlns=\&quot;http://www.w3.org/1999/xhtml\&quot;&gt;Condition'</span><span style="color: navy">, </span><span style="color: maroon">IPSConditionCodeCodingCode</span><span style="color: navy">, </span><span style="color: blue">',clinicalStatus:'</span><span style="color: navy">, </span><span style="color: maroon">IPSConditionClinicalStatusCodingCode</span><span style="color: navy">, </span><span style="color: blue">',verificationStatus:'</span><span style="color: navy">, </span><span style="color: maroon">IPSConditionVerificationStatusCodingCode</span><span style="color: navy">, </span><span style="color: blue">'&lt;/div&gt;'</span><span style="color: navy">)</span> <i>&quot;SetConditionNarrativeElement&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSEntryCondition.resource = <span style="color: maroon">IPSCondition</span> <i>&quot;SetCondition&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;SetCondition&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;SetEmptyCondition&quot;</i><span style="color: navy">;</span>
    RNDSEntry<b> where </b>(RNDSEntry = 'empty')<span style="color: navy"><b> -&gt; </b></span>IPSEntryAllergyIntolerance<b> then</b><span style="color: navy"> {
</span>      RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid</span><span style="color: navy">, </span> IPSEntryAllergyIntolerance.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid</span><span style="color: navy">)</span> <i>&quot;SetFullUrl&quot;</i><span style="color: navy">;</span>
      RNDSEntry<span style="color: navy"><b> -&gt; </b></span><b>create</b><span style="color: navy">(</span><span style="color: blue">'AllergyIntolerance'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSAllergyIntolerance</span><b> then</b><span style="color: navy"> {
</span>        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'active'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSAllergyIntolerance.clinicalStatus = <span style="color: maroon">cc</span> <i>&quot;SetClinicalStatus&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'no-allergy-info'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'No information about allergies'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSAllergyIntolerance.code = <span style="color: maroon">cc</span> <i>&quot;SetCode&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSAllergyIntolerance.patient<b> as </b><span style="color: maroon">IPSAllergyIntolerancePatient</span><span style="color: navy">, </span> IPSAllergyIntolerancePatient.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPatientReference</span><span style="color: navy">)</span> <i>&quot;SetPatient&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSEntryAllergyIntolerance.resource = <span style="color: maroon">IPSAllergyIntolerance</span> <i>&quot;SetAllergyIntolerance&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSAllergyIntolerance.text<b> as </b><span style="color: maroon">IPSAllergyIntoleranceText</span><span style="color: navy">, </span> IPSAllergyIntoleranceText.status = <span style="color: blue">'generated'</span><span style="color: navy">, </span> IPSAllergyIntoleranceText.div = <span style="color: blue">'&lt;div xmlns=\&quot;http://www.w3.org/1999/xhtml\&quot;&gt;No allergy information&lt;/div&gt;'</span> <i>&quot;SetAllergyText&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;SetAllergyIntolerance&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;SetEmptyAllergyIntolerance&quot;</i><span style="color: navy">;</span>
    RNDSEntry<b> where </b>(RNDSEntry = 'empty')<span style="color: navy"><b> -&gt; </b></span>IPSEntryMedicationStatement<b> then</b><span style="color: navy"> {
</span>      RNDSEntry<span style="color: navy"><b> -&gt; </b></span><b>create</b><span style="color: navy">(</span><span style="color: blue">'MedicationStatement'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSMedicationStatement</span><b> then</b><span style="color: navy"> {
</span>        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSMedicationStatement.status = <span style="color: blue">'unknown'</span> <i>&quot;SetStatus&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'no-medication-info'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'No information about medications'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSMedicationStatement.medication = <span style="color: maroon">cc</span> <i>&quot;SetCode&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSMedicationStatement.effectivePeriod<b> as </b><span style="color: maroon">IPSMedicationStatementEffectivePeriod</span><b> then </b>NotApplicable<span style="color: navy">(</span><span style="color: maroon">RNDSEntry</span><span style="color: navy">, </span><span style="color: maroon">IPSMedicationStatementEffectivePeriod</span><span style="color: navy">)</span> <i>&quot;SetEffectivePeriod&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSMedicationStatement.subject<b> as </b><span style="color: maroon">IPSMedicationStatementSubject</span><span style="color: navy">, </span> IPSMedicationStatementSubject.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPatientReference</span><span style="color: navy">)</span> <i>&quot;SetSubject&quot;</i><span style="color: navy">;</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid</span><span style="color: navy">, </span> IPSEntryMedicationStatement.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryMedicationStatement.resource = <span style="color: maroon">IPSMedicationStatement</span> <i>&quot;SetMedicationStatement&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;SetMedicationStatement&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;SetEmptyMedicationStatement&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;SetEmptyIPSEntries&quot;</i><span style="color: navy">;</span>
  src.entry<b> as </b><span style="color: maroon">RNDSEntry</span><span style="color: navy"><b> -&gt; </b></span> tgt.entry<b> as </b><span style="color: maroon">IPSEntry</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryCondition</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryVitalSigns</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryResults</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntrySpecimen</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryImmunization</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryProcedures</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryMedicationRequests</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryMedications</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryAllergyIntolerance</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryMedicationStatement</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryPatient</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryPractitioner</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">IPSEntryCustodian</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSPatientReference</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSPractitionerReference</span><b> then</b><span style="color: navy"> {
</span>    RNDSEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResource</span><span style="color: navy"><b> -&gt; </b></span><b>create</b><span style="color: navy">(</span><span style="color: blue">'Composition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSEntryResourceComposition</span><b> then</b><span style="color: navy"> {
</span>      RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceComposition.status = <span style="color: blue">'final'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'60591-5'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'Patient Summary Document'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryResourceComposition.type = <span style="color: maroon">cc</span><span style="color: navy">, </span> IPSEntryResourceComposition.date = <span style="color: navy">(</span>now()<span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryResourceComposition.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><span style="color: navy">, </span> <span style="color: navy">(</span>today()<span style="color: navy">)</span><b> as </b><span style="color: maroon">today</span><span style="color: navy">, </span> IPSEntryResourceComposition.title = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient Summary as of'</span><span style="color: navy">, </span><span style="color: maroon">today</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryResourceComposition.confidentiality = <span style="color: blue">'N'</span><span style="color: navy">, </span> IPSEntryResourceComposition.text<b> as </b><span style="color: maroon">IPSEntryResourceCompositionText</span><span style="color: navy">, </span> IPSEntryResourceCompositionText.status = <span style="color: blue">'generated'</span><span style="color: navy">, </span> IPSEntryResourceCompositionText.div = <b>append</b><span style="color: navy">(</span><span style="color: blue">'&lt;div xmlns=\&quot;http://www.w3.org/1999/xhtml\&quot;&gt;Title: International Patient Summary from Brazil, code: http://loinc.org#60591-5, status: generated, confidentiality: N&lt;/div&gt;'</span><span style="color: navy">)</span> <i>&quot;SetCompositionFirstOrderFields&quot;</i><span style="color: navy">;</span>
      RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceComposition.subject<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSubject</span><span style="color: navy">, </span> IPSEntryResourceComposition.author<b> as </b><span style="color: maroon">IPSEntryResourceCompositionPractitioner</span><span style="color: navy">, </span> IPSEntryResourceComposition.custodian<b> as </b><span style="color: maroon">IPSEntryResourceCompositionCustodian</span><span style="color: navy">, </span> IPSEntryResourceComposition.section<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionActiveProblems</span><span style="color: navy">, </span> IPSEntryResourceComposition.section<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionMedications</span><span style="color: navy">, </span> IPSEntryResourceComposition.section<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionAllergiesAndIntolerances</span><span style="color: navy">, </span> IPSEntryResourceComposition.section<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionResults</span><span style="color: navy">, </span> IPSEntryResourceComposition.section<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionVitalSigns</span><b> then</b><span style="color: navy"> {
</span>        <span style="color: navy">// </span><span style="color: green">Bloco que seta as referencias a subject, practitioner e custodian no composition</span>
        RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSubject.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPatientReference</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryResourceCompositionPractitioner.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPractitionerReference</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryResourceCompositionCustodian.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPractitionerReference</span><span style="color: navy">)</span> <i>&quot;SetResourceCompositionReferences&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria a secao de problemas no composition</span>
        RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionActiveProblems.title = <span style="color: blue">'Active Problems'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'11450-4'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'Problem list Reported'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionActiveProblems.code = <span style="color: maroon">cc</span> <i>&quot;SetActiveProblems&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria condition vazio quando nao ha conditions no bundle</span>
        RNDSEntryResource<b> where </b>(RNDSEntryResource.entry.resource.entry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRCondicaoSaude').empty())<span style="color: navy"><b> -&gt; </b></span> <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">IPSEntryEmptyCondition</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSEntryEmptyConditionId</span><span style="color: navy">, </span> IPSEntryEmptyCondition.id = <span style="color: maroon">IPSEntryEmptyConditionId</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/condition-clinical'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'active'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryEmptyCondition.clinicalStatus = <span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'no-problem-info'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'No information about problems'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryEmptyCondition.code = <span style="color: maroon">cc</span><span style="color: navy">, </span> IPSEntryEmptyCondition.subject<b> as </b><span style="color: maroon">IPSEntryEmptyConditionSubject</span><span style="color: navy">, </span> IPSEntryEmptyConditionSubject.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPatientReference</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryCondition.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSEntryEmptyConditionId</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryCondition.resource = <span style="color: maroon">IPSEntryEmptyCondition</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionActiveProblems.entry<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionActiveProblemsEntry</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionActiveProblemsEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSEntryEmptyConditionId</span><span style="color: navy">)</span> <i>&quot;CreateNoKnownConditions&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria a secao de alergias no composition</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionAllergiesAndIntolerances.title = <span style="color: blue">'Allergies and Intolerances'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'48765-2'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'Allergies and adverse reactions Document'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionAllergiesAndIntolerances.code = <span style="color: maroon">cc</span> <i>&quot;SetAllergiesAndIntolerances&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria o Allergy Intolerance vazio quando nao ha allergy intolerance no bundle</span>
        RNDSEntryResource<b> where </b>(RNDSEntryResource.entry.resource.entry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRAlergiaReacaoAdversa').empty())<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'AllergyIntolerance'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSEntryEmptyAllergyIntolerance</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSEntryEmptyAllergyIntoleranceId</span><span style="color: navy">, </span> IPSEntryEmptyAllergyIntolerance.id = <span style="color: maroon">IPSEntryEmptyAllergyIntoleranceId</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'active'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryEmptyAllergyIntolerance.clinicalStatus = <span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'no-allergy-info'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'No information about allergies'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryEmptyAllergyIntolerance.code = <span style="color: maroon">cc</span><span style="color: navy">, </span> IPSEntryEmptyAllergyIntolerance.patient<b> as </b><span style="color: maroon">IPSEntryEmptyAllergyIntolerancePatient</span><span style="color: navy">, </span> IPSEntryEmptyAllergyIntolerancePatient.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPatientReference</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryEmptyAllergyIntolerance.text<b> as </b><span style="color: maroon">IPSEntryEmptyAllergyIntoleranceText</span><span style="color: navy">, </span> IPSEntryEmptyAllergyIntoleranceText.status = <span style="color: blue">'generated'</span><span style="color: navy">, </span> IPSEntryEmptyAllergyIntoleranceText.div = <span style="color: blue">'&lt;div xmlns=\&quot;http://www.w3.org/1999/xhtml\&quot;&gt;No known allergies&lt;/div&gt;'</span><span style="color: navy">, </span> IPSEntryAllergyIntolerance.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSEntryEmptyAllergyIntoleranceId</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryAllergyIntolerance.resource = <span style="color: maroon">IPSEntryEmptyAllergyIntolerance</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionAllergiesAndIntolerances.entry<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionAllergiesAndIntolerancesEntry</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionAllergiesAndIntolerancesEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSEntryEmptyAllergyIntoleranceId</span><span style="color: navy">)</span> <i>&quot;CreateNoKnownConditions&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria Medication Statement vazio quando nao ha medication statement no bundle</span>
        RNDSEntryResource<b> where </b>(RNDSEntryResource.entry.resource.entry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRMedicamento').empty())<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'MedicationStatement'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSEntryEmptyMedicationStatement</span><span style="color: navy">, </span> <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSEntryEmptyMedicationStatementId</span><span style="color: navy">, </span> IPSEntryEmptyMedicationStatement.id = <span style="color: maroon">IPSEntryEmptyMedicationStatementId</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'no-medication-info'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'No information about medications'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryEmptyMedicationStatement.medication = <span style="color: maroon">cc</span><span style="color: navy">, </span> IPSEntryEmptyMedicationStatement.status = <span style="color: blue">'unknown'</span><span style="color: navy">, </span> IPSEntryEmptyMedicationStatement.subject<b> as </b><span style="color: maroon">IPSEntryEmptyMedicationStatementSubject</span><span style="color: navy">, </span> IPSEntryEmptyMedicationStatementSubject.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPatientReference</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryMedicationStatement.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSEntryEmptyMedicationStatementId</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryMedicationStatement.resource = <span style="color: maroon">IPSEntryEmptyMedicationStatement</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionMedications.entry<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionMedicationEntry</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionMedicationEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSEntryEmptyMedicationStatementId</span><span style="color: navy">)</span> <i>&quot;CreateNoKnownMedications&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria conditions BRCondicaoSaude</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>          RNDSEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>            RNDSEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntry</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                RNDSEntryResourceEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntry</span><b> then</b><span style="color: navy"> {
</span>                  RNDSEntryResourceEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span><b> where </b>(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRCondicaoSaude').empty().not())<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                    RNDSEntryResourceEntryResourceEntryResource.id<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionActiveProblems.entry<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionActiveProblemsEntry</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionActiveProblemsEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">AddEntry</span><span style="color: navy">, </span> AddEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> AddEntry.resource = <span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span> <i>&quot;AddEntry&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;SetResource&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResourceEntry&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResource&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResource&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;IterateRNDSEntry&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria alergias BRAlergiaReacaoAdversa</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>          RNDSEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>            RNDSEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntry</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                RNDSEntryResourceEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntry</span><b> then</b><span style="color: navy"> {
</span>                  RNDSEntryResourceEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span><b> where </b>(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRAlergiaReacaoAdversa').empty().not())<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                    RNDSEntryResourceEntryResourceEntryResource.id<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionAllergiesAndIntolerances.entry<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionAllergiesAndIntolerancesEntry</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionAllergiesAndIntolerancesEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">AddEntry</span><span style="color: navy">, </span> AddEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> AddEntry.resource = <span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span> <i>&quot;AddEntry&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;SetResource&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResourceEntry&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResource&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResource&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;IterateRNDSEntry&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria Secao de REL</span>
        RNDSEntryResource<b> where </b>(RNDSEntryResource.entry.resource.entry.resource.meta.where((profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRDiagnosticoCOVID19-TesteRapido') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRDiagnosticoLaboratorioClinico') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRObservacaoDescritiva')).empty().not())<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceComposition<b> then</b><span style="color: navy"> {
</span>          RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceCompositionSectionResults<b> then</b><span style="color: navy"> {
</span>            <span style="color: navy">// </span><span style="color: green">cria section de results no composition</span>
            RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceCompositionSectionResults<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionResults.title = <span style="color: blue">'Results'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'30954-2'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'Relevant diagnostic tests/laboratory data Narrative'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionResults.code = <span style="color: maroon">cc</span> <i>&quot;SetResultsNarrative&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;SetCompositionSectionResults&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;CreateSectionResults&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;CreateSectionResultsIfExist&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que mapeia REL</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>          RNDSEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>            RNDSEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntry</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                RNDSEntryResourceEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntry</span><b> then</b><span style="color: navy"> {
</span>                  RNDSEntryResourceEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span><b> where </b>(RNDSEntryResourceEntryResourceEntry.resource.meta.where((profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRDiagnosticoCOVID19-TesteRapido') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRDiagnosticoLaboratorioClinico') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRObservacaoDescritiva')).empty().not())<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                    RNDSEntryResourceEntryResourceEntryResource.id<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionResults.entry<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionResultsEntry</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionResultsEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">AddEntry</span><span style="color: navy">, </span> AddEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> AddEntry.resource = <span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span> <i>&quot;AddEntry&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;SetResource&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResourceEntry&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResource&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResource&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;IterateRNDSEntry&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que mapeia BRAmostraBiologica-1.0</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>          RNDSEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>            RNDSEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntry</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                RNDSEntryResourceEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntry</span><b> then</b><span style="color: navy"> {
</span>                  RNDSEntryResourceEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span><b> where </b>(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRAmostraBiologica').empty().not())<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                    RNDSEntryResourceEntryResourceEntryResource.id<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy"><b> -&gt; </b></span> tgt.entry<b> as </b><span style="color: maroon">AddEntry</span><span style="color: navy">, </span> AddEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> AddEntry.resource = <span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span> <i>&quot;AddEntry&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;SetResource&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResourceEntry&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResource&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResource&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;IterateRNDSEntry&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria Secao de Vital Signs</span>
        RNDSEntryResource<b> where </b>(RNDSEntryResource.entry.resource.entry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRMedidaObservada').empty().not())<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceComposition<b> then</b><span style="color: navy"> {
</span>          RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceCompositionSectionVitalSigns<b> then</b><span style="color: navy"> {
</span>            <span style="color: navy">// </span><span style="color: green">cria section de results no composition</span>
            RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceCompositionSectionVitalSigns<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionVitalSigns.title = <span style="color: blue">'Vital Signs'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'8716-3'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'Vital signs'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionVitalSigns.code = <span style="color: maroon">cc</span> <i>&quot;SetResultsNarrative&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;SetCompositionSectionResults&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;CreateSectionResults&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;CreateSectionResultsIfExist&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria Vital Signs</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>          RNDSEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>            RNDSEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntry</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                RNDSEntryResourceEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntry</span><b> then</b><span style="color: navy"> {
</span>                  RNDSEntryResourceEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span><b> where </b>(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRMedidaObservada').empty().not())<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                    RNDSEntryResourceEntryResourceEntryResource.id<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionVitalSigns.entry<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionVitalSignsEntry</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionVitalSignsEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">AddEntry</span><span style="color: navy">, </span> AddEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> AddEntry.resource = <span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span> <i>&quot;AddEntry&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;SetResource&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResourceEntry&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResource&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResource&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;IterateRNDSEntry&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria secao de Imunizacao</span>
        RNDSEntryResource<b> where </b>(RNDSEntryResource.entry.resource.entry.resource.meta.where((profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministrado') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministradoCarga') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministradoCampanha')).empty().not())<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceComposition<b> then</b><span style="color: navy"> {
</span>          RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceComposition.section<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionImmunizations</span><b> then</b><span style="color: navy"> {
</span>            <span style="color: navy">// </span><span style="color: green">cria section de immunizations no composition</span>
            RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceCompositionSectionImmunizations<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionImmunizations.title = <span style="color: blue">'Immunizations'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'11369-6'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'History of Immunization Narrative'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionImmunizations.code = <span style="color: maroon">cc</span> <i>&quot;SetImmunizationsNarrative&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;SetCompositionSectionImmunizations&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Bloco que mapeia BRImunobiologicoAdministrado-2.0, BRImunobiologicoAdministradoCampanha-1.0 e BRImunobiologicoAdministradoCarga-2.0</span>
            RNDSEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntry</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                RNDSEntryResourceEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntry</span><b> then</b><span style="color: navy"> {
</span>                  RNDSEntryResourceEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span><b> where </b>(RNDSEntryResourceEntryResourceEntry.resource.meta.where((profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministrado') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministradoCarga') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministradoCampanha')).empty().not())<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                    RNDSEntryResourceEntryResourceEntryResource.id<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionImmunizations.entry<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionImmunizationsEntry</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionImmunizationsEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">AddEntry</span><span style="color: navy">, </span> AddEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> AddEntry.resource = <span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span> <i>&quot;AddEntry&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;SetResource&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResourceEntry&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResource&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;CreateSectionImmunizations&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;CreateSectionImmunizationsIfExists&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">http://www.saude.gov.br/fhir/r4/StructureDefinition/BRProcedimentoRealizado-1.0</span>
        RNDSEntryResource<b> where </b>(RNDSEntryResource.entry.resource.entry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRProcedimentoRealizado').empty().not())<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceComposition<b> then</b><span style="color: navy"> {
</span>          RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceComposition.section<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionProcedures</span><b> then</b><span style="color: navy"> {
</span>            <span style="color: navy">// </span><span style="color: green">cria section de procedures no composition</span>
            RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceCompositionSectionProcedures<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionProcedures.title = <span style="color: blue">'History of procedures'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'47519-4'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'History of Procedures Narrative'</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionProcedures.code = <span style="color: maroon">cc</span> <i>&quot;SetProceduresNarrative&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;SetCompositionSectionProcedures&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Bloco que mapeia BRImunobiologicoAdministrado-2.0, BRImunobiologicoAdministradoCampanha-1.0 e BRImunobiologicoAdministradoCarga-2.0</span>
            RNDSEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntry</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResource</span><span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                RNDSEntryResourceEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntry</span><b> then</b><span style="color: navy"> {
</span>                  RNDSEntryResourceEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span><b> where </b>(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRProcedimentoRealizado').empty().not())<span style="color: navy"><b> -&gt; </b></span>tgt.entry<b> then</b><span style="color: navy"> {
</span>                    RNDSEntryResourceEntryResourceEntryResource.id<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionProcedures.entry<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionProceduresEntry</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionProceduresEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">AddEntry</span><span style="color: navy">, </span> AddEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> AddEntry.resource = <span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span> <i>&quot;AddEntry&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;SetResource&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResourceEntry&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResource&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;CreateSectionProcedures&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;CreateSectionProceduresIfExists&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">cria section de medications no composition</span>
        RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span>IPSEntryResourceCompositionSectionMedications<b> then</b><span style="color: navy"> {
</span>          RNDSEntryResource<span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionMedications.title = <span style="color: blue">'Medication'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> c.code = <span style="color: blue">'10160-0'</span><span style="color: navy">, </span> c.display = <span style="color: blue">'History of Medication use Narrative'</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <span style="color: maroon">c</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionMedications.code = <span style="color: maroon">cc</span> <i>&quot;SetMedicationsNarrative&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">http://www.saude.gov.br/fhir/r4/StructureDefinition/BRPrescricaoMedicamento</span>
          RNDSEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntry</span><span style="color: navy"><b> -&gt; </b></span>IPSEntryMedicationRequests<b> then</b><span style="color: navy"> {
</span>            RNDSEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResource</span><span style="color: navy"><b> -&gt; </b></span>IPSEntryMedicationRequests<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResourceEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntry</span><b> then</b><span style="color: navy"> {
</span>                RNDSEntryResourceEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span><b> where </b>(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRPrescricaoMedicamento').empty().not())<span style="color: navy"><b> -&gt; </b></span>IPSEntryMedicationRequests.resource<b> as </b><span style="color: maroon">IPSEntryMedicationRequestsResource</span><b> then</b><span style="color: navy"> {
</span>                  RNDSEntryResourceEntryResourceEntryResource.id<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceCompositionSectionMedications.entry<b> as </b><span style="color: maroon">IPSEntryResourceCompositionSectionMedicationsEntry</span><span style="color: navy">, </span> IPSEntryResourceCompositionSectionMedicationsEntry.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> tgt.entry<b> as </b><span style="color: maroon">AddEntry</span><span style="color: navy">, </span> AddEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> AddEntry.resource = <span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span> <i>&quot;AddEntry&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;SetResource&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResourceEntry&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResource&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">http://www.saude.gov.br/fhir/r4/StructureDefinition/BRMedicamento</span>
          RNDSEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntry</span><span style="color: navy"><b> -&gt; </b></span>IPSEntryMedications<b> then</b><span style="color: navy"> {
</span>            RNDSEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResource</span><span style="color: navy"><b> -&gt; </b></span>IPSEntryMedications<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResourceEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntry</span><b> then</b><span style="color: navy"> {
</span>                RNDSEntryResourceEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span><b> where </b>(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRMedicamento').empty().not())<span style="color: navy"><b> -&gt; </b></span>IPSEntryMedications.resource<b> as </b><span style="color: maroon">IPSEntryMedicationsResource</span><b> then</b><span style="color: navy"> {
</span>                  RNDSEntryResourceEntryResourceEntryResource.id<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy"><b> -&gt; </b></span> tgt.entry<b> as </b><span style="color: maroon">AddEntry</span><span style="color: navy">, </span> AddEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResourceId</span><span style="color: navy">)</span><span style="color: navy">, </span> AddEntry.resource = <span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span> <i>&quot;AddEntry&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;SetResource&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResourceEntry&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResource&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntry&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;SetCompositionSectionMedications&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria Patient</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSEntryPatient<b> then</b><span style="color: navy"> {
</span>          RNDSEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResource</span><span style="color: navy"><b> -&gt; </b></span>IPSEntryPatient<b> then</b><span style="color: navy"> {
</span>            RNDSEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntry</span><span style="color: navy"><b> -&gt; </b></span>IPSEntryPatient<b> then</b><span style="color: navy"> {
</span>              RNDSEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResource</span><span style="color: navy"><b> -&gt; </b></span>IPSEntryPatient<b> then</b><span style="color: navy"> {
</span>                RNDSEntryResourceEntryResource.entry<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntry</span><b> then</b><span style="color: navy"> {
</span>                  RNDSEntryResourceEntryResourceEntry.resource<b> as </b><span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span><b> where </b>(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRIndividuo').empty().not())<span style="color: navy"><b> -&gt; </b></span>IPSEntryPatient.resource<b> as </b><span style="color: maroon">IPSEntryPatientResource</span><b> then</b><span style="color: navy"> {
</span>                    RNDSEntryResourceEntryResourceEntryResource<span style="color: navy"><b> -&gt; </b></span>IPSEntryPatient.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPatientReference</span><span style="color: navy">)</span> <i>&quot;SetPatientFullUrl&quot;</i><span style="color: navy">;</span>
                    RNDSEntryResourceEntryResourceEntryResource<span style="color: navy"><b> -&gt; </b></span>IPSEntryPatient.resource = <span style="color: maroon">RNDSEntryResourceEntryResourceEntryResource</span> <i>&quot;SetPatientResource&quot;</i><span style="color: navy">;</span>
                    RNDSEntryResourceEntryResourceEntryResource<span style="color: navy"><b> -&gt; </b></span>IPSEntryPatientResource.id = <span style="color: maroon">IPSPatientReference</span> <i>&quot;SetPatientId&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;SetPatient&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResourceEntry&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntryResource&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResourceEntry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;IterateRNDSEntryResource&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;IterateRNDSEntry&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bloco que cria organization para author e custodian</span>
        RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSEntryPractitioner<b> then</b><span style="color: navy"> {
</span>          RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSEntryPractitioner.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPractitionerReference</span><span style="color: navy">)</span> <i>&quot;SetFullUrl&quot;</i><span style="color: navy">;</span>
          RNDSEntry<span style="color: navy"><b> -&gt; </b></span><b>create</b><span style="color: navy">(</span><span style="color: blue">'Organization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSOrganization</span><b> then</b><span style="color: navy"> {
</span>            RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSOrganization.id = <span style="color: maroon">IPSPractitionerReference</span> <i>&quot;SetId&quot;</i><span style="color: navy">;</span>
            RNDSEntry<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Identifier'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">IPSPractitionerIdentifier</span><span style="color: navy">, </span> IPSPractitionerIdentifier.system = <span style="color: blue">'http://www.saude.gov.br/fhir/r4/NamingSystem/cnpj'</span><span style="color: navy">, </span> IPSPractitionerIdentifier.value = <span style="color: blue">'00394544000185'</span><span style="color: navy">, </span> IPSOrganization.identifier = <span style="color: maroon">IPSPractitionerIdentifier</span> <i>&quot;SetIdentifier&quot;</i><span style="color: navy">;</span>
            RNDSEntry<span style="color: navy"><b> -&gt; </b></span>IPSOrganization.name = <span style="color: blue">'Ministério da Saúde do Brasil'</span> <i>&quot;SetName&quot;</i><span style="color: navy">;</span>
            RNDSEntry<span style="color: navy"><b> -&gt; </b></span> IPSEntryPractitioner.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSPractitionerReference</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntryPractitioner.resource = <span style="color: maroon">IPSOrganization</span> <i>&quot;SetAuthor&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;SetAuthor&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;SetEmptyAuthor&quot;</i><span style="color: navy">;</span>
        RNDSEntryResource.id<b> as </b><span style="color: maroon">RNDSEntryResourceId</span><span style="color: navy"><b> -&gt; </b></span> IPSEntryResourceComposition.id<b> as </b><span style="color: maroon">IPSEntryResourceCompositionId</span><span style="color: navy">, </span> IPSEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">IPSEntryResourceCompositionId</span><span style="color: navy">)</span><span style="color: navy">, </span> IPSEntry.resource = <span style="color: maroon">IPSEntryResourceComposition</span> <i>&quot;SetResourceComposition&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;SetSubjectAuthorCustodianSection&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;SetIPSEntryResourceComposition&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;SetIPSEntries&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>DataAbsentReason<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>Element, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Element<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">TgtExtension</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'code'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.value = <span style="color: blue">'unknown'</span><span style="color: navy">, </span> TgtExtension.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/data-absent-reason'</span><span style="color: navy">, </span> TgtExtension.value = <span style="color: maroon">c</span><span style="color: navy">, </span> tgt.extension = <span style="color: maroon">TgtExtension</span> <i>&quot;SetExtension&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>NotApplicable<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>Element, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Element<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">TgtExtension</span><span style="color: navy">, </span> <b>create</b><span style="color: navy">(</span><span style="color: blue">'code'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">c</span><span style="color: navy">, </span> c.value = <span style="color: blue">'not-applicable'</span><span style="color: navy">, </span> TgtExtension.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/data-absent-reason'</span><span style="color: navy">, </span> TgtExtension.value = <span style="color: maroon">c</span><span style="color: navy">, </span> tgt.extension = <span style="color: maroon">TgtExtension</span> <i>&quot;SetExtension&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url value="https://ips.saude.gov.br/fhir/StructureMap/StructureMapBRIPS"/>
  <version value="1.0.0"/>
  <name value="StructureMapBRIPS"/>
  <title value="Mapeamento de Bundle da RNDS para o IPS"/>
  <status value="draft"/>
  <date value="2024-12-23T18:46:21+00:00"/>
  <publisher value="Ministério do Saúde do Brasil"/>
  <contact>
    <name value="Ministério do Saúde do Brasil"/>
    <telecom>
      <system value="url"/>
      <value value="https://gov.br/saude"/>
    </telecom>
    <telecom>
      <system value="email"/>
      <value value="contato@gointerop.com"/>
    </telecom>
  </contact>
  <contact>
    <name value="Italo Macedo"/>
    <telecom>
      <system value="email"/>
      <value value="italo@gointerop.com"/>
      <use value="work"/>
    </telecom>
  </contact>
  <description value="Mapeamento de Bundle da RNDS para o IPS"/>
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166"/>
      <code value="BR"/>
      <display value="Brazil"/>
    </coding>
  </jurisdiction>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
    <mode value="source"/>
    <alias value="TLeft"/>
  </structure>
  <structure>
    <url
         value="http://hl7.org/fhir/uv/ips/StructureDefinition/Bundle-uv-ips"/>
    <mode value="target"/>
    <alias value="TRight"/>
  </structure>
  <group>
    <name value="RNDSIPSBundle"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="TLeft"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="TRight"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="SetBundleMetaData"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="RNDSID"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <variable value="IPS"/>
      </target>
      <rule>
        <name value="SetMetaData"/>
        <source>
          <context value="RNDSID"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="IPSIdentifier"/>
        </target>
        <rule>
          <name value="SetDocumentTypeAndTimestampAndIdentifier"/>
          <source>
            <context value="RNDSID"/>
          </source>
          <target>
            <context value="IPS"/>
            <contextType value="variable"/>
            <element value="type"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="document"/>
            </parameter>
          </target>
          <target>
            <context value="IPS"/>
            <contextType value="variable"/>
            <element value="timestamp"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="now()"/>
            </parameter>
          </target>
          <target>
            <context value="IPSIdentifier"/>
            <contextType value="variable"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="urn:ietf:rfc:3986"/>
            </parameter>
          </target>
          <target>
            <contextType value="variable"/>
            <variable value="uuid"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="IPSIdentifier"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="SetEmptyIPSEntries"/>
      <source>
        <context value="src"/>
        <defaultValueString value="empty"/>
        <element value="entry"/>
        <variable value="RNDSEntry"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntry"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryCondition"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryAllergyIntolerance"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryMedicationStatement"/>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="IPSPatientReference"/>
        <transform value="uuid"/>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="IPSPractitionerReference"/>
        <transform value="uuid"/>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="IPSConditionNoKnownProblemsReference"/>
        <transform value="uuid"/>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="IPSMedicationStatementNoKnownMedicationsReference"/>
        <transform value="uuid"/>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="IPSAllergyIntoleranceNoKnownAllergiesReference"/>
        <transform value="uuid"/>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="IPSVitalSignsNoKnownVitalSignsReference"/>
        <transform value="uuid"/>
      </target>
      <rule>
        <name value="SetEmptyComposition"/>
        <source>
          <context value="RNDSEntry"/>
          <condition value="(RNDSEntry = 'empty')"/>
        </source>
        <target>
          <context value="IPSEntry"/>
          <contextType value="variable"/>
        </target>
        <rule>
          <name value="SetFullUrl"/>
          <source>
            <context value="RNDSEntry"/>
          </source>
          <target>
            <contextType value="variable"/>
            <variable value="uuid"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="IPSEntry"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="SetComposition"/>
          <source>
            <context value="RNDSEntry"/>
          </source>
          <target>
            <contextType value="variable"/>
            <variable value="IPSComposition"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Composition"/>
            </parameter>
          </target>
          <rule>
            <name value="SetCompositionFirstOrderFields"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="final"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="60591-5"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Patient Summary Document"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="type"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="date"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="now()"/>
              </parameter>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="id"/>
              <transform value="uuid"/>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="today"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="today()"/>
              </parameter>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="title"/>
              <transform value="append"/>
              <parameter>
                <valueString value="Patient Summary as of:"/>
              </parameter>
              <parameter>
                <valueId value="today"/>
              </parameter>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="confidentiality"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="N"/>
              </parameter>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="text"/>
              <variable value="IPSCompositionText"/>
            </target>
            <target>
              <context value="IPSCompositionText"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="generated"/>
              </parameter>
            </target>
            <target>
              <context value="IPSCompositionText"/>
              <contextType value="variable"/>
              <element value="div"/>
              <transform value="append"/>
              <parameter>
                <valueString
                             value="&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;Title: International Patient Summary from Brazil, code: http://loinc.org#60591-5, status: generated, confidentiality: N&lt;/div&gt;"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetSubjectAuthorCustodianSection"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="subject"/>
              <variable value="IPSCompositionSubject"/>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="author"/>
              <variable value="IPSCompositionAuthor"/>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="custodian"/>
              <variable value="IPSCompositionCustodian"/>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="section"/>
              <variable value="IPSCompositionSectionActiveProblems"/>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="section"/>
              <variable value="IPSCompositionMedication"/>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="section"/>
              <variable value="IPSCompositionAllergiesAndIntolerances"/>
            </target>
            <target>
              <context value="IPSComposition"/>
              <contextType value="variable"/>
              <element value="section"/>
              <variable value="IPSCompositionVitalSigns"/>
            </target>
            <rule>
              <name value="SetReferences"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <context value="IPSCompositionSubject"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="IPSPatientReference"/>
                </parameter>
              </target>
              <target>
                <context value="IPSCompositionAuthor"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="IPSPractitionerReference"/>
                </parameter>
              </target>
              <target>
                <context value="IPSCompositionCustodian"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="IPSPractitionerReference"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="SetActiveProblems"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <context value="IPSCompositionSectionActiveProblems"/>
                <contextType value="variable"/>
                <element value="title"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Active Problems"/>
                </parameter>
              </target>
              <target>
                <contextType value="variable"/>
                <variable value="cc"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="CodeableConcept"/>
                </parameter>
              </target>
              <target>
                <contextType value="variable"/>
                <variable value="c"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Coding"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="11450-4"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Problem list Reported"/>
                </parameter>
              </target>
              <target>
                <context value="cc"/>
                <contextType value="variable"/>
                <element value="coding"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="c"/>
                </parameter>
              </target>
              <target>
                <context value="IPSCompositionSectionActiveProblems"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="cc"/>
                </parameter>
              </target>
              <target>
                <context value="IPSCompositionSectionActiveProblems"/>
                <contextType value="variable"/>
                <element value="entry"/>
                <variable value="IPSCompositionSectionActiveProblemsEntry"/>
              </target>
              <target>
                <context value="IPSCompositionSectionActiveProblemsEntry"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="IPSConditionNoKnownProblemsReference"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="SetTitleMedications"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <context value="IPSCompositionMedication"/>
                <contextType value="variable"/>
                <element value="title"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Medications"/>
                </parameter>
              </target>
              <target>
                <contextType value="variable"/>
                <variable value="cc"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="CodeableConcept"/>
                </parameter>
              </target>
              <target>
                <contextType value="variable"/>
                <variable value="c"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Coding"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="10160-0"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="History of Medication use Narrative"/>
                </parameter>
              </target>
              <target>
                <context value="cc"/>
                <contextType value="variable"/>
                <element value="coding"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="c"/>
                </parameter>
              </target>
              <target>
                <context value="IPSCompositionMedication"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="cc"/>
                </parameter>
              </target>
              <target>
                <context value="IPSCompositionMedication"/>
                <contextType value="variable"/>
                <element value="entry"/>
                <variable value="IPSCompositionSectionMedicationEntry"/>
              </target>
              <target>
                <context value="IPSCompositionSectionMedicationEntry"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId
                           value="IPSMedicationStatementNoKnownMedicationsReference"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="SetAllergiesAndIntolerances"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <context value="IPSCompositionAllergiesAndIntolerances"/>
                <contextType value="variable"/>
                <element value="title"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Allergies and Intolerances"/>
                </parameter>
              </target>
              <target>
                <contextType value="variable"/>
                <variable value="cc"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="CodeableConcept"/>
                </parameter>
              </target>
              <target>
                <contextType value="variable"/>
                <variable value="c"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Coding"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="48765-2"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="Allergies and adverse reactions Document"/>
                </parameter>
              </target>
              <target>
                <context value="cc"/>
                <contextType value="variable"/>
                <element value="coding"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="c"/>
                </parameter>
              </target>
              <target>
                <context value="IPSCompositionAllergiesAndIntolerances"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="cc"/>
                </parameter>
              </target>
              <target>
                <context value="IPSCompositionAllergiesAndIntolerances"/>
                <contextType value="variable"/>
                <element value="entry"/>
                <variable
                          value="IPSCompositionSectionAllergiesAndIntolerancesEntry"/>
              </target>
              <target>
                <context
                         value="IPSCompositionSectionAllergiesAndIntolerancesEntry"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId
                           value="IPSAllergyIntoleranceNoKnownAllergiesReference"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="SetVitalSigns"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <context value="IPSCompositionVitalSigns"/>
                <contextType value="variable"/>
                <element value="title"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Vital Signs"/>
                </parameter>
              </target>
              <target>
                <contextType value="variable"/>
                <variable value="cc"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="CodeableConcept"/>
                </parameter>
              </target>
              <target>
                <contextType value="variable"/>
                <variable value="c"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Coding"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="8716-3"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Vital signs"/>
                </parameter>
              </target>
              <target>
                <context value="cc"/>
                <contextType value="variable"/>
                <element value="coding"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="c"/>
                </parameter>
              </target>
              <target>
                <context value="IPSCompositionVitalSigns"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="cc"/>
                </parameter>
              </target>
              <target>
                <context value="IPSCompositionVitalSigns"/>
                <contextType value="variable"/>
                <element value="entry"/>
                <variable value="IPSCompositionVitalSignsEntry"/>
              </target>
              <target>
                <context value="IPSCompositionVitalSignsEntry"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="IPSVitalSignsNoKnownVitalSignsReference"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="SetResourceComposition"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSEntry"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSComposition"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="SetEmptyCondition"/>
        <source>
          <context value="RNDSEntry"/>
          <condition value="(RNDSEntry = 'empty')"/>
        </source>
        <target>
          <context value="IPSEntryCondition"/>
          <contextType value="variable"/>
        </target>
        <rule>
          <name value="SetFullUrl"/>
          <source>
            <context value="RNDSEntry"/>
          </source>
          <target>
            <contextType value="variable"/>
            <variable value="uuid"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="IPSEntryCondition"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="SetCondition"/>
          <source>
            <context value="RNDSEntry"/>
          </source>
          <target>
            <contextType value="variable"/>
            <variable value="IPSCondition"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Condition"/>
            </parameter>
          </target>
          <rule>
            <name value="SetClinicalStatus"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://terminology.hl7.org/CodeSystem/condition-clinical"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSCondition"/>
              <contextType value="variable"/>
              <element value="clinicalStatus"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetCode"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="no-problem-info"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="No information about problems"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSCondition"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetCode"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://terminology.hl7.org/CodeSystem/condition-ver-status"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="confirmed"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Confirmed"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSCondition"/>
              <contextType value="variable"/>
              <element value="verificationStatus"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetSubject"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSCondition"/>
              <contextType value="variable"/>
              <element value="subject"/>
              <variable value="IPSConditionSubject"/>
            </target>
            <target>
              <context value="IPSConditionSubject"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSPatientReference"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetConditionNarrativeElement"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSEntryCondition"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <variable value="IPSEntryConditionResource"/>
            </target>
            <target>
              <context value="IPSEntryConditionResource"/>
              <contextType value="variable"/>
              <element value="text"/>
              <variable value="IPSEntryConditionResourceText"/>
            </target>
            <target>
              <context value="IPSEntryConditionResourceText"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="generated"/>
              </parameter>
            </target>
            <target>
              <context value="IPSCondition"/>
              <contextType value="variable"/>
              <element value="code"/>
              <variable value="IPSConditionCode"/>
            </target>
            <target>
              <context value="IPSConditionCode"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="IPSConditionCodeCoding"/>
            </target>
            <target>
              <context value="IPSConditionCodeCoding"/>
              <contextType value="variable"/>
              <element value="code"/>
              <variable value="IPSConditionCodeCodingCode"/>
            </target>
            <target>
              <context value="IPSCondition"/>
              <contextType value="variable"/>
              <element value="clinicalStatus"/>
              <variable value="IPSConditionClinicalStatus"/>
            </target>
            <target>
              <context value="IPSConditionClinicalStatus"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="IPSConditionClinicalStatusCoding"/>
            </target>
            <target>
              <context value="IPSConditionClinicalStatusCoding"/>
              <contextType value="variable"/>
              <element value="code"/>
              <variable value="IPSConditionClinicalStatusCodingCode"/>
            </target>
            <target>
              <context value="IPSCondition"/>
              <contextType value="variable"/>
              <element value="verificationStatus"/>
              <variable value="IPSConditionVerificationStatus"/>
            </target>
            <target>
              <context value="IPSConditionVerificationStatus"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="IPSConditionVerificationStatusCoding"/>
            </target>
            <target>
              <context value="IPSConditionVerificationStatusCoding"/>
              <contextType value="variable"/>
              <element value="code"/>
              <variable value="IPSConditionVerificationStatusCodingCode"/>
            </target>
            <target>
              <context value="IPSEntryConditionResourceText"/>
              <contextType value="variable"/>
              <element value="div"/>
              <transform value="append"/>
              <parameter>
                <valueString
                             value="&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;Condition"/>
              </parameter>
              <parameter>
                <valueId value="IPSConditionCodeCodingCode"/>
              </parameter>
              <parameter>
                <valueString value=",clinicalStatus:"/>
              </parameter>
              <parameter>
                <valueId value="IPSConditionClinicalStatusCodingCode"/>
              </parameter>
              <parameter>
                <valueString value=",verificationStatus:"/>
              </parameter>
              <parameter>
                <valueId value="IPSConditionVerificationStatusCodingCode"/>
              </parameter>
              <parameter>
                <valueString value="&lt;/div&gt;"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetCondition"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSEntryCondition"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSCondition"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="SetEmptyAllergyIntolerance"/>
        <source>
          <context value="RNDSEntry"/>
          <condition value="(RNDSEntry = 'empty')"/>
        </source>
        <target>
          <context value="IPSEntryAllergyIntolerance"/>
          <contextType value="variable"/>
        </target>
        <rule>
          <name value="SetFullUrl"/>
          <source>
            <context value="RNDSEntry"/>
          </source>
          <target>
            <contextType value="variable"/>
            <variable value="uuid"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="IPSEntryAllergyIntolerance"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="SetAllergyIntolerance"/>
          <source>
            <context value="RNDSEntry"/>
          </source>
          <target>
            <contextType value="variable"/>
            <variable value="IPSAllergyIntolerance"/>
            <transform value="create"/>
            <parameter>
              <valueString value="AllergyIntolerance"/>
            </parameter>
          </target>
          <rule>
            <name value="SetClinicalStatus"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="clinicalStatus"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetCode"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="no-allergy-info"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="No information about allergies"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetPatient"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="patient"/>
              <variable value="IPSAllergyIntolerancePatient"/>
            </target>
            <target>
              <context value="IPSAllergyIntolerancePatient"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSPatientReference"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetAllergyIntolerance"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSEntryAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSAllergyIntolerance"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetAllergyText"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="text"/>
              <variable value="IPSAllergyIntoleranceText"/>
            </target>
            <target>
              <context value="IPSAllergyIntoleranceText"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="generated"/>
              </parameter>
            </target>
            <target>
              <context value="IPSAllergyIntoleranceText"/>
              <contextType value="variable"/>
              <element value="div"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;No allergy information&lt;/div&gt;"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="SetEmptyMedicationStatement"/>
        <source>
          <context value="RNDSEntry"/>
          <condition value="(RNDSEntry = 'empty')"/>
        </source>
        <target>
          <context value="IPSEntryMedicationStatement"/>
          <contextType value="variable"/>
        </target>
        <rule>
          <name value="SetMedicationStatement"/>
          <source>
            <context value="RNDSEntry"/>
          </source>
          <target>
            <contextType value="variable"/>
            <variable value="IPSMedicationStatement"/>
            <transform value="create"/>
            <parameter>
              <valueString value="MedicationStatement"/>
            </parameter>
          </target>
          <rule>
            <name value="SetStatus"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSMedicationStatement"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="unknown"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetCode"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="no-medication-info"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="No information about medications"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSMedicationStatement"/>
              <contextType value="variable"/>
              <element value="medication"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetEffectivePeriod"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSMedicationStatement"/>
              <contextType value="variable"/>
              <element value="effectivePeriod"/>
              <variable value="IPSMedicationStatementEffectivePeriod"/>
            </target>
            <dependent>
              <name value="NotApplicable"/>
              <variable value="RNDSEntry"/>
              <variable value="IPSMedicationStatementEffectivePeriod"/>
            </dependent>
          </rule>
          <rule>
            <name value="SetSubject"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSMedicationStatement"/>
              <contextType value="variable"/>
              <element value="subject"/>
              <variable value="IPSMedicationStatementSubject"/>
            </target>
            <target>
              <context value="IPSMedicationStatementSubject"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSPatientReference"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetMedicationStatement"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <contextType value="variable"/>
              <variable value="uuid"/>
              <transform value="uuid"/>
            </target>
            <target>
              <context value="IPSEntryMedicationStatement"/>
              <contextType value="variable"/>
              <element value="fullUrl"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="uuid"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryMedicationStatement"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSMedicationStatement"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="SetIPSEntries"/>
      <source>
        <context value="src"/>
        <element value="entry"/>
        <variable value="RNDSEntry"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntry"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryCondition"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryVitalSigns"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryResults"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntrySpecimen"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryImmunization"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryProcedures"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryMedicationRequests"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryMedications"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryAllergyIntolerance"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryMedicationStatement"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryPatient"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryPractitioner"/>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="IPSEntryCustodian"/>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="IPSPatientReference"/>
        <transform value="uuid"/>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="IPSPractitionerReference"/>
        <transform value="uuid"/>
      </target>
      <rule>
        <name value="SetIPSEntryResourceComposition"/>
        <source>
          <context value="RNDSEntry"/>
          <element value="resource"/>
          <variable value="RNDSEntryResource"/>
        </source>
        <target>
          <contextType value="variable"/>
          <variable value="IPSEntryResourceComposition"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Composition"/>
          </parameter>
        </target>
        <rule>
          <name value="SetCompositionFirstOrderFields"/>
          <source>
            <context value="RNDSEntry"/>
          </source>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="status"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="final"/>
            </parameter>
          </target>
          <target>
            <contextType value="variable"/>
            <variable value="cc"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CodeableConcept"/>
            </parameter>
          </target>
          <target>
            <contextType value="variable"/>
            <variable value="c"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Coding"/>
            </parameter>
          </target>
          <target>
            <context value="c"/>
            <contextType value="variable"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://loinc.org"/>
            </parameter>
          </target>
          <target>
            <context value="c"/>
            <contextType value="variable"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="60591-5"/>
            </parameter>
          </target>
          <target>
            <context value="c"/>
            <contextType value="variable"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Patient Summary Document"/>
            </parameter>
          </target>
          <target>
            <context value="cc"/>
            <contextType value="variable"/>
            <element value="coding"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="c"/>
            </parameter>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="type"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="cc"/>
            </parameter>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="date"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="now()"/>
            </parameter>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="id"/>
            <transform value="uuid"/>
          </target>
          <target>
            <contextType value="variable"/>
            <variable value="today"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="today()"/>
            </parameter>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="title"/>
            <transform value="append"/>
            <parameter>
              <valueString value="Patient Summary as of"/>
            </parameter>
            <parameter>
              <valueId value="today"/>
            </parameter>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="confidentiality"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="N"/>
            </parameter>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="text"/>
            <variable value="IPSEntryResourceCompositionText"/>
          </target>
          <target>
            <context value="IPSEntryResourceCompositionText"/>
            <contextType value="variable"/>
            <element value="status"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="generated"/>
            </parameter>
          </target>
          <target>
            <context value="IPSEntryResourceCompositionText"/>
            <contextType value="variable"/>
            <element value="div"/>
            <transform value="append"/>
            <parameter>
              <valueString
                           value="&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;Title: International Patient Summary from Brazil, code: http://loinc.org#60591-5, status: generated, confidentiality: N&lt;/div&gt;"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="SetSubjectAuthorCustodianSection"/>
          <source>
            <context value="RNDSEntryResource"/>
          </source>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="subject"/>
            <variable value="IPSEntryResourceCompositionSubject"/>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="author"/>
            <variable value="IPSEntryResourceCompositionPractitioner"/>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="custodian"/>
            <variable value="IPSEntryResourceCompositionCustodian"/>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="section"/>
            <variable
                      value="IPSEntryResourceCompositionSectionActiveProblems"/>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="section"/>
            <variable value="IPSEntryResourceCompositionSectionMedications"/>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="section"/>
            <variable
                      value="IPSEntryResourceCompositionSectionAllergiesAndIntolerances"/>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="section"/>
            <variable value="IPSEntryResourceCompositionSectionResults"/>
          </target>
          <target>
            <context value="IPSEntryResourceComposition"/>
            <contextType value="variable"/>
            <element value="section"/>
            <variable value="IPSEntryResourceCompositionSectionVitalSigns"/>
          </target>
          <rule>
            <name value="SetResourceCompositionReferences"/>
            <source>
              <context value="RNDSEntryResource"/>
            </source>
            <target>
              <context value="IPSEntryResourceCompositionSubject"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSPatientReference"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryResourceCompositionPractitioner"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSPractitionerReference"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryResourceCompositionCustodian"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSPractitionerReference"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetActiveProblems"/>
            <source>
              <context value="RNDSEntryResource"/>
            </source>
            <target>
              <context
                       value="IPSEntryResourceCompositionSectionActiveProblems"/>
              <contextType value="variable"/>
              <element value="title"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Active Problems"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="11450-4"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Problem list Reported"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context
                       value="IPSEntryResourceCompositionSectionActiveProblems"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="CreateNoKnownConditions"/>
            <source>
              <context value="RNDSEntryResource"/>
              <condition
                         value="(RNDSEntryResource.entry.resource.entry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRCondicaoSaude').empty())"/>
            </source>
            <target>
              <contextType value="variable"/>
              <variable value="IPSEntryEmptyCondition"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Condition"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="IPSEntryEmptyConditionId"/>
              <transform value="uuid"/>
            </target>
            <target>
              <context value="IPSEntryEmptyCondition"/>
              <contextType value="variable"/>
              <element value="id"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSEntryEmptyConditionId"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://terminology.hl7.org/CodeSystem/condition-clinical"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyCondition"/>
              <contextType value="variable"/>
              <element value="clinicalStatus"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="no-problem-info"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="No information about problems"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyCondition"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyCondition"/>
              <contextType value="variable"/>
              <element value="subject"/>
              <variable value="IPSEntryEmptyConditionSubject"/>
            </target>
            <target>
              <context value="IPSEntryEmptyConditionSubject"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSPatientReference"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryCondition"/>
              <contextType value="variable"/>
              <element value="fullUrl"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSEntryEmptyConditionId"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryCondition"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSEntryEmptyCondition"/>
              </parameter>
            </target>
            <target>
              <context
                       value="IPSEntryResourceCompositionSectionActiveProblems"/>
              <contextType value="variable"/>
              <element value="entry"/>
              <variable
                        value="IPSEntryResourceCompositionSectionActiveProblemsEntry"/>
            </target>
            <target>
              <context
                       value="IPSEntryResourceCompositionSectionActiveProblemsEntry"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSEntryEmptyConditionId"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="SetAllergiesAndIntolerances"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context
                       value="IPSEntryResourceCompositionSectionAllergiesAndIntolerances"/>
              <contextType value="variable"/>
              <element value="title"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Allergies and Intolerances"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://loinc.org"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="48765-2"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="Allergies and adverse reactions Document"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context
                       value="IPSEntryResourceCompositionSectionAllergiesAndIntolerances"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="CreateNoKnownConditions"/>
            <source>
              <context value="RNDSEntryResource"/>
              <condition
                         value="(RNDSEntryResource.entry.resource.entry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRAlergiaReacaoAdversa').empty())"/>
            </source>
            <target>
              <contextType value="variable"/>
              <variable value="IPSEntryEmptyAllergyIntolerance"/>
              <transform value="create"/>
              <parameter>
                <valueString value="AllergyIntolerance"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="IPSEntryEmptyAllergyIntoleranceId"/>
              <transform value="uuid"/>
            </target>
            <target>
              <context value="IPSEntryEmptyAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="id"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSEntryEmptyAllergyIntoleranceId"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="clinicalStatus"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="no-allergy-info"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="No information about allergies"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="patient"/>
              <variable value="IPSEntryEmptyAllergyIntolerancePatient"/>
            </target>
            <target>
              <context value="IPSEntryEmptyAllergyIntolerancePatient"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSPatientReference"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="text"/>
              <variable value="IPSEntryEmptyAllergyIntoleranceText"/>
            </target>
            <target>
              <context value="IPSEntryEmptyAllergyIntoleranceText"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="generated"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyAllergyIntoleranceText"/>
              <contextType value="variable"/>
              <element value="div"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;No known allergies&lt;/div&gt;"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="fullUrl"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSEntryEmptyAllergyIntoleranceId"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryAllergyIntolerance"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSEntryEmptyAllergyIntolerance"/>
              </parameter>
            </target>
            <target>
              <context
                       value="IPSEntryResourceCompositionSectionAllergiesAndIntolerances"/>
              <contextType value="variable"/>
              <element value="entry"/>
              <variable
                        value="IPSEntryResourceCompositionSectionAllergiesAndIntolerancesEntry"/>
            </target>
            <target>
              <context
                       value="IPSEntryResourceCompositionSectionAllergiesAndIntolerancesEntry"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSEntryEmptyAllergyIntoleranceId"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="CreateNoKnownMedications"/>
            <source>
              <context value="RNDSEntryResource"/>
              <condition
                         value="(RNDSEntryResource.entry.resource.entry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRMedicamento').empty())"/>
            </source>
            <target>
              <contextType value="variable"/>
              <variable value="IPSEntryEmptyMedicationStatement"/>
              <transform value="create"/>
              <parameter>
                <valueString value="MedicationStatement"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="IPSEntryEmptyMedicationStatementId"/>
              <transform value="uuid"/>
            </target>
            <target>
              <context value="IPSEntryEmptyMedicationStatement"/>
              <contextType value="variable"/>
              <element value="id"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSEntryEmptyMedicationStatementId"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="c"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="no-medication-info"/>
              </parameter>
            </target>
            <target>
              <context value="c"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="No information about medications"/>
              </parameter>
            </target>
            <target>
              <contextType value="variable"/>
              <variable value="cc"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <target>
              <context value="cc"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="c"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyMedicationStatement"/>
              <contextType value="variable"/>
              <element value="medication"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="cc"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyMedicationStatement"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="unknown"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryEmptyMedicationStatement"/>
              <contextType value="variable"/>
              <element value="subject"/>
              <variable value="IPSEntryEmptyMedicationStatementSubject"/>
            </target>
            <target>
              <context value="IPSEntryEmptyMedicationStatementSubject"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSPatientReference"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryMedicationStatement"/>
              <contextType value="variable"/>
              <element value="fullUrl"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSEntryEmptyMedicationStatementId"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryMedicationStatement"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSEntryEmptyMedicationStatement"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntryResourceCompositionSectionMedications"/>
              <contextType value="variable"/>
              <element value="entry"/>
              <variable
                        value="IPSEntryResourceCompositionSectionMedicationEntry"/>
            </target>
            <target>
              <context
                       value="IPSEntryResourceCompositionSectionMedicationEntry"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSEntryEmptyMedicationStatementId"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="IterateRNDSEntry"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="entry"/>
            </target>
            <rule>
              <name value="IterateRNDSEntryResource"/>
              <source>
                <context value="RNDSEntry"/>
                <element value="resource"/>
                <variable value="RNDSEntryResource"/>
              </source>
              <target>
                <context value="tgt"/>
                <contextType value="variable"/>
                <element value="entry"/>
              </target>
              <rule>
                <name value="IterateRNDSEntryResourceEntry"/>
                <source>
                  <context value="RNDSEntryResource"/>
                  <element value="entry"/>
                  <variable value="RNDSEntryResourceEntry"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                </target>
                <rule>
                  <name value="IterateRNDSEntryResourceEntryResource"/>
                  <source>
                    <context value="RNDSEntryResourceEntry"/>
                    <element value="resource"/>
                    <variable value="RNDSEntryResourceEntryResource"/>
                  </source>
                  <target>
                    <context value="tgt"/>
                    <contextType value="variable"/>
                    <element value="entry"/>
                  </target>
                  <rule>
                    <name value="IterateRNDSEntryResourceEntryResourceEntry"/>
                    <source>
                      <context value="RNDSEntryResourceEntryResource"/>
                      <element value="entry"/>
                      <variable value="RNDSEntryResourceEntryResourceEntry"/>
                    </source>
                    <rule>
                      <name value="SetResource"/>
                      <source>
                        <context value="RNDSEntryResourceEntryResourceEntry"/>
                        <element value="resource"/>
                        <variable
                                  value="RNDSEntryResourceEntryResourceEntryResource"/>
                        <condition
                                   value="(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRCondicaoSaude').empty().not())"/>
                      </source>
                      <target>
                        <context value="tgt"/>
                        <contextType value="variable"/>
                        <element value="entry"/>
                      </target>
                      <rule>
                        <name value="AddEntry"/>
                        <source>
                          <context
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                          <element value="id"/>
                          <variable
                                    value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                        </source>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionActiveProblems"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable
                                    value="IPSEntryResourceCompositionSectionActiveProblemsEntry"/>
                        </target>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionActiveProblemsEntry"/>
                          <contextType value="variable"/>
                          <element value="reference"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="tgt"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable value="AddEntry"/>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="fullUrl"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="resource"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResource"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="IterateRNDSEntry"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="entry"/>
            </target>
            <rule>
              <name value="IterateRNDSEntryResource"/>
              <source>
                <context value="RNDSEntry"/>
                <element value="resource"/>
                <variable value="RNDSEntryResource"/>
              </source>
              <target>
                <context value="tgt"/>
                <contextType value="variable"/>
                <element value="entry"/>
              </target>
              <rule>
                <name value="IterateRNDSEntryResourceEntry"/>
                <source>
                  <context value="RNDSEntryResource"/>
                  <element value="entry"/>
                  <variable value="RNDSEntryResourceEntry"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                </target>
                <rule>
                  <name value="IterateRNDSEntryResourceEntryResource"/>
                  <source>
                    <context value="RNDSEntryResourceEntry"/>
                    <element value="resource"/>
                    <variable value="RNDSEntryResourceEntryResource"/>
                  </source>
                  <target>
                    <context value="tgt"/>
                    <contextType value="variable"/>
                    <element value="entry"/>
                  </target>
                  <rule>
                    <name value="IterateRNDSEntryResourceEntryResourceEntry"/>
                    <source>
                      <context value="RNDSEntryResourceEntryResource"/>
                      <element value="entry"/>
                      <variable value="RNDSEntryResourceEntryResourceEntry"/>
                    </source>
                    <rule>
                      <name value="SetResource"/>
                      <source>
                        <context value="RNDSEntryResourceEntryResourceEntry"/>
                        <element value="resource"/>
                        <variable
                                  value="RNDSEntryResourceEntryResourceEntryResource"/>
                        <condition
                                   value="(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRAlergiaReacaoAdversa').empty().not())"/>
                      </source>
                      <target>
                        <context value="tgt"/>
                        <contextType value="variable"/>
                        <element value="entry"/>
                      </target>
                      <rule>
                        <name value="AddEntry"/>
                        <source>
                          <context
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                          <element value="id"/>
                          <variable
                                    value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                        </source>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionAllergiesAndIntolerances"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable
                                    value="IPSEntryResourceCompositionSectionAllergiesAndIntolerancesEntry"/>
                        </target>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionAllergiesAndIntolerancesEntry"/>
                          <contextType value="variable"/>
                          <element value="reference"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="tgt"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable value="AddEntry"/>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="fullUrl"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="resource"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResource"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="CreateSectionResultsIfExist"/>
            <source>
              <context value="RNDSEntryResource"/>
              <condition
                         value="(RNDSEntryResource.entry.resource.entry.resource.meta.where((profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRDiagnosticoCOVID19-TesteRapido') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRDiagnosticoLaboratorioClinico') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRObservacaoDescritiva')).empty().not())"/>
            </source>
            <target>
              <context value="IPSEntryResourceComposition"/>
              <contextType value="variable"/>
            </target>
            <rule>
              <name value="CreateSectionResults"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <context value="IPSEntryResourceCompositionSectionResults"/>
                <contextType value="variable"/>
              </target>
              <rule>
                <name value="SetCompositionSectionResults"/>
                <source>
                  <context value="RNDSEntryResource"/>
                </source>
                <target>
                  <context value="IPSEntryResourceCompositionSectionResults"/>
                  <contextType value="variable"/>
                </target>
                <rule>
                  <name value="SetResultsNarrative"/>
                  <source>
                    <context value="RNDSEntryResource"/>
                  </source>
                  <target>
                    <context
                             value="IPSEntryResourceCompositionSectionResults"/>
                    <contextType value="variable"/>
                    <element value="title"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Results"/>
                    </parameter>
                  </target>
                  <target>
                    <contextType value="variable"/>
                    <variable value="cc"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="CodeableConcept"/>
                    </parameter>
                  </target>
                  <target>
                    <contextType value="variable"/>
                    <variable value="c"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="30954-2"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="Relevant diagnostic tests/laboratory data Narrative"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="cc"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="c"/>
                    </parameter>
                  </target>
                  <target>
                    <context
                             value="IPSEntryResourceCompositionSectionResults"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="cc"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="IterateRNDSEntry"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="entry"/>
            </target>
            <rule>
              <name value="IterateRNDSEntryResource"/>
              <source>
                <context value="RNDSEntry"/>
                <element value="resource"/>
                <variable value="RNDSEntryResource"/>
              </source>
              <target>
                <context value="tgt"/>
                <contextType value="variable"/>
                <element value="entry"/>
              </target>
              <rule>
                <name value="IterateRNDSEntryResourceEntry"/>
                <source>
                  <context value="RNDSEntryResource"/>
                  <element value="entry"/>
                  <variable value="RNDSEntryResourceEntry"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                </target>
                <rule>
                  <name value="IterateRNDSEntryResourceEntryResource"/>
                  <source>
                    <context value="RNDSEntryResourceEntry"/>
                    <element value="resource"/>
                    <variable value="RNDSEntryResourceEntryResource"/>
                  </source>
                  <target>
                    <context value="tgt"/>
                    <contextType value="variable"/>
                    <element value="entry"/>
                  </target>
                  <rule>
                    <name value="IterateRNDSEntryResourceEntryResourceEntry"/>
                    <source>
                      <context value="RNDSEntryResourceEntryResource"/>
                      <element value="entry"/>
                      <variable value="RNDSEntryResourceEntryResourceEntry"/>
                    </source>
                    <rule>
                      <name value="SetResource"/>
                      <source>
                        <context value="RNDSEntryResourceEntryResourceEntry"/>
                        <element value="resource"/>
                        <variable
                                  value="RNDSEntryResourceEntryResourceEntryResource"/>
                        <condition
                                   value="(RNDSEntryResourceEntryResourceEntry.resource.meta.where((profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRDiagnosticoCOVID19-TesteRapido') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRDiagnosticoLaboratorioClinico') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRObservacaoDescritiva')).empty().not())"/>
                      </source>
                      <target>
                        <context value="tgt"/>
                        <contextType value="variable"/>
                        <element value="entry"/>
                      </target>
                      <rule>
                        <name value="AddEntry"/>
                        <source>
                          <context
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                          <element value="id"/>
                          <variable
                                    value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                        </source>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionResults"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable
                                    value="IPSEntryResourceCompositionSectionResultsEntry"/>
                        </target>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionResultsEntry"/>
                          <contextType value="variable"/>
                          <element value="reference"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="tgt"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable value="AddEntry"/>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="fullUrl"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="resource"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResource"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="IterateRNDSEntry"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="entry"/>
            </target>
            <rule>
              <name value="IterateRNDSEntryResource"/>
              <source>
                <context value="RNDSEntry"/>
                <element value="resource"/>
                <variable value="RNDSEntryResource"/>
              </source>
              <target>
                <context value="tgt"/>
                <contextType value="variable"/>
                <element value="entry"/>
              </target>
              <rule>
                <name value="IterateRNDSEntryResourceEntry"/>
                <source>
                  <context value="RNDSEntryResource"/>
                  <element value="entry"/>
                  <variable value="RNDSEntryResourceEntry"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                </target>
                <rule>
                  <name value="IterateRNDSEntryResourceEntryResource"/>
                  <source>
                    <context value="RNDSEntryResourceEntry"/>
                    <element value="resource"/>
                    <variable value="RNDSEntryResourceEntryResource"/>
                  </source>
                  <target>
                    <context value="tgt"/>
                    <contextType value="variable"/>
                    <element value="entry"/>
                  </target>
                  <rule>
                    <name value="IterateRNDSEntryResourceEntryResourceEntry"/>
                    <source>
                      <context value="RNDSEntryResourceEntryResource"/>
                      <element value="entry"/>
                      <variable value="RNDSEntryResourceEntryResourceEntry"/>
                    </source>
                    <rule>
                      <name value="SetResource"/>
                      <source>
                        <context value="RNDSEntryResourceEntryResourceEntry"/>
                        <element value="resource"/>
                        <variable
                                  value="RNDSEntryResourceEntryResourceEntryResource"/>
                        <condition
                                   value="(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRAmostraBiologica').empty().not())"/>
                      </source>
                      <target>
                        <context value="tgt"/>
                        <contextType value="variable"/>
                        <element value="entry"/>
                      </target>
                      <rule>
                        <name value="AddEntry"/>
                        <source>
                          <context
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                          <element value="id"/>
                          <variable
                                    value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                        </source>
                        <target>
                          <context value="tgt"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable value="AddEntry"/>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="fullUrl"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="resource"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResource"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="CreateSectionResultsIfExist"/>
            <source>
              <context value="RNDSEntryResource"/>
              <condition
                         value="(RNDSEntryResource.entry.resource.entry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRMedidaObservada').empty().not())"/>
            </source>
            <target>
              <context value="IPSEntryResourceComposition"/>
              <contextType value="variable"/>
            </target>
            <rule>
              <name value="CreateSectionResults"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <context
                         value="IPSEntryResourceCompositionSectionVitalSigns"/>
                <contextType value="variable"/>
              </target>
              <rule>
                <name value="SetCompositionSectionResults"/>
                <source>
                  <context value="RNDSEntryResource"/>
                </source>
                <target>
                  <context
                           value="IPSEntryResourceCompositionSectionVitalSigns"/>
                  <contextType value="variable"/>
                </target>
                <rule>
                  <name value="SetResultsNarrative"/>
                  <source>
                    <context value="RNDSEntryResource"/>
                  </source>
                  <target>
                    <context
                             value="IPSEntryResourceCompositionSectionVitalSigns"/>
                    <contextType value="variable"/>
                    <element value="title"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Vital Signs"/>
                    </parameter>
                  </target>
                  <target>
                    <contextType value="variable"/>
                    <variable value="cc"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="CodeableConcept"/>
                    </parameter>
                  </target>
                  <target>
                    <contextType value="variable"/>
                    <variable value="c"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="8716-3"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Vital signs"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="cc"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="c"/>
                    </parameter>
                  </target>
                  <target>
                    <context
                             value="IPSEntryResourceCompositionSectionVitalSigns"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="cc"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="IterateRNDSEntry"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="entry"/>
            </target>
            <rule>
              <name value="IterateRNDSEntryResource"/>
              <source>
                <context value="RNDSEntry"/>
                <element value="resource"/>
                <variable value="RNDSEntryResource"/>
              </source>
              <target>
                <context value="tgt"/>
                <contextType value="variable"/>
                <element value="entry"/>
              </target>
              <rule>
                <name value="IterateRNDSEntryResourceEntry"/>
                <source>
                  <context value="RNDSEntryResource"/>
                  <element value="entry"/>
                  <variable value="RNDSEntryResourceEntry"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                </target>
                <rule>
                  <name value="IterateRNDSEntryResourceEntryResource"/>
                  <source>
                    <context value="RNDSEntryResourceEntry"/>
                    <element value="resource"/>
                    <variable value="RNDSEntryResourceEntryResource"/>
                  </source>
                  <target>
                    <context value="tgt"/>
                    <contextType value="variable"/>
                    <element value="entry"/>
                  </target>
                  <rule>
                    <name value="IterateRNDSEntryResourceEntryResourceEntry"/>
                    <source>
                      <context value="RNDSEntryResourceEntryResource"/>
                      <element value="entry"/>
                      <variable value="RNDSEntryResourceEntryResourceEntry"/>
                    </source>
                    <rule>
                      <name value="SetResource"/>
                      <source>
                        <context value="RNDSEntryResourceEntryResourceEntry"/>
                        <element value="resource"/>
                        <variable
                                  value="RNDSEntryResourceEntryResourceEntryResource"/>
                        <condition
                                   value="(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRMedidaObservada').empty().not())"/>
                      </source>
                      <target>
                        <context value="tgt"/>
                        <contextType value="variable"/>
                        <element value="entry"/>
                      </target>
                      <rule>
                        <name value="AddEntry"/>
                        <source>
                          <context
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                          <element value="id"/>
                          <variable
                                    value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                        </source>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionVitalSigns"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable
                                    value="IPSEntryResourceCompositionSectionVitalSignsEntry"/>
                        </target>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionVitalSignsEntry"/>
                          <contextType value="variable"/>
                          <element value="reference"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="tgt"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable value="AddEntry"/>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="fullUrl"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="resource"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResource"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="CreateSectionImmunizationsIfExists"/>
            <source>
              <context value="RNDSEntryResource"/>
              <condition
                         value="(RNDSEntryResource.entry.resource.entry.resource.meta.where((profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministrado') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministradoCarga') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministradoCampanha')).empty().not())"/>
            </source>
            <target>
              <context value="IPSEntryResourceComposition"/>
              <contextType value="variable"/>
            </target>
            <rule>
              <name value="CreateSectionImmunizations"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <context value="IPSEntryResourceComposition"/>
                <contextType value="variable"/>
                <element value="section"/>
                <variable
                          value="IPSEntryResourceCompositionSectionImmunizations"/>
              </target>
              <rule>
                <name value="SetCompositionSectionImmunizations"/>
                <source>
                  <context value="RNDSEntryResource"/>
                </source>
                <target>
                  <context
                           value="IPSEntryResourceCompositionSectionImmunizations"/>
                  <contextType value="variable"/>
                </target>
                <rule>
                  <name value="SetImmunizationsNarrative"/>
                  <source>
                    <context value="RNDSEntryResource"/>
                  </source>
                  <target>
                    <context
                             value="IPSEntryResourceCompositionSectionImmunizations"/>
                    <contextType value="variable"/>
                    <element value="title"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="Immunizations"/>
                    </parameter>
                  </target>
                  <target>
                    <contextType value="variable"/>
                    <variable value="c"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="11369-6"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="History of Immunization Narrative"/>
                    </parameter>
                  </target>
                  <target>
                    <contextType value="variable"/>
                    <variable value="cc"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="CodeableConcept"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="cc"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="c"/>
                    </parameter>
                  </target>
                  <target>
                    <context
                             value="IPSEntryResourceCompositionSectionImmunizations"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="cc"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="IterateRNDSEntryResourceEntry"/>
                <source>
                  <context value="RNDSEntryResource"/>
                  <element value="entry"/>
                  <variable value="RNDSEntryResourceEntry"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                </target>
                <rule>
                  <name value="IterateRNDSEntryResourceEntryResource"/>
                  <source>
                    <context value="RNDSEntryResourceEntry"/>
                    <element value="resource"/>
                    <variable value="RNDSEntryResourceEntryResource"/>
                  </source>
                  <target>
                    <context value="tgt"/>
                    <contextType value="variable"/>
                    <element value="entry"/>
                  </target>
                  <rule>
                    <name value="IterateRNDSEntryResourceEntryResourceEntry"/>
                    <source>
                      <context value="RNDSEntryResourceEntryResource"/>
                      <element value="entry"/>
                      <variable value="RNDSEntryResourceEntryResourceEntry"/>
                    </source>
                    <rule>
                      <name value="SetResource"/>
                      <source>
                        <context value="RNDSEntryResourceEntryResourceEntry"/>
                        <element value="resource"/>
                        <variable
                                  value="RNDSEntryResourceEntryResourceEntryResource"/>
                        <condition
                                   value="(RNDSEntryResourceEntryResourceEntry.resource.meta.where((profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministrado') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministradoCarga') or (profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRImunobiologicoAdministradoCampanha')).empty().not())"/>
                      </source>
                      <target>
                        <context value="tgt"/>
                        <contextType value="variable"/>
                        <element value="entry"/>
                      </target>
                      <rule>
                        <name value="AddEntry"/>
                        <source>
                          <context
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                          <element value="id"/>
                          <variable
                                    value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                        </source>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionImmunizations"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable
                                    value="IPSEntryResourceCompositionSectionImmunizationsEntry"/>
                        </target>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionImmunizationsEntry"/>
                          <contextType value="variable"/>
                          <element value="reference"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="tgt"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable value="AddEntry"/>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="fullUrl"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="resource"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResource"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="CreateSectionProceduresIfExists"/>
            <source>
              <context value="RNDSEntryResource"/>
              <condition
                         value="(RNDSEntryResource.entry.resource.entry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRProcedimentoRealizado').empty().not())"/>
            </source>
            <target>
              <context value="IPSEntryResourceComposition"/>
              <contextType value="variable"/>
            </target>
            <rule>
              <name value="CreateSectionProcedures"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <context value="IPSEntryResourceComposition"/>
                <contextType value="variable"/>
                <element value="section"/>
                <variable
                          value="IPSEntryResourceCompositionSectionProcedures"/>
              </target>
              <rule>
                <name value="SetCompositionSectionProcedures"/>
                <source>
                  <context value="RNDSEntryResource"/>
                </source>
                <target>
                  <context
                           value="IPSEntryResourceCompositionSectionProcedures"/>
                  <contextType value="variable"/>
                </target>
                <rule>
                  <name value="SetProceduresNarrative"/>
                  <source>
                    <context value="RNDSEntryResource"/>
                  </source>
                  <target>
                    <context
                             value="IPSEntryResourceCompositionSectionProcedures"/>
                    <contextType value="variable"/>
                    <element value="title"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="History of procedures"/>
                    </parameter>
                  </target>
                  <target>
                    <contextType value="variable"/>
                    <variable value="cc"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="CodeableConcept"/>
                    </parameter>
                  </target>
                  <target>
                    <contextType value="variable"/>
                    <variable value="c"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://loinc.org"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="47519-4"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="c"/>
                    <contextType value="variable"/>
                    <element value="display"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="History of Procedures Narrative"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="cc"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="c"/>
                    </parameter>
                  </target>
                  <target>
                    <context
                             value="IPSEntryResourceCompositionSectionProcedures"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="cc"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="IterateRNDSEntryResourceEntry"/>
                <source>
                  <context value="RNDSEntryResource"/>
                  <element value="entry"/>
                  <variable value="RNDSEntryResourceEntry"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                </target>
                <rule>
                  <name value="IterateRNDSEntryResourceEntryResource"/>
                  <source>
                    <context value="RNDSEntryResourceEntry"/>
                    <element value="resource"/>
                    <variable value="RNDSEntryResourceEntryResource"/>
                  </source>
                  <target>
                    <context value="tgt"/>
                    <contextType value="variable"/>
                    <element value="entry"/>
                  </target>
                  <rule>
                    <name value="IterateRNDSEntryResourceEntryResourceEntry"/>
                    <source>
                      <context value="RNDSEntryResourceEntryResource"/>
                      <element value="entry"/>
                      <variable value="RNDSEntryResourceEntryResourceEntry"/>
                    </source>
                    <rule>
                      <name value="SetResource"/>
                      <source>
                        <context value="RNDSEntryResourceEntryResourceEntry"/>
                        <element value="resource"/>
                        <variable
                                  value="RNDSEntryResourceEntryResourceEntryResource"/>
                        <condition
                                   value="(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRProcedimentoRealizado').empty().not())"/>
                      </source>
                      <target>
                        <context value="tgt"/>
                        <contextType value="variable"/>
                        <element value="entry"/>
                      </target>
                      <rule>
                        <name value="AddEntry"/>
                        <source>
                          <context
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                          <element value="id"/>
                          <variable
                                    value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                        </source>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionProcedures"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable
                                    value="IPSEntryResourceCompositionSectionProceduresEntry"/>
                        </target>
                        <target>
                          <context
                                   value="IPSEntryResourceCompositionSectionProceduresEntry"/>
                          <contextType value="variable"/>
                          <element value="reference"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="tgt"/>
                          <contextType value="variable"/>
                          <element value="entry"/>
                          <variable value="AddEntry"/>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="fullUrl"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="AddEntry"/>
                          <contextType value="variable"/>
                          <element value="resource"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResource"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="SetCompositionSectionMedications"/>
            <source>
              <context value="RNDSEntryResource"/>
            </source>
            <target>
              <context value="IPSEntryResourceCompositionSectionMedications"/>
              <contextType value="variable"/>
            </target>
            <rule>
              <name value="SetMedicationsNarrative"/>
              <source>
                <context value="RNDSEntryResource"/>
              </source>
              <target>
                <context
                         value="IPSEntryResourceCompositionSectionMedications"/>
                <contextType value="variable"/>
                <element value="title"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Medication"/>
                </parameter>
              </target>
              <target>
                <contextType value="variable"/>
                <variable value="c"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Coding"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://loinc.org"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="10160-0"/>
                </parameter>
              </target>
              <target>
                <context value="c"/>
                <contextType value="variable"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="History of Medication use Narrative"/>
                </parameter>
              </target>
              <target>
                <contextType value="variable"/>
                <variable value="cc"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="CodeableConcept"/>
                </parameter>
              </target>
              <target>
                <context value="cc"/>
                <contextType value="variable"/>
                <element value="coding"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="c"/>
                </parameter>
              </target>
              <target>
                <context
                         value="IPSEntryResourceCompositionSectionMedications"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="cc"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="IterateRNDSEntryResourceEntry"/>
              <source>
                <context value="RNDSEntryResource"/>
                <element value="entry"/>
                <variable value="RNDSEntryResourceEntry"/>
              </source>
              <target>
                <context value="IPSEntryMedicationRequests"/>
                <contextType value="variable"/>
              </target>
              <rule>
                <name value="IterateRNDSEntryResourceEntryResource"/>
                <source>
                  <context value="RNDSEntryResourceEntry"/>
                  <element value="resource"/>
                  <variable value="RNDSEntryResourceEntryResource"/>
                </source>
                <target>
                  <context value="IPSEntryMedicationRequests"/>
                  <contextType value="variable"/>
                </target>
                <rule>
                  <name value="IterateRNDSEntryResourceEntryResourceEntry"/>
                  <source>
                    <context value="RNDSEntryResourceEntryResource"/>
                    <element value="entry"/>
                    <variable value="RNDSEntryResourceEntryResourceEntry"/>
                  </source>
                  <rule>
                    <name value="SetResource"/>
                    <source>
                      <context value="RNDSEntryResourceEntryResourceEntry"/>
                      <element value="resource"/>
                      <variable
                                value="RNDSEntryResourceEntryResourceEntryResource"/>
                      <condition
                                 value="(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRPrescricaoMedicamento').empty().not())"/>
                    </source>
                    <target>
                      <context value="IPSEntryMedicationRequests"/>
                      <contextType value="variable"/>
                      <element value="resource"/>
                      <variable value="IPSEntryMedicationRequestsResource"/>
                    </target>
                    <rule>
                      <name value="AddEntry"/>
                      <source>
                        <context
                                 value="RNDSEntryResourceEntryResourceEntryResource"/>
                        <element value="id"/>
                        <variable
                                  value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                      </source>
                      <target>
                        <context
                                 value="IPSEntryResourceCompositionSectionMedications"/>
                        <contextType value="variable"/>
                        <element value="entry"/>
                        <variable
                                  value="IPSEntryResourceCompositionSectionMedicationsEntry"/>
                      </target>
                      <target>
                        <context
                                 value="IPSEntryResourceCompositionSectionMedicationsEntry"/>
                        <contextType value="variable"/>
                        <element value="reference"/>
                        <transform value="append"/>
                        <parameter>
                          <valueString value="urn:uuid:"/>
                        </parameter>
                        <parameter>
                          <valueId
                                   value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                        </parameter>
                      </target>
                      <target>
                        <context value="tgt"/>
                        <contextType value="variable"/>
                        <element value="entry"/>
                        <variable value="AddEntry"/>
                      </target>
                      <target>
                        <context value="AddEntry"/>
                        <contextType value="variable"/>
                        <element value="fullUrl"/>
                        <transform value="append"/>
                        <parameter>
                          <valueString value="urn:uuid:"/>
                        </parameter>
                        <parameter>
                          <valueId
                                   value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                        </parameter>
                      </target>
                      <target>
                        <context value="AddEntry"/>
                        <contextType value="variable"/>
                        <element value="resource"/>
                        <transform value="copy"/>
                        <parameter>
                          <valueId
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="IterateRNDSEntryResourceEntry"/>
              <source>
                <context value="RNDSEntryResource"/>
                <element value="entry"/>
                <variable value="RNDSEntryResourceEntry"/>
              </source>
              <target>
                <context value="IPSEntryMedications"/>
                <contextType value="variable"/>
              </target>
              <rule>
                <name value="IterateRNDSEntryResourceEntryResource"/>
                <source>
                  <context value="RNDSEntryResourceEntry"/>
                  <element value="resource"/>
                  <variable value="RNDSEntryResourceEntryResource"/>
                </source>
                <target>
                  <context value="IPSEntryMedications"/>
                  <contextType value="variable"/>
                </target>
                <rule>
                  <name value="IterateRNDSEntryResourceEntryResourceEntry"/>
                  <source>
                    <context value="RNDSEntryResourceEntryResource"/>
                    <element value="entry"/>
                    <variable value="RNDSEntryResourceEntryResourceEntry"/>
                  </source>
                  <rule>
                    <name value="SetResource"/>
                    <source>
                      <context value="RNDSEntryResourceEntryResourceEntry"/>
                      <element value="resource"/>
                      <variable
                                value="RNDSEntryResourceEntryResourceEntryResource"/>
                      <condition
                                 value="(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRMedicamento').empty().not())"/>
                    </source>
                    <target>
                      <context value="IPSEntryMedications"/>
                      <contextType value="variable"/>
                      <element value="resource"/>
                      <variable value="IPSEntryMedicationsResource"/>
                    </target>
                    <rule>
                      <name value="AddEntry"/>
                      <source>
                        <context
                                 value="RNDSEntryResourceEntryResourceEntryResource"/>
                        <element value="id"/>
                        <variable
                                  value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                      </source>
                      <target>
                        <context value="tgt"/>
                        <contextType value="variable"/>
                        <element value="entry"/>
                        <variable value="AddEntry"/>
                      </target>
                      <target>
                        <context value="AddEntry"/>
                        <contextType value="variable"/>
                        <element value="fullUrl"/>
                        <transform value="append"/>
                        <parameter>
                          <valueString value="urn:uuid:"/>
                        </parameter>
                        <parameter>
                          <valueId
                                   value="RNDSEntryResourceEntryResourceEntryResourceId"/>
                        </parameter>
                      </target>
                      <target>
                        <context value="AddEntry"/>
                        <contextType value="variable"/>
                        <element value="resource"/>
                        <transform value="copy"/>
                        <parameter>
                          <valueId
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="IterateRNDSEntry"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSEntryPatient"/>
              <contextType value="variable"/>
            </target>
            <rule>
              <name value="IterateRNDSEntryResource"/>
              <source>
                <context value="RNDSEntry"/>
                <element value="resource"/>
                <variable value="RNDSEntryResource"/>
              </source>
              <target>
                <context value="IPSEntryPatient"/>
                <contextType value="variable"/>
              </target>
              <rule>
                <name value="IterateRNDSEntryResourceEntry"/>
                <source>
                  <context value="RNDSEntryResource"/>
                  <element value="entry"/>
                  <variable value="RNDSEntryResourceEntry"/>
                </source>
                <target>
                  <context value="IPSEntryPatient"/>
                  <contextType value="variable"/>
                </target>
                <rule>
                  <name value="IterateRNDSEntryResourceEntryResource"/>
                  <source>
                    <context value="RNDSEntryResourceEntry"/>
                    <element value="resource"/>
                    <variable value="RNDSEntryResourceEntryResource"/>
                  </source>
                  <target>
                    <context value="IPSEntryPatient"/>
                    <contextType value="variable"/>
                  </target>
                  <rule>
                    <name value="IterateRNDSEntryResourceEntryResourceEntry"/>
                    <source>
                      <context value="RNDSEntryResourceEntryResource"/>
                      <element value="entry"/>
                      <variable value="RNDSEntryResourceEntryResourceEntry"/>
                    </source>
                    <rule>
                      <name value="SetPatient"/>
                      <source>
                        <context value="RNDSEntryResourceEntryResourceEntry"/>
                        <element value="resource"/>
                        <variable
                                  value="RNDSEntryResourceEntryResourceEntryResource"/>
                        <condition
                                   value="(RNDSEntryResourceEntryResourceEntry.resource.meta.where(profile = 'http://www.saude.gov.br/fhir/r4/StructureDefinition/BRIndividuo').empty().not())"/>
                      </source>
                      <target>
                        <context value="IPSEntryPatient"/>
                        <contextType value="variable"/>
                        <element value="resource"/>
                        <variable value="IPSEntryPatientResource"/>
                      </target>
                      <rule>
                        <name value="SetPatientFullUrl"/>
                        <source>
                          <context
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                        </source>
                        <target>
                          <context value="IPSEntryPatient"/>
                          <contextType value="variable"/>
                          <element value="fullUrl"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId value="IPSPatientReference"/>
                          </parameter>
                        </target>
                      </rule>
                      <rule>
                        <name value="SetPatientResource"/>
                        <source>
                          <context
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                        </source>
                        <target>
                          <context value="IPSEntryPatient"/>
                          <contextType value="variable"/>
                          <element value="resource"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueId
                                     value="RNDSEntryResourceEntryResourceEntryResource"/>
                          </parameter>
                        </target>
                      </rule>
                      <rule>
                        <name value="SetPatientId"/>
                        <source>
                          <context
                                   value="RNDSEntryResourceEntryResourceEntryResource"/>
                        </source>
                        <target>
                          <context value="IPSEntryPatientResource"/>
                          <contextType value="variable"/>
                          <element value="id"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueId value="IPSPatientReference"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="SetEmptyAuthor"/>
            <source>
              <context value="RNDSEntry"/>
            </source>
            <target>
              <context value="IPSEntryPractitioner"/>
              <contextType value="variable"/>
            </target>
            <rule>
              <name value="SetFullUrl"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <context value="IPSEntryPractitioner"/>
                <contextType value="variable"/>
                <element value="fullUrl"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="IPSPractitionerReference"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="SetAuthor"/>
              <source>
                <context value="RNDSEntry"/>
              </source>
              <target>
                <contextType value="variable"/>
                <variable value="IPSOrganization"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Organization"/>
                </parameter>
              </target>
              <rule>
                <name value="SetId"/>
                <source>
                  <context value="RNDSEntry"/>
                </source>
                <target>
                  <context value="IPSOrganization"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="IPSPractitionerReference"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="SetIdentifier"/>
                <source>
                  <context value="RNDSEntry"/>
                </source>
                <target>
                  <contextType value="variable"/>
                  <variable value="IPSPractitionerIdentifier"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Identifier"/>
                  </parameter>
                </target>
                <target>
                  <context value="IPSPractitionerIdentifier"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="http://www.saude.gov.br/fhir/r4/NamingSystem/cnpj"/>
                  </parameter>
                </target>
                <target>
                  <context value="IPSPractitionerIdentifier"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="00394544000185"/>
                  </parameter>
                </target>
                <target>
                  <context value="IPSOrganization"/>
                  <contextType value="variable"/>
                  <element value="identifier"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="IPSPractitionerIdentifier"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="SetName"/>
                <source>
                  <context value="RNDSEntry"/>
                </source>
                <target>
                  <context value="IPSOrganization"/>
                  <contextType value="variable"/>
                  <element value="name"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Ministério da Saúde do Brasil"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="SetAuthor"/>
                <source>
                  <context value="RNDSEntry"/>
                </source>
                <target>
                  <context value="IPSEntryPractitioner"/>
                  <contextType value="variable"/>
                  <element value="fullUrl"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="urn:uuid:"/>
                  </parameter>
                  <parameter>
                    <valueId value="IPSPractitionerReference"/>
                  </parameter>
                </target>
                <target>
                  <context value="IPSEntryPractitioner"/>
                  <contextType value="variable"/>
                  <element value="resource"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="IPSOrganization"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="SetResourceComposition"/>
            <source>
              <context value="RNDSEntryResource"/>
              <element value="id"/>
              <variable value="RNDSEntryResourceId"/>
            </source>
            <target>
              <context value="IPSEntryResourceComposition"/>
              <contextType value="variable"/>
              <element value="id"/>
              <variable value="IPSEntryResourceCompositionId"/>
            </target>
            <target>
              <context value="IPSEntry"/>
              <contextType value="variable"/>
              <element value="fullUrl"/>
              <transform value="append"/>
              <parameter>
                <valueString value="urn:uuid:"/>
              </parameter>
              <parameter>
                <valueId value="IPSEntryResourceCompositionId"/>
              </parameter>
            </target>
            <target>
              <context value="IPSEntry"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="IPSEntryResourceComposition"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="DataAbsentReason"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="Element"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Element"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="SetExtension"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="TgtExtension"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Extension"/>
        </parameter>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="c"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <target>
        <context value="c"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="unknown"/>
        </parameter>
      </target>
      <target>
        <context value="TgtExtension"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/data-absent-reason"/>
        </parameter>
      </target>
      <target>
        <context value="TgtExtension"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="c"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="TgtExtension"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="NotApplicable"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="Element"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Element"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="SetExtension"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <contextType value="variable"/>
        <variable value="TgtExtension"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Extension"/>
        </parameter>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="c"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <target>
        <context value="c"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="not-applicable"/>
        </parameter>
      </target>
      <target>
        <context value="TgtExtension"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/data-absent-reason"/>
        </parameter>
      </target>
      <target>
        <context value="TgtExtension"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="c"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="TgtExtension"/>
        </parameter>
      </target>
    </rule>
  </group>
</StructureMap>