[Django]-How to best create connections for a booking app?

1👍

I can throw in some ideas.

Models

I think you are on the right track. You just need to associate models Doctor, Secretary and Patient to the User model. I would recommend you to create a custom user model inherited from AbstractUser.
In this model, you can either add a choice field with choices for each type of user. link to docs

Also, you need to link the user model with the correct model.

  1. One way to do is to have a OneToOneField for the user model in all your user type models: Doctor, Secretary, Patient
  2. Or you can explore generic relations. It will further streamline things for you. link to docs.

Signup

You can provide a field for users to select at the time of signup, or provide separate links to signup and handle things at the backend. Something like If you are a doctor, click here to signup. In both cases, you’ll need to override the signup process.

So a signup link can look like: /signup/doctor/ or /signup/patient/. All signup will be using the same view, just different url kwargs. link to docs

You can just create rows on the relevant model for user type on form success.

Booking

Yes, you need to create a separate model, and you can store all your bookings in this model. Doesn’t matter how many users use your app. Just use a good database solution, like Postgres. There are ways to optimize your queries, like indexing, don’t worry about it for now. Just make sure to save all references like, patient, doctor, created, last modified, created by which user, from_datetime, to_datetime, etc.

It would be better to handle the 20 min appointment blocks in forms.py.
You can create a list of acceptable time blocks, so that if in future you want to change this time to say 30 min, its easily doable. Just handle all validations at the form level and it should do the trick.

2👍

First of all, I’m a django noob, so please read the following with that it mind.

Looks pretty good – the only thing I see missing is how you link patients to clinics and or doctors.

The other thing I notice is how doctors can have multiple clinics. I assume each clinic has its own calender, rather the doctor itself? Or maybe both? i.e. Even if a doctor was available on his calendar, he might not have a room at the clinic for the patient as other doctors’ calenders would clash with it.

Personally, I wouldn’t create a new app for clinic unless you want to model it in far more detail. Keep it simple initially.

Also, if you’re allowing doctors, secretaries, and patients to login to your site, it might be better to have consumer/provider class model descending from custom user. ideas…

I would start thinking about the problem in more abstract terms. Service/provider/consumer.

But, I think you’re on the right track.

Leave a comment