Skip to content

About

Consent-based platform that unifies a patient's medical records across hospitals, with QR/OTP sharing, offline OCR and follow-up tracking.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

60 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ HealthSync

A secure, privacy-first, consent-governed digital healthcare interoperability platform enabling patients, hospitals, and insurance providers to access and manage medical records with complete control.

Node.js MongoDB React Tailwind CSS Socket.IO Tests License

HealthSync solves the problem of fragmented healthcare records by aggregating patient data across hospitals, diagnostic centers, and paper files into a single, unified digital health identity. Patients retain full ownership over their data, granting temporary, scoped access to doctors and insurers via QR codes and OTP verification.

Patient dashboard

πŸ“Έ Screenshots

Health timeline Medical records
Health timeline with AI assistant and record filters Medical records list
Follow-up safety net Consent & sharing
Follow-ups extracted from reports Scoped, time-limited access codes
Landing page

Landing page

Screenshots use a fictional demo patient.

πŸ“˜ For a full walkthrough of the concepts and workflows, see the HealthSync guide (PDF).


✨ Core Features & Implemented Modules

πŸ“„ 1. Unified Medical Vault & Interactive Timeline

  • Cross-Hospital Aggregation: Centralizes prescriptions, lab reports, radiology imaging, discharge summaries, and vaccination certificates across all healthcare facilities.
  • Chronological Health Timeline: Month-by-month visual timeline (TimelineView.jsx) with live record counts, category filters, date-range selectors, and keyword search.
  • Data Integrity: Differentiates between hospital-issued records (read-only and tamper-proof) and self-reported patient uploads.

πŸ’Š 2. Medication Cabinet & Safety Guard

  • Active Cabinet & History Tracking: Dedicated medication cabinet (MedicationCabinetView.jsx) separating currently active medications from discontinued/past prescription history.
  • Drug Interaction & Allergy Alerts: Automatically cross-references active prescriptions to detect drug-drug interactions and patient allergies in real-time.
  • Status Controls: One-click toggling between Active and Completed/Discontinued prescription statuses.

⏰ 3. Follow-up Loop Closure Safety Net (Incidental Findings)

  • Incidental Recommendation Tracking: Automatically parses radiology and discharge prose for future clinical promises ("Repeat chest CT in 6 months").
  • Confidence Gating State Machine:
    • $\ge$ 0.80 Confidence: Automatically logged as active open obligation.
    • 0.45 – 0.79 Confidence: Logged as pending_confirm asking the patient to confirm.
    • < 0.45 Confidence: Discarded to prevent false alarm fatigue.
  • Automated Escalation Scheduler: Background cron job (followupScheduler.js) executing multi-tier alerts (T-30, T-7, due date, T+1, T+30 overdue).
  • Auto-Closure Engine: Detects incoming lab or imaging records that fulfill open obligations and marks them completed.

πŸ“· 4. Multi-Format OCR & Document Digitization Pipeline

  • Format Support: Supports PDF (vector text layers & scanned images), PNG, JPG, WebP, and HEIC files (up to 25 pages / 60 MB per scan).
  • Image Preprocessing & Rasterization: Image despeckling, contrast enhancement, auto-rotation via sharp, and multi-page PDF page rasterization via mupdf.
  • Offline OCR Pool: Tesseract.js worker pool using offline trained data (@tesseract.js-data/eng) with CPU concurrency queuing and idle worker auto-teardown.

πŸ”’ 5. Consent-Based Access & Audit System

  • Patient-Driven Sharing: Grant temporary access to doctors, hospitals, or insurance adjusters via QR code or OTP verification.
  • Granular Permission Checkboxes: Selectively toggle permission scopes (medicalHistory, prescriptions, reports, allergies, bloodGroup).
  • Instant Revocation & Audit Logs: Patients can revoke provider access at any time. Immutable audit logs (AuditLog.js) record every access event, timestamp, and provider identity.

πŸ›‘οΈ 6. Insurance & Claims Interoperability

  • Policy Management: Patients link health insurance policies directly to their vault.
  • Consent-Backed Claims: File claims with attached medical proof and diagnostic records.
  • Claim Lifecycle Tracking: Real-time status tracking (Submitted $\rightarrow$ Under Review $\rightarrow$ Info Requested $\rightarrow$ Approved / Rejected).
  • Multi-Party Live Chat: Built-in real-time messaging thread (ClaimDetailDrawer.jsx) between patient, hospital billing, and insurance adjusters.

πŸ“’ 7. Health Advisories & Real-Time Alerts

  • Regional & Public Alerts: Targeted health advisories and WHO disease outbreak news broadcast directly to patient dashboards.
  • WebSockets: Real-time live notifications and message badges powered by Socket.IO.

πŸ” 8. Enterprise Authentication & Security Foundation

  • Dual-Token Authentication: JWT Access Tokens & Refresh Tokens with automatic Refresh Token Rotation and secure HTTP-only cookies.
  • Account Lockout & Rate Limiting: Account lockout after consecutive failed login attempts, authentication rate limiters, and bcrypt password hashing.
  • Security Headers & Sanitation: Protected by Helmet, HPP, MongoDB injection protection, XSS sanitization, and express-validator.

πŸ›  Tech Stack

Backend

  • Runtime: Node.js, Express.js (v5)
  • Database: MongoDB, Mongoose ORM
  • Real-time: Socket.IO
  • OCR & Image Processing: Tesseract.js, Sharp, MuPDF, PDF-Parse
  • Security: Helmet, Express Rate Limit, Express Validator, HPP, Express XSS Sanitizer, bcryptjs, JSONWebToken
  • Email & Utilities: Nodemailer, Winston Logger, Compression, Cookie Parser

