beda-software/fhir-sdc

Fix populate for repeating answers when itemContext is specified

ruscoder opened this issue · 0 comments

Questionnaire:

{ 
            "resourceType": "Questionnaire",
            "status": "active",
            "launchContext": [{"name": "LaunchPatient", "type": "Patient",},],
            "item": [
                {
                    "type": "group",
                    "linkId": "names",
                    "itemContext": {
                        "language": "text/fhirpath",
                        "expression": "%LaunchPatient.name",
                    },
                    "item": [
                        {
                            "repeats": True,
                            "type": "string",
                            "linkId": "firstName",
                            "initialExpression": {
                                "language": "text/fhirpath",
                                "expression": "given",
                            },
                        },
                    ],
                },
            ],
        },
}

Launch patient

 {
        "resourceType": "Patient",
        "id": "patienit-id",
        "name": [{"given": ["Peter", "Middlename"]}, {"given": ["Pit"]}, {"given": ["Little Pitty"]},],
}

must be populated into:

{
        "item": [
            {
                "item": [
                    {
                        "linkId": "firstName",
                        "answer": [
                            {"value": {"string": "Peter"}},
                            {"value": {"string": "Middlename"}},
                            {"value": {"string": "Pit"}},
                            {"value": {"string": "Little Pitty"}},
                        ],
                    }
                ],
                "linkId": "names",
            }
        ],
        "resourceType": "QuestionnaireResponse",
}