-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug/clean date #31
Bug/clean date #31
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #31 +/- ##
===========================================
- Coverage 93.22% 93.14% -0.09%
===========================================
Files 24 24
Lines 1166 1181 +15
===========================================
+ Hits 1087 1100 +13
- Misses 79 81 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had considered doing this when I first wrote the patient portion, but I don't think this is the right thing to do. Even though a person was born on a specific day, that day changes between timezones. For instance, if a person was born on May 31st in New York, that could very well be April 1st in Australia.
Best practice here would be to always pass in a timezone-aware datetime object. The clean_datetime
method actually will translate a timezone-naive datetime into UTC properly. For example:
>>> from datetime import datetime, timezone
>>> dt = datetime.now()
>>> dt
datetime.datetime(2022, 8, 9, 18, 10, 47, 877296)
>>> dt.astimezone(tz=timezone.utc)
datetime.datetime(2022, 8, 10, 1, 10, 47, 877296, tzinfo=datetime.timezone.utc)
Thoughts?
Ahhh ok. So Welkin is defining a "DATE" object to be a ISO-8601 UTC Zulu string with a zero timestamp. That's silly I view this as a bug in the Welkin API. A birthdate should be a full timestamp. If a doctor were to tell a patient "Happy Birthday!" but they're a few timezones away, the patient could respond with "Oh, thanks, but that was yesterday". Or maybe it doesn't matter, since the primary use of birth date is probably identity verification. What do you think of this approach? Keeps us using the same logic for timestamp formatting regardless of input. def clean_date(date: date) -> str:
dt = datetime(date.year, date.month, date.day, 0, 0, 0)
return clean_datetime(dt) Either way, approved, merge at your leisure. |
Sweet, thank you. Opted for your method I much prefer that. |
This pr adds a clean date method specifically for the creation of patients with their birthdate but also general use. The clean datetime does not suffice and passing a raw date does not work with the api.
Example of failure:

Expected behavior is for the date to be converted into a string and the patient successfully created