Inspiration

The Problem Patients frequently leave clinics or diagnostic labs holding dense PDFs, unfamiliar lab values, and handwritten prescriptions filled with abbreviations (HbA1c, TSH, BD, PC, HS). This communication gap causes confusion, anxiety, missed follow-up questions, and difficulty tracking health progress over time—especially for people more comfortable communicating in Hindi or Hinglish.

What it does

MedAi is a full-stack, AI-powered medical communication platform featuring Dr. Sehat, a virtual medical information assistant designed to translate complex healthcare documents into clear, calm, patient-friendly language across English, Hindi (हिन्दी), and Hinglish.

MedAi brings together 13 integrated modules in one accessible, mobile- and desktop-ready dashboard:

AI Medical Report Analysis & Simplified Reports: Upload PDF, JPG, or PNG lab reports to extract structured test tables (Test Name | Result | Normal Range | Status), plain-language summaries, glossaries of complex terms, audio read-aloud, and downloadable summaries. Important Health Alerts (Deterministic Safety Engine): Uses validated, rule-based clinical thresholds—independently of unrestricted AI—to distinguish Potentially Urgent lab values from routine out-of-range findings. Dr. Sehat AI Medical Chatbot: A stateful, report-aware conversational assistant supporting follow-up questions in English, Hindi, and Hinglish via text or voice. Prescription Explainer: Decodes standard prescription abbreviations (OD, BD, TDS, PC, HS, SOS) while explicitly highlighting unclear or smudged handwriting and prompting users to verify with their doctor or pharmacist rather than guessing. Voice & Accessibility: Built-in Speech-to-Text microphone input, Text-to-Speech read-aloud (en-IN / hi-IN), scalable text sizes, High Contrast mode, and switchable calming themes. Medical Report Comparison & Health Progress: Matches comparable tests and units across two dated reports and evaluates trends relative to clinical reference ranges (Improved relative to the reference range, Stable, Needs attention, or Insufficient data for comparison). Personalized Diet & Lifestyle Guide: Generates supportive daily habits and a 7-day meal and exercise plan tailored to dietary preferences, allergies, and mobility—paired with a prominent medical safety disclaimer. Medical Dictionary: Searchable medical terminology and abbreviation guide cross-linked directly to matching tests in the patient's own uploaded reports. Doctor Visit Preparation & Nearby Care: Organizes report findings, personal concerns, and prioritized doctor questions into a downloadable visit sheet, paired with a live Nearby Hospitals & Clinics finder (OpenStreetMap + GPS/city search), emergency helplines (112, 108, 104), and a personal saved-doctors contact book. Patient Dashboard & Private History: Chronological, user-scoped storage for reports, prescriptions, comparisons, and chats with full user control to revisit or delete records.

How we built it

We designed MedAi with a modular full-stack architecture so each of the 13 patient-facing modules works independently while sharing one secure patient context:

Backend (Python + Flask): Built as modular REST blueprints (auth, reports, chat, prescriptions, comparison, lifestyle, dictionary, doctor_prep) behind a unified storage abstraction that supports Firebase Firestore & Auth (protected by strict per-user firestore.rules) alongside a zero-setup SQLite fallback for local development and testing. Multimodal AI Pipeline (Gemini 3.8 Flash via google-genai Interactions API): Instead of brittle OCR pipelines, we send uploaded PDF, JPG, and PNG reports and prescriptions directly to gemini-3.8-flash using Pydantic JSON schemas (response_format) to extract structured lab tables, plain-language English/Hindi summaries, decoded prescription abbreviations, and personalized wellness routines. For Dr. Sehat, we use stateful multi-turn conversations (previous_interaction_id) grounded in the patient's selected report with interaction-scoped medical safety instructions. Deterministic Clinical Safety Layer: Built a dedicated Python rules engine (clinical_rules.py) that cross-checks extracted values against printed reference ranges and validated adult critical lab thresholds (e.g., Hemoglobin, Glucose, Potassium, Sodium, Creatinine, Platelets, WBC, HbA1c)—ensuring Potentially Urgent alerts are never generated solely from unrestricted AI. Frontend (React 19 + Vite + Tailwind CSS v4): Designed a calm, accessible floating-glass dashboard with switchable wellness themes, full English / Hindi (हिन्दी) / Hinglish support, Web Speech API microphone input & read-aloud (en-IN / hi-IN), scalable font sizes, and High Contrast mode. Nearby Care Directory: Integrated OpenStreetMap's Nominatim geocoding and Overpass API with browser GPS/city search inside Doctor Visit Prep to surface real nearby hospitals, clinics, distances, and verified Google Maps links alongside a private saved-doctors contact book.

