FHIR Chat · calculatedExpression & type · questionnaire

Stream: questionnaire

Topic: calculatedExpression & type


view this post on Zulip Paul Lynch (Apr 23 2021 at 23:19):

Is it documented someplace that the result of a calculatedExpression should agree with item.type, and what the behavior should be if it doesn't? I couldn't find it.

view this post on Zulip Lloyd McKenzie (Apr 24 2021 at 15:41):

Probably not defined - care to create a change request?

view this post on Zulip Paul Lynch (Apr 26 2021 at 18:30):

FHIR-31991

view this post on Zulip Ephraim Kigamba (Jun 07 2021 at 14:50):

Hey @Lloyd McKenzie , can calculatedExpression be used to copy the value/answer of another item?

view this post on Zulip Lloyd McKenzie (Jun 07 2021 at 14:51):

Yes, though you might also need variable, depending on the relative location.

view this post on Zulip Ephraim Kigamba (Jun 08 2021 at 09:46):

Thanks @Lloyd McKenzie Do you have a quick example where variable would be needed?

view this post on Zulip Lloyd McKenzie (Jun 08 2021 at 13:27):

calculatedExpression will only have access to descendant items. If the item you want to copy is a sibling or ancestor, you'll have to capture the value in a variable to be able to reference it with calculatedExpression in the current item.

view this post on Zulip Ephraim Kigamba (Jun 08 2021 at 13:30):

Oh! Cool. Now I get you

view this post on Zulip Paul Lynch (Jun 08 2021 at 15:24):

Lloyd McKenzie said:

calculatedExpression will only have access to descendant items. If the item you want to copy is a sibling or ancestor, you'll have to capture the value in a variable to be able to reference it with calculatedExpression in the current item.

@Lloyd McKenzie I don't think that is correct, in general. An Expression can access anything in the Questionnaire/QuestionnaireResponse via %questionnaire and %resource. However, if you are dealing with an Expression in a repeating group, you can't find the correct repetition that way, and need to rely on %context, which limits you to the item and its children. In that case you would want a variable on the repeating group.

view this post on Zulip Ephraim Kigamba (Jun 08 2021 at 15:29):

@Paul Lynch Noted. Thanks for the clarification.


Last updated: Apr 12 2022 at 19:14 UTC