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/
- π Dashboard with real-time statistics
- π₯ Complete doctor management (Add, Edit, Delete)
- π€ Patient management and oversight
- π View all appointments across the hospital
- π Advanced search functionality
- π Personal dashboard with today's appointments
- π₯ Assigned patients list
- π Appointment management
- π Record treatment and medical notes
- π Access patient medical history
- π Search doctors by specialization
- π Book appointments with available doctors
- π View appointment history
- π Access personal medical records
- βοΈ Edit personal profile
- 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)
- 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
- HTML5 & Jinja2 Templates
- CSS: Bootstrap 5.3.0
- Icons: Font Awesome 6.4.0
- Responsive Design with Mobile-first approach
- Platform: Render
- Database: PostgreSQL on Render
- Environment: Python 3.x
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
- Email, Password (hashed), Name, Role (admin/doctor/patient)
- User reference, Specialization, Appointments list
- User reference, Medical history, Appointments & Treatments
- Patient, Doctor, Date, Time, Reason, Status (Booked/Completed/Cancelled)
- Appointment, Diagnosis, Prescription, Medical notes
- Department names and descriptions
- Python 3.8+
- pip
- Virtual environment (recommended)
- Clone the repository
git clone https://github.com/yourusername/hospital-management-system.git
cd hospital-management-system- Create virtual environment
python -m venv venv
# Activate (Windows)
venv\Scripts\activate
# Activate (macOS/Linux)
source venv/bin/activate- Install dependencies
pip install -r requirements.txt- Create .env file
cp .env.example .env- Edit .env with your settings
SECRET_KEY=your-very-secure-random-key-here
FLASK_ENV=development
DATABASE_URL=sqlite:///hms.db- Run the application
python app.py- Access the application
http://localhost:5000
- Email: admin@hms.com
- Password: admin123
- Role: Administrator
- Email: doctor@hms.com
- Password: doctor123
- Specialization: Cardiology
- Email: patient@hms.com
- Password: patient123
- Register or Login
- Go to Search Doctors
- Filter by specialization
- Click "Book Appointment"
- Select date and time
- Submit booking
- View in "My Appointments"
- Login as Doctor
- View appointments in dashboard
- Click appointment to complete
- Fill diagnosis, prescription, notes
- Submit treatment
- Status updates to "Completed"
- Login as Admin
- View dashboard statistics
- Add new doctors (Admin Panel)
- Delete patients if needed
- Search for specific users
- Monitor all appointments
GET/POST / β Landing page
GET/POST /login β Login
GET/POST /register β Patient registration
GET /logout β Logout
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
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
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
- Push to GitHub
git add .
git commit -m "Ready for deployment"
git push origin main-
Create Render Account
- Visit render.com
- Sign up with GitHub
-
Create PostgreSQL Database
- Click "New +" β "PostgreSQL"
- Choose free tier
- Copy connection string
-
Create Web Service
- Click "New +" β "Web Service"
- Select your GitHub repository
- Configure:
- Build Command:
pip install -r requirements.txt - Start Command:
gunicorn app:app
- Build Command:
-
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
- SECRET_KEY: Generate using
-
Deploy
- Click "Deploy"
- Monitor logs for errors
- Access your live app!
β
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
- π± 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
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.
- Check email/password in database
- Verify SECRET_KEY is set
- Clear browser cookies
- Verify DATABASE_URL format
- Check PostgreSQL is running
- Run migrations if needed
- Check route definitions in
app_routes.py - Verify templates exist in correct folders
- Restart Flask server
- Check
static/folder structure - Verify CSS/JS file paths
- Clear browser cache
| Feature | Admin | Doctor | Patient |
|---|---|---|---|
| View Dashboard | β | β | β |
| Manage Doctors | β | β | β |
| Manage Patients | β | β | β |
| Book Appointment | β | β | β |
| Complete Appointment | β | β | β |
| View All Appointments | β | β | β |
| View Medical Records | β | β | β |
| Record Treatment | β | β | β |
| Search Users | β | β | β |
- 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+
# 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- 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
- Developer: Shivam Shukla
- Idea: Shivansh Shukla
- Flask community for excellent documentation
- Bootstrap for responsive design framework
- Font Awesome for beautiful icons
- Render for hosting platform
If you find this project useful, please give it a β on GitHub!
Made with β€οΈ for better hospital management