FHIR Release 3 (STU)

This page is part of the FHIR Specification (v3.0.2: STU 3). The current version which supercedes this version is 5.0.0. For a full list of available versions, see the Directory of published versions . Page versions: R5 R4B R4 R3

Pharmacy Work GroupMaturity Level: N/ABallot Status: InformativeCompartments: Encounter, Patient, Practitioner

R2 : R3 Converson maps for MedicationRequest.

Functional status for this map: 18 tests of which 1 fail to execute. All tests pass round-trip testing and 5 r3 resources are invalid (6 errors). (see documentation)

map "http://hl7.org/fhir/StructureMap/MedicationOrder2to3" = "R2 to R3 Conversions for MedicationOrder"

uses "http://hl7.org/fhir/DSTU2/StructureDefinition/MedicationOrder" alias MedicationOrderR2 as source
uses "http://hl7.org/fhir/StructureDefinition/MedicationRequest" alias MedicationRequest as target

imports "http://hl7.org/fhir/StructureMap/*2to3"

group for type+types MedicationOrder extends DomainResource
  input src : MedicationOrderR2 as source
  input tgt : MedicationRequest as target

  "MedicationOrder-intent" : for src make tgt.intent = "order"
  "MedicationOrder-identifier" : for src.identifier make tgt.identifier
  "MedicationOrder-dateWritten" : for src.dateWritten make tgt.authoredOn
  // dateEnded, reasonEnded (see Provenance)
  "MedicationOrder-status" : for src.status make tgt.status
  "MedicationOrder-patient" : for src.patient make tgt.subject
  "MedicationOrder-prescriber" : for src where prescriber.exists() make tgt.requester as vt then medRequestor(src, vt)
  "MedicationOrder-encounter" : for src.encounter make tgt.context
  "MedicationOrder-reasonCode" : for src.reason where $this is CodeableConcept make tgt.reasonCode
  "MedicationOrder-reasonCode" : for src.reason where $this is Reference make tgt.reasonReference
  "MedicationOrder-note" : for src.note make tgt.note // only_one
  "MedicationOrder-medication" : for src.medication make tgt.medication 

  "MedicationOrder-dosageInstruction" : for src.dosageInstruction as vs make tgt.dosageInstruction as vt then medDosageInstruction(vs, vt) 
  "MedicationOrder-dispenseRequest" : for src.dispenseRequest as vs check medication.empty() make tgt.dispenseRequest as vt then medDispenseRequest(vs, vt) 
  "MedicationOrder-substitution" : for src.substitution as vs make tgt.substitution as vt then medSubstitution(vs, vt) 
  "MedicationOrder-priorPrescription" : for src.priorPrescription make tgt.priorPrescription 
endgroup

group medDosageInstruction extends Element //? BackboneElement
  input src as source
  input tgt as target

  "MedicationOrder.dosage-text" : for src.text make tgt.text
  "MedicationOrder.dosage-additionalInstructions" : for src.additionalInstructions make tgt.additionalInstruction
  "MedicationOrder.dosage-timing" : for src.timing make tgt.timing
  "MedicationOrder.dosage-asNeeded" : for src.asNeeded make tgt.asNeeded
  "MedicationOrder.dosage-site" : for src.site where $this is CodeableConcept make tgt.site  
  "MedicationOrder.dosage-route" : for src.route make tgt.route
  "MedicationOrder.dosage-method" : for src.method make tgt.method
  "MedicationOrder.dosage-dose" : for src.dose make tgt.dose
  "MedicationOrder.dosage-rate" : for src.rate make tgt.rate
  "MedicationOrder.dosage-maxDosePerPeriod" : for src.maxDosePerPeriod make tgt.maxDosePerPeriod 
endgroup


group medDispenseRequest extends BackboneElement
  input src as source
  input tgt as target

  // the medication at this level is a duplicate, and should not be different to the main medication 
  // (in spite of R2 containing an example that does just that). it is ignored here
  "MedicationOrder.dispenseRequest-validityPeriod" : for src.validityPeriod make tgt.validityPeriod
  "MedicationOrder.dispenseRequest-numberOfRepeatsAllowed" : for src.numberOfRepeatsAllowed make tgt.numberOfRepeatsAllowed
  "MedicationOrder.dispenseRequest-quantity" : for src.quantity make tgt.quantity
  "MedicationOrder.dispenseRequest-expectedSupplyDuration" : for src.expectedSupplyDuration as v make tgt.expectedSupplyDuration as d then QuantityToDuration(v, d)
endgroup

group medSubstitution extends BackboneElement
  input src as source
  input tgt as target

  "MedicationOrder.substitution-reason" : for src.reason make tgt.reason
endgroup

group medRequestor 
  input src as source
  input tgt as target

  "MedicationOrder-prescriber2" : for src.prescriber make tgt.agent 
endgroup
map "http://hl7.org/fhir/StructureMap/MedicationOrder3to2" = "R3 to R2 Conversions for MedicationOrder"

uses "http://hl7.org/fhir/StructureDefinition/MedicationRequest" alias MedicationRequest as source
uses "http://hl7.org/fhir/DSTU2/StructureDefinition/MedicationOrder" alias MedicationOrderR2 as target

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

