Skip to content

(Fix)Inconsistent Appointment Dates between Calendar and List View(03-5338 )#2190

Open
bhavya-jpg wants to merge 1 commit intoopenmrs:mainfrom
bhavya-jpg:fix/appointment-date-discrepancy
Open

(Fix)Inconsistent Appointment Dates between Calendar and List View(03-5338 )#2190
bhavya-jpg wants to merge 1 commit intoopenmrs:mainfrom
bhavya-jpg:fix/appointment-date-discrepancy

Conversation

@bhavya-jpg
Copy link

@bhavya-jpg bhavya-jpg commented Jan 11, 2026

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. O3-5338

Summary

This PR addresses a bug where appointments were appearing on inconsistent dates when comparing the Appointments Calendar (Monthly View) and the Appointments List (Daily View).

Problem:
The Calendar View relied on the /appointment/appointmentSummary endpoint, which aggregates counts based on UTC dates on the backend. However, the List View renders appointments in the user's local timezone. This caused visual discrepancies (e.g., an appointment at 11 PM UTC would show on "Jan 15" in the Calendar but "Jan 16" in the List for users in IST).

Solution:
Refactored the [useAppointmentsCalendar] in openmrs-esm-patient-management/packages/esm-appointments-app/src/hooks/useAppointmentsCalendar.ts:6:0-65:2) hook to:

  1. Fetch raw appointment data using the /appointments/search endpoint (matching the List view's data source).
  2. Aggregate appointments on the client-side using dayjs to respect the user's local timezone.
  3. Ensure that if an appointment appears on a specific date in the list, it is counted for that same date in the calendar.

Screenshots

Screenshot 2026-01-11 at 11 27 43 PM Screenshot 2026-01-11 at 11 27 29 PM

Related Issue##

https://openmrs.atlassian.net/browse/O3-5338

Other

  • Code changes were verified to be type-safe.
  • No backend changes were required.

@gitcliff
Copy link
Contributor

@bhavya-jpg could kindly look into the e2e test failure ?

@bhavya-jpg
Copy link
Author

hi @gitcliff

I investigated the E2E test failures in
e2e/specs/appointments.spec.ts
(specifically "Add, edit and cancel an appointment") and confirmed they are unrelated to my changes.

Isolation: My changes are strictly limited to useAppointmentsCalendar.ts, which is only used in the Calendar View. The failing test exercises the List View and Add/Edit forms, which use entirely different hooks (useAppointmentList) and do not invoke my modified code.
Cause: The failure is a timeout (Timed out 60000ms waiting for expect(locator).toBeVisible()) when waiting for the "Add Appointment" modal to open, which appears to be a known flake or environmental latency issue.
Verification: The @openmrs/esm-appointments-app package builds successfully, and type checks pass.
I verified locally that the Calendar View behaves correctly with my fix.

can you please help me out in this

@ELVIS-KATO
Copy link
Contributor

Hey @bhavya-jpg! 😊
Thanks for the PR. Could you please make sure it follows the OpenMRS conventional style for pull requests? You can refer to this guide
for details, and it might also help to check out a few PRs from other contributors. Otherwise thanks!

@bhavya-jpg
Copy link
Author

@ELVIS-KATO surely I will make the changes in the pr msg ,as per the conventional style of OpenMRS ,in the mean time can you please help me out with this E2E test error ,I am not able to figure out whats causing that actually .

thank you

@ELVIS-KATO
Copy link
Contributor

From what I can see, the failing tests are all related to ward e2e scenarios, which are unrelated to the calendar changes you’ve worked on. These tests are known to be flaky at times, and addressing them is typically handled by the maintainers. Please don’t worry about these failures — they’re not caused by your changes. Your focus on the calendar ticket is exactly what’s needed here.

@bhavya-jpg
Copy link
Author

bhavya-jpg commented Jan 29, 2026

@ELVIS-KATO thank you so much for the heads up about the E2E failure ,I am really relieved now ,I was really trying to figure out what was going wrong,and I have updated the pr also ,I think there wasnt any issue with the pr message itself as it follows the standard conventional template of PR message for OPENMRS ,I've changed the name of the pr to the jira issue ,as it was written in the PR conventions

@bhavya-jpg bhavya-jpg changed the title fixed the appointment date discrepancy in the appointements app (03-5338 )Inconsistent Appointment Dates between Calendar and List View Jan 29, 2026
@ELVIS-KATO
Copy link
Contributor

@bhavya-jpg Appreciate the update. One small thing—it would be great if the PR title started with a conventional prefix such as fix, feat, etc., based on the nature of the change. Everything else looks good, thanks!

@bhavya-jpg bhavya-jpg changed the title (03-5338 )Inconsistent Appointment Dates between Calendar and List View (Fix)Inconsistent Appointment Dates between Calendar and List View(03-5338 ) Jan 29, 2026
@bhavya-jpg
Copy link
Author

@ELVIS-KATO hey ,thanks for the review man ,i have made the change that you asked for hopefully everything looks good now

@ELVIS-KATO
Copy link
Contributor

@denniskigen, help me checkout this PR

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