Challenges we ran into

Preventing AI Overreach in Healthcare: Ensuring the platform explains lab results and prescriptions helpfully without crossing into diagnosis, medication changes, or guessing smudged handwritten prescriptions required strict structured schemas, explicit legibility_status flags (clear / uncertain / unreadable), and a separate deterministic clinical alert engine. Reliable Report Comparison Across Different Labs: Different diagnostic labs use different test names (e.g., Hb vs Haemoglobin, FBS vs Fasting Blood Glucose) and units (mg/dL vs mmol/L). We had to build canonical name matching and unit compatibility checks so mismatched units trigger "Insufficient data for comparison" instead of misleading progress arrows. Avoiding Fabricated Doctor Contact Info: When adding nearby hospitals and doctors, generating doctor phone numbers with an LLM would be dangerous. We solved this by querying real OpenStreetMap place data, surfacing real emergency helplines (112, 108, 104), linking directly to Google Maps for verified listings, and letting users save their own doctor contacts. Cross-Platform & Production Readiness: Handling Windows SQLite file locking during automated tests, enforcing CORS cleanly across Render (gunicorn) and Vercel (*.vercel.app) previews, and keeping API secrets strictly out of Git history with .env / .gitignore hygiene.

Accomplishments that we're proud of

All 13 Planned Modules Delivered End-to-End: Built a cohesive, real full-stack application—from multimodal PDF/image report parsing and Dr. Sehat voice chat to prescription legibility warnings, report progress comparison, personalized daily & 7-day lifestyle guides, report-linked medical dictionary, and nearby hospital search. Safety Built Into the Architecture, Not Just a Footer: Deterministic critical-value alerts, mandatory medication safety disclaimers on lifestyle guidance, uncertainty highlighting on handwritten prescriptions, and strict per-user data isolation (both in API routes and firestore.rules). True Accessibility & Multilingual Reach: Supporting English, Hindi, and Hinglish together with voice input/output, adjustable font scaling, and High Contrast mode makes complex medical reports genuinely approachable for everyday families. Verified with Automated Tests: End-to-end backend tests covering clinical alert rules, unit-mismatch comparison safety, prescription uncertainty checks, saved doctor CRUD, and cross-user access isolation

What we learned

Structured Outputs + Deterministic Rules Are Better Together: Pairing Gemini 3.8 Flash's multimodal JSON extraction with deterministic Python validation gives the best of both worlds—human-friendly explanations backed by predictable, auditable clinical logic. Design Tone Matters in Health Tech: A cluttered medical UI adds anxiety; a calm palette, clear visual hierarchy (Normal / Routine Attention / Potentially Urgent), and plain-language summaries immediately make lab reports feel less intimidating. Security & Secret Hygiene From Day One: Strict per-user scoping, input/schema validation in firestore.rules, and keeping credentials isolated in gitignored .env files are essential whenever handling sensitive personal health data.

What's next for MedAi

More Regional Indian Languages: Expanding our modular i18n and voice pipeline beyond English, Hindi, and Hinglish to Marathi, Gujarati, Tamil, Telugu, and Bengali. Production Firebase Auth, Firestore & Encrypted Storage: Connecting live Firebase Authentication, Firestore persistence, and encrypted Cloud Storage for long-term multi-device patient history. Visual Health Trend Charts & Longitudinal Insights: Plotting multi-report lab trajectories over months/years (e.g., HbA1c, Hemoglobin, Lipid Profile) alongside exportable PDF Doctor Visit Summaries. Clinical Review & Validation: Partnering with qualified physicians and pharmacists to review explanations, expand validated clinical alert rules (including pediatric and sex-specific ranges), and refine patient safety guardrails.

Built With

Share this project:

Updates

Submission history