FHIR Cross-Version Mapping Pack
0.1.0 - Ballot for Release 5.1.0 International flag

FHIR Cross-Version Mapping Pack, published by HL7 International / FHIR Infrastructure. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/fhir-cross-version/ and changes regularly. See the Directory of published versions

StructureMap: DiagnosticOrder Transforms: R3 to R2

Official URL: http://hl7.org/fhir/StructureMap/ProcedureRequestDO3to2 Version: 0.1.0
Standards status: Draft Maturity Level: 1 Computable Name: ProcedureRequestDO3to2

DiagnosticOrderTransformsR3toR2

/// url = 'http://hl7.org/fhir/StructureMap/ProcedureRequestDO3to2'
/// name = 'ProcedureRequestDO3to2'
/// title = 'DiagnosticOrder Transforms: R3 to R2'
/// status = 'active'

uses "http://hl7.org/fhir/3.0/ProcedureRequest" alias DiagnosticRequest as source
uses "http://hl7.org/fhir/1.0/DiagnosticOrder" alias DiagnosticOrderR2 as target

imports "http://hl7.org/fhir/StructureMap/*3to2"

// in R3, DiagnosticOrder is folded into ProcedureRequest, and there's no easy
// way to tell them apart. it requires special knowledge to decide to convert
// a procedure request back to a DiagnosticOrder, but they are marked with an
// extension in case this helps
group DiagnosticOrder(source src : ProcedureRequest, target tgt : DiagnosticOrderR2) extends DomainResource <<type+>> {
  src.subject -> tgt.subject "DiagnosticOrder-subject";
  src.requester as v then {
    v.agent -> tgt.orderer "DiagnosticOrder-orderer-inner";
  } "DiagnosticOrder-orderer";
  src.identifier -> tgt.identifier "DiagnosticOrder-identifier";
  src.context -> tgt.encounter "DiagnosticOrder-encounter";
  src.reasonCode -> tgt.reason "DiagnosticOrder-reason";
  src.supportingInfo -> tgt.supportingInformation "DiagnosticOrder-supportingInformation";
  src.status where src.intent = 'proposal' -> tgt.status = 'proposed' "DiagnosticOrder-status1";
  src.status where src.intent = 'plan' -> tgt.status = 'planned' "DiagnosticOrder-status2";
  src.status as v where (src.intent != 'proposal') and (src.intent != 'plan') -> tgt.status = translate(v, 'http://hl7.org/fhir/ConceptMap/ProcedureRequest.status-R3toR2', 'code') "DiagnosticOrder-status3";
  src.priority -> tgt.priority "DiagnosticOrder-priority";
  src where src.authoredOn.exists() or src.requester.exists() -> tgt.event as ev then doEvent(src, ev) "DiagnosticOrder-event";
  src where src.code.exists() -> tgt.item as it then doItem(src, it) "DiagnosticOrder-item";
  src.note -> tgt.note "DiagnosticOrder-note";
}

group doEvent(source src, target tgt) {
  src -> tgt.status = 'requested' "event-status";
  src.authoredOn -> tgt.dateTime "event-dateTime";
}

group doItem(source src, target tgt) {
  src.code -> tgt.code "item-code";
}