Search code examples
hl7-fhir

FHIR Questionnaire - questions order


In my application I want to use FHIR Questionnaire resource. On the server side I am trying to generate questionnaire with different types of questions and send it to the application where user (patient) can fill in answers and send them back. However in some cases I would like from user to answer only specific questions of the questionnaire and not all of them. For example if questionnaire consists of two questions:

  1. Do you smoke or drink alcohol?
  2. Measure your heart rate.

I would like that user answers second question only if he has answered on the first question with 'yes'. The second question is skipped if he has answered 'no'.

The problem is that I do not know how to add these rules, which will tell which question is next, inside the Questionnaire resource. I came along to some extensions like ordinalValue, but I couldn't find out how/where to use them and where to define if user's answer must be equal / less / greater than some value.

So I would like to know which extension i need to use (and how) to achieve what I've written before? Is this even possible with existing extensions or I would have to define a new one?

I am adding simple representation (with only relevant data) of mentioned questionnaire in the JSON form:

{
  "resourceType": "Questionnaire",
  ...
  "item": [
    {
      "linkId": "1",
      "text": "Do you smoke or drink alcohol?",
      "type": "boolean"
      << ??? extension ???>>
    },
    {
      "linkId": "2",
      "text": "Measure your heart rate.",
      "type": "integer"
    }]
}

Solution

  • You could use the Questionnaire.item.enableWhen element for this:

    {
        "linkId": "2",
        "text": "Measure your heart rate.",
        "type": "integer"
        "enableWhen": [{
                "question": "1",
                "answerBoolean": "true",
            }
        ],
    }