FHIR Chat · FHIR Mapping Language · implementers

Stream: implementers

Topic: FHIR Mapping Language


view this post on Zulip Flavius Butnariu (Mar 15 2017 at 15:17):

Dear all,

I have a question related to managing lists in the FHIR mapping language.

Given the below source structure,

    TLeft
      a22 : string [0..*]

how to write a rule such that only the index-th a22 is selected?
rule_name: for source.a22 as a where [FHIRPath Boolean condition] make ...

I will be grateful for any information you can provide.

With kind regards,
Flavius

view this post on Zulip Lloyd McKenzie (Mar 15 2017 at 15:23):

I believe it uses FHIRPath, which means you'd just say source.a22[5] to grab the 6th repetition

view this post on Zulip Flavius Butnariu (Mar 15 2017 at 15:48):

@Lloyd McKenzie thank you for your prompt reply.

I gather from FHIR Mapping Language that FHIRPath expressions are allowed only in the where and check clauses.
rule_name: for source.a22 as a where [FHIRPath Boolean condition] check [FHIRPath Boolean condition] make ...
I've also tried something like
rule_name: for source.a22[5] as a make ...,
but the reference implementation throws the following exception.

org.hl7.fhir.dstu3.utils.FHIRLexer$FHIRLexerException: Error at 11, 3: Found "5" expecting ":"
    at org.hl7.fhir.dstu3.utils.FHIRLexer.error(FHIRLexer.java:101)
        ...

view this post on Zulip Grahame Grieve (Mar 15 2017 at 19:05):

yes this is not supported right now

view this post on Zulip Grahame Grieve (Mar 15 2017 at 19:06):

with the where clause:

view this post on Zulip Grahame Grieve (Mar 15 2017 at 19:06):

for source.a as v where v = source.a[22] make....

view this post on Zulip Flavius Butnariu (Mar 16 2017 at 10:59):

@Grahame Grieve thank you for your reply.

Unfortunately, this doesn't seem to work, although no exception is thrown.

view this post on Zulip Grahame Grieve (Mar 16 2017 at 11:01):

I'll test it when I get a chance

view this post on Zulip Domenico (Apr 10 2017 at 15:45):

Hi all,
can you explain me what is the Fhir Mapping Language section? How can I use it?

view this post on Zulip Lloyd McKenzie (Apr 10 2017 at 15:51):

Start with StructureMap. Essentially it gives you a formal way to convert two arbitrary structure definitions.

view this post on Zulip Domenico (Apr 12 2017 at 10:37):

@Lloyd McKenzie Can you give me an example ( in other words a scenario where I can use it)?

view this post on Zulip Lloyd McKenzie (Apr 12 2017 at 14:14):

We're using it to map between DSTU2 models and STU3 models. It's also been used to map from logical models to FHIR resources, from v2 models to FHIR resources, etc.

view this post on Zulip Domenico (Apr 12 2017 at 14:32):

@Lloyd McKenzie thank you for your reply. In your opinion if I have my custom model can I use Mapping language to map my model with STU3 model?

view this post on Zulip Lloyd McKenzie (Apr 12 2017 at 14:51):

I'm not sure my opinion is worth a lot as I haven't used the language yet. However, it's certainly the intention that you'd be able to do that.

view this post on Zulip Grahame Grieve (Apr 15 2017 at 20:28):

yes that's the intention

view this post on Zulip Flavius Butnariu (May 06 2017 at 16:07):

Consider the source structure

    TLeft
      s : [0..1]
        ss1 : string [1..1]
        ss2 : string [1..1]

and the target structure

    TRight
      t : [0..1]
        tt : [1..1]
          ttt1 : string [1..1]
          ttt2 : string [1..1]

Let's say we want to map ss1 to ttt1 and ss2 to ttt2. This could be done as follows:

map "http://hl7.org/fhir/StructureMap/tutorial" = tutorial

uses "http://hl7.org/fhir/StructureDefinition/tutorial-left" as source
uses "http://hl7.org/fhir/StructureDefinition/tutorial-right" as target

group tutorial
  input "source" : TLeft as source
  input "target" : TRight as target

rule_a : for source.s as s make target.t as t then {
  rule_aa : for s make t.tt as tt then {
    rule_aaa1 : for s.ss1 as v make tt.ttt1 = v
    rule_aaa2 : for s.ss2 as v make tt.ttt2 = v
  }
}

endgroup

Is there a more concise way of writing those nested rules?

view this post on Zulip Grahame Grieve (May 06 2017 at 16:09):

you can do this:

rule_a : for source.s as s make target.t as t, t.tt as tt then {
    rule_aaa1 : for s.ss1 as v make tt.ttt1 = v
    rule_aaa2 : for s.ss2 as v make tt.ttt2 = v
}

view this post on Zulip Flavius Butnariu (May 06 2017 at 16:15):

@Grahame Grieve It works! Many thanks!

view this post on Zulip Grahame Grieve (May 06 2017 at 17:58):

NP

view this post on Zulip Grahame Grieve (May 07 2017 at 09:10):

If we had a breakfast session or an evening birds of the feather here at the HL7 meeting about the mapping language, would anyone else be interested (e.g. @Flavius Butnariu , @Claude Nanjo, @Alexander Henket ). If you are, it might be Tues/Wed evening, or Wed morning, or Thursday morning. Let me know if you interested and if you are, when you're available. thx

view this post on Zulip Vadim Peretokin (May 07 2017 at 09:23):

I would be, free on the time

view this post on Zulip Alexander Henket (May 07 2017 at 09:24):

Interested. Thurs morning is not possible. Tues/Wed evening are both fine

view this post on Zulip Jeffrey Danford (May 07 2017 at 09:25):

+1, and your timing is perfect. Either evening looks good for me.

view this post on Zulip robert worden (May 07 2017 at 09:56):

let me know when you have converged - any time up to Wednesady

view this post on Zulip nicola (RIO/SS) (May 07 2017 at 10:10):

+1

view this post on Zulip Grahame Grieve (May 07 2017 at 10:10):

we'll decide tonight, and I'll let you know here

view this post on Zulip Brian Postlethwaite (May 07 2017 at 14:55):

Possibly me too.

view this post on Zulip Grahame Grieve (May 07 2017 at 20:58):

Wednesday 6pm to 7pm in room 3158

view this post on Zulip Flavius Butnariu (May 08 2017 at 07:26):

In which timezone is this meeting taking place?

view this post on Zulip Flavius Butnariu (May 08 2017 at 07:27):

In FHIR mapping language, is there a way to set value[x] of Observation to a complex type (e.g., Quantity) rather than to a primitive type?

group src2tgt
  input src : Src as source
  input tgt : Observation as target

rule_value : for src.value as v, src.unit as u make tgt.value = ... new Quantity(v, u) ...

endgroup

view this post on Zulip Lloyd McKenzie (May 08 2017 at 07:31):

The meeting will be in Madrid at the HL7 WGM, so GMT+1 I believe

view this post on Zulip Grahame Grieve (May 08 2017 at 07:44):

local to Madrid, where the HL7 meeting is currently being held

view this post on Zulip Grahame Grieve (May 08 2017 at 07:45):

make Create(Quantity) as q, tgt.value = q, q....

view this post on Zulip Flavius Butnariu (May 08 2017 at 08:22):

Although my rule looks like this

rule_value : for src.value as v make create("Quantity") as q, tgt.value = q, q.value = v

the reference implementation throws the following exception

org.hl7.fhir.exceptions.FHIRException: Cannot set property value on null - value is not a primitive type (Quantity) or an ElementModel type
    at org.hl7.fhir.dstu3.elementmodel.Element.setProperty(Element.java:297)
    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.executeRule(StructureMapUtilities.java:1210)
    at org.hl7.fhir.dstu3.utils.StructureMapUtilities.executeRule(StructureMapUtilities.java:1210)
    at org.hl7.fhir.dstu3.utils.StructureMapUtilities.executeGroup(StructureMapUtilities.java:1191)
    at org.hl7.fhir.dstu3.utils.StructureMapUtilities.transform(StructureMapUtilities.java:1165)
    ...

view this post on Zulip Flavius Butnariu (May 08 2017 at 08:39):

I believe the issue is in method runTransform of class StructureMapUtilities, which returns a Base object that looks like this base.PNG
Are there any alternative ways of writing the rule in the FHIR mapping language?

view this post on Zulip Grahame Grieve (May 08 2017 at 08:59):

oh that is a bug. I think. I'll have to investigate

view this post on Zulip Grahame Grieve (May 08 2017 at 08:59):

it's because it's a complex type that contains a value property. dumb programming on my part

view this post on Zulip Flavius Butnariu (May 08 2017 at 09:29):

From what I gather, the issue is that object Base returned by runTransform is an instance of Type. The aforementioned exception is raised because an instance of Element is expected. However, I see that Type extends Element, which in turn extends Base, so I've assumed that casting Type to Elementwould do the trick, but that raises another exception.

java.lang.ClassCastException: org.hl7.fhir.dstu3.model.Quantity cannot be cast to org.hl7.fhir.dstu3.elementmodel.Element

view this post on Zulip Grahame Grieve (May 08 2017 at 10:23):

yes you're crossing different heirarchies there. I'll have to investigate this one. But it will take to time to set a test case up, unless you can feed me one

view this post on Zulip Flavius Butnariu (May 08 2017 at 11:52):

structuredefinition-src.xml
source1.xml

Let me know if these will do.

view this post on Zulip Flavius Butnariu (May 08 2017 at 13:35):

src2tgt.map

view this post on Zulip robert worden (May 08 2017 at 16:32):

At the BOF on the mapping language (Madrid Weds evening) I'd like to discuss its relation to FHIR Transform Engine, another mapping approach to data transforms.
At first sight the two look quite dfifferent, but it is possible to convert both ways between the two mapping languages. This gives a possibled synergy, to mix and match approaches.
I've summarised in bullet points in the attached 2 slides:
FML_FTE.pdf

view this post on Zulip Flavius Butnariu (May 09 2017 at 13:17):

Consider the following target structure:

Bundle : Resource
  ...
  entry : BackboneElement
    resource : Resource
  ...

I'm trying to set resource to create("Observation"), but the reference implementation keeps throwing an exception.

org.hl7.fhir.exceptions.FHIRException: Cannot set property resource on entry - value is not a primitive type (Observation) or an ElementModel type
    at org.hl7.fhir.dstu3.elementmodel.Element.setProperty(Element.java:300)
    at org.hl7.fhir.dstu3.utils.StructureMapUtilities.processTarget(StructureMapUtilities.java:1626)
    at org.hl7.fhir.dstu3.utils.StructureMapUtilities.executeRule(StructureMapUtilities.java:1241)
    at org.hl7.fhir.dstu3.utils.StructureMapUtilities.executeRule(StructureMapUtilities.java:1245)
    at org.hl7.fhir.dstu3.utils.StructureMapUtilities.executeGroup(StructureMapUtilities.java:1226)
    at org.hl7.fhir.dstu3.utils.StructureMapUtilities.transform(StructureMapUtilities.java:1200)
    ...

I would appreciate any suggestion.

view this post on Zulip Grahame Grieve (May 09 2017 at 15:55):

put your whole mapping statement in - what you say you're trying to do is right, but the exception indicates you've got something wrong

view this post on Zulip Flavius Butnariu (May 09 2017 at 16:15):

Here's my mapping.

