I need help thinking through the logic and how optimize scheduling which allowing 1 provider to see customers in 2 different chairs with overlapping start/end times. The challenge is that a provider may only be required for a portion of a given appointment.
Resources: 2 Chairs, 1 Provider
In the example below, we have 4 appointments. The Customer (CUST #) will occupy the chair for the duration of the appointment; however, provider is only occupied for for a portion of the time. The (X) denotes the 15 minute increments the provider is needed and otherwise unavailable and the (/) denotes 15 minute increments the provider is not needed and is available to see other customers.
Now, let’s say I’m a user looking to book a 60 minute appointment in which we only need the provider for the third 15 minute increment (pattern of (/)(/)(X)(/)). We know we need a chair that’s available for 60 minutes. However, the challenge I’m finding is ensuring the provider is available during that 15 minute increment in which they are needed. See below for a visual break down. I can’t seem to wrap my mind around the logic required.
APPOINTMENT TO BOOK: 60 Minutes where the provider is needed for a 15 minute portion as denoted by the (X) in the following pattern: (/)(/)(X)(/)
Expected availability based on current schedule:
- 10:30AM-11:30AM
- 11:15AM-12:15PM
- 11:30AM-12:30PM
CURRENT SCHEDULE:
Chair 1 | Chair 2 |
---|---|
CUST 1 (/) | CUST 2 (X) |
CUST 1 (/) | CUST 2 (X) |
CUST 1 (X) | CUST 2 (/) |
CUST 1 (/) | OPEN |
CUST 1 (/) | OPEN |
CUST 1 (/) | OPEN |
OPEN | CUST 3 (/) |
OPEN | CUST 3 (X) |
OPEN | CUST 3 (/) |
OPEN | OPEN |
CUST 4 (/) | OPEN |
CUST 4 (/) | OPEN |
CUST 4 (/) | OPEN |
CUST 4 (/) | OPEN |
CUST 4 (X) | OPEN |
CUST 4 (/) | LUNCH BLOCK |
OPEN | LUNCH BLOCK |
OPEN | OPEN |
INPUTS:
- List of existing scheduled appointment objects which include the appointment start time, chair, and pattern as I’ve defined above.
- List of provider schedule objects which is their working hours for a chair or chairs.
- List of blockout objects for lunch, breaks, etc. for a chair or chairs.
- Appointment to be scheduled. An object with a pattern as defined above.
If it matters, I’m using Javascript with moment.js.