Open Healthedata1 opened 3 years ago
I fully agree with you, that an empty list should be ignored just a null value.
Although I can see the argument for persisting an empty list when building an instance. You might want to append items in a subsequent step. So it would not always be desirable behavior. Maybe the class could preserve the list, but the serialization methods would "scrub" them or not based on a parameter?
All are default behaviors from the Pydnatic
but It is possible to change that empty list, dict to None during serialization. I will work on it.
Thanks!
Description
I am creating a FHIR object using the models and a spreadsheet as a source When there is repeating element and their is no data in the source, my code creates an empty list. This empty list is preserved unlike when the element is None. I think when an element is evaluated to these Falsy types listed below I think it should behave the same ... namely the element value should be
None
. Note that in FHIR "when present, elements cannot be empty - they SHALL have a value attribute, child elements, or extensions".What I Did
As a convenience, I would like to see these falsy values be treated like None instead of persisting.