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