map "http://fhir.ch/ig/ch-rad-order/StructureMap/RadOrderQrToBundle" = "RadOrderQrToBundle" // Radiologoy QuestionnaireResponse to Bundle uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient 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/BackboneElement" alias BackboneElement as target imports "http://fhir.ch/ig/ch-orf/StructureMap/OrfQrToBundle" group RadOrderQrToBundle(source qr : QuestionnaireResponse, target bundle : Bundle) { qr -> bundle.identifier as documentIdentifier, documentIdentifier.system = 'urn:ietf:rfc:3986', uuid() as uuidDoc, documentIdentifier.value = ('urn:uuid:' + uuidDoc) "documentIdentifier"; qr as qrcp -> bundle.entry as e, e.resource = create('Composition') as composition, composition.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + uuid), bundle.entry as e2, bundle.timestamp = (now()) as timestamp, 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 = qrcp as questionnaireresp, questionnaireresp.id = uuid() as uuid4, e4.fullUrl = ('urn:uuid:' + uuid4), bundle.entry as e5, e5.resource = create('ServiceRequest') as servicerequest, servicerequest.id = uuid() as uuid5, e5.fullUrl = ('urn:uuid:' + uuid5) then { qr.questionnaire as can -> bundle.entry as e6, e6.resource = (can.resolve()) as q, q.id = uuid() as uuid6, e6.fullUrl = append('urn:uuid:', uuid6) then QrToBundle(qr, q, patient, questionnaireresp, servicerequest, composition, bundle) "orfbundle"; qr then RadOrderQrToServiceRequest(qr, patient, bundle, composition, servicerequest) "servicerequest"; } "orfbundle"; } group RadOrderQrToServiceRequest(source qr : QuestionnaireResponse, target patient : Patient, target bundle : Bundle, target composition : Composition, target serviceRequest : ServiceRequest) { qr.item as grp where linkId = 'requestedService' then RequestedServiceItems(grp, serviceRequest) "requestedService"; qr.item as grp where linkId = 'reason' then ReasonServiceItems(grp, serviceRequest) "reason"; qr.item as grp where linkId = 'imagingService' then ImagingServiceItems(grp, serviceRequest) "imagingService"; qr.item as grp where linkId = 'orderDetail' then OrderDetailServiceItems(grp, serviceRequest) "orderDetail"; qr.item as grp where linkId = 'diagnosisList' then DiagnosisListServiceItems(grp, patient, bundle, serviceRequest) "diagnosisList"; qr.item as grp where linkId = 'caveat' then CaveatServiceItems(grp, patient, bundle, serviceRequest) "Caveat"; } group RequestedServiceItems(source src : BackboneElement, target serviceRequest : ServiceRequest) { src.item as item where ((linkId.value = 'requestedService.service') and answer.exists()) then { item.answer as answer then { answer.value : Coding as coding -> serviceRequest.category as cc, cc.coding = coding "service"; } "valueCoding"; } "answer"; } group ReasonServiceItems(source src : BackboneElement, target serviceRequest : ServiceRequest) { src.item as item where ((linkId.value = 'reason.question') and answer.exists()) then { item.answer as answer then { answer.value : string as value -> serviceRequest.reasonCode as reasonCode, reasonCode.text = value "question"; } "valueString"; } "answer"; } group ImagingServiceItems(source src : BackboneElement, target serviceRequest : ServiceRequest) { src.item as item where ((linkId.value = 'imagingService.type') and answer.exists()) then { item.answer as answer then { answer.value : Coding as coding -> serviceRequest.code as code, code.coding = coding "service"; } "valueCoding"; } "answer"; } group OrderDetailServiceItems(source src : BackboneElement, target serviceRequest : ServiceRequest) { src.item as item where ((linkId.value = 'orderDetail.imagingRegion') and answer.exists()) then { item.answer as answer then { 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 "imagingRegion"; } "valueCoding"; } "answer"; src.item as item where ((linkId.value = 'orderDetail.imagingFocus') and answer.exists()) then { item.answer as answer then { answer.value : Coding as coding -> serviceRequest.bodySite as cc, cc.coding = coding "imagingFocus"; } "valueCoding"; } "answer"; src.item as item where ((linkId.value = 'orderDetail.laterality') and answer.exists()) then { item.answer as answer then { 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 "laterality"; } "valueCoding"; } "answer"; src.item as item where ((linkId.value = 'orderDetail.viewType') and answer.exists()) then { item.answer as answer then { 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 "viewType"; } "valueCoding"; } "answer"; src.item as item where ((linkId.value = 'orderDetail.maneuverType') and answer.exists()) then { item.answer as answer then { 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 "maneuverType"; } "valueCoding"; } "answer"; src.item as item where ((linkId.value = 'orderDetail.guidanceForAction') and answer.exists()) then { item.answer as answer then { 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 "guidanceForAction"; } "valueCoding"; } "answer"; } group DiagnosisListServiceItems(source src : BackboneElement, target patient : Patient, target bundle : Bundle, target serviceRequest : ServiceRequest) { src.item as item where ((linkId.value = 'diagnosisList.secondaryDiagnosis') and answer.exists()) then { item.answer as answer then { 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) "secondaryDiagnosis"; } "valueString"; } "answer"; } group CaveatServiceItems(source src : BackboneElement, target patient : Patient, target bundle : Bundle, target serviceRequest : ServiceRequest) { src.item as item where ((linkId.value = 'caveat.bloodCoagulation') and answer.exists()) then { item.answer as answer then { answer.value : boolean as value where answer.valueBoolean -> 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.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) "bloodCoagulation"; } "valueString"; } "answer"; src.item as item where ((linkId.value = 'caveat.renalInsufficiency') and answer.exists()) then { item.answer as answer then { answer.value : boolean as value where answer.valueBoolean -> 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.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 { // FIXME TODO answer.item as item2 where (linkId.value = 'caveat.renalInsufficiency.creatinineClearance') then RenalInsufficiencyCreatinineServiceItems(item2, patient, bundle, serviceRequest, condition) "RenalInsufficiencyCreatinineServiceItems"; answer.item as item2 where (linkId.value = 'caveat.renalInsufficiency.creatinine') then RenalInsufficiencyCreatinineServiceItems(item2, patient, bundle, serviceRequest, condition) "RenalInsufficiencyCreatinineServiceItems"; } "renalInsufficiency"; } "valueString"; } "answer"; src.item as item where ((linkId.value = 'caveat.claustrophobia') and answer.exists()) then { item.answer as answer then { answer.value : boolean as value where answer.valueBoolean -> 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.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) "claustrophobia"; } "valueString"; } "answer"; src.item as item where ((linkId.value = 'caveat.bodyPiercing') and answer.exists()) then { item.answer as answer then { answer.value : boolean as value where answer.valueBoolean -> 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.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) "bodyPiercing"; } "valueString"; } "answer"; src.item as item where ((linkId.value = 'caveat.device') and answer.exists()) then { item.answer as answer then { 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.coding as coding2, coding2.code = '397578001', coding2.system = 'http://snomed.info/sct', coding2.display = 'Device in situ (finding)', condition.subject as subject, subject.reference = ('urn:uuid:' + patient.id), condition.note as note, note.text = value "device"; } "valueString"; } "answer"; src.item as item where ((linkId.value = 'caveat.hyperthyroidism') and answer.exists()) then { item.answer as answer then { answer.value : boolean as value where answer.valueBoolean -> 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.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) "hyperthyroidism"; } "valueString"; } "answer"; src.item as item where ((linkId.value = 'caveat.diabetes') and answer.exists()) then { item.answer as answer then { answer.value : boolean as value where answer.valueBoolean -> 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.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) "diabetes"; } "valueString"; } "answer"; src.item as item where ((linkId.value = 'caveat.gravida') and answer.exists()) then { item.answer as answer then { answer.value : boolean as value where answer.valueBoolean -> 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.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) "gravida"; } "valueString"; } "answer"; src.item as item where ((linkId.value = 'caveat.contrastMediaAllergy') and answer.exists()) then { item.answer as answer then { answer.value : boolean as value where answer.valueBoolean -> 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.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) "contrastMediaAllergy"; } "valueString"; } "answer"; src.item as item where ((linkId.value = 'caveat.drugPrescription') and answer.exists()) then { item.answer as answer then { 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.coding as coding2, coding2.code = '182817000', coding2.system = 'http://snomed.info/sct', coding2.display = 'Drug prescription (situation)', condition.subject as subject, subject.reference = ('urn:uuid:' + patient.id), condition.note as note, note.text = value "drugPrescription"; } "valueString"; } "answer"; } group RenalInsufficiencyCreatinineServiceItems(source src : BackboneElement, target patient : Patient, target bundle : Bundle, target serviceRequest : ServiceRequest, target condition : Condition) { src -> bundle.entry as e, e.resource = create('Observation') as observation, observation.id = uuid() as uuid, e.fullUrl = ('urn:uuid:' + uuid), observation.status = 'final', observation.code as code, code.coding as coding2, coding2.code = '723188008', coding2.system = 'http://snomed.info/sct', coding2.display = 'Renal insufficiency (disorder)', condition.evidence as evidence, evidence.detail as detail, detail.reference = ('urn:uuid:' + uuid), observation.subject as subject, subject.reference = ('urn:uuid:' + patient.id) then { src.item as item where ((linkId.value = 'caveat.renalInsufficiency.creatinine.quantity') and answer.exists()) then { item.answer as answer then { answer.value : Quantity as value -> observation.value = value; }; } "quantity"; src.item as item where ((linkId.value = 'caveat.renalInsufficiency.creatinine.dateTime') and answer.exists()) then { item.answer as answer then { answer.value : dateTime as value -> observation.effective = value; }; } "dateTime"; } "observation"; }
Radiologoy QuestionnaireResponse to Bundle
((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 = 'diagnosisList.secondaryDiagnosis') and answer.exists())
((linkId.value = 'caveat.bloodCoagulation') and answer.exists())
((linkId.value = 'caveat.renalInsufficiency') and answer.exists())
(linkId.value = 'caveat.renalInsufficiency.creatinine')
FIXME TODO answer.item as item2 where (linkId.value = 'caveat.renalInsufficiency.creatinineClearance') then RenalInsufficiencyCreatinineServiceItems(item2, patient, bundle, serviceRequest, condition) "RenalInsufficiencyCreatinineServiceItems";
((linkId.value = 'caveat.claustrophobia') and answer.exists())
((linkId.value = 'caveat.bodyPiercing') and answer.exists())
((linkId.value = 'caveat.device') and answer.exists())
((linkId.value = 'caveat.hyperthyroidism') and answer.exists())
((linkId.value = 'caveat.diabetes') and answer.exists())
((linkId.value = 'caveat.gravida') and answer.exists())
((linkId.value = 'caveat.contrastMediaAllergy') and answer.exists())
((linkId.value = 'caveat.drugPrescription') and answer.exists())
((linkId.value = 'caveat.renalInsufficiency.creatinine.quantity') and answer.exists())
((linkId.value = 'caveat.renalInsufficiency.creatinine.dateTime') and answer.exists())