Stream: questionnaire
Topic: answerOption as an expression result
Diane (Mar 06 2022 at 21:45):
In a questionnaire, I want to use a calculated expression like if the answer to question 1 or 2 is x, then populate question 3 with "Approved", but I don't want the string "Approved", I want the coding from the answerOption for question 3.
A. Which of these do I want my fhirpath expression to return?
-
[{"system":"www.terminologyexample.com","code":"Approved","display":"Approved"}]
-
[{"valueCoding":{"system":"www.terminologyexample.com","code":"Approved","display":"Approved"}}]
-
"answerOption":[{"valueCoding":{"system":"www.terminologyexample.com","code":"Approved","display":"Approved"}}]
B. For the syntax, this is what seems to work in the fhirpath tester, but it doesn't work in LHC Forms:
iif(conditional for Question1 or Question2, %questionnaire.item.where(linkId = 'Question3').answerOption.where(valueCoding.display = 'Approved'))
Since I am referring to the answerOption for question 3 from an extension on question 3, should my expression be more local like:
iif(conditional for Question1 or Question2, %item.answerOption.where(valueCoding.display = 'Approved'))
or
iif(conditional for Question1 or Question2, %answerOption.where(valueCoding.display = 'Approved'))
C. And how do I know if I need a % or not? Should the syntax be %item.answerOption... or item.answerOption...
Lloyd McKenzie (Mar 06 2022 at 23:04):
a) you would want #2. However, there should be an "http://" at the start of your system.
b) driving off 'display' is usually a bad idea - it's supposed to be for human consumption and it can change at any time without any expectation it'll impact code. Is there a reason you can't know what the 'code' is for approved?
c) '%' is used when you're referencing a context variable. So if you're referring to an element name within context, you don't need/want it. When you're referring to a special context variable (%context, %resource, %questionnaire, etc.) you do.
Paul Lynch (Mar 07 2022 at 23:10):
@Lloyd McKenzie I think the answer to (a) is #1. That is the Coding.
Last updated: Apr 12 2022 at 19:14 UTC