Skip to content

khuntaaryan-droid/hms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini Hospital Management System (HMS)

A full-stack, dual-dashboard Hospital Management System built with Django, featuring real-time Google Calendar synchronization and an independent Node.js serverless microservice for automated email notifications.

🌟 Features

  • Dual Dashboards: Custom role-based interfaces for Doctors and Patients.
  • Smart Scheduling: Doctors can generate hourly time slots; booked slots dynamically disappear from the available pool.
  • Google Calendar Integration: Secure OAuth2 + PKCE flow to automatically create Google Calendar events for both the Patient and the Doctor upon booking.
  • Serverless Email Microservice: A decoupled Node.js service using the Serverless Framework and Resend API to deliver asynchronous HTML confirmation emails.

🛠️ Prerequisites

Before you begin, ensure you have the following installed on your Windows machine:

  • Python 3.x (for the Django Backend)
  • PostgreSQL on Docker (for database)
  • Node.js & npm (for the Email Microservice)
  • Google Cloud Console Account (For Calendar API credentials.json)
  • Resend Account (For Email API Key)

📂 Project Structure

/hms_workspace
│
├── /hms                 # The Django Backend
│   ├── manage.py
│   ├── credentials.json         # Google OAuth Keys (User provided)
│   ├── /hms             # Core settings
│   └── /core                    # Main application logic
│
└── /email_service        # The Node.js Microservice
    ├── handler.js               # Email sending logic
    ├── serverless.yml           # Microservice configuration
    ├── package.json
    └── test.json                # Local testing payload

🚀 Setup & Installation Instructions

Follow these steps exactly to get the entire ecosystem running on your local machine.

Step 1: Set Up the Django Backend

  1. Open a terminal and navigate to your hms folder.

  2. Create and activate a virtual environment:

    python -m venv .venv
    .\.venv\Scripts\activate
    
  3. Install the required Python packages:

    pip install -r requirements.txt
    
  4. Apply the database migrations:

    python manage.py makemigrations
    python manage.py migrate
    
  5. Create an admin account to manage the database:

    python manage.py createsuperuser
    

Step 2: Create the postgres container on Docker

  1. Start the Docker Desktop and run following command on the terminal(NOTE: Replace all values according to you)

    docker run --name hms-postgres \
    -e POSTGRES_USER=<admin-name> \
    -e POSTGRES_PASSWORD=<password> \
    -e POSTGRES_DB=<database-name> \
    -p 5432:5432 \
    -d postgres
    

Step 3: Configure Google Calendar API

  1. Go to the Google Cloud Console.
  2. Enable the Google Calendar API.
  3. Create an External OAuth Consent Screen and add your test Gmail addresses to the Test Users list.
  4. Create OAuth Client ID credentials (Web Application) with the redirect URI: http://127.0.0.1:8000/oauth2callback/.
  5. Download the JSON file, rename it to credentials.json, and place it in the root of your hms folder.

Step 4: Set Up the Email Microservice

  1. Open a new terminal window and navigate to your email_service folder.

  2. Install the free version of the Serverless Framework globally:

    npm install -g serverless@3
    
  3. Install the required local dependencies:

    npm install resend serverless-offline@13 --save-dev
    

🏃‍♂️ Running the Application

Because this project utilizes a microservice architecture, you must run two servers simultaneously in two separate terminal windows.

Terminal 1: Start the Email Microservice

Open a terminal in the email_service folder. Run the command that matches your terminal type to inject your Resend API key and start the listener on port 3000:

Command Prompt (CMD):

set RESEND_API_KEY=<re_YOUR_KEY_HERE> && serverless offline

PowerShell:

$env:RESEND_API_KEY="re_YOUR_KEY_HERE"; serverless offline

Terminal 2: Start the Django Server

Open a terminal in the hms folder, activate your virtual environment, and run the Django server:

.\.venv\Scripts\activate
python manage.py runserver

🧪 How to Test the Flow

  1. Go to http://127.0.0.1:8000/admin and ensure your Patient user account's email matches the exact email you registered with Resend (Free Tier requirement).
  2. Go to http://127.0.0.1:8000/patient/dashboard/.
  3. Click Book Now on an available slot.
  4. Log into Google when prompted (If warned about unverified apps, click Advanced -> Go to App).
  5. The system will book the slot, sync to Google Calendar, and trigger the Node.js server to send a confirmation email.
  6. Check your Google Calendar and your Email Inbox!

Releases

No releases published

Packages

 
 
 

Contributors