Stream: mapping-framework
Topic: My own engine taught me something today
Ewout Kramer (May 28 2019 at 15:07):
While I was working on my implementation of a mapping engine, I debugged what I thought was incorrect behaviour. This is what I had:
data.values as values where (blockindex = 1 and groupindex = 0 and itemid = 'id_1125') then { values.value as value -> tgt.name as name then { value -> name.given } } "rule_select_name";
To my surprise, my engine only generated an empty "given" element within an "name" element in the target.
While debugging I discovered the engine did what it was supposed to do. Although I interpreted the rule value -> name.given
as a rule that would copy the contents of value into given, this is not what it is supposed to do, since it is not a "simple form" according to https://www.hl7.org/fhir/mapping-language.html#simple.
So what it did was for all occurrences in "value" (1 instance), run the target rule. Which does nothing more that create the target element.
I guess what I should have done is:
values.value as value -> tgt.name as name, name.given = value;
Which does indeed work fine.
Is this the intended behaviour? If so, isn't the syntax a bit confusing? Or should be allow x -> y.z to be a "simple form" too?
Grahame Grieve (May 28 2019 at 20:42):
maybe it would be useful, though would we have cardinality restrictions on the inner?
Ewout Kramer (May 29 2019 at 07:22):
Yes, the inner should be 0..1, to not mess with the logic that everywhere the context itself is 0..1, and the context variable name (its children) may select repeating items.
Ewout Kramer (May 29 2019 at 07:24):
Though in the end, it means there's two ways to do it, and the "correct" one is shorter too.
Last updated: Apr 12 2022 at 19:14 UTC