map "http://hl7.org/fhir/StructureMap/tutorial" = "tutorial"

uses "http://hl7.org/fhir/StructureDefinition/Src" as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" as target

group src2tgt
  input src : Src as source
  input tgt : Bundle as target

  rule_do_something : for src as s make tgt.type = "collection", tgt.entry as e, e.resource = create("Observation") as t then Src2Observation(s, t)

endgroup

group Src2Observation
  input src : Src as source
  input tgt : Device as target 

  rule_do_something : for src.unit make tgt.comment

endgroup

structuredefinition-src.xml

view this post on Zulip Grahame Grieve (May 09 2017 at 17:28):

why this?

view this post on Zulip Grahame Grieve (May 09 2017 at 17:28):

e.resource = create("Observation") as t, e.resource = obs

view this post on Zulip Flavius Butnariu (May 09 2017 at 18:11):

Rectified the mapping. Nevertheless, the exception still lies with attempting to assign an Observation to resource.

view this post on Zulip robert worden (May 09 2017 at 18:35):

should we put up a paper notice about the Weds Q5 meeting re mapping language? I can do.

view this post on Zulip Grahame Grieve (May 09 2017 at 19:07):

sure that would be good thanks

view this post on Zulip Grahame Grieve (May 09 2017 at 19:08):

I didn't actually think that fixing that would fix the problem. But one can always live in hope

view this post on Zulip Grahame Grieve (May 09 2017 at 19:09):

but your mapping looks good, so it's probably my bug...

view this post on Zulip Grahame Grieve (May 09 2017 at 19:09):

i think I'll get to this before we talk mapping tomorrow night

view this post on Zulip Flavius Butnariu (May 10 2017 at 08:48):

The BOF on the mapping language is open only to attendees of the HL7 International Conference & Working Group Meeting or also to people in remote locations?

view this post on Zulip Grahame Grieve (May 10 2017 at 08:54):

not sure how remote participation would work.

view this post on Zulip Grahame Grieve (May 10 2017 at 08:54):

you have a web camera?

view this post on Zulip Flavius Butnariu (May 10 2017 at 09:03):

I do. However, I completely understand if this is a meeting in person.

view this post on Zulip Grahame Grieve (May 10 2017 at 09:06):

well, it's not formally limited or secret or anything. There's just no good infrastructure for remote participation. It's just a bunch of us sitting in a circle in a hotel room. but we could set up a web ex if you understand it won't work very well

view this post on Zulip Grahame Grieve (May 10 2017 at 16:01):

I'm going to be there a little late - a few minutes

view this post on Zulip nicola (RIO/SS) (May 10 2017 at 17:52):

Here are links about datalog: https://en.wikipedia.org/wiki/Datalog, http://www.csd.uoc.gr/~hy562/1112_spring/instr_material/WhatYouAlwaysWantedtoKnowAboutDatalog_AndNeverDaredtoAsk.pdf, http://logic.stanford.edu/dataintegration/chapters/chap01.html

view this post on Zulip Grahame Grieve (May 11 2017 at 06:31):

how do you map using data log?

view this post on Zulip nicola (RIO/SS) (May 11 2017 at 08:03):

Mapping could be represented as deduced facts, i.e. set of queries/rules

view this post on Zulip Grahame Grieve (May 12 2017 at 11:00):

Wednesday 6pm to 7pm in room 3158

view this post on Zulip Flavius Butnariu (May 13 2017 at 10:19):

A script in the FHIR mapping language can include concept maps along any number of groups of rules according to the ANTLR grammar of the FHIR mapping language. After this script is parsed, the resulting parse tree conforms to the abstract syntax of the FHIR mapping language, which essentially is the StructureMapresource, right? Now my question is why the StructureMap resource does not seem to relate to or reference the ConceptMap resource?

view this post on Zulip Flavius Butnariu (May 15 2017 at 08:43):

