FHIR Chat · Context of evaluating select/where expressions · fhirpath

Stream: fhirpath

Topic: Context of evaluating select/where expressions


view this post on Zulip ryan moehrke (Jan 15 2021 at 18:55):

I tried looking through the spec to see if there was specific guidance towards this and I didn't notice any, but my question revolves around methods like .contains() and .single() that require the input collection to be one item.
If you put those types of methods into a select() or where() as parameters, are those supposed to resolve without error if the input collection to the select method has multiple items.
For an esoteric example Patient.name.given.select($this.single()) - In my interpretation of the spec this would be equivalent to Patient.name.given as the context that single() is being run in mean that it wouldn't know of any more than one item at a time.
For a more nuanced example Patient.name.given.select($this.contains('Ryan')) - the substring match would normally fail vs an array of names (say, there is a usual "Ryan M" an official "Ryan Moehrke") But again, in my interpretation the select() would allow the contains() method to run against each item individually and get back a list of 'Ryan's that I could assert exist

I bring this up because my quick go-to fhirpath evaluator for testing out my wild theories (https://hl7.github.io/fhirpath.js/) does not work this way, both of my examples here throw errors and I honestly don't know who is right..

view this post on Zulip ryan moehrke (Jan 29 2021 at 20:28):

Now that work group week is mostly over, can I get a read on this?

view this post on Zulip Lloyd McKenzie (Jan 29 2021 at 21:39):

My read is that you're correct, but I'm not an expert. @Bryn Rhodes @Paul Lynch

view this post on Zulip Paul Lynch (Jan 29 2021 at 22:07):

That looks like a bug in fhirpath.js to me. Patient.name.given.select(length) works, but Patient.name.given.select($this.length) does not work correctly. I think $this is set to all of "given", but should be each item.

view this post on Zulip Bryn Rhodes (Jan 30 2021 at 17:16):

Yes, @ryan moehrke, you are correct, the $this is an iterator variable and only contains the item in the current iteration.

view this post on Zulip Paul Lynch (Feb 01 2021 at 13:18):

We will try to get a fix for this into fhirpath.js, but it might be a couple of weeks.

view this post on Zulip Paul Lynch (Feb 04 2021 at 00:15):

@ryan moehrke This is now fixed in version 2.7.3 of fhirpath.js.


Last updated: Apr 12 2022 at 19:14 UTC