This is a simplified solution. But with the following entities and logic you would get pretty far...
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)
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