@robert worden I am interested in exploring the capabilities of the FHIR transform engine, and I wonder whether it is available for download somewhere? Many thanks!

view this post on Zulip robert worden (May 15 2017 at 09:07):

@Flavius Butnariu Please give me a week or so, and I can send you the FHIR Transform Engine tools with a couple of sample mapping projects. I'm currently working on the facility to round-trip between FML mappings and FTE mappings - I'd like to get that to a more tidy state.

view this post on Zulip robert worden (May 15 2017 at 18:19):

On the page defining FHIR Mapping Language 'there is an antlr grammar for the concrete syntax' - but the link is broken. Anybody got it?

view this post on Zulip Flavius Butnariu (May 16 2017 at 07:04):

@robert worden I believe this is the ANTLR grammar of the FHIR mapping language.

view this post on Zulip Grahame Grieve (May 17 2017 at 06:01):

ConceptMaps will be contained resources in the structuremap resource

view this post on Zulip Flavius Butnariu (May 17 2017 at 13:51):

Is there any reason why a rule can specify for a source/target context at most a child element

rule_name : for context.element as s ... 

but not a grandchild element?

rule_name : for context.element.element as s ...

view this post on Zulip Grahame Grieve (May 17 2017 at 19:52):

mainly to keep the structure /grammar simpler for tools that want to do visual editing

view this post on Zulip Flavius Butnariu (May 22 2017 at 08:56):

@robert worden I would like to follow up on my request from last week. I am particularly interested in exploring the possibility of mapping a source to a target using FTE along with its in-between UML model, so I was wondering whether this feature is mature enough to play with it? I will be grateful for any information you can provide.

view this post on Zulip robert worden (May 22 2017 at 09:08):

@Flavius Butnariu the feature is mature enough to play with (and to run translation tests); I am now trying to get two things done: (a) get the bridge to FHIR Mapping Language working in both directions, and (b) build a good demo project with a couple of examples. If you can wait a couple of weeks for these, it should make it a lot easier to understand. I could send you the Eclipse plugins before that, but would prefer to complete the package.

view this post on Zulip Eric Haas (May 23 2017 at 23:25):

Just getting started with the mapping language and ran into this...

Trying to use a constant for identifier system. like so

LogicalModel.UniqueID : for source.UniqueID : string 1..1 as v make appt.identifier as t, t.value = v, t.system = 'http://acme.org'

add get this....

org.hl7.fhir.exceptions.FHIRException: The type string is not compatible with the allowed types for Identifier.system

view this post on Zulip Grahame Grieve (May 24 2017 at 00:03):

that's pretty bizarre...

view this post on Zulip Eric Haas (May 24 2017 at 00:09):

my example or the error?

view this post on Zulip Grahame Grieve (May 24 2017 at 00:09):

the error. that should work work

view this post on Zulip Eric Haas (May 24 2017 at 00:11):

OK I'll reset everything and try again

view this post on Zulip Eric Haas (May 24 2017 at 03:15):

Still getting above error. But was able to walk through whole thing on my IG-Template anyway. A bit of a steep learning curve on the syntax but really handy tool - thanks again GG. The profile instance generation had a bit of a hiccup and didn't populate all the mappings correctly - it missed the "un-nested terms".

view this post on Zulip robert worden (May 26 2017 at 08:18):

@Flavius Butnariu is the ANTLR grammar for the mapping language you pointed me to the current version?
e.g the grammar rule for group is just
'group' groupName ('extends' groupName)* (ruleInput)+ (ruleGroup)+ 'endgroup'
where groupName is just IDENTIFIER, so will not parse 'group for types....'

view this post on Zulip Flavius Butnariu (May 26 2017 at 19:39):

@robert worden the ANTLR grammar was retrieved from http://gforge.hl7.org/gf/project/fhir/scmsvn/?action=browse&path=%2Ftrunk%2Fbuild%2Fimages%2Fmapping.g4&view=log. Maybe @Grahame Grieve can provide further details on the status of the grammar.

view this post on Zulip David Hay (May 28 2017 at 17:14):

Worth a separate stream?

view this post on Zulip robert worden (May 29 2017 at 17:07):

Thanks @Flavius Butnariu ; @Claude Nanjo I see you wrote the grammar. Has anyone implemented a parser with exactly this grammar? When I did so with the ANTLR4 eclipse plugin , my java generated parser has two problems: (a) the rule for 'group' does not recognise 'group for types...', and (b) the rule for structureDefinition is a black hole, consuming all text to the end of the file. Any comments?

view this post on Zulip Grahame Grieve (May 29 2017 at 18:11):

@Flavius Butnariu @Eric Haas @robert worden I am up to working on the mapping engine - which of the bugs you have are still a problem?

view this post on Zulip robert worden (May 29 2017 at 18:24):

@Grahame Grieve I am not using the mapping engine yet, as I cannot find it in the HAPI 2.4 distribution - so I am probably looking in the wrong place - where is the right place? I have generated a parser for the mapping language from the ANTLR grammar and had the problems noted above.

view this post on Zulip Grahame Grieve (May 29 2017 at 19:38):

The class name is org.hl7.fhir.dstu3.utils.StructureMapUtilities. @James Agnew is selective about which classes from the build get included in HAPI - perhaps this one is not?

view this post on Zulip robert worden (May 29 2017 at 21:03):

Yes - it's there - thanks. Looking at it now.

view this post on Zulip Flavius Butnariu (May 30 2017 at 07:50):

@Grahame Grieve one bug that I found was in terms of setting value[x] of Observation to a complex type such as Quantity.

Source structure

    Src
      value : decimal [1..1]
      unit : string [1..1]

Source structure definition
Source instance

map "http://hl7.org/fhir/StructureMap/tutorial" = "tutorial"

uses "http://hl7.org/fhir/StructureDefinition/Src" as source
uses "http://hl7.org/fhir/StructureDefinition/Observation" as target

group tutorial
  input src : Src as source
  input tgt : Observation as target

  //rule_value : for src.value as v make tgt.value = v // set value[x] of Observation to primitive type decimal
  rule_value : for src.value as v make create("Quantity") as q, tgt.value = q, q.value = v

endgroup

view this post on Zulip Eric Haas (May 30 2017 at 16:04):

I discovered this:

Trying to use a constant for identifier system. like so
LogicalModel.UniqueID : for source.UniqueID : string 1..1 as v make appt.identifier as t, t.value = v, t.system = 'http://acme.org'
add get this....
org.hl7.fhir.exceptions.FHIRException: The type string is not compatible with the allowed types for Identifier.system

view this post on Zulip Eric Haas (May 30 2017 at 16:13):

Also when flattening the structure here the example data for foo.bar and foo.baz doesn't map over. ( in the ig-publisher tool)

lgoical model:

pasted image

mapped to Appt:

pasted image

example data ( notice the status an description are missing)

pasted image

view this post on Zulip Eric Haas (May 30 2017 at 16:19):

Finally when mapping a logical model to a structure, why is the default behavior for any nonmapped element to be constrained to a cardinality of 0..0 (not used)? I'm not disagreeing with this but just want to understand the rationale.

view this post on Zulip robert worden (Jun 06 2017 at 12:02):

I have a problem with the concrete syntax of the mapping language , and its ANTLR grammar.
In the abstract syntax of the StructureMap resource, one rule can have zero or more target parts.

The case of zero target parts is important, for 'filler' rules which just take a step down through the source structure, through a node which does not represent anything in the target. Filler rules are needed, because a rule can only take one step at a time in the source structure.

But in the concrete syntax, a rule must have one or more target parts. The ANTLR grammar enforces this, requiring a 'make' before any 'then'.

