FHIR Chat · Limit of 1 initialExpression or calculatedExpression? · questionnaire

Stream: questionnaire

Topic: Limit of 1 initialExpression or calculatedExpression?


view this post on Zulip Paul Lynch (Dec 11 2018 at 16:37):

I think that logically, it does not make sense for a field to have more than one initialExpression, or more than one calculatedExpression, and (probably) not more than one of either. Is there anything in the spec to say that a valid questionnaire will not have more that one of those?

view this post on Zulip Lloyd McKenzie (Dec 11 2018 at 17:09):

The cardinality of each should have a max of 1. We could add context invariants to each that would prevent there from being more than one of both

view this post on Zulip Paul Lynch (Dec 11 2018 at 17:25):

Okay-- I see there is a cardinality setting of 0..1 on those extensions.

view this post on Zulip Lloyd McKenzie (Dec 11 2018 at 17:31):

If you think it's important to enforce the cross-extension cardinality limit, you can submit a change request

view this post on Zulip Paul Lynch (Dec 11 2018 at 17:51):

I am unsure about that. As a contrived example, suppose you have a BMI field. You might want an initialExpression to load in the previous BMI value, and then have a calculatedExpression to update it when height and weight values (which could start out blank, preventing the calculatedExpression from running) are filled in.

view this post on Zulip Lloyd McKenzie (Dec 11 2018 at 18:08):

One of the things we haven't done with calculatedValue yet is declare at what point the value gets calculated - does there have to be an answer for all of the questions?

view this post on Zulip Paul Lynch (Dec 11 2018 at 19:15):

The spec says, "Calculated value is updated as other answers in the QuestionnaireResponse are filled in". I was assuming this meant, "whenever a value changes, run the calculatedExpressions".

view this post on Zulip Brian Postlethwaite (Dec 12 2018 at 02:15):

And the renderer could be smart about it, maybe.

view this post on Zulip Paul Lynch (Dec 12 2018 at 15:08):

If by "smart" you mean being selective about which expressions need to be run, I don't see a way to do that with the current spec. You do not know in advance what other answers a FHIRPath expression might reference, and the set of answers it references could change from one run to the next. In LHC-Forms, we specify explicitly what the source items are, so we only run what is needed when one of the source items changes. It would be nice if something like that were in Questionnaire, though for small forms it doesn't seem to hurt too much to run them all.


Last updated: Apr 12 2022 at 19:14 UTC