skalarsystems / fhirzeug

A Python FHIR specification parser and class generator
Apache License 2.0
17 stars 1 forks source link

Issue with empty sub-objects #40

Closed julian-r closed 4 years ago

julian-r commented 4 years ago

Deserialzing

{
                "resourceType": "ClinicalImpression",
                "status": "completed",
                "subject": {"reference": ""},
}

Leads to a internal representation of:

resource_type='ClinicalImpression' id=None meta=None implicit_rules=None language=None text=None contained=None extension=None modifier_extension=None identifier=None status=<EventStatus.completed: 'completed'> status_reason=None code=None description=None subject=Reference(id=None, extension=None, reference=None, type=None, identifier=None, display=None) encounter=None effective_date_time=None effective_period=None date=None assessor=None previous=None problem=None investigation=None protocol=None summary=None finding=None prognosis_codeable_concept=None prognosis_reference=None supporting_info=None note=None

Which then leads to a serialization of, which is an invalid ClinicalImpression since subject has a carnality of 1...1:

{
                "resourceType": "ClinicalImpression",
                "status": "completed"
}

This behavior is half correct. The subject should actually be stripped before de-serialization, which then would lead to a ValidationError, because subject is a required field.