LHNCBC / lforms-fhir-app

A SMART on FHIR app that uses lforms widget to handle Questionnaire and QuestionnaireResponse

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

linking answer from question nested under a multiple choice question to the correct answer of the multiple choice question is not possible

Rosnyni opened this issue · comments

When there is question item nested in a repetable choice item, like this :

{
  "item": [
    {
      "item": [
        {
          "type": "dateTime",
          "linkId": "9619975540361",
          "text": "1ère pose",
          "enableBehavior": "any"
        },
        {
          "type": "dateTime",
          "linkId": "383437689368",
          "text": "repose",
          "enableBehavior": "all",
          "repeats": true
        }
      ],
      "type": "choice",
      "linkId": "2624342465402",
      "text": "analgésie",
      "repeats": true,
      "answerOption": [
        {
          "valueCoding": {
            "display": "Analgésie péridurale"
          }
        },
        {
          "valueCoding": {
            "display": "MEOPA"
          }
        }
      ]
    }
  ],
  "resourceType": "Questionnaire",
  "title": "New Form",
  "status": "draft"
}

the lhc form demo and the smart app generate a questionnaireResponse in which the answer of the nested items are nested in the first answer of the choice question, like this :

{
  "resourceType": "QuestionnaireResponse",
  "meta": {
    "profile": [
      "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse|2.7"
    ],
    "tag": [
      {
        "code": "lformsVersion: 34.0.1"
      }
    ]
  },
  "status": "completed",
  "authored": "2023-08-28T07:35:15.678Z",
  "item": [
    {
      "linkId": "2624342465402",
      "text": "analgésie",
      "answer": [
        {
          "valueCoding": {
            "system": "local",
            "code": "M",
            "display": "MEOPA"
          },
          "item": [
            {
              "linkId": "9619975540361",
              "text": "1ère pose",
              "answer": [
                {
                  "valueDateTime": "2023-08-28T07:35:10.301Z"
                }
              ]
            }
          ]
        },
        {
          "valueCoding": {
            "system": "local",
            "code": "AP",
            "display": "Analgésie péridurale"
          }
        }
      ]
    }
  ]
}

It is not my understanding on how it should work (but I can be wrong). In my understanding, it should bee possible for the user to associate the response to the nested item to any desired response to the repeatable choice item (and possibly to multiple answer).

So there is probably something to fix :

  • in the UI to allow for the nested item to be answered for each response to the multiple choice item
  • in the questionnaireResponse generation (that is obviously closely linked to the UI...)

It is however possible to turnaround this: nesting a non-repeatable choice item in a repeatable group item. The items nested under the choice are then trivialy linked to the correct choice answer.

Please take a look at https://www.hl7.org/fhir/questionnaireresponse.html#nesting, and the diagrams next to it, and let me know if that clears things up. I believe our output is correct per the specification.

Thank you for your answer and sorry for the delay.

My understanding of the reference you provide confort me in my understanding however.

It is stated that :

items nested within a question always nest within each answer to the question. If the question allows multiple answers, each will have its own set of nested items.

Also for questions nested under a multiple choice question like that :

{
  "item": [
    {
      "type": "choice",
      "linkId": "4674330159806",
      "text": "choice question",
      "required": false,
      "repeats": true,
      "readOnly": false,
      "answerOption": [
        {
          "valueCoding": {
            "display": "choice 1"
          }
        },
        {
          "valueCoding": {
            "display": "choice 2"
          }
        },
        {
          "valueCoding": {
            "display": "choice 3"
          }
        }
      ],
      "item": [
        {
          "type": "date",
          "linkId": "4316066837308",
          "text": "choice date"
        },
        {
          "type": "string",
          "linkId": "4810994496630",
          "text": "choice comment"
        }
      ]
    }
  ],
  "resourceType": "Questionnaire",
  "title": "Test Form",
  "status": "draft"
}

It should be possible to associate answer of the nested question with each choice

With the above exemple, It should be possible to have :

choice question : choice 1
choice comment : commentary of the choice 1

choice question : choice 2
choice comment : commentary of the choice 2

to make a parallel with the diagram you point to, the choice question is Q3
and the choice comment is Q4
each answer to Q3 has its own Q4 answer

(I must confess that I don't understand why there is a Q4 nested in Q3 and a Q4 nested in a group nested in Q4... I just ask on chat.fhir.org)

Okay, I see your point. The nested child items do not repeat for each selected answer, but they should.

That's it, but your way of expressing it is much more concise than mine :-)

This is now fixed as of 36.0.5.