Stream: fhirpath
Topic: Question from Questionnaire handling
Grahame Grieve (Feb 28 2019 at 22:17):
@Paul Lynch has a question (see GF#19530) about the correct way to refer to variables defined in questionnaires in FHIRPath statements in expressions found in the Questionnaire.
Grahame Grieve (Feb 28 2019 at 22:18):
the intent is that the expressions can use the defined variables as values .
Grahame Grieve (Feb 28 2019 at 22:18):
Paul has implemented using %[var-name], where as I dropped the %, so that you just used the variable name, and it's known object in the FHIRPath engine.
Grahame Grieve (Feb 28 2019 at 22:19):
On the basis that %[x] is used for global constants.
Grahame Grieve (Feb 28 2019 at 22:19):
Paul points out that questionnaire variables are behaving like global constants anyway
Grahame Grieve (Feb 28 2019 at 22:20):
there'd be a 3rd option - use something like questionnaireVariables().[var-name]
Grahame Grieve (Feb 28 2019 at 22:20):
@Ewout Kramer @Bryn Rhodes @Brian Postlethwaite do you have style opinions on this?
Bryn Rhodes (Feb 28 2019 at 23:41):
I would prefer without the %, since with the percent it may collide with environment variable names.
Bryn Rhodes (Feb 28 2019 at 23:41):
Without the % it may collide with resource names, but that's a more understandable situation I think (and easier to resolve).
Grahame Grieve (Mar 01 2019 at 01:00):
it may also collide with property names. which sounds more serious...
Grahame Grieve (Mar 01 2019 at 01:00):
vars() or some variant is the least likely to collide with something
Brian Postlethwaite (Mar 01 2019 at 03:49):
vars("varname")
would work
I was ok with env variables.
Paul Lynch (Mar 01 2019 at 15:01):
I think that with %, colliding with environment variables is okay. If someone names a variable "resource", and then writes FHIRPath using %resource, it should probably refer to their variable. If they didn't mean to do that, they can just change the variable name, because these are variables defined inside the same Questionnaire that has the FHIRPath. (At least, that it the one use case of which I am aware.)
Paul Lynch (Mar 01 2019 at 15:13):
I am also reluctant to introduce a second kind of variable. The API for the FHIRPath engine then needs to take two hashes of variables, one for environment variables, and one for "other" variables. (I am not sure how to explain "other" variables, in the fhirpath.js API. What would I call them? Non-environment variables?) I'll grant that there could be a need for a second kind of variable, but in this Questionnaire space I am familiar with, I don't see it.
Grahame Grieve (Mar 01 2019 at 19:09):
which other variables get addressed through %[name]?
Paul Lynch (Mar 07 2019 at 15:57):
@Grahame Grieve Sorry for the long delay in replying-- I was out for a few days. I am not sure I've understood your question. We currently have "environment variables" accessed through %[name], and I am in favor of using the same syntax for variables created by extensions like questionnaire-calculatedExpression. When I said "second kind of variable above" I was arguing against introducing a separate syntax for referencing (within FHIRPath) variables introduced by those extensions.
Last updated: Apr 12 2022 at 19:14 UTC