Frontend

  • Framework: React 19, Vite, React Router
  • Styling: Tailwind CSS 4, Lucide React Icons
  • Real-time Client: Socket.IO Client

Testing

  • Backend: 200+ Jest + Supertest tests across auth, OCR, follow-ups, insurance, consent and the AI pipeline

πŸ“‚ Project Structure

HealthSync/
β”œβ”€β”€ Backend/
β”‚   β”œβ”€β”€ scripts/                # Database seeders (seedAdmin.js, seedInsurance.js)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/             # Security, upload, & report configurations
β”‚   β”‚   β”œβ”€β”€ constants/          # Follow-up & Record Type constants
β”‚   β”‚   β”œβ”€β”€ controllers/        # Express controllers (auth, record, consent, insurance, etc.)
β”‚   β”‚   β”œβ”€β”€ jobs/               # Background cron jobs (followupScheduler.js)
β”‚   β”‚   β”œβ”€β”€ middleware/         # Auth, RBAC, Rate limiters, Validation
β”‚   β”‚   β”œβ”€β”€ models/             # Mongoose schemas (User, MedicalRecord, Claim, FollowUp, etc.)
β”‚   β”‚   β”œβ”€β”€ routes/             # API routes (patient, hospital, insurance, dev, advisory)
β”‚   β”‚   β”œβ”€β”€ services/           # Service layer (ocr, followup, record, consent, insurance, extractors)
β”‚   β”‚   β”œβ”€β”€ utils/              # ApiError, ApiResponse, Logger, AsyncHandler
β”‚   β”‚   β”œβ”€β”€ app.js              # Express app setup & security middleware
β”‚   β”‚   β”œβ”€β”€ server.js           # HTTP & Socket.IO server initialization
β”‚   β”‚   └── socket.js           # Socket.IO connection & event handlers
β”‚   └── tests/                  # Jest test suites (auth, ocr, followup, insurance, batchScan)
β”œβ”€β”€ Frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/         # UI components (TimelineView, MedicationCabinetView, ConsentsView, etc.)
β”‚   β”‚   β”œβ”€β”€ context/            # AuthContext
β”‚   β”‚   β”œβ”€β”€ lib/                # API client helpers, Socket client, Formatters
β”‚   β”‚   β”œβ”€β”€ pages/              # Dashboards (Patient, Hospital, Insurance, Admin, Login, Signup)
β”‚   β”‚   β”œβ”€β”€ App.jsx             # Main router
β”‚   β”‚   └── main.jsx            # Entry point

βš™οΈ Getting Started

Requirements: Node.js 20+ and MongoDB (local install, Atlas, or docker run -d -p 27017:27017 mongo:7).

1. Clone the repository

git clone https://github.com/itsnjstyle27/HealthSync.git
cd HealthSync

2. Install Backend & Frontend Dependencies

# Install Backend dependencies
cd Backend
npm install

# Install Frontend dependencies
cd ../Frontend
npm install

3. Configure Environment Variables

Copy the example file and fill in the two token secrets (64+ random characters each):

cd Backend
cp .env.example .env

Everything else has working defaults. Backend/.env.example documents every setting:

  • SMTP is optional. Without it, new accounts are verified automatically in development.
  • AI summaries and embeddings are off until you set AI_API_KEY. OCR and the rule-based follow-up extractor work fully offline.

The frontend calls http://localhost:5000/api by default. To point it elsewhere, set VITE_API_URL in Frontend/.env.

4. Run Development Servers

# Start Backend server (from Backend folder)
npm run dev

# Start Frontend development server (from Frontend folder)
npm run dev        # http://localhost:3000

5. Run the tests

cd Backend
npm test           # uses MONGO_URI_TEST from .env

πŸ—ΊοΈ Roadmap & Status

  • Authentication & Security Foundation β€” Dual JWT, token rotation, account lockout, rate-limiting
  • Unified Medical Record Vault β€” Multi-category record storage, OCR, self-reported vs. hospital-issued records
  • Interactive Health Timeline β€” Chronological month-by-month history with filter facets and search
  • Medication Cabinet & Safety Guard β€” Active cabinet, history tracking, real-time drug interaction & allergy alerts
  • Follow-up Loop Closure Safety Net β€” Incidental recommendation extraction, confidence gating, auto-closure engine
  • Consent-Based Access Control β€” OTP & QR code access, granular permission checkboxes, instant revocation
  • Doctor & Hospital Dashboard β€” Linked patient lookup, QR/OTP verification, clinical record issuance
  • Insurance Integration & Claims β€” Policy linking, claim lifecycle management, real-time multi-party claim chat
  • Health Advisories & Public Alerts β€” Targeted health broadcasts, WHO disease outbreak alerts
  • Real-time WebSockets β€” Socket.IO notifications, status badges, and claim chat threads

πŸ‘₯ Contributors

  • Neerav Mishra: creator and maintainer. Built authentication, the landing and sign-in flows, the patient and hospital dashboards, the admin portal, the OCR pipeline and the follow-up safety net.
  • Ayush Pratap Singh: insurance and claims, the medication cabinet, the HealthSync ID system, and the AI health assistant with its RAG pipeline.

πŸ“„ License

This project is licensed under the MIT License.

About

Consent-based platform that unifies a patient's medical records across hospitals, with QR/OTP sharing, offline OCR and follow-up tracking.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages