How to use something like enableWhen to filter answerOptions in the Questionnaire?


We are developing a questionnaire using the HL7 FHIR standard. However, we have not found a way to include response options that depends on a condition.

For example, in the question below the option “pregnancy” should only show if the patient is female:

  1. Do you have any of the conditions below?
    [ ] Pregnancy (condition: only show if patient is female)
    [x] Diabetes
    [x] Hypertension
    [ ] Asthma

Another example:

  1. Have you been treated for the diseases below?
    [x] Diabetes (condition: only show if answer to question 1 contains diabetes)
    [x] Hypertension (condition: only show if answer to question 1 contains hypertension)
    [ ] Asthma

Is there any way to represent this kind of condition? We saw that enableWhen exists, but it seems to work only for the whole question.

Thank you!

1 Like

Looks like you’re looking at STU3- have you looked at R4 where we beefed enableWhen up?

We looked at the R4. But we understand that enableWhen is used to hide the entire item (a question). That’s right?

What we need to do is hide some answerOptions from an item (a question).

Thank you!

Right. You’re wanting dynamic control of options, not questions. We don’t have anything that supports that right now. Can you submit a change request? We might look at expanding the context of the enableWhenExpression extension to also be available on item.option. (In the meantime, you could define your own extension for that purpose.)

Thanks. I submited a change request about it