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

How can I validate any FHIR? #78

Open
gitpushdashf opened this issue Aug 24, 2021 · 3 comments
Open

How can I validate any FHIR? #78

gitpushdashf opened this issue Aug 24, 2021 · 3 comments

Comments

@gitpushdashf
Copy link

Hi,

I'd like to validate any type of FHIR dictionary. Whether a Bundle, MedicationRequest, etc. I just want to know that it's valid FHIR.

So far I have:

from fhir.resources.bundle import Bundle

Bundle(**fhir_dict)

Which works great for bundles. I tried Resource, but it doesn't seem to automatically map the resource.

Is this possible with fhir.resources, or easily atainable? I like the error messages a lot more than JSON Schema.

Thank you!

@nazrulworld
Copy link
Owner

Hi, @gitpushdashf thanks for your interest in this project. Can you please add the problem with the details, perhaps with an example?
//I tried Resource, but it doesn't seem to automatically map the resource.// you mean fhir.resources.resource.Resource?

@gitpushdashf
Copy link
Author

We're wanting to make sure the FHIR that developer write is valid. We have some fields that can be any JSON FHIR, whether MedicationRequest or Bundle. So we load the JSON into a dict, and then try to process it. However, we don't know in advance if it might be a MedicationRequest, Bundle, etc. We just want to raise an error if it's invalid.

We've been using jsonschema for this, but the error messages are terrible. These are much easier to read.

Yes, that's right. I meant fhir.resources.resource.Resource.

@gitpushdashf
Copy link
Author

Ok, here's what I came up with:

from fhir.resources import construct_fhir_element

construct_fhir_element(resource["resourceType"], resource)

Piggybacking off of #76.

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

2 participants