Skip to content

Latest commit

ย 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Hospital Management System (HMS)

A comprehensive Hospital Management System built with Django REST Framework (Backend) and React + Vite (Frontend). This system enables patients to book appointments with doctors and allows doctors to manage their availability and appointments.

๐Ÿš€ Features

For Patients

  • User registration and authentication
  • Browse available doctors by specialization
  • View doctor profiles and availability slots
  • Book appointments with doctors
  • View appointment history

For Doctors

  • Dedicated doctor registration
  • Create and manage professional profile
  • Set availability slots (date, time, status)
  • View and manage appointments
  • Update profile information

General Features

  • Role-based authentication (Patient/Doctor)
  • Secure session-based authentication
  • Responsive UI with modern design
  • RESTful API architecture
  • PostgreSQL database

๐Ÿ› ๏ธ Technology Stack

Backend

  • Django 6.0 - Web framework
  • Django REST Framework - API development
  • PostgreSQL - Database
  • CORS Headers - Cross-origin resource sharing

Frontend

  • React 19.2 - UI library
  • Vite 7.2 - Build tool
  • React Router DOM 7.11 - Routing
  • Axios 1.13 - HTTP client
  • Bootstrap 5.3 - CSS framework

๐Ÿ“‹ Prerequisites

  • Python 3.10+
  • Node.js 20.19+ or 22.12+
  • PostgreSQL 12+
  • npm or yarn

๐Ÿ”ง Installation

Backend Setup

  1. Navigate to backend directory
cd HMS-Backend
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install django djangorestframework psycopg2-binary django-cors-headers
  1. Configure PostgreSQL

Create a database named hms_db:

CREATE DATABASE hms_db;

Update hms_backend/settings.py with your PostgreSQL credentials:

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "hms_db",
        "USER": "your_postgres_user",
        "PASSWORD": "your_postgres_password",
        "HOST": "127.0.0.1",
        "PORT": "5432",
    }
}
  1. Run migrations
python manage.py makemigrations
python manage.py migrate
  1. Create superuser (optional)
python manage.py createsuperuser
  1. Run development server
python manage.py runserver

Backend will be available at http://127.0.0.1:8000

Frontend Setup

  1. Navigate to frontend directory
cd HMS-Frontend/react-app
  1. Install dependencies
npm install
  1. Run development server
npm run dev

Frontend will be available at http://localhost:5173

๐Ÿ“ Project Structure

HMS/
โ”œโ”€โ”€ HMS-Backend/
โ”‚   โ”œโ”€โ”€ accounts/           # User authentication & authorization
โ”‚   โ”œโ”€โ”€ doctors/            # Doctor profiles & availability
โ”‚   โ”œโ”€โ”€ patients/           # Patient management
โ”‚   โ”œโ”€โ”€ appointments/       # Appointment booking system
โ”‚   โ”œโ”€โ”€ hms_backend/        # Project settings
โ”‚   โ””โ”€โ”€ manage.py
โ”‚
โ””โ”€โ”€ HMS-Frontend/
    โ””โ”€โ”€ react-app/
        โ”œโ”€โ”€ src/
        โ”‚   โ”œโ”€โ”€ components/
        โ”‚   โ”‚   โ”œโ”€โ”€ header/
        โ”‚   โ”‚   โ”œโ”€โ”€ footer/
        โ”‚   โ”‚   โ”œโ”€โ”€ main/
        โ”‚   โ”‚   โ”œโ”€โ”€ login/
        โ”‚   โ”‚   โ”œโ”€โ”€ register/
        โ”‚   โ”‚   โ”œโ”€โ”€ doctor/
        โ”‚   โ”‚   โ”œโ”€โ”€ patient-dashboard/
        โ”‚   โ”‚   โ”œโ”€โ”€ about/
        โ”‚   โ”‚   โ””โ”€โ”€ services/
        โ”‚   โ”œโ”€โ”€ App.jsx
        โ”‚   โ”œโ”€โ”€ AuthContext.jsx
        โ”‚   โ””โ”€โ”€ main.jsx
        โ””โ”€โ”€ package.json

๐Ÿ”Œ API Endpoints

Authentication

  • POST /api/accounts/register/ - User registration
  • POST /api/accounts/login/ - User login

Doctors

  • GET /api/doctors/doctors/ - List all doctors
  • GET /api/doctors/doctor/profile/ - Get doctor profile (authenticated)
  • GET /api/doctors/profile-status/ - Check if user has doctor profile
  • GET /api/doctors/doctor/availability/ - Get doctor availability
  • POST /api/doctors/doctor/availability/ - Create availability slot
  • GET /api/doctors/doctor/<id>/slots/ - Get available slots for a doctor

๐ŸŽจ Design Choices

Backend

  • Session-based authentication for simplicity and security
  • Role-based access control using is_staff flag
  • Separate apps for modularity (accounts, doctors, patients, appointments)
  • PostgreSQL for robust relational data management

Frontend

  • Context API for global authentication state
  • React Router for client-side routing
  • Bootstrap for rapid UI development with custom CSS overlays
  • Axios for API communication
  • Conditional rendering for role-based UI

๐Ÿšฆ Usage

Patient Flow

  1. Register as a patient
  2. Login to access patient dashboard
  3. Browse available doctors
  4. View doctor availability slots
  5. Book appointments

Doctor Flow

  1. Register as a doctor
  2. Complete doctor profile (specialization, fees, etc.)
  3. Set availability slots
  4. View and manage appointments
  5. Update profile as needed

๐Ÿ”’ Security Features

  • CSRF protection enabled
  • CORS configured for localhost development
  • Password validation on registration
  • Session-based authentication
  • Protected routes requiring authentication

๐ŸŒ Environment Variables

Create a .env file for production deployment:

# Backend
SECRET_KEY=your-secret-key
DEBUG=False
DATABASE_URL=postgres://user:password@host:port/dbname
ALLOWED_HOSTS=your-domain.com

# Frontend
VITE_API_URL=https://api.your-domain.com

๐Ÿ“ Available Scripts

Backend

python manage.py runserver      # Start development server
python manage.py makemigrations # Create migrations
python manage.py migrate        # Apply migrations
python manage.py createsuperuser # Create admin user
python manage.py test           # Run tests

Frontend

npm run dev      # Start development server
npm run build    # Build for production
npm run preview  # Preview production build
npm run lint     # Run ESLint

๐Ÿ› Known Issues

  • Doctor profile creation redirect needs backend integration
  • Appointment booking functionality is frontend-only (backend pending)
  • File upload for doctor images requires media file configuration

๐Ÿ”ฎ Future Enhancements

  • Complete appointment booking backend
  • Email notifications for appointments
  • Payment integration for consultation fees
  • Patient medical history
  • Doctor ratings and reviews
  • Search and filter functionality
  • Admin dashboard
  • PDF prescription generation
  • Video consultation feature

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License.

๐Ÿ‘ฅ Team

Developed by a passionate team of developers, designers, and healthcare enthusiasts.

๐Ÿ“ž Support

For support, email info@hmshospitals.com or join our Slack channel.


Note: This is a development version. For production deployment, ensure proper security configurations, environment variables, and hosting setup.

About

A Hospital Management System

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages