Skip to content

Instantly share code, notes, and snippets.

@tsialas
Last active December 17, 2020 11:54
Show Gist options
  • Save tsialas/5f0081e21fc77ce20a08b26d865d4c60 to your computer and use it in GitHub Desktop.
Save tsialas/5f0081e21fc77ce20a08b26d865d4c60 to your computer and use it in GitHub Desktop.

Requirement

As a doctor, I want to be able to reschedule an appointment for any given datetime. We always assume that the doc has already confirmed the new appointment time with their patient. Current restrictions not allowing free rescheduling should be bypassed as elegantly as possible. Execution starts @ ConsultationController->postReschedule()

Solution

After reviewing the business requirements of the "rescheduling by doctor" case, it's evident that it's indeed a special case with lots of differences in the handling logic (compared to a simple booking or patient rescheduling). This justifies some basic code refactoring to avoid adding code complexity or duplication.

Key Points

  1. Skip call to isBookingDatetimeWithinAllowedThreshold() to ignore the currently enforced minimum threshold of [now + 24 hours] on bookings/reschedulings.

  2. Skip call to ConsultationAvailability::hasAvailableSlot(). It doesn't matter if the rescheduled datetime falls within a predefined availability slot. All we care about is avoiding conflicts with existing bookings via the hasActiveBooking() method.

  3. ConsultationAvailability::markAsBooked() includes code which will produce an exception if the rescheduled time does not match an availability slot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment