Closed ytitov closed 3 years ago
@ytitov first of all thanks a lot for reporting this issue.
Encounter(**{"class": 'inpatient', "status": "planned"})
this obisouly validation error as class
should be Coding
type dict instead of string, for example Encounter(**{"class": {"code": 'inpatient'}, "status": "planned"})
. But I am fully agree with you about confusing error message, I will work on it.
I cannot reproduce this error, in my local (Mac + Pycharm environment), would be nice if can share a gist file.
@nazrulworld First, thanks for your responses.
You're right, my object was invalid, but I really wish the error message made sense. Unfortunately I am not a python expert, just a user :)
To replicate:
pip install -e .[all]
./setup.py install
from fhir.resources.organization import Organization
org = Organization.construct()
The resulting error:
$ python demo_fail.py
Traceback (most recent call last):
File "demo_fail.py", line 2, in <module>
org = Organization.construct()
File "C:\Users\ytitov\workspace\fhir\kn-udm-to-fhir\fhir.resources\fhir\resources\fhirabstractmodel.py", line 386, in construct
m, "__dict__", {**deepcopy(cls.__field_defaults__), **values}
AttributeError: type object 'Organization' has no attribute '__field_defaults__'
(venv_py37)
EDIT: Just for good measure I did the same thing on my other PC which is running Arch Linux with python 3.8.3. Used code from master and installed that, still same error. If you still can't reproduce I can see if I can create a Dockerfile for you.
@ytitov I can confirm that problem to be reproducible in my PC and I know why this is happing https://pypi.org/project/pydantic/1.7/ so new pydantic has some breaking changes. use earlier version than 1.7 would solve this problem. But I am looking forward to support pydantic 1.7
@nazrulworld looks like downgrading to pydantic 1.6.1 fixes my issue
Greetings, I am investigating this library to use in a ETL step for a data integration and looking to create FHIR data structures. I've never used pydantic before so please forgive my ignorance :) Could I get some help with why this is failing?
Description
I am trying to create an encounter:
What I Did
Results in a confusing error. Especially since it is talking about "jsondecode" error.
In addition to above Example 5 doesn't seem to work either:
results in