FHIR Chat · enableWhen for hiding items? · questionnaire

Stream: questionnaire

Topic: enableWhen for hiding items?


view this post on Zulip Tadas Antanavicius (Dec 13 2019 at 02:13):

Hi,

I'd like to use enableWhen in two ways:
1) Hide large parts of a Questionnaire based on some answer at the top of an item tree --> desired behavior is to avoid rendering the item tree altogether
2) Visually indicate that a specific question is "disabled" as a result of the user's response to another question

It seems like right now my rendering implementation needs to decide whether to treat all enableWhen logic as resulting in either (1) or (2), but is not configurable to do both.

Is there some extension that exists that would cover this use case? e.g. something like hiddenWhen (conditionally hide, as opposed to enableWhen's enable/disable) or enableWhenRender (if false, hide instead of disable).

I haven't been able to find anything in Questionnaire extensions (https://build.fhir.org/questionnaire-extensions.html) or SDC (http://build.fhir.org/ig/HL7/sdc/) that is along those lines.

Thanks!

view this post on Zulip Lloyd McKenzie (Dec 13 2019 at 02:20):

Right now there's no extension that would drive the behaviour. Can you explain why a questionnaire author would want to?

view this post on Zulip Tadas Antanavicius (Dec 13 2019 at 18:48):

Sure thing. 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.

Here's what that Questionnaire 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
      ]
    }
  ]
}

Does that make sense? Is there a different way to go about this than my line of thinking?

view this post on Zulip Lloyd McKenzie (Dec 13 2019 at 19:23):

Hmm. "No to all" is something different than "enable/disable" because (at least logically) you're forcing an answer for the questions. Submit a change request for us to talk about the use-case. It's certainly something that shows up in some forms and we should have a way to handle it.

view this post on Zulip Tadas Antanavicius (Dec 13 2019 at 19:59):

Sounds good, made it here: https://jira.hl7.org/browse/FHIR-25380


Last updated: Apr 12 2022 at 19:14 UTC