group for type+types MedicationRequest extends DomainResource
  input src : MedicationRequest as source
  input tgt : MedicationOrderR2 as target

  "MedicationOrder-identifier" : for src.identifier make tgt.identifier
  "MedicationOrder-dateWritten" : for src.authoredOn make tgt.dateWritten
  // dateEnded
  // reasonEnded
  "MedicationOrder-status" : for src.status check $this != 'cancelled' and $this != 'unknown' make tgt.status 
  "MedicationOrder-patient" : for src.subject make tgt.patient
  "MedicationOrder-prescriber" : for src.requester as req make tgt.prescriber as vt then medRequestor(req, vt)
  "MedicationOrder-encounter" : for src.context make tgt.encounter
  "MedicationOrder-reasonCode" : for src.reasonCode make tgt.reason
  "MedicationOrder-reasonCode" : for src.reasonReference make tgt.reason
  "MedicationOrder-note" : for src.note only_one make tgt.note
  "MedicationOrder-medication" : for src.medication make tgt.medication 

  "MedicationOrder-dosageInstruction" : for src.dosageInstruction as vs make tgt.dosageInstruction as vt then medDosageInstruction(vs, vt) 
  "MedicationOrder-dispenseRequest" : for src.dispenseRequest as vs make tgt.dispenseRequest as vt then medDispenseRequest(vs, vt) 
  "MedicationOrder-substitution" : for src.substitution as vs make tgt.substitution as vt then medSubstitution(vs, vt) 
  "MedicationOrder-priorPrescription" : for src.priorPrescription make tgt.priorPrescription 
endgroup

group medDosageInstruction extends Element //? BackboneElement
  input src as source
  input tgt as target

  "MedicationOrder.dosage-text" : for src.text make tgt.text
  "MedicationOrder.dosage-additionalInstructions" : for src.additionalInstruction only_one make tgt.additionalInstructions
  "MedicationOrder.dosage-timing" : for src.timing make tgt.timing
  "MedicationOrder.dosage-asNeeded" : for src.asNeeded make tgt.asNeeded
  "MedicationOrder.dosage-site" : for src.site make tgt.site  
  "MedicationOrder.dosage-route" : for src.route make tgt.route
  "MedicationOrder.dosage-method" : for src.method make tgt.method
  "MedicationOrder.dosage-dose" : for src.dose make tgt.dose
  "MedicationOrder.dosage-rate" : for src.rate make tgt.rate
  "MedicationOrder.dosage-maxDosePerPeriod" : for src.maxDosePerPeriod make tgt.maxDosePerPeriod
endgroup


group medDispenseRequest extends BackboneElement
  input src as source
  input tgt as target

  "MedicationOrder.dispenseRequest-validityPeriod" : for src.validityPeriod make tgt.validityPeriod
  "MedicationOrder.dispenseRequest-numberOfRepeatsAllowed" : for src.numberOfRepeatsAllowed make tgt.numberOfRepeatsAllowed
  "MedicationOrder.dispenseRequest-quantity" : for src.quantity make tgt.quantity
  "MedicationOrder.dispenseRequest-expectedSupplyDuration" : for src.expectedSupplyDuration as v make tgt.expectedSupplyDuration as d then DurationToQuantity(v, d)
endgroup

group medSubstitution extends BackboneElement
  input src as source
  input tgt as target

  "MedicationOrder.substitution-reason" : for src.reason make tgt.reason
endgroup

group medRequestor 
  input src as source
  input tgt as target

  "MedicationOrder-prescriber2" : for src.agent as sa then Reference(sa, tgt)
endgroup
medicationorder-example
  • ERROR @ MedicationRequest.dosageInstruction.extension[2][url='http://hl7.org/fhir/StructureDefinition/pharmacy-core-infuseOver']: The Extension 'http://hl7.org/fhir/StructureDefinition/pharmacy-core-infuseOver' definition allows for the types [Duration] but found type Quantity (src = InstanceValidator)
  • INFORMATION @ MedicationRequest.dosageInstruction.extension[2].valueQuantity: Could not verify slice for profile http://hl7.org/fhir/StructureDefinition/pharmacy-core-infuseOver (src = InstanceValidator)
f001
  • ERROR @ MedicationRequest.dispenseRequest.expectedSupplyDuration: There SHALL be a code if there is a value and it SHALL be an expression of time. If system is present, it SHALL be UCUM. [code.exists() implies ((system = %ucum) and value.exists())] (src = InstanceValidator)
medrx007
  • ERROR @ MedicationRequest: Profile http://hl7.org/fhir/StructureDefinition/MedicationRequest, Element 'MedicationRequest.subject': minimum required = 1, but only found 0 (src = InstanceValidator)
medrx008
  • ERROR @ MedicationRequest: Profile http://hl7.org/fhir/StructureDefinition/MedicationRequest, Element 'MedicationRequest.subject': minimum required = 1, but only found 0 (src = InstanceValidator)
medrx009
  • ERROR @ MedicationRequest: Profile http://hl7.org/fhir/StructureDefinition/MedicationRequest, Element 'MedicationRequest.subject': minimum required = 1, but only found 0 (src = InstanceValidator)