Making a recurrent appointment scheduling software with django and python

Well, this is a pretty open-ended question, but I’ll try and at least get you started down the right path.

First thing you’ll need is a model to store your appointments. You mentioned a front-end that supplies some details, so I’m not sure what other system(s) you have in place, but my first thought would be to create an Appointment model that would store some patient identifier (ID #, whatever you use) and a start and end datetime for each appointment you have booked. You’ll also need to code in the bounds of your schedule - the earliest and latest times you can schedule an appointment for.

Then you need to write some logic that will handle things like identifying all open timeslots for a particular day, and seeking forward in the calendar for the next available timeslot. So if you fed the system 25-May-2020 as the preferred date, you can query the database for any appointments scheduled for that date and display all of the possible times that aren’t already booked. You’ll also need logic to handle the multiple days aspect - if you are trying to book an appointment where d = 5 days, you’ll need to look at all times available today that are also available over the next 4 days.

Stuff like this seems trivially easy at first glance, but once you get into the weeds you can see how it can get pretty tricky.

I would Google “conference room scheduling algorithms” - there are a lot of examples of algos that deal with comparing calendars and finding free times/conflicts as this is a common question for programming courses/interview prep.You might find this video interesting - it’s a former Google engineer doing a mock interview with a college student and they use a calendar algorithm as the problem to work through. You can see some of the thought process and logic involved in working with blocks of time: https://youtu.be/3Q_oYDQ2whs

As a new programmer, this is a pretty complex case to muscle through (and, if I’m being honest, you’d probably be better off designing how you want the system to work and passing that off to a freelancer to code it for you) – but I don’t want to discourage you, and kudos to trying to learn how to do this on your own.

Working with dates is not trivial, and depending on how robust you want to make the system, you might also have to work around holidays, vacation days, cancellations, rescheduling, etc…

If you want some more specific advice, post what you’ve tried and where you’re getting stuck. Are you still in the planning phase? Are you halfway through building the thing and are having a specific problem?

Hope that helps a little bit at least…

-Jim

1 Like