CH ORF (R4)
2.0.0-ballot - ballot Switzerland flag

This page is part of the CH ORF (R4) (v2.0.0-ballot: STU 2 Ballot 1) based on FHIR R4. This is the current published version in its permanent home (it will always be available at this URL). For a full list of available versions, see the Directory of published versions

: Map ORF - XML Representation

Draft as of 2023-06-29

Raw xml | Download



<StructureMap xmlns="http://hl7.org/fhir">
  <id value="OrfQrToBundle"/>
  <text>
    <status value="additional"/>
    <div xmlns="http://www.w3.org/1999/xhtml">
      <pre>map &quot;http://fhir.ch/ig/ch-orf/StructureMap/OrfQrToBundle&quot; = &quot;OrfQrToBundle&quot;

//
// ORF QuestionnaireResponse to Bundle
// 2021-01-11 Oliver Egger, copyright ahdis ag, Apache License 
// 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

uses &quot;http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse&quot; alias QuestionnaireResponse as source
uses &quot;http://hl7.org/fhir/StructureDefinition/BackboneElement&quot; alias BackboneElement as source
uses &quot;http://hl7.org/fhir/StructureDefinition/Bundle&quot; alias Bundle as target
uses &quot;http://hl7.org/fhir/StructureDefinition/Composition&quot; alias Composition as target
uses &quot;http://hl7.org/fhir/StructureDefinition/Patient&quot; alias Patient as target
uses &quot;http://hl7.org/fhir/StructureDefinition/RelatedPerson&quot; alias RelatedPerson as target
uses &quot;http://hl7.org/fhir/StructureDefinition/Organization&quot; alias Organization as target
uses &quot;http://hl7.org/fhir/StructureDefinition/Practitioner&quot; alias Practitioner as target
uses &quot;http://hl7.org/fhir/StructureDefinition/PractitionerRole&quot; alias PractitionerRole as target
uses &quot;http://hl7.org/fhir/StructureDefinition/ServiceRequest&quot; alias ServiceRequest as target
uses &quot;http://hl7.org/fhir/StructureDefinition/Extension&quot; alias Extension as target
uses &quot;http://hl7.org/fhir/StructureDefinition/EpisodeOfCare&quot; alias EpisodeOfCare as target
uses &quot;http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse&quot; alias QuestionnaireResponseTarget as target

group OrfQrToBundle(source qr : QuestionnaireResponse, target bundle : Bundle ) {
      qr -&gt; bundle.identifier as documentIdentifier, documentIdentifier.system = 'urn:ietf:rfc:3986',  uuid() as uuidDoc, documentIdentifier.value = append('urn:uuid:', uuidDoc) &quot;documentIdentifier&quot;;
      qr as qrcp -&gt; bundle.entry as e, 
             e.resource = create('Composition') as composition, 
             composition.id = uuid() as uuid,
             e.fullUrl = append('urn:uuid:',uuid),
             bundle.entry as e2, 
             bundle.timestamp = (now()) as timestamp,
             composition.date = timestamp,
             composition.title = 'Order and Referral by Form',
             composition.type as type, type.coding as coding, coding.code = '419891008', coding.system = 'http://snomed.info/sct',
             composition.category as category, category.coding as coding, coding.code = '721963009', coding.system = 'http://snomed.info/sct',
             e2.resource = create('Patient') as patient,
             patient.id = uuid() as uuid2,
             e2.fullUrl = append('urn:uuid:',uuid2),
             bundle.entry as e4, 
             e4.resource = qrcp as questionnaireresp,
             questionnaireresp.id = uuid() as uuid4,
             e4.fullUrl = append('urn:uuid:',uuid4),
             bundle.entry as e5, 
             e5.resource = create('ServiceRequest') as servicerequest, 
             servicerequest.id = uuid() as uuid5,
             e5.fullUrl = append('urn:uuid:',uuid5) then {
               qr.questionnaire as can -&gt; bundle.entry as e6, e6.resource = (can.resolve()) as q, q.id = uuid() as uuid6, e6.fullUrl = append('urn:uuid:',uuid6) then QrToBundle(qr, q, patient, questionnaireresp, servicerequest, composition, bundle) &quot;orfbundle&quot;;
             } &quot;orfbundle&quot;;
}

group QrToGroups(source qr : QuestionnaireResponse, target patient : Patient, target bundle: Bundle, target composition : Composition, target serviceRequest: ServiceRequest) {
    qr.item as grp where linkId='order' then OrderItems(grp, bundle, composition, serviceRequest) &quot;grporder&quot;;
    qr.item as grp where linkId='receiver' then ReceiverInit(grp, bundle, composition, serviceRequest) &quot;receiver&quot;;
    qr.item as grp where linkId='initiator' then InitiatorInit(grp, bundle, patient, composition, serviceRequest) &quot;grpinitiator&quot;;
    qr.item as grp where linkId='patient' then PatientItems(grp, bundle, patient, composition, serviceRequest) &quot;grppatient&quot;;
    qr.item as grp where linkId='requestedEncounter' then RequestedEncounterItems(grp, bundle, patient, serviceRequest) &quot;grprequestedencounter&quot;;
    qr.item as grp where linkId='coverage' then Coverage(grp, bundle, patient, serviceRequest) &quot;grprequestedencounter&quot;;
    qr.item as grp where linkId='sender' then SenderAuthorInit(grp, bundle, composition, serviceRequest) &quot;grpsender&quot;;
    qr.item as grp where linkId='receiverCopy' then ReceiverCopy(grp, bundle, patient, composition, serviceRequest) &quot;receiverCopy&quot;;
    qr.item as grp where linkId='appointment' then Appointment(grp, bundle, composition, serviceRequest) &quot;appointment&quot;;
    qr.item as grp where linkId='previousResults' then PreviousResults(grp, bundle, serviceRequest) &quot;previousResults&quot;;
    qr.item as grp where linkId='antecedentEpisodeOfCare' then AntecedentEpisodeOfCareInit(grp, bundle, patient, composition) &quot;AntecedentEpisodeOfCareInit&quot;;
    qr.item as grp where linkId='consent' then Consent(grp, bundle, composition) &quot;consent&quot;;
    qr.item as grp where linkId='note' then Note(grp, serviceRequest) &quot;note&quot;;
}

group OrderItems(source src : BackboneElement, target bundle: Bundle, target composition, target serviceRequest : ServiceRequest) {

  src.item as item where (linkId.value = 'order.precedentDocumentIdentifier' and answer.exists())   -&gt; composition.extension as ext, ext.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-precedentdocument',
                                                                        ext.value = create('Identifier') as value, value.system='urn:ietf:rfc:3986', value.value=('urn:uuid:'+item.answer.valueString) &quot;order.precedentDocumentIdentifier&quot;; 

  src.item as item where (linkId.value = 'order.placerOrderIdentifier' and answer.exists()) -&gt; serviceRequest.identifier as value share placer, 
                                                                                   value.type as type, type.coding as coding,
                                                                                   coding.system = 'http://terminology.hl7.org/CodeSystem/v2-0203',
                                                                                   coding.code = 'PLAC',
                                                                                   value.value=(item.answer.valueString) &quot;order.placerOrderIdentifier&quot;; 
  src.item as item where (linkId.value = 'order.placerOrderIdentifierDomain' and answer.exists()) -&gt; serviceRequest.identifier as value share placer, 
                                                                                   value.system=(item.answer.valueString) &quot;order.placerOrderIdentifierDomain&quot;; 
  src.item as item where (linkId.value = 'order.fillerOrderIdentifier' and answer.exists()) -&gt; serviceRequest.identifier as value share filler, 
                                                                                   value.type as type, type.coding as coding,
                                                                                   coding.system = 'http://terminology.hl7.org/CodeSystem/v2-0203',
                                                                                   coding.code = 'FILL',
                                                                                   value.value=(item.answer.valueString) &quot;order.fillerOrderIdentifier&quot;; 
  src.item as item where (linkId.value = 'order.fillerOrderIdentifierDomain' and answer.exists()) -&gt; serviceRequest.identifier as value share filler, 
                                                                                   value.system=(item.answer.valueString) &quot;order.fillerOrderIdentifierDomain&quot;; 

  src.item as item where (linkId.value = 'order.dateTime' and answer.exists()) -&gt; serviceRequest.authoredOn = (item.answer.value);

  src.item as item where (linkId.value = 'order.priority' and answer.exists()) -&gt; serviceRequest.priority = (item.answer.value.code);

  src.item as item where (linkId.value = 'order.notificationContactDocument') then {
      item -&gt; bundle.entry as e4, 
               e4.resource = create('PractitionerRole') as practitionerRoleDataEnterer, 
               practitionerRoleDataEnterer.id = uuid() as uuid4,
               e4.fullUrl = append('urn:uuid:',uuid4),
               composition.extension as extension,
               bundle.entry as e5, 
               e5.resource = create('Practitioner') as practitionerDataEnterer, 
               practitionerDataEnterer.id = uuid() as uuid5,
               e5.fullUrl = append('urn:uuid:',uuid5),
               practitionerRoleDataEnterer.practitioner = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid5)
//   ,
// FIXME not known here               practitionerRoleDataEnterer.organization = create('Reference') as reference, reference.type='Organization', reference.reference = append('urn:uuid:',uuid3) 
               then {
                     item then UrgentNotificationContactForRequestItems(item, practitionerRoleDataEnterer, practitionerDataEnterer) &quot;data&quot;;
                     item then ExtOrfUrgentNotificationContactForRequest(item, practitionerRoleDataEnterer, extension) &quot;extension&quot;;
                  } &quot;order.notificationContactDocument.items&quot;;
      } &quot;order.notificationContactDocument&quot;;
   
   src.item as item where (linkId.value = 'order.notificationContactDocumentResponse') then {
      item -&gt; bundle.entry as e4, 
               e4.resource = create('PractitionerRole') as practitionerRoleDataEnterer, 
               practitionerRoleDataEnterer.id = uuid() as uuid4,
               e4.fullUrl = append('urn:uuid:',uuid4),
               composition.extension as extension,
               bundle.entry as e5, 
               e5.resource = create('Practitioner') as practitionerDataEnterer, 
               practitionerDataEnterer.id = uuid() as uuid5,
               e5.fullUrl = append('urn:uuid:',uuid5),
               practitionerRoleDataEnterer.practitioner = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid5)
// ,
// FIXME not known here practitionerRoleDataEnterer.organization = create('Reference') as reference, reference.type='Organization', reference.reference = append('urn:uuid:',uuid3) 
               then {
                     item then UrgentNotificationContactForResponseItems(item, practitionerRoleDataEnterer, practitionerDataEnterer) &quot;data&quot;;
                     item then ExtOrfUrgentNotificationContactForResponse(item, practitionerRoleDataEnterer, extension) &quot;extension&quot;;
                  } &quot;order.notificationContactDocumentResponse.items&quot;;
      } &quot;order.notificationContactDocumentResponse&quot;;
}

group UrgentNotificationContactForRequestPractitionerItems(source src : BackboneElement, target practitioner: Practitioner) {
   src.item as item where (linkId.value = 'order.notificationContactDocument.practitioner.familyName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'order.notificationContactDocument.practitioner.givenName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'order.notificationContactDocument.practitioner.title' and answer.exists()) -&gt; practitioner.name as name share practitionerName, 
                                                                        name.prefix = (item.answer.value) as prefix,
                                                                        prefix.extension as ext, ext.url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier',
                                                                        ext.value = create('code') as value, value.value='AC' &quot;sender.author.practitioner.title&quot;; 
     src.item as item where (linkId.value = 'order.notificationContactDocument.practitioner.phone' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'phone',
                                                                                   value.value=(item.answer.value) &quot;sender.author.practitioner.phone&quot;; 
   src.item as item where (linkId.value = 'order.notificationContactDocument.practitioner.email' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;sender.author.practitioner.email&quot;; 
}

group UrgentNotificationContactForRequestItems(source src : BackboneElement, target practitionerRole: practitionerRole, target practitioner : Practitioner) {
   src.item as item where (linkId.value = 'order.notificationContactDocument.practitioner') then UrgentNotificationContactForRequestPractitionerItems(item, practitioner);
}

group ExtOrfUrgentNotificationContactForRequest(source src: BackboneElement, target practitionerRole: PractitionerRole, target ext: Extension) {
  src -&gt; ext.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-urgentnoficationcontactforthisdocument' &quot;url&quot;;
  src -&gt; ext.value = create('Reference') as reference, 
                reference.reference = ('urn:uuid:'+%practitionerRole.id) &quot;practitionerRole&quot;;
}

group UrgentNotificationContactForResponsePractitionerItems(source src : BackboneElement, target practitioner: Practitioner) {
   src.item as item where (linkId.value = 'order.notificationContactDocumentResponse.practitioner.familyName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'order.notificationContactDocumentResponse.practitioner.givenName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'order.notificationContactDocumentResponse.practitioner.title' and answer.exists()) -&gt; practitioner.name as name share practitionerName, 
                                                                        name.prefix = (item.answer.value) as prefix,
                                                                        prefix.extension as ext, ext.url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier',
                                                                        ext.value = create('code') as value, value.value='AC' &quot;sender.author.practitioner.title&quot;; 
     src.item as item where (linkId.value = 'order.notificationContactDocumentResponse.practitioner.phone' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'phone',
                                                                                   value.value=(item.answer.value) &quot;sender.author.practitioner.phone&quot;; 
   src.item as item where (linkId.value = 'order.notificationContactDocumentResponse.practitioner.email' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;sender.author.practitioner.email&quot;; 
}

group UrgentNotificationContactForResponseItems(source src : BackboneElement, target practitionerRole: practitionerRole, target practitioner : Practitioner) {
   src.item as item where (linkId.value = 'order.notificationContactDocumentResponse.practitioner') then UrgentNotificationContactForResponsePractitionerItems(item, practitioner);
}

group ExtOrfUrgentNotificationContactForResponse(source src: BackboneElement, target practitionerRole: PractitionerRole, target ext: Extension) {
  src -&gt; ext.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-urgentnoficationcontactfortheresponsetothisdocument' &quot;url&quot;;
  src -&gt; ext.value = create('Reference') as reference, 
                 reference.reference = ('urn:uuid:'+%practitionerRole.id) &quot;practitionerRole&quot;;
}


group ReceiverPractitionerItems(source src : BackboneElement, target practitioner : Practitioner) {
   src.item as item where (linkId.value = 'receiver.practitioner.familyName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'receiver.practitioner.givenName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'receiver.practitioner.title' and answer.exists()) -&gt; practitioner.name as name share practitionerName, 
                                                                        name.prefix = (item.answer.value) as prefix,
                                                                        prefix.extension as ext, ext.url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier',
                                                                        ext.value = create('code') as value, value.value='AC' &quot;receiver.practitioner.title&quot;; 
   src.item as item where (linkId.value = 'receiver.practitioner.gln' and answer.exists()) -&gt; practitioner.identifier as value, 
                                                                                   value.system = 'urn:oid:2.51.1.3',
                                                                                   value.value=(item.answer.value) &quot;receiver.practitioner.gln&quot;; 
   src.item as item where (linkId.value = 'receiver.practitioner.zsr' and answer.exists()) -&gt; practitioner.identifier as value, 
                                                                                   value.system = 'urn:oid:2.16.756.5.30.1.123.100.2.1.1',
                                                                                   value.value=(item.answer.value) &quot;receiver.practitioner.zsr&quot;; 
   src.item as item where (linkId.value = 'receiver.practitioner.phone' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'phone',
                                                                                   value.value=(item.answer.value) &quot;receiver.practitioner.phone&quot;; 
   src.item as item where (linkId.value = 'receiver.practitioner.email' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;receiver.practitioner.email&quot;; 
}

group ReceiverOrganizationItems(source src : BackboneElement, target organization : Organization) {
   src.item as item where (linkId.value = 'receiver.organization.name' and answer.exists()) -&gt; organization.name = (item.answer.value);
   src.item as item where (linkId.value = 'receiver.organization.gln' and answer.exists()) -&gt; organization.identifier as value, 
                                                                                   value.system = 'urn:oid:2.51.1.3',
                                                                                   value.value=(item.answer.value) &quot;receiver.organization.gln&quot;;
   src.item as item where (linkId.value = 'receiver.organization.zsr' and answer.exists()) -&gt; organization.identifier as value, 
                                                                                   value.system = 'urn:oid:2.16.756.5.30.1.123.100.2.1.1',
                                                                                   value.value=(item.answer.value) &quot;receiver.organization.zsr&quot;; 
   src.item as item where (linkId.value = 'receiver.organization.streetAddressLine' and answer.exists()) -&gt; organization.address as address share orgAddress then {
     item.answer as answer -&gt; address.line = (answer.value) &quot;receiver.organization.streetAddressLine&quot;;
   } &quot;item.answer&quot;;
   src.item as item where (linkId.value = 'receiver.organization.postalCode' and answer.exists()) -&gt; organization.address as address share orgAddress, address.postalCode = (item.answer.value) &quot;receiver.organization.postalCode&quot;;
   src.item as item where (linkId.value = 'receiver.organization.city' and answer.exists()) -&gt; organization.address as address share orgAddress, address.city = (item.answer.value) &quot;receiver.organization.city&quot;;
   src.item as item where (linkId.value = 'receiver.organization.country' and answer.exists()) -&gt; organization.address as address share orgAddress, address.country = (item.answer.value) &quot;receiver.organization.country&quot;;
}

group ReceiverItems(source src : BackboneElement, target bundle: Bundle, target practitionerRole: practitionerRole) {
   src.item as item where (linkId.value = 'receiver.practitioner') -&gt; 
      bundle.entry as e2, 
      e2.resource = create('Practitioner') as practitioner, 
      practitioner.id = uuid() as uuid2,
      practitionerRole.practitioner = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid2),
      e2.fullUrl = append('urn:uuid:',uuid2) then ReceiverPractitionerItems(item, practitioner);
   src.item as item where (linkId.value = 'receiver.organization') -&gt;
     bundle.entry as e3, 
     e3.resource = create('Organization') as organization, 
     organization.id = uuid() as uuid3,
     practitionerRole.organization = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid3), 
     e3.fullUrl = append('urn:uuid:',uuid3) then ReceiverOrganizationItems(item, organization);
}

group Consent(source src : BackboneElement, target bundle: Bundle, target composition : Composition) {
   src.item as item where (linkId.value = 'consent.statement' and answer.exists()) -&gt; bundle.entry as e, 
          e.resource = create('Consent') as consent,
          consent.status = 'active', 
          consent.scope as scope, scope.coding as coding, coding.code = 'treatment', coding.system= 'http://terminology.hl7.org/CodeSystem/consentscope',
          consent.category as category, category.coding as coding, coding.code = '59284-0', coding.system= 'http://loinc.org',
          consent.policyRule as policyRule, policyRule.coding as coding, coding.code = '385432009', coding.system= 'http://snomed.info/sct',
          consent.id = uuid() as uuid,
          e.fullUrl = append('urn:uuid:',uuid),
          composition.extension as ext, 
          ext.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-patientconsent',
          ext.value = create('Reference') as reference, 
          consent.extension as extcode,
          extcode.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-consentcode',
          extcode.value = create('CodeableConcept') as cc, cc.coding = (item.answer.value),
          reference.reference = append('urn:uuid:',uuid) then {
            item.answer as answer then {
               answer.item as item where (linkId.value = 'consent.statement.note' and answer.exists())
               -&gt; consent.extension as extnote,
                  extnote.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-consentnote',
                  extnote.value = (item.answer.value) &quot;consent.statement.note&quot;;
            } &quot;item.answer&quot;;
          } &quot;consent.statement&quot;;
}

group ReceiverInit(source src : BackboneElement, target bundle: Bundle, target composition : Composition, target serviceRequest: ServiceRequest) {
   src -&gt; bundle.entry as e, 
          e.resource = create('PractitionerRole') as practitionerRole, 
          practitionerRole.id = uuid() as uuid,
          e.fullUrl = append('urn:uuid:',uuid),
          composition.extension as ext, 
          ext.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-receiver',
          ext.value = create('Reference') as reference, 
          reference.reference = append('urn:uuid:',uuid) then
          ReceiverItems(src, bundle, practitionerRole) &quot;receiver&quot;;
}

group InitiatorItems(source src : BackboneElement, target bundle: Bundle, target patient: Patient, target ext: Extension) {
   src.item as item where (linkId.value = 'initiator.personalrelation' and answer.exists()) -&gt; 
      ext.extension as extension, 
      extension.url = 'ch-orf-personalrelation', 
      extension.value = (item.answer.value) &quot;initiator.personalrelation&quot;;
   src.item as item where (linkId.value = 'initiator.legalrelation' and answer.exists()) -&gt; 
      ext.extension as extension, 
      extension.url = 'ch-orf-legalrelation', 
      extension.value = (item.answer.value) &quot;initiator.legalrelation&quot;;
   src.item as item where (linkId='initiator.practitionerRole') -&gt; bundle.entry as e4, 
      e4.resource = create('PractitionerRole') as practitionerrole, 
      ext.extension as extension,
      practitionerrole.id = uuid() as uuid4,
      extension.url = 'ch-orf-personorganization',
      extension.value =  create('Reference') as reference, 
      reference.reference = append('urn:uuid:',uuid4),
      e4.fullUrl = append('urn:uuid:',uuid4) then {
         item then InitiatorPractitionerRoleItems(item, bundle, practitionerrole) &quot;data&quot;;
      } &quot;InitiatorPractitionerRoleItems&quot;;
   src.item as item where (linkId='initiator.relatedPerson') -&gt; bundle.entry as e4, 
            e4.resource = create('RelatedPerson') as relatedPerson,
            ext.extension as extension, 
            extension.url = 'ch-orf-personorganization',
            extension.value =  create('Reference') as reference, 
            relatedPerson.id = uuid() as uuid4,
            reference.reference = append('urn:uuid:',uuid4),
            relatedPerson.patient as reference,
            reference.reference = ('urn:uuid:'+%patient.id),
            e4.fullUrl = append('urn:uuid:',uuid4) then {
               item then InitiatorRelatedPersonItems(item, relatedPerson) &quot;data&quot;;
            } &quot;initiator.relatedPerson&quot;;
}

group InitiatorRelatedPersonItems(source src : BackboneElement, target relatedPerson: RelatedPerson) {
   src.item as item where (linkId.value = 'initiator.relatedPerson.familyName' and answer.exists()) -&gt; relatedPerson.name as name share name, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'initiator.relatedPerson.givenName' and answer.exists()) -&gt; relatedPerson.name as name share name, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'initiator.relatedPerson.phone' and answer.exists()) then {
      item.answer as answer -&gt; relatedPerson.telecom as value, value.system = 'phone',
                                value.value= (answer.value) &quot;initiator.relatedPerson.phone&quot;; 
   } &quot;phone&quot;;
   src.item as item where (linkId.value = 'initiator.relatedPerson.email' and answer.exists()) -&gt; relatedPerson.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;initiator.relatedPerson.email&quot;; 
   src.item as item where (linkId.value = 'initiator.relatedPerson.streetAddressLine' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress then {
     item.answer as answer -&gt; address.line = (answer.value) &quot;initiator.relatedPerson.streetAddressLine&quot;;
   } &quot;item.answer&quot;;
   src.item as item where (linkId.value = 'initiator.relatedPerson.postalCode' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress, address.postalCode = (item.answer.value) &quot;initiator.relatedPerson.postalCode&quot;;
   src.item as item where (linkId.value = 'initiator.relatedPerson.city' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress, address.city = (item.answer.value) &quot;initiator.relatedPerson.city&quot;;
   src.item as item where (linkId.value = 'initiator.relatedPerson.country' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress, address.country = (item.answer.value) &quot;initiator.relatedPerson.country&quot;;
}


group InitiatorPractitionerRoleItems(source src : BackboneElement, target bundle: Bundle, target practitionerRole: practitionerRole) {
   src.item as item where (linkId.value = 'initiator.practitionerRole.practitioner') -&gt; 
      bundle.entry as e2, 
      e2.resource = create('Practitioner') as practitioner, 
      practitioner.id = uuid() as uuid2,
      practitionerRole.practitioner = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid2),
      e2.fullUrl = append('urn:uuid:',uuid2) then InitiatorPractitionerItems(item, practitioner);
   src.item as item where (linkId.value = 'initiator.practitionerRole.organization') -&gt;
     bundle.entry as e3, 
     e3.resource = create('Organization') as organization, 
     organization.id = uuid() as uuid3,
     practitionerRole.organization = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid3), 
     e3.fullUrl = append('urn:uuid:',uuid3) then InitiatorOrganizationItems(item, organization);
}

group InitiatorPractitionerItems(source src : BackboneElement, target practitioner : Practitioner) {
   src.item as item where (linkId.value = 'initiator.practitionerRole.practitioner.familyName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'initiator.practitionerRole.practitioner.givenName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'initiator.practitionerRole.practitioner.title' and answer.exists()) -&gt; practitioner.name as name share practitionerName, 
                                                                        name.prefix = (item.answer.value) as prefix,
                                                                        prefix.extension as ext, ext.url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier',
                                                                        ext.value = create('code') as value, value.value='AC' &quot;initiator.practitionerRole.practitioner.title&quot;; 
   src.item as item where (linkId.value = 'initiator.practitionerRole.practitioner.phone' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'phone',
                                                                                   value.value=(item.answer.value) &quot;initiator.practitionerRole.practitioner.phone&quot;; 
   src.item as item where (linkId.value = 'initiator.practitionerRole.practitioner.email' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;initiator.practitionerRole.practitioner.email&quot;; 
   src.item as item where (linkId.value = 'initiator.practitionerRole.practitioner.gln' and answer.exists()) -&gt; practitioner.identifier as value, 
                                                                                   value.system = 'urn:oid:2.51.1.3',
                                                                                   value.value=(item.answer.value) &quot;receiver.practitioner.gln&quot;; 
   src.item as item where (linkId.value = 'initiator.practitionerRole.practitioner.zsr' and answer.exists()) -&gt; practitioner.identifier as value, 
                                                                                   value.system = 'urn:oid:2.16.756.5.30.1.123.100.2.1.1',
                                                                                   value.value=(item.answer.value) &quot;receiver.practitioner.zsr&quot;; 
}

group InitiatorOrganizationItems(source src : BackboneElement, target organization : Organization) {
   src.item as item where (linkId.value = 'initiator.practitionerRole.organization.name' and answer.exists()) -&gt; organization.name = (item.answer.value);
   src.item as item where (linkId.value = 'initiator.practitionerRole.organization.streetAddressLine' and answer.exists()) -&gt; organization.address as address share orgAddress then {
     item.answer as answer -&gt; address.line = (answer.value) &quot;initiator.practitionerRole.organization.streetAddressLine&quot;;
   } &quot;item.answer&quot;;
   src.item as item where (linkId.value = 'initiator.practitionerRole.organization.postalCode' and answer.exists()) -&gt; organization.address as address share orgAddress, address.postalCode = (item.answer.value) &quot;initiator.practitionerRole.organization.postalCode&quot;;
   src.item as item where (linkId.value = 'initiator.practitionerRole.organization.city' and answer.exists()) -&gt; organization.address as address share orgAddress, address.city = (item.answer.value) &quot;initiator.practitionerRole.organization.city&quot;;
   src.item as item where (linkId.value = 'initiator.practitionerRole.organization.country' and answer.exists()) -&gt; organization.address as address share orgAddress, address.country = (item.answer.value) &quot;initiator.practitionerRole.organization.country&quot;;
}

group FamilyDoctorInit(source src : BackboneElement, target bundle: Bundle, target patient: Patient, target composition : Composition, target serviceRequest: ServiceRequest) {
  src -&gt; bundle.entry as e4, 
  e4.resource = create('PractitionerRole') as practitionerRole,
  practitionerRole.id = uuid() as uuid4,
  patient.generalPractitioner = create('Reference') as gp, 
  gp.reference = append('urn:uuid:',uuid4),
  e4.fullUrl = append('urn:uuid:',uuid4) then {
     src.item as item where (linkId.value = 'familydoctor.practitioner') -&gt; 
     bundle.entry as e2, 
     e2.resource = create('Practitioner') as practitioner, 
    practitioner.id = uuid() as uuid2,
     practitionerRole.practitioner = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid2),
     e2.fullUrl = append('urn:uuid:',uuid2) then FamilyDoctorPractitionerItems(item, practitioner);

     src.item as item where (linkId.value = 'familydoctor.organization') -&gt;
     bundle.entry as e3, 
     e3.resource = create('Organization') as organization, 
     organization.id = uuid() as uuid3,
     practitionerRole.organization = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid3), 
     e3.fullUrl = append('urn:uuid:',uuid3) then FamilyDoctorOrganizationItems(item, organization);
 } &quot;FamilyDoctorInit&quot;;
}

group FamilyDoctorPractitionerItems(source src : BackboneElement, target practitioner : Practitioner) {
   src.item as item where (linkId.value = 'familydoctor.practitioner.familyName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'familydoctor.practitioner.givenName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'familydoctor.practitioner.gln' and answer.exists()) -&gt; practitioner.identifier as value, 
                                                                                   value.system = 'urn:oid:2.51.1.3',
                                                                                   value.value=(item.answer.value) &quot;familydoctor.practitioner.gln&quot;; 
   src.item as item where (linkId.value = 'familydoctor.practitioner.zsr' and answer.exists()) -&gt; practitioner.identifier as value, 
                                                                                   value.system = 'urn:oid:2.16.756.5.30.1.123.100.2.1.1',
                                                                                   value.value=(item.answer.value) &quot;familydoctor.practitioner.zsr&quot;; 
   src.item as item where (linkId.value = 'familydoctor.practitioner.title' and answer.exists()) -&gt; practitioner.name as name share practitionerName, 
                                                                        name.prefix = (item.answer.value) as prefix,
                                                                        prefix.extension as ext, ext.url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier',
                                                                        ext.value = create('code') as value, value.value='AC' &quot;familydoctor.practitioner.title&quot;; 
   src.item as item where (linkId.value = 'familydoctor.practitioner.phone' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'phone',
                                                                                   value.value=(item.answer.value) &quot;familydoctor.practitioner.phone&quot;; 
   src.item as item where (linkId.value = 'familydoctor.practitioner.email' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;familydoctor.practitioner.email&quot;; 
}

group FamilyDoctorOrganizationItems(source src : BackboneElement, target organization : Organization) {
   src.item as item where (linkId.value = 'familydoctor.organization.name' and answer.exists()) -&gt; organization.name = (item.answer.value);
   src.item as item where (linkId.value = 'familydoctor.organization.streetAddressLine' and answer.exists()) -&gt; organization.address as address share orgAddress then {
     item.answer as answer -&gt; address.line = (answer.value) &quot;familydoctor.organization.streetAddressLine&quot;;
   } &quot;item.answer&quot;;
   src.item as item where (linkId.value = 'familydoctor.organization.postalCode' and answer.exists()) -&gt; organization.address as address share orgAddress, address.postalCode = (item.answer.value) &quot;familydoctor.organization.postalCode&quot;;
   src.item as item where (linkId.value = 'familydoctor.organization.city' and answer.exists()) -&gt; organization.address as address share orgAddress, address.city = (item.answer.value) &quot;familydoctor.organization.city&quot;;
   src.item as item where (linkId.value = 'familydoctor.organization.country' and answer.exists()) -&gt; organization.address as address share orgAddress, address.country = (item.answer.value) &quot;familydoctor.organization.country&quot;;
   src.item as item where (linkId.value = 'familydoctor.organization.gln' and answer.exists()) -&gt; organization.identifier as value, 
                                                                                   value.system = 'urn:oid:2.51.1.3',
                                                                                   value.value=(item.answer.value) &quot;familydoctor.organization.gln&quot;;
   src.item as item where (linkId.value = 'familydoctor.organization.zsr' and answer.exists()) -&gt; organization.identifier as value, 
                                                                                   value.system = 'urn:oid:2.16.756.5.30.1.123.100.2.1.1',
                                                                                   value.value=(item.answer.value) &quot;familydoctorr.organization.zsr&quot;; 
}

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

group AntecedentEpisodeOfCareItems(source src : BackboneElement, target bundle: Bundle, target tgt: Patient, target episodeofcare : EpisodeOfCare) {
   src.item as item where (linkId.value = 'antecedentEpisodeOfCare.start' and answer.exists()) -&gt; episodeofcare.statusHistory as statusHistory, statusHistory.status='finished', statusHistory.period as period, period.start = (item.answer.value), period.end = (item.answer.value) then {
        src.item as iteme where (linkId.value = 'antecedentEpisodeOfCare.end' and answer.exists()) -&gt; period.end = (iteme.answer.value) &quot;antecedentEpisodeOfCareEndNotSameAsStart&quot;;
   } &quot;antecedentEpisodeOfCare.requestedPeriod.start&quot;;
   src.item as item where (linkId.value = 'antecedentEpisodeOfCare.managingOrganization') -&gt; 
      bundle.entry as e3, 
          e3.resource = create('Organization') as organization, 
          organization.id = uuid() as uuid3,
          e3.fullUrl = append('urn:uuid:',uuid3),
          episodeofcare.patient = create('Reference') as reference, reference.reference = ('urn:uuid:'+%tgt.id),
          episodeofcare.managingOrganization = create('Reference') as reference, 
          reference.reference = append('urn:uuid:',uuid3) then AntecedentEpisodeOfCareOrganizationItems(item, organization) &quot;antecedentEpisodeOfCare.managingOrganization&quot;;
}

group AntecedentEpisodeOfCareOrganizationItems(source src : BackboneElement, target organization : Organization) {
   src.item as item where (linkId.value = 'antecedentEpisodeOfCare.managingOrganization.name' and answer.exists()) -&gt; organization.name = (item.answer.value);
   src.item as item where (linkId.value = 'antecedentEpisodeOfCare.managingOrganization.streetAddressLine' and answer.exists()) -&gt; organization.address as address share orgAddress then {
      item.answer as answer -&gt; address.line = (answer.value) &quot;antecedentEpisodeOfCareorganization.streetAddressLine&quot;;
   } &quot;item.answer&quot;;
   src.item as item where (linkId.value = 'antecedentEpisodeOfCare.managingOrganization.postalCode' and answer.exists()) -&gt; organization.address as address share orgAddress, address.postalCode = (item.answer.value) &quot;sender.author.organization.postalCode&quot;;
   src.item as item where (linkId.value = 'antecedentEpisodeOfCare.managingOrganization.city' and answer.exists()) -&gt; organization.address as address share orgAddress, address.city = (item.answer.value) &quot;sender.author.organization.city&quot;;
   src.item as item where (linkId.value = 'antecedentEpisodeOfCare.managingOrganization.country' and answer.exists()) -&gt; organization.address as address share orgAddress, address.country = (item.answer.value) &quot;sender.author.organization.country&quot;;
}

group InitiatorInit(source src : BackboneElement, target bundle: Bundle, target patient: Patient, target composition : Composition, target serviceRequest: ServiceRequest) {
   src -&gt; composition.extension as ext, 
          ext.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-initiator'
          then InitiatorItems(src, bundle, patient, ext) &quot;receiver&quot;;
}

group PatientItems(source src : BackboneElement, target bundle: Bundle, target tgt: Patient, target composition : Composition, target serviceRequest: ServiceRequest) {
  src.item as grp where linkId='familydoctor' then FamilyDoctorInit(grp, bundle, tgt, composition, serviceRequest) &quot;grpfamily&quot;;

  src.item as item then PatientItems(item, bundle, tgt, composition, serviceRequest);
  src.item as item where (linkId.value = 'patient.familyName' and answer.exists()) -&gt; tgt.name as name share patientName,name.family = (item.answer.value);
  src.item as item where (linkId.value = 'patient.maidenName' and answer.exists()) -&gt; tgt.name as name, name.use = 'maiden', name.family = (item.answer.value);
  src.item as item where (linkId.value = 'patient.givenName' and answer.exists()) -&gt; tgt.name as name share patientName, name.given = (item.answer.value);
  src.item as item where (linkId.value = 'patient.localPid' and answer.exists()) -&gt; tgt.identifier as value share localpid, 
                                                                                   value.type as type, type.coding as coding,
                                                                                   coding.system = 'http://terminology.hl7.org/CodeSystem/v2-0203',
                                                                                   coding.code = 'MR',
                                                                                   value.value=(item.answer.valueString) &quot;patient.localPid&quot;;
  src.item as item where (linkId.value = 'patient.localPidDomain' and answer.exists()) -&gt; tgt.identifier as value share localpid, 
                                                                                   value.system=(item.answer.valueString) &quot;patient.localPidDomain&quot;; 
  src.item as item where (linkId.value = 'patient.birthDate' and answer.exists()) -&gt; tgt.birthDate = (item.answer.value);
  src.item as item where (linkId.value = 'patient.gender' and answer.exists()) -&gt; tgt.gender = (item.answer.value.code);
  src.item as item where (linkId.value = 'patient.maritalStatus' and answer.exists()) then {
   item.answer as answer then {
      answer.value: Coding as coding -&gt; tgt.maritalStatus as maritalStatus, maritalStatus.coding = coding &quot;maritalStatus&quot;; 
      } &quot;answer&quot;;
  } &quot;patient.maritalStatus&quot;; 
  src.item as item where (linkId.value = 'patient.phone' and answer.exists()) then {
   item.answer as answer -&gt; tgt.telecom as value, value.system = 'phone', value.value=(answer.value) &quot;patient.phone&quot;;  
  } &quot;patient.phone&quot;;
  src.item as item where (linkId.value = 'patient.email' and answer.exists()) -&gt; tgt.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;patient.email&quot;; 
  src.item as item where (linkId.value = 'patient.streetAddressLine' and answer.exists()) -&gt; tgt.address as address share orgAddress then {
     item.answer as answer -&gt; address.line = (answer.value) &quot;patient.streetAddressLine&quot;;
  } &quot;item.answer&quot;;
  src.item as item where (linkId.value = 'patient.postalCode' and answer.exists()) -&gt; tgt.address as address share orgAddress, address.postalCode = (item.answer.value) &quot;patient.postalCode&quot;;
  src.item as item where (linkId.value = 'patient.city' and answer.exists()) -&gt; tgt.address as address share orgAddress, address.city = (item.answer.value) &quot;patient.city&quot;;
  src.item as item where (linkId.value = 'patient.country' and answer.exists()) -&gt; tgt.address as address share orgAddress, address.country = (item.answer.value) &quot;patient.country&quot;;

  src.item as item where (linkId.value = 'patient.languageOfCorrespondence' and answer.exists()) then {
   item.answer as answer then {
      answer.value: Coding as coding -&gt; tgt.communication as communication, communication.preferred = true, communication.language as language, language.coding = coding &quot;languageOfCorrespondence&quot;; 
      } &quot;answer&quot;;
  } &quot;patient.languageOfCorrespondence&quot;; 

  src.item as item where (linkId.value = 'patient.contactperson') -&gt; tgt.contact as contact then {
   item.item as item where (linkId.value = 'patient.contactperson.familyName' and answer.exists()) -&gt; contact.name as name share contactName,name.family = (item.answer.value);
   item.item as item where (linkId.value = 'patient.contactperson.givenName' and answer.exists()) -&gt; contact.name as name share contactName, name.given = (item.answer.value);

   src.item as item where (linkId.value = 'patient.contactperson.phone' and answer.exists()) then {
      item.answer as answer -&gt; tgt.telecom as value, value.system = 'phone', value.value=(answer.value) &quot;patient.phone&quot;;  
     } &quot;patient.contactperson.phone&quot;;
   
   item.item as item where (linkId.value = 'patient.contactperson.email' and answer.exists()) -&gt; contact.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;patient.email&quot;; 
   item.item as item where (linkId.value = 'patient.contactperson.relationship' and answer.exists()) -&gt; contact.relationship as relationship, 
                                                                                   relationship.text=(item.answer.value) &quot;patient.contactperson.relationship&quot;; 
  } &quot;contact&quot;;
}

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

 group Coverage(source src : BackboneElement, target bundle: Bundle, target patient: Patient, target serviceRequest : ServiceRequest) {
// coverage.beneficiary
// coverage.beneficiary.ahvn13
     src.item as item where where (linkId.value = 'coverage.beneficiary') then {
      item.item as item where (linkId.value = 'coverage.beneficiary.ahvn13' and answer.exists()) -&gt; 
         patient.identifier as identifier, identifier.system = 'urn:oid:2.16.756.5.32', identifier.value = (item.answer.value) &quot;coverage.beneficiary.ahvn13&quot;;
     } &quot;coverage.beneficiary&quot;;

//   coverage.kvg	
//   coverage.kvg.name	 
//   coverage.kvg.insuranceCardNumber	
      src.item as item where where (linkId.value = 'coverage.kvg') -&gt; bundle.entry as e4, 
      e4.resource = create('Coverage') as coverage, 
      coverage.id = uuid() as uuid4,
      e4.fullUrl = ('urn:uuid:'+%uuid4),
      serviceRequest.insurance as insurance, insurance.reference = ('urn:uuid:'+%uuid4),
      coverage.status = 'active',
      coverage.beneficiary = create('Reference') as subject, subject.reference = ('urn:uuid:'+%patient.id),
      coverage.type as type, type.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coveragetype', coding.code = 'KVG' then {
         item.item as item where (linkId.value = 'coverage.kvg.name' and answer.exists()) -&gt;
           coverage.payor as payor, payor.reference as refcontained, refcontained.value = '#org', 
           coverage.contained = create('Organization') as organization, organization.id = 'org', organization.name = (item.answer.value) &quot;coverage.kvg.name&quot;;
         item.item as item where (linkId.value = 'coverage.kvg.insuranceCardNumber' and answer.exists()) -&gt;
           coverage.identifier as identifier, identifier.type as typeid, typeid.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype', coding.code = 'VeKa', 
           identifier.value = (item.answer.value) &quot;coverage.kvg.insuranceCardNumber&quot;;
      } &quot;coveragekvg&quot;;
//   coverage.uvg	Unfallversicherung (nach UVG)	0..1	group		Definition: Coverage.type
//   coverage.uvg.name	Name der Versicherung	0..1	string		Definition: Coverage.payor
//   coverage.uvg.claimNumber	Schadennummer	0..1	string		Definition: Coverage.identifier
   src.item as item where where (linkId.value = 'coverage.uvg') -&gt; bundle.entry as e4, 
      e4.resource = create('Coverage') as coverage, 
      coverage.id = uuid() as uuid4,
      e4.fullUrl = ('urn:uuid:'+%uuid4),
      serviceRequest.insurance as insurance, insurance.reference = ('urn:uuid:'+%uuid4),
      coverage.status = 'active',
      coverage.beneficiary = create('Reference') as subject, subject.reference = ('urn:uuid:'+%patient.id),
      coverage.type as type, type.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coveragetype', coding.code = 'UVG' then {
         item.item as item where (linkId.value = 'coverage.uvg.name' and answer.exists()) -&gt;
           coverage.payor as payor, payor.reference as refcontained, refcontained.value = '#org', 
           coverage.contained = create('Organization') as organization, organization.id = 'org', organization.name = (item.answer.value) &quot;coverage.uvg.name&quot;;
         item.item as item where (linkId.value = 'coverage.uvg.claimNumber' and answer.exists()) -&gt;
           coverage.identifier as identifier, identifier.type as typeid, typeid.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype', coding.code = 'Claim', 
           identifier.value = (item.answer.value) &quot;coverage.uvg.claimNumber&quot;;
      } &quot;coverageuvg&quot;;
//  coverage.vvg	Zusatzversicherung (nach VVG)	0..1	group		Definition: Coverage.type
//  coverage.vvg.name	Name der Versicherung	0..1	string		Definition: Coverage.payor
//  coverage.vvg.insuranceCardNumber	Kennnummer der Versichertenkarte	0..1	string		Definition: Coverage.identifier
 src.item as item where where (linkId.value = 'coverage.vvg') -&gt; bundle.entry as e4, 
      e4.resource = create('Coverage') as coverage, 
      coverage.id = uuid() as uuid4,
      e4.fullUrl = ('urn:uuid:'+%uuid4),
      serviceRequest.insurance as insurance, insurance.reference = ('urn:uuid:'+%uuid4),
      coverage.status = 'active',
      coverage.beneficiary = create('Reference') as subject, subject.reference = ('urn:uuid:'+%patient.id),
      coverage.type as type, type.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coveragetype', coding.code = 'VVG' then {
         item.item as item where (linkId.value = 'coverage.vvg.name' and answer.exists()) -&gt;
           coverage.payor as payor, payor.reference as refcontained, refcontained.value = '#org', 
           coverage.contained = create('Organization') as organization, organization.id = 'org', organization.name = (item.answer.value) &quot;coverage.vvg.name&quot;;
         item.item as item where (linkId.value = 'coverage.vvg.insuranceCardNumber' and answer.exists()) -&gt;
           coverage.identifier as identifier, identifier.type as typeid, typeid.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype', coding.code = 'VeKa', 
           identifier.value = (item.answer.value) &quot;coverage.vvg.insuranceCardNumber&quot;;
      } &quot;coveragevvg&quot;;

// coverage.iv	Invalidenversicherung (IV)	0..1	group		Definition: Coverage.type
// coverage.iv.verfuegungsnummer
src.item as item where where (linkId.value = 'coverage.iv') -&gt; bundle.entry as e4, 
   e4.resource = create('Coverage') as coverage, 
   coverage.id = uuid() as uuid4,
   e4.fullUrl = ('urn:uuid:'+%uuid4),
   serviceRequest.insurance as insurance, insurance.reference = ('urn:uuid:'+%uuid4),
   coverage.status = 'active',
   coverage.beneficiary = create('Reference') as subject, subject.reference = ('urn:uuid:'+%patient.id),
   coverage.type as type, type.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coveragetype', coding.code = 'IVG' then {
      item.item as item where (linkId.value = 'coverage.iv.verfuegungsnummer' and answer.exists()) -&gt;
      coverage.identifier as identifier, identifier.type as typeid, typeid.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype', coding.code = 'IV', 
      identifier.value = (item.answer.value),
      coverage.payor as payor, payor.reference as refcontained, refcontained.value = '#org', 
      coverage.contained = create('Organization') as organization, organization.id = 'org', organization.name = 'IV' &quot;coverage.iv.verfuegungsnummer&quot;;
   } &quot;coverageiv&quot;;

 // coverage.mv	Militärversicherung (MV)	0..1	group		Definition: Coverage.type
// coverage.mv.versichertennummer
src.item as item where where (linkId.value = 'coverage.mv') -&gt; bundle.entry as e4, 
   e4.resource = create('Coverage') as coverage, 
   coverage.id = uuid() as uuid4,
   e4.fullUrl = ('urn:uuid:'+%uuid4),
   serviceRequest.insurance as insurance, insurance.reference = ('urn:uuid:'+%uuid4),
   coverage.status = 'active',
   coverage.beneficiary = create('Reference') as subject, subject.reference = ('urn:uuid:'+%patient.id),
   coverage.type as type, type.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coveragetype', coding.code = 'MVG' then {
      item.item as item where (linkId.value = 'coverage.mv.versichertennummer' and answer.exists()) -&gt;
      coverage.identifier as identifier, identifier.type as typeid, typeid.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coverageidentifiertype', coding.code = 'MV', 
      identifier.value = (item.answer.value),
      coverage.payor as payor, payor.reference as refcontained, refcontained.value = '#org', 
      coverage.contained = create('Organization') as organization, organization.id = 'org', organization.name = 'MV' &quot;coverage.mv.versichertennummer&quot;;
   } &quot;coveragemv&quot;;
      
   // coverage.self	Selbstzahler	0..1	group		Definition: Coverage.type
   // coverage.self.familyName	Name	0..1	string		Definition: Coverage.payor
   // coverage.self.givenName	Vorname	0..1	string		Definition: Coverage.payor
   src.item as item where where (linkId.value = 'coverage.self') then {
      
      item.item as item where (linkId.value = 'coverage.self.patient' and answer.exists() and answer.value) -&gt;
         bundle.entry as e4, 
         e4.resource = create('Coverage') as coverage, 
         coverage.id = uuid() as uuid4,
         e4.fullUrl = ('urn:uuid:'+%uuid4),
         serviceRequest.insurance as insurance, insurance.reference = ('urn:uuid:'+%uuid4),
         coverage.status = 'active',
         coverage.beneficiary = create('Reference') as subject, subject.reference = ('urn:uuid:'+%patient.id),
         coverage.type as type, type.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coveragetype', coding.code = 'Self',
         coverage.payor  as subject, subject.reference = ('urn:uuid:'+%patient.id) &quot;payor&quot;;

      item.item as item2 where (linkId.value = 'coverage.self.patientRelatedPerson' and answer.exists() and answer.value) then {        
            item.item as item where (linkId.value = 'coverage.self.relatedPerson') -&gt;
            bundle.entry as e5, 
            e5.resource = create('Coverage') as coverage, 
            coverage.id = uuid() as uuid4,
            e5.fullUrl = ('urn:uuid:'+%uuid4),
            serviceRequest.insurance as insurance, insurance.reference = ('urn:uuid:'+%uuid4),
            coverage.status = 'active',
            coverage.beneficiary = create('Reference') as subject, subject.reference = ('urn:uuid:'+%patient.id),
            coverage.type as type, type.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coveragetype', coding.code = 'Self',
            bundle.entry as e6, 
            e6.resource = create('RelatedPerson') as relatedPerson, 
            relatedPerson.id = uuid() as uuid6,
            e6.fullUrl = append('urn:uuid:',uuid6),
            coverage.payor as subject, subject.reference = ('urn:uuid:'+%relatedPerson.id),
            relatedPerson.patient as reference, reference.reference = ('urn:uuid:'+%patient.id)
            then 
              CoverageRelatedPersonItems(item,relatedPerson) &quot;coverage.self.relatedPerson&quot;;
      } &quot;coverage.self.patientrelated.&quot;;
   } &quot;self&quot;;
 
// coverage.other	Anderer Kostenträger	0..1	group		Definition: Coverage.type
// coverage.other.name	Name des Kostenträgers	0..1	string		Definition: Coverage.payor
// coverage.other.id	Beliebige ID	0..1	string		Definition: Coverage.identifier
// coverage.other.id.note TODO
   src.item as item where where (linkId.value = 'coverage.other') -&gt; bundle.entry as e4, 
   e4.resource = create('Coverage') as coverage, 
   coverage.id = uuid() as uuid4,
   e4.fullUrl = ('urn:uuid:'+%uuid4),
   serviceRequest.insurance as insurance, insurance.reference = ('urn:uuid:'+%uuid4),
   coverage.status = 'active',
   coverage.beneficiary = create('Reference') as subject, subject.reference = ('urn:uuid:'+%patient.id),
   coverage.type as type, type.coding as coding, coding.system = 'http://fhir.ch/ig/ch-orf/CodeSystem/ch-orf-cs-coveragetype', coding.code = 'Other' then {
      item.item as item where (linkId.value = 'coverage.other.name' and answer.exists()) -&gt;
      coverage.payor as payor, payor.reference as refcontained, refcontained.value = '#org', 
      coverage.contained = create('Organization') as organization, organization.id = 'org', organization.name = (item.answer.value) &quot;coverage.other.name&quot;;
      item.item as item where (linkId.value = 'coverage.other.id' and answer.exists()) -&gt;
      coverage.identifier as identifier, identifier.value = (item.answer.value) &quot;coverage.other.id&quot;;
   } &quot;coveragevvg&quot;;
}

group CoverageRelatedPersonItems(source src : BackboneElement, target relatedPerson: RelatedPerson) {
   src.item as item where (linkId.value = 'coverage.self.relatedPerson.familyName' and answer.exists()) -&gt; relatedPerson.name as name share name, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'coverage.self.relatedPerson.givenName' and answer.exists()) -&gt; relatedPerson.name as name share name, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'coverage.self.relatedPerson.phone' and answer.exists()) then {
      item.answer as answer -&gt; relatedPerson.telecom as value, value.system = 'phone',
                                value.value= (answer.value) &quot;coverage.self.relatedPerson.phone&quot;; 
   } &quot;phone&quot;;
   src.item as item where (linkId.value = 'coverage.self.relatedPerson.email' and answer.exists()) -&gt; relatedPerson.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;coverage.self.relatedPerson.email&quot;; 
   src.item as item where (linkId.value = 'coverage.self.relatedPerson.streetAddressLine' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress then {
     item.answer as answer -&gt; address.line = (answer.value) &quot;coverage.self.relatedPerson.streetAddressLine&quot;;
   } &quot;item.answer&quot;;
   src.item as item where (linkId.value = 'coverage.self.relatedPerson.postalCode' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress, address.postalCode = (item.answer.value) &quot;coverage.self.relatedPerson.postalCode&quot;;
   src.item as item where (linkId.value = 'coverage.self.relatedPerson.city' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress, address.city = (item.answer.value) &quot;coverage.self.relatedPerson.city&quot;;
   src.item as item where (linkId.value = 'coverage.self.relatedPerson.country' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress, address.country = (item.answer.value) &quot;coverage.self.relatedPerson.country&quot;;
}


group SenderAuthorPractitionerItems(source src : BackboneElement, target practitioner: Practitioner) {
   src.item as item where (linkId.value = 'sender.author.practitioner.familyName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'sender.author.practitioner.givenName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'sender.author.practitioner.title' and answer.exists()) -&gt; practitioner.name as name share practitionerName, 
                                                                        name.prefix = (item.answer.value) as prefix,
                                                                        prefix.extension as ext, ext.url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier',
                                                                        ext.value = create('code') as value, value.value='AC' &quot;sender.author.practitioner.title&quot;; 
   src.item as item where (linkId.value = 'sender.author.practitioner.gln' and answer.exists()) -&gt; practitioner.identifier as value, 
                                                                                   value.system = 'urn:oid:2.51.1.3',
                                                                                   value.value=(item.answer.value) &quot;sender.author.practitioner.gln&quot;; 
   src.item as item where (linkId.value = 'sender.author.practitioner.zsr' and answer.exists()) -&gt; practitioner.identifier as value, 
                                                                                   value.system = 'urn:oid:2.16.756.5.30.1.123.100.2.1.1',
                                                                                   value.value=(item.answer.value) &quot;recsender.author.practitioner.zsr&quot;; 
   src.item as item where (linkId.value = 'sender.author.practitioner.phone' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'phone',
                                                                                   value.value=(item.answer.value) &quot;sender.author.practitioner.phone&quot;; 
   src.item as item where (linkId.value = 'sender.author.practitioner.email' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;sender.author.practitioner.email&quot;; 
}

group SenderAuthorOrganizationItems(source src : BackboneElement, target organization: Organization) {
   src.item as item where (linkId.value = 'sender.author.organization.name' and answer.exists()) -&gt; organization.name = (item.answer.value);
   src.item as item where (linkId.value = 'sender.author.organization.gln' and answer.exists()) -&gt; organization.identifier as value, 
                                                                                   value.system = 'urn:oid:2.51.1.3',
                                                                                   value.value=(item.answer.value) &quot;sender.author.organization.gln&quot;;
   src.item as item where (linkId.value = 'sender.author.organization.zsr' and answer.exists()) -&gt; organization.identifier as value, 
                                                                                   value.system = 'urn:oid:2.16.756.5.30.1.123.100.2.1.1',
                                                                                   value.value=(item.answer.value) &quot;sender.author.organization.zsr&quot;; 
   src.item as item where (linkId.value = 'sender.author.organization.streetAddressLine' and answer.exists()) -&gt; organization.address as address share orgAddress then {
     item.answer as answer -&gt; address.line = (answer.value) &quot;sender.author.organization.streetAddressLine&quot;;
   } &quot;item.answer&quot;;
   src.item as item where (linkId.value = 'sender.author.organization.postalCode' and answer.exists()) -&gt; organization.address as address share orgAddress, address.postalCode = (item.answer.value) &quot;sender.author.organization.postalCode&quot;;
   src.item as item where (linkId.value = 'sender.author.organization.city' and answer.exists()) -&gt; organization.address as address share orgAddress, address.city = (item.answer.value) &quot;sender.author.organization.city&quot;;
   src.item as item where (linkId.value = 'sender.author.organization.country' and answer.exists()) -&gt; organization.address as address share orgAddress, address.country = (item.answer.value) &quot;sender.author.organization.country&quot;;
}

group SenderAuthorItems(source src : BackboneElement, target practitionerRole: practitionerRole, target practitioner : Practitioner, target organization: Organization) {
   src.item as item where (linkId.value = 'sender.author.practitioner') then SenderAuthorPractitionerItems(item, practitioner);
   src.item as item where (linkId.value = 'sender.author.organization') then SenderAuthorOrganizationItems(item, organization);
}

group SenderDataEntererPractitionerItems(source src : BackboneElement, target practitioner: Practitioner) {
   src.item as item where (linkId.value = 'sender.dataenterer.practitioner.familyName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'sender.dataenterer.practitioner.givenName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'sender.dataenterer.practitioner.phone' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'phone',
                                                                                   value.value=(item.answer.value) &quot;sender.author.practitioner.phone&quot;; 
   src.item as item where (linkId.value = 'sender.dataenterer.practitioner.email' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;sender.author.practitioner.email&quot;; 
}

group SenderDataEntererItems(source src : BackboneElement, target practitionerRole: practitionerRole, target practitioner : Practitioner, target organization: Organization) {
   src.item as item where (linkId.value = 'sender.dataenterer.practitioner') then SenderDataEntererPractitionerItems(item, practitioner);
}

group ChExtEprDataEnterer(source src: BackboneElement, target practitionerRole: PractitionerRole, target ext: Extension) {
  src -&gt; ext.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-dataenterer' &quot;url&quot;;
  src -&gt; ext.extension as ext, ext.url='enterer', ext.value = create('Reference') as reference, 
                 reference.reference = ('urn:uuid:'+%practitionerRole.id) &quot;practitionerRole&quot;;
}

group SenderAuthorInit(source src : BackboneElement, target bundle: Bundle, target composition : Composition, target serviceRequest: ServiceRequest) {
   src -&gt; bundle.entry as e, 
          e.resource = create('PractitionerRole') as practitionerRole, 
          practitionerRole.id = uuid() as uuid,
          e.fullUrl = append('urn:uuid:',uuid),
          bundle.entry as e2, 
          e2.resource = create('Practitioner') as practitioner, 
          practitioner.id = uuid() as uuid2,
          e2.fullUrl = append('urn:uuid:',uuid2),
          bundle.entry as e3, 
          e3.resource = create('Organization') as organization, 
          organization.id = uuid() as uuid3,
          e3.fullUrl = append('urn:uuid:',uuid3),
          composition.author = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid),
          serviceRequest.requester = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid),
          practitionerRole.practitioner = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid2),
          practitionerRole.organization = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid3) then {
             src.item as item where (linkId.value = 'sender.author') then SenderAuthorItems(item, practitionerRole, practitioner, organization) &quot;sender.author&quot;;
             src.item as item where (linkId.value = 'sender.dataenterer') then {
               item -&gt; bundle.entry as e4, 
                      e4.resource = create('PractitionerRole') as practitionerRoleDataEnterer, 
                      practitionerRoleDataEnterer.id = uuid() as uuid4,
                      e4.fullUrl = append('urn:uuid:',uuid4),
                      composition.extension as extension,
                      bundle.entry as e5, 
                      e5.resource = create('Practitioner') as practitionerDataEnterer, 
                      practitionerDataEnterer.id = uuid() as uuid5,
                      e5.fullUrl = append('urn:uuid:',uuid5),
                      practitionerRoleDataEnterer.practitioner = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid5),
                      practitionerRoleDataEnterer.organization = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid3) 
                      then {
                            item then SenderDataEntererItems(item, practitionerRoleDataEnterer, practitionerDataEnterer, organization) &quot;data&quot;;
                            item then ChExtEprDataEnterer(item, practitionerRoleDataEnterer, extension) &quot;extension&quot;;
                         } &quot;sender.dataenterer.items&quot;;
             } &quot;sender.dataenterer&quot;;
          } &quot;sender&quot;;
}

group ReceiverCopyRelatedPersonItems(source src : BackboneElement, target relatedPerson: RelatedPerson) {
   src.item as item where (linkId.value = 'receiverCopy.relatedPerson.familyName' and answer.exists()) -&gt; relatedPerson.name as name share name, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'receiverCopy.relatedPerson.givenName' and answer.exists()) -&gt; relatedPerson.name as name share name, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'receiverCopy.relatedPerson.phone' and answer.exists()) then {
      item.answer as answer -&gt; relatedPerson.telecom as value, value.system = 'phone',
                                value.value= (answer.value) &quot;receiverCopy.relatedPerson.phone&quot;; 
   } &quot;phone&quot;;
   src.item as item where (linkId.value = 'receiverCopy.relatedPerson.email' and answer.exists()) -&gt; relatedPerson.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;receiverCopy.relatedPerson.email&quot;; 
   src.item as item where (linkId.value = 'receiverCopy.relatedPerson.streetAddressLine' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress then {
     item.answer as answer -&gt; address.line = (answer.value) &quot;receiverCopy.relatedPerson.streetAddressLine&quot;;
   } &quot;item.answer&quot;;
   src.item as item where (linkId.value = 'receiverCopy.relatedPerson.postalCode' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress, address.postalCode = (item.answer.value) &quot;receiverCopy.relatedPerson.postalCode&quot;;
   src.item as item where (linkId.value = 'receiverCopy.relatedPerson.city' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress, address.city = (item.answer.value) &quot;receiverCopy.relatedPerson.city&quot;;
   src.item as item where (linkId.value = 'receiverCopy.relatedPerson.country' and answer.exists()) -&gt; relatedPerson.address as address share orgAddress, address.country = (item.answer.value) &quot;receiverCopy.relatedPerson.country&quot;;
}

group ReceiverCopyPractitionerItems(source src : BackboneElement, target practitioner : Practitioner) {
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.practitioner.familyName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.family = (item.answer.value);
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.practitioner.givenName' and answer.exists()) -&gt; practitioner.name as name share practitionerName, name.given = (item.answer.value);
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.practitioner.title' and answer.exists()) -&gt; practitioner.name as name share practitionerName, 
                                                                        name.prefix = (item.answer.value) as prefix,
                                                                        prefix.extension as ext, ext.url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier',
                                                                        ext.value = create('code') as value, value.value='AC' &quot;receiverCopy.practitionerRole.practitioner.title&quot;; 
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.practitioner.phone' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'phone',
                                                                                   value.value=(item.answer.value) &quot;receiverCopy.practitionerRole.practitioner.phone&quot;; 
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.practitioner.email' and answer.exists()) -&gt; practitioner.telecom as value, 
                                                                                   value.system = 'email',
                                                                                   value.value=(item.answer.value) &quot;receiverCopy.practitionerRole.practitioner.email&quot;; 
}

group ReceiverCopyOrganizationItems(source src : BackboneElement, target organization : Organization) {
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.organization.name' and answer.exists()) -&gt; organization.name = (item.answer.value);
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.organization.streetAddressLine' and answer.exists()) -&gt; organization.address as address share orgAddress then {
     item.answer as answer -&gt; address.line = (answer.value) &quot;receiverCopy.practitionerRole.organization.streetAddressLine&quot;;
   } &quot;item.answer&quot;;
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.organization.postalCode' and answer.exists()) -&gt; organization.address as address share orgAddress, address.postalCode = (item.answer.value) &quot;receiverCopy.practitionerRole.organization.postalCode&quot;;
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.organization.city' and answer.exists()) -&gt; organization.address as address share orgAddress, address.city = (item.answer.value) &quot;receiverCopy.practitionerRole.organization.city&quot;;
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.organization.country' and answer.exists()) -&gt; organization.address as address share orgAddress, address.country = (item.answer.value) &quot;receiverCopy.practitionerRole.organization.country&quot;;
}

group ReceiverCopyPractitionerRoleItems(source src : BackboneElement, target bundle: Bundle, target practitionerRole: practitionerRole) {
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.practitioner') -&gt; 
      bundle.entry as e2, 
      e2.resource = create('Practitioner') as practitioner, 
      practitioner.id = uuid() as uuid2,
      practitionerRole.practitioner = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid2),
      e2.fullUrl = append('urn:uuid:',uuid2) then ReceiverCopyPractitionerItems(item, practitioner);
   src.item as item where (linkId.value = 'receiverCopy.practitionerRole.organization') -&gt;
     bundle.entry as e3, 
     e3.resource = create('Organization') as organization, 
     organization.id = uuid() as uuid3,
     practitionerRole.organization = create('Reference') as reference, reference.reference = append('urn:uuid:',uuid3), 
     e3.fullUrl = append('urn:uuid:',uuid3) then ReceiverCopyOrganizationItems(item, organization);
}

