Stream: implementers
Topic: FHIR mapping language implementations
Flavius Butnariu (Mar 13 2017 at 08:43):
Dear all,
I was wondering what FHIR implementations are out there that support to some extent the FHIR mapping language.
I will be grateful for any information you can provide.
With kind regards,
Flavius
Oliver Egger (Mar 13 2017 at 19:11):
the java reference implemementation has the fhir mapping language included, i startet a tutorial, but got diverted by other work, have to update as soon as i get time: https://github.com/ahdis/fhir-mapping-tutorial see
Flavius Butnariu (Apr 28 2017 at 11:20):
I know that the Java reference implementation can handle mappings specified in the FHIR mapping language from logical models to FHIR resources. The question is: can it also handle mappings to extended FHIR resources, i.e., a FHIR resource extended with additional data elements? Many thanks!
Lloyd McKenzie (Apr 28 2017 at 13:57):
Unless you're using the built-in extension capability, you couldn't call such structures FHIR resources. FHIR doesn't allow the introduction of custom elements except as extensions. If you're talking about extensions, the language should support mapping to any StructureDefinition - including profiles that make use of extensions.
Flavius Butnariu (May 01 2017 at 13:08):
@Lloyd McKenzie thank you for your reply.
I understand that I cannot have something like
<Observation xmlns="http://hl7.org/fhir"> ... <comment value="some string"/> <additionalDataElement value="some other string"/> ... </Observation>
but instead something like
<Observation xmlns="http://hl7.org/fhir"> ... <comment value="some string"/> <extension url="structure/definition/of/extension"> <valueString value="some other string"/> </extension> ... </Observation>
Here's what I try to accomplish:
- Extend a FHIR resource with an additional data element.
- Map some other endpoint to this additional data element using the FHIR mapping language.
- Run the mapping using the Java reference implementation.
The Java reference implementation can handle a mapping to a data element such as comment
. However, I struggle to make it work with my additional data element. Can this be accomplished in the current implementation?
Lloyd McKenzie (May 01 2017 at 16:40):
Make sure the extension is at the right place in your XML instance - extensions are one of the first elements allowed (only "id" and a couple of other elements are allowed to appear sooner). Also make sure your URL is a full URL. Beyond that, I'm pretty sure the StructureMap process works with extensions.
Flavius Butnariu (May 02 2017 at 15:59):
I still can't manage to map to an extended FHIR resource. Maybe another pair of eyes can quickly spot what I'm doing wrong.
On the source side, I have a simple logical model - thanks to @Oliver Egger - specified by the structure definition available here.
<TLeft xmlns="http://hl7.org/fhir/tutorial"> <a value="some string" /> </TLeft>
On the target side, I have FHIR resource Observation-genetics extended from the standard FHIR resource Observation.
Now let's say I wanna map a
of TLeft
to observation-geneticsDNARegionName
of Observation-genetics
. It makes little sense, but both are of type string
, so why not?
map "http://hl7.org/fhir/StructureMap/tutorial" = "tutorial" uses "http://hl7.org/fhir/StructureDefinition/tutorial-left" as source uses "http://hl7.org/fhir/StructureDefinition/observation-genetics" as target group tutorial input source : TLeft as source input target : observation-genetics as target rule_a: for source.a as a make target.observation-geneticsDNARegionName = a endgroup
The reference implementation will actually complain about this mapping.
org.hl7.fhir.dstu3.utils.FHIRLexer$FHIRLexerException: Error at 8, 6: Found "-" expecting "as" at org.hl7.fhir.dstu3.utils.FHIRLexer.error(FHIRLexer.java:101) at org.hl7.fhir.dstu3.utils.FHIRLexer.error(FHIRLexer.java:97) at org.hl7.fhir.dstu3.utils.FHIRLexer.token(FHIRLexer.java:266) at org.hl7.fhir.dstu3.utils.StructureMapUtilities.parseInput(StructureMapUtilities.java:807) ...
So let me go ahead and get rid of those dashes in the structure definition of Observation-genetics, in the structure definition of extension observation-geneticsDNARegionName, and in the mapping.
Now here's the output coming from the reference implementation.
java.lang.Error: Cannot set property observationgeneticsDNARegionName on null at org.hl7.fhir.dstu3.elementmodel.Element.setProperty(Element.java:330) at org.hl7.fhir.dstu3.utils.StructureMapUtilities.processTarget(StructureMapUtilities.java:1579) at org.hl7.fhir.dstu3.utils.StructureMapUtilities.executeRule(StructureMapUtilities.java:1206) at org.hl7.fhir.dstu3.utils.StructureMapUtilities.executeGroup(StructureMapUtilities.java:1191) at org.hl7.fhir.dstu3.utils.StructureMapUtilities.transform(StructureMapUtilities.java:1165) ...
Any clues on what I'm doing wrong?
Michael Osborne (May 02 2017 at 20:28):
(deleted)
Michael Osborne (May 02 2017 at 20:29):
Seems like you have not defined target.observation-geneticsDNARegionName
Grahame Grieve (May 02 2017 at 22:29):
looks like 3 things:
- if your element name has a "-" in it, you have to surround the name with " (see how this works in the FHIRPath spec)
- you have to construct the target and pass it into the mapping language
- what is "observation-geneticsDNARegionName"? that's not a valid element
Flavius Butnariu (May 03 2017 at 08:51):
@Grahame Grieve thank you for your reply.
I understand that surrounding an element name with quotes would prevent the lexer exception.
However, a rule such rule_a: for source.a as a make target."comment" = a
, where comment
is an element of resource Observation
, would produce the following output:
java.lang.Error: Cannot set property "comment" on null at org.hl7.fhir.dstu3.elementmodel.Element.setProperty(Element.java:330) at org.hl7.fhir.dstu3.utils.StructureMapUtilities.processTarget(StructureMapUtilities.java:1579) at org.hl7.fhir.dstu3.utils.StructureMapUtilities.executeRule(StructureMapUtilities.java:1206) at org.hl7.fhir.dstu3.utils.StructureMapUtilities.executeGroup(StructureMapUtilities.java:1191) at org.hl7.fhir.dstu3.utils.StructureMapUtilities.transform(StructureMapUtilities.java:1165) ...
If the quotes are removed, the rule would be executed successfully.
Flavius Butnariu (May 03 2017 at 10:04):
@Grahame Grieve observation-geneticsDNARegionName
is an extension used by profile Observation-genetics of resource Observation. The structure definitions of this extension and profile are available in /publish/definitions.xml.zip
.
Putting the lexer exception aside, am I wrong to assume that a rule such as
rule_a: for source.a as a make target.observation-geneticsDNARegionName = a
is correct? The intention here is as follows: I have resource Observation with its data elements. However, these data elements are insufficient, so I want to add a new data element to Observation (by means of an extension). My mapping rule should map to this new data element. To have a go at this, I used profile Observation-genetics and extension observation-geneticsDNARegionName as an example.
Moreover, would it be possible to provide me with a few extra pointers on how to construct the target and pass it into the mapping language?
Flavius Butnariu (May 03 2017 at 11:36):
Digging through the mappings available in \implementations\r2maps\
I was able to figure out my conundrum.
My rule should be something like
rule_a: for source.a as a make target.extension as t, t.url = 'http://hl7.org/fhir/StructureDefinition/observation-geneticsDNARegionName', t.value = a
suresh sargar (May 03 2017 at 12:58):
I am using FHIR DSTU3 compatible HAPI API to encode JSON data from XML data which i have. the problem which i observed is for Patient Resource is we have "deceasedBoolean" and "deceasedDateTime" field for Patient but when when we convert into JSON only one of the fields remain in JSON. look like one is overwrite to another.
How do i preserve both values into JSON?
Michele Mottini (May 03 2017 at 12:59):
You cannot have both. If you set deceasedDateTime then you don't need deceasedBoolean
suresh sargar (May 03 2017 at 13:20):
Thanks @Michele Mottini
suresh sargar (May 03 2017 at 17:37):
Hi Team,
suresh sargar (May 03 2017 at 17:40):
Hi Team,
Can i get STU3 all FHIR resource .XSD at one place? currently i am getting .XSD per resource visiting that resource page.
Igor Sirkovich (May 03 2017 at 17:50):
Look at http://www.hl7.org/fhir/downloads.html
Lloyd McKenzie (May 03 2017 at 20:16):
There's a single schema that combines all the resources and data types too - fhir-single.xsd (you'll still need the xml and xhtml schemas)
Grahame Grieve (May 04 2017 at 00:38):
The problem with "comment" is a bug in the tool. If you can create a gForge task, I'll get to it soon
Flavius Butnariu (May 04 2017 at 10:15):
@Grahame Grieve I created tracker item #13316 for this bug. I hope this is the proper way to raise the issue.
Flavius Butnariu (May 04 2017 at 13:15):
I've notice that executing a mapping from a source structure to a target profile extending a FHIR resource, does not seem to require the structure definition of the extension, but does require the structure definition of the profile. The reference implementation definitely does not complain about the missing structure definition, and it actually generates output as expected.
And not only that, but the declaration of the extension in the profile can be omitted, and the reference implementation can still generate output as expected most likely guided only by the mapping.
Is this intentional?
Grahame Grieve (May 04 2017 at 15:25):
sure. it works with the instances. the profiles are only observation
Vadim Peretokin (Jun 16 2017 at 09:39):
Looking to get started with the FHIR mapping language - had a look around, I take it I should download the latest svn source and use the reference implementation classes from there? Not seeing any stand-alone tools that can run the maps
Grahame Grieve (Jun 16 2017 at 13:34):
it's on my todo list to package up a stand alone tool
robert worden (Jun 16 2017 at 16:03):
Also available shortly: (now working as a proof of concept)
Generate a Java transform class from FHIR mappings, which runs the transform direct on HAPI (i.e. no mapping engine needed).
This and other extensions to mapping language support are part of a proposed HL7 project. Info from me if interested.
suresh sargar (Jun 20 2017 at 05:13):
Hi Team,
I want to store resource content(https://www.hl7.org/fhir/patient.html#resource) into Database for my application use. Is there any utility/ HAPI API gives me handy information for each resource to store in Database?
Jean Duteau (May 02 2018 at 17:37):
I'm working on developing some CCDA-to-FHIR mappings using the FHIR Mapping Language. I'm wondering if there are any FHIR Mapping Engine implementations that could be used for testing my mappings? This is an old topic but a simple google search didn't reveal anything besides FHIR Transform Engine (from Robert Worden) and that doesn't seem to use FML?
David Hay (May 02 2018 at 23:47):
Hi Jean - are you aware of this project: https://gforge.hl7.org/gf/download/trackeritem/15874/16474/HL7_Project_Scope_Statement_CCDA_on_FHIR_Mappings_20180323.docx
(would be interested in an engine myself!)
Lloyd McKenzie (May 03 2018 at 02:20):
I believe the validator has a mode that executes mappings (don't remember if it's structure maps or concept maps). I do know Grahame has an implementation.
Jean Duteau (May 03 2018 at 04:23):
@David Hay yes - my company was awarded the contract for the initial work on that project and that is why I'm asking. :)
David Hay (May 03 2018 at 04:41):
brilliant!
Grahame Grieve (May 05 2018 at 04:47):
so talked to Jean about this elsewhere, but for everyone's interest:
Grahame Grieve (May 05 2018 at 04:50):
You can run the transforms:
java -jar org.hl7.fhir.validator.jar [source-file-name] -transform [url] -ig [logical-model] -ig [path-to-maps] -output [dest-name] -defn [local-igpack]
where
- source-file-name=the name of the file you want to transform
- url= canonical url of the structure map to start at
- logical-model=the structure definitions for the source or dest (if either are not FHIR resources of the version in the definitions) (can be repeated)
- path-to-maps=folder containing structure maps (text representation as .map, or xml or json forms)
- dest-name=where you want the output to go
*local-igpack=your local copy of the file [fhir]/igpack.zip (makes things faster)
David Hay (May 11 2018 at 03:49):
btw - there's a broken link in the spec from the mapping page (http://hl7.org/fhir/2018Jan/mapping-language.html) - http://hl7.org/fhir/2018Jan/mapping.g4 is a 404
Grahame Grieve (May 11 2018 at 22:11):
can you make a task?
David Hay (May 16 2018 at 04:25):
Gustav Vella (Oct 22 2018 at 10:32):
May I ask a follow-up question to your instructions as to running the validator:
We (@Alexander Zautke) are currently trying to use the FHIR Mapping language to transform a logical model and ran into this issue (https://chat.fhir.org/#narrow/stream/8-hapi/subject/Hapi.20Logical.20Model/near/200452) .
we are currently running the validator as follows:
java -jar org.hl7.fhir.validator.jar ../source.xml
-ig ../SDSource.StructureDefinition.xml
-ig ../SDTarget.StructureDefinition.xml
-ig ../maps/
-transform http://uk-koeln.de/fhir/StructureMap/test
-output output/output.xml
Has somebody ever succeeded in transforming a logical model and can share how to execute the validator for that purpose? Or has this not been done with the validator before?
Grahame Grieve (Oct 22 2018 at 12:00):
I've done it. I'll have to go document this properly.
Grahame Grieve (Oct 22 2018 at 12:00):
I'll let you know when I have
Gustav Vella (Oct 22 2018 at 12:49):
feel relieved to know that we are on the right track.
Grahame Grieve (Oct 22 2018 at 22:20):
http://wiki.hl7.org/index.php?title=Using_the_FHIR_Validator_to_transform_content
Grahame Grieve (Oct 22 2018 at 22:20):
not that this all works - I'll set to testing it shortly
Alexander Zautke (Oct 23 2018 at 08:06):
Awesome work! Thank you!
With regard to testing, currently, the validator is throwing the following exception for me:
.. connect to tx server @ http://tx.fhir.org .. definitions from hl7.fhir.core#3.6.0 Exception in thread "main" java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonArray
Michel Rutten (Oct 23 2018 at 08:10):
@robert worden
Grahame Grieve (Oct 23 2018 at 08:11):
I'm working on it now
Alexander Zautke (Oct 23 2018 at 16:02):
Just as a heads-up, there is a NullPointer Exception in StructureMapUtilities processSource. When jumping into the FHIRException ("Unknown input variable..."), vars.summary() will fail.
It would be no problem for me to fix it, is there any preferred way of submitting a patch?
Lloyd McKenzie (Oct 23 2018 at 17:40):
@Grahame Grieve
Grahame Grieve (Oct 23 2018 at 20:46):
I already fixed that
Grahame Grieve (Oct 23 2018 at 20:47):
waiting for GitHub to ok the merge - it's still sick a little
Last updated: Apr 12 2022 at 19:14 UTC