FHIR Chat · this vs $this · fhirpath

Stream: fhirpath

Topic: this vs $this


view this post on Zulip Josh Mandel (May 02 2019 at 17:35):

In this example we see the following expression:

(this | %previous).location.where(location = 'Location/emergency' and status in {'active', 'completed'}).exists()

Should this actually be $this, or are both valid?

view this post on Zulip Josh Mandel (May 02 2019 at 17:35):

(Related: how are fhirpath expressions in the spec validated?)

view this post on Zulip Bryn Rhodes (May 02 2019 at 18:05):

Should be $this, it's a special-purpose identifier in the grammar.

view this post on Zulip Bryn Rhodes (May 02 2019 at 18:06):

The expressions in the spec are validated with the engine running

view this post on Zulip Bryn Rhodes (May 02 2019 at 18:06):

in the build

view this post on Zulip Bryn Rhodes (May 02 2019 at 18:06):

But since that particular example doesn't actually run as part of the build, it's not validated.

view this post on Zulip Grahame Grieve (May 02 2019 at 18:07):

that expression is not validated - it's not in a place the validator knows to look and validate. And I think it should actually be

(%current | %previous).location.where(location = 'Location/emergency' and status in {'active', 'completed'}).exists()

view this post on Zulip Paul Lynch (May 02 2019 at 18:09):

Where is %current defined?

view this post on Zulip Bryn Rhodes (May 02 2019 at 18:10):

%current is a context variable so it's defined by whatever the context specifies. In this case, a trigger condition, so it's specified as part of the condition element as an expectation of the implementation.

view this post on Zulip Paul Lynch (May 02 2019 at 18:17):

That makes sense. FYI, at http://build.fhir.org/metadatatypes-definitions.html#TriggerDefinition.condition, I saw %previous mentioned, but not %current defined as a variable name. Although it says you should be able to get to the current resource, it does not say what variable name it is in.

view this post on Zulip Grahame Grieve (May 02 2019 at 18:23):

right. that work is incomplete for that reason

view this post on Zulip Josh Mandel (May 02 2019 at 19:21):

Added GF#21233


Last updated: Apr 12 2022 at 19:14 UTC