Open Mo-Di opened 2 years ago
Hi @Mo-Di first of all, thanks a lot for using this library.
I like your idea that would give developers more flexibilities to handle nonstandard fields. Unfortunately, we cannot allow
any nonstandard field like this, as you know this library is 100% complying with FHIR Specification, besides Config.extra
is in class level should not modify from function/method.
Extension
, Meta
you could ask your integrator to implement, or maybe you do some filter on the extra field (perhaps generate an Extension ) before constructing FHIR Object
Description
Our integrator sends us extra fields in their response JSON that aren't part of resource definition. For example, their
DocumentReference
resource json has extra fieldscreated
,indexed
andclass
. RunningDocumentReference.parse_obj(response_json)
throws error such asextra fields not permitted (type=value_error.extra)
.Our current workaround is to override the abstract model before calling
parse_obj
:FHIRAbstractModel.Config.extra = Extra.allow
. This feels too hacky.Maybe
fhir.resources
could surface an argument likeallow_extra
forparse_obj
?What I Did