Skip to content

Latest commit

 

History

History
187 lines (157 loc) · 6.78 KB

File metadata and controls

187 lines (157 loc) · 6.78 KB

MediQR

Unified Healthcare Queue & Secure Prescription Portal
A high-performance, privacy-first, full-stack medical gateway linking Doctors, Patients, and Pharmacies into a secure paperless network.

FastAPI React PostgreSQL Tailwind JWT


⚡ Key Highlights & Workflows

🏥 Real-Time Queue Tracker & Status Lights

Patients join waiting lists by scanning the clinic's unique Chamber UUID. The dashboard tracks progress with live blinking status bars:

  • 🟠 Doctor is seeing: ANOTHER PATIENT — Flashes amber when the doctor is currently busy in consultation.
  • 🟢 Doctor is seeing: YOU — Flashes green when the doctor calls you into the chamber.
  • Doctor is currently: IDLE — Displays when the chamber is currently waiting for the next patient.

🔐 Hybrid Offline-First Prescription Sharing (QR Passport)

MediQR supports both connected and zero-connectivity environments (such as hospital basements):

  1. Online Mode (JWT Token): Generates a cryptographically signed 5-minute security token. Pharmacies verify it via the API.
  2. Offline Mode (QR Passport): Serializes the latest prescription details directly into a compressed Base64 payload embedded inside the QR code. Allows pharmacies to scan and decrypt prescriptions instantly with zero internet access.

🧭 System Workflow

[ Patient ] === (Scan Chamber QR) ===> [ Live Queue Room ]
     |                                          || (Doctor Calls Next)
     | <== (Consultation & RX Issued) <=========||
     |
     +--- [ Online Mode ]  ===> (5-Min Signed JWT) =====> [ Pharmacy Dashboard ]
     |                                                           || (Verifies & Decrypts)
     +--- [ Offline Mode ] ===> (Base64 QR Passport) ============> [ Dispenses Medicine ]

📂 Relational Database Design

erDiagram
    users ||--o| chambers : "doctor_id (one-to-one)"
    users ||--o{ queues : "patient_id"
    users ||--o{ prescriptions : "patient_id / doctor_id"
    chambers ||--o{ queues : "chamber_id"
    
    users {
        UUID id PK "Unique identifier"
        string role "patient | doctor | pharmacy"
        string full_name "User profile name"
        string username UK "Alphanumeric key"
        string mobile "10-digit verify"
        string pin_code "Postal reference"
        string address "Residential info"
        string hashed_password "Bcrypt secret"
    }
    
    chambers {
        UUID id PK "Chamber ID"
        UUID doctor_id FK "Linked doctor profile"
        string clinic_name "Medical center title"
        string city "City location"
        string open_time "Start timing"
        string close_time "End timing"
        string qr_code_key UK "Unique QR value UUID"
    }
    
    queues {
        int id PK "Auto-increment ID"
        UUID chamber_id FK "Chamber reference"
        UUID patient_id FK "Patient reference"
        string status "waiting | active | completed"
        datetime joined_at "Audit timestamp"
    }

    prescriptions {
        UUID id PK "Prescription ID"
        UUID doctor_id FK "Treating doctor"
        UUID patient_id FK "Assigned patient"
        string medications "Prescribed drugs"
        string instructions "Usage guidance notes"
        datetime created_at "Issue timestamp"
    }
Loading

⚙️ Installation & Development Setup

🐍 Backend API Setup

  1. Navigate to the backend folder:
    cd backend
  2. Setup virtual environment:
    python -m venv .venv
    # Windows:
    .venv\Scripts\Activate.ps1
    # macOS/Linux:
    source .venv/bin/activate
  3. Install packages:
    pip install fastapi uvicorn sqlalchemy psycopg2-binary pyjwt passlib bcrypt python-dotenv
  4. Define environment variables in backend/.env:
    DB_USER=postgres
    DB_PASSWORD=your_password
    DB_HOST=127.0.0.1
    DB_PORT=5432
    DB_NAME=MEDIQR
    JWT_SECRET_KEY=4e92b3a8d6f1c7e9a2b5c8d0f1e2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0
    ALGORITHM=HS256
  5. Spin up the FastAPI server:
    uvicorn main:app --reload

⚡ Frontend Setup

  1. Navigate to the frontend folder:
    cd frontend
  2. Install Node modules:
    npm install
  3. Start the Vite server:
    npm run dev

🐳 Docker Compose Setup (Recommended)

You can run the entire application stack in containerized environments with a single command if you have Docker installed:

  1. Build and spin up the containers:
    docker-compose up --build
  2. Access the portals:
    • Frontend Web App: http://localhost
    • Backend REST API: http://localhost:8000

🔬 Step-by-Step Test Procedure

🟢 1. Reset Database

  • Navigate to http://127.0.0.1:8000/docs.
  • Under the Development section, run clear-all-users to start fresh.

🔵 2. Doctor Chamber Setup

  • Register a Doctor account (e.g. dr_house) and log in.
  • Fill out the clinic details to generate your unique Chamber UUID QR Code.
  • Copy the Chamber UUID string.

🟡 3. Patient Waiting Room

  • Open two separate tabs. Register Patient A (alice) and Patient B (bob).
  • Both patients paste the Chamber UUID and click Join Waiting Queue.
  • Patient B immediately sees the live indicator: Doctor is consulting: IDLE and position #2.

🔴 4. Live Consultation

  • Doctor dashboard shows both patients. Click Call Next Patient.
  • Patient A's status instantly updates to "In Chamber / Consulting".
  • Patient B's status bar flashes amber: Doctor is seeing: ANOTHER PATIENT.

🟣 5. Secure Checkout & Decryption

  • Doctor fills out the prescription form (using shorthand like TDS PC) and submits.
  • Patient A opens Share Prescriptions and clicks the Offline QR Passport tab.
  • Log in as a Pharmacy account. Paste the offline token into the verification bar.
  • The pharmacy dashboard instantly decodes and translates the prescription without calling the database backend!

Give this project a star if you find it helpful!
⭐ MediQR — Open-Source Digital Healthcare Portal ⭐