Generated Narrative: StructureMap RadOrderQrToBundle #xD; map "http://fhir.ch/ig/ch-rad-order/StructureMap/RadOrderQrToBundle" = "RadOrderQrToBundle"#xD; #xD; // Radiologoy QuestionnaireResponse to Bundle#xD; // Derived from ORF QuestionnaireResponse to Bundle#xD; // 2021-01-11 Oliver Egger, copyright ahdis ag, Apache License#xD; // QRF Questionnaire: http://fhir.ch/ig/ch-orf/Questionnaire-order-referral-form.html#xD; // QRF QuestionnaireResponse: http://fhir.ch/ig/ch-orf/QuestionnaireResponse-order-referral-form.xml.html#xD; // Bundle: http://fhir.ch/ig/ch-orf/StructureDefinition-ch-orf-document.html#xD; #xD; uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source#xD; uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target#xD; uses "http://hl7.org/fhir/StructureDefinition/RelatedPerson" alias RelatedPerson as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Organization" alias Organization as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Practitioner" alias Practitioner as target#xD; uses "http://hl7.org/fhir/StructureDefinition/PractitionerRole" alias PractitionerRole as target#xD; uses "http://hl7.org/fhir/StructureDefinition/ServiceRequest" alias ServiceRequest as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Extension" alias Extension as target#xD; uses "http://hl7.org/fhir/StructureDefinition/EpisodeOfCare" alias EpisodeOfCare as target#xD; uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponseTarget as target#xD; uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source#xD; uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Organization" alias Organization as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Practitioner" alias Practitioner as target#xD; uses "http://hl7.org/fhir/StructureDefinition/PractitionerRole" alias PractitionerRole as target#xD; uses "http://hl7.org/fhir/StructureDefinition/ServiceRequest" alias ServiceRequest as target#xD; #xD; imports "http://fhir.ch/ig/ch-orf/StructureMap/OrfQrToBundle"#xD; #xD; group RadOrderQrToBundle(source qr : QuestionnaireResponse, target bundle : Bundle) {#xD; qr -> bundle.identifier as documentIdentifier, documentIdentifier.system = 'urn:ietf:rfc:3986', uuid() as uuidDoc, documentIdentifier.value = append('urn:uuid:', uuidDoc) "documentIdentifier";#xD; qr as qrcp -> bundle.entry as e, e.resource = create('Composition') as composition, composition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), composition.title = 'Radiologieauftrag', composition.type as type, type.coding as coding, coding.code = '2161000195103', coding.system = 'urn:oid:2.16.756.5.30.1.127.3.4', coding.display = 'Imaging order (record artifact)', composition.category as category, category.coding as coding, coding.code = '721963009', coding.system = 'http://snomed.info/sct', coding.display = 'Order (record artifact)', bundle.entry as e2, bundle.timestamp = (now()) as timestamp, bundle.type = 'document', composition.date = timestamp, e2.resource = create('Patient') as patient, patient.id = uuid() as uuid2, e2.fullUrl = ('urn:uuid:' + %uuid2), bundle.entry as e4, e4.resource = create('QuestionnaireResponse') as questionnaireresp then {#xD; qr then QuestionnaireResponseMap(qr, questionnaireresp) "questionnaireresp";#xD; 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 = ('urn:uuid:' + %uuid5) then {#xD; qr then OrfComposition(qr, composition, patient, questionnaireresp, servicerequest, bundle) "composition";#xD; qr then QrToGroups(questionnaireresp, patient, bundle, composition, servicerequest) "orf";#xD; qr then RadOrderQrToServiceRequest(questionnaireresp, patient, bundle, composition, servicerequest) "servicerequest";#xD; } "servicerequest";#xD; } "orfbundle";#xD; }#xD; #xD; group RadOrderQrToServiceRequest(source qr : QuestionnaireResponse, target patient : Patient, target bundle : Bundle, target composition : Composition, target serviceRequest : ServiceRequest) {#xD; qr.item as grp where linkId = 'requestedService' then RequestedServiceItems(grp, serviceRequest) "requestedService";#xD; qr.item as grp where linkId = 'reason' then ReasonServiceItems(grp, serviceRequest) "reason";#xD; qr.item as grp where linkId = 'imagingService' then ImagingServiceItems(grp, serviceRequest) "imagingService";#xD; qr.item as grp where linkId = 'orderDetail' then OrderDetailServiceItems(grp, serviceRequest) "orderDetail";#xD; qr.item as grp where linkId = 'desiredRadiologist' then DesiredRadiologistServiceItems(grp, bundle, serviceRequest) "desiredRadiologist";#xD; qr.item as grp where linkId = 'diagnosisList' then DiagnosisListServiceItems(grp, patient, bundle, serviceRequest) "diagnosisList";#xD; qr.item as grp where linkId = 'caveat' then CaveatServiceItems(grp, patient, bundle, serviceRequest) "Caveat";#xD; qr.item as grp where linkId = 'previousResults' then {#xD; grp.item as grp where linkId = 'attachedFile' then PreviousImagingStudyResultsNonDicom(grp, bundle, serviceRequest, patient) "attachment";#xD; grp.item as grp where linkId = 'dicomObject' then PreviousImagingStudyResults(grp, bundle, serviceRequest, patient) "attachment";#xD; } "previousResults";#xD; }#xD; #xD; group RequestedServiceItems(source src, target serviceRequest : ServiceRequest) {#xD; src.item as item where ((linkId.value = 'requestedService.service') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as coding -> serviceRequest.category as cc, cc.coding = coding "requestedServiceService";#xD; } "answerCalueCoding";#xD; } "itemAnswer";#xD; }#xD; #xD; group ReasonServiceItems(source src, target serviceRequest : ServiceRequest) {#xD; src.item as item where ((linkId.value = 'reason.question') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : string as value -> serviceRequest.reasonCode as reasonCode, reasonCode.text = value "reasonQuestion";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; }#xD; #xD; group ImagingServiceItems(source src, target serviceRequest : ServiceRequest) {#xD; src.item as item where ((linkId.value = 'imagingService.type') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as coding -> serviceRequest.code as code, code.coding = coding "requestedServiceService";#xD; } "answerValueCoding";#xD; } "itemAnswer";#xD; }#xD; #xD; group OrderDetailServiceItems(source src, target serviceRequest : ServiceRequest) {#xD; src.item as item where ((linkId.value = 'orderDetail.imagingRegion') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as coding -> serviceRequest.orderDetail as cc, cc.extension as ext, ext.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-order-detail-type', ext.value = create('Coding') as coding, coding.system = 'http://fhir.ch/ig/ch-rad-order/CodeSystem/ch-rad-order-order-detail-type', coding.code = 'imagingRegion', cc.coding = coding "orderDetailImagingRegion";#xD; } "answerValueCoding";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'orderDetail.imagingFocus') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as coding -> serviceRequest.bodySite as cc, cc.coding = coding "orderDetailImagingFocus";#xD; } "answerValueCoding";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'orderDetail.laterality') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as coding -> serviceRequest.orderDetail as cc, cc.extension as ext, ext.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-order-detail-type', ext.value = create('Coding') as coding, coding.system = 'http://fhir.ch/ig/ch-rad-order/CodeSystem/ch-rad-order-order-detail-type', coding.code = 'laterality', cc.coding = coding "orderDetailLaterality";#xD; } "answerValueCoding";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'orderDetail.viewType') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as coding -> serviceRequest.orderDetail as cc, cc.extension as ext, ext.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-order-detail-type', ext.value = create('Coding') as coding, coding.system = 'http://fhir.ch/ig/ch-rad-order/CodeSystem/ch-rad-order-order-detail-type', coding.code = 'viewType', cc.coding = coding "orderDetailViewType";#xD; } "answerValueCoding";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'orderDetail.maneuverType') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as coding -> serviceRequest.orderDetail as cc, cc.extension as ext, ext.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-order-detail-type', ext.value = create('Coding') as coding, coding.system = 'http://fhir.ch/ig/ch-rad-order/CodeSystem/ch-rad-order-order-detail-type', coding.code = 'maneuverType', cc.coding = coding "orderDetailManeuverType";#xD; } "answerValueCoding";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'orderDetail.guidanceForAction') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as coding -> serviceRequest.orderDetail as cc, cc.extension as ext, ext.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-order-detail-type', ext.value = create('Coding') as coding, coding.system = 'http://fhir.ch/ig/ch-rad-order/CodeSystem/ch-rad-order-order-detail-type', coding.code = 'guidanceForAction', cc.coding = coding "orderDetailGuidanceForAction";#xD; } "answerValueCoding";#xD; } "itemAnswer";#xD; }#xD; #xD; group DesiredRadiologistServiceItems(source src, target bundle : Bundle, target serviceRequest : ServiceRequest) {#xD; src -> bundle.entry as e, e.resource = create('Practitioner') as practitioner, practitioner.id = uuid() as uuid, serviceRequest.performer as performer, performer.reference = ('urn:uuid:' + %uuid), e.fullUrl = ('urn:uuid:' + %uuid) then {#xD; src.item as item where ((linkId.value = 'desiredRadiologist.familyName') and answer.exists()) -> practitioner.name as name share name, name.family = (%item.answer.value);#xD; src.item as item where ((linkId.value = 'desiredRadiologist.givenName') and answer.exists()) -> practitioner.name as name share name, name.given = (%item.answer.value);#xD; } "serviceRequestPerformer";#xD; }#xD; #xD; group DiagnosisListServiceItems(source src, target patient : Patient, target bundle : Bundle, target serviceRequest : ServiceRequest) {#xD; src.item as item where ((linkId.value = 'diagnosisList.primaryDiagnosis') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : string as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.reasonReference as reasonReference, reasonReference.reference = ('urn:uuid:' + %uuid), condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.text = value, condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "diagnosisListPrimaryDiagnosis";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'diagnosisList.secondaryDiagnosis') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : string as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.text = value, condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "diagnosisListSecondaryDiagnosis";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'diagnosisList.bodyHeight') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Quantity as value -> bundle.entry as e, e.resource = create('Observation') as observation, observation.status = 'final', observation.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), observation.status = 'final', serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), observation.category as category, category.coding as coding, coding.code = 'vital-signs', coding.system = 'http://terminology.hl7.org/CodeSystem/observation-category', observation.value = value, observation.code as cc, cc.coding as c, c.system = 'http://loinc.org', c.code = '8302-2', observation.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "observationBodyHeight";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'diagnosisList.bodyWeight') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Quantity as value -> bundle.entry as e, e.resource = create('Observation') as observation, observation.status = 'final', observation.id = uuid() as uuid, observation.status = 'final', e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), observation.category as category, category.coding as coding, coding.code = 'vital-signs', coding.system = 'http://terminology.hl7.org/CodeSystem/observation-category', observation.value = value, observation.code as cc, cc.coding as c, c.system = 'http://loinc.org', c.code = '29463-7', observation.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "observationBbodyWeight";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; }#xD; #xD; group CaveatServiceItems(source src, target patient : Patient, target bundle : Bundle, target serviceRequest : ServiceRequest) {#xD; src.item as item where ((linkId.value = 'caveatList.bloodCoagulation') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '64779008', coding.system = 'http://snomed.info/sct', coding.display = 'Blood coagulation disorder (disorder)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = value, condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding as coding2, coding2.code = '64779008', coding2.system = 'http://snomed.info/sct', coding2.display = 'Blood coagulation disorder (disorder)', condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) then {#xD; answer.item as subitem where (linkId.value = 'caveatList.bloodCoagulation.INR') -> bundle.entry as e, e.resource = create('Observation') as observation, observation.id = uuid() as uuid, observation.status = 'final', e.fullUrl = ('urn:uuid:' + %uuid), condition.evidence as evidence, evidence.detail as detail, detail.reference = ('urn:uuid:' + %uuid), observation.code as cc, cc.coding as c, c.system = 'http://loinc.org', c.code = '34714-6', observation.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) then {#xD; subitem.item as quantityitem where ((linkId.value = 'caveatList.bloodCoagulation.INR.quantity') and answer.exists()) then {#xD; quantityitem.answer as answer then {#xD; answer.value : Quantity as value -> observation.value = value;#xD; } "caveatBloodCoagulationINRQuantityValue";#xD; } "caveatBloodCoagulationINRQuantity";#xD; subitem.item as datetimeitem where ((linkId.value = 'caveatList.bloodCoagulation.INR.dateTime') and answer.exists()) then {#xD; datetimeitem.answer as answer then {#xD; answer.value : dateTime as value -> observation.effective = value;#xD; } "caveatBloodCoagulationINRDateTimeValue";#xD; } "caveatBloodCoagulationINRDateTime";#xD; } "caveatBloodCoagulationINR";#xD; answer.item as subitem where (linkId.value = 'caveatList.bloodCoagulation.platelets') -> bundle.entry as e, e.resource = create('Observation') as observation, observation.id = uuid() as uuid, observation.status = 'final', e.fullUrl = ('urn:uuid:' + %uuid), condition.evidence as evidence, evidence.detail as detail, detail.reference = ('urn:uuid:' + %uuid), observation.code as cc, cc.coding as c, c.system = 'http://loinc.org', c.code = '26515-7', observation.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) then {#xD; subitem.item as quantityitem where ((linkId.value = 'caveatList.bloodCoagulation.platelets.quantity') and answer.exists()) then {#xD; quantityitem.answer as answer then {#xD; answer.value : Quantity as value -> observation.value = value;#xD; } "caveatBloodCoagulationINRPlateletsValue";#xD; } "caveatBloodCoagulationINRPlatelets";#xD; subitem.item as datetimeitem where ((linkId.value = 'caveatList.bloodCoagulation.platelets.dateTime') and answer.exists()) then {#xD; datetimeitem.answer as answer then {#xD; answer.value : dateTime as value -> observation.effective = value;#xD; } "caveatBloodCoagulationINRPlateletsValue";#xD; } "caveatBloodCoagulationINRPlatelets";#xD; } "caveatBloodCoagulationINR";#xD; } "bloodCoagulation";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'caveatList.renalInsufficiency') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '723188008', coding.system = 'http://snomed.info/sct', coding.display = 'Renal insufficiency (disorder)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = value, condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding as coding2, coding2.code = '723188008', coding2.system = 'http://snomed.info/sct', coding2.display = 'Renal insufficiency (disorder)', condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) then {#xD; answer.item as subitem where (linkId.value = 'caveatList.renalInsufficiency.creatinineClearance') -> bundle.entry as e, e.resource = create('Observation') as observation, observation.status = 'final', observation.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), condition.evidence as evidence, evidence.detail as detail, detail.reference = ('urn:uuid:' + %uuid), observation.code as cc, cc.coding as c, c.system = 'http://loinc.org', c.code = '33558-8', observation.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) then {#xD; subitem.item as quantityitem where ((linkId.value = 'caveatList.renalInsufficiency.creatinineClearance.quantity') and answer.exists()) then {#xD; quantityitem.answer as answer then {#xD; answer.value : Quantity as value -> observation.value = value;#xD; } "caveatListRenalInsufficiencyCreatinineClearanceQuantityValue";#xD; } "caveatListRenalInsufficiencyCreatinineClearanceQuantity";#xD; subitem.item as datetimeitem where ((linkId.value = 'caveatList.renalInsufficiency.creatinineClearance.dateTime') and answer.exists()) then {#xD; datetimeitem.answer as answer then {#xD; answer.value : dateTime as value -> observation.effective = value;#xD; } "caveatListRenalInsufficiencyCreatinineClearanceDateTimeValue";#xD; } "caveatListRenalInsufficiencyCreatinineClearancedateTime";#xD; } "caveatListRenalInsufficiencyCreatinineClearanceINR";#xD; answer.item as subitem where (linkId.value = 'caveatList.renalInsufficiency.creatinine') -> bundle.entry as e, e.resource = create('Observation') as observation, observation.status = 'final', observation.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), condition.evidence as evidence, evidence.detail as detail, detail.reference = ('urn:uuid:' + %uuid), observation.code as cc, cc.coding as c, c.system = 'http://loinc.org', c.code = '77140-2', observation.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) then {#xD; subitem.item as quantityitem where ((linkId.value = 'caveatList.renalInsufficiency.creatinine.quantity') and answer.exists()) then {#xD; quantityitem.answer as answer then {#xD; answer.value : Quantity as value -> observation.value = value;#xD; } "caveatListRenalInsufficiencyCreatinineValue";#xD; } "caveatListRenalInsufficiencyCreatinine";#xD; subitem.item as datetimeitem where ((linkId.value = 'caveatList.renalInsufficiency.creatinine.dateTime') and answer.exists()) then {#xD; datetimeitem.answer as answer then {#xD; answer.value : dateTime as value -> observation.effective = value;#xD; } "caveatListRenalInsufficiencyCreatininevalue";#xD; } "caveatBloodCoagulationINRPlatelets";#xD; } "caveatListRenalInsufficiencyCreatinine";#xD; } "bloodCoagulation";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'caveatList.claustrophobia') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '19887002', coding.system = 'http://snomed.info/sct', coding.display = 'Claustrophobia (finding)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = value, condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding as coding2, coding2.code = '19887002', coding2.system = 'http://snomed.info/sct', coding2.display = 'Claustrophobia (finding)', condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "caveatListClaustrophobia";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'caveatList.bodyPiercing') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '879862001', coding.system = 'http://snomed.info/sct', coding.display = 'Body piercing (finding)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = value, condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding as coding2, coding2.code = '879862001', coding2.system = 'http://snomed.info/sct', coding2.display = 'Body piercing (finding)', condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "caveatListBodyPiercing";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'caveatList.device') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '397578001', coding.system = 'http://snomed.info/sct', coding.display = 'Device in situ (finding)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = create('Coding') as coding, coding.code = '52101004', coding.system = 'http://snomed.info/sct', coding.display = 'Present (qualifier value)', condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding = value, condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "caveatListDevice";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'caveatList.hyperthyroidism') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '34486009', coding.system = 'http://snomed.info/sct', coding.display = 'Hyperthyroidism (disorder)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = value, condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding as coding2, coding2.code = '34486009', coding2.system = 'http://snomed.info/sct', coding2.display = 'Hyperthyroidism (disorder)', condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "caveatListHyperthyroidism";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'caveatList.diabetes') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '73211009', coding.system = 'http://snomed.info/sct', coding.display = 'Diabetes mellitus (disorder)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = value, condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding as coding2, coding2.code = '73211009', coding2.system = 'http://snomed.info/sct', coding2.display = 'Diabetes mellitus (disorder)', condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "caveatListDiabetes";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'caveatList.gravida') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '366321006', coding.system = 'http://snomed.info/sct', coding.display = 'Finding of gravida (finding)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = value, condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding as coding2, coding2.code = '366321006', coding2.system = 'http://snomed.info/sct', coding2.display = 'Finding of gravida (finding)', condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "caveatListGravida";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; src.item as item where ((linkId.value = 'caveatList.contrastMediaAllergy') and answer.exists()) then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '293637006', coding.system = 'http://snomed.info/sct', coding.display = 'Allergy to contrast media (finding)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = value, condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding as coding2, coding2.code = '293637006', coding2.system = 'http://snomed.info/sct', coding2.display = 'Allergy to contrast media (finding)', condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "caveatListContrastMediaAllergy";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; // "caveatListDrugPrescription.metformin"#xD; // caveatList.drugPrescription.betaBlocke#xD; src.item as item where (linkId.value = 'caveatList.drugPrescription') then DesiredRadiologistServiceItemsDrugDescription(item, bundle, serviceRequest, patient) "DrugPrescription";#xD; }#xD; #xD; group DesiredRadiologistServiceItemsDrugDescription(source src, target bundle : Bundle, target serviceRequest : ServiceRequest, target patient : Patient) {#xD; src.item as item where (linkId.value = 'caveatList.drugPrescription.metformin') then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '182817000', coding.system = 'http://snomed.info/sct', coding.display = 'Drug prescription (situation)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = value, condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding as coding2, coding2.code = '372567009', coding2.system = 'http://snomed.info/sct', coding2.display = 'Metformin (substance)', condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "caveatListDrugPrescription";#xD; } "answerValueString";#xD; } "caveatListDrugPrescriptionMetformin";#xD; src.item as item where (linkId.value = 'caveatList.drugPrescription.betaBlocker') then {#xD; item.answer as answer then {#xD; answer.value : Coding as value -> bundle.entry as e, e.resource = create('Condition') as condition, condition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + %uuid), serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid), condition.extension as ext1, ext1.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-caveat-type', ext1.value = create('Coding') as coding, coding.code = '182817000', coding.system = 'http://snomed.info/sct', coding.display = 'Drug prescription (situation)', condition.extension as ext2, ext2.url = 'http://fhir.ch/ig/ch-rad-order/StructureDefinition/ch-rad-order-qualifier-value', ext2.value = value, condition.category as category, category.coding as coding, coding.code = 'problem-list-item', coding.system = 'http://terminology.hl7.org/CodeSystem/condition-category', coding.display = 'Problem List Item', condition.code as code, code.coding as coding2, coding2.code = '373254001', coding2.system = 'http://snomed.info/sct', coding2.display = 'Substance with beta adrenergic receptor antagonist mechanism of action (substance)', condition.subject as subject, subject.reference = ('urn:uuid:' + %patient.id) "caveatListDrugPrescription";#xD; } "answerValueString";#xD; } "caveatListDrugPrescriptionBetaBlocker";#xD; }#xD; #xD; group PreviousImagingStudyResultsNonDicom(source item, target bundle : Bundle, target serviceRequest : ServiceRequest, target patient : Patient) {#xD; item as item -> bundle.entry as e, e.resource = create('DocumentReference') as documentReference, documentReference.id = uuid() as uuid, documentReference.subject as subject, subject.reference = ('urn:uuid:' + %patient.id), e.fullUrl = append('urn:uuid:', uuid), documentReference.status = 'current', serviceRequest.supportingInfo as supportingInfo, supportingInfo.reference = ('urn:uuid:' + %uuid) then {#xD; item.answer as answer -> documentReference.content as content, content.attachment = (%answer.value) as attachment then {#xD; answer.item as dictomitem where ((linkId.value = 'attachedFile.description') and answer.exists()) -> documentReference.description = (%dictomitem.answer.value) "description";#xD; } "answerValueString";#xD; } "itemAnswer";#xD; }#xD; #xD; group PreviousImagingStudyResults(source item, target bundle : Bundle, target serviceRequest : ServiceRequest, target patient : Patient) {#xD; item as item -> bundle.entry as e, e.resource = create('ImagingStudy') as imagingStudy, imagingStudy.id = uuid() as uuid, imagingStudy.status = 'available', imagingStudy.subject as subject, subject.reference = ('urn:uuid:' + %patient.id), e.fullUrl = append('urn:uuid:', uuid), serviceRequest.subject as subject, subject.reference = ('urn:uuid:' + %patient.id), serviceRequest.supportingInfo as supportingInfo, imagingStudy.series as series, series.instance as instance, supportingInfo.reference = ('urn:uuid:' + %uuid) then {#xD; item.answer as answer then {#xD; answer.value : string as value -> imagingStudy.description = value "description";#xD; } "answerValueString";#xD; item.item as item where (linkId.value = 'dicomObject.sopInstanceUid') and answer.exists() -> instance.uid = (%item.answer.value) "uid";#xD; item.item as item where (linkId.value = 'dicomObject.modality') and answer.exists() -> series.modality as modality, modality.code = (%item.answer.value.code) "modality";#xD; item.item as item where (linkId.value = 'dicomObject.studyInstanceUid') and answer.exists() -> imagingStudy.identifier as uid, uid.type as type, type.coding as coding, coding.system = 'urn:dicom:uid', coding.code = 'PLAC', uid.value = (%item.answer.value) "uid";#xD; item.item as item where (linkId.value = 'dicomObject.SeriesInstanceUid') and answer.exists() -> series.uid = (%item.answer.value) "attachmentdicomSeriesInstanceUid";#xD; item.item as item where (linkId.value = 'dicomObject.acsn') and answer.exists() -> imagingStudy.identifier as acsn, acsn.type as type, type.coding as coding, coding.system = 'http://terminology.hl7.org/CodeSystem/v2-0203', coding.code = 'ACSN', acsn.value = (%item.answer.value) "acsn";#xD; } "supportingInfo";#xD; }#xD; #xD;
Radiologoy QuestionnaireResponse to Bundle Derived from ORF QuestionnaireResponse to Bundle 2021-01-11 Oliver Egger, copyright ahdis ag, Apache License QRF Questionnaire: http://fhir.ch/ig/ch-orf/Questionnaire-order-referral-form.html QRF QuestionnaireResponse: http://fhir.ch/ig/ch-orf/QuestionnaireResponse-order-referral-form.xml.html Bundle: http://fhir.ch/ig/ch-orf/StructureDefinition-ch-orf-document.html
((linkId.value = 'requestedService.service') and answer.exists())
((linkId.value = 'reason.question') and answer.exists())
((linkId.value = 'imagingService.type') and answer.exists())
((linkId.value = 'orderDetail.imagingRegion') and answer.exists())
((linkId.value = 'orderDetail.imagingFocus') and answer.exists())
((linkId.value = 'orderDetail.laterality') and answer.exists())
((linkId.value = 'orderDetail.viewType') and answer.exists())
((linkId.value = 'orderDetail.maneuverType') and answer.exists())
((linkId.value = 'orderDetail.guidanceForAction') and answer.exists())
((linkId.value = 'desiredRadiologist.familyName') and answer.exists())
((linkId.value = 'desiredRadiologist.givenName') and answer.exists())
((linkId.value = 'diagnosisList.primaryDiagnosis') and answer.exists())
((linkId.value = 'diagnosisList.secondaryDiagnosis') and answer.exists())
((linkId.value = 'diagnosisList.bodyHeight') and answer.exists())
((linkId.value = 'diagnosisList.bodyWeight') and answer.exists())
((linkId.value = 'caveatList.bloodCoagulation') and answer.exists())
(linkId.value = 'caveatList.bloodCoagulation.INR')
((linkId.value = 'caveatList.bloodCoagulation.INR.quantity') and answer.exists())
((linkId.value = 'caveatList.bloodCoagulation.INR.dateTime') and answer.exists())
(linkId.value = 'caveatList.bloodCoagulation.platelets')
((linkId.value = 'caveatList.bloodCoagulation.platelets.quantity') and answer.exists())
((linkId.value = 'caveatList.bloodCoagulation.platelets.dateTime') and answer.exists())
((linkId.value = 'caveatList.renalInsufficiency') and answer.exists())
(linkId.value = 'caveatList.renalInsufficiency.creatinineClearance')
((linkId.value = 'caveatList.renalInsufficiency.creatinineClearance.quantity') and answer.exists())
((linkId.value = 'caveatList.renalInsufficiency.creatinineClearance.dateTime') and answer.exists())
(linkId.value = 'caveatList.renalInsufficiency.creatinine')
((linkId.value = 'caveatList.renalInsufficiency.creatinine.quantity') and answer.exists())
((linkId.value = 'caveatList.renalInsufficiency.creatinine.dateTime') and answer.exists())
((linkId.value = 'caveatList.claustrophobia') and answer.exists())
((linkId.value = 'caveatList.bodyPiercing') and answer.exists())
((linkId.value = 'caveatList.device') and answer.exists())
((linkId.value = 'caveatList.hyperthyroidism') and answer.exists())
((linkId.value = 'caveatList.diabetes') and answer.exists())
((linkId.value = 'caveatList.gravida') and answer.exists())
((linkId.value = 'caveatList.contrastMediaAllergy') and answer.exists())
(linkId.value = 'caveatList.drugPrescription')
(linkId.value = 'caveatList.drugPrescription.metformin')
(linkId.value = 'caveatList.drugPrescription.betaBlocker')
Substance with beta adrenergic receptor antagonist mechanism of action (substance)
((linkId.value = 'attachedFile.description') and answer.exists())
(linkId.value = 'dicomObject.sopInstanceUid') and answer.exists()
(linkId.value = 'dicomObject.modality') and answer.exists()
(linkId.value = 'dicomObject.studyInstanceUid') and answer.exists()
(linkId.value = 'dicomObject.SeriesInstanceUid') and answer.exists()
(linkId.value = 'dicomObject.acsn') and answer.exists()