Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Hospital Management System

A full-stack Hospital Management System (HMS) built with Flask, SQLite, Redis, Celery, Vue 3, Vite, Bootstrap, and Axios.

This application supports three roles:

  • Admin
  • Doctor
  • Patient

It provides role-based dashboards, appointment management, patient treatment history, doctor availability, Redis caching, and Celery background jobs in a clean and easy-to-follow architecture.

Project Highlights

  • JWT-based authentication for all roles
  • Programmatic SQLite database creation
  • Auto-created admin account
  • Doctor management and patient search for admin users
  • Doctor availability management for the next 7 days
  • Appointment booking, rescheduling, and cancellation
  • Diagnosis, prescription, and treatment history tracking
  • Redis caching for doctor lists, departments, and admin dashboard statistics
  • Celery background tasks for reminders, reports, and CSV export
  • Vue 3 + Vite frontend with Bootstrap UI

Tech Stack

Backend

  • Flask
  • Flask Blueprints
  • Flask SQLAlchemy
  • Flask JWT Extended
  • SQLite
  • Redis
  • Celery

Frontend

  • Vue 3
  • Vite
  • Vue Router
  • Bootstrap
  • Axios

Roles and Features

Admin

  • View dashboard statistics
  • Add, update, and delete doctor profiles
  • Search doctors and patients
  • Manage appointments
  • Blacklist and unblacklist users

Doctor

  • View today and weekly appointments
  • Add availability for the next 7 days
  • Complete or cancel appointments
  • Add diagnosis, prescription, and notes
  • View patient history

Patient

  • Register and log in
  • View departments
  • Search doctors
  • Book, reschedule, and cancel appointments
  • View treatment history
  • Update personal profile
  • Trigger CSV export of treatment records

System Design

Backend Structure

backend/
├── app.py
├── config.py
├── extensions.py
├── models/
├── routes/
├── services/
├── tasks/
├── templates/
└── utils/

Frontend Structure

frontend/
├── index.html
├── package.json
├── vite.config.js
└── src/
    ├── components/
    ├── pages/
    ├── router/
    ├── services/
    ├── App.vue
    └── main.js

Key Design Notes

  • Jinja2 is used only to serve the initial HTML entry point
  • Vue handles the full application UI
  • SQLAlchemy models create the database programmatically
  • Service files keep business logic separate from route files
  • Role-based access is enforced using JWT and custom decorators

Caching

Redis caching is used for:

  • doctor list
  • department list
  • admin dashboard statistics

The system includes cache expiry and cache invalidation after updates.

Background Jobs

Celery + Redis are used for:

  1. Daily patient reminders
  2. Monthly doctor activity reports
  3. User-triggered CSV export of patient treatment history

Sample Accounts

These accounts are seeded automatically when the backend starts for the first time:

  • admin / admin123
  • doctor1 / doctor123
  • doctor2 / doctor123
  • patient1 / patient123

Getting Started

1. Clone the Repository

git clone https://github.com/23f2001850/hospital-management-system-v2.git
cd hospital-management-system-v2

2. Install Backend Dependencies

python -m pip install -r requirements.txt

3. Install Frontend Dependencies

cd frontend
npm install
cd ..

Redis Setup

Redis must be running on port 6379.

Option 1: If Redis is installed locally

redis-server --port 6379

Option 2: Run Redis using Docker

docker run --name hms-redis -p 6379:6379 redis:7

Option 3: Windows install examples

winget install Redis.Redis

or

choco install redis -y

Running the Project

Open separate terminals for each service.

Terminal 1: Start Redis

redis-server --port 6379

Terminal 2: Start the Flask Backend

cd "c:\Krishna_Jain\Hospital Management System"
New-Item -ItemType Directory -Force backend\runtime | Out-Null
$env:HMS_DATA_DIR = (Resolve-Path backend\runtime).Path
$env:HMS_EXPORT_DIR = (Resolve-Path backend\exports).Path
python -m backend.app

Backend runs at:

http://localhost:5000

Terminal 3: Start Celery Worker

cd "c:\Krishna_Jain\Hospital Management System"
$env:HMS_DATA_DIR = (Resolve-Path backend\runtime).Path
$env:HMS_EXPORT_DIR = (Resolve-Path backend\exports).Path
python -m celery -A backend.tasks.celery_app.celery_app worker --loglevel=info --pool=solo

Terminal 4: Start Celery Beat

cd "c:\Krishna_Jain\Hospital Management System"
$env:HMS_DATA_DIR = (Resolve-Path backend\runtime).Path
$env:HMS_EXPORT_DIR = (Resolve-Path backend\exports).Path
python -m celery -A backend.tasks.celery_app.celery_app beat --loglevel=info

Terminal 5: Start the Frontend

cd "c:\Krishna_Jain\Hospital Management System\frontend"
npm run dev

Frontend runs at:

http://localhost:5173

API Notes

  • Base URL: http://localhost:5000
  • Frontend Axios client automatically sends the JWT token in the Authorization header
  • The system uses proper role checks for admin, doctor, and patient routes

Example Login Request

POST /api/auth/login
Content-Type: application/json
{
  "username": "admin",
  "password": "admin123"
}

Example Patient Booking Request

POST /api/patient/appointments
Authorization: Bearer <token>
Content-Type: application/json
{
  "doctor_id": 1,
  "appointment_date": "2026-04-08",
  "appointment_time": "11:00",
  "reason": "Follow-up consultation"
}

Validation and Business Rules

  • Only the next 7 days are allowed for doctor availability and patient booking
  • Double booking is prevented for the same doctor, date, and time
  • Only booked appointments can be completed, cancelled, or rescheduled
  • Blacklisted users cannot access protected actions

Frontend Pages

  • Landing page
  • Login page
  • Register page
  • Admin dashboard
  • Doctor dashboard
  • Patient dashboard
  • Patient profile page
  • Appointment booking page

Verification

The project has been validated with:

  • backend role-based API smoke tests
  • appointment booking, rescheduling, and completion checks
  • CSV export task execution
  • Vite production build verification

Repository

GitHub Repository:

https://github.com/23f2001850/hospital-management-system-v2

About

A full-stack Hospital Management System (HMS) built with Flask, SQLite, Redis, Celery, Vue 3, Vite, Bootstrap, and Axios.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages