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

Sample code execution error #135

Open
GreySeaWolf opened this issue Jul 6, 2023 · 3 comments
Open

Sample code execution error #135

GreySeaWolf opened this issue Jul 6, 2023 · 3 comments

Comments

@GreySeaWolf
Copy link

  • fhir.resources version: Latest (July, 3)
  • Python version: 3.9
  • Operating System: Windows 10

Description

Examples fail:

This is a sample Python script.

Press Shift+F10 to execute it or replace it with your code.

Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

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

def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.

Press the green button in the gutter to run the script.

if name == 'main':
print_hi('PyCharm')

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

org.resource_type == "Organization"
isinstance(org.address[0], Address)
org.address[0].country == "Switzerland"
org.dict()['active'] is True

print('DONE')

See PyCharm help at https://www.jetbrains.com/help/pycharm/

error:
Traceback (most recent call last):
File "C:\CODE\EpicFHIR\main.py", line 23, in
org = Organization(**data)
File "C:\CODE\EpicFHIR\venv\lib\site-packages\fhir\resources\core\fhirabstractmodel.py", line 105, in init
BaseModel.init(pydantic_self, **data)
File "pydantic\main.py", line 341, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 1 validation error for Organization
address
extra fields not permitted (type=value_error.extra)

Process finished with exit code 1

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
@melindmi
Copy link

@GreySeaWolf, I have the same issue. Did you manage to find a solution or an explanation? Thanks

@rhummel2323
Copy link

Bump, I am also experiencing this issue, thanks!

@Vamshi3130
Copy link

I think ,the issue is There is no inner element called address in Organization resource.
So it is giving an extra fields not allowed error

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

4 participants