R4 Draft for Comment

This page is part of the FHIR Specification (v3.2.0: R4 Ballot 1). 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: Informative Compartments: Patient, Practitioner, RelatedPerson

R2 : R3 Conversion maps for MedicationStatement.

Functional status for this map: 7 tests that all execute ok. All tests pass round-trip testing and 1 r3 resources are invalid (1 errors). (see documentation)

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

uses "http://hl7.org/fhir/DSTU2/StructureDefinition/MedicationStatement" alias MedicationStatementR2 as source
uses "http://hl7.org/fhir/StructureDefinition/MedicationStatement" alias MedicationStatement as target

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

group for type+types  MedicationStatement extends DomainResource
  input src : MedicationStatementR2 as source
  input tgt : MedicationStatement as target

  "MedicationStatement-identifier" : for src.identifier make tgt.identifier
  "MedicationStatement-subject" : for src.patient make tgt.subject
  "MedicationStatement-informationSource" : for src.informationSource make tgt.informationSource
  "MedicationStatement-dateAsserted" : for src.dateAsserted make tgt.dateAsserted
  "MedicationStatement-status" : for src.status make tgt.status
  "MedicationStatement-wasNotTaken" : for src.wasNotTaken as vt where $this = true make tgt.taken = "n"
  "MedicationStatement-wasNotTaken" : for src.wasNotTaken as vt where $this = false make tgt.taken = "y"
  "MedicationStatement-reasonNotTaken" : for src.reasonNotTaken make tgt.reasonNotTaken
  "MedicationStatement-reasonForUse" : for src.reasonForUse where $this is CodeableConcept make tgt.reasonCode
  "MedicationStatement-reasonForUse" : for src.reasonForUse where $this is Reference make tgt.reasonReference
  "MedicationStatement-effective" : for src.effective make tgt.effective
  "MedicationStatement-note" : for src.note make tgt.note
  "MedicationStatement-supportingInformation" : for src.supportingInformation make tgt.derivedFrom
  "MedicationStatement-medication" : for src.medication make tgt.medication
  
  "MedicationStatement-dosage" : for src.dosage as vs0 make tgt.dosage as vt0 then mstDosage(vs0, vt0)
endgroup

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

  "DosageInstruction-text" : for src.text make tgt.text
  "DosageInstruction-timing" : for src.timing make tgt.timing
  "DosageInstruction-asNeeded" : for src.asNeeded make tgt.asNeeded 
  "DosageInstruction-site" : for src.site where $this is CodeableConcept make tgt.site // todo: handle Reference?
  "DosageInstruction-route" : for src.route make tgt.route
  "DosageInstruction-method" : for src.method make tgt.method
  "DosageInstruction-quantity" : for src.quantity make tgt.dose
  "DosageInstruction-rate" : for src.rate make tgt.rate 
  "DosageInstruction-maxDosePerPeriod" : for src.maxDosePerPeriod make tgt.maxDosePerPeriod
endgroup

map "http://hl7.org/fhir/StructureMap/MedicationStatement3to2" = "R3 to R2 Conversion for MedicationStatement"

uses "http://hl7.org/fhir/StructureDefinition/MedicationStatement" alias MedicationStatement as source
uses "http://hl7.org/fhir/DSTU2/StructureDefinition/MedicationStatement" alias MedicationStatementR2 as target

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

group for type+types  MedicationStatement extends DomainResource
  input src : MedicationStatement as source
  input tgt : MedicationStatementR2 as target

  "MedicationStatement-identifier" : for src.identifier make tgt.identifier
  "MedicationStatement-subject" : for src.subject make tgt.patient
  "MedicationStatement-informationSource" : for src.informationSource make tgt.informationSource
  "MedicationStatement-dateAsserted" : for src.dateAsserted make tgt.dateAsserted
  "MedicationStatement-status" : for src.status check src.status != 'stopped' and status != 'on-hold' make tgt.status
  "MedicationStatement-wasNotTaken" : for src.taken as vt where $this = 'n' make tgt.wasNotTaken = true
  "MedicationStatement-wasNotTaken" : for src.taken as vt where $this = 'y' make tgt.wasNotTaken = false
  "MedicationStatement-reasonNotTaken" : for src.reasonNotTaken make tgt.reasonNotTaken
  "MedicationStatement-reasonForUse1" : for src.reasonCode make tgt.reasonForUse
  "MedicationStatement-reasonForUse2" : for src.reasonReference make tgt.reasonForUse
  "MedicationStatement-effective" : for src.effective make tgt.effective
  "MedicationStatement-note" : for src.note make tgt.note
  "MedicationStatement-supportingInformation" : for src.derivedFrom make tgt.supportingInformation
  "MedicationStatement-medication" : for src.medication make tgt.medication
  
  "MedicationStatement-dosage" : for src.dosage as vs0 make tgt.dosage as vt0 then mstDosage(vs0, vt0)
endgroup

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

  "DosageInstruction-text" : for src.text make tgt.text
  "DosageInstruction-timing" : for src.timing make tgt.timing
  "DosageInstruction-asNeeded" : for src.asNeeded make tgt.asNeeded 
  "DosageInstruction-site" : for src.site make tgt.site // todo: handle Reference?
  "DosageInstruction-route" : for src.route make tgt.route
  "DosageInstruction-method" : for src.method make tgt.method
  "DosageInstruction-quantity" : for src.dose make tgt.quantity
  "DosageInstruction-rate" : for src.rate make tgt.rate 
  "DosageInstruction-maxDosePerPeriod" : for src.maxDosePerPeriod make tgt.maxDosePerPeriod
endgroup

medicationstatement-example
  • ERROR @ MedicationStatement: Profile http://hl7.org/fhir/StructureDefinition/MedicationStatement, Element 'MedicationStatement.taken': minimum required = 1, but only found 0 (src = InstanceValidator)