How to make a time slot

0
Hello, for my booking app I want to make 1 hour time slots which are connected to the availability of a doctor.   Right now a doctor can fill in his availability with start and end time for every day, but my goal is that when  someone makes an appointment they can only book between those hours and that they can't double book a slot.   Any help would be appreciated  
asked
2 answers
0

This is a simplified solution. But with the following entities and logic you would get pretty far...

  • Doctor (or physician/arts)
    • Name
    • ...
  • DoctorAvailability
    • Day (enum day of week)
    • Start time
    • End time
    • Association to Doctor
  • Timeslots
    • Day
    • StartTime
    • EndTime
    • Status (available, reserved, confirmed, blocked)
    • Association to Doctor

For each Doctor you create 1 or multiple availability objects (e.g. for each day 1 from 08:00 till 17:00 or multiple per day like monday 08:00 – 11:00 and monday 15:00 – 18:00)

Generate each week the next set of time slots (e.g. schedule gets created on each monday for the week after...this is totally up to you.). You can use a scheduled event for this or a manual action that triggers it.

Retrieve each Doctor, iterate through this list, retrieve each DoctorAvailability, iterate through this list generate create for each hour the doctor is available timeslot (link the timeslots to the doctor).
The Timeslots are available for booking, if someone is in the process of booking you can temporary reserve this timeslot (if the booking is complete set it to completed for example), if the timeslot needs to be blocked for something else you can use the status blocked). If you really want to make sure no one else can (in case of concurrency) reserve the same timeslot look at the marketplace and look for a Locking  module)

answered
0

Hi Niek, I am in the middle of creating a very similar booking app myself. Let’s join forces and build something great. If you are interested, let me know and I will invite you to my project. Regards, Tim

answered