-
Type:
Change Request
-
Resolution: Persuasive with Modification
-
Priority:
Medium
-
FHIR Core (FHIR)
-
R4
-
FHIR Infrastructure
-
Questionnaire
-
-
Paul Lynch/Brian Postlethwaite: 9-0-0
-
Enhancement
-
Compatible, substantive
This is a follow up to a brief discussion on FHIR Chat: https://chat.fhir.org/#narrow/stream/179255-questionnaire/topic/enableWhen.20for.20hiding.20items.3F
In brief: we need a way to conditionally toggle the "readOnly" or "enabled" status of a question based on responses to other question(s).
Description of my use case (from the FHIR Chat):
Let's say I'm building a Questionnaire for patients to fill out when they arrive at a hospital.
This Questionnaire would include questions about their background. Let's say one of those question is, "Do you have a legal guardian?". If yes, we want to ask questions about that guardian, like "First Name," "Last Name," etc.
If the answer is not "yes", then I don't want to clutter the UI by rendering irrelevant "Guardian First Name"-like questions.
This Questionnaire would also include questions about their medical history. There might be a whole section that is a long list of medical conditions, of which an individual is likely to have at most one or two.
Because it is a long, mostly irrelevant list, I want to include a "No to all" option for UX purposes. If this option is selected, I want to lock all of the listed condition responses into being "No" (effectively making them readOnly, or disabled). I'd rather not hide them altogether, because I want to make it obvious that the patient is submitting the fact that they do not have any one of these conditions. And the inverse is also true: I'd like to disable, but not hide, the "No to all" option if any options are selected as "Yes".
Here's what that a Questionnaire that comes close to this functionality would look like:
{ "resourceType": "Questionnaire", "item": [ { "linkId": "patient-background", "type": "group", "text": "Background", "item": [ { "linkId": "has-guardian", "text": "Do you have a legal guardian?", "type": "boolean" }, { "linkId": "guardian-first-name", "text": "Guardian First Name", "type": "string", "enableWhen": [ { "question": "has-guardian", "operator": "=", "answerBoolean": true } ] }, { "linkId": "guardian-last-name", "text": "Guardian Last Name", "type": "string", "enableWhen": [ { "question": "has-guardian", "operator": "=", "answerBoolean": true } ] } ] }, { "linkId": "patient-conditions", "type": "group", "text": "Past Conditions", "item": [ { "linkId": "no-past-conditions", "text": "No to all", "type": "boolean" }, { "linkId": "condition-1", "text": "<condition 1 description>", "type": "boolean", "enableWhen": [ { "question": "no-past-conditions", "operator": "=", "answerBoolean": false } ] }, { "linkId": "condition-2", "text": "<condition 2 description>", "type": "boolean", "enableWhen": [ { "question": "no-past-conditions", "operator": "=", "answerBoolean": false } ] }, { "linkId": "condition-3", "text": "<condition 3 description>", "type": "boolean", "enableWhen": [ { "question": "no-past-conditions", "operator": "=", "answerBoolean": false } ] }, ... more conditions ] } ] }
As Lloyd McKenzie pointed out, that "disable" functionality is a little different from the intended use of `enableWhen`, so maybe this should be logically structured differently.
Another line of thinking: maybe we could use some extension that augments calculatedExpression so that a "successful calculation" flips the question's status to "readOnly"?
With that extension, each of the "conditions" questions above could have a `calculatedExpression` that evaluates to false if the "No to all" question is true; otherwise, it would not perform any calculation. This new extension would suggest that, when this `calculatedExpression` is successful, the question goes from "readOnly: false" "readOnly: true". Seems a little convoluted; anyone have more elegant ideas here?