Skip to content

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

Draft
mmabey wants to merge 1 commit into
nazrulworld:masterfrom
mmabey:fhirdatetime
Draft

WIP: Use fhirdatetime instead of Pydantic's datetime#68
mmabey wants to merge 1 commit into
nazrulworld:masterfrom
mmabey:fhirdatetime

Conversation

@mmabey

@mmabey mmabey commented Apr 27, 2021

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Owner

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

Copy link
Copy Markdown

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.

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

Successfully merging this pull request may close these issues.

3 participants