fhir.resources
fhir.resources copied to clipboard
WIP: Use fhirdatetime instead of Pydantic's datetime
Re: #29
I tried to be very light-handed with changing the existing validators. It's possible that some of the remaining checks aren't necessary, but I didn't feel like that was my call. I've used the changes to fhir.resources
in my own code with success. It's still possible that fhirdatetime
has some issues (in fact, I can see that many STU3 and R4 tests are failing with these changes), which is why I've created this as a draft PR. Looking forward to getting some feedback!
Thanks a lot for your amazing work! The major issue, I see the same class is used for three types of data. Date, DateTime, Instant. It is literally possible to provide datetime value for Date type which should not. for example
dt = fhirdatetime.FhirDateTime.now()
Date.validate(dt)
I think better would be we add two more classes in that package. I will add details here https://github.com/mmabey/fhirdatetime
after working with both the smart FHIRClient.py models and fhir.resources. I find that using python's datetime natively works so much better that always converting dates, datetime to a FHIRDate. So I would prefer to keep and I imagine ( no proof ) it works much better with Pydantic and fastAPI.