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

AllergyIntolerance object gives "Extra fields not permitted" error for reaction object. #155

Open
vshah11 opened this issue Jun 14, 2024 · 6 comments

Comments

@vshah11
Copy link

vshah11 commented Jun 14, 2024

  • fhir.resources version: 7.1.0
  • Python version: ~=3.10.7
  • Operating System:

Description

I am using fhir.resources to parse the AllergyIntolerance resource object. According to latest version of pydantic v2 and fhir.resources, it should be accepting the reaction.manifestation fields but I keep getting the - extra fields not permitted (type=value_error.extra) error.

Screenshot 2024-06-14 at 12 25 18 PM

The fhir documentation specifying that this is a valid AllergyIntolerance field and not an Extra -

https://hl7.org/fhir/R4/allergyintolerance.html

I wish to understand if there are some breaking changes when upgrading fhir.resources to version 7.1 and pydantic to version 2.*?
My previous setup had "fhir.resources==6.4.0", "pydantic==1.10.14" and I did not face this issue.

What I Did

from fhir.resources.allergyintolerance import AllergyIntolerance
resource = AllergyIntolerance.parse_obj(data_object)
@AniMukherjee
Copy link

I'm facing similar issue with fhir.resources version: 7.1.0 for Organization.

from fhir.resources.organization import Organization
from fhir.resources.address import Address

data = {"id": "f001", "active": True, "name": "Acme Corporation", "address": [{"country": "Switzerland"}]}
org = Organization(**data)

same code from example is throwing "Extra fields not permitted" error.

@nazrulworld
Copy link
Owner

It seems you chose the wrong FHIR version. In FHIR R5 https://www.hl7.org/fhir/organization.html
there is no property named "address", so naturally you are getting this error.

@AniMukherjee
Copy link

Thank you for your response. I'm actually looking for some assistance here. I'm new in Health Care technologies and not very sure of the latest standards.

I went through the documentation and understood that R4 only had "address" in "Organization".
Is there any old version of fhir.resources that parses R4 version?

@nazrulworld
Copy link
Owner

You can try

from fhir.resources.R4B.organization import Organization
from fhir.resources.R4B.address import Address

data = {"id": "f001", "active": True, "name": "Acme Corporation", "address": [{"country": "Switzerland"}]}
org = Organization(**data)

@AniMukherjee
Copy link

Thank you again for your help. I'm able to parse my JSONs now!

@AniMukherjee
Copy link

I got one more issue parsing Coverage resource. What I found in official document is that "type of Coverage" is of CodeableConcept datatype. But while parsing it is identified as simple list element and throwing an error. Can you please suggest a fix for this?

ValidationError: 1 validation error for Coverage
type -> __root__
  Value is expected from the instance of <class 'fhir.resources.R4B.codeableconcept.CodeableConcept'>, but got type <class 'list'> (type=value_error)
image

I'm able to parse this individual element as CodeableConcept; but not the complete Coverage JSON.

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

No branches or pull requests

3 participants