DEV Community

Cover image for Building a healthcare appointment system
wathika
wathika

Posted on

Building a healthcare appointment system

:

πŸ₯ HealthCare Appointment System
A full-stack clinic booking system that allows patients to schedule appointments with doctors, and enables doctors to manage their availability and appointments. Designed for small to medium-sized clinics seeking to digitize and streamline operations.

πŸš€ Tech Stack
Backend: Python 3.12, Django + Django REST Framework (DRF)

Database: PostgreSQL

API Testing: Postman

Version Control: Git + GitHub

Frontend: React

Deployment:

Backend: render.com

Frontend: vercel.com

πŸ‘₯ 1. User Registration and Roles
Users can register as one of the following:

Patient

Doctor

Admin (limited to only 2 per clinic)

All newly registered users are set to inactive by default. They must be activated by an admin for security purposes.

National ID is the primary login credential and also used to uniquely identify users in the system.

Upon activation:

A PatientProfile, DoctorProfile, or AdminProfile is automatically created based on the selected role.

        {
            "email": "Margarita11@gmail.com",
            "full_name": "Ruben Hoppe Iv",
            "national_id": "858523627",
            "phone_number": "2547858523627",
            "role": "patient",
            "profile_pic": "https://shorturl.at/cA9tj",
            "doctor_profile": null,
            "patient_profile": {
                "user": 14,
                "age": 23,
                "medical_history": ""
            }
        }
Enter fullscreen mode Exit fullscreen mode

πŸ” 2. Authentication & Access Control
JWT authentication is implemented using SimpleJWT.

The access token is valid for 1 hour, and the refresh token lasts 1 day.

The token payload includes:

email
role
exp (expiry)
Enter fullscreen mode Exit fullscreen mode

You can access the user's role directly via: request.user.role

Role-based permissions:

Doctors: Can update availability, view/cancel appointments, and view all patients.

Patients: Can schedule, view, and cancel appointments. Also able to browse all doctors for booking.

Admins: Can activate/deactivate users and manage system settings.

πŸ“† 3. Appointment Booking
Patients can book appointments using a selected doctor, date (calendar input), and time (24-hour format).
The system performs several checks before confirming:

Is the doctor available?

Is the appointment time in the future?

If both are valid, an appointment is created with the status scheduled.

βš™οΈ 4. Doctor Availability
Doctors can toggle their availability status (True/False).

Patients can only book appointments with available doctors.

If a doctor is marked as unavailable, they will not receive new bookings.

πŸ“‹ 5. Appointment Management
πŸ§‘ Patient Actions:
View upcoming and past appointments.

Cancel appointments before the scheduled time.

πŸ‘¨β€βš•οΈ Doctor Actions:
View all appointments where they are assigned.

Mark appointments as completed when done.

Example appointment response:

{
  "success": true,
  "message": "",
  "data": [
    {
      "id": 1,
      "appointment_date": "2025-08-23",
      "appointment_time": "08:00:00",
      "status": "scheduled",
      "created_at": "2025-07-28T17:26:29.745662+03:00",
      "patient": 1,
      "doctor": 1
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

πŸ§‘β€πŸ’Ό 6. Admin Controls
The system allows only one or two admins (enforced via the AdminProfile model).

Admins can:

Activate or deactivate user accounts.

Manage clinic-wide settings (e.g., appointing doctors, enforcing limits).

View system activity logs (future enhancement).

πŸ”’ 7. Security & Validation
DRF permissions restrict access based on user roles.

Key validations include:

Preventing bookings in the past.

Ensuring doctor availability before assigning appointments.

Enforcing unique constraints on National ID, email, and phone number.

πŸ“¦ Links
πŸ§‘β€πŸ’» GitHub: github.com/Boonerd/healthcare-appointment-system
Postman testing: https://www.postman.com/wathika/workspace/healthcare-system-appointment/collection/34083824-b0f81078-d6c9-4172-a254-106883c2c60b?action=share&creator=34083824

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.