Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept extra fields when calling parse_obj. #84

Open
Mo-Di opened this issue Nov 10, 2021 · 1 comment
Open

Accept extra fields when calling parse_obj. #84

Mo-Di opened this issue Nov 10, 2021 · 1 comment
Labels
question Further information is requested

Comments

@Mo-Di
Copy link

Mo-Di commented Nov 10, 2021

  • fhir.resources version: 6.1.0
  • Python version: 3.9
  • Operating System:

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 fields created, indexed and class. Running DocumentReference.parse_obj(response_json) throws error such as extra 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 like allow_extra for parse_obj?

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
@nazrulworld nazrulworld added the question Further information is requested label Nov 11, 2021
@nazrulworld
Copy link
Owner

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.

  1. I think your current approach is good for now.
  2. There are many ways to put extra (nonstandard info) inside FHIR resource for example 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants