beda-software / fhir-sdc

http://hl7.org/fhir/uv/sdc/ implementation with python
MIT License
18 stars 4 forks source link

Fix populate for repeating answers when itemContext is specified #22

Closed ruscoder closed 3 years ago

ruscoder commented 3 years ago

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",
}