FHIR Chat · FHIR Mapping language & extensions [copy of query posted in · mapping-framework

Stream: mapping-framework

Topic: FHIR Mapping language & extensions [copy of query posted in


view this post on Zulip Dave Barnet (Nov 08 2021 at 10:00):

Hopefully a quick and easy question/answer. We are looking at transforming STU3 profiles into R4 profiles. Most of the mappings are provided on the R4 resources on the "R3 Conversions" tab. It looks like there's a general format to the syntax in that elements that are on the base resouce and not in a backbone element are addressed directly (for example src.identifier -> tgt.identifier;) those in a backbone element are put into their own group and dealt with. I'm a bit unsure as to what to do with extensions. For example, is the source (STU3 profile) has a complex extension that part of now belongs on a R4 element - what's the mapping language syntax? For example, within a STU3 MedicationRequest we have a complex extension that has information about repeat medication
Extension url:https:[base]/StructureDefinition/Extension-MedicationRepeatInformation
extension url: numberOfRepeatPrescriptionsAllowed (as an integer)
extension url: numberOfRepeatPrescriptionsIssued (as an integer)
The numberOfRepeatPrescriptionsAllowed now maps to the R4 element MedicationRequest.dispenseRequest.numberOfRepeatsAllowed
How would we represent this in FHIR mapping language? - in terms of how do you reference an element in a complex extension?

view this post on Zulip Oliver Egger (Nov 18 2021 at 10:23):

you match first the complex extension and match then within the complex extension, same as you would do with a backbone element.
I don't have an example for R3 to R4, but for R4 to CDA we do the following (where ch-emed-ext-treatmentplan is a complex extension):

https://github.com/hl7ch/cda-fhir-maps/blob/master/input/maps/BundleToCdaChEmed.map#L433

  medicationDispense.extension as extension where url='http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan'
    -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode='REFR',
        entryRelationship.substanceAdministration as substanceAdministration
          then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference";

and then https://github.com/hl7ch/cda-fhir-maps/blob/master/input/maps/BundleToCdaChEmed.map#L286

group MTPReferenceEntryContentModule(source ext: Extension, target substanceAdministration : SubstanceAdministration) {
 ext.extension as extension where $this.url='id' then {
    extension.valueIdentifier as valueIdentifier -> substanceAdministration.id as id then IdentifierII(valueIdentifier, id) "id";
  } "id";

you can do this also without a group and list the rules after then.


Last updated: Apr 12 2022 at 19:14 UTC