Recently I wrote about one of the limitations of FHIRPath. The relevant text is below:
group.population | consisting of a set of population elements, one for each criteria defined in each group. | %def.group.population.all( $this.code ~ (%resource.group.population)[$index].code ) |
group.stratifier | In addition, each group will contain stratifiers with a value stratum for each value defined by the stratifier criteria, for each criteria defined in the measure. | %def.group.stratifier.all( $this.code ~ (%resource.group.stratifier)[$index].code ) and %def.group.stratifier.component.all( $this.code ~ (%resource.group.stratifier.stratum .component)[$index].code ) |
What was really challenging in this was a limitation of FHIRPath. FHIRPath provides the $this and $index variables to define the current position within the evaluated context. It works very much like "." does within XPath expressions. Unfortunately, FHIR has no way to assign $this or $index to a variable so that it can be used with the same values in subexpressions contained inside the initial expression.
These two sets of constraints say both MORE and LESS than I actually want to say. What they say is for each Population in %def.group.population, the code associated with population in the Measure has to match the corresponding population in the MeasureReport by numeric index. That's a bit of BS. Index has no semantics in the slice, code is what supplies the semantics, but there's no way to compare features of two lists that have matching semantics.
Given: %def.group represents groups sliced by code in Measure, and %resource.group represents groups sliced by code in MeasureReport.group, how would you match up other attribute values in def.group A to concepts in report.group B where A.code ~ B.code (these kind of constraints are called co-occurence constraints).
Take %def.group as the source of codes to work from. The following simply won't work:
%def.group.all(
$this.somethingElse =
%resource.group.select(code ~ $this.code).somethingElse
)
The reason is that select() takes expression as an argument, meaning that inside the where(), $this means something different than it means in %def.group.all(). To resolve this, what I'd need would be some sort of value assignment:
%def.group.all(
let that = $this
$this.somethingElse =
%resource.group.select(code ~ $that.code).somethingElse
)
There are other ways to achieve a similar effect, for example, introducing a syntax that escapes to the outer level. If $this means the context of this expression, $$this could mean the context of the outer expression, and $$$this could go the next level up, and I would write:
%def.group.all(
$this.somethingElse =
%resource.group.select(code ~ $$this.code).somethingElse
)
0 comments:
Post a Comment