CH ORF (R4)
0.10.0 - STU 1 Ballot
This page is part of the CH ORF (R4) (v0.10.0: STU 1) based on FHIR R4. . For a full list of available versions, see the Directory of published versions
map "http://fhir.ch/ig/ch-orf/StructureMap/OrfBundleToQr" = "OrfBundleToQr" // ORF Bundle To QuestionnaireResonse // Bundle: http://build.fhir.org/ig/hl7ch/ch-orf/StructureDefinition-ch-orf-document.html // QRF Questionnaire Response: http://build.fhir.org/ig/hl7ch/ch-orf/QuestionnaireResponse-referral-min.xml.html uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as source uses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as source uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as source uses "http://hl7.org/fhir/StructureDefinition/Organization" alias Organization as source uses "http://hl7.org/fhir/StructureDefinition/Practitioner" alias Practitioner as source uses "http://hl7.org/fhir/StructureDefinition/PractitionerRole" alias PractitionerRole as source uses "http://hl7.org/fhir/StructureDefinition/ServiceRequest" alias ServiceRequest as source uses "http://hl7.org/fhir/StructureDefinition/BackboneElement" alias BackboneElement as source uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as target group OrfBundleToQr(source bundle : Bundle, target qr : QuestionnaireResponse) { bundle -> qr.questionnaire = 'http://fhir.ch/ig/ch-orf/Questionnaire/order-referral-form' "questionnaire"; bundle -> qr.status = 'completed' "status"; bundle.entry first as entry then { entry.resource as composition then { composition.section as section then { bundle.entry as entry then { entry.fullUrl where ($this in %section.entry.reference) and $this.startsWith('urn:uuid') then { entry.resource : ServiceRequest as serviceRequest then CompositionToQr(bundle, composition, serviceRequest, qr) "servicerequest"; } "fullUrlAsUuid"; entry.resource : ServiceRequest as serviceRequest where ('ServiceRequest' + '/' + $this.id) in %section.entry.reference then CompositionToQr(bundle, composition, serviceRequest, qr) "servicerequest"; }; }; }; }; } group CompositionToQr(source bundle : Bundle, source composition : Composition, source serviceRequest : ServiceRequest, target qr : QuestionnaireResponse) { composition -> qr.item as item, item.linkId = 'order' then OrderToQr(bundle, composition, serviceRequest, item) "order"; composition.extension as ext where url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-receiver' -> qr.item as item, item.linkId = 'receiver' then ReceiverToQr(bundle, serviceRequest, ext, item) "receiver"; composition.subject -> qr.item as item, item.linkId = 'patient' then PatientToQr(bundle, composition, serviceRequest, item) "patient"; serviceRequest.extension as ext where url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-requestedencounterdetails' -> qr.item as item, item.linkId = 'requestedEncounter' then RequestedEncounterDetailsToQr(bundle, ext, item) "requestedEncounter"; serviceRequest.insurance first as insurance -> qr.item as item, item.linkId = 'coverage' then CoverageToQr(bundle, composition, serviceRequest, item) "requestedEncounter"; composition.author -> qr.item as item, item.linkId = 'sender' then SenderToQr(bundle, composition, serviceRequest, item) "sender"; composition.extension first as extension where (url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-copyreceiver') -> qr.item as item, item.linkId = 'receiverCopies' then ReceiverCopyToQr(bundle, composition, serviceRequest, item) "receiverCopies"; serviceRequest.extension as ext where url = 'ch-orf-locationandtime' -> qr.item as item, item.linkId = 'appointment' then AppointmentDetailsToQr(bundle, ext, item) "apopintments"; serviceRequest.note first as note -> qr.item as item, item.linkId = 'note' then NoteToQr(serviceRequest, item); } group OrderToQr(source bundle : Bundle, source composition : Composition, source serviceRequest : ServiceRequest, target item : BackboneElement) { // <linkId value="order.title" /> composition.title as title -> item.item as itemfirst, itemfirst.linkId = 'order.title', itemfirst.answer as answer, answer.value = title; // <linkId value="order.type" /> composition.type as comptype then { comptype.coding as coding -> item.item as itemfirst, itemfirst.linkId = 'order.type', itemfirst.answer as answer, answer.value = coding "type"; } "CodeableConceptType"; // <linkId value="order.category" /> composition.category as compcat then { compcat.coding as coding -> item.item as itemfirst, itemfirst.linkId = 'order.category', itemfirst.answer as answer, answer.value = coding "category"; } "CodeableConceptType"; // <linkId value="order.placerOrderIdentifierDomain" /> serviceRequest.identifier as identifier where (type.coding.where((system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203') and (code.value = 'PLAC'))) -> item.item as itemfirst, itemfirst.linkId = 'order.placerOrderIdentifier', itemfirst.answer as answer, answer.value = (identifier.value) then { identifier.system as system -> item.item as itemsecond, itemsecond.linkId = 'order.placerOrderIdentifierDomain', itemsecond.answer as answer, answer.value = cast(system, 'string') "placerOrderIdentifierDomain"; } "placerOrderIdentifierDomain"; // <linkId value="order.fillerOrderIdentifier" /> serviceRequest.identifier as identifier where (type.coding.where((system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203') and (code.value = 'FILL'))) -> item.item as itemfirst, itemfirst.linkId = 'order.fillerOrderIdentifier', itemfirst.answer as answer, answer.value = (identifier.value) then { identifier.system as system -> item.item as itemsecond, itemsecond.linkId = 'order.fillerOrderIdentifierDomain', itemsecond.answer as answer, answer.value = cast(system, 'string') "fillerOrderIdentifier"; } "fillerOrderIdentifierDomain"; // <linkId value="order.precedentDocumentIdentifier" /> composition.extension as extension where url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-precedentdocument' then { extension.value as value where value.startsWith('urn:uuid:') -> item.item as item, item.linkId = 'order.precedentDocumentIdentifier', item.answer as answer, answer.value = (value.value.substring(9)) "precedentDocumentIdentifier"; } "composition"; // 'order.dateTime'- currently not mapped in qr response composition.extension as extension where url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-urgentnoficationcontactforthisdocument' then { extension.value as value then { bundle.entry as entry then { entry.fullUrl where ($this in %value.reference) and $this.startsWith('urn:uuid') then { entry.resource : PractitionerRole as practitionerRole then UrgentNotificationToQr(bundle, composition, practitionerRole, item) "practitionerRole"; } "fullUrlAsUuid"; entry.resource : PractitionerRole as practitionerRole where ('PractitionerRole' + '/' + $this.id) in %value.reference then UrgentNotificationToQr(bundle, composition, practitionerRole, item) "practitionerRole"; }; }; } "composition"; // Urgent Notification Contact for the Response to this document composition.extension as extension where url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-urgentnoficationcontactfortheresponsetothisdocument' then { extension.value as value then { bundle.entry as entry then { entry.fullUrl where ($this in %value.reference) and $this.startsWith('urn:uuid') then { entry.resource : PractitionerRole as practitionerRole then UrgentNotificationResponseToQr(bundle, composition, practitionerRole, item) "practitionerRole"; } "fullUrlAsUuid"; entry.resource : PractitionerRole as practitionerRole where ('PractitionerRole' + '/' + $this.id) in %value.reference then UrgentNotificationResponseToQr(bundle, composition, practitionerRole, item) "practitionerRole"; }; }; } "composition"; // order.priority serviceRequest.priority as priority -> item.item as item, item.linkId = 'order.priority', item.answer as answer, answer.value = create('Coding') as coding, coding.system = 'http://hl7.org/fhir/request-priority', coding.code = priority; } group UrgentNotificationToQr(source bundle : Bundle, source composition : Composition, source practitionerRole : PractitionerRole, target item : BackboneElement) { composition -> item.item as itemgroup, itemgroup.linkId = 'order.notificationContactDocument', itemgroup.item as item, item.linkId = 'order.notificationContactDocument.practitioner' then { practitionerRole.practitioner as practitioner then { bundle.entry as entry then { entry.fullUrl where ($this in %practitioner.reference) and $this.startsWith('urn:uuid') then { entry.resource : Practitioner as practitioner then UrgentNotificationPractitionerToQr(bundle, composition, practitioner, item) "practitioner"; } "fullUrlAsUuid"; entry.resource : Practitioner as practitioner where ('Practitioner' + '/' + $this.id) in %practitioner.reference then UrgentNotificationPractitionerToQr(bundle, composition, practitioner, item) "practitioner"; }; }; } "urgentnotification"; } group UrgentNotificationPractitionerToQr(source bundle : Bundle, source composition : Composition, source practitioner : Practitioner, target item : BackboneElement) { practitioner.name as name then { // order.notificationContactDocument.practitioner.title name.prefix as prefix where (extension.where((url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier') and (valueCode = 'AC'))) -> item.item as item, item.linkId = 'order.notificationContactDocument.practitioner.title', item.answer as answer, answer.value = prefix; // order.notificationContactDocument.practitioner.familyName name.family as family -> item.item as item, item.linkId = 'order.notificationContactDocument.practitioner.familyName', item.answer as answer, answer.value = family; // order.notificationContactDocument.practitioner.givenName name.given as given -> item.item as item, item.linkId = 'order.notificationContactDocument.practitioner.givenName', item.answer as answer, answer.value = given; }; // order.notificationContactDocument.practitioner.phone practitioner.telecom as telecom where (system = 'phone') -> item.item as item, item.linkId = 'order.notificationContactDocument.practitioner.phone', item.answer as answer, answer.value = (telecom.value) "phone"; // order.notificationContactDocument.practitioner.memaol practitioner.telecom as telecom where (system = 'email') -> item.item as item, item.linkId = 'order.notificationContactDocument.practitioner.email', item.answer as answer, answer.value = (telecom.value) "email"; } group UrgentNotificationResponseToQr(source bundle : Bundle, source composition : Composition, source practitionerRole : PractitionerRole, target item : BackboneElement) { // order.notificationContactDocumentResponse composition -> item.item as itemgroup, itemgroup.linkId = 'order.notificationContactDocumentResponse', itemgroup.item as item, item.linkId = 'order.notificationContactDocumentResponse.practitioner' then { practitionerRole.practitioner as practitioner then { bundle.entry as entry then { entry.fullUrl where ($this in %practitioner.reference) and $this.startsWith('urn:uuid') then { entry.resource : Practitioner as practitioner then UrgentNotificationResponsePractitionerToQr(bundle, composition, practitioner, item) "practitioner"; } "fullUrlAsUuid"; entry.resource : Practitioner as practitioner where ('Practitioner' + '/' + $this.id) in %practitioner.reference then UrgentNotificationResponsePractitionerToQr(bundle, composition, practitioner, item) "practitioner"; }; }; } "urgentnotification"; } group UrgentNotificationResponsePractitionerToQr(source bundle : Bundle, source composition : Composition, source practitioner : Practitioner, target item : BackboneElement) { practitioner.name as name then { // order.notificationContactDocumentResponse.practitioner.title name.prefix as prefix where (extension.where((url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier') and (valueCode = 'AC'))) -> item.item as item, item.linkId = 'order.notificationContactDocumentResponse.practitioner.title', item.answer as answer, answer.value = prefix; // order.notificationContactDocumentResponse.practitioner.familyName name.family as family -> item.item as item, item.linkId = 'order.notificationContactDocumentResponse.practitioner.familyName', item.answer as answer, answer.value = family; // order.notificationContactDocumentResponse.practitioner.givenName name.given as given -> item.item as item, item.linkId = 'order.notificationContactDocumentResponse.practitioner.givenName', item.answer as answer, answer.value = given; }; // order.notificationContactDocumentResponse.practitioner.phone practitioner.telecom as telecom where (system = 'phone') -> item.item as item, item.linkId = 'order.notificationContactDocumentResponse.practitioner.phone', item.answer as answer, answer.value = (telecom.value) "phone"; // order.notificationContactDocumentResponse.practitioner.memaol practitioner.telecom as telecom where (system = 'email') -> item.item as item, item.linkId = 'order.notificationContactDocumentResponse.practitioner.email', item.answer as answer, answer.value = (telecom.value) "email"; } group ReceiverToQr(source bundle : Bundle, source composition : Composition, source ext : Extension, target item : BackboneElement) { bundle.entry as entry then { entry.fullUrl where ($this in %ext.valueReference.reference) and $this.startsWith('urn:uuid') then { entry.resource : PractitionerRole as practitionerRole then ReceiverPractitionerRoleToQr(bundle, composition, practitionerRole, item) "practitioner"; } "fullUrlAsUuid"; entry.resource : PractitionerRoler as practitionerRole where ('PractitionerRole' + '/' + $this.id) in %ext.valueReference.reference then ReceiverPractitionerRoleToQr(bundle, composition, practitionerRole, item) "practitioner"; }; } group ReceiverPractitionerRoleToQr(source bundle : Bundle, source composition : Composition, source practitionerRole : PractitionerRole, target itemgroup : BackboneElement) { practitionerRole.practitioner as practitioner -> itemgroup.item as item, item.linkId = 'receiver.practitioner' then { bundle.entry as entry then { entry.fullUrl where ($this in %practitioner.reference) and $this.startsWith('urn:uuid') then { entry.resource : Practitioner as practitioner then ReceiverPractitionerToQr(bundle, composition, practitioner, item) "practitioner"; } "fullUrlAsUuid"; entry.resource : Practitioner as practitioner where ('Practitioner' + '/' + $this.id) in %practitioner.reference then ReceiverPractitionerToQr(bundle, composition, practitioner, item) "practitioner"; }; }; practitionerRole.organization as organization -> itemgroup.item as item, item.linkId = 'receiver.organization' then { bundle.entry as entry then { entry.fullUrl where ($this in %organization.reference) and $this.startsWith('urn:uuid') then { entry.resource : Organization as organization then ReceiverOrganizationToQr(bundle, composition, organization, item) "organization"; } "fullUrlAsUuid"; entry.resource : Organization as organization where ('Organization' + '/' + $this.id) in %organization.reference then ReceiverOrganizationToQr(bundle, composition, practitioner, item) "organization"; }; }; } group ReceiverPractitionerToQr(source bundle : Bundle, source composition : Composition, source practitioner : Practitioner, target item : BackboneElement) { practitioner.name as name then { // receiver.practitioner.title name.prefix as prefix where (extension.where((url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier') and (valueCode = 'AC'))) -> item.item as item, item.linkId = 'receiver.practitioner.title', item.answer as answer, answer.value = prefix; // receiver.practitioner.familyName name.family as family -> item.item as item, item.linkId = 'receiver.practitioner.familyName', item.answer as answer, answer.value = family; // receiver.practitioner.givenName name.given as given -> item.item as item, item.linkId = 'receiver.practitioner.givenName', item.answer as answer, answer.value = given; }; // receiver.practitioner.gln practitioner.identifier as identifier where (system = 'urn:oid:2.51.1.3') then { identifier.value as value -> item.item as item, item.linkId = 'receiver.practitioner.gln', item.answer as answer, answer.value = cast(value, 'string') "gln"; }; // receiver.practitioner.phone practitioner.telecom as telecom where (system = 'phone') -> item.item as item, item.linkId = 'receiver.practitioner.phone', item.answer as answer, answer.value = (telecom.value) "phone"; // receiver.practitioneremail practitioner.telecom as telecom where (system = 'email') -> item.item as item, item.linkId = 'receiver.practitioner.email', item.answer as answer, answer.value = (telecom.value) "email"; } group ReceiverOrganizationToQr(source bundle : Bundle, source composition : Composition, source organization : Organization, target item : BackboneElement) { // receiver.organization.name organization.name as name -> item.item as item, item.linkId = 'receiver.organization.name', item.answer as answer, answer.value = name; // receiver.organization.streetAddressLine organization.address as addr then { addr.line first as line1 -> item.item as item, item.linkId = 'receiver.organization.streetAddressLine' then { addr.line as line -> item.answer as answer, answer.value = line; } "addrlinefirst"; // receiver.organization.postalCode addr.postalCode as postalCode -> item.item as item, item.linkId = 'receiver.organization.postalCode', item.answer as answer, answer.value = postalCode; // receiver.organization.city addr.city as city -> item.item as item, item.linkId = 'receiver.organization.city', item.answer as answer, answer.value = city; // receiver.organization.country addr.country as country -> item.item as item, item.linkId = 'receiver.organization.country', item.answer as answer, answer.value = country; } "addr"; } group PatientToQr(source bundle : Bundle, source composition : Composition, source serviceRequest : ServiceRequest, target item : BackboneElement) { composition.subject as subject then { bundle.entry as entry then { entry.fullUrl where ($this in %subject.reference) and $this.startsWith('urn:uuid') then { entry.resource : Patient as patient then PatientDetailsToQr(bundle, composition, patient, item) "patient"; } "fullUrlAsUuid"; entry.resource : Patient as patient where ('Patient' + '/' + $this.id) in %subject.reference then PatientDetailsToQr(bundle, composition, patient, item) "patient"; }; } "practitioner"; } group PatientDetailsToQr(source bundle : Bundle, source composition : Composition, source patient : Patient, target item : BackboneElement) { // patient.familyName patient.name as name where (use.empty() or (use = 'official')) then { name.family as family -> item.item as item, item.linkId = 'patient.familyName', item.answer as answer, answer.value = family; } "familyName"; patient.name as name where use = 'maiden' then { name.family as family -> item.item as item, item.linkId = 'patient.maidenName', item.answer as answer, answer.value = family "maidenName"; } "maidenName"; patient.name as name where (use.empty() or (use = 'official')) then { // patient.givenName name.given as given -> item.item as item, item.linkId = 'patient.givenName', item.answer as answer, answer.value = given; } "givenName"; // patient.localPid patient.identifier as identifier where (type.coding.where((system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203') and (code.value = 'MR'))) -> item.item as item1, item1.linkId = 'patient.localPid', item1.answer as answer, answer.value = (identifier.value) then { identifier.system as system -> item.item as item2, item2.linkId = 'patient.localPidDomain', item2.answer as answer, answer.value = cast(system, 'string') "placerOrderIdentifierDomain"; } "localPid"; // patient.birthDate patient.birthDate as birthDate -> item.item as item, item.linkId = 'patient.birthDate', item.answer as answer, answer.value = birthDate; // patient.gender patient.gender as gender -> item.item as item, item.linkId = 'patient.gender', item.answer as answer, answer.value = create('Coding') as coding, coding.system = 'http://hl7.org/fhir/administrative-gender', coding.code = gender; // patient.phone patient.telecom as telecom where (system = 'phone') -> item.item as item, item.linkId = 'patient.phone', item.answer as answer, answer.value = (telecom.value) "phone"; // patient.email patient.telecom as telecom where (system = 'email') -> item.item as item, item.linkId = 'patient.email', item.answer as answer, answer.value = (telecom.value) "email"; patient.address as addr then { addr.line first as line1 -> item.item as item, item.linkId = 'patient.streetAddressLine' then { addr.line as line -> item.answer as answer, answer.value = line; } "addrlinefirst"; // patient.postalCode addr.postalCode as postalCode -> item.item as item, item.linkId = 'patient.postalCode', item.answer as answer, answer.value = postalCode; // patient.city addr.city as city -> item.item as item, item.linkId = 'patient.city', item.answer as answer, answer.value = city; // patient.country addr.country as country -> item.item as item, item.linkId = 'patient.country', item.answer as answer, answer.value = country; } "addr"; // patient.contactperson patient.contact as contact -> item.item as item, item.linkId = 'patient.contactperson' then { // patient.contactperson.relationship contact.relationship as relationship then { relationship.text as text -> item.item as item, item.linkId = 'patient.contactperson.relationship', item.answer as answer, answer.value = text "relationship"; }; contact.name as name then { // patient.contactperson.familyName name.family as family -> item.item as item, item.linkId = 'patient.contactperson.familyName', item.answer as answer, answer.value = family "familyName"; // patient.contactperson.givenName name.given as given -> item.item as item, item.linkId = 'patient.contactperson.givenName', item.answer as answer, answer.value = given "givenName"; }; // patient.contactperson.phone contact.telecom as telecom where (system = 'phone') -> item.item as item, item.linkId = 'patient.contactperson.phone', item.answer as answer, answer.value = (telecom.value) "phone"; // patient.contactperson.email contact.telecom as telecom where (system = 'email') -> item.item as item, item.linkId = 'patient.contactperson.email', item.answer as answer, answer.value = (telecom.value) "email"; }; } group RequestedEncounterDetailsToQr(source bundle : Bundle, source ext : Extension, target item : BackboneElement) { bundle.entry as entry then { entry.fullUrl where ($this in %ext.valueReference.reference) and $this.startsWith('urn:uuid') then { entry.resource : Encounter as encounter then EncounterToQr(encounter, item) "encounter"; } "fullUrlAsUuid"; entry.resource : Encounter as encounter where ('Encounter' + '/' + $this.id) in %ext.valueReference.reference then EncounterToQr(encounter, item) "encounter"; }; } group EncounterToQr(source encounter : Encounter, target item : BackboneElement) { // requestedEncounter.class encounter.class as class -> item.item as item, item.linkId = 'requestedEncounter.class', item.answer as answer, answer.value = class; // requestedEncounter.desiredAccommodation encounter.extension as extension where url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-desiredaccommodation' then { extension.value as value -> item.item as item, item.linkId = 'requestedEncounter.desiredAccommodation', item.answer as answer, answer.value = value "desiredAccommodation"; } "desiredAccommodation"; } group AppointmentDetailsToQr(source bundle : Bundle, source ext : Extension, target item : BackboneElement) { bundle.entry as entry then { entry.fullUrl where ($this in %ext.valueReference.reference) and $this.startsWith('urn:uuid') then { entry.resource : Appointment as appointment then AppointmentToQr(appointment, item) "appointment"; } "fullUrlAsUuid"; entry.resource : Appointment as appointment where ('Appointment' + '/' + $this.id) in %ext.valueReference.reference then AppointmentToQr(appointment, item) "encounter"; }; } group LocationToQr(source loc : Locaton, target item : BackboneElement) { loc -> item.item as item, item.linkId = 'appointment.location' then { // appointment.location.name location.name as name -> item.item as itemloc, itemloc.linkId = 'appointment.location.name', answer.value = name; // appointment.location.phone location.telecom as telecom where system = 'phone' -> item.item as itemloc, itemloc.linkId = 'appointment.location.phone', answer.value = (%telecom.value) "phone"; // appointment.location.email location.telecom as telecom where system = 'email' -> item.item as itemloc, itemloc.linkId = 'appointment.location.email', answer.value = (%telecom.value) "email"; location.addr as addr then { // appointment.location.streetAddressLine addr.streetAddressLine as line -> item.item as itemloc, itemloc.linkId = 'appointment.location.streetAddressLine', answer.value = line; // appointment.location.postalCode addr.postalCode as postalCode -> item.item as itemloc, itemloc.linkId = 'appointment.location.postalCode', answer.value = postalCode; // appointment.location.city addr.city as city -> item.item as itemloc, itemloc.linkId = 'appointment.location.city', answer.value = city; // appointment.location.country addr.country as country -> item.item as itemloc, itemloc.linkId = 'appointment.location.country', answer.value = country; }; } "location"; } group AppointmentToQr(source app : Appointment, target item : BackboneElement) { // appointment.location app.participant as particiapnt then { bundle.entry as entry then { entry.fullUrl where ($this in %participant.reference) and $this.startsWith('urn:uuid') then { entry.resource : Location as location then LocationToQr(location, item) "location"; } "fullUrlAsUuid"; entry.resource : Location as location where ('Location' + '/' + $this.id) in %participant.reference then LocationToQr(location, item) "location"; }; }; // appointment.requestedPeriod app.requestedPeriod as requestedPeriod -> item.item as item, item.linkId = 'appointment.requestedPeriod' then { // appointment.requestedPeriod.start requestedPeriod.start as start -> item.item as itemloc, itemloc.linkId = 'appointment.requestedPeriod.start', answer.value = start; // appointment.requestedPeriod.end requestedPeriod.end as end -> item.item as itemloc, itemloc.linkId = 'appointment.requestedPeriod.end', answer.value = end; }; // appointment.status app.status as status -> item.item as itemloc, itemloc.linkId = 'appointment.requestedPeriod.status', answer.value = status; // appointment.patientInstruction app.patientInstruction as patientInstruction -> item.item as itemloc, itemloc.linkId = 'appointment.patientInstruction', answer.value = patientInstruction; } group CoverageBeneficiary(source patient : Patient, target item : BackboneElement) { patient.identifier as identifier where system = 'urn:oid:2.16.756.5.32' -> item.item as itemkvg, itemkvg.linkId = 'coverage.beneficiary', itemkvg.item as itemname, itemname.linkId = 'coverage.beneficiary.ahvn13', itemname.answer as answer, answer.value = (%identifier.value) "ahvn13"; } group CoverageKvg(source coverage : Coverage, target item : BackboneElement) { coverage -> item.item as itemkvg, itemkvg.linkId = 'coverage.kvg', itemkvg.item as itemname, itemname.linkId = 'coverage.kvg.name', itemname.answer as answer, answer.value = (%coverage.contained.name), itemkvg.item as itemno, itemno.linkId = 'coverage.kvg.insuranceCardNumber', itemno.answer as answer, answer.value = (%coverage.identifier.value) "kvg"; } group CoverageUvg(source coverage : Coverage, target item : BackboneElement) { coverage -> item.item as itemkvg, itemkvg.linkId = 'coverage.uvg', itemkvg.item as itemname, itemname.linkId = 'coverage.uvg.name', itemname.answer as answer, answer.value = (%coverage.contained.name), itemkvg.item as itemno, itemno.linkId = 'coverage.uvg.claimNumber', itemno.answer as answer, answer.value = (%coverage.identifier.value) "uvg"; } group CoverageVvg(source coverage : Coverage, target item : BackboneElement) { coverage -> item.item as itemkvg, itemkvg.linkId = 'coverage.vvg', itemkvg.item as itemname, itemname.linkId = 'coverage.vvg.name', itemname.answer as answer, answer.value = (%coverage.contained.name), itemkvg.item as itemno, itemno.linkId = 'coverage.vvg.insuranceCardNumber', itemno.answer as answer, answer.value = (%coverage.identifier.value) "vvg"; } group CoverageIvg(source coverage : Coverage, target item : BackboneElement) { coverage -> item.item as itemkvg, itemkvg.linkId = 'coverage.iv', itemkvg.item as itemno, itemno.linkId = 'coverage.iv.verfuegungsnummer', itemno.answer as answer, answer.value = (%coverage.identifier.value) "iv"; } group CoverageMvg(source coverage : Coverage, target item : BackboneElement) { coverage -> item.item as itemkvg, itemkvg.linkId = 'coverage.mv', itemkvg.item as itemno, itemno.linkId = 'coverage.mv.versichertennummer', itemno.answer as answer, answer.value = (%coverage.identifier.value) "mv"; } group CoverageSelf(source coverage : Coverage, target item : BackboneElement) { coverage -> item.item as itemkvg, itemkvg.linkId = 'coverage.self', itemkvg.item as itemname, itemname.linkId = 'coverage.self.familyName', itemname.answer as answer, answer.value = (%coverage.contained.name.family), itemkvg.item as itemno, itemno.linkId = 'coverage.self.givenName', itemno.answer as answer, answer.value = (%coverage.contained.name.given) "uvg"; } group CoverageOther(source coverage : Coverage, target item : BackboneElement) { coverage -> item.item as itemkvg, itemkvg.linkId = 'coverage.other', itemkvg.item as itemname, itemname.linkId = 'coverage.other.name', itemname.answer as answer, answer.value = (%coverage.contained.name), itemkvg.item as itemno, itemno.linkId = 'coverage.other.id', itemno.answer as answer, answer.value = (%coverage.identifier.value) "uvg"; } group CoverageToQr(source bundle : Bundle, source composition : Composition, source serviceRequest : ServiceRequest, target item : BackboneElement) { composition.subject as subject then { bundle.entry as entry then { entry.fullUrl where ($this in %subject.reference) and $this.startsWith('urn:uuid') then { entry.resource : Patient as patient then CoverageBeneficiary(patient, item) "patient"; } "fullUrlAsUuid"; entry.resource : Patient as patient where ('Patient' + '/' + $this.id) in %subject.reference then CoverageBeneficiary(patient, item) "patient"; }; } "practitioner"; bundle.entry as entry then { entry.fullUrl where ($this in %serviceRequest.insurance.reference) and $this.startsWith('urn:uuid') then { entry.resource : Coverage as coverage where (type.coding.code = 'KVG') then CoverageKvg(coverage, item) "coveragekvg"; entry.resource : Coverage as coverage where (type.coding.code = 'UVG') then CoverageUvg(coverage, item) "coverageuvg"; entry.resource : Coverage as coverage where (type.coding.code = 'VVG') then CoverageVvg(coverage, item) "coverageVvg"; entry.resource : Coverage as coverage where (type.coding.code = 'IVG') then CoverageIvg(coverage, item) "coverageVvg"; entry.resource : Coverage as coverage where (type.coding.code = 'MVG') then CoverageMvg(coverage, item) "coverageVvg"; entry.resource : Coverage as coverage where (type.coding.code = 'Self') then CoverageSelf(coverage, item) "coverageSelf"; entry.resource : Coverage as coverage where (type.coding.code = 'Other') then CoverageOther(coverage, item) "coverageOth4r"; } "fullUrlAsUuid"; entry.resource : Coverage as coverage where (type.coding.code = 'KVG') and (('Coverage' + '/' + $this.id) in %serviceRequest.insurance.reference) then CoverageKvg(coverage, item) "coveragekvg"; entry.resource : Coverage as coverage where (type.coding.code = 'UVG') and (('Coverage' + '/' + $this.id) in %serviceRequest.insurance.reference) then CoverageUvg(coverage, item) "coverageuvg"; entry.resource : Coverage as coverage where (type.coding.code = 'VVG') and (('Coverage' + '/' + $this.id) in %serviceRequest.insurance.reference) then CoverageVvg(coverage, item) "coverageuvg"; entry.resource : Coverage as coverage where (type.coding.code = 'IVG') and (('Coverage' + '/' + $this.id) in %serviceRequest.insurance.reference) then CoverageIvg(coverage, item) "coverageivg"; entry.resource : Coverage as coverage where (type.coding.code = 'MVG') and (('Coverage' + '/' + $this.id) in %serviceRequest.insurance.reference) then CoverageMvg(coverage, item) "coveragemvg"; entry.resource : Coverage as coverage where (type.coding.code = 'Self') and (('Coverage' + '/' + $this.id) in %serviceRequest.insurance.reference) then CoverageSelf(coverage, item) "coverageself"; entry.resource : Coverage as coverage where (type.coding.code = 'Other') and (('Coverage' + '/' + $this.id) in %serviceRequest.insurance.reference) then CoverageOther(coverage, item) "coverageother"; }; } group SenderToQr(source bundle : Bundle, source composition : Composition, source serviceRequest : ServiceRequest, target item : BackboneElement) { composition.author as author then { bundle.entry as entry then { entry.fullUrl where ($this in %author.reference) and $this.startsWith('urn:uuid') then { entry.resource : PractitionerRole as practitionerRole then SenderPractitionerRoleToQr(bundle, composition, practitionerRole, item) "practitioner"; } "fullUrlAsUuid"; entry.resource : PractitionerRoler as practitionerRole where ('PractitionerRole' + '/' + $this.id) in %author.reference then SenderPractitionerRoleToQr(bundle, composition, practitionerRole, item) "practitioner"; }; }; composition.extension as ext where (url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-dataenterer') then { ext.extension as extension where (url = 'enterer') then { extension.value as value then { bundle.entry as entry then { entry.fullUrl where ($this in %value.reference) and $this.startsWith('urn:uuid') then { entry.resource : PractitionerRole as practitionerRole then DataEntererPractitionerRoleToQr(bundle, composition, practitionerRole, item) "practitionerRole"; } "fullUrlAsUuid"; entry.resource : PractitionerRole as practitionerRole where ('PractitionerRole' + '/' + $this.id) in %value.reference then DataEntererPractitionerRoleToQr(bundle, composition, practitionerRole, item) "practitionerRole"; }; }; } "enterer"; } "dataenterer"; } group SenderPractitionerRoleToQr(source bundle : Bundle, source composition : Composition, source practitionerRole : PractitionerRole, target itemsender : BackboneElement) { composition -> itemsender.item as itemgroup, itemgroup.linkId = 'sender.author' then { practitionerRole.practitioner as practitioner -> itemgroup.item as item, item.linkId = 'sender.author.practitioner' then { bundle.entry as entry then { entry.fullUrl where ($this in %practitioner.reference) and $this.startsWith('urn:uuid') then { entry.resource : Practitioner as practitioner then SenderPractitionerToQr(bundle, composition, practitioner, item) "practitioner"; } "fullUrlAsUuid"; entry.resource : Practitioner as practitioner where ('Practitioner' + '/' + $this.id) in %practitioner.reference then SenderPractitionerToQr(bundle, composition, practitioner, item) "practitioner"; }; }; practitionerRole.organization as organization -> itemgroup.item as item, item.linkId = 'sender.author.organization' then { bundle.entry as entry then { entry.fullUrl where ($this in %organization.reference) and $this.startsWith('urn:uuid') then { entry.resource : Organization as organization then SenderOrganizationToQr(bundle, composition, organization, item) "organization"; } "fullUrlAsUuid"; entry.resource : Organization as organization where ('Organization' + '/' + $this.id) in %organization.reference then SenderOrganizationToQr(bundle, composition, practitioner, item) "organization"; }; }; } "author"; } group SenderPractitionerToQr(source bundle : Bundle, source composition : Composition, source practitioner : Practitioner, target item : BackboneElement) { practitioner.name as name then { // sender.author.practitioner.title name.prefix as prefix where (extension.where((url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier') and (valueCode = 'AC'))) -> item.item as item, item.linkId = 'sender.author.practitioner.title', item.answer as answer, answer.value = prefix; // sender.author.practitioner.familyName name.family as family -> item.item as item, item.linkId = 'sender.author.practitioner.familyName', item.answer as answer, answer.value = family; // sender.author.practitioner.givenName name.given as given -> item.item as item, item.linkId = 'sender.author.practitioner.givenName', item.answer as answer, answer.value = given; }; // sender.author.practitioner.gln practitioner.identifier as identifier where (system = 'urn:oid:2.51.1.3') then { identifier.value as value -> item.item as item, item.linkId = 'sender.author.practitioner.gln', item.answer as answer, answer.value = cast(value, 'string') "gln"; }; // sender.author.practitioner.phone practitioner.telecom as telecom where (system = 'phone') -> item.item as item, item.linkId = 'sender.author.practitioner.phone', item.answer as answer, answer.value = (telecom.value) "phone"; // sender.author.practitioneremila practitioner.telecom as telecom where (system = 'email') -> item.item as item, item.linkId = 'sender.author.practitioner.email', item.answer as answer, answer.value = (telecom.value) "email"; } group SenderOrganizationToQr(source bundle : Bundle, source composition : Composition, source organization : Organization, target item : BackboneElement) { // sender.author.organization.name organization.name as name -> item.item as item, item.linkId = 'sender.author.organization.name', item.answer as answer, answer.value = name; // sender.author.organization.streetAddressLine organization.address as addr then { addr.line first as line1 -> item.item as item, item.linkId = 'sender.author.organization.streetAddressLine' then { addr.line as line -> item.answer as answer, answer.value = line; } "addrlinefirst"; // sender.author.organization.postalCode addr.postalCode as postalCode -> item.item as item, item.linkId = 'sender.author.organization.postalCode', item.answer as answer, answer.value = postalCode; // sender.author.organization.city addr.city as city -> item.item as item, item.linkId = 'sender.author.organization.city', item.answer as answer, answer.value = city; // sender.author.organization.country addr.country as country -> item.item as item, item.linkId = 'sender.author.organization.country', item.answer as answer, answer.value = country; } "addr"; } group DataEntererPractitionerRoleToQr(source bundle : Bundle, source composition : Composition, source practitionerRole : PractitionerRole, target itemsender : BackboneElement) { composition -> itemsender.item as itemgroup, itemgroup.linkId = 'sender.dataenterer' then { practitionerRole.practitioner as practitioner -> itemgroup.item as item, item.linkId = 'sender.dataenterer.practitioner' then { bundle.entry as entry then { entry.fullUrl where ($this in %practitioner.reference) and $this.startsWith('urn:uuid') then { entry.resource : Practitioner as practitioner then DataEntererPractitionerToQr(bundle, composition, practitioner, item) "practitioner"; } "fullUrlAsUuid"; entry.resource : Practitioner as practitioner where ('Practitioner' + '/' + $this.id) in %practitioner.reference then DataEntererPractitionerToQr(bundle, composition, practitioner, item) "practitioner"; }; }; } "dataenterer"; } group DataEntererPractitionerToQr(source bundle : Bundle, source composition : Composition, source practitioner : Practitioner, target item : BackboneElement) { // sender.dataenterer.practitioner.familyName practitioner.name as name then { name.family as family -> item.item as item, item.linkId = 'sender.dataenterer.practitioner.familyName', item.answer as answer, answer.value = family; // sender.dataenterer.practitioner.givenName name.given as given -> item.item as item, item.linkId = 'sender.dataenterer.practitioner.givenName', item.answer as answer, answer.value = given; }; // sender.dataenterer.practitioner.phone practitioner.telecom as telecom where (system = 'phone') -> item.item as item, item.linkId = 'sender.dataenterer.practitioner.phone', item.answer as answer, answer.value = (telecom.value) "phone"; // sender.dataenterer.practitioner.email practitioner.telecom as telecom where (system = 'email') -> item.item as item, item.linkId = 'sender.dataenterer.practitioner.email', item.answer as answer, answer.value = (telecom.value) "email"; } group ReceiverCopyToQr(source bundle : Bundle, source composition : Composition, source serviceRequest : ServiceRequest, target item : BackboneElement) { composition.extension as extension where (url = 'http://fhir.ch/ig/ch-orf/StructureDefinition/ch-orf-copyreceiver') then { extension.value as value then { bundle.entry as entry then { entry.fullUrl where ($this in %value.reference) and $this.startsWith('urn:uuid') then { entry.resource : Organization as organization then ReceiverCopyOrganizationToQr(bundle, composition, organization, item) "organization"; entry.resource : Patient as patient then ReceiverCopyPatientToQr(bundle, composition, patient, item) "patient"; } "fullUrlAsUuid"; entry.resource : Organization as organization where ('Organization' + '/' + $this.id) in %value.reference then ReceiverCopyOrganizationToQr(bundle, composition, organization, item) "organization"; entry.resource : Patient as patient where ('Patient' + '/' + $this.id) in %value.reference then ReceiverCopyPatientToQr(bundle, composition, patient, item) "patient"; }; }; }; } group ReceiverCopyOrganizationToQr(source bundle : Bundle, source composition : Composition, source organization : Organization, target itemsender : BackboneElement) { organization -> itemsender.item as item, item.linkId = 'receiverCopy' then { // receiverCopy.organization.name organization.name as name -> item.item as item, item.linkId = 'receiverCopy.organization.name', item.answer as answer, answer.value = name; organization.contact as contact then { contact.name as name then { // receiverCopy.title name.prefix as prefix where (extension.where((url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier') and (valueCode = 'AC'))) -> item.item as item, item.linkId = 'receiverCopy.title', item.answer as answer, answer.value = prefix; // receiverCopy.familyName name.family as family -> item.item as item, item.linkId = 'receiverCopy.familyName', item.answer as answer, answer.value = family; // receiverCopy.givenName name.given as given -> item.item as item, item.linkId = 'receiverCopy.givenName', item.answer as answer, answer.value = given; }; }; // receiverCopy.phone organization.telecom as telecom where (system = 'phone') -> item.item as item, item.linkId = 'receiverCopy.phone', item.answer as answer, answer.value = (telecom.value) "phone"; // receiverCopy.email organization.telecom as telecom where (system = 'email') -> item.item as item, item.linkId = 'receiverCopy.email', item.answer as answer, answer.value = (telecom.value) "email"; // receiverCopy.organization.streetAddressLine organization.address as addr then { addr.line first as line1 -> item.item as item, item.linkId = 'receiverCopy.streetAddressLine' then { addr.line as line -> item.answer as answer, answer.value = line; } "addrlinefirst"; // receiverCopy.postalCode addr.postalCode as postalCode -> item.item as item, item.linkId = 'receiverCopy.postalCode', item.answer as answer, answer.value = postalCode; // receiverCopy.city addr.city as city -> item.item as item, item.linkId = 'receiverCopy.city', item.answer as answer, answer.value = city; // receiverCopy.country addr.country as country -> item.item as item, item.linkId = 'receiverCopy.country', item.answer as answer, answer.value = country; } "addr"; } "organization"; } group ReceiverCopyPatientToQr(source bundle : Bundle, source composition : Composition, source patient : Patient, target itemsender : BackboneElement) { patient -> itemsender.item as item, item.linkId = 'receiverCopy' then { patient.name as name then { // receiverCopy.familyName name.family as family -> item.item as item, item.linkId = 'receiverCopy.familyName', item.answer as answer, answer.value = family; // receiverCopy.givenName name.given as given -> item.item as item, item.linkId = 'receiverCopy.givenName', item.answer as answer, answer.value = given; // receiverCopy.title name.prefix as prefix where (extension.where((url = 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier') and (valueCode = 'AC'))) -> item.item as item, item.linkId = 'receiverCopy.title', item.answer as answer, answer.value = prefix; }; // receiverCopy.phone patient.telecom as telecom where (system = 'phone') -> item.item as item, item.linkId = 'receiverCopy.phone', item.answer as answer, answer.value = (telecom.value) "phone"; // receiverCopy.email patient.telecom as telecom where (system = 'email') -> item.item as item, item.linkId = 'receiverCopy.email', item.answer as answer, answer.value = (telecom.value) "email"; // receiverCopy.organization.streetAddressLine patient.address as addr then { addr.line first as line1 -> item.item as item, item.linkId = 'receiverCopy.streetAddressLine' then { addr.line as line -> item.answer as answer, answer.value = line; } "addrlinefirst"; // receiverCopy.postalCode addr.postalCode as postalCode -> item.item as item, item.linkId = 'receiverCopy.postalCode', item.answer as answer, answer.value = postalCode; // receiverCopy.city addr.city as city -> item.item as item, item.linkId = 'receiverCopy.city', item.answer as answer, answer.value = city; // receiverCopy.country addr.country as country -> item.item as item, item.linkId = 'receiverCopy.country', item.answer as answer, answer.value = country; } "addr"; } "patient"; } group NoteToQr(source serviceRequest : ServiceRequest, target item : BackboneElement) { serviceRequest.note as note then { note.text as text -> item.item as item, item.linkId = 'note.text', item.answer as answer, answer.value = cast(text, 'string'); }; }