{
"resourceType": "QuestionnaireResponse",
"status": "amended",
"id": "qr1",
"item": [
{
"linkId": "1",
"text": "Group 1",
"item": [
{
"linkId": "1.1",
"text": "Question 1.1",
"answer": [
{
"valueString": "Answer 1.1",
"item": [
{
"linkId": "1.1.1",
"text": "Follow-up to 1.1"
}
]
}
]
},
{
"linkId": "1.2",
"text": "Question 1.2",
"item": [
{
"linkId": "1.2.1",
"text": "Question 1.2.1"
}
]
}
]
},
{
"linkId": "2",
"text": "Group 2"
}
]
}
Instead of having a separate forEach element for each level of nesting, you can use repeat to traverse the entire structure recursively, and extract all the item elements at once:
ViewDefinition:
{
"resource": "QuestionnaireResponse",
"status": "active",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
}
]
},
{
"repeat": [
"item"
],
"column": [
{
"name": "linkId",
"path": "linkId",
"type": "string"
},
{
"name": "text",
"path": "text",
"type": "string"
}
]
}
]
}Result of running this ViewDefinition will be a table with the following columns:
You can try it yourself by running a new Aidbox instance by following the instructions in the Run Aidbox locally guide.
Get in touch with us today!