group ExtOrfCopyReceiverPatient(source src: BackboneElement, target patient: Patient, target ext: Extension) {
  src -&gt; ext.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-copyreceiver' &quot;url&quot;;
  src -&gt; ext.value = create('Reference') as reference, 
                reference.reference = ('urn:uuid:'+%patient.id) &quot;patient&quot;;
}

group ExtOrfCopyReceiver(source src: BackboneElement, target res, target ext: Extension) {
  src -&gt; ext.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-copyreceiver' &quot;url&quot;;
  src -&gt; ext.value = create('Reference') as reference, 
                reference.reference = ('urn:uuid:'+%res.id) &quot;organization&quot;;
}

group ReceiverCopy(source grp : BackboneElement, target bundle: Bundle, target patient: Patient, target composition : Composition, target serviceRequest: ServiceRequest) {
  grp.item as item where (linkId='receiverCopy.practitionerRole') -&gt; bundle.entry as e4, 
            e4.resource = create('PractitionerRole') as practitionerrole, 
            composition.extension as extension,
            practitionerrole.id = uuid() as uuid4,
            e4.fullUrl = append('urn:uuid:',uuid4) then {
               item then ReceiverCopyPractitionerRoleItems(item, bundle, practitionerrole) &quot;data&quot;;
               item then ExtOrfCopyReceiver(item, practitionerrole, extension) &quot;extension&quot;;
            } &quot;receiverCopyPractitionerRole1&quot;;
   grp.item as item where (linkId='receiverCopy.patient') -&gt;  
            composition.extension as extension then {
               item then ExtOrfCopyReceiver(item, patient, extension) &quot;extension&quot;;
            } &quot;receiverCopyPractitionerRole2&quot;;
   grp.item as item where (linkId='receiverCopy.relatedPerson') -&gt; bundle.entry as e4, 
            e4.resource = create('RelatedPerson') as relatedPerson, 
            composition.extension as extension,
            relatedPerson.id = uuid() as uuid4,
            relatedPerson.patient as reference,
            reference.reference = ('urn:uuid:'+%patient.id),
            e4.fullUrl = append('urn:uuid:',uuid4) then {
               item then ReceiverCopyRelatedPersonItems(item, relatedPerson) &quot;data&quot;;
               item then ExtOrfCopyReceiver(item, relatedPerson, extension) &quot;extension&quot;;
            } &quot;receiverCopyPractitionerRole3&quot;;
}

