Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VaidikaAI v3 πŸ₯

AI-powered multilingual hospital workflow β€” Protothon Hackathon 2025

Speak any language. Receive world-class care.


What's New in v3

  • 🎀 Real-time bilingual voice β€” patient speaks Hindi, doctor hears English live. Doctor speaks English, patient hears it in Hindi instantly.
  • πŸ“± QR code on every token slip β€” scan at doctor, lab, pharmacy to load patient in one second.
  • πŸ–¨οΈ Print-ready token slip β€” generates from browser with embedded QR code.
  • πŸ“„ Clinical PDF Generation β€” Download a professional, formatted clinical record PDF with one click.
  • πŸ”‰ Bilingual Kiosk & Discharge β€” System speaks to patients in their preferred language during check-in and discharge.
  • 🚨 Emergency SMS alerts β€” Twilio sends SMS to duty team for high/emergency cases automatically.
  • πŸ“Š Analytics dashboard β€” live stats, severity breakdown, language chart, dept completion rates.
  • πŸ€– Multi-LLM Intelligence β€” Support for Google Gemini (Primary), Llama 3.2 (Local), and Claude 3.5.
  • πŸ”„ Returning Patients β€” One-click re-registration via patient ID or QR scan.

Architecture

graph TD
    subgraph "Frontend (Next.js)"
        UI["User Portals (Reception, Doctor, Lab, Pharmacy, Analytics)"]
        BrowserMic["Browser Microphone"]
    end

    subgraph "Backend (FastAPI)"
        API["FastAPI Server"]
        PDF["PDF Generation (FPDF2)"]
        QR["QR Generation"]
    end

    subgraph "External Services"
        Sarvam["Sarvam AI (STT, Translate, TTS)"]
        Gemini["Google Gemini (Primary LLM)"]
        Claude["Claude 3.5 (Fallback)"]
        Twilio["Twilio SMS API"]
    end

    subgraph "Local AI & Data"
        Ollama["Ollama (Llama 3.2:3b)"]
        SQLite["SQLite DB (Main Storage)"]
        Delta["Delta Lake (Analytics)"]
        Airflow["Airflow (Pipelines)"]
    end

    UI <--> API
    BrowserMic --> API
    API <--> Sarvam
    API <--> Gemini
    API <--> Claude
    API <--> Ollama
    API <--> SQLite
    API --> Twilio
    API --> PDF
    API --> QR
    API --> Airflow
    Airflow --> Delta
    Delta --> UI
Loading

Project Structure

vaidika-v3/
β”œβ”€β”€ agents/
β”‚   β”œβ”€β”€ schema.py                   # All Pydantic models
β”‚   └── consultation_agent.py       # Qwen2.5:7b via Ollama
β”œβ”€β”€ voice/
β”‚   └── sarvam.py                   # STT + translate + TTS + bilingual pipeline
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ database.py                 # SQLite init (all tables)
β”‚   β”œβ”€β”€ qr_utils.py                 # QR code generation (base64 PNG)
β”‚   β”œβ”€β”€ pdf_utils.py                # FPDF2 clinical record PDF generation
β”‚   β”œβ”€β”€ alerts.py                   # Twilio SMS emergency alerts
β”‚   └── main.py                     # FastAPI β€” 15+ endpoints
β”œβ”€β”€ pipelines/
β”‚   └── hospital_dag.py             # Airflow DAG (parallel lab+pharmacy+alert)
β”œβ”€β”€ data/
β”‚   └── spark_manager.py            # PySpark + Delta Lake
β”œβ”€β”€ docker/
β”‚   β”œβ”€β”€ Dockerfile.backend
β”‚   └── docker-compose.yml
β”œβ”€β”€ vaidika-ui/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ page.js                 # Home hub (API/Ollama/DB status)
β”‚   β”‚   β”œβ”€β”€ reception/page.js       # Register + QR slip + print
β”‚   β”‚   β”œβ”€β”€ token-display/page.js   # Waiting room TV
β”‚   β”‚   β”œβ”€β”€ doctor/page.js          # Bilingual voice + AI record + PDF + discharge
β”‚   β”‚   β”œβ”€β”€ lab/page.js             # QR scan + enter results
β”‚   β”‚   β”œβ”€β”€ pharmacy/page.js        # QR scan + dispense
β”‚   β”‚   └── analytics/page.js       # Live dashboard
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ QRScanner.js            # Camera QR scanner (html5-qrcode)
β”‚   β”‚   └── PatientLoader.js        # Reusable: text input + QR scan button
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ api.js                  # All API calls
β”‚   β”‚   └── useRecorder.js          # Browser mic recording hook
β”‚   └── package.json
β”œβ”€β”€ requirements.txt
└── .env.example

Setup

Step 1 β€” Environment variables

cp .env.example .env

Fill in .env:

Key Where to get it
SARVAM_API_KEY https://dashboard.sarvam.ai β†’ Sign up β†’ API Keys
GOOGLE_API_KEY https://aistudio.google.com β†’ Get API Key
TWILIO_ACCOUNT_SID https://twilio.com β†’ Console (leave blank to disable SMS)
TWILIO_AUTH_TOKEN Twilio Console
TWILIO_FROM_NUMBER Your Twilio phone number
EMERGENCY_ALERT_NUMBER Doctor/duty team phone number

Step 2 β€” Python dependencies

# Core API (Python 3.10 to 3.14 supported)
pip install -r requirements.txt

# Optional: Data Pipelines (Requires Python < 3.14)
# pip install -r requirements-pipelines.txt

Note

The core API supports Python 3.14. However, apache-airflow and pyspark do not yet support Python 3.14. If you are on Python 3.14, the API will automatically skip these features.

Step 3 β€” Ollama + Qwen2.5

# Linux/Mac
curl -fsSL https://ollama.com/install.sh | sh
ollama serve &
ollama pull llama3.2:3b

# Verify
ollama list   # should show llama3.2:3b

Step 4 β€” Test AI agent alone

python -m agents.consultation_agent
# Prints a filled ClinicalRecord JSON in ~3 seconds

Step 5 β€” Start backend

python api/main.py
# API:  http://localhost:8000
# Docs: http://localhost:8000/docs

Step 6 β€” Start frontend

cd vaidika-ui
npm install or yarn install
npm run dev or yarn dev
# Frontend: http://localhost:3000

Data Model (ERD)

erDiagram
    PATIENTS ||--o{ CONSULTATIONS : "has"
    PATIENTS ||--o{ DEPT_UPDATES : "receives"
    PATIENTS ||--o{ LAB_ORDERS : "has"
    PATIENTS ||--o{ PRESCRIPTIONS : "has"
    PATIENTS ||--o{ EMERGENCY_ALERTS : "triggers"

    PATIENTS {
        string patient_id PK
        string name
        int age
        string gender
        string language
        string aadhaar_last4
        int token_number
        int room_number
        string qr_code
        int checked_in
        string created_at
    }

    CONSULTATIONS {
        string consultation_id PK
        string patient_id FK
        string transcript
        string symptoms
        string diagnosis
        string prescriptions
        string lab_tests
        string severity
        string route_to
        string followup
        string clinical_notes
        string created_at
    }

    DEPT_UPDATES {
        string update_id PK
        string patient_id FK
        string dept
        string action
        string data
        string updated_at
    }

    LAB_ORDERS {
        string order_id PK
        string patient_id FK
        string tests
        string status
        string results
        string created_at
        string updated_at
    }

    PRESCRIPTIONS {
        string rx_id PK
        string patient_id FK
        string medicines
        string status
        string created_at
        string updated_at
    }

    EMERGENCY_ALERTS {
        string alert_id PK
        string patient_id FK
        string severity
        string diagnosis
        int sms_sent
        string created_at
    }
Loading

Patient Journey

1. Reception β†’ /reception

  • Staff enters patient name, age, gender, preferred language.
  • System generates Patient ID (VK-2025-XXXXX), token, and room.
  • Click πŸ–¨οΈ Print Token Slip β†’ patient carries this slip with QR.

2. Waiting Room β†’ /token-display & /checkin

  • TV screen shows current tokens + room numbers.
  • Patient scans QR at kiosk β†’ hears welcome message in their language.

3. Doctor β†’ /doctor

  • Staff scans patient QR code.
  • Bilingual voice consultation:
    • Click "Record Patient" β†’ patient speaks Hindi β†’ doctor sees English.
    • Click "Record Doctor" β†’ doctor speaks English β†’ patient hears Hindi.
  • Click CONFIRM β†’ Qwen2.5 generates clinical record.
  • πŸ“„ Download PDF β†’ Professional record instantly generated.
  • πŸ”‰ Discharge β†’ Patient hears final instructions in their language.

4. Lab & Pharmacy β†’ /lab & /pharmacy

  • Scan QR β†’ enter results or mark medicines dispensed.
  • Updates sync back to the main clinical record.

5. Analytics β†’ /analytics

  • Live stats, emergency alerts, and department progress bars.

API Endpoints

Method Endpoint Description
GET /health API + Ollama + DB status
POST /register Register patient β†’ ID + token + QR code
GET /patient/{id} Get patient info
POST /checkin Kiosk check-in β†’ welcome audio
POST /voice/patient-speech Audio β†’ STT + translate to English
POST /voice/doctor-speech Audio β†’ STT β†’ translate + TTS output
POST /consultation Transcript β†’ AI record β†’ SMS + Analytics
GET /record/{id} Full record (consult + lab + pharmacy)
GET /patient/{id}/pdf NEW: Generate Clinical Record PDF
GET /discharge/{id} Discharge message + billing + audio
POST /department/update Lab/pharmacy post results
GET /tokens/active Today's token list
GET /analytics/summary Full dashboard stats
POST /translate Translate any text (Sarvam)
POST /speak-b64 Text β†’ speech audio base64

Tech Stack

Component Technology
Local AI Llama 3.2:3b via Ollama (100% offline)
Cloud AI Google Gemini Flash 1.5 & Claude 3.5
Voice Sarvam AI (saarika:v2.5, mayura-v1, bulbul-v2)
QR qrcode (Python) + html5-qrcode (JS)
PDF fpdf2 (Python)
Backend FastAPI + SQLite
Frontend Next.js 14 + Tailwind CSS
Pipeline Apache Airflow 2.9 (Optional)
Data PySpark 3.5 + Delta Lake 3.1 (Optional)

VaidikaAI v3 β€” Protothon Hackathon 2025

About

AI-powered multilingual hospital workflow

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages