You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I had in mind was making my Pydantic models compatible with Mapping. Then, the library will be generalized from dict and list types to mapping and sequence types.
I am happy to help implement this one in a PR if it is viable 🙌
The text was updated successfully, but these errors were encountered:
If I got you right, currently it's impossible to pass Pydantic model into fhirpathpy.evaluate without explicitly invoking model_dump() on the instance first.
I guess it's not easy to adjust the code to support pydantic models, because in that case all conditions like isinstance(data, dict) should be supplemented with isinstance(data, BaseModel) that will require pydantic as a dependency.
What concerns do you have with writing evaluate(model.model_dump(), "expression")?
My concerns with evaluate(model.model_dump(), "expression") :
I'm using a custom BaseModel for my FHIR Pydantic models with custom methods (eg. __str__(), __liquid__()). When running model_dump() all those methods are lost.
To a lesser extent, performance
Some ideas I'm playing with
First solution I have in mind is generalizing the type checks for dict
If I find a way to implement __getitem__ on my Pydantic model. Replacing all isinstance(data, dict) with isinstance(data, Mapping) would be enough I think.
Second solution, but this is more a workaround:
Maybe there is a way to extract the model 'path' of the result items from evaluate. Base on the path I can try to parse result nodes back to Pydantic. 🤔
Is it technically possible to support Pydantic models like the ones generated by https://github.com/beda-software/fhir-py-types directly in fhirpath (without needing to serialize)?
What I had in mind was making my Pydantic models compatible with Mapping. Then, the library will be generalized from
dict
andlist
types tomapping
andsequence
types.I am happy to help implement this one in a PR if it is viable 🙌
The text was updated successfully, but these errors were encountered: