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".
None
[] - an empty list
{} - an empty dict
() - an empty tuple
'' - an empty str
b'' - an empty bytes
set() - an empty set.
What I Did
cs = construct_fhir_element('CapabilityStatement',dict(
id = meta.id,
url = f'{canon}CapabilityStatement/{meta.id}',
version = meta.version,
# more elements
instantiates = [i for i in meta.instantiates.split(',') if i], #<<<< this evaluates to '[]' instead of None
))
Note that I can code around this but I think this should be the default behavior of the classes as a convienence.
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
Note that I can code around this but I think this should be the default behavior of the classes as a convienence.