Skip to content

Add service availability configuration with weekly scheduling#2145

Open
gabriel090 wants to merge 5 commits intoopenmrs:mainfrom
gabriel090:KHP3-8729
Open

Add service availability configuration with weekly scheduling#2145
gabriel090 wants to merge 5 commits intoopenmrs:mainfrom
gabriel090:KHP3-8729

Conversation

@gabriel090
Copy link
Contributor

@gabriel090 gabriel090 commented Dec 3, 2025

Requirements

  • This PR has a title that briefly describes the work done, including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work is based on designs, which are linked or shown either in the Jira ticket or the description below.
  • My work includes tests or is validated by existing tests.

Summary

Add a new "Configure Service Availability" feature that allows administrators
to set maximum appointment limits at both the service-level and per-day level through
weekly schedules.
Features Added:

  • Global maximum appointment limit for all days
  • Weekly availability toggle with day-specific configuration
  • Per-day maximum limits (overrides global limit)
  • Per-day time ranges (start/end times)
  • Days not selected are blocked for appointments

1. Set up for Maximum Limit for All Days

Purpose: Set a default maximum appointment limit that applies to all days of the week for a service.
How to Use:

  1. Open "Configure Service Availability" workspace
  2. Select a service from the dropdown
  3. Enter a number in the "Max Appointments Limit" field
  4. If weekly availability is NOT enabled, this limit applies to all days
    Behavior:
  • The limit is stored in the maxAppointmentsLimit field of the appointment service
  • Applies uniformly across all days unless weekly availability overrides it
  • Leave empty for unlimited appointments
  • Accepts only positive integers
daily_setup.mp4

2. Booking When Maximum Limit is Reached

Current Behavior:

  • The system currently does not validate against the maximum limit when booking appointments
  • The maxAppointmentsLimit field is configured and saved, but not enforced during booking

Expected Behavior (To Be Implemented):
When a user attempts to book an appointment:

  1. The system should check the current appointment count for that service/day
  2. Compare against the configured maxAppointmentsLimit.
  3. If the limit is reached:
    • Display alert: "Maximum appointment limit reached for [Service Name] on [Date]."
    • Prevent booking
    • Suggest alternative dates/times
daily_booking.mp4

3. Weekly Setup for a Service

Purpose: Configure different availability schedules and limits for each day of the week.

How to Enable:

  1. Select a service
  2. Toggle "Enable weekly availability?" to Yes
  3. Day selection checkboxes appear for all days of the week

Selecting Days:

Step 1: Check desired days

  • Check any combination of days (Monday through Sunday)
  • Multiple days can be selected
    Day-Specific Maximum Limits:
  • Each day can have its own maxAppointmentsLimit.
  • Overrides the global service limit for that specific day
  • Leave empty for unlimited appointments on that day
weekly_setup.mp4

4. How It Works When the Max Limit for a Specific Day is Reached

Current Implementation:

  • The limit is saved in the database
  • Backend stores the configuration in the weeklyAvailability array
weekly_booking1.mp4

Screenshots

Related Issue

Other

@makombe makombe requested review from brandones, chibongho, denniskigen, donaldkibet and makombe and removed request for denniskigen December 4, 2025 09:26
@makombe
Copy link
Contributor

makombe commented Dec 5, 2025

@gabriel090 Please add a ticket in the openmrs Jira for tracking purposes and future reference. Thanks

1 similar comment
@makombe
Copy link
Contributor

makombe commented Dec 5, 2025

@gabriel090 Please add a ticket in the openmrs Jira for tracking purposes and future reference. Thanks

@EDSONZ-WASSWA
Copy link
Contributor

please resolve the conflict in your PR code

@chibongho
Copy link
Contributor

please resolve the conflict in your PR code

Specifically, we recently migrated to use Workspace V2. @gabriel090 Please refer to the migration guide on what needs to be changed.

@chibongho
Copy link
Contributor

@gabriel090 Please add a ticket in the openmrs Jira for tracking purposes and future reference. Thanks

I second this. Looks like the backend actually supports the feature you're working on. That said, we have not implemented this on the frontend because we haven't needed it. Has that changed? If so, a JIRA to document the requirements would be good.

Copy link
Contributor

@chibongho chibongho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a thorough review; just some initial comments.

@gabriel090
Copy link
Contributor Author

please resolve the conflict in your PR code

Specifically, we recently migrated to use Workspace V2. @gabriel090 Please refer to the migration guide on what needs to be changed.

Thanks for the feedback! I've migrated the service availability form to use Workspace v2 architecture. The changes include:

  1. Updated routes. json with the new workspaces2, workspaceWindows2, and workspaceGroups2 structure following the proper hierarchy (appointments group → service-availability-form-window → service-availability-form-workspace)
  2. Modified the component to use Workspace2DefinitionProps and wrapped the form in the component
  3. Changed the launch call from launchWorkspace to launchWorkspace2

@gabriel090
Copy link
Contributor Author

I second this. Looks like the backend actually supports the feature you're working on. That said, we have not implemented this on the frontend because we haven't needed it. Has that changed? If so, a JIRA to document the requirements would be good.

Yes, the requirements have changed. This feature is now needed to manage appointment capacity and prevent overbooking at our facilities.
Key requirements:

  1. Global appointment limits: Set a maximum number of appointments allowed per day across all days of the week
  2. Weekly availability configuration: Enable/disable specific days of the week for appointments
  3. Day-specific limits: Override the global limit for individual days (e.g., fewer appointments on Fridays)
  4. Day-specific time ranges: Configure different operating hours for each day

- Migrated service availability form to Workspace v2 architecture
- Removed inline styles (opacity) in favor of CSS classes
- Optimized tests: removed clearAllMocks, replaced waitFor with findBy
- Removed comments and unused code from SCSS and TypeScript files
@brandones
Copy link
Contributor

I second this. Looks like the backend actually supports the feature you're working on. That said, we have not implemented this on the frontend because we haven't needed it. Has that changed? If so, a JIRA to document the requirements would be good.

Yes, the requirements have changed. This feature is now needed to manage appointment capacity and prevent overbooking at our facilities. Key requirements:

  1. Global appointment limits: Set a maximum number of appointments allowed per day across all days of the week
  2. Weekly availability configuration: Enable/disable specific days of the week for appointments
  3. Day-specific limits: Override the global limit for individual days (e.g., fewer appointments on Fridays)
  4. Day-specific time ranges: Configure different operating hours for each day

Great! Please file a ticket in Jira.

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.

6 participants