Stream: fhirpath
Topic: IsDistinct
Grahame Grieve (Aug 16 2018 at 10:29):
GF#17275 is actually a bug in my FHIRPath somewhere. Maybe in my head...
(concept.code | descendants().concept.code).isDistinct()
Grahame Grieve (Aug 16 2018 at 10:29):
because, of course (!), | is a set union, and the outcomes are guaranteed to be unique....
Grahame Grieve (Aug 16 2018 at 10:30):
so it should be
concept.code.combine(descendants().concept.code).isDistinct()
Brian Postlethwaite (Aug 17 2018 at 00:28):
Yes, one of my favourite dislikes ;)
Brian Postlethwaite (Aug 17 2018 at 00:42):
I still don't like the syntax on the combine operation. It just feels weird to me, the scope of the collection inside the call, isn't the thing to the left of the function, it is its parent. (descendants() isn't called on the items of code, its called on the items of concept)
Bryn Rhodes (Aug 17 2018 at 00:45):
It is a bit strange that it's not like other iterators in that regard (like .select() and .where()) and there's no visual cue in the syntax to say that.
Brian Postlethwaite (Aug 17 2018 at 00:45):
Are these the same thing (ignoring the isdistinct part)?
Patient.name.select(given | family)
Patient.name.select(given.combine(family))
Brian Postlethwaite (Aug 17 2018 at 00:46):
the . operator isn't applying to the property
Brian Postlethwaite (Aug 17 2018 at 00:46):
I know its too late, wish I'd complained earlier, and been in the ballot pool - Thanks HL7Au
Bryn Rhodes (Aug 17 2018 at 00:47):
Yeah, those would be the same (minus the distinct), because the identifiers within the select will both resolve on the currently iterated name element.
Brian Postlethwaite (Aug 17 2018 at 00:48):
Patient.name.select(given.combine($this.family))
Bryn Rhodes (Aug 17 2018 at 00:49):
Yeah, that at least gives a visual cue
Brian Postlethwaite (Aug 17 2018 at 00:49):
Is it the only function where the $this isn't the thing on the left of the . ?
Brian Postlethwaite (Aug 17 2018 at 00:49):
In this example the $this is name, and not given
Bryn Rhodes (Aug 17 2018 at 00:52):
No, .subsetOf()
, .supersetOf()
, .intersect()
, .exclude()
, .union()
(synonym for |
), and all of the singleton functions like .indexOf()
, .startsWith
, etc.
Bryn Rhodes (Aug 17 2018 at 00:53):
By number, functions that introduce an iterating context are actually the minority.
Brian Postlethwaite (Aug 17 2018 at 00:56):
Thanks Bryn, I'm going to have to go investigate how Ewout has done this then!
Paul Lynch (Aug 24 2018 at 15:59):
Coincidentally, I am trying to implement subsetOf today. @Bryn Rhodes Does "$this" really apply in subsetOf? The documentation under "5. Functions" says, "If the function takes an expression as a parameter.... These expressions may refer to the special $this element...." The function "subsetOf" is not one of those listed as taking an "expression", but rather the documentation (at http://hl7.org/fhirpath/#existence) says it takes a "collection".
Bryn Rhodes (Aug 24 2018 at 18:57):
You're right, $this
does not apply in a .subsetOf()
; the list I provided above is operators where $this
does not apply (because they're not "iterators").
Paul Lynch (Aug 24 2018 at 18:59):
@Brian Postlethwaite I don't think
Patient.name.select(given.combine(family))
is correct syntax. The "select" function expects "projection: expression" as an argument, but you are passing it the result of "combine", which is a collection.
Bryn Rhodes (Aug 24 2018 at 19:02):
The entire argument given.combine(family)
is the "expression" argument.
Bryn Rhodes (Aug 24 2018 at 19:02):
So that expression is evaluated for every member of the Patient.name
collection.
Paul Lynch (Aug 24 2018 at 19:28):
Okay, that makes sense. Thanks.
Last updated: Apr 12 2022 at 19:14 UTC