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

Validation error with ImagingStudy resource #120

Open
alessiacarotenuto opened this issue Jan 24, 2023 · 2 comments
Open

Validation error with ImagingStudy resource #120

alessiacarotenuto opened this issue Jan 24, 2023 · 2 comments

Comments

@alessiacarotenuto
Copy link

alessiacarotenuto commented Jan 24, 2023

  • fhir.resources version: 6.5.0
  • Python version: 3.10.8
  • Operating System: Windows

Validation error with ImagingStudy resource

I am trying to create an ImagingStudy resource associated with a patient (already created with fhir.resources) and then transform the resource into a JSON/XML object. I get the following error:

Traceback (most recent call last):
  File "C:\Users\\PycharmProjects\pythonProject1\Prova_json_imagingstudy.py", line 13, in <module>
    study = ImagingStudy()
  File "C:\Users\\anaconda3\envs\pythonProject1\lib\site-packages\fhir\resources\core\fhirabstractmodel.py", line 105, in __init__
    BaseModel.__init__(__pydantic_self__, **data)
  File "pydantic\main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for ImagingStudy
__root__ -> status
  field required (type=value_error.missing)

My simple code is: 

### from fhir.resources.imagingstudy import ImagingStudy
from fhir.resources.coding import Coding


from Prova_json_patient import my_patient


import uuid

# Create a new study object
study = ImagingStudy()

# Set the study resource fields
study.subject = 'Patient/' + my_patient.id

study.modality = Coding()
study.modality.code = 'CT'
study.modality.system = 'https://dicom.nema.org/resources/ontology/DCM'

study.id = 'urn:oid:' + str(uuid.uuid4())
study.status = 'available'
print(study.json())

How can this be solved and why does it happen?

@nazrulworld @mmabey @chgl @simonvadee

@chgl
Copy link
Contributor

chgl commented Jan 24, 2023

Maybe the same issue as #56

Could you please try the workaround from #56 (comment)

@Vamshi3130
Copy link

It's because in ImagingStudy class status field is mmarked required , Ur instantiating class without passing required field which gives this 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

3 participants