nazrulworld / fhir.resources

FHIR Resources https://www.hl7.org/fhir/resourcelist.html
https://pypi.org/project/fhir.resources/
Other
372 stars 104 forks source link

WIP: Use fhirdatetime instead of Pydantic's datetime #68

Open mmabey opened 3 years ago

mmabey commented 3 years ago

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!

nazrulworld commented 3 years ago

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

Healthedata1 commented 3 years ago

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.