Stream: mapping-framework
Topic: context in where clause: context or context.element?
Oliver Egger (Jan 08 2020 at 21:38):
The FHIR mapping language specifies for the source where condition:
where [condition]: a FHIRPath expression that is evaluated to boolean on the context. If the expression returns false, the source element has no match
what is exactly 'evaluated to boolean on the context', is it context or context.element? context.element is defined as
The element is an (optional) name of a child element of the context. If the name is not provided, the source is the context. If it is provided, the rule will apply once for each element on the context that matches this name.
From this description I would assume the following where clauses to evaluate the length of source.a2 (context.element as context):
source.a2 as a where length()<20 -> target.a2 = a "rule_a20b "; source.a2 as a where $this.length()<20 -> target.a2 = a "rule_a20b"; source.a2 as a where source.a2.length()<20 -> target.a2 = a "rule_a20b"; source.a2 as a where %source.a2.length()<20 -> target.a2 = a "rule_a20b";
the Java fhir mapping language also evaluates the above rules, however the tutorial describe it the following way (context as context):
source.a2 as a where a2.length()<20 -> target.a2 = a "rule_a20b";
also the example in the spec itself:
src.value : integer 0..* default 10 first as vs0 where value >= 10 check value <= 100 log value
which cannot be evaluated with the java fhir mapping language. is this an implementation issue or need the examples be corrected? @Alexander Zautke @Vadim Peretokin @Grahame Grieve
Alexander Zautke (Jan 08 2020 at 21:46):
Context is properly defined by the StructureMap resource as: "Type or variable this rule applies to". Meaning in this case the child element. So in your example it would be "a2". Always, at least to my interpretation.
Alexander Zautke (Jan 08 2020 at 21:47):
Therefore I would agree that the example is not correct and should be updated
Alexander Zautke (Jan 08 2020 at 21:49):
source.a2 as a where %source.a2.length()<20 -> target.a2 = a "rule_a20b";
What is %source
supposed to be here?
Oliver Egger (Jan 08 2020 at 21:59):
source.a2 as a where %source.a2.length()<20 -> target.a2 = a "rule_a20b";
What is%source
supposed to be here?
I have the group defined as: group tutorial(source source : TLeft, target target : TRight) and then I can also access the source parameter in the fhirpath expression as a variable with %source
Alexander Zautke (Jan 09 2020 at 22:30):
Ahh, yes, of course. Then source.a2 as a where %source.a2.length()<20 -> target.a2 = a "rule_a20b";
should also work.
Alexander Zautke (Jan 09 2020 at 22:32):
Would the first one be valid? Or only the second one? The third option would only work, in my opinion, if a2 would have a child called "source".
Oliver Egger (Jan 09 2020 at 22:39):
Would the first one be valid? Or only the second one? The third option would only work, in my opinion, if a2 would have a child called "source".
I think 1 (length()<20 ), 2 ($this.length()<20) and 4 (%source.a2.length()<20 if source is a variable) should be valid, but not 3 source.a2.length()<20.
Last updated: Apr 12 2022 at 19:14 UTC