CH ORF (R4)
3.0.0-ci-build - ci-build Switzerland flag

CH ORF (R4), published by HL7 Switzerland. This guide is not an authorized publication; it is the continuous build for version 3.0.0-ci-build built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/hl7ch/ch-orf/ and changes regularly. See the Directory of published versions

: Map ORF - XML Representation

Draft as of 2024-10-15

Raw xml | Download


<StructureMap xmlns="http://hl7.org/fhir">
  <id value="OrfQrToBundle"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap OrfQrToBundle</b></p><a name="OrfQrToBundle"> </a><a name="hcOrfQrToBundle"> </a><a name="OrfQrToBundle-en-US"> </a><pre class="fml">
<b>map</b><span style="color: navy"> &quot;</span>http://fhir.ch/ig/ch-orf/StructureMap/OrfQrToBundle<span style="color: navy">&quot; = &quot;</span>OrfQrToBundle<span style="color: navy">&quot;

</span><span style="color: navy">// </span><span style="color: green">ORF QuestionnaireResponse to Bundle</span>
<span style="color: navy">// </span><span style="color: green">2021-01-11 Oliver Egger</span>
<span style="color: navy">// </span><span style="color: green">QRF Questionnaire: http://fhir.ch/ig/ch-orf/Questionnaire-order-referral-form.html</span>
<span style="color: navy">// </span><span style="color: green">QRF QuestionnaireResponse: http://fhir.ch/ig/ch-orf/QuestionnaireResponse-order-referral-form.xml.html</span>
<span style="color: navy">// </span><span style="color: green">Bundle: http://fhir.ch/ig/ch-orf/StructureDefinition-ch-orf-document.html</span>

<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/questionnaireresponse.html" title="QuestionnaireResponse">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style="color: navy">&quot; </span><b>alias </b>QuestionnaireResponseSource <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/bundle.html" title="Bundle">http://hl7.org/fhir/StructureDefinition/Bundle</a><span style="color: navy">&quot; </span><b>alias </b>Bundle <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/composition.html" title="Composition">http://hl7.org/fhir/StructureDefinition/Composition</a><span style="color: navy">&quot; </span><b>alias </b>Composition <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/patient.html" title="Patient">http://hl7.org/fhir/StructureDefinition/Patient</a><span style="color: navy">&quot; </span><b>alias </b>Patient <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/relatedperson.html" title="RelatedPerson">http://hl7.org/fhir/StructureDefinition/RelatedPerson</a><span style="color: navy">&quot; </span><b>alias </b>RelatedPerson <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/organization.html" title="Organization">http://hl7.org/fhir/StructureDefinition/Organization</a><span style="color: navy">&quot; </span><b>alias </b>Organization <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/practitioner.html" title="Practitioner">http://hl7.org/fhir/StructureDefinition/Practitioner</a><span style="color: navy">&quot; </span><b>alias </b>Practitioner <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/practitionerrole.html" title="PractitionerRole">http://hl7.org/fhir/StructureDefinition/PractitionerRole</a><span style="color: navy">&quot; </span><b>alias </b>PractitionerRole <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/servicerequest.html" title="ServiceRequest">http://hl7.org/fhir/StructureDefinition/ServiceRequest</a><span style="color: navy">&quot; </span><b>alias </b>ServiceRequest <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/extensibility.html#Extension" title="Extension">http://hl7.org/fhir/StructureDefinition/Extension</a><span style="color: navy">&quot; </span><b>alias </b>Extension <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/episodeofcare.html" title="EpisodeOfCare">http://hl7.org/fhir/StructureDefinition/EpisodeOfCare</a><span style="color: navy">&quot; </span><b>alias </b>EpisodeOfCare <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/questionnaireresponse.html" title="QuestionnaireResponse">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style="color: navy">&quot; </span><b>alias </b>QuestionnaireResponse <b>as </b><b>target</b>

<b>group </b>OrfQrToBundle<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QuestionnaireResponseSource, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span> bundle.identifier<b> as </b><span style="color: maroon">documentIdentifier</span><span style="color: navy">, </span> documentIdentifier.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">uuidDoc</span><span style="color: navy">, </span> documentIdentifier.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">uuidDoc</span><span style="color: navy">)</span> <i>&quot;documentIdentifier&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Composition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">composition</span><span style="color: navy">, </span> composition.id = <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> e.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> bundle.entry<b> as </b><span style="color: maroon">e2</span><span style="color: navy">, </span> bundle.timestamp = <span style="color: navy">(</span>now()<span style="color: navy">)</span><b> as </b><span style="color: maroon">timestamp</span><span style="color: navy">, </span> bundle.type = <span style="color: blue">'document'</span><span style="color: navy">, </span> composition.date = <span style="color: maroon">timestamp</span><span style="color: navy">, </span> composition.title = <span style="color: blue">'Order and Referral by Form'</span><span style="color: navy">, </span> composition.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'419891008'</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://snomed.info/sct'</span><span style="color: navy">, </span> composition.category<b> as </b><span style="color: maroon">category</span><span style="color: navy">, </span> category.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'721963009'</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://snomed.info/sct'</span><span style="color: navy">, </span> e2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Patient'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">patient</span><span style="color: navy">, </span> patient.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> e2.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">uuid2</span><span style="color: navy">)</span><span style="color: navy">, </span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'QuestionnaireResponse'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">questionnaireresp</span><b> then</b><span style="color: navy"> {
</span>    qr<b> then </b>QuestionnaireResponseMap<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">questionnaireresp</span><span style="color: navy">)</span> <i>&quot;questionnaireresp&quot;</i><span style="color: navy">;</span>
    qr<span style="color: navy"><b> -&gt; </b></span> questionnaireresp.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.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">uuid4</span><span style="color: navy">)</span><span style="color: navy">, </span> bundle.entry<b> as </b><span style="color: maroon">e5</span><span style="color: navy">, </span> e5.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ServiceRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">servicerequest</span><span style="color: navy">, </span> servicerequest.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid5</span><span style="color: navy">, </span> e5.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">uuid5</span><span style="color: navy">)</span><b> then </b>QrToBundle<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">questionnaireresp</span><span style="color: navy">, </span><span style="color: maroon">servicerequest</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">)</span> <i>&quot;orfbundle&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;OrfQrToBundle&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>QuestionnaireResponseMap<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>QuestionnaireResponse<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <span style="color: maroon">value</span><span style="color: navy">;</span>
  src.basedOn<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.basedOn = <span style="color: maroon">value</span><span style="color: navy">;</span>
  src.partOf<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.partOf = <span style="color: maroon">value</span><span style="color: navy">;</span>
  src.questionnaire<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.questionnaire = <span style="color: maroon">value</span><span style="color: navy">;</span>
  src.status<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.status = <span style="color: maroon">value</span><span style="color: navy">;</span>
  src.subject<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.subject = <span style="color: maroon">value</span><span style="color: navy">;</span>
  src.encounter<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.encounter = <span style="color: maroon">value</span><span style="color: navy">;</span>
  src.authored<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.authored = <span style="color: maroon">value</span><span style="color: navy">;</span>
  src.author<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.author = <span style="color: maroon">value</span><span style="color: navy">;</span>
  src.source<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.source = <span style="color: maroon">value</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>tgt.item = <span style="color: maroon">value</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>QrToGroups<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QuestionnaireResponseSource, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'order'<b> then </b>OrderItems<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;grporder&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'receiver'<b> then </b>ReceiverInit<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;receiver&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'initiator'<b> then </b>InitiatorInit<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;grpinitiator&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'patient'<b> then </b>PatientItems<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;grppatient&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'requestedEncounter'<b> then </b>RequestedEncounterItems<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;grprequestedencounter&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'coverage'<b> then </b>Coverage<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;grprequestedencounter&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'sender'<b> then </b>SenderAuthorInit<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;grpsender&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'receiverCopy'<b> then </b>ReceiverCopy<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;receiverCopy&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'appointment'<b> then </b>Appointment<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;appointment&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'antecedentEpisodeOfCare'<b> then </b>AntecedentEpisodeOfCareInit<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">)</span> <i>&quot;AntecedentEpisodeOfCareInit&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'consent'<b> then </b>Consent<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">)</span> <i>&quot;consent&quot;</i><span style="color: navy">;</span>
  qr.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'note'<b> then </b>Note<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;note&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>OrderItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">composition</span>, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.precedentDocumentIdentifier') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> composition.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-precedentdocument'</span><span style="color: navy">, </span> ext.value = <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">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:ietf:rfc:3986'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>'urn:uuid:' + %item.answer.value<span style="color: navy">)</span> <i>&quot;orderPrecedentDocumentIdentifier&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.placerOrderIdentifier') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> serviceRequest.identifier<b> as </b><span style="color: maroon">value</span> <b>share</b> <b>placer</b><span style="color: navy">, </span> value.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v2-0203'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'PLAC'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;orderPlacerOrderIdentifier&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.placerOrderIdentifierDomain') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> serviceRequest.identifier<b> as </b><span style="color: maroon">value</span> <b>share</b> <b>placer</b><span style="color: navy">, </span> value.system = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;orderPlacerOrderIdentifierDomain&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.fillerOrderIdentifier') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> serviceRequest.identifier<b> as </b><span style="color: maroon">value</span> <b>share</b> <b>filler</b><span style="color: navy">, </span> value.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v2-0203'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'FILL'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;orderFillerOrderIdentifier&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.fillerOrderIdentifierDomain') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> serviceRequest.identifier<b> as </b><span style="color: maroon">value</span> <b>share</b> <b>filler</b><span style="color: navy">, </span> value.system = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;orderFillerOrderIdentifierDomain&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.authoredOn') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>serviceRequest.authoredOn = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.priority') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>serviceRequest.priority = <span style="color: navy">(</span>%item.answer.value.code<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'order.notificationContactDocument')<b> then</b><span style="color: navy"> {
