FHIR Chat · Responses to nested questions · questionnaire

Stream: questionnaire

Topic: Responses to nested questions


view this post on Zulip Morten Ernebjerg (Mar 24 2020 at 16:16):

I'm just starting to play around with Questionnaire/QuestionnaireResponse (for STU3) and have a question regarding responses to questionnaires with nested questions.

I constructed the following Questionnaire with two questions, one nested within the other:

{
    "resourceType": "Questionnaire",
    "url": "http://example.com/Questionnaire/practice-questionnaire-test2",
    "status": "draft",
    "item": [{
        "linkId": "date",
        "required": true,
        "text": "Date of hospital visit",
        "type": "date",
        "item": [{
            "linkId": "rating",
            "required": true,
            "text": "What general score would you give the hospital on a scale from 1 to 10?",
            "type": "integer"
        }]
    }]
}

I expected the following to be a valid response:

{
    "resourceType": "QuestionnaireResponse",
    "questionnaire": {
        "reference": "http://example.com/Questionnaire/practice-questionnaire-test2"
    },
    "status": "completed",
    "item": [{
        "linkId": "date",
        "answer": [{
            "valueDate": "2020-03-23",
            "item": [{
                "linkId": "rating",
                "answer": [{
                    "valueInteger": 10
                }]
            }]
        }]
    }]
}

But this gives an error upon validation (latest JAR) - the validator does not find the second answer:

java -jar org.hl7.fhir.validator.jar -version 3.0.2 -questionnaire required -ig practice-questionnaire-test2.json  practice-questionnaireresponse-test2.json
(...)
*FAILURE* validating practice-questionnaireresponse-test2.json:  error:1 warn:0 info:0
  Error @ QuestionnaireResponse.item[0] (line 7, col15) : No response found for required item with id = 'rating'

I tried various other ways of structuring the response but did not find one that worked. Any ideas as to what I am doing wrong?

view this post on Zulip Lloyd McKenzie (Mar 24 2020 at 16:37):

It may be you're not doing anything wrong. @Grahame Grieve - I can't see anything wrong with these instances, do you??

view this post on Zulip Grahame Grieve (Mar 30 2020 at 01:00):

the problem here is the whole answer/question thing. The validator is validating the item.answer.item, but it's actually looking for item.item when it gives that error message

view this post on Zulip Grahame Grieve (Mar 30 2020 at 01:01):

@Lloyd McKenzie the source questionnaire doesn't say anything item.item vs item.answer.item does it? they're both the same (this is in R3)

view this post on Zulip Lloyd McKenzie (Mar 30 2020 at 01:24):

item.item is used for children of groups, item.answer.item is used for children of questions. We've approved a change request to make that more clear.

view this post on Zulip Grahame Grieve (Mar 30 2020 at 01:36):

does that apply retrospectively in R3 and R4?

view this post on Zulip Lloyd McKenzie (Mar 30 2020 at 01:37):

Yes. It was always the intention, just not always well documented other than a few examples.

view this post on Zulip Grahame Grieve (Mar 30 2020 at 02:34):

ok fixed next release

view this post on Zulip Morten Ernebjerg (Mar 30 2020 at 08:11):

Great, thanks! :confetti:


Last updated: Apr 12 2022 at 19:14 UTC