Closed axelv closed 1 year ago
Thanks for helping us making this library even better! There were some updates to the main branch recently that include resourceType
generation and automation of update_forward_refs
for BaseModel
resources. Please let us know if there are any issues left with that. As for the AnyResource
type - I believe it's a great idea and we can also extend it to other contexts where we now have Resource
(like contained
property). Will look into it!
Quick update on the proposed changes: synthea-generated resources validation should now work in the main branch.
Very cool @m0rl! Meanwhile I'm looking for an elegant way to implement the Any* types for abstract structures like Resource, DomainResource. Not sure if this also holds for Element and BackboneElement (these also have abstract = true
).
Very cool @m0rl! Meanwhile I'm looking for an elegant way to implement the Any* types for abstract structures like Resource, DomainResource. Not sure if this also holds for Element and BackboneElement (these also have
abstract = true
).
Nevermind. I just notice that you already fixed the AnyResource generation.
Good job Bundle.parse_file
on the Synthea works fine👍 🚀
Pytest results on 1180 Bundles
Total number of tests expected to run: 1180
Total number of tests run: 1180
Total number of tests passed: 1180
Total number of tests failed: 0
Total number of tests failed with errors: 0
Total number of tests skipped: 0
Total number of tests with no result data: 0
Finished running tests!
Thanks for testing it! We also plan to add synthea bundle validation regression tests in the near future (together with the regression tests for R4/R5 spec parsing and typecheck).
First of all thx for starting this awesome library!
This is WIP but I'd like your feedback on how to proceed. My goal is to validate the generated models on Synthea generated FHIR resources so we that we are confident that the models work correctly. During this attempt I encountered several issues:
Pydantic models have circular references which need to be resolved using
update_forward_refs
. I added this inast.py
We will need a union type of all resources to parse resources inside a Bundle. Currently, Pydantic tries to validate
Bundle.entry.resource
as aResource
but actually, it should validate it as a Union of all possible resources. I added the automatic generation of such a union type (see:AnyResource
) toast.py
.resourceType
was missing. I tried to generate it automatically but failed to do it correctly for all resources because some resources are split into multiple models. I think this is the result of polymorphic elements. ExImmunization = _ImmunizationDateTime | _ImmunizationString
. Having two models with the sameresourceType
is not practical because then we can't use Pydantic'sField(discriminator='resourceType')
for Union typesToDo:
Any thoughts on the issues above? Feedback on code style and directory structure is welcome!