FHIR Chat · Accessing variables from the FHIR variable extension · fhirpath

Stream: fhirpath

Topic: Accessing variables from the FHIR variable extension


view this post on Zulip Paul Lynch (Oct 24 2018 at 15:22):

Are variables provided by http://hl7.org/fhir/StructureDefinition/variable (which says they appear in the FHIRPath context) to be accessed like environment variables by prefixing them with '%'? Both the FHIR-specific variables (http://hl7.org/fhir/2018Sep/fhirpath.html#variables) and environment variables start with %. I don't see anything in either the main FHIRPath spec or the FHIR extensions that discusses accessing other types of variables-- though I guess that is because http://hl7.org/fhir/StructureDefinition/variable is new. I did notice that Grahame's blog post (http://www.healthintersections.com.au/?p=2835) used variable names without %, but I am wondering if maybe that was an oversight, since there is the potential then for confusion between a variable name and an attribute name of the structure being traversed. (The confusion could be resolved by specifying a priority, but that priority would then need to be documented somewhere.)

view this post on Zulip Grahame Grieve (Oct 26 2018 at 13:19):

I guess that was an oversight

view this post on Zulip Paul Lynch (Oct 26 2018 at 16:53):

I added GF#19530-- a request for documentation about this. For now, I will just assume that % should be used.

view this post on Zulip Brian Postlethwaite (Oct 26 2018 at 21:34):

I had assumed that the % is what would be used, or $ but haven't started to implement that part yet.

view this post on Zulip Paul Lynch (Oct 26 2018 at 21:37):

I would just as soon stick with % for all variable types, unless there is a need to give the variables types separate name-spaces. (My preference for that is becoming stronger as I am writing the code for it right now... but it not too much code to change if it goes a different way.)

view this post on Zulip Brian Postlethwaite (Oct 26 2018 at 22:23):

$ is already a variable for $this

view this post on Zulip Brian Postlethwaite (Oct 26 2018 at 22:24):

So would be consistent with that too, where % is environment, including %resource, which feels like ore like a variable. So I'm on the fence on this too.

view this post on Zulip Paul Lynch (Oct 26 2018 at 22:29):

In the grammar, '$this' is a very special thing defined as that particular string. The % comes from "externalConstant", which I am happy to consider variable values, since they are passed in (i.e. external) to the fhirpath engine.

view this post on Zulip Brian Postlethwaite (Oct 26 2018 at 23:56):

That makes some sense. Happy to continue with that. Did we get a tracker logged to clarify this?

view this post on Zulip Grahame Grieve (Oct 27 2018 at 07:59):

yes $ is special. % should be used in this case

view this post on Zulip Paul Lynch (Oct 27 2018 at 19:13):

@Brian Postlethwaite GF#19530


Last updated: Apr 12 2022 at 19:14 UTC