Stream: mapping-framework
Topic: Production use of FHIR mapping language
Anthony Rocco (Nov 22 2021 at 19:35):
Hi - relatively new to FHIR. The challenge I'm faced with is consuming data from a certain EHR vendor's proprietary API and transforming the consumed data to FHIR resources. One thing I'm come across is the FHIR mapping language (http://hl7.org/fhir/r4/mapping-language.html). Is the mapping language spec only intended to transform data from one version of FHIR to another, or does my use-case also fit the intended use-case of the mapping language spec? Have others' implemented this spec in a production system? I see there are mapping engines available in Java, can anyone speak to how stable they are or even point me to an example implementation? Thanks.
Lloyd McKenzie (Nov 22 2021 at 20:19):
@Grahame Grieve
Oliver Egger (Nov 22 2021 at 22:19):
@Anthony Rocco you can use the mapping language to convert from non-fhir representation, e.g. from CDA to FHIR, you need to have a Logical Model of the data if it is not FHIR. The Java reference implementation includes FHIR Mapping Language support, you can use with the FHIR validator directly. We do use this implementation on top of hapi in matchbox (see https://github.com/ahdis/matchbox) however not yet in production, you can try it out here: https://ahdis.github.io/matchbox-formfiller/#/mappinglanguage which uses the test instance https://test.ahdis.ch/matchbox/fhir/metadata
Anthony Rocco (Nov 23 2021 at 15:09):
Oliver Egger said:
Anthony Rocco you can use the mapping language to convert from non-fhir representation, e.g. from CDA to FHIR, you need to have a Logical Model of the data if it is not FHIR. The Java reference implementation includes FHIR Mapping Language support, you can use with the FHIR validator directly. We do use this implementation on top of hapi in matchbox (see https://github.com/ahdis/matchbox) however not yet in production, you can try it out here: https://ahdis.github.io/matchbox-formfiller/#/mappinglanguage which uses the test instance https://test.ahdis.ch/matchbox/fhir/metadata
Thanks for the reply Oliver! When you say "you need to have a Logical Model of the data if it is not FHIR", is there a specific way this model needs to be defined in order for the mapping engine to function properly, ie. a json representation of the model?
EDIT: Looking at this some more I see the data needs to be represented as a FHIR structure definition resource, is that correct? So then I take it the structure definition resource is able to be used to represent non-FHIR data models?
Lloyd McKenzie (Nov 23 2021 at 15:26):
It needs to be expressed as a StructureDefinition. (Syntax can be XML, JSON or RDF)
Oliver Egger (Nov 23 2021 at 17:01):
yes, see 5.3.5.4 Logical Models http://www.hl7.org/fhir/structuredefinition.html#logical
Anthony Rocco (Nov 24 2021 at 18:42):
Oliver Egger said:
yes, see 5.3.5.4 Logical Models http://www.hl7.org/fhir/structuredefinition.html#logical
Thanks! One thing I'm not fully understanding - even after looking at some examples - is the difference between "snapshot" and "differential" and which I would use when defining a non-FHIR structure.
Oliver Egger (Nov 24 2021 at 19:13):
Use the differential, this is then applied to the snapshot of the base definition. if you are defining the StructureDefinition in an Implementation Guide the snapshot will be automatically created, see example here: https://www.alis-connect.ch/fhir/StructureDefinition-Header.html
Anthony Rocco (Nov 29 2021 at 18:54):
@Oliver Egger
I started to put together a POC for using FHIR mapping language w/ the mapping engine in the HAPI library.
I'm performing the transform like this:
Element source = Manager.parse(context, new FileInputStream(sourcePath), Manager.FhirFormat.XML);
Element destination = Manager.build(context, context.getStructure(DESTINATION_URL));
structureMapUtilities.transform(null, source, structureMaps.get(mapUrl), destination);
However the compose method for IParser expected a Resource, not an Element, ie
void compose(OutputStream var1, Resource var2) throws IOException;
Any idea how to serialize the destination object to xml then? Thanks
Oliver Egger (Nov 29 2021 at 19:02):
you need to use the parsers from org.hl7.fhir.r5.elementmodel, see https://github.com/ahdis/matchbox/blob/main/src/main/java/ch/ahdis/matchbox/mappinglanguage/StructureMapTransformProvider.java#L190
Anthony Rocco (Nov 30 2021 at 15:51):
Oliver Egger said:
you need to use the parsers from org.hl7.fhir.r5.elementmodel, see https://github.com/ahdis/matchbox/blob/main/src/main/java/ch/ahdis/matchbox/mappinglanguage/StructureMapTransformProvider.java#L190
Thanks Oliver! I tried performing the mapping in step 8 here https://github.com/ahdis/fhir-mapping-tutorial/blob/master/maptutorial/step8/logical/structuredefinition-tleft.xml using my program, however it fails because Manager.parse expects there to be a snapshot in the StructureDefinition for TLeft. I tried adding a snapshot node with the same value as differential but then get the error org.hl7.fhir.exceptions.DefinitionException: Unable to find type 'code' for name 'd' on property TLeft.d
. What would be the correct thing to do here?
Edit: I suspect this is because I havent loaded the definition for code? I think I need to download the definitions zip from here http://hl7.org/fhir/downloads.html and load that into my context.
Edit: Yep, got it working.
Last updated: Apr 12 2022 at 19:14 UTC