group Appointment(source grp : BackboneElement, target bundle: Bundle, target composition : Composition, target serviceRequest: ServiceRequest) {
   grp.item -&gt; bundle.entry as e4, 
   e4.resource = create('Appointment') as appointment, 
   appointment.id = uuid() as uuid4,
   e4.fullUrl = ('urn:uuid:'+%uuid4),
   serviceRequest.extension as extension,
   extension.url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-locationandtime',
   extension.value = create('Reference') as reference, reference.reference = ('urn:uuid:'+%uuid4)                
   then {
      grp.item as item where (linkId.value = 'appointment.status' and answer.value.code='proposed') -&gt; appointment.status = (item.answer.value.code) then {
         grp.item as itemp where (linkId.value = 'appointment.requestedPeriod') then {
           itemp.item as item2 where (linkId.value = 'appointment.requestedPeriod.start' and answer.exists()) -&gt; appointment.requestedPeriod as requestedPeriod, requestedPeriod.start = (item2.answer.value), requestedPeriod.end = (item2.answer.value) then {
           itemp.item as item3 where (linkId.value = 'appointment.requestedPeriod.end' and answer.exists()) -&gt; requestedPeriod.end = (item3.answer.value) &quot;appointment.requestedPeriod.end.if.not.same.as.start&quot;;
           } &quot;appointment.requestedPeriod.start&quot;;
         } &quot;appointment.requestedPeriod&quot;;
      } &quot;proposed&quot;;
      grp.item as item where (linkId.value = 'appointment.status' and (answer.value.code='pending' or answer.value.code='booked')) -&gt; appointment.status = (item.answer.value.code) then {
         grp.item as itemp where (linkId.value = 'appointment.requestedPeriod') then {
           itemp.item as item2 where (linkId.value = 'appointment.requestedPeriod.start' and answer.exists()) -&gt; appointment.start = (item2.answer.value), appointment.end = (item2.answer.value) then {
           itemp.item as item3 where (linkId.value = 'appointment.requestedPeriod.end' and answer.exists()) -&gt; appointment.end = (item3.answer.value) &quot;appointment.end.if.not.same.as.start&quot;;
           } &quot;appointment.start&quot;;
         } &quot;appointment.startend&quot;;
      } &quot;pendingorbooked&quot;;
      grp.item as item where (linkId.value = 'appointment.patientInstruction' and answer.exists()) -&gt; appointment.patientInstruction = (item.answer.value) &quot;appointment.patientInstruction&quot;;
      grp.item as item where (linkId.value = 'appointment.location') then {
         item -&gt; bundle.entry as e5, 
         e5.resource = create('Location') as location, 
         location.id = uuid() as uuid5,
         e5.fullUrl = ('urn:uuid:'+%uuid5),
         appointment.participant as participant, participant.status = 'tentative', participant.actor = create('Reference') as actor, actor.reference = ('urn:uuid:'+%location.id) then {
            item.item as item3 where (linkId.value = 'appointment.location.name' and answer.exists()) -&gt; location.name = (item3.answer.value);
            item.item as item3 where (linkId.value = 'appointment.location.phone' and answer.exists()) -&gt; location.telecom as value, value.system = 'phone', value.value=(item3.answer.value) &quot;appointment.location.phone&quot;; 
            item.item as item3 where (linkId.value = 'appointment.location.email' and answer.exists()) -&gt; location.telecom as value, value.system = 'email', value.value=(item3.answer.value) &quot;appointment.location.email&quot;; 
            item.item as item3 where (linkId.value = 'appointment.location.streetAddressLine' and answer.exists()) -&gt; location.address as address share orgAddress then {
               item.answer as answer -&gt; address.line = (answer.value) &quot;line&quot;;
            } &quot;appointment.location.streetAddressLine&quot;;
            item.item as item3 where (linkId.value = 'appointment.location.postalCode' and answer.exists()) -&gt; location.address as address share orgAddress, address.postalCode = (item3.answer.value) &quot;appointment.location.postalCode&quot;;
            item.item as item3 where (linkId.value = 'appointment.location.city' and answer.exists()) -&gt; location.address as address share orgAddress, address.city = (item3.answer.value) &quot;appointment.location.city&quot;;
            item.item as item3 where (linkId.value = 'appointment.location.country' and answer.exists()) -&gt; location.address as address share orgAddress, address.country = (item3.answer.value) &quot;appointment.location.country&quot;;
         } &quot;location&quot;;
      } &quot;appointment.location&quot;;
   } &quot;Appointment&quot;;
}