</span>    item<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'PractitionerRole'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerRoleDataEnterer</span><span style="color: navy">, </span> practitionerRoleDataEnterer.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.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">uuid4</span><span style="color: navy">)</span><span style="color: navy">, </span> composition.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> bundle.entry<b> as </b><span style="color: maroon">e5</span><span style="color: navy">, </span> e5.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerDataEnterer</span><span style="color: navy">, </span> practitionerDataEnterer.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid5</span><span style="color: navy">, </span> e5.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">uuid5</span><span style="color: navy">)</span><span style="color: navy">, </span> practitionerRoleDataEnterer.practitioner = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid5</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      item<b> then </b>UrgentNotificationContactForRequestItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitionerRoleDataEnterer</span><span style="color: navy">, </span><span style="color: maroon">practitionerDataEnterer</span><span style="color: navy">)</span> <i>&quot;data&quot;</i><span style="color: navy">;</span>
      item<b> then </b>ExtOrfUrgentNotificationContactForRequest<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitionerRoleDataEnterer</span><span style="color: navy">, </span><span style="color: maroon">extension</span><span style="color: navy">)</span> <i>&quot;extension&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderNotificationContactDocumentItems&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;ordeNnotificationContactDocument&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'order.notificationContactDocumentResponse')<b> then</b><span style="color: navy"> {
</span>    item<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'PractitionerRole'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerRoleDataEnterer</span><span style="color: navy">, </span> practitionerRoleDataEnterer.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.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">uuid4</span><span style="color: navy">)</span><span style="color: navy">, </span> composition.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> bundle.entry<b> as </b><span style="color: maroon">e5</span><span style="color: navy">, </span> e5.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerDataEnterer</span><span style="color: navy">, </span> practitionerDataEnterer.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid5</span><span style="color: navy">, </span> e5.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">uuid5</span><span style="color: navy">)</span><span style="color: navy">, </span> practitionerRoleDataEnterer.practitioner = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid5</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      item<b> then </b>UrgentNotificationContactForResponseItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitionerRoleDataEnterer</span><span style="color: navy">, </span><span style="color: maroon">practitionerDataEnterer</span><span style="color: navy">)</span> <i>&quot;data&quot;</i><span style="color: navy">;</span>
      item<b> then </b>ExtOrfUrgentNotificationContactForResponse<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitionerRoleDataEnterer</span><span style="color: navy">, </span><span style="color: maroon">extension</span><span style="color: navy">)</span> <i>&quot;extension&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;orderNotificationContactDocumentResponseItems&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;orderNotificationContactDocumentResponse&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>UrgentNotificationContactForRequestPractitionerItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.notificationContactDocument.practitioner.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.notificationContactDocument.practitioner.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.notificationContactDocument.practitioner.title') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.prefix = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><b> as </b><span style="color: maroon">prefix</span><span style="color: navy">, </span> prefix.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier'</span><span style="color: navy">, </span> ext.value = <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">value</span><span style="color: navy">, </span> value.value = <span style="color: blue">'AC'</span> <i>&quot;senderAuthorPractitionerTitle&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.notificationContactDocument.practitioner.phone') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorPractitionerPhone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.notificationContactDocument.practitioner.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorPractitionerEmail&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>UrgentNotificationContactForRequestItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitionerRole</span><span style="color: navy"> : </span>PractitionerRole, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'order.notificationContactDocument.practitioner')<b> then </b>UrgentNotificationContactForRequestPractitionerItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ExtOrfUrgentNotificationContactForRequest<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitionerRole</span><span style="color: navy"> : </span>PractitionerRole, <b>target</b> <span style="color: maroon">ext</span><span style="color: navy"> : </span>Extension<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-urgentnoficationcontactforthisdocument'</span> <i>&quot;url&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span> ext.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %practitionerRole.id<span style="color: navy">)</span> <i>&quot;practitionerRole&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>UrgentNotificationContactForResponsePractitionerItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.notificationContactDocumentResponse.practitioner.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.notificationContactDocumentResponse.practitioner.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.notificationContactDocumentResponse.practitioner.title') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.prefix = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><b> as </b><span style="color: maroon">prefix</span><span style="color: navy">, </span> prefix.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier'</span><span style="color: navy">, </span> ext.value = <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">value</span><span style="color: navy">, </span> value.value = <span style="color: blue">'AC'</span> <i>&quot;senderAuthorPractitionerTitle&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.notificationContactDocumentResponse.practitioner.phone') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorPractitionerPhone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'order.notificationContactDocumentResponse.practitioner.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorPractitionerEmail&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>UrgentNotificationContactForResponseItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitionerRole</span><span style="color: navy"> : </span>PractitionerRole, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'order.notificationContactDocumentResponse.practitioner')<b> then </b>UrgentNotificationContactForResponsePractitionerItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ExtOrfUrgentNotificationContactForResponse<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitionerRole</span><span style="color: navy"> : </span>PractitionerRole, <b>target</b> <span style="color: maroon">ext</span><span style="color: navy"> : </span>Extension<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-urgentnoficationcontactfortheresponsetothisdocument'</span> <i>&quot;url&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span> ext.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %practitionerRole.id<span style="color: navy">)</span> <i>&quot;practitionerRole&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ReceiverPractitionerItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.practitioner.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.practitioner.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.practitioner.title') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.prefix = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><b> as </b><span style="color: maroon">prefix</span><span style="color: navy">, </span> prefix.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier'</span><span style="color: navy">, </span> ext.value = <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">value</span><span style="color: navy">, </span> value.value = <span style="color: blue">'AC'</span> <i>&quot;receiverPractitionerTitle&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.practitioner.gln') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.51.1.3'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverPractitionerGln&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.practitioner.zsr') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.16.756.5.30.1.123.100.2.1.1'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverPractitionerZsr&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.practitioner.phone') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverPractitionerPhone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.practitioner.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverPractitionerEmail&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ReceiverOrganizationItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">organization</span><span style="color: navy"> : </span>Organization<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.organization.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.name = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.organization.gln') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.51.1.3'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverOrganizationGln&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.organization.zsr') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.16.756.5.30.1.123.100.2.1.1'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverOrganizationZsr&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.organization.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;receiverOrganizationStreetAddressLine&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.organization.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverOrganizationPostalCode&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.organization.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverOrganizationCity&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiver.organization.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverOrganizationCountry&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ReceiverItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">practitionerRole</span><span style="color: navy"> : </span>PractitionerRole<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'receiver.practitioner')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e2</span><span style="color: navy">, </span> e2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitioner</span><span style="color: navy">, </span> practitioner.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> practitionerRole.practitioner = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid2</span><span style="color: navy">)</span><span style="color: navy">, </span> e2.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">uuid2</span><span style="color: navy">)</span><b> then </b>ReceiverPractitionerItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'receiver.organization')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e3</span><span style="color: navy">, </span> e3.resource = <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">organization</span><span style="color: navy">, </span> organization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid3</span><span style="color: navy">, </span> practitionerRole.organization = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid3</span><span style="color: navy">)</span><span style="color: navy">, </span> e3.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">uuid3</span><span style="color: navy">)</span><b> then </b>ReceiverOrganizationItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>Consent<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'consent.statement') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Consent'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">consent</span><span style="color: navy">, </span> consent.status = <span style="color: blue">'active'</span><span style="color: navy">, </span> consent.scope<b> as </b><span style="color: maroon">scope</span><span style="color: navy">, </span> scope.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'treatment'</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/consentscope'</span><span style="color: navy">, </span> consent.category<b> as </b><span style="color: maroon">category</span><span style="color: navy">, </span> category.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'59284-0'</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> consent.policyRule<b> as </b><span style="color: maroon">policyRule</span><span style="color: navy">, </span> policyRule.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'385432009'</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://snomed.info/sct'</span><span style="color: navy">, </span> consent.id = <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> e.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> composition.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-patientconsent'</span><span style="color: navy">, </span> ext.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> consent.extension<b> as </b><span style="color: maroon">extcode</span><span style="color: navy">, </span> extcode.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-consentcode'</span><span style="color: navy">, </span> extcode.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">, </span> reference.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">uuid</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><b> then</b><span style="color: navy"> {
</span>      answer.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'consent.statement.note') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> consent.extension<b> as </b><span style="color: maroon">extnote</span><span style="color: navy">, </span> extnote.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-consentnote'</span><span style="color: navy">, </span> extnote.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;consentStatementNote&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;consentStatement&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ReceiverInit<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'PractitionerRole'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerRole</span><span style="color: navy">, </span> practitionerRole.id = <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> e.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> composition.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-receiver'</span><span style="color: navy">, </span> ext.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid</span><span style="color: navy">)</span><b> then </b>ReceiverItems<span style="color: navy">(</span><span style="color: maroon">src</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">practitionerRole</span><span style="color: navy">)</span> <i>&quot;receiver&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>InitiatorItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">ext</span><span style="color: navy"> : </span>Extension<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.personalrelation') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> ext.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> extension.url = <span style="color: blue">'ch-orf-personalrelation'</span><span style="color: navy">, </span> extension.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;Initiatorpersonalrelation&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.legalrelation') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> ext.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> extension.url = <span style="color: blue">'ch-orf-legalrelation'</span><span style="color: navy">, </span> extension.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;Initiatorlegalrelation&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId = 'initiator.practitionerRole')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'PractitionerRole'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerrole</span><span style="color: navy">, </span> ext.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> practitionerrole.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> extension.url = <span style="color: blue">'ch-orf-personorganization'</span><span style="color: navy">, </span> extension.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid4</span><span style="color: navy">)</span><span style="color: navy">, </span> e4.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">uuid4</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    item<b> then </b>InitiatorPractitionerRoleItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">practitionerrole</span><span style="color: navy">)</span> <i>&quot;data&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;InitiatorPractitionerRoleItems&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId = 'initiator.relatedPerson')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'RelatedPerson'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">relatedPerson</span><span style="color: navy">, </span> ext.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> extension.url = <span style="color: blue">'ch-orf-personorganization'</span><span style="color: navy">, </span> extension.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> relatedPerson.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> reference.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">uuid4</span><span style="color: navy">)</span><span style="color: navy">, </span> relatedPerson.patient<b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> e4.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">uuid4</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    item<b> then </b>InitiatorRelatedPersonItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">relatedPerson</span><span style="color: navy">)</span> <i>&quot;data&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;InitiatorelatedPerson&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>InitiatorRelatedPersonItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">relatedPerson</span><span style="color: navy"> : </span>RelatedPerson<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.relatedPerson.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>name</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.relatedPerson.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>name</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.relatedPerson.phone') and answer.exists())<b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span> relatedPerson.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;InitiatorelatedPersonPhone&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;Phone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.relatedPerson.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;InitiatorelatedPersonEmail&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.relatedPerson.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;InitiatorelatedPersonStreetAddressLine&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.relatedPerson.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;InitiatorelatedPersonPostalCode&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.relatedPerson.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;InitiatorelatedPersonCity&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.relatedPerson.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;InitiatorelatedPersonCountry&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>InitiatorPractitionerRoleItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">practitionerRole</span><span style="color: navy"> : </span>PractitionerRole<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'initiator.practitionerRole.practitioner')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e2</span><span style="color: navy">, </span> e2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitioner</span><span style="color: navy">, </span> practitioner.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> practitionerRole.practitioner = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid2</span><span style="color: navy">)</span><span style="color: navy">, </span> e2.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">uuid2</span><span style="color: navy">)</span><b> then </b>InitiatorPractitionerItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'initiator.practitionerRole.organization')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e3</span><span style="color: navy">, </span> e3.resource = <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">organization</span><span style="color: navy">, </span> organization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid3</span><span style="color: navy">, </span> practitionerRole.organization = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid3</span><span style="color: navy">)</span><span style="color: navy">, </span> e3.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">uuid3</span><span style="color: navy">)</span><b> then </b>InitiatorOrganizationItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>InitiatorPractitionerItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.practitioner.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.practitioner.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.practitioner.title') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.prefix = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><b> as </b><span style="color: maroon">prefix</span><span style="color: navy">, </span> prefix.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier'</span><span style="color: navy">, </span> ext.value = <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">value</span><span style="color: navy">, </span> value.value = <span style="color: blue">'AC'</span> <i>&quot;InitiatorractitionerRolePractitionerTitle&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.practitioner.phone') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;InitiatorractitionerRolePractitionerPhone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.practitioner.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;InitiatorractitionerRolePractitionerEmail&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.practitioner.gln') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.51.1.3'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverPractitionerGln&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.practitioner.zsr') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.16.756.5.30.1.123.100.2.1.1'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverPractitionerZsr&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>InitiatorOrganizationItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">organization</span><span style="color: navy"> : </span>Organization<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.organization.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.name = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.organization.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;InitiatorractitionerRoleOrganizationStreetAddressLine&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.organization.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;InitiatorractitionerRoleOrganizationPostalCode&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.organization.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;InitiatorractitionerRoleOrganizationCity&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'initiator.practitionerRole.organization.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;InitiatorractitionerRoleOrganizationCountry&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>FamilyDoctorInit<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'PractitionerRole'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerRole</span><span style="color: navy">, </span> practitionerRole.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> patient.generalPractitioner = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">gp</span><span style="color: navy">, </span> gp.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">uuid4</span><span style="color: navy">)</span><span style="color: navy">, </span> e4.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">uuid4</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'familydoctor.practitioner')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e2</span><span style="color: navy">, </span> e2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitioner</span><span style="color: navy">, </span> practitioner.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> practitionerRole.practitioner = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid2</span><span style="color: navy">)</span><span style="color: navy">, </span> e2.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">uuid2</span><span style="color: navy">)</span><b> then </b>FamilyDoctorPractitionerItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span><span style="color: navy">;</span>
    src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'familydoctor.organization')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e3</span><span style="color: navy">, </span> e3.resource = <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">organization</span><span style="color: navy">, </span> organization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid3</span><span style="color: navy">, </span> practitionerRole.organization = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid3</span><span style="color: navy">)</span><span style="color: navy">, </span> e3.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">uuid3</span><span style="color: navy">)</span><b> then </b>FamilyDoctorOrganizationItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;FamilyDoctorInit&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>FamilyDoctorPractitionerItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.practitioner.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.practitioner.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.practitioner.gln') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.51.1.3'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;familydoctorPractitionerGln&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.practitioner.zsr') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.16.756.5.30.1.123.100.2.1.1'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;familydoctorPractitionerZsr&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.practitioner.title') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.prefix = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><b> as </b><span style="color: maroon">prefix</span><span style="color: navy">, </span> prefix.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier'</span><span style="color: navy">, </span> ext.value = <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">value</span><span style="color: navy">, </span> value.value = <span style="color: blue">'AC'</span> <i>&quot;familydoctorPractitionerTitle&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.practitioner.phone') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;familydoctorPractitionerPhone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.practitioner.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;familydoctorPractitionerEmail&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>FamilyDoctorOrganizationItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">organization</span><span style="color: navy"> : </span>Organization<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.organization.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.name = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.organization.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;familydoctorOrganizationStreetAddressLine&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.organization.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;familydoctorOrganizationPostalCode&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.organization.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;familydoctorOrganizationCity&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.organization.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;familydoctorOrganizationCountry&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.organization.gln') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.51.1.3'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;familydoctorOrganizationGln&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'familydoctor.organization.zsr') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.16.756.5.30.1.123.100.2.1.1'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;familydoctorOrganizationZsr&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>AntecedentEpisodeOfCareInit<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span> composition.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-antecedentepisodeofcare'</span><span style="color: navy">, </span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'EpisodeOfCare'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">episodeofcare</span><span style="color: navy">, </span> episodeofcare.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> episodeofcare.status = <span style="color: blue">'finished'</span><span style="color: navy">, </span> ext.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ref</span><span style="color: navy">, </span> ref.reference = <span style="color: navy">(</span>'urn:uuid:' + %episodeofcare.id<span style="color: navy">)</span><b> then </b>AntecedentEpisodeOfCareItems<span style="color: navy">(</span><span style="color: maroon">src</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">episodeofcare</span><span style="color: navy">)</span> <i>&quot;AntecedentEpisodeOfCareItems&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>AntecedentEpisodeOfCareItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">episodeofcare</span><span style="color: navy"> : </span>EpisodeOfCare<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'antecedentEpisodeOfCare.start') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> episodeofcare.statusHistory<b> as </b><span style="color: maroon">statusHistory</span><span style="color: navy">, </span> statusHistory.status = <span style="color: blue">'finished'</span><span style="color: navy">, </span> statusHistory.period<b> as </b><span style="color: maroon">period</span><span style="color: navy">, </span> period.start = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">, </span> period.end = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    src.item<b> as </b><span style="color: maroon">iteme</span><b> where </b>((linkId.value = 'antecedentEpisodeOfCare.end') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>period.end = <span style="color: navy">(</span>%iteme.answer.value<span style="color: navy">)</span> <i>&quot;antecedentEpisodeOfCareEndNotSameAsStart&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;antecedentEpisodeOfCareRequestedPeriodStart&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'antecedentEpisodeOfCare.managingOrganization')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e3</span><span style="color: navy">, </span> e3.resource = <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">organization</span><span style="color: navy">, </span> organization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid3</span><span style="color: navy">, </span> e3.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">uuid3</span><span style="color: navy">)</span><span style="color: navy">, </span> episodeofcare.patient = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %tgt.id<span style="color: navy">)</span><span style="color: navy">, </span> episodeofcare.managingOrganization = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid3</span><span style="color: navy">)</span><b> then </b>AntecedentEpisodeOfCareOrganizationItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span> <i>&quot;antecedentEpisodeOfCareManagingOrganization&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>AntecedentEpisodeOfCareOrganizationItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">organization</span><span style="color: navy"> : </span>Organization<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'antecedentEpisodeOfCare.managingOrganization.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.name = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'antecedentEpisodeOfCare.managingOrganization.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;antecedentEpisodeOfCareorganizationStreetAddressLine&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'antecedentEpisodeOfCare.managingOrganization.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorOrganizationPostalCode&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'antecedentEpisodeOfCare.managingOrganization.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorOrganizationCity&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'antecedentEpisodeOfCare.managingOrganization.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorOrganizationCountry&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>InitiatorInit<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span> composition.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-initiator'</span><b> then </b>InitiatorItems<span style="color: navy">(</span><span style="color: maroon">src</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">ext</span><span style="color: navy">)</span> <i>&quot;receiver&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>PatientItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">grp</span><b> where </b>linkId = 'familydoctor'<b> then </b>FamilyDoctorInit<span style="color: navy">(</span><span style="color: maroon">grp</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">tgt</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span> <i>&quot;grpfamily&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> then </b>PatientItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">tgt</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">serviceRequest</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> tgt.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>patientName</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.maidenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> tgt.name<b> as </b><span style="color: maroon">name</span><span style="color: navy">, </span> name.use = <span style="color: blue">'maiden'</span><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> tgt.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>patientName</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.localPid') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> tgt.identifier<b> as </b><span style="color: maroon">value</span> <b>share</b> <b>localpid</b><span style="color: navy">, </span> value.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v2-0203'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'MR'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;PatientLocalPid&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.localPidDomain') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> tgt.identifier<b> as </b><span style="color: maroon">value</span> <b>share</b> <b>localpid</b><span style="color: navy">, </span> value.system = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;PatientLocalPidDomain&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.birthDate') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>tgt.birthDate = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.gender') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>tgt.gender = <span style="color: navy">(</span>%item.answer.value.code<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.maritalStatus') and answer.exists())<b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><b> then</b><span style="color: navy"> {
</span>      answer.value<span style="color: navy"> : </span>Coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy"><b> -&gt; </b></span> tgt.maritalStatus<b> as </b><span style="color: maroon">maritalStatus</span><span style="color: navy">, </span> maritalStatus.coding = <span style="color: maroon">coding</span> <i>&quot;maritalStatus&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;patientMaritalStatus&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.phone') and answer.exists())<b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span> tgt.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;PatientPhone&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;PatientPhone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> tgt.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;PatientEmail&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>tgt.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;PatientStreetAddressLine&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> tgt.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;PatientPostalCode&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> tgt.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;PatientCity&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> tgt.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;PatientCountry&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.languageOfCorrespondence') and answer.exists())<b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><b> then</b><span style="color: navy"> {
</span>      answer.value<span style="color: navy"> : </span>Coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy"><b> -&gt; </b></span> tgt.communication<b> as </b><span style="color: maroon">communication</span><span style="color: navy">, </span> communication.preferred = <span style="color: blue">true</span><span style="color: navy">, </span> communication.language<b> as </b><span style="color: maroon">language</span><span style="color: navy">, </span> language.coding = <span style="color: maroon">coding</span> <i>&quot;languageOfCorrespondence&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;PatientLanguageOfCorrespondence&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'patient.contactperson')<span style="color: navy"><b> -&gt; </b></span>tgt.contact<b> as </b><span style="color: maroon">contact</span><b> then</b><span style="color: navy"> {
</span>    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.contactperson.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> contact.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>contactName</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.contactperson.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> contact.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>contactName</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
    src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.contactperson.phone') and answer.exists())<b> then</b><span style="color: navy"> {
</span>      item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span> tgt.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;PatientPhone&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;PatientContactpersonPhone&quot;</i><span style="color: navy">;</span>
    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.contactperson.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> contact.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;PatientEmail&quot;</i><span style="color: navy">;</span>
    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'patient.contactperson.relationship') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> contact.relationship<b> as </b><span style="color: maroon">relationship</span><span style="color: navy">, </span> relationship.text = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;PatientContactpersonRelationship&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;contact&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>RequestedEncounterItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Encounter'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">encounter</span><span style="color: navy">, </span> encounter.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> encounter.status = <span style="color: blue">'planned'</span><span style="color: navy">, </span> serviceRequest.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> encounter.subject = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> extension.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-requestedencounterdetails'</span><span style="color: navy">, </span> extension.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'requestedEncounter.class') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>encounter.class = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;requestedEncounterClass&quot;</i><span style="color: navy">;</span>
    src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'requestedEncounter.desiredAccommodation') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> encounter.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> extension.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-desiredaccommodation'</span><span style="color: navy">, </span> extension.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;requestedEncounterDesiredAccommodation&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;RequestedEncounterItems&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>Coverage<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  <span style="color: navy">// </span><span style="color: green">coverage.beneficiary</span>
  <span style="color: navy">// </span><span style="color: green">coverage.beneficiary.ahvn13</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>where(linkId.value = 'coverage.beneficiary')<b> then</b><span style="color: navy"> {
</span>    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.beneficiary.ahvn13') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> patient.identifier<b> as </b><span style="color: maroon">identifier</span><span style="color: navy">, </span> identifier.system = <span style="color: blue">'urn:oid:2.16.756.5.32'</span><span style="color: navy">, </span> identifier.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageBeneficiaryAhvn13&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;coverageBeneficiary&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">coverage.kvg</span>
  <span style="color: navy">// </span><span style="color: green">coverage.kvg.name</span>
  <span style="color: navy">// </span><span style="color: green">coverage.kvg.insuranceCardNumber</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>where(linkId.value = 'coverage.kvg')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coverage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">coverage</span><span style="color: navy">, </span> coverage.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> serviceRequest.insurance<b> as </b><span style="color: maroon">insurance</span><span style="color: navy">, </span> insurance.reference = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> coverage.status = <span style="color: blue">'active'</span><span style="color: navy">, </span> coverage.beneficiary = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> coverage.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'1'</span><b> then</b><span style="color: navy"> {
