-
Notifications
You must be signed in to change notification settings - Fork 309
(fix) O3-4970: Use date-only format for immunization expiration dates #2779
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
Conversation
|
@denniskigen @NethmiRodrigo kindly help in reviewing this PR. |
| * toDateOnlyString(date); // Returns "2025-12-31" | ||
| * ``` | ||
| */ | ||
| export const toDateOnlyString = (date: Date): string => { |
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 don't think we need this date formatting utility. If we just need to set things to a specific date format, dayjs() can already do so.
packages/esm-patient-immunizations-app/src/immunizations/immunizations-form.test.tsx
Outdated
Show resolved
Hide resolved
| const immunizationWithExpiration = { | ||
| vaccineUuid: '782AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', | ||
| immunizationId: 'test-immunization-with-expiration', | ||
| vaccinationDate: new Date('2024-12-25').toString(), |
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.
Dates should still be formatted as ISO Strings here.
packages/esm-patient-immunizations-app/src/immunizations/utils.ts
Outdated
Show resolved
Hide resolved
|
Hey @ibacher , @NethmiRodrigo , @VeronicaMuthee ! |
|
@denniskigen @Muppasanipraneeth I remember in yesterday's call there was a discussion about this issue being related to the backend. Or am I mistaken? |
yes @NethmiRodrigo the issue was backend could not pickup timezone |
|
@NethmiRodrigo @Muppasanipraneeth @denniskigen I'd like to clarify the approach I've taken in this PR. My Solution is Timezone-Independent:
Benefits of this approach:
Question: Is this timezone-independent frontend approach the correct way to resolve O3-4970, or would you prefer a different strategy that involves backend timezone handling changes? I believe this solution addresses the root cause while being the most robust approach, but I'm happy to adjust if there's a preferred architectural direction. |
|
Hi @ibacher, just checking if you’ve had a chance to review this PR. Thanks! |
- Add toDateOnlyString() utility function with robust error handling - Update immunization form to use timezone-safe date formatting - Replace .toISOString() with manual YYYY-MM-DD formatting - Add comprehensive unit tests for date utility (11 test cases) - Add regression test for O3-4970 in immunization form tests - Ensure FHIR compliance for Immunization.expirationDate field - Fix date shift bug where 31/12/2025 was saved as 30/12/2025 Fixes: https://openmrs.atlassian.net/browse/O3-4970
…izations-form.test.tsx Co-authored-by: Ian <[email protected]>
…ility
- Remove toDateOnlyString utility and its tests
- Import dayjs and replace toDateOnlyString(...) with dayjs(...).format('YYYY-MM-DD')
- Update form tests to expect ISO-formatted strings again
- Ensure existing tests pass without the custom utility
Co-authored-by: Nethmi Rodrigo <[email protected]>
Add test coverage to verify expiration dates are sent as YYYY-MM-DD date-only strings to prevent timezone conversion bugs.
Addressed in subsequent commits.
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.
Thanks, @UjjawalPrabhat! LGTM.
…#2779) * O3-4970: Use date-only format for immunization expiration dates - Add toDateOnlyString() utility function with robust error handling - Update immunization form to use timezone-safe date formatting - Replace .toISOString() with manual YYYY-MM-DD formatting - Add comprehensive unit tests for date utility (11 test cases) - Add regression test for O3-4970 in immunization form tests - Ensure FHIR compliance for Immunization.expirationDate field - Fix date shift bug where 31/12/2025 was saved as 30/12/2025 Fixes: https://openmrs.atlassian.net/browse/O3-4970 * Update packages/esm-patient-immunizations-app/src/immunizations/immunizations-form.test.tsx Co-authored-by: Ian <[email protected]> * fix(O3-4970): use dayjs for date-only formatting and remove custom utility - Remove toDateOnlyString utility and its tests - Import dayjs and replace toDateOnlyString(...) with dayjs(...).format('YYYY-MM-DD') - Update form tests to expect ISO-formatted strings again - Ensure existing tests pass without the custom utility * Update packages/esm-patient-immunizations-app/src/immunizations/utils.ts Co-authored-by: Nethmi Rodrigo <[email protected]> * Add expiration date format tests Add test coverage to verify expiration dates are sent as YYYY-MM-DD date-only strings to prevent timezone conversion bugs.
Requirements
Summary
This PR fixes the issue where the immunization expiration date field was being saved with a one-day shift due to ISO-UTC conversion.
Screen Recording:
Recording.2025-10-09.132330.mp4
Related Issue
https://openmrs.atlassian.net/browse/O3-4970
Other