So I think the concrete syntax and its grammar need to be changed. I am not a grammar geek. Can anybody help?

(p.s. I note the ANTLR grammar is not used in Grahame's Java mapping engine, so maybe the grammar is not tested ?)

view this post on Zulip Julie Evans (Jun 06 2017 at 22:14):

@robert worden Status of the "good demo project with a couple of examples"? Is it available for download? Thx.

view this post on Zulip robert worden (Jun 07 2017 at 12:24):

@Julie Evans not quite ready yet - need to get a demo round trip between FHIR Mappings and FTE mappings, so need to sort the ANTLR Grammar for the mapping language

view this post on Zulip Julie Evans (Jun 07 2017 at 15:35):

Is anyone aware of any simple StructureMap instance examples besides the ActivityDefinition to SupplyRequest published in the FHIR spec?

view this post on Zulip Grahame Grieve (Jun 09 2017 at 04:55):

there's all the R2/R3 mappings. and there's structure maps here:

view this post on Zulip Grahame Grieve (Jun 09 2017 at 04:55):

http://fhir.hl7.org.au/fhir/rcpa/index.html

view this post on Zulip Flavius Butnariu (Jul 11 2017 at 15:12):

What would be the StructureMap equivalent of the following FHIR mapping language rule?

rule_a : for src.a as v make tgt.a = v * 100

A first take on this would be something like

<StructureMap xmlns="http://hl7.org/fhir">
  ...
  <rule>
    <name value="rule_a"/>
    <source>
      <context value="src"/>
      <element value="a"/>
      <variable value="v"/>
    </source>
    <target>
      <context value="tgt"/>
      <contextType value="variable"/>
      <element value="a"/>
      <transform value="evaluate"/>
      <parameter>
        <valueString value="v * 100"/>
      </parameter>
    </target>
  </rule>
  ...
</StructureMap>

Am i anywhere close?
Moreover, is there any implementation out there that can "execute" StructureMaps?

view this post on Zulip Grahame Grieve (Jul 11 2017 at 20:50):

the java build includes org.hl7.fhir.r4.utils.StructureMapUtilities

view this post on Zulip Flavius Butnariu (Jul 12 2017 at 07:45):

Is the FHIR mapping language powerful enough to capture the logic of doing unit conversion (e.g., between kilograms and pounds)? If you always expect to find measurements in kilograms on the source side, and if you always need to convert them to pounds on the target side, then I expect that this conversion could be expressed (hardcoded) pretty straightforward in the FHIR mapping language. However, what if there can be a wide choice of units on the target side and an equally wide choice of units on the source side? Hardcoding all conversions in the mapping doesn't seem too elegant. Any thoughts on this?

view this post on Zulip Grahame Grieve (Jul 12 2017 at 10:22):

we should probably add an API operation for this. The underlying semantics are all there if the units are UCUM, but the language doesn't address it

view this post on Zulip Vadim Peretokin (Jul 19 2017 at 07:34):

Using the step 1 & 2 in the tutorial, I can't get it to output an element with a different name. This:

rule_a: for source.a as a make target.b = a

Complains:

java.lang.Error: Cannot set property b on null
    at org.hl7.fhir.r4.elementmodel.Element.setProperty(Element.java:344)
    at org.hl7.fhir.r4.utils.StructureMapUtilities.processTarget(StructureMapUtilities.java:1626)
    at org.hl7.fhir.r4.utils.StructureMapUtilities.executeRule(StructureMapUtilities.java:1241)

view this post on Zulip Vadim Peretokin (Jul 19 2017 at 07:35):

Am I doing something wrong? Seems valid according to step 2 and everything I've read... though:

element: The name of a child element that is valid in the context. The created value will be placed into the named element

Is ambiguous - what is valid defined by?

view this post on Zulip Vadim Peretokin (Jul 19 2017 at 07:47):

Got it - it's defined by the logical model in there. Derp.

view this post on Zulip Flavius Butnariu (Jul 28 2017 at 12:35):

Given the following rule in the FHIR mapping language,

...
input src : Source as source
input tgt : Bundle as target

myRule : for src.element as v make tgt.entry as e, e.resource = create("Practitioner") as p, then callAnotherGroup(v, p, tgt)
...

what would be its StructureMap equivalent? Is it anything close to what follows?

        <rule>
            <name value="myRule"/>
            <source>
                <context value="src"/>
                <element value="element"/>
                <variable value="v"/>
            </source>
            <target>
                <context value="tgt"/>
                <contextType value="variable"/>
                <element value="entry"/>
                <variable value="e"/>
            </target>
            <target>
                <context value="e"/>
                <contextType value="variable"/>
                <element value="resource"/>
                <variable value="p"/>
                <transform value="create"/>
                <parameter>
                    <valueString value="'Practitioner'"/>
                </parameter>
            </target>
            <dependent>
                <name value="callAnotherGroup"/>
                <variable value="v"/>
                <variable value="p"/>
                <variable value="tgt"/>
            </dependent>
        </rule>

view this post on Zulip Vadim Peretokin (Oct 27 2017 at 09:13):

FHIR mapping language says:

Rules in a group may be applied in any order; there is no sense of sequentially applying one rule after another.

Is it implying that it doesn't matter what order the rules are written in, because the output schema will order them correctly? If so it doesn't seem to be the case because switching the order of rules around changed the order used in the output

view this post on Zulip Grahame Grieve (Oct 27 2017 at 20:34):

it shouldn't do - that's the point of the rule.

view this post on Zulip robert worden (Nov 13 2017 at 18:59):

I have built tools to generate transforms from example source-target pairs. The transforms are delivered in HAPI Java or FHIR Mapping Language. Should save costs; I am looking for examples to calibrate the cost savings. See webex at at https://youtu.be/uyMTzib_irk

view this post on Zulip Michael Lawley (Nov 22 2017 at 01:34):

Is there any guidance somewhere on using the StructureMapUtilities to transform from POJOs / non-FHIR objects? I believe this should be possible given some kind of typing structures?

view this post on Zulip robert worden (Sep 20 2018 at 17:18):

Who going to Baltimore is using FHIR Mapping Language, or interested in doing so? I'd like to meet up, or even a BOF if enough people are interested.

view this post on Zulip Rick Geimer (Sep 20 2018 at 17:41):

Count me in

view this post on Zulip Brian Postlethwaite (Sep 23 2018 at 10:42):

Me too

view this post on Zulip Bryn Rhodes (Sep 24 2018 at 18:31):

We are using it to define the QDM->QI-Core mappings in the Clinical Reasoning connectathon track. Still working on getting QDM element definitions so we can run the code, but that's the plan. Definitely interested in the discussion.

view this post on Zulip Robinette Renner (Sep 24 2018 at 18:49):

I am also interested.

view this post on Zulip Eric Haas (Sep 24 2018 at 22:30):

If Bryn is in so am I :-) ( seriously I am interested too)

view this post on Zulip robert worden (Sep 30 2018 at 13:06):

* Transforming to FHIR * Breakout Session , today , 4 pm, Constellation F
Building transforms - with FHIR Mapping Language, or in other ways?
How are you doing it ? What are the problems?
Come along and talk about it - or listen

view this post on Zulip robert worden (Sep 30 2018 at 21:22):

Transforming to FHIR breakoutsession : here are the slides I showed Transforming-to-FHIR-and-TBX.pptx

view this post on Zulip Brian Kaney (Aug 06 2019 at 21:15):

Is there a more appropriate stream for FHIR Mapping Language questions, or will this one do?

view this post on Zulip Lloyd McKenzie (Aug 06 2019 at 21:41):

#mapping-framework is where the geeky questions go :)


Last updated: Apr 12 2022 at 19:14 UTC