Skip to content

Shivam-Shukl/Hospital-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ Hospital Management System (HMS)

A comprehensive, production-ready web application for managing hospital operations, patient care, appointments, and medical records with role-based access control.

Live Demo: https://hms-etvm.onrender.com/


✨ Features

πŸ‘¨β€βš•οΈ Admin Panel

  • πŸ“Š Dashboard with real-time statistics
  • πŸ‘₯ Complete doctor management (Add, Edit, Delete)
  • πŸ‘€ Patient management and oversight
  • πŸ“… View all appointments across the hospital
  • πŸ” Advanced search functionality

πŸ‘¨β€βš•οΈ Doctor Portal

  • πŸ“‹ Personal dashboard with today's appointments
  • πŸ‘₯ Assigned patients list
  • πŸ“… Appointment management
  • πŸ“ Record treatment and medical notes
  • πŸ“Š Access patient medical history

πŸ‘¨β€πŸ’Ό Patient Portal

  • πŸ” Search doctors by specialization
  • πŸ“… Book appointments with available doctors
  • πŸ“‹ View appointment history
  • πŸ“ Access personal medical records
  • βš™οΈ Edit personal profile

πŸ” Security & Access Control

  • Secure password hashing (Werkzeug)
  • CSRF protection on all forms
  • Role-based access control (Admin, Doctor, Patient)
  • Session-based authentication (Flask-Login)
  • SQL injection prevention (SQLAlchemy ORM)

πŸ› οΈ Tech Stack

Backend

  • Framework: Flask 2.3.0
  • Database: SQLite (Dev) / PostgreSQL (Production)
  • ORM: SQLAlchemy 3.0.5
  • Authentication: Flask-Login 0.6.2
  • Forms: WTForms 3.0.1 with Flask-WTF
  • Server: Gunicorn 20.1.0

Frontend

  • HTML5 & Jinja2 Templates
  • CSS: Bootstrap 5.3.0
  • Icons: Font Awesome 6.4.0
  • Responsive Design with Mobile-first approach

Deployment

  • Platform: Render
  • Database: PostgreSQL on Render
  • Environment: Python 3.x

πŸ“ Project Structure

hospital-management-system/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ app_init.py              # Flask initialization & config
β”‚   β”œβ”€β”€ app_models.py            # Database models (6 models)
β”‚   β”œβ”€β”€ app_forms.py             # Form validation (7 forms)
β”‚   β”œβ”€β”€ app_routes.py            # All routes (50+ endpoints)
β”‚   β”œβ”€β”€ templates/               # HTML templates (17 files)
β”‚   β”‚   β”œβ”€β”€ base.html
β”‚   β”‚   β”œβ”€β”€ landing_page.html
β”‚   β”‚   β”œβ”€β”€ admin/               # Admin templates
β”‚   β”‚   β”œβ”€β”€ doctor/              # Doctor templates
β”‚   β”‚   └── patient/             # Patient templates
β”‚   └── static/
β”‚       β”œβ”€β”€ css/style.css
β”‚       β”œβ”€β”€ js/script.js
β”‚       └── images/
β”œβ”€β”€ app.py                       # Main entry point
β”œβ”€β”€ requirements.txt             # Python dependencies
β”œβ”€β”€ Procfile                     # Render deployment config
β”œβ”€β”€ .env.example                 # Environment variables template
β”œβ”€β”€ .gitignore
└── README.md                    # This file

πŸ—„οΈ Database Models

User (Base Authentication)

  • Email, Password (hashed), Name, Role (admin/doctor/patient)

Doctor

  • User reference, Specialization, Appointments list

Patient

  • User reference, Medical history, Appointments & Treatments

Appointment

  • Patient, Doctor, Date, Time, Reason, Status (Booked/Completed/Cancelled)

Treatment

  • Appointment, Diagnosis, Prescription, Medical notes

Department

  • Department names and descriptions

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • pip
  • Virtual environment (recommended)

Installation

  1. Clone the repository
git clone https://github.com/yourusername/hospital-management-system.git
cd hospital-management-system
  1. Create virtual environment
python -m venv venv

# Activate (Windows)
venv\Scripts\activate

# Activate (macOS/Linux)
source venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt
  1. Create .env file
cp .env.example .env
  1. Edit .env with your settings
SECRET_KEY=your-very-secure-random-key-here
FLASK_ENV=development
DATABASE_URL=sqlite:///hms.db
  1. Run the application
python app.py
  1. Access the application
http://localhost:5000

πŸ“ Test Credentials

Admin Account

Doctor Account

  • Email: doctor@hms.com
  • Password: doctor123
  • Specialization: Cardiology

Patient Account


πŸ”„ User Workflows

Patient Booking Appointment

  1. Register or Login
  2. Go to Search Doctors
  3. Filter by specialization
  4. Click "Book Appointment"
  5. Select date and time
  6. Submit booking
  7. View in "My Appointments"

Doctor Recording Treatment

  1. Login as Doctor
  2. View appointments in dashboard
  3. Click appointment to complete
  4. Fill diagnosis, prescription, notes
  5. Submit treatment
  6. Status updates to "Completed"

Admin Managing System

  1. Login as Admin
  2. View dashboard statistics
  3. Add new doctors (Admin Panel)
  4. Delete patients if needed
  5. Search for specific users
  6. Monitor all appointments

πŸ“Š Key Routes

Authentication

GET/POST  /              β†’ Landing page
GET/POST  /login         β†’ Login
GET/POST  /register      β†’ Patient registration
GET       /logout        β†’ Logout

Admin Dashboard

GET       /admin/dashboard       β†’ Statistics
GET       /admin/doctors         β†’ Doctor list
GET/POST  /admin/doctor/add      β†’ Add doctor
GET       /admin/patients        β†’ Patient list
GET       /admin/appointments    β†’ All appointments
GET/POST  /admin/search          β†’ Search

Doctor Dashboard

GET       /doctor/dashboard                β†’ Overview
GET       /doctor/appointments             β†’ My appointments
GET/POST  /doctor/appointment/<id>/complete→ Complete appointment
GET       /doctor/patients                 β†’ My patients
GET       /doctor/patient/<id>/history     β†’ Patient history

Patient Dashboard

GET       /patient/dashboard           β†’ Overview
GET/POST  /patient/search-doctors      β†’ Search doctors
GET/POST  /patient/book-appointment    β†’ Book appointment
GET       /patient/appointments        β†’ My appointments
GET       /patient/medical-history     β†’ Medical records
GET/POST  /patient/profile/edit        β†’ Edit profile

🌐 Deployment on Render

Step-by-Step Deployment Guide

  1. Push to GitHub
git add .
git commit -m "Ready for deployment"
git push origin main
  1. Create Render Account

  2. Create PostgreSQL Database

    • Click "New +" β†’ "PostgreSQL"
    • Choose free tier
    • Copy connection string
  3. Create Web Service

    • Click "New +" β†’ "Web Service"
    • Select your GitHub repository
    • Configure:
      • Build Command: pip install -r requirements.txt
      • Start Command: gunicorn app:app
  4. Add Environment Variables

    • SECRET_KEY: Generate using python -c "import secrets; print(secrets.token_hex(32))"
    • DATABASE_URL: Paste PostgreSQL connection string
    • FLASK_ENV: production
  5. Deploy

    • Click "Deploy"
    • Monitor logs for errors
    • Access your live app!

πŸ” Security Features

βœ… Password Security: Werkzeug hashing with salt
βœ… CSRF Protection: Flask-WTF tokens on all forms
βœ… Session Management: Secure Flask-Login sessions
βœ… Role-Based Access: Route decorators for authorization
βœ… SQL Injection Prevention: SQLAlchemy parameterized queries
βœ… Input Validation: WTForms validators
βœ… HTTPS Ready: For production deployment


🎨 UI/UX Features

  • πŸ“± Fully Responsive: Mobile, tablet, desktop
  • 🎯 Intuitive Navigation: Role-based menu
  • ✨ Modern Design: Bootstrap 5 + custom CSS
  • πŸš€ Smooth Animations: Page transitions
  • πŸŒ™ Dark Mode Support: Eye-friendly interface
  • β™Ώ Accessible: WCAG compliant

πŸ“¦ Dependencies

Flask==2.3.0                    # Web framework
Flask-SQLAlchemy==3.0.5        # ORM
Flask-Login==0.6.2             # Authentication
Flask-WTF==1.1.1               # CSRF protection
WTForms==3.0.1                 # Form handling
python-dotenv==1.0.0           # Environment variables
gunicorn==20.1.0               # Production server
psycopg2-binary==2.9.6         # PostgreSQL driver

See requirements.txt for complete list.


πŸ› Troubleshooting

Login Issues

  • Check email/password in database
  • Verify SECRET_KEY is set
  • Clear browser cookies

Database Errors

  • Verify DATABASE_URL format
  • Check PostgreSQL is running
  • Run migrations if needed

404 Routes

  • Check route definitions in app_routes.py
  • Verify templates exist in correct folders
  • Restart Flask server

Static Files Not Loading

  • Check static/ folder structure
  • Verify CSS/JS file paths
  • Clear browser cache

πŸ‘₯ Role Permissions Matrix

Feature Admin Doctor Patient
View Dashboard βœ… βœ… βœ…
Manage Doctors βœ… ❌ ❌
Manage Patients βœ… ❌ ❌
Book Appointment ❌ ❌ βœ…
Complete Appointment ❌ βœ… ❌
View All Appointments βœ… ❌ ❌
View Medical Records βœ… βœ… βœ…
Record Treatment ❌ βœ… ❌
Search Users βœ… ❌ ❌

πŸ“ˆ Project Statistics

  • Total Python Files: 5 core files
  • HTML Templates: 17 files
  • API Routes: 50+ endpoints
  • Database Models: 6 models
  • Form Classes: 7 forms
  • Security Layers: 6 implementations
  • Lines of Code: 3000+

πŸ”„ Git Workflow

# Clone repository
git clone https://github.com/yourusername/hospital-management-system.git

# Create feature branch
git checkout -b feature/your-feature-name

# Make changes and commit
git add .
git commit -m "Add feature description"

# Push to GitHub
git push origin feature/your-feature-name

# Create Pull Request on GitHub

🚧 Future Enhancements

  • Email notifications for appointments
  • SMS reminders
  • Prescription delivery integration
  • Video consultation support
  • Advanced analytics & reporting
  • Mobile app (React Native)
  • AI-powered appointment suggestions
  • Payment gateway integration
  • Multi-language support
  • Two-factor authentication

πŸ‘¨β€πŸ’» Authors

  • Developer: Shivam Shukla
  • Idea: Shivansh Shukla

πŸ™ Acknowledgments

  • Flask community for excellent documentation
  • Bootstrap for responsive design framework
  • Font Awesome for beautiful icons
  • Render for hosting platform

🌟 Star This Project

If you find this project useful, please give it a ⭐ on GitHub!


Made with ❀️ for better hospital management

About

Flask-based hospital management system with appointments, treatments, and secure authentication system.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors