nazrulworld / fhir.resources

FHIR Resources https://www.hl7.org/fhir/resourcelist.html
https://pypi.org/project/fhir.resources/
Other
365 stars 104 forks source link

Sample code execution error #135

Open GreySeaWolf opened 1 year ago

GreySeaWolf commented 1 year ago

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 commented 1 year ago

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

rhummel2323 commented 11 months ago

Bump, I am also experiencing this issue, thanks!

Vamshi3130 commented 5 months ago

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