</span>    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.kvg.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> coverage.payor<b> as </b><span style="color: maroon">payor</span><span style="color: navy">, </span> payor.reference<b> as </b><span style="color: maroon">refcontained</span><span style="color: navy">, </span> refcontained.value = <span style="color: blue">'#org'</span><span style="color: navy">, </span> coverage.contained = <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">organization</span><span style="color: navy">, </span> organization.id = <span style="color: blue">'org'</span><span style="color: navy">, </span> organization.name = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageKvgName&quot;</i><span style="color: navy">;</span>
    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.kvg.insuranceCardNumber') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> coverage.identifier<b> as </b><span style="color: maroon">identifier</span><span style="color: navy">, </span> identifier.type<b> as </b><span style="color: maroon">typeid</span><span style="color: navy">, </span> typeid.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'VeKa'</span><span style="color: navy">, </span> identifier.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageKvgInsuranceCardNumber&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;coveragekvg&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">coverage.uvg	Unfallversicherung (nach UVG)	0..1	group		Definition: Coverage.type</span>
  <span style="color: navy">// </span><span style="color: green">coverage.uvg.name	Name der Versicherung	0..1	string		Definition: Coverage.payor</span>
  <span style="color: navy">// </span><span style="color: green">coverage.uvg.claimNumber	Schadennummer	0..1	string		Definition: Coverage.identifier</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>where(linkId.value = 'coverage.uvg')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coverage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">coverage</span><span style="color: navy">, </span> coverage.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> serviceRequest.insurance<b> as </b><span style="color: maroon">insurance</span><span style="color: navy">, </span> insurance.reference = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> coverage.status = <span style="color: blue">'active'</span><span style="color: navy">, </span> coverage.beneficiary = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> coverage.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'4'</span><b> then</b><span style="color: navy"> {
</span>    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.uvg.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> coverage.payor<b> as </b><span style="color: maroon">payor</span><span style="color: navy">, </span> payor.reference<b> as </b><span style="color: maroon">refcontained</span><span style="color: navy">, </span> refcontained.value = <span style="color: blue">'#org'</span><span style="color: navy">, </span> coverage.contained = <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">organization</span><span style="color: navy">, </span> organization.id = <span style="color: blue">'org'</span><span style="color: navy">, </span> organization.name = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageUvgName&quot;</i><span style="color: navy">;</span>
    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.uvg.claimNumber') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> coverage.identifier<b> as </b><span style="color: maroon">identifier</span><span style="color: navy">, </span> identifier.type<b> as </b><span style="color: maroon">typeid</span><span style="color: navy">, </span> typeid.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'Claim'</span><span style="color: navy">, </span> identifier.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageUvgClaimNumber&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;coverageuvg&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">coverage.vvg	Zusatzversicherung (nach VVG)	0..1	group		Definition: Coverage.type</span>
  <span style="color: navy">// </span><span style="color: green">coverage.vvg.name	Name der Versicherung	0..1	string		Definition: Coverage.payor</span>
  <span style="color: navy">// </span><span style="color: green">coverage.vvg.insuranceCardNumber	Kennnummer der Versichertenkarte	0..1	string		Definition: Coverage.identifier</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>where(linkId.value = 'coverage.vvg')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coverage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">coverage</span><span style="color: navy">, </span> coverage.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> serviceRequest.insurance<b> as </b><span style="color: maroon">insurance</span><span style="color: navy">, </span> insurance.reference = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> coverage.status = <span style="color: blue">'active'</span><span style="color: navy">, </span> coverage.beneficiary = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> coverage.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-core/CodeSystem/mainguarantor'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'ZV'</span><b> then</b><span style="color: navy"> {
</span>    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.vvg.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> coverage.payor<b> as </b><span style="color: maroon">payor</span><span style="color: navy">, </span> payor.reference<b> as </b><span style="color: maroon">refcontained</span><span style="color: navy">, </span> refcontained.value = <span style="color: blue">'#org'</span><span style="color: navy">, </span> coverage.contained = <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">organization</span><span style="color: navy">, </span> organization.id = <span style="color: blue">'org'</span><span style="color: navy">, </span> organization.name = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageVvgName&quot;</i><span style="color: navy">;</span>
    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.vvg.insuranceCardNumber') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> coverage.identifier<b> as </b><span style="color: maroon">identifier</span><span style="color: navy">, </span> identifier.type<b> as </b><span style="color: maroon">typeid</span><span style="color: navy">, </span> typeid.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'VeKa'</span><span style="color: navy">, </span> identifier.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageVvgInsuranceCardNumber&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;coveragevvg&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">coverage.iv	Invalidenversicherung (IV)	0..1	group		Definition: Coverage.type</span>
  <span style="color: navy">// </span><span style="color: green">coverage.iv.verfuegungsnummer</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>where(linkId.value = 'coverage.iv')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coverage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">coverage</span><span style="color: navy">, </span> coverage.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> serviceRequest.insurance<b> as </b><span style="color: maroon">insurance</span><span style="color: navy">, </span> insurance.reference = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> coverage.status = <span style="color: blue">'active'</span><span style="color: navy">, </span> coverage.beneficiary = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> coverage.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'2'</span><b> then</b><span style="color: navy"> {
</span>    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.iv.verfuegungsnummer') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> coverage.identifier<b> as </b><span style="color: maroon">identifier</span><span style="color: navy">, </span> identifier.type<b> as </b><span style="color: maroon">typeid</span><span style="color: navy">, </span> typeid.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'IV'</span><span style="color: navy">, </span> identifier.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">, </span> coverage.payor<b> as </b><span style="color: maroon">payor</span><span style="color: navy">, </span> payor.reference<b> as </b><span style="color: maroon">refcontained</span><span style="color: navy">, </span> refcontained.value = <span style="color: blue">'#org'</span><span style="color: navy">, </span> coverage.contained = <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">organization</span><span style="color: navy">, </span> organization.id = <span style="color: blue">'org'</span><span style="color: navy">, </span> organization.name = <span style="color: blue">'IV'</span> <i>&quot;coverageivverfuegungsnummer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;coverageiv&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">coverage.mv	Militärversicherung (MV)	0..1	group		Definition: Coverage.type</span>
  <span style="color: navy">// </span><span style="color: green">coverage.mv.versichertennummer</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>where(linkId.value = 'coverage.mv')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coverage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">coverage</span><span style="color: navy">, </span> coverage.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> serviceRequest.insurance<b> as </b><span style="color: maroon">insurance</span><span style="color: navy">, </span> insurance.reference = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> coverage.status = <span style="color: blue">'active'</span><span style="color: navy">, </span> coverage.beneficiary = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> coverage.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'3'</span><b> then</b><span style="color: navy"> {
</span>    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.mv.versichertennummer') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> coverage.identifier<b> as </b><span style="color: maroon">identifier</span><span style="color: navy">, </span> identifier.type<b> as </b><span style="color: maroon">typeid</span><span style="color: navy">, </span> typeid.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'MV'</span><span style="color: navy">, </span> identifier.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">, </span> coverage.payor<b> as </b><span style="color: maroon">payor</span><span style="color: navy">, </span> payor.reference<b> as </b><span style="color: maroon">refcontained</span><span style="color: navy">, </span> refcontained.value = <span style="color: blue">'#org'</span><span style="color: navy">, </span> coverage.contained = <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">organization</span><span style="color: navy">, </span> organization.id = <span style="color: blue">'org'</span><span style="color: navy">, </span> organization.name = <span style="color: blue">'MV'</span> <i>&quot;coveragemvversichertennummer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;coveragemv&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">coverage.self	Selbstzahler	0..1	group		Definition: Coverage.type</span>
  <span style="color: navy">// </span><span style="color: green">coverage.self.familyName	Name	0..1	string		Definition: Coverage.payor</span>
  <span style="color: navy">// </span><span style="color: green">coverage.self.givenName	Vorname	0..1	string		Definition: Coverage.payor</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>where(linkId.value = 'coverage.self')<b> then</b><span style="color: navy"> {
</span>    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.self.patient') and answer.exists() and answer.value)<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coverage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">coverage</span><span style="color: navy">, </span> coverage.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> serviceRequest.insurance<b> as </b><span style="color: maroon">insurance</span><span style="color: navy">, </span> insurance.reference = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> coverage.status = <span style="color: blue">'active'</span><span style="color: navy">, </span> coverage.beneficiary = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> coverage.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'5'</span><span style="color: navy">, </span> coverage.payor<b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span> <i>&quot;payor&quot;</i><span style="color: navy">;</span>
    item.item<b> as </b><span style="color: maroon">item2</span><b> where </b>((linkId.value = 'coverage.self.patientRelatedPerson') and answer.exists() and answer.value)<b> then</b><span style="color: navy"> {
</span>      item.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'coverage.self.relatedPerson')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e5</span><span style="color: navy">, </span> e5.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coverage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">coverage</span><span style="color: navy">, </span> coverage.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e5.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> serviceRequest.insurance<b> as </b><span style="color: maroon">insurance</span><span style="color: navy">, </span> insurance.reference = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> coverage.status = <span style="color: blue">'active'</span><span style="color: navy">, </span> coverage.beneficiary = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> coverage.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'5'</span><span style="color: navy">, </span> bundle.entry<b> as </b><span style="color: maroon">e6</span><span style="color: navy">, </span> e6.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'RelatedPerson'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">relatedPerson</span><span style="color: navy">, </span> relatedPerson.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid6</span><span style="color: navy">, </span> e6.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">uuid6</span><span style="color: navy">)</span><span style="color: navy">, </span> coverage.payor<b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %relatedPerson.id<span style="color: navy">)</span><span style="color: navy">, </span> relatedPerson.patient<b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><b> then </b>CoverageRelatedPersonItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">relatedPerson</span><span style="color: navy">)</span> <i>&quot;coverageselfrelatedPerson&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;coverageselfpatientrelated&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;self&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">coverage.other	Anderer Kostenträger	0..1	group		Definition: Coverage.type</span>
  <span style="color: navy">// </span><span style="color: green">coverage.other.name	Name des Kostenträgers	0..1	string		Definition: Coverage.payor</span>
  <span style="color: navy">// </span><span style="color: green">coverage.other.id	Beliebige ID	0..1	string		Definition: Coverage.identifier</span>
  <span style="color: navy">// </span><span style="color: green">coverage.other.id.note TODO</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>where(linkId.value = 'coverage.other')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coverage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">coverage</span><span style="color: navy">, </span> coverage.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> serviceRequest.insurance<b> as </b><span style="color: maroon">insurance</span><span style="color: navy">, </span> insurance.reference = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> coverage.status = <span style="color: blue">'active'</span><span style="color: navy">, </span> coverage.beneficiary = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">subject</span><span style="color: navy">, </span> subject.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> coverage.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'8'</span><b> then</b><span style="color: navy"> {
</span>    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.other.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> coverage.payor<b> as </b><span style="color: maroon">payor</span><span style="color: navy">, </span> payor.reference<b> as </b><span style="color: maroon">refcontained</span><span style="color: navy">, </span> refcontained.value = <span style="color: blue">'#org'</span><span style="color: navy">, </span> coverage.contained = <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">organization</span><span style="color: navy">, </span> organization.id = <span style="color: blue">'org'</span><span style="color: navy">, </span> organization.name = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageOtherName&quot;</i><span style="color: navy">;</span>
    item.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.other.id') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> coverage.identifier<b> as </b><span style="color: maroon">identifier</span><span style="color: navy">, </span> identifier.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageOtherId&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;coveragevvg&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>CoverageRelatedPersonItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">relatedPerson</span><span style="color: navy"> : </span>RelatedPerson<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.self.relatedPerson.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>name</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.self.relatedPerson.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>name</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.self.relatedPerson.phone') and answer.exists())<b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span> relatedPerson.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;coverageSelfRelatedPersonPhone&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;Phone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.self.relatedPerson.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageSelfRelatedPersonEmail&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.self.relatedPerson.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;coverageSelfRelatedPersonStreetAddressLine&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.self.relatedPerson.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageSelfRelatedPersonPostalCode&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.self.relatedPerson.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageSelfRelatedPersonCity&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'coverage.self.relatedPerson.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;coverageSelfRelatedPersonCountry&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SenderAuthorPractitionerItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.practitioner.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.practitioner.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.practitioner.title') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.prefix = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><b> as </b><span style="color: maroon">prefix</span><span style="color: navy">, </span> prefix.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier'</span><span style="color: navy">, </span> ext.value = <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">value</span><span style="color: navy">, </span> value.value = <span style="color: blue">'AC'</span> <i>&quot;senderAuthorPractitionerTitle&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.practitioner.gln') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.51.1.3'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorPractitionerGln&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.practitioner.zsr') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.16.756.5.30.1.123.100.2.1.1'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorPractitionerZsr&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.practitioner.phone') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorPractitionerPhone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.practitioner.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorPractitionerEmail&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SenderAuthorOrganizationItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">organization</span><span style="color: navy"> : </span>Organization<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.organization.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.name = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.organization.gln') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.51.1.3'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorOrganizationGln&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.organization.zsr') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.identifier<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'urn:oid:2.16.756.5.30.1.123.100.2.1.1'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorOrganizationZsr&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.organization.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorOrganizationStreetAddressLine&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.organization.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorOrganizationPostalCode&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.organization.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorOrganizationCity&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.author.organization.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorOrganizationCountry&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SenderAuthorItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitionerRole</span><span style="color: navy"> : </span>PractitionerRole, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner, <b>target</b> <span style="color: maroon">organization</span><span style="color: navy"> : </span>Organization<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'sender.author.practitioner')<b> then </b>SenderAuthorPractitionerItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'sender.author.organization')<b> then </b>SenderAuthorOrganizationItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SenderDataEntererPractitionerItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.dataenterer.practitioner.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.dataenterer.practitioner.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.dataenterer.practitioner.phone') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorPractitionerPhone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'sender.dataenterer.practitioner.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;senderAuthorPractitionerEmail&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SenderDataEntererItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitionerRole</span><span style="color: navy"> : </span>PractitionerRole, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner, <b>target</b> <span style="color: maroon">organization</span><span style="color: navy"> : </span>Organization<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'sender.dataenterer.practitioner')<b> then </b>SenderDataEntererPractitionerItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ChExtEprDataEnterer<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitionerRole</span><span style="color: navy"> : </span>PractitionerRole, <b>target</b> <span style="color: maroon">ext</span><span style="color: navy"> : </span>Extension<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-dataenterer'</span> <i>&quot;url&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span> ext.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'enterer'</span><span style="color: navy">, </span> ext.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %practitionerRole.id<span style="color: navy">)</span> <i>&quot;practitionerRole&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SenderAuthorInit<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'PractitionerRole'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerRole</span><span style="color: navy">, </span> practitionerRole.id = <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> e.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> bundle.entry<b> as </b><span style="color: maroon">e2</span><span style="color: navy">, </span> e2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitioner</span><span style="color: navy">, </span> practitioner.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> e2.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">uuid2</span><span style="color: navy">)</span><span style="color: navy">, </span> bundle.entry<b> as </b><span style="color: maroon">e3</span><span style="color: navy">, </span> e3.resource = <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">organization</span><span style="color: navy">, </span> organization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid3</span><span style="color: navy">, </span> e3.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">uuid3</span><span style="color: navy">)</span><span style="color: navy">, </span> composition.author = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid</span><span style="color: navy">)</span><span style="color: navy">, </span> serviceRequest.requester = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid</span><span style="color: navy">)</span><span style="color: navy">, </span> practitionerRole.practitioner = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid2</span><span style="color: navy">)</span><span style="color: navy">, </span> practitionerRole.organization = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid3</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'sender.author')<b> then </b>SenderAuthorItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitionerRole</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span> <i>&quot;senderAuthor&quot;</i><span style="color: navy">;</span>
    src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'sender.dataenterer')<b> then</b><span style="color: navy"> {
</span>      item<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'PractitionerRole'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerRoleDataEnterer</span><span style="color: navy">, </span> practitionerRoleDataEnterer.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.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">uuid4</span><span style="color: navy">)</span><span style="color: navy">, </span> composition.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> bundle.entry<b> as </b><span style="color: maroon">e5</span><span style="color: navy">, </span> e5.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerDataEnterer</span><span style="color: navy">, </span> practitionerDataEnterer.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid5</span><span style="color: navy">, </span> e5.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">uuid5</span><span style="color: navy">)</span><span style="color: navy">, </span> practitionerRoleDataEnterer.practitioner = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid5</span><span style="color: navy">)</span><span style="color: navy">, </span> practitionerRoleDataEnterer.organization = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid3</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        item<b> then </b>SenderDataEntererItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitionerRoleDataEnterer</span><span style="color: navy">, </span><span style="color: maroon">practitionerDataEnterer</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span> <i>&quot;data&quot;</i><span style="color: navy">;</span>
        item<b> then </b>ChExtEprDataEnterer<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitionerRoleDataEnterer</span><span style="color: navy">, </span><span style="color: maroon">extension</span><span style="color: navy">)</span> <i>&quot;extension&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;senderDataentererItems&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;senderDataenterer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;sender&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ReceiverCopyRelatedPersonItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">relatedPerson</span><span style="color: navy"> : </span>RelatedPerson<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.relatedPerson.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>name</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.relatedPerson.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>name</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.relatedPerson.phone') and answer.exists())<b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span> relatedPerson.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyRelatedPersonPhone&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;Phone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.relatedPerson.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyRelatedPersonEmail&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.relatedPerson.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyRelatedPersonStreetAddressLine&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.relatedPerson.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyRelatedPersonPostalCode&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.relatedPerson.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyRelatedPersonCity&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.relatedPerson.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> relatedPerson.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyRelatedPersonCountry&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ReceiverCopyPractitionerItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">practitioner</span><span style="color: navy"> : </span>Practitioner<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.practitionerRole.practitioner.familyName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.family = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.practitionerRole.practitioner.givenName') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.given = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.practitionerRole.practitioner.title') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.name<b> as </b><span style="color: maroon">name</span> <b>share</b> <b>practitionerName</b><span style="color: navy">, </span> name.prefix = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><b> as </b><span style="color: maroon">prefix</span><span style="color: navy">, </span> prefix.extension<b> as </b><span style="color: maroon">ext</span><span style="color: navy">, </span> ext.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier'</span><span style="color: navy">, </span> ext.value = <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">value</span><span style="color: navy">, </span> value.value = <span style="color: blue">'AC'</span> <i>&quot;receiverCopyPractitionerRolePractitionerTitle&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.practitionerRole.practitioner.phone') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyPractitionerRolePractitionerPhone&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.practitionerRole.practitioner.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> practitioner.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyPractitionerRolePractitionerEmail&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ReceiverCopyOrganizationItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">organization</span><span style="color: navy"> : </span>Organization<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.practitionerRole.organization.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.name = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.practitionerRole.organization.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>    item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyPractitionerRoleOrganizationStreetAddressLine&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;itemAnswer&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.practitionerRole.organization.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyPractitionerRoleOrganizationPostalCode&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.practitionerRole.organization.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyPractitionerRoleOrganizationCity&quot;</i><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'receiverCopy.practitionerRole.organization.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> organization.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;receiverCopyPractitionerRoleOrganizationCountry&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ReceiverCopyPractitionerRoleItems<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">practitionerRole</span><span style="color: navy"> : </span>PractitionerRole<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'receiverCopy.practitionerRole.practitioner')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e2</span><span style="color: navy">, </span> e2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitioner</span><span style="color: navy">, </span> practitioner.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> practitionerRole.practitioner = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid2</span><span style="color: navy">)</span><span style="color: navy">, </span> e2.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">uuid2</span><span style="color: navy">)</span><b> then </b>ReceiverCopyPractitionerItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'receiverCopy.practitionerRole.organization')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e3</span><span style="color: navy">, </span> e3.resource = <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">organization</span><span style="color: navy">, </span> organization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid3</span><span style="color: navy">, </span> practitionerRole.organization = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.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">uuid3</span><span style="color: navy">)</span><span style="color: navy">, </span> e3.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">uuid3</span><span style="color: navy">)</span><b> then </b>ReceiverCopyOrganizationItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ExtOrfCopyReceiverPatient<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">ext</span><span style="color: navy"> : </span>Extension<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-copyreceiver'</span> <i>&quot;url&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span> ext.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span> <i>&quot;patient&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ExtOrfCopyReceiverPractitionerRole<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">res</span><span style="color: navy"> : </span>PractitionerRole, <b>target</b> <span style="color: maroon">ext</span><span style="color: navy"> : </span>Extension<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-copyreceiver'</span> <i>&quot;url&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span> ext.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %res.id<span style="color: navy">)</span> <i>&quot;organization&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ExtOrfCopyReceiverRelatedPerson<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">res</span><span style="color: navy"> : </span>RelatedPerson, <b>target</b> <span style="color: maroon">ext</span><span style="color: navy"> : </span>Extension<span style="color: navy">)</span><span style="color: navy"> {
</span>  src<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-copyreceiver'</span> <i>&quot;url&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span> ext.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %res.id<span style="color: navy">)</span> <i>&quot;organization&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ReceiverCopy<span style="color: navy">(</span><b>source</b> <span style="color: maroon">grp</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  grp.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId = 'receiverCopy.practitionerRole')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'PractitionerRole'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerrole</span><span style="color: navy">, </span> composition.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> practitionerrole.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.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">uuid4</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    item<b> then </b>ReceiverCopyPractitionerRoleItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">practitionerrole</span><span style="color: navy">)</span> <i>&quot;data&quot;</i><span style="color: navy">;</span>
    item<b> then </b>ExtOrfCopyReceiverPractitionerRole<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">practitionerrole</span><span style="color: navy">, </span><span style="color: maroon">extension</span><span style="color: navy">)</span> <i>&quot;extension&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;receiverCopyPractitionerRole1&quot;</i><span style="color: navy">;</span>
  grp.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId = 'receiverCopy.patient')<span style="color: navy"><b> -&gt; </b></span>composition.extension<b> as </b><span style="color: maroon">extension</span><b> then</b><span style="color: navy"> {
</span>    item<b> then </b>ExtOrfCopyReceiverPatient<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">extension</span><span style="color: navy">)</span> <i>&quot;extension&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;receiverCopyPatient&quot;</i><span style="color: navy">;</span>
  grp.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId = 'receiverCopy.relatedPerson')<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'RelatedPerson'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">relatedPerson</span><span style="color: navy">, </span> composition.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> relatedPerson.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> relatedPerson.patient<b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span><span style="color: navy">, </span> e4.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">uuid4</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    item<b> then </b>ReceiverCopyRelatedPersonItems<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">relatedPerson</span><span style="color: navy">)</span> <i>&quot;data&quot;</i><span style="color: navy">;</span>
    item<b> then </b>ExtOrfCopyReceiverRelatedPerson<span style="color: navy">(</span><span style="color: maroon">item</span><span style="color: navy">, </span><span style="color: maroon">relatedPerson</span><span style="color: navy">, </span><span style="color: maroon">extension</span><span style="color: navy">)</span> <i>&quot;extension&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;receiverCopyRelatedPerson&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>Appointment<span style="color: navy">(</span><b>source</b> <span style="color: maroon">grp</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  grp<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e4</span><span style="color: navy">, </span> e4.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Appointment'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">appointment</span><span style="color: navy">, </span> appointment.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid4</span><span style="color: navy">, </span> e4.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><span style="color: navy">, </span> serviceRequest.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy">, </span> extension.url = <span style="color: blue">'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-locationandtime'</span><span style="color: navy">, </span> extension.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %uuid4<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    grp.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'appointment.status') and (answer.value.code = 'proposed'))<span style="color: navy"><b> -&gt; </b></span>appointment.status = <span style="color: navy">(</span>%item.answer.value.code<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      grp.item<b> as </b><span style="color: maroon">itemp</span><b> where </b>(linkId.value = 'appointment.requestedPeriod')<b> then</b><span style="color: navy"> {
</span>        itemp.item<b> as </b><span style="color: maroon">item2</span><b> where </b>((linkId.value = 'appointment.requestedPeriod.start') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> appointment.requestedPeriod<b> as </b><span style="color: maroon">requestedPeriod</span><span style="color: navy">, </span> requestedPeriod.start = <span style="color: navy">(</span>%item2.answer.value<span style="color: navy">)</span><span style="color: navy">, </span> requestedPeriod.end = <span style="color: navy">(</span>%item2.answer.value<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>          itemp.item<b> as </b><span style="color: maroon">item3</span><b> where </b>((linkId.value = 'appointment.requestedPeriod.end') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>requestedPeriod.end = <span style="color: navy">(</span>%item3.answer.value<span style="color: navy">)</span> <i>&quot;appointmentRequestedPeriodendifnotsameasstart&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;appointmentRequestedPeriodStart&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;appointmentRequestedPeriod&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;proposed&quot;</i><span style="color: navy">;</span>
    grp.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'appointment.status') and ((answer.value.code = 'pending') or (answer.value.code = 'booked')))<span style="color: navy"><b> -&gt; </b></span>appointment.status = <span style="color: navy">(</span>%item.answer.value.code<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      grp.item<b> as </b><span style="color: maroon">itemp</span><b> where </b>(linkId.value = 'appointment.requestedPeriod')<b> then</b><span style="color: navy"> {
</span>        itemp.item<b> as </b><span style="color: maroon">item2</span><b> where </b>((linkId.value = 'appointment.requestedPeriod.start') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> appointment.start = <span style="color: navy">(</span>%item2.answer.value<span style="color: navy">)</span><span style="color: navy">, </span> appointment.end = <span style="color: navy">(</span>%item2.answer.value<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>          itemp.item<b> as </b><span style="color: maroon">item3</span><b> where </b>((linkId.value = 'appointment.requestedPeriod.end') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>appointment.end = <span style="color: navy">(</span>%item3.answer.value<span style="color: navy">)</span> <i>&quot;appointmentendifnotsameasstart&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;appointmentStart&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;appointmentStartend&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;pendingorbooked&quot;</i><span style="color: navy">;</span>
    grp.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId.value = 'appointment.patientInstruction') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>appointment.patientInstruction = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;appointmentPatientInstruction&quot;</i><span style="color: navy">;</span>
    grp.item<b> as </b><span style="color: maroon">item</span><b> where </b>(linkId.value = 'appointment.location')<b> then</b><span style="color: navy"> {
</span>      item<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e5</span><span style="color: navy">, </span> e5.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Location'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">location</span><span style="color: navy">, </span> location.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid5</span><span style="color: navy">, </span> e5.fullUrl = <span style="color: navy">(</span>'urn:uuid:' + %uuid5<span style="color: navy">)</span><span style="color: navy">, </span> appointment.participant<b> as </b><span style="color: maroon">participant</span><span style="color: navy">, </span> participant.status = <span style="color: blue">'tentative'</span><span style="color: navy">, </span> participant.actor = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">actor</span><span style="color: navy">, </span> actor.reference = <span style="color: navy">(</span>'urn:uuid:' + %location.id<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        item.item<b> as </b><span style="color: maroon">item3</span><b> where </b>((linkId.value = 'appointment.location.name') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>location.name = <span style="color: navy">(</span>%item3.answer.value<span style="color: navy">)</span><span style="color: navy">;</span>
        item.item<b> as </b><span style="color: maroon">item3</span><b> where </b>((linkId.value = 'appointment.location.phone') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> location.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'phone'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item3.answer.value<span style="color: navy">)</span> <i>&quot;appointmentLocationPhone&quot;</i><span style="color: navy">;</span>
        item.item<b> as </b><span style="color: maroon">item3</span><b> where </b>((linkId.value = 'appointment.location.email') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> location.telecom<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.system = <span style="color: blue">'email'</span><span style="color: navy">, </span> value.value = <span style="color: navy">(</span>%item3.answer.value<span style="color: navy">)</span> <i>&quot;appointmentLocationEmail&quot;</i><span style="color: navy">;</span>
        item.item<b> as </b><span style="color: maroon">item3</span><b> where </b>((linkId.value = 'appointment.location.streetAddressLine') and answer.exists())<span style="color: navy"><b> -&gt; </b></span>location.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><b> then</b><span style="color: navy"> {
</span>          item.answer<b> as </b><span style="color: maroon">answer</span><span style="color: navy"><b> -&gt; </b></span>address.line = <span style="color: navy">(</span>%answer.value<span style="color: navy">)</span> <i>&quot;line&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;appointmentLocationStreetAddressLine&quot;</i><span style="color: navy">;</span>
        item.item<b> as </b><span style="color: maroon">item3</span><b> where </b>((linkId.value = 'appointment.location.postalCode') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> location.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.postalCode = <span style="color: navy">(</span>%item3.answer.value<span style="color: navy">)</span> <i>&quot;appointmentLocationPostalCode&quot;</i><span style="color: navy">;</span>
        item.item<b> as </b><span style="color: maroon">item3</span><b> where </b>((linkId.value = 'appointment.location.city') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> location.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.city = <span style="color: navy">(</span>%item3.answer.value<span style="color: navy">)</span> <i>&quot;appointmentlocationCity&quot;</i><span style="color: navy">;</span>
        item.item<b> as </b><span style="color: maroon">item3</span><b> where </b>((linkId.value = 'appointment.location.country') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> location.address<b> as </b><span style="color: maroon">address</span> <b>share</b> <b>orgAddress</b><span style="color: navy">, </span> address.country = <span style="color: navy">(</span>%item3.answer.value<span style="color: navy">)</span> <i>&quot;appointmentLocationCountry&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;location&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;appointmentLocation&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;Appointment&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>Note<span style="color: navy">(</span><b>source</b> <span style="color: maroon">grp</span>, <b>target</b> <span style="color: maroon">serviceRequest</span><span style="color: navy"> : </span>ServiceRequest<span style="color: navy">)</span><span style="color: navy"> {
</span>  grp.item<b> as </b><span style="color: maroon">item</span><b> where </b>((linkId = 'note.text') and answer.exists())<span style="color: navy"><b> -&gt; </b></span> serviceRequest.note<b> as </b><span style="color: maroon">note</span><span style="color: navy">, </span> note.text = <span style="color: navy">(</span>%item.answer.value<span style="color: navy">)</span> <i>&quot;noteText&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>QrToBundle<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QuestionnaireResponseSource, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">questionnaireresp</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">servicerequest</span><span style="color: navy"> : </span>ServiceRequest, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  <span style="color: navy">// </span><span style="color: green">group QrToBundle(source qr : QuestionnaireResponseSource, target q: Questionnaire, target patient : Patient, target questionnaireresp: QuestionnaireResponse, target servicerequest: ServiceRequest, target composition : Composition, target bundle : Bundle) {</span>
  qr<span style="color: navy"><b> -&gt; </b></span>bundle.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;id&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span>bundle.type = <span style="color: blue">'document'</span> <i>&quot;type&quot;</i><span style="color: navy">;</span>
  qr<b> then </b>OrfComposition<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">questionnaireresp</span><span style="color: navy">, </span><span style="color: maroon">servicerequest</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">)</span> <i>&quot;composition&quot;</i><span style="color: navy">;</span>
  qr<b> then </b>QrToGroups<span style="color: navy">(</span><span style="color: maroon">qr</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">servicerequest</span><span style="color: navy">)</span> <i>&quot;qrgroups&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">group OrfComposition(source qr : QuestionnaireResponseSource, target q: Questionnaire, target tgt : Composition, target patient: Patient, target questionnaireresp: QuestionnaireResponse, target servicerequest: ServiceRequest, target bundle : Bundle) {</span>
<b>group </b>OrfComposition<span style="color: navy">(</span><b>source</b> <span style="color: maroon">qr</span><span style="color: navy"> : </span>QuestionnaireResponseSource, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">questionnaireresp</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">servicerequest</span><span style="color: navy"> : </span>ServiceRequest, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  qr<span style="color: navy"><b> -&gt; </b></span>tgt.status = <span style="color: blue">'final'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span> tgt.subject = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span> <i>&quot;subject&quot;</i><span style="color: navy">;</span>
  qr<span style="color: navy"><b> -&gt; </b></span> tgt.section<b> as </b><span style="color: maroon">tgtSection</span><span style="color: navy">, </span> tgtSection.title = <span style="color: blue">'Order-Referral'</span><span style="color: navy">, </span> tgtSection.code<b> as </b><span style="color: maroon">code</span><span style="color: navy">, </span> code.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> coding.code = <span style="color: blue">'93037-0'</span><span style="color: navy">, </span> coding.display = <span style="color: blue">'Portable medical order form'</span><span style="color: navy">, </span> tgtSection.entry = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %questionnaireresp.id<span style="color: navy">)</span><span style="color: navy">, </span> tgtSection.entry = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %servicerequest.id<span style="color: navy">)</span> <i>&quot;sections&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">,</span>
  <span style="color: navy">// </span><span style="color: green">tgtSection.entry = create('Reference') as reference, reference.reference = (%q.url) &quot;sections&quot;;</span>
  qr<span style="color: navy"><b> -&gt; </b></span> servicerequest.status = <span style="color: blue">'active'</span><span style="color: navy">, </span> servicerequest.intent = <span style="color: blue">'order'</span><span style="color: navy">, </span> servicerequest.subject = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span> <i>&quot;servicerequest&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url value="http://fhir.ch/ig/ch-orf/StructureMap/OrfQrToBundle"/>
  <version value="3.0.0-ci-build"/>
  <name value="OrfQrToBundle"/>
  <status value="draft"/>
  <date value="2024-10-15T15:54:56+00:00"/>
  <publisher value="HL7 Switzerland"/>
  <contact>
    <name value="HL7 Switzerland"/>
    <telecom>
      <system value="url"/>
      <value value="https://www.hl7.ch/"/>
    </telecom>
  </contact>
  <description
               value="ORF QuestionnaireResponse to Bundle
2021-01-11 Oliver Egger
QRF Questionnaire: http://fhir.ch/ig/ch-orf/Questionnaire-order-referral-form.html
QRF QuestionnaireResponse: http://fhir.ch/ig/ch-orf/QuestionnaireResponse-order-referral-form.xml.html
Bundle: http://fhir.ch/ig/ch-orf/StructureDefinition-ch-orf-document.html"/>
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166"/>
      <code value="CH"/>
    </coding>
  </jurisdiction>
  <copyright value="CC0-1.0"/>
  <structure>
    <url
         value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"/>
    <mode value="source"/>
    <alias value="QuestionnaireResponseSource"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
    <mode value="target"/>
    <alias value="Bundle"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Composition"/>
    <mode value="target"/>
    <alias value="Composition"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Patient"/>
    <mode value="target"/>
    <alias value="Patient"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/RelatedPerson"/>
    <mode value="target"/>
    <alias value="RelatedPerson"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Organization"/>
    <mode value="target"/>
    <alias value="Organization"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Practitioner"/>
    <mode value="target"/>
    <alias value="Practitioner"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/PractitionerRole"/>
    <mode value="target"/>
    <alias value="PractitionerRole"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/ServiceRequest"/>
    <mode value="target"/>
    <alias value="ServiceRequest"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Extension"/>
    <mode value="target"/>
    <alias value="Extension"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/EpisodeOfCare"/>
    <mode value="target"/>
    <alias value="EpisodeOfCare"/>
  </structure>
  <structure>
    <url
         value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"/>
    <mode value="target"/>
    <alias value="QuestionnaireResponse"/>
  </structure>
  <group>
    <name value="OrfQrToBundle"/>
    <typeMode value="none"/>
    <input>
      <name value="qr"/>
      <type value="QuestionnaireResponseSource"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="documentIdentifier"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="documentIdentifier"/>
      </target>
      <target>
        <context value="documentIdentifier"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:ietf:rfc:3986"/>
        </parameter>
      </target>
      <target>
        <contextType value="variable"/>
        <variable value="uuidDoc"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="documentIdentifier"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuidDoc"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="OrfQrToBundle"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="composition"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Composition"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e2"/>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="timestamp"/>
        <variable value="timestamp"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="now()"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="type"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="document"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="date"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="timestamp"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="title"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Order and Referral by Form"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="419891008"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://snomed.info/sct"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="category"/>
        <variable value="category"/>
      </target>
      <target>
        <context value="category"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="721963009"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://snomed.info/sct"/>
        </parameter>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="patient"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Patient"/>
        </parameter>
      </target>
      <target>
        <context value="patient"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="questionnaireresp"/>
        <transform value="create"/>
        <parameter>
          <valueString value="QuestionnaireResponse"/>
        </parameter>
      </target>
      <rule>
        <name value="questionnaireresp"/>
        <source>
          <context value="qr"/>
        </source>
        <dependent>
          <name value="QuestionnaireResponseMap"/>
          <variable value="qr"/>
          <variable value="questionnaireresp"/>
        </dependent>
      </rule>
      <rule>
        <name value="orfbundle"/>
        <source>
          <context value="qr"/>
        </source>
        <target>
          <context value="questionnaireresp"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid4"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e4"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid4"/>
          </parameter>
        </target>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e5"/>
        </target>
        <target>
          <context value="e5"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="servicerequest"/>
          <transform value="create"/>
          <parameter>
            <valueString value="ServiceRequest"/>
          </parameter>
        </target>
        <target>
          <context value="servicerequest"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid5"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e5"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid5"/>
          </parameter>
        </target>
        <dependent>
          <name value="QrToBundle"/>
          <variable value="qr"/>
          <variable value="patient"/>
          <variable value="questionnaireresp"/>
          <variable value="servicerequest"/>
          <variable value="composition"/>
          <variable value="bundle"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="QuestionnaireResponseMap"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="QuestionnaireResponse"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="identifier"/>
      <source>
        <context value="src"/>
        <element value="identifier"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="basedOn"/>
      <source>
        <context value="src"/>
        <element value="basedOn"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="basedOn"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="partOf"/>
      <source>
        <context value="src"/>
        <element value="partOf"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="partOf"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="questionnaire"/>
      <source>
        <context value="src"/>
        <element value="questionnaire"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="questionnaire"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
        <element value="status"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="src"/>
        <element value="subject"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="encounter"/>
      <source>
        <context value="src"/>
        <element value="encounter"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="encounter"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="authored"/>
      <source>
        <context value="src"/>
        <element value="authored"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="authored"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="author"/>
      <source>
        <context value="src"/>
        <element value="author"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="author"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="source"/>
      <source>
        <context value="src"/>
        <element value="source"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="source"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="value"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="item"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="QrToGroups"/>
    <typeMode value="none"/>
    <input>
      <name value="qr"/>
      <type value="QuestionnaireResponseSource"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="grporder"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'order'"/>
      </source>
      <dependent>
        <name value="OrderItems"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="composition"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="receiver"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'receiver'"/>
      </source>
      <dependent>
        <name value="ReceiverInit"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="composition"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="grpinitiator"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'initiator'"/>
      </source>
      <dependent>
        <name value="InitiatorInit"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="patient"/>
        <variable value="composition"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="grppatient"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'patient'"/>
      </source>
      <dependent>
        <name value="PatientItems"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="patient"/>
        <variable value="composition"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="grprequestedencounter"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'requestedEncounter'"/>
      </source>
      <dependent>
        <name value="RequestedEncounterItems"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="patient"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="grprequestedencounter"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'coverage'"/>
      </source>
      <dependent>
        <name value="Coverage"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="patient"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="grpsender"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'sender'"/>
      </source>
      <dependent>
        <name value="SenderAuthorInit"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="composition"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="receiverCopy"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'receiverCopy'"/>
      </source>
      <dependent>
        <name value="ReceiverCopy"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="patient"/>
        <variable value="composition"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="appointment"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'appointment'"/>
      </source>
      <dependent>
        <name value="Appointment"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="composition"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="AntecedentEpisodeOfCareInit"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'antecedentEpisodeOfCare'"/>
      </source>
      <dependent>
        <name value="AntecedentEpisodeOfCareInit"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="patient"/>
        <variable value="composition"/>
      </dependent>
    </rule>
    <rule>
      <name value="consent"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'consent'"/>
      </source>
      <dependent>
        <name value="Consent"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="composition"/>
      </dependent>
    </rule>
    <rule>
      <name value="note"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'note'"/>
      </source>
      <dependent>
        <name value="Note"/>
        <variable value="grp"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="OrderItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="orderPrecedentDocumentIdentifier"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.precedentDocumentIdentifier') and answer.exists())"/>
      </source>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-precedentdocument"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Identifier"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:ietf:rfc:3986"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="orderPlacerOrderIdentifier"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.placerOrderIdentifier') and answer.exists())"/>
      </source>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
        <listMode value="share"/>
        <listRuleId value="placer"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://terminology.hl7.org/CodeSystem/v2-0203"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="PLAC"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="orderPlacerOrderIdentifierDomain"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.placerOrderIdentifierDomain') and answer.exists())"/>
      </source>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
        <listMode value="share"/>
        <listRuleId value="placer"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="orderFillerOrderIdentifier"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.fillerOrderIdentifier') and answer.exists())"/>
      </source>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
        <listMode value="share"/>
        <listRuleId value="filler"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://terminology.hl7.org/CodeSystem/v2-0203"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="FILL"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="orderFillerOrderIdentifierDomain"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.fillerOrderIdentifierDomain') and answer.exists())"/>
      </source>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
        <listMode value="share"/>
        <listRuleId value="filler"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.authoredOn') and answer.exists())"/>
      </source>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="authoredOn"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.priority') and answer.exists())"/>
      </source>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="priority"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value.code"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="ordeNnotificationContactDocument"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'order.notificationContactDocument')"/>
      </source>
      <rule>
        <name value="orderNotificationContactDocumentItems"/>
        <source>
          <context value="item"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e4"/>
        </target>
        <target>
          <context value="e4"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="practitionerRoleDataEnterer"/>
          <transform value="create"/>
          <parameter>
            <valueString value="PractitionerRole"/>
          </parameter>
        </target>
        <target>
          <context value="practitionerRoleDataEnterer"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid4"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e4"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid4"/>
          </parameter>
        </target>
        <target>
          <context value="composition"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <variable value="extension"/>
        </target>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e5"/>
        </target>
        <target>
          <context value="e5"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="practitionerDataEnterer"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Practitioner"/>
          </parameter>
        </target>
        <target>
          <context value="practitionerDataEnterer"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid5"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e5"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid5"/>
          </parameter>
        </target>
        <target>
          <context value="practitionerRoleDataEnterer"/>
          <contextType value="variable"/>
          <element value="practitioner"/>
          <variable value="reference"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid5"/>
          </parameter>
        </target>
        <rule>
          <name value="data"/>
          <source>
            <context value="item"/>
          </source>
          <dependent>
            <name value="UrgentNotificationContactForRequestItems"/>
            <variable value="item"/>
            <variable value="practitionerRoleDataEnterer"/>
            <variable value="practitionerDataEnterer"/>
          </dependent>
        </rule>
        <rule>
          <name value="extension"/>
          <source>
            <context value="item"/>
          </source>
          <dependent>
            <name value="ExtOrfUrgentNotificationContactForRequest"/>
            <variable value="item"/>
            <variable value="practitionerRoleDataEnterer"/>
            <variable value="extension"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="orderNotificationContactDocumentResponse"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'order.notificationContactDocumentResponse')"/>
      </source>
      <rule>
        <name value="orderNotificationContactDocumentResponseItems"/>
        <source>
          <context value="item"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e4"/>
        </target>
        <target>
          <context value="e4"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="practitionerRoleDataEnterer"/>
          <transform value="create"/>
          <parameter>
            <valueString value="PractitionerRole"/>
          </parameter>
        </target>
        <target>
          <context value="practitionerRoleDataEnterer"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid4"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e4"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid4"/>
          </parameter>
        </target>
        <target>
          <context value="composition"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <variable value="extension"/>
        </target>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e5"/>
        </target>
        <target>
          <context value="e5"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="practitionerDataEnterer"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Practitioner"/>
          </parameter>
        </target>
        <target>
          <context value="practitionerDataEnterer"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid5"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e5"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid5"/>
          </parameter>
        </target>
        <target>
          <context value="practitionerRoleDataEnterer"/>
          <contextType value="variable"/>
          <element value="practitioner"/>
          <variable value="reference"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid5"/>
          </parameter>
        </target>
        <rule>
          <name value="data"/>
          <source>
            <context value="item"/>
          </source>
          <dependent>
            <name value="UrgentNotificationContactForResponseItems"/>
            <variable value="item"/>
            <variable value="practitionerRoleDataEnterer"/>
            <variable value="practitionerDataEnterer"/>
          </dependent>
        </rule>
        <rule>
          <name value="extension"/>
          <source>
            <context value="item"/>
          </source>
          <dependent>
            <name value="ExtOrfUrgentNotificationContactForResponse"/>
            <variable value="item"/>
            <variable value="practitionerRoleDataEnterer"/>
            <variable value="extension"/>
          </dependent>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="UrgentNotificationContactForRequestPractitionerItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.notificationContactDocument.practitioner.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.notificationContactDocument.practitioner.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerTitle"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.notificationContactDocument.practitioner.title') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="prefix"/>
        <variable value="prefix"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
      <target>
        <context value="prefix"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="AC"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerPhone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.notificationContactDocument.practitioner.phone') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="phone"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.notificationContactDocument.practitioner.email') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="UrgentNotificationContactForRequestItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitionerRole"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'order.notificationContactDocument.practitioner')"/>
      </source>
      <dependent>
        <name value="UrgentNotificationContactForRequestPractitionerItems"/>
        <variable value="item"/>
        <variable value="practitioner"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="ExtOrfUrgentNotificationContactForRequest"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitionerRole"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="url"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-urgentnoficationcontactforthisdocument"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="practitionerRole"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %practitionerRole.id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="UrgentNotificationContactForResponsePractitionerItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.notificationContactDocumentResponse.practitioner.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.notificationContactDocumentResponse.practitioner.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerTitle"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.notificationContactDocumentResponse.practitioner.title') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="prefix"/>
        <variable value="prefix"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
      <target>
        <context value="prefix"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="AC"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerPhone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.notificationContactDocumentResponse.practitioner.phone') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="phone"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.notificationContactDocumentResponse.practitioner.email') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="UrgentNotificationContactForResponseItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitionerRole"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'order.notificationContactDocumentResponse.practitioner')"/>
      </source>
      <dependent>
        <name value="UrgentNotificationContactForResponsePractitionerItems"/>
        <variable value="item"/>
        <variable value="practitioner"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="ExtOrfUrgentNotificationContactForResponse"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitionerRole"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="url"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-urgentnoficationcontactfortheresponsetothisdocument"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="practitionerRole"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %practitionerRole.id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="ReceiverPractitionerItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.practitioner.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.practitioner.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverPractitionerTitle"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.practitioner.title') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="prefix"/>
        <variable value="prefix"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
      <target>
        <context value="prefix"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="AC"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverPractitionerGln"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.practitioner.gln') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.51.1.3"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverPractitionerZsr"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.practitioner.zsr') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.16.756.5.30.1.123.100.2.1.1"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverPractitionerPhone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.practitioner.phone') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="phone"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverPractitionerEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.practitioner.email') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="ReceiverOrganizationItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="organization"/>
      <type value="Organization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.organization.name') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="name"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverOrganizationGln"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.organization.gln') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.51.1.3"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverOrganizationZsr"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.organization.zsr') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.16.756.5.30.1.123.100.2.1.1"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="itemAnswer"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.organization.streetAddressLine') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <rule>
        <name value="receiverOrganizationStreetAddressLine"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="address"/>
          <contextType value="variable"/>
          <element value="line"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="receiverOrganizationPostalCode"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.organization.postalCode') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="postalCode"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverOrganizationCity"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.organization.city') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="city"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverOrganizationCountry"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiver.organization.country') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="country"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="ReceiverItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="practitionerRole"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="(linkId.value = 'receiver.practitioner')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e2"/>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="practitioner"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <dependent>
        <name value="ReceiverPractitionerItems"/>
        <variable value="item"/>
        <variable value="practitioner"/>
      </dependent>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="(linkId.value = 'receiver.organization')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e3"/>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="organization"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Organization"/>
        </parameter>
      </target>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid3"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="organization"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <dependent>
        <name value="ReceiverOrganizationItems"/>
        <variable value="item"/>
        <variable value="organization"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="Consent"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="consentStatement"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'consent.statement') and answer.exists())"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="consent"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Consent"/>
        </parameter>
      </target>
      <target>
        <context value="consent"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="active"/>
        </parameter>
      </target>
      <target>
        <context value="consent"/>
        <contextType value="variable"/>
        <element value="scope"/>
        <variable value="scope"/>
      </target>
      <target>
        <context value="scope"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="treatment"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://terminology.hl7.org/CodeSystem/consentscope"/>
        </parameter>
      </target>
      <target>
        <context value="consent"/>
        <contextType value="variable"/>
        <element value="category"/>
        <variable value="category"/>
      </target>
      <target>
        <context value="category"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="59284-0"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://loinc.org"/>
        </parameter>
      </target>
      <target>
        <context value="consent"/>
        <contextType value="variable"/>
        <element value="policyRule"/>
        <variable value="policyRule"/>
      </target>
      <target>
        <context value="policyRule"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="385432009"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://snomed.info/sct"/>
        </parameter>
      </target>
      <target>
        <context value="consent"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-patientconsent"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="consent"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="extcode"/>
      </target>
      <target>
        <context value="extcode"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-consentcode"/>
        </parameter>
      </target>
      <target>
        <context value="extcode"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <target>
        <context value="cc"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <rule>
        <name value="itemAnswer"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <rule>
          <name value="consentStatementNote"/>
          <source>
            <context value="answer"/>
            <element value="item"/>
            <variable value="item"/>
            <condition
                       value="((linkId.value = 'consent.statement.note') and answer.exists())"/>
          </source>
          <target>
            <context value="consent"/>
            <contextType value="variable"/>
            <element value="extension"/>
            <variable value="extnote"/>
          </target>
          <target>
            <context value="extnote"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-consentnote"/>
            </parameter>
          </target>
          <target>
            <context value="extnote"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="%item.answer.value"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ReceiverInit"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="receiver"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitionerRole"/>
        <transform value="create"/>
        <parameter>
          <valueString value="PractitionerRole"/>
        </parameter>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-receiver"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <dependent>
        <name value="ReceiverItems"/>
        <variable value="src"/>
        <variable value="bundle"/>
        <variable value="practitionerRole"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="InitiatorItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="Initiatorpersonalrelation"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.personalrelation') and answer.exists())"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="extension"/>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="ch-orf-personalrelation"/>
        </parameter>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="Initiatorlegalrelation"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.legalrelation') and answer.exists())"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="extension"/>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="ch-orf-legalrelation"/>
        </parameter>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="InitiatorPractitionerRoleItems"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="(linkId = 'initiator.practitionerRole')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitionerrole"/>
        <transform value="create"/>
        <parameter>
          <valueString value="PractitionerRole"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="extension"/>
      </target>
      <target>
        <context value="practitionerrole"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="ch-orf-personorganization"/>
        </parameter>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid4"/>
        </parameter>
      </target>
      <rule>
        <name value="data"/>
        <source>
          <context value="item"/>
        </source>
        <dependent>
          <name value="InitiatorPractitionerRoleItems"/>
          <variable value="item"/>
          <variable value="bundle"/>
          <variable value="practitionerrole"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="InitiatorelatedPerson"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="(linkId = 'initiator.relatedPerson')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="relatedPerson"/>
        <transform value="create"/>
        <parameter>
          <valueString value="RelatedPerson"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="extension"/>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="ch-orf-personorganization"/>
        </parameter>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="patient"/>
        <variable value="reference"/>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid4"/>
        </parameter>
      </target>
      <rule>
        <name value="data"/>
        <source>
          <context value="item"/>
        </source>
        <dependent>
          <name value="InitiatorRelatedPersonItems"/>
          <variable value="item"/>
          <variable value="relatedPerson"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="InitiatorRelatedPersonItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="relatedPerson"/>
      <type value="RelatedPerson"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.relatedPerson.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="name"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.relatedPerson.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="name"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="Phone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.relatedPerson.phone') and answer.exists())"/>
      </source>
      <rule>
        <name value="InitiatorelatedPersonPhone"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="relatedPerson"/>
          <contextType value="variable"/>
          <element value="telecom"/>
          <variable value="value"/>
        </target>
        <target>
          <context value="value"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="phone"/>
          </parameter>
        </target>
        <target>
          <context value="value"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="InitiatorelatedPersonEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.relatedPerson.email') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="itemAnswer"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.relatedPerson.streetAddressLine') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <rule>
        <name value="InitiatorelatedPersonStreetAddressLine"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="address"/>
          <contextType value="variable"/>
          <element value="line"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="InitiatorelatedPersonPostalCode"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.relatedPerson.postalCode') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="postalCode"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="InitiatorelatedPersonCity"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.relatedPerson.city') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="city"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="InitiatorelatedPersonCountry"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.relatedPerson.country') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="country"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="InitiatorPractitionerRoleItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="practitionerRole"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'initiator.practitionerRole.practitioner')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e2"/>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="practitioner"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <dependent>
        <name value="InitiatorPractitionerItems"/>
        <variable value="item"/>
        <variable value="practitioner"/>
      </dependent>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'initiator.practitionerRole.organization')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e3"/>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="organization"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Organization"/>
        </parameter>
      </target>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid3"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="organization"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <dependent>
        <name value="InitiatorOrganizationItems"/>
        <variable value="item"/>
        <variable value="organization"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="InitiatorPractitionerItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.practitioner.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.practitioner.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="InitiatorractitionerRolePractitionerTitle"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.practitioner.title') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="prefix"/>
        <variable value="prefix"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
      <target>
        <context value="prefix"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="AC"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="InitiatorractitionerRolePractitionerPhone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.practitioner.phone') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="phone"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="InitiatorractitionerRolePractitionerEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.practitioner.email') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverPractitionerGln"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.practitioner.gln') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.51.1.3"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverPractitionerZsr"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.practitioner.zsr') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.16.756.5.30.1.123.100.2.1.1"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="InitiatorOrganizationItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="organization"/>
      <type value="Organization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.organization.name') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="name"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="itemAnswer"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.organization.streetAddressLine') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <rule>
        <name value="InitiatorractitionerRoleOrganizationStreetAddressLine"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="address"/>
          <contextType value="variable"/>
          <element value="line"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="InitiatorractitionerRoleOrganizationPostalCode"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.organization.postalCode') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="postalCode"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="InitiatorractitionerRoleOrganizationCity"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.organization.city') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="city"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="InitiatorractitionerRoleOrganizationCountry"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'initiator.practitionerRole.organization.country') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="country"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="FamilyDoctorInit"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="FamilyDoctorInit"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitionerRole"/>
        <transform value="create"/>
        <parameter>
          <valueString value="PractitionerRole"/>
        </parameter>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="patient"/>
        <contextType value="variable"/>
        <element value="generalPractitioner"/>
        <variable value="gp"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="gp"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid4"/>
        </parameter>
      </target>
      <rule>
        <name value="item"/>
        <source>
          <context value="src"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="(linkId.value = 'familydoctor.practitioner')"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e2"/>
        </target>
        <target>
          <context value="e2"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="practitioner"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Practitioner"/>
          </parameter>
        </target>
        <target>
          <context value="practitioner"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid2"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="practitionerRole"/>
          <contextType value="variable"/>
          <element value="practitioner"/>
          <variable value="reference"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid2"/>
          </parameter>
        </target>
        <target>
          <context value="e2"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid2"/>
          </parameter>
        </target>
        <dependent>
          <name value="FamilyDoctorPractitionerItems"/>
          <variable value="item"/>
          <variable value="practitioner"/>
        </dependent>
      </rule>
      <rule>
        <name value="item"/>
        <source>
          <context value="src"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="(linkId.value = 'familydoctor.organization')"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e3"/>
        </target>
        <target>
          <context value="e3"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid3"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="practitionerRole"/>
          <contextType value="variable"/>
          <element value="organization"/>
          <variable value="reference"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid3"/>
          </parameter>
        </target>
        <target>
          <context value="e3"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid3"/>
          </parameter>
        </target>
        <dependent>
          <name value="FamilyDoctorOrganizationItems"/>
          <variable value="item"/>
          <variable value="organization"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="FamilyDoctorPractitionerItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.practitioner.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.practitioner.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="familydoctorPractitionerGln"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.practitioner.gln') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.51.1.3"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="familydoctorPractitionerZsr"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.practitioner.zsr') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.16.756.5.30.1.123.100.2.1.1"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="familydoctorPractitionerTitle"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.practitioner.title') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="prefix"/>
        <variable value="prefix"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
      <target>
        <context value="prefix"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="AC"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="familydoctorPractitionerPhone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.practitioner.phone') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="phone"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="familydoctorPractitionerEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.practitioner.email') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="FamilyDoctorOrganizationItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="organization"/>
      <type value="Organization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.organization.name') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="name"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="itemAnswer"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.organization.streetAddressLine') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <rule>
        <name value="familydoctorOrganizationStreetAddressLine"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="address"/>
          <contextType value="variable"/>
          <element value="line"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="familydoctorOrganizationPostalCode"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.organization.postalCode') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="postalCode"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="familydoctorOrganizationCity"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.organization.city') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="city"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="familydoctorOrganizationCountry"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.organization.country') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="country"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="familydoctorOrganizationGln"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.organization.gln') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.51.1.3"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="familydoctorOrganizationZsr"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'familydoctor.organization.zsr') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.16.756.5.30.1.123.100.2.1.1"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="AntecedentEpisodeOfCareInit"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="AntecedentEpisodeOfCareItems"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-antecedentepisodeofcare"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="episodeofcare"/>
        <transform value="create"/>
        <parameter>
          <valueString value="EpisodeOfCare"/>
        </parameter>
      </target>
      <target>
        <context value="episodeofcare"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="episodeofcare"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="finished"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="ref"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="ref"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %episodeofcare.id"/>
        </parameter>
      </target>
      <dependent>
        <name value="AntecedentEpisodeOfCareItems"/>
        <variable value="src"/>
        <variable value="bundle"/>
        <variable value="patient"/>
        <variable value="episodeofcare"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="AntecedentEpisodeOfCareItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="episodeofcare"/>
      <type value="EpisodeOfCare"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="antecedentEpisodeOfCareRequestedPeriodStart"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'antecedentEpisodeOfCare.start') and answer.exists())"/>
      </source>
      <target>
        <context value="episodeofcare"/>
        <contextType value="variable"/>
        <element value="statusHistory"/>
        <variable value="statusHistory"/>
      </target>
      <target>
        <context value="statusHistory"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="finished"/>
        </parameter>
      </target>
      <target>
        <context value="statusHistory"/>
        <contextType value="variable"/>
        <element value="period"/>
        <variable value="period"/>
      </target>
      <target>
        <context value="period"/>
        <contextType value="variable"/>
        <element value="start"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
      <target>
        <context value="period"/>
        <contextType value="variable"/>
        <element value="end"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
      <rule>
        <name value="antecedentEpisodeOfCareEndNotSameAsStart"/>
        <source>
          <context value="src"/>
          <element value="item"/>
          <variable value="iteme"/>
          <condition
                     value="((linkId.value = 'antecedentEpisodeOfCare.end') and answer.exists())"/>
        </source>
        <target>
          <context value="period"/>
          <contextType value="variable"/>
          <element value="end"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%iteme.answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="antecedentEpisodeOfCareManagingOrganization"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'antecedentEpisodeOfCare.managingOrganization')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e3"/>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="organization"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Organization"/>
        </parameter>
      </target>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid3"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <target>
        <context value="episodeofcare"/>
        <contextType value="variable"/>
        <element value="patient"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %tgt.id"/>
        </parameter>
      </target>
      <target>
        <context value="episodeofcare"/>
        <contextType value="variable"/>
        <element value="managingOrganization"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <dependent>
        <name value="AntecedentEpisodeOfCareOrganizationItems"/>
        <variable value="item"/>
        <variable value="organization"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="AntecedentEpisodeOfCareOrganizationItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="organization"/>
      <type value="Organization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'antecedentEpisodeOfCare.managingOrganization.name') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="name"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="itemAnswer"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'antecedentEpisodeOfCare.managingOrganization.streetAddressLine') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <rule>
        <name value="antecedentEpisodeOfCareorganizationStreetAddressLine"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="address"/>
          <contextType value="variable"/>
          <element value="line"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="senderAuthorOrganizationPostalCode"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'antecedentEpisodeOfCare.managingOrganization.postalCode') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="postalCode"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorOrganizationCity"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'antecedentEpisodeOfCare.managingOrganization.city') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="city"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorOrganizationCountry"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'antecedentEpisodeOfCare.managingOrganization.country') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="country"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="InitiatorInit"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="receiver"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-initiator"/>
        </parameter>
      </target>
      <dependent>
        <name value="InitiatorItems"/>
        <variable value="src"/>
        <variable value="bundle"/>
        <variable value="patient"/>
        <variable value="ext"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="PatientItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="grpfamily"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'familydoctor'"/>
      </source>
      <dependent>
        <name value="FamilyDoctorInit"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <variable value="tgt"/>
        <variable value="composition"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
      </source>
      <dependent>
        <name value="PatientItems"/>
        <variable value="item"/>
        <variable value="bundle"/>
        <variable value="tgt"/>
        <variable value="composition"/>
        <variable value="serviceRequest"/>
      </dependent>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="patientName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.maidenName') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="use"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="maiden"/>
        </parameter>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="patientName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="PatientLocalPid"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.localPid') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
        <listMode value="share"/>
        <listRuleId value="localpid"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://terminology.hl7.org/CodeSystem/v2-0203"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="MR"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="PatientLocalPidDomain"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.localPidDomain') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
        <listMode value="share"/>
        <listRuleId value="localpid"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.birthDate') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="birthDate"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.gender') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="gender"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value.code"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="patientMaritalStatus"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.maritalStatus') and answer.exists())"/>
      </source>
      <rule>
        <name value="answer"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <rule>
          <name value="maritalStatus"/>
          <source>
            <context value="answer"/>
            <type value="Coding"/>
            <element value="value"/>
            <variable value="coding"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="maritalStatus"/>
            <variable value="maritalStatus"/>
          </target>
          <target>
            <context value="maritalStatus"/>
            <contextType value="variable"/>
            <element value="coding"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="coding"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="PatientPhone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.phone') and answer.exists())"/>
      </source>
      <rule>
        <name value="PatientPhone"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="telecom"/>
          <variable value="value"/>
        </target>
        <target>
          <context value="value"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="phone"/>
          </parameter>
        </target>
        <target>
          <context value="value"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="PatientEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.email') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="itemAnswer"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.streetAddressLine') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <rule>
        <name value="PatientStreetAddressLine"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="address"/>
          <contextType value="variable"/>
          <element value="line"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="PatientPostalCode"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.postalCode') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="postalCode"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="PatientCity"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.city') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="city"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="PatientCountry"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.country') and answer.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="country"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="PatientLanguageOfCorrespondence"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.languageOfCorrespondence') and answer.exists())"/>
      </source>
      <rule>
        <name value="answer"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <rule>
          <name value="languageOfCorrespondence"/>
          <source>
            <context value="answer"/>
            <type value="Coding"/>
            <element value="value"/>
            <variable value="coding"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="communication"/>
            <variable value="communication"/>
          </target>
          <target>
            <context value="communication"/>
            <contextType value="variable"/>
            <element value="preferred"/>
            <transform value="copy"/>
            <parameter>
              <valueBoolean value="true"/>
            </parameter>
          </target>
          <target>
            <context value="communication"/>
            <contextType value="variable"/>
            <element value="language"/>
            <variable value="language"/>
          </target>
          <target>
            <context value="language"/>
            <contextType value="variable"/>
            <element value="coding"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="coding"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="contact"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="(linkId.value = 'patient.contactperson')"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="contact"/>
        <variable value="contact"/>
      </target>
      <rule>
        <name value="item"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'patient.contactperson.familyName') and answer.exists())"/>
        </source>
        <target>
          <context value="contact"/>
          <contextType value="variable"/>
          <element value="name"/>
          <variable value="name"/>
          <listMode value="share"/>
          <listRuleId value="contactName"/>
        </target>
        <target>
          <context value="name"/>
          <contextType value="variable"/>
          <element value="family"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="item"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'patient.contactperson.givenName') and answer.exists())"/>
        </source>
        <target>
          <context value="contact"/>
          <contextType value="variable"/>
          <element value="name"/>
          <variable value="name"/>
          <listMode value="share"/>
          <listRuleId value="contactName"/>
        </target>
        <target>
          <context value="name"/>
          <contextType value="variable"/>
          <element value="given"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="PatientContactpersonPhone"/>
        <source>
          <context value="src"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'patient.contactperson.phone') and answer.exists())"/>
        </source>
        <rule>
          <name value="PatientPhone"/>
          <source>
            <context value="item"/>
            <element value="answer"/>
            <variable value="answer"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="telecom"/>
            <variable value="value"/>
          </target>
          <target>
            <context value="value"/>
            <contextType value="variable"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="phone"/>
            </parameter>
          </target>
          <target>
            <context value="value"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="%answer.value"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="PatientEmail"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'patient.contactperson.email') and answer.exists())"/>
        </source>
        <target>
          <context value="contact"/>
          <contextType value="variable"/>
          <element value="telecom"/>
          <variable value="value"/>
        </target>
        <target>
          <context value="value"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="email"/>
          </parameter>
        </target>
        <target>
          <context value="value"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="PatientContactpersonRelationship"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'patient.contactperson.relationship') and answer.exists())"/>
        </source>
        <target>
          <context value="contact"/>
          <contextType value="variable"/>
          <element value="relationship"/>
          <variable value="relationship"/>
        </target>
        <target>
          <context value="relationship"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="RequestedEncounterItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="RequestedEncounterItems"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="encounter"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Encounter"/>
        </parameter>
      </target>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="planned"/>
        </parameter>
      </target>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="extension"/>
      </target>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="subject"/>
        <variable value="subject"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="subject"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-requestedencounterdetails"/>
        </parameter>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <rule>
        <name value="requestedEncounterClass"/>
        <source>
          <context value="src"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'requestedEncounter.class') and answer.exists())"/>
        </source>
        <target>
          <context value="encounter"/>
          <contextType value="variable"/>
          <element value="class"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="requestedEncounterDesiredAccommodation"/>
        <source>
          <context value="src"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'requestedEncounter.desiredAccommodation') and answer.exists())"/>
        </source>
        <target>
          <context value="encounter"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <variable value="extension"/>
        </target>
        <target>
          <context value="extension"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-desiredaccommodation"/>
          </parameter>
        </target>
        <target>
          <context value="extension"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Coverage"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="coverageBeneficiary"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="where(linkId.value = 'coverage.beneficiary')"/>
      </source>
      <rule>
        <name value="coverageBeneficiaryAhvn13"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.beneficiary.ahvn13') and answer.exists())"/>
        </source>
        <target>
          <context value="patient"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="identifier"/>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="urn:oid:2.16.756.5.32"/>
          </parameter>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="coveragekvg"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="where(linkId.value = 'coverage.kvg')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="coverage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coverage"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="insurance"/>
        <variable value="insurance"/>
      </target>
      <target>
        <context value="insurance"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="active"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="beneficiary"/>
        <variable value="subject"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="subject"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="1"/>
        </parameter>
      </target>
      <rule>
        <name value="coverageKvgName"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.kvg.name') and answer.exists())"/>
        </source>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="payor"/>
          <variable value="payor"/>
        </target>
        <target>
          <context value="payor"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <variable value="refcontained"/>
        </target>
        <target>
          <context value="refcontained"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="#org"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="contained"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="org"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="name"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="coverageKvgInsuranceCardNumber"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.kvg.insuranceCardNumber') and answer.exists())"/>
        </source>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="identifier"/>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="type"/>
          <variable value="typeid"/>
        </target>
        <target>
          <context value="typeid"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype"/>
          </parameter>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="VeKa"/>
          </parameter>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="coverageuvg"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="where(linkId.value = 'coverage.uvg')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="coverage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coverage"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="insurance"/>
        <variable value="insurance"/>
      </target>
      <target>
        <context value="insurance"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="active"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="beneficiary"/>
        <variable value="subject"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="subject"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="4"/>
        </parameter>
      </target>
      <rule>
        <name value="coverageUvgName"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.uvg.name') and answer.exists())"/>
        </source>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="payor"/>
          <variable value="payor"/>
        </target>
        <target>
          <context value="payor"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <variable value="refcontained"/>
        </target>
        <target>
          <context value="refcontained"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="#org"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="contained"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="org"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="name"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="coverageUvgClaimNumber"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.uvg.claimNumber') and answer.exists())"/>
        </source>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="identifier"/>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="type"/>
          <variable value="typeid"/>
        </target>
        <target>
          <context value="typeid"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype"/>
          </parameter>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Claim"/>
          </parameter>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="coveragevvg"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="where(linkId.value = 'coverage.vvg')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="coverage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coverage"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="insurance"/>
        <variable value="insurance"/>
      </target>
      <target>
        <context value="insurance"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="active"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="beneficiary"/>
        <variable value="subject"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="subject"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-core/CodeSystem/mainguarantor"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="ZV"/>
        </parameter>
      </target>
      <rule>
        <name value="coverageVvgName"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.vvg.name') and answer.exists())"/>
        </source>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="payor"/>
          <variable value="payor"/>
        </target>
        <target>
          <context value="payor"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <variable value="refcontained"/>
        </target>
        <target>
          <context value="refcontained"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="#org"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="contained"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="org"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="name"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="coverageVvgInsuranceCardNumber"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.vvg.insuranceCardNumber') and answer.exists())"/>
        </source>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="identifier"/>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="type"/>
          <variable value="typeid"/>
        </target>
        <target>
          <context value="typeid"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype"/>
          </parameter>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="VeKa"/>
          </parameter>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="coverageiv"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="where(linkId.value = 'coverage.iv')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="coverage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coverage"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="insurance"/>
        <variable value="insurance"/>
      </target>
      <target>
        <context value="insurance"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="active"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="beneficiary"/>
        <variable value="subject"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="subject"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="2"/>
        </parameter>
      </target>
      <rule>
        <name value="coverageivverfuegungsnummer"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.iv.verfuegungsnummer') and answer.exists())"/>
        </source>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="identifier"/>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="type"/>
          <variable value="typeid"/>
        </target>
        <target>
          <context value="typeid"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype"/>
          </parameter>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="IV"/>
          </parameter>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="payor"/>
          <variable value="payor"/>
        </target>
        <target>
          <context value="payor"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <variable value="refcontained"/>
        </target>
        <target>
          <context value="refcontained"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="#org"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="contained"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="org"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="name"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="IV"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="coveragemv"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="where(linkId.value = 'coverage.mv')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="coverage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coverage"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="insurance"/>
        <variable value="insurance"/>
      </target>
      <target>
        <context value="insurance"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="active"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="beneficiary"/>
        <variable value="subject"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="subject"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="3"/>
        </parameter>
      </target>
      <rule>
        <name value="coveragemvversichertennummer"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.mv.versichertennummer') and answer.exists())"/>
        </source>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="identifier"/>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="type"/>
          <variable value="typeid"/>
        </target>
        <target>
          <context value="typeid"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype"/>
          </parameter>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="MV"/>
          </parameter>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="payor"/>
          <variable value="payor"/>
        </target>
        <target>
          <context value="payor"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <variable value="refcontained"/>
        </target>
        <target>
          <context value="refcontained"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="#org"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="contained"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="org"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="name"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="MV"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="self"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="where(linkId.value = 'coverage.self')"/>
      </source>
      <rule>
        <name value="payor"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.self.patient') and answer.exists() and answer.value)"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e4"/>
        </target>
        <target>
          <context value="e4"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="coverage"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Coverage"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid4"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e4"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="'urn:uuid:' + %uuid4"/>
          </parameter>
        </target>
        <target>
          <context value="serviceRequest"/>
          <contextType value="variable"/>
          <element value="insurance"/>
          <variable value="insurance"/>
        </target>
        <target>
          <context value="insurance"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="'urn:uuid:' + %uuid4"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="status"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="active"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="beneficiary"/>
          <variable value="subject"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="subject"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="'urn:uuid:' + %patient.id"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="type"/>
          <variable value="type"/>
        </target>
        <target>
          <context value="type"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor"/>
          </parameter>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="5"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="payor"/>
          <variable value="subject"/>
        </target>
        <target>
          <context value="subject"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="'urn:uuid:' + %patient.id"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="coverageselfpatientrelated"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item2"/>
          <condition
                     value="((linkId.value = 'coverage.self.patientRelatedPerson') and answer.exists() and answer.value)"/>
        </source>
        <rule>
          <name value="coverageselfrelatedPerson"/>
          <source>
            <context value="item"/>
            <element value="item"/>
            <variable value="item"/>
            <condition
                       value="(linkId.value = 'coverage.self.relatedPerson')"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e5"/>
          </target>
          <target>
            <context value="e5"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="coverage"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Coverage"/>
            </parameter>
          </target>
          <target>
            <context value="coverage"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid4"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e5"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %uuid4"/>
            </parameter>
          </target>
          <target>
            <context value="serviceRequest"/>
            <contextType value="variable"/>
            <element value="insurance"/>
            <variable value="insurance"/>
          </target>
          <target>
            <context value="insurance"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %uuid4"/>
            </parameter>
          </target>
          <target>
            <context value="coverage"/>
            <contextType value="variable"/>
            <element value="status"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="active"/>
            </parameter>
          </target>
          <target>
            <context value="coverage"/>
            <contextType value="variable"/>
            <element value="beneficiary"/>
            <variable value="subject"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="subject"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %patient.id"/>
            </parameter>
          </target>
          <target>
            <context value="coverage"/>
            <contextType value="variable"/>
            <element value="type"/>
            <variable value="type"/>
          </target>
          <target>
            <context value="type"/>
            <contextType value="variable"/>
            <element value="coding"/>
            <variable value="coding"/>
          </target>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor"/>
            </parameter>
          </target>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="5"/>
            </parameter>
          </target>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e6"/>
          </target>
          <target>
            <context value="e6"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="relatedPerson"/>
            <transform value="create"/>
            <parameter>
              <valueString value="RelatedPerson"/>
            </parameter>
          </target>
          <target>
            <context value="relatedPerson"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid6"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e6"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid6"/>
            </parameter>
          </target>
          <target>
            <context value="coverage"/>
            <contextType value="variable"/>
            <element value="payor"/>
            <variable value="subject"/>
          </target>
          <target>
            <context value="subject"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %relatedPerson.id"/>
            </parameter>
          </target>
          <target>
            <context value="relatedPerson"/>
            <contextType value="variable"/>
            <element value="patient"/>
            <variable value="reference"/>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %patient.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="CoverageRelatedPersonItems"/>
            <variable value="item"/>
            <variable value="relatedPerson"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="coveragevvg"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="where(linkId.value = 'coverage.other')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="coverage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coverage"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="insurance"/>
        <variable value="insurance"/>
      </target>
      <target>
        <context value="insurance"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="active"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="beneficiary"/>
        <variable value="subject"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="subject"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
      <target>
        <context value="coverage"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-core/CodeSystem/bfs-medstats-25-mainguarantor"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="8"/>
        </parameter>
      </target>
      <rule>
        <name value="coverageOtherName"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.other.name') and answer.exists())"/>
        </source>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="payor"/>
          <variable value="payor"/>
        </target>
        <target>
          <context value="payor"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <variable value="refcontained"/>
        </target>
        <target>
          <context value="refcontained"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="#org"/>
          </parameter>
        </target>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="contained"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="org"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="name"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="coverageOtherId"/>
        <source>
          <context value="item"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'coverage.other.id') and answer.exists())"/>
        </source>
        <target>
          <context value="coverage"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="identifier"/>
        </target>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="CoverageRelatedPersonItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="relatedPerson"/>
      <type value="RelatedPerson"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'coverage.self.relatedPerson.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="name"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'coverage.self.relatedPerson.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="name"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="Phone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'coverage.self.relatedPerson.phone') and answer.exists())"/>
      </source>
      <rule>
        <name value="coverageSelfRelatedPersonPhone"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="relatedPerson"/>
          <contextType value="variable"/>
          <element value="telecom"/>
          <variable value="value"/>
        </target>
        <target>
          <context value="value"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="phone"/>
          </parameter>
        </target>
        <target>
          <context value="value"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="coverageSelfRelatedPersonEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'coverage.self.relatedPerson.email') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="itemAnswer"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'coverage.self.relatedPerson.streetAddressLine') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <rule>
        <name value="coverageSelfRelatedPersonStreetAddressLine"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="address"/>
          <contextType value="variable"/>
          <element value="line"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="coverageSelfRelatedPersonPostalCode"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'coverage.self.relatedPerson.postalCode') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="postalCode"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="coverageSelfRelatedPersonCity"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'coverage.self.relatedPerson.city') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="city"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="coverageSelfRelatedPersonCountry"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'coverage.self.relatedPerson.country') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="country"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SenderAuthorPractitionerItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.practitioner.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.practitioner.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerTitle"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.practitioner.title') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="prefix"/>
        <variable value="prefix"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
      <target>
        <context value="prefix"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="AC"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerGln"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.practitioner.gln') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.51.1.3"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerZsr"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.practitioner.zsr') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.16.756.5.30.1.123.100.2.1.1"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerPhone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.practitioner.phone') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="phone"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.practitioner.email') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SenderAuthorOrganizationItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="organization"/>
      <type value="Organization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.organization.name') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="name"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorOrganizationGln"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.organization.gln') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.51.1.3"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorOrganizationZsr"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.organization.zsr') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="urn:oid:2.16.756.5.30.1.123.100.2.1.1"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="itemAnswer"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.organization.streetAddressLine') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <rule>
        <name value="senderAuthorOrganizationStreetAddressLine"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="address"/>
          <contextType value="variable"/>
          <element value="line"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="senderAuthorOrganizationPostalCode"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.organization.postalCode') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="postalCode"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorOrganizationCity"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.organization.city') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="city"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorOrganizationCountry"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.author.organization.country') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="country"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SenderAuthorItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitionerRole"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="organization"/>
      <type value="Organization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="(linkId.value = 'sender.author.practitioner')"/>
      </source>
      <dependent>
        <name value="SenderAuthorPractitionerItems"/>
        <variable value="item"/>
        <variable value="practitioner"/>
      </dependent>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="(linkId.value = 'sender.author.organization')"/>
      </source>
      <dependent>
        <name value="SenderAuthorOrganizationItems"/>
        <variable value="item"/>
        <variable value="organization"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="SenderDataEntererPractitionerItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.dataenterer.practitioner.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.dataenterer.practitioner.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerPhone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.dataenterer.practitioner.phone') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="phone"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="senderAuthorPractitionerEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'sender.dataenterer.practitioner.email') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SenderDataEntererItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitionerRole"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="organization"/>
      <type value="Organization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'sender.dataenterer.practitioner')"/>
      </source>
      <dependent>
        <name value="SenderDataEntererPractitionerItems"/>
        <variable value="item"/>
        <variable value="practitioner"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="ChExtEprDataEnterer"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitionerRole"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="url"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-dataenterer"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="practitionerRole"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="enterer"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %practitionerRole.id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="SenderAuthorInit"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="sender"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitionerRole"/>
        <transform value="create"/>
        <parameter>
          <valueString value="PractitionerRole"/>
        </parameter>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e2"/>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e3"/>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="organization"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Organization"/>
        </parameter>
      </target>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid3"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="author"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="requester"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="practitioner"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="organization"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <rule>
        <name value="senderAuthor"/>
        <source>
          <context value="src"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="(linkId.value = 'sender.author')"/>
        </source>
        <dependent>
          <name value="SenderAuthorItems"/>
          <variable value="item"/>
          <variable value="practitionerRole"/>
          <variable value="practitioner"/>
          <variable value="organization"/>
        </dependent>
      </rule>
      <rule>
        <name value="senderDataenterer"/>
        <source>
          <context value="src"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="(linkId.value = 'sender.dataenterer')"/>
        </source>
        <rule>
          <name value="senderDataentererItems"/>
          <source>
            <context value="item"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e4"/>
          </target>
          <target>
            <context value="e4"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="practitionerRoleDataEnterer"/>
            <transform value="create"/>
            <parameter>
              <valueString value="PractitionerRole"/>
            </parameter>
          </target>
          <target>
            <context value="practitionerRoleDataEnterer"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid4"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e4"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid4"/>
            </parameter>
          </target>
          <target>
            <context value="composition"/>
            <contextType value="variable"/>
            <element value="extension"/>
            <variable value="extension"/>
          </target>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e5"/>
          </target>
          <target>
            <context value="e5"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="practitionerDataEnterer"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Practitioner"/>
            </parameter>
          </target>
          <target>
            <context value="practitionerDataEnterer"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid5"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e5"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid5"/>
            </parameter>
          </target>
          <target>
            <context value="practitionerRoleDataEnterer"/>
            <contextType value="variable"/>
            <element value="practitioner"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid5"/>
            </parameter>
          </target>
          <target>
            <context value="practitionerRoleDataEnterer"/>
            <contextType value="variable"/>
            <element value="organization"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid3"/>
            </parameter>
          </target>
          <rule>
            <name value="data"/>
            <source>
              <context value="item"/>
            </source>
            <dependent>
              <name value="SenderDataEntererItems"/>
              <variable value="item"/>
              <variable value="practitionerRoleDataEnterer"/>
              <variable value="practitionerDataEnterer"/>
              <variable value="organization"/>
            </dependent>
          </rule>
          <rule>
            <name value="extension"/>
            <source>
              <context value="item"/>
            </source>
            <dependent>
              <name value="ChExtEprDataEnterer"/>
              <variable value="item"/>
              <variable value="practitionerRoleDataEnterer"/>
              <variable value="extension"/>
            </dependent>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ReceiverCopyRelatedPersonItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="relatedPerson"/>
      <type value="RelatedPerson"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.relatedPerson.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="name"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.relatedPerson.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="name"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="Phone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.relatedPerson.phone') and answer.exists())"/>
      </source>
      <rule>
        <name value="receiverCopyRelatedPersonPhone"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="relatedPerson"/>
          <contextType value="variable"/>
          <element value="telecom"/>
          <variable value="value"/>
        </target>
        <target>
          <context value="value"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="phone"/>
          </parameter>
        </target>
        <target>
          <context value="value"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="receiverCopyRelatedPersonEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.relatedPerson.email') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="itemAnswer"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.relatedPerson.streetAddressLine') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <rule>
        <name value="receiverCopyRelatedPersonStreetAddressLine"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="address"/>
          <contextType value="variable"/>
          <element value="line"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="receiverCopyRelatedPersonPostalCode"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.relatedPerson.postalCode') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="postalCode"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverCopyRelatedPersonCity"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.relatedPerson.city') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="city"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverCopyRelatedPersonCountry"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.relatedPerson.country') and answer.exists())"/>
      </source>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="country"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="ReceiverCopyPractitionerItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="practitioner"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.practitionerRole.practitioner.familyName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="family"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.practitionerRole.practitioner.givenName') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="given"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverCopyPractitionerRolePractitionerTitle"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.practitionerRole.practitioner.title') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="name"/>
        <variable value="name"/>
        <listMode value="share"/>
        <listRuleId value="practitionerName"/>
      </target>
      <target>
        <context value="name"/>
        <contextType value="variable"/>
        <element value="prefix"/>
        <variable value="prefix"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
      <target>
        <context value="prefix"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier"/>
        </parameter>
      </target>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="AC"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverCopyPractitionerRolePractitionerPhone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.practitionerRole.practitioner.phone') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="phone"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverCopyPractitionerRolePractitionerEmail"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.practitionerRole.practitioner.email') and answer.exists())"/>
      </source>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="email"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="ReceiverCopyOrganizationItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="organization"/>
      <type value="Organization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.practitionerRole.organization.name') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="name"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="itemAnswer"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.practitionerRole.organization.streetAddressLine') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <rule>
        <name
              value="receiverCopyPractitionerRoleOrganizationStreetAddressLine"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <target>
          <context value="address"/>
          <contextType value="variable"/>
          <element value="line"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%answer.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="receiverCopyPractitionerRoleOrganizationPostalCode"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.practitionerRole.organization.postalCode') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="postalCode"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverCopyPractitionerRoleOrganizationCity"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.practitionerRole.organization.city') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="city"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="receiverCopyPractitionerRoleOrganizationCountry"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'receiverCopy.practitionerRole.organization.country') and answer.exists())"/>
      </source>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <listMode value="share"/>
        <listRuleId value="orgAddress"/>
      </target>
      <target>
        <context value="address"/>
        <contextType value="variable"/>
        <element value="country"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="ReceiverCopyPractitionerRoleItems"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="practitionerRole"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'receiverCopy.practitionerRole.practitioner')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e2"/>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="practitioner"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <dependent>
        <name value="ReceiverCopyPractitionerItems"/>
        <variable value="item"/>
        <variable value="practitioner"/>
      </dependent>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'receiverCopy.practitionerRole.organization')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e3"/>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="organization"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Organization"/>
        </parameter>
      </target>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid3"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="organization"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <dependent>
        <name value="ReceiverCopyOrganizationItems"/>
        <variable value="item"/>
        <variable value="organization"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="ExtOrfCopyReceiverPatient"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="url"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-copyreceiver"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="patient"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="ExtOrfCopyReceiverPractitionerRole"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="res"/>
      <type value="PractitionerRole"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="url"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-copyreceiver"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="organization"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %res.id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="ExtOrfCopyReceiverRelatedPerson"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="res"/>
      <type value="RelatedPerson"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="url"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-copyreceiver"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="organization"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %res.id"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="ReceiverCopy"/>
    <typeMode value="none"/>
    <input>
      <name value="grp"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="receiverCopyPractitionerRole1"/>
      <source>
        <context value="grp"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="(linkId = 'receiverCopy.practitionerRole')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitionerrole"/>
        <transform value="create"/>
        <parameter>
          <valueString value="PractitionerRole"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="extension"/>
      </target>
      <target>
        <context value="practitionerrole"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid4"/>
        </parameter>
      </target>
      <rule>
        <name value="data"/>
        <source>
          <context value="item"/>
        </source>
        <dependent>
          <name value="ReceiverCopyPractitionerRoleItems"/>
          <variable value="item"/>
          <variable value="bundle"/>
          <variable value="practitionerrole"/>
        </dependent>
      </rule>
      <rule>
        <name value="extension"/>
        <source>
          <context value="item"/>
        </source>
        <dependent>
          <name value="ExtOrfCopyReceiverPractitionerRole"/>
          <variable value="item"/>
          <variable value="practitionerrole"/>
          <variable value="extension"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="receiverCopyPatient"/>
      <source>
        <context value="grp"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="(linkId = 'receiverCopy.patient')"/>
      </source>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="extension"/>
      </target>
      <rule>
        <name value="extension"/>
        <source>
          <context value="item"/>
        </source>
        <dependent>
          <name value="ExtOrfCopyReceiverPatient"/>
          <variable value="item"/>
          <variable value="patient"/>
          <variable value="extension"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="receiverCopyRelatedPerson"/>
      <source>
        <context value="grp"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="(linkId = 'receiverCopy.relatedPerson')"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="relatedPerson"/>
        <transform value="create"/>
        <parameter>
          <valueString value="RelatedPerson"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="extension"/>
      </target>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="patient"/>
        <variable value="reference"/>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid4"/>
        </parameter>
      </target>
      <rule>
        <name value="data"/>
        <source>
          <context value="item"/>
        </source>
        <dependent>
          <name value="ReceiverCopyRelatedPersonItems"/>
          <variable value="item"/>
          <variable value="relatedPerson"/>
        </dependent>
      </rule>
      <rule>
        <name value="extension"/>
        <source>
          <context value="item"/>
        </source>
        <dependent>
          <name value="ExtOrfCopyReceiverRelatedPerson"/>
          <variable value="item"/>
          <variable value="relatedPerson"/>
          <variable value="extension"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Appointment"/>
    <typeMode value="none"/>
    <input>
      <name value="grp"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="Appointment"/>
      <source>
        <context value="grp"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="appointment"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Appointment"/>
        </parameter>
      </target>
      <target>
        <context value="appointment"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="extension"/>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-locationandtime"/>
        </parameter>
      </target>
      <target>
        <context value="extension"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %uuid4"/>
        </parameter>
      </target>
      <rule>
        <name value="proposed"/>
        <source>
          <context value="grp"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'appointment.status') and (answer.value.code = 'proposed'))"/>
        </source>
        <target>
          <context value="appointment"/>
          <contextType value="variable"/>
          <element value="status"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value.code"/>
          </parameter>
        </target>
        <rule>
          <name value="appointmentRequestedPeriod"/>
          <source>
            <context value="grp"/>
            <element value="item"/>
            <variable value="itemp"/>
            <condition
                       value="(linkId.value = 'appointment.requestedPeriod')"/>
          </source>
          <rule>
            <name value="appointmentRequestedPeriodStart"/>
            <source>
              <context value="itemp"/>
              <element value="item"/>
              <variable value="item2"/>
              <condition
                         value="((linkId.value = 'appointment.requestedPeriod.start') and answer.exists())"/>
            </source>
            <target>
              <context value="appointment"/>
              <contextType value="variable"/>
              <element value="requestedPeriod"/>
              <variable value="requestedPeriod"/>
            </target>
            <target>
              <context value="requestedPeriod"/>
              <contextType value="variable"/>
              <element value="start"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%item2.answer.value"/>
              </parameter>
            </target>
            <target>
              <context value="requestedPeriod"/>
              <contextType value="variable"/>
              <element value="end"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%item2.answer.value"/>
              </parameter>
            </target>
            <rule>
              <name value="appointmentRequestedPeriodendifnotsameasstart"/>
              <source>
                <context value="itemp"/>
                <element value="item"/>
                <variable value="item3"/>
                <condition
                           value="((linkId.value = 'appointment.requestedPeriod.end') and answer.exists())"/>
              </source>
              <target>
                <context value="requestedPeriod"/>
                <contextType value="variable"/>
                <element value="end"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="%item3.answer.value"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="pendingorbooked"/>
        <source>
          <context value="grp"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'appointment.status') and ((answer.value.code = 'pending') or (answer.value.code = 'booked')))"/>
        </source>
        <target>
          <context value="appointment"/>
          <contextType value="variable"/>
          <element value="status"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value.code"/>
          </parameter>
        </target>
        <rule>
          <name value="appointmentStartend"/>
          <source>
            <context value="grp"/>
            <element value="item"/>
            <variable value="itemp"/>
            <condition
                       value="(linkId.value = 'appointment.requestedPeriod')"/>
          </source>
          <rule>
            <name value="appointmentStart"/>
            <source>
              <context value="itemp"/>
              <element value="item"/>
              <variable value="item2"/>
              <condition
                         value="((linkId.value = 'appointment.requestedPeriod.start') and answer.exists())"/>
            </source>
            <target>
              <context value="appointment"/>
              <contextType value="variable"/>
              <element value="start"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%item2.answer.value"/>
              </parameter>
            </target>
            <target>
              <context value="appointment"/>
              <contextType value="variable"/>
              <element value="end"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%item2.answer.value"/>
              </parameter>
            </target>
            <rule>
              <name value="appointmentendifnotsameasstart"/>
              <source>
                <context value="itemp"/>
                <element value="item"/>
                <variable value="item3"/>
                <condition
                           value="((linkId.value = 'appointment.requestedPeriod.end') and answer.exists())"/>
              </source>
              <target>
                <context value="appointment"/>
                <contextType value="variable"/>
                <element value="end"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="%item3.answer.value"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="appointmentPatientInstruction"/>
        <source>
          <context value="grp"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'appointment.patientInstruction') and answer.exists())"/>
        </source>
        <target>
          <context value="appointment"/>
          <contextType value="variable"/>
          <element value="patientInstruction"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%item.answer.value"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="appointmentLocation"/>
        <source>
          <context value="grp"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="(linkId.value = 'appointment.location')"/>
        </source>
        <rule>
          <name value="location"/>
          <source>
            <context value="item"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e5"/>
          </target>
          <target>
            <context value="e5"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="location"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Location"/>
            </parameter>
          </target>
          <target>
            <context value="location"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid5"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e5"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %uuid5"/>
            </parameter>
          </target>
          <target>
            <context value="appointment"/>
            <contextType value="variable"/>
            <element value="participant"/>
            <variable value="participant"/>
          </target>
          <target>
            <context value="participant"/>
            <contextType value="variable"/>
            <element value="status"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="tentative"/>
            </parameter>
          </target>
          <target>
            <context value="participant"/>
            <contextType value="variable"/>
            <element value="actor"/>
            <variable value="actor"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="actor"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %location.id"/>
            </parameter>
          </target>
          <rule>
            <name value="item"/>
            <source>
              <context value="item"/>
              <element value="item"/>
              <variable value="item3"/>
              <condition
                         value="((linkId.value = 'appointment.location.name') and answer.exists())"/>
            </source>
            <target>
              <context value="location"/>
              <contextType value="variable"/>
              <element value="name"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%item3.answer.value"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="appointmentLocationPhone"/>
            <source>
              <context value="item"/>
              <element value="item"/>
              <variable value="item3"/>
              <condition
                         value="((linkId.value = 'appointment.location.phone') and answer.exists())"/>
            </source>
            <target>
              <context value="location"/>
              <contextType value="variable"/>
              <element value="telecom"/>
              <variable value="value"/>
            </target>
            <target>
              <context value="value"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="phone"/>
              </parameter>
            </target>
            <target>
              <context value="value"/>
              <contextType value="variable"/>
              <element value="value"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%item3.answer.value"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="appointmentLocationEmail"/>
            <source>
              <context value="item"/>
              <element value="item"/>
              <variable value="item3"/>
              <condition
                         value="((linkId.value = 'appointment.location.email') and answer.exists())"/>
            </source>
            <target>
              <context value="location"/>
              <contextType value="variable"/>
              <element value="telecom"/>
              <variable value="value"/>
            </target>
            <target>
              <context value="value"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="email"/>
              </parameter>
            </target>
            <target>
              <context value="value"/>
              <contextType value="variable"/>
              <element value="value"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%item3.answer.value"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="appointmentLocationStreetAddressLine"/>
            <source>
              <context value="item"/>
              <element value="item"/>
              <variable value="item3"/>
              <condition
                         value="((linkId.value = 'appointment.location.streetAddressLine') and answer.exists())"/>
            </source>
            <target>
              <context value="location"/>
              <contextType value="variable"/>
              <element value="address"/>
              <variable value="address"/>
              <listMode value="share"/>
              <listRuleId value="orgAddress"/>
            </target>
            <rule>
              <name value="line"/>
              <source>
                <context value="item"/>
                <element value="answer"/>
                <variable value="answer"/>
              </source>
              <target>
                <context value="address"/>
                <contextType value="variable"/>
                <element value="line"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="%answer.value"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="appointmentLocationPostalCode"/>
            <source>
              <context value="item"/>
              <element value="item"/>
              <variable value="item3"/>
              <condition
                         value="((linkId.value = 'appointment.location.postalCode') and answer.exists())"/>
            </source>
            <target>
              <context value="location"/>
              <contextType value="variable"/>
              <element value="address"/>
              <variable value="address"/>
              <listMode value="share"/>
              <listRuleId value="orgAddress"/>
            </target>
            <target>
              <context value="address"/>
              <contextType value="variable"/>
              <element value="postalCode"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%item3.answer.value"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="appointmentlocationCity"/>
            <source>
              <context value="item"/>
              <element value="item"/>
              <variable value="item3"/>
              <condition
                         value="((linkId.value = 'appointment.location.city') and answer.exists())"/>
            </source>
            <target>
              <context value="location"/>
              <contextType value="variable"/>
              <element value="address"/>
              <variable value="address"/>
              <listMode value="share"/>
              <listRuleId value="orgAddress"/>
            </target>
            <target>
              <context value="address"/>
              <contextType value="variable"/>
              <element value="city"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%item3.answer.value"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="appointmentLocationCountry"/>
            <source>
              <context value="item"/>
              <element value="item"/>
              <variable value="item3"/>
              <condition
                         value="((linkId.value = 'appointment.location.country') and answer.exists())"/>
            </source>
            <target>
              <context value="location"/>
              <contextType value="variable"/>
              <element value="address"/>
              <variable value="address"/>
              <listMode value="share"/>
              <listRuleId value="orgAddress"/>
            </target>
            <target>
              <context value="address"/>
              <contextType value="variable"/>
              <element value="country"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%item3.answer.value"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Note"/>
    <typeMode value="none"/>
    <input>
      <name value="grp"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="noteText"/>
      <source>
        <context value="grp"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="((linkId = 'note.text') and answer.exists())"/>
      </source>
      <target>
        <context value="serviceRequest"/>
        <contextType value="variable"/>
        <element value="note"/>
        <variable value="note"/>
      </target>
      <target>
        <context value="note"/>
        <contextType value="variable"/>
        <element value="text"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="%item.answer.value"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="QrToBundle"/>
    <typeMode value="none"/>
    <input>
      <name value="qr"/>
      <type value="QuestionnaireResponseSource"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="questionnaireresp"/>
      <type value="QuestionnaireResponse"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="servicerequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="id"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="type"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="type"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="document"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="composition"/>
      <source>
        <context value="qr"/>
      </source>
      <dependent>
        <name value="OrfComposition"/>
        <variable value="qr"/>
        <variable value="composition"/>
        <variable value="patient"/>
        <variable value="questionnaireresp"/>
        <variable value="servicerequest"/>
        <variable value="bundle"/>
      </dependent>
    </rule>
    <rule>
      <name value="qrgroups"/>
      <source>
        <context value="qr"/>
      </source>
      <dependent>
        <name value="QrToGroups"/>
        <variable value="qr"/>
        <variable value="patient"/>
        <variable value="bundle"/>
        <variable value="composition"/>
        <variable value="servicerequest"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="OrfComposition"/>
    <typeMode value="none"/>
    <documentation
                   value="group OrfComposition(source qr : QuestionnaireResponseSource, target q: Questionnaire, target tgt : Composition, target patient: Patient, target questionnaireresp: QuestionnaireResponse, target servicerequest: ServiceRequest, target bundle : Bundle) {"/>
    <input>
      <name value="qr"/>
      <type value="QuestionnaireResponseSource"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="questionnaireresp"/>
      <type value="QuestionnaireResponse"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="servicerequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="status"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="subject"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="subject"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="sections"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="section"/>
        <variable value="tgtSection"/>
      </target>
      <target>
        <context value="tgtSection"/>
        <contextType value="variable"/>
        <element value="title"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Order-Referral"/>
        </parameter>
      </target>
      <target>
        <context value="tgtSection"/>
        <contextType value="variable"/>
        <element value="code"/>
        <variable value="code"/>
      </target>
      <target>
        <context value="code"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://loinc.org"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="93037-0"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="display"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Portable medical order form"/>
        </parameter>
      </target>
      <target>
        <context value="tgtSection"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %questionnaireresp.id"/>
        </parameter>
      </target>
      <target>
        <context value="tgtSection"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %servicerequest.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="servicerequest"/>
      <source>
        <context value="qr"/>
      </source>
      <target>
        <context value="servicerequest"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="active"/>
        </parameter>
      </target>
      <target>
        <context value="servicerequest"/>
        <contextType value="variable"/>
        <element value="intent"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="order"/>
        </parameter>
      </target>
      <target>
        <context value="servicerequest"/>
        <contextType value="variable"/>
        <element value="subject"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %patient.id"/>
        </parameter>
      </target>
    </rule>
  </group>
</StructureMap>