group PreviousResults(source grp : BackboneElement, target bundle: Bundle, target serviceRequest: ServiceRequest) {
   grp.item as item where (linkId='previousResults.attachment' and answer.exists()) then {
      item.answer as answer then {
         answer.value: Attachment as attachment -&gt; 
            bundle.entry as e, 
            e.resource = create('Media') as media, 
            media.id = uuid() as uuid,
            media.status = 'completed',
            e.fullUrl = append('urn:uuid:',uuid), 
            media.content = attachment,
            serviceRequest.supportingInfo as supportingInfo,
            supportingInfo.reference = ('urn:uuid:'+uuid)
            &quot;media&quot;; 
      } &quot;answer&quot;;
   } &quot;item&quot;;
}

group Note(source grp : BackboneElement, target serviceRequest: ServiceRequest) {
   grp.item as item where (linkId='note.text' and answer.exists()) -&gt; serviceRequest.note as note, note.text = (item.answer.value) &quot;note.text&quot;;
}

group QrToBundle(source qr : QuestionnaireResponse, target q: Questionnaire, target patient : Patient, target questionnaireresp: QuestionnaireResponseTarget, target servicerequest: ServiceRequest, target composition : Composition, target bundle : Bundle) {
  qr -&gt; bundle.id = uuid() &quot;id&quot;;
  qr -&gt; bundle.type = 'document' &quot;type&quot;;
  qr then OrfComposition(qr, q, composition, patient, questionnaireresp, servicerequest, bundle) &quot;composition&quot;;
  qr then QrToGroups(qr, patient, bundle, composition, servicerequest) &quot;qrgroups&quot;;
}

group OrfComposition(source qr : QuestionnaireResponse, target q: Questionnaire, target tgt : Composition, target patient: Patient, target questionnaireresp: QuestionnaireResponseTarget, target servicerequest: ServiceRequest, target bundle : Bundle) {
  qr -&gt; tgt.status = 'final' &quot;status&quot;;
  qr -&gt; tgt.subject = create('Reference') as reference, reference.reference = ('urn:uuid:'+%patient.id) &quot;subject&quot;;
  qr -&gt; tgt.section as tgtSection, 
     tgtSection.title = 'Order-Referral', 
     tgtSection.code as code, code.coding as coding, coding.system='http://loinc.org', coding.code='93037-0', coding.display='Portable medical order form',
     tgtSection.entry = create('Reference') as reference, reference.reference = ('urn:uuid:'+%questionnaireresp.id),
     tgtSection.entry = create('Reference') as reference, reference.reference = ('urn:uuid:'+%servicerequest.id),
     tgtSection.entry = create('Reference') as reference, reference.reference = ('urn:uuid:'+%q.id) &quot;sections&quot;;
  qr -&gt; servicerequest.status = 'active',
      servicerequest.intent = 'order',
      servicerequest.subject = create('Reference') as reference, reference.reference = ('urn:uuid:'+%patient.id) &quot;servicerequest&quot;;
}</pre>
    </div>
  </text>
  <url value="http://fhir.ch/ig/ch-orf/StructureMap/OrfQrToBundle"/>
  <version value="2.0.0-ballot"/>
  <name value="OrfQrToBundle"/>
  <status value="draft"/>
  <date value="2023-06-29T21:20:25+02:00"/>
  <publisher value="HL7 Switzerland"/>
  <contact>
    <name value="HL7 Switzerland"/>
    <telecom>
      <system value="url"/>
      <value value="https://www.hl7.ch/"/>
    </telecom>
  </contact>
  <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="QuestionnaireResponse"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/BackboneElement"/>
    <mode value="source"/>
    <alias value="BackboneElement"/>
  </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="QuestionnaireResponseTarget"/>
  </structure>
  <group>
    <name value="OrfQrToBundle"/>
    <typeMode value="none"/>
    <input>
      <name value="qr"/>
      <type value="QuestionnaireResponse"/>
      <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="orfbundle"/>
      <source>
        <context value="qr"/>
        <variable value="qrcp"/>
      </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="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="copy"/>
        <parameter>
          <valueId value="qrcp"/>
        </parameter>
      </target>
      <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>
      <rule>
        <name value="orfbundle"/>
        <source>
          <context value="qr"/>
          <element value="questionnaire"/>
          <variable value="can"/>
        </source>
        <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="q"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="can.resolve()"/>
          </parameter>
        </target>
        <target>
          <context value="q"/>
          <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>
        <dependent>
          <name value="QrToBundle"/>
          <variable value="qr"/>
          <variable value="q"/>
          <variable value="patient"/>
          <variable value="questionnaireresp"/>
          <variable value="servicerequest"/>
          <variable value="composition"/>
          <variable value="bundle"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="QrToGroups"/>
    <typeMode value="none"/>
    <input>
      <name value="qr"/>
      <type value="QuestionnaireResponse"/>
      <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="previousResults"/>
      <source>
        <context value="qr"/>
        <element value="item"/>
        <variable value="grp"/>
        <condition value="linkId = 'previousResults'"/>
      </source>
      <dependent>
        <name value="PreviousResults"/>
        <variable value="grp"/>
        <variable value="bundle"/>
        <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"/>
      <type value="BackboneElement"/>
      <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="order.precedentDocumentIdentifier"/>
      <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.valueString"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="order.placerOrderIdentifier"/>
      <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.valueString"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="order.placerOrderIdentifierDomain"/>
      <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.valueString"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="order.fillerOrderIdentifier"/>
      <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.valueString"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="order.fillerOrderIdentifierDomain"/>
      <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.valueString"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'order.dateTime') 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="order.notificationContactDocument"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'order.notificationContactDocument')"/>
      </source>
      <rule>
        <name value="order.notificationContactDocument.items"/>
        <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="order.notificationContactDocumentResponse"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="(linkId.value = 'order.notificationContactDocumentResponse')"/>
      </source>
      <rule>
        <name value="order.notificationContactDocumentResponse.items"/>
        <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"/>
      <type value="BackboneElement"/>
      <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="sender.author.practitioner.title"/>
      <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="sender.author.practitioner.phone"/>
      <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="sender.author.practitioner.email"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="sender.author.practitioner.title"/>
      <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="sender.author.practitioner.phone"/>
      <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="sender.author.practitioner.email"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="receiver.practitioner.title"/>
      <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="receiver.practitioner.gln"/>
      <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="receiver.practitioner.zsr"/>
      <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="receiver.practitioner.phone"/>
      <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="receiver.practitioner.email"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="receiver.organization.gln"/>
      <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="receiver.organization.zsr"/>
      <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="item.answer"/>
      <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="receiver.organization.streetAddressLine"/>
        <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="receiver.organization.postalCode"/>
      <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="receiver.organization.city"/>
      <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="receiver.organization.country"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="consent.statement"/>
      <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="item.answer"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <rule>
          <name value="consent.statement.note"/>
          <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="initiator.personalrelation"/>
      <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="initiator.legalrelation"/>
      <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="initiator.relatedPerson"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="initiator.relatedPerson.phone"/>
        <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="initiator.relatedPerson.email"/>
      <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="item.answer"/>
      <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="initiator.relatedPerson.streetAddressLine"/>
        <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="initiator.relatedPerson.postalCode"/>
      <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="initiator.relatedPerson.city"/>
      <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="initiator.relatedPerson.country"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="initiator.practitionerRole.practitioner.title"/>
      <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="initiator.practitionerRole.practitioner.phone"/>
      <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="initiator.practitionerRole.practitioner.email"/>
      <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="receiver.practitioner.gln"/>
      <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="receiver.practitioner.zsr"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="item.answer"/>
      <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="initiator.practitionerRole.organization.streetAddressLine"/>
        <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="initiator.practitionerRole.organization.postalCode"/>
      <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="initiator.practitionerRole.organization.city"/>
      <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="initiator.practitionerRole.organization.country"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="familydoctor.practitioner.gln"/>
      <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="familydoctor.practitioner.zsr"/>
      <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="familydoctor.practitioner.title"/>
      <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="familydoctor.practitioner.phone"/>
      <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="familydoctor.practitioner.email"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="item.answer"/>
      <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="familydoctor.organization.streetAddressLine"/>
        <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="familydoctor.organization.postalCode"/>
      <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="familydoctor.organization.city"/>
      <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="familydoctor.organization.country"/>
      <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="familydoctor.organization.gln"/>
      <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="familydoctorr.organization.zsr"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="antecedentEpisodeOfCare.requestedPeriod.start"/>
      <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="antecedentEpisodeOfCare.managingOrganization"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="item.answer"/>
      <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="antecedentEpisodeOfCareorganization.streetAddressLine"/>
        <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="sender.author.organization.postalCode"/>
      <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="sender.author.organization.city"/>
      <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="sender.author.organization.country"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="patient.localPid"/>
      <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.valueString"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="patient.localPidDomain"/>
      <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.valueString"/>
        </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="patient.maritalStatus"/>
      <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="patient.phone"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId.value = 'patient.phone') and answer.exists())"/>
      </source>
      <rule>
        <name value="patient.phone"/>
        <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="patient.email"/>
      <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="item.answer"/>
      <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="patient.streetAddressLine"/>
        <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="patient.postalCode"/>
      <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="patient.city"/>
      <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="patient.country"/>
      <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="patient.languageOfCorrespondence"/>
      <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="patient.contactperson.phone"/>
        <source>
          <context value="src"/>
          <element value="item"/>
          <variable value="item"/>
          <condition
                     value="((linkId.value = 'patient.contactperson.phone') and answer.exists())"/>
        </source>
        <rule>
          <name value="patient.phone"/>
          <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="patient.email"/>
        <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="patient.contactperson.relationship"/>
        <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"/>
      <type value="BackboneElement"/>
      <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="requestedEncounter.class"/>
        <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="requestedEncounter.desiredAccommodation"/>
        <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"/>
      <type value="BackboneElement"/>
      <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="coverage.beneficiary"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="item"/>
        <condition value="where(linkId.value = 'coverage.beneficiary')"/>
      </source>
      <rule>
        <name value="coverage.beneficiary.ahvn13"/>
        <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-orf/CodeSystem/ch-orf-cs-coveragetype"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="KVG"/>
        </parameter>
      </target>
      <rule>
        <name value="coverage.kvg.name"/>
        <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="coverage.kvg.insuranceCardNumber"/>
        <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-orf/CodeSystem/ch-orf-cs-coveragetype"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="UVG"/>
        </parameter>
      </target>
      <rule>
        <name value="coverage.uvg.name"/>
        <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="coverage.uvg.claimNumber"/>
        <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-orf/CodeSystem/ch-orf-cs-coveragetype"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="VVG"/>
        </parameter>
      </target>
      <rule>
        <name value="coverage.vvg.name"/>
        <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="coverage.vvg.insuranceCardNumber"/>
        <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-orf/CodeSystem/ch-orf-cs-coveragetype"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="IVG"/>
        </parameter>
      </target>
      <rule>
        <name value="coverage.iv.verfuegungsnummer"/>
        <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-orf/CodeSystem/ch-orf-cs-coveragetype"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="MVG"/>
        </parameter>
      </target>
      <rule>
        <name value="coverage.mv.versichertennummer"/>
        <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-orf/CodeSystem/ch-orf-cs-coveragetype"/>
          </parameter>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Self"/>
          </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="coverage.self.patientrelated."/>
        <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="coverage.self.relatedPerson"/>
          <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-orf/CodeSystem/ch-orf-cs-coveragetype"/>
            </parameter>
          </target>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Self"/>
            </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-orf/CodeSystem/ch-orf-cs-coveragetype"/>
        </parameter>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Other"/>
        </parameter>
      </target>
      <rule>
        <name value="coverage.other.name"/>
        <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="coverage.other.id"/>
        <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"/>
      <type value="BackboneElement"/>
      <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="coverage.self.relatedPerson.phone"/>
        <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="coverage.self.relatedPerson.email"/>
      <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="item.answer"/>
      <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="coverage.self.relatedPerson.streetAddressLine"/>
        <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="coverage.self.relatedPerson.postalCode"/>
      <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="coverage.self.relatedPerson.city"/>
      <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="coverage.self.relatedPerson.country"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="sender.author.practitioner.title"/>
      <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="sender.author.practitioner.gln"/>
      <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="recsender.author.practitioner.zsr"/>
      <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="sender.author.practitioner.phone"/>
      <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="sender.author.practitioner.email"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="sender.author.organization.gln"/>
      <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="sender.author.organization.zsr"/>
      <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="item.answer"/>
      <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="sender.author.organization.streetAddressLine"/>
        <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="sender.author.organization.postalCode"/>
      <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="sender.author.organization.city"/>
      <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="sender.author.organization.country"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="sender.author.practitioner.phone"/>
      <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="sender.author.practitioner.email"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="sender.author"/>
        <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="sender.dataenterer"/>
        <source>
          <context value="src"/>
          <element value="item"/>
          <variable value="item"/>
          <condition value="(linkId.value = 'sender.dataenterer')"/>
        </source>
        <rule>
          <name value="sender.dataenterer.items"/>
          <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"/>
      <type value="BackboneElement"/>
      <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="receiverCopy.relatedPerson.phone"/>
        <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="receiverCopy.relatedPerson.email"/>
      <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="item.answer"/>
      <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="receiverCopy.relatedPerson.streetAddressLine"/>
        <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="receiverCopy.relatedPerson.postalCode"/>
      <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="receiverCopy.relatedPerson.city"/>
      <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="receiverCopy.relatedPerson.country"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="receiverCopy.practitionerRole.practitioner.title"/>
      <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="receiverCopy.practitionerRole.practitioner.phone"/>
      <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="receiverCopy.practitionerRole.practitioner.email"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="item.answer"/>
      <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="receiverCopy.practitionerRole.organization.streetAddressLine"/>
        <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="receiverCopy.practitionerRole.organization.postalCode"/>
      <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="receiverCopy.practitionerRole.organization.city"/>
      <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="receiverCopy.practitionerRole.organization.country"/>
      <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"/>
      <type value="BackboneElement"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="ExtOrfCopyReceiver"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="BackboneElement"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="res"/>
      <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"/>
      <type value="BackboneElement"/>
      <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="ExtOrfCopyReceiver"/>
          <variable value="item"/>
          <variable value="practitionerrole"/>
          <variable value="extension"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="receiverCopyPractitionerRole2"/>
      <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="ExtOrfCopyReceiver"/>
          <variable value="item"/>
          <variable value="patient"/>
          <variable value="extension"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="receiverCopyPractitionerRole3"/>
      <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="ExtOrfCopyReceiver"/>
          <variable value="item"/>
          <variable value="relatedPerson"/>
          <variable value="extension"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Appointment"/>
    <typeMode value="none"/>
    <input>
      <name value="grp"/>
      <type value="BackboneElement"/>
      <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"/>
        <element 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="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="appointment.requestedPeriod"/>
          <source>
            <context value="grp"/>
            <element value="item"/>
            <variable value="itemp"/>
            <condition
                       value="(linkId.value = 'appointment.requestedPeriod')"/>
          </source>
          <rule>
            <name value="appointment.requestedPeriod.start"/>
            <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="appointment.requestedPeriod.end.if.not.same.as.start"/>
              <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="appointment.startend"/>
          <source>
            <context value="grp"/>
            <element value="item"/>
            <variable value="itemp"/>
            <condition
                       value="(linkId.value = 'appointment.requestedPeriod')"/>
          </source>
          <rule>
            <name value="appointment.start"/>
            <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="appointment.end.if.not.same.as.start"/>
              <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="appointment.patientInstruction"/>
        <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="appointment.location"/>
        <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="appointment.location.phone"/>
            <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="appointment.location.email"/>
            <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="appointment.location.streetAddressLine"/>
            <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="appointment.location.postalCode"/>
            <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="appointment.location.city"/>
            <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="appointment.location.country"/>
            <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="PreviousResults"/>
    <typeMode value="none"/>
    <input>
      <name value="grp"/>
      <type value="BackboneElement"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="item"/>
      <source>
        <context value="grp"/>
        <element value="item"/>
        <variable value="item"/>
        <condition
                   value="((linkId = 'previousResults.attachment') and answer.exists())"/>
      </source>
      <rule>
        <name value="answer"/>
        <source>
          <context value="item"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <rule>
          <name value="media"/>
          <source>
            <context value="answer"/>
            <type value="Attachment"/>
            <element value="value"/>
            <variable value="attachment"/>
          </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="media"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Media"/>
            </parameter>
          </target>
          <target>
            <context value="media"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="media"/>
            <contextType value="variable"/>
            <element value="status"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="completed"/>
            </parameter>
          </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="media"/>
            <contextType value="variable"/>
            <element value="content"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="attachment"/>
            </parameter>
          </target>
          <target>
            <context value="serviceRequest"/>
            <contextType value="variable"/>
            <element value="supportingInfo"/>
            <variable value="supportingInfo"/>
          </target>
          <target>
            <context value="supportingInfo"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + uuid"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Note"/>
    <typeMode value="none"/>
    <input>
      <name value="grp"/>
      <type value="BackboneElement"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="serviceRequest"/>
      <type value="ServiceRequest"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="note.text"/>
      <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="QuestionnaireResponse"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="q"/>
      <type value="Questionnaire"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="questionnaireresp"/>
      <type value="QuestionnaireResponseTarget"/>
      <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="q"/>
        <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"/>
    <input>
      <name value="qr"/>
      <type value="QuestionnaireResponse"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="q"/>
      <type value="Questionnaire"/>
      <mode value="target"/>
    </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="QuestionnaireResponseTarget"/>
      <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>
      <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:' + %q.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>