An intelligent outpatient department management system that uses Google Gemini AI to triage patients, prioritize queues dynamically, and generate clinical documentation in real-time.
- Patients describe symptoms via text or voice at check-in
- Gemini Flash analyses the symptoms and assigns a severity score (1–100)
- AI estimates the predicted consultation duration
- The doctor's dashboard shows a real-time queue sorted by Priority Score
- Priority Score formula:
S + (T × 0.5)— Severity + Waiting Time (minutes) - Implements an aging algorithm to prevent low-severity patients from waiting indefinitely
- Queue updates automatically every 60 seconds and instantly via WebSocket on any new check-in
- Patients can dictate symptoms verbally instead of typing
- Doctors can record consultations in real-time
- Audio is captured via the browser's
MediaRecorderAPI and transcribed by Gemini AI on the backend
- After a consultation, the doctor pastes or records the doctor-patient dialogue
- Gemini generates structured SOAP notes (Subjective, Objective, Assessment, Plan)
- AI also drafts a prescription with medication name, dosage, frequency, and duration
- A general advice and follow-up summary is also generated
- Socket.IO pushes queue updates to all connected doctor dashboards simultaneously
- A live connection indicator shows socket status
| Layer | Technology |
|---|---|
| Frontend | React (Vite), Vanilla CSS, Lucide Icons, Socket.IO Client |
| Backend | Node.js, Express.js |
| Database | MongoDB (via Mongoose) |
| AI | Google Gemini Flash (@google/generative-ai) |
| Real-time | Socket.IO |
| Fonts | DM Sans, DM Serif Display, JetBrains Mono |
PriorityQ/
├── backend/
│ ├── controllers/
│ │ ├── triageController.js # Patient check-in & AI triage logic
│ │ ├── queueController.js # Priority score calculation & broadcast
│ │ └── notesController.js # SOAP note & prescription generation
│ ├── models/
│ │ └── PatientVisit.js # Mongoose schema (severity, notes, prescription)
│ ├── routes/
│ │ └── api.js # All REST API endpoints + /transcribe
│ ├── services/
│ │ └── aiService.js # Gemini AI: triage, SOAP notes, audio transcription
│ ├── server.js # Express + Socket.IO + MongoDB connection
│ ├── .env # Environment variables (API key, DB URI)
│ └── package.json
│
└── frontend/
├── src/
│ ├── components/
│ │ ├── PatientIntake.jsx # Check-in form with voice input
│ │ ├── DoctorDashboard.jsx # Live priority queue for doctors
│ │ └── ConsultationRoom.jsx # Dialogue input, SOAP notes, prescription
│ ├── services/
│ │ ├── api.js # Axios API helpers
│ │ └── socket.js # Socket.IO client singleton
│ ├── App.jsx # Router + layout + nav
│ └── index.css # Design system (glassmorphism, tokens)
└── index.html
- Node.js v18+
- MongoDB (running locally on
mongodb://localhost:27017) - A Google Gemini API key from Google AI Studio
⚠️ Important: Create your API key by clicking "Create API key in new project" in AI Studio. Do not use an existing Google Cloud project — it may have billing restrictions that block the free tier.
# Install backend dependencies
cd backend
npm install
# Install frontend dependencies
cd ../frontend
npm installCreate / update backend/.env:
PORT=5000
FRONTEND_URL=http://localhost:5173
MONGO_URI=mongodb://localhost:27017/opd_platform
GEMINI_API_KEY=your_api_key_here
AI_MODEL=gemini-2.0-flashMake sure your local MongoDB service is running:
# Windows (run as Administrator)
net start MongoDBOpen two terminals:
# Terminal 1 — Backend
cd backend
npm run dev
# Terminal 2 — Frontend
cd frontend
npm run dev- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- Enter the patient's name and age
- Describe symptoms by typing or clicking "Speak" to use voice
- Click "Check In & Assess"
- The AI returns a severity score (1–100), a label (e.g., Moderate), and an estimated consultation time
- See all waiting patients sorted by Priority Score (highest first)
- The
#1patient is highlighted as "Next" - The queue auto-refreshes every 60 seconds; new check-ins trigger an instant update via Socket.IO
- Click "Consult" to open the consultation room for any patient
- Type or record the doctor-patient dialogue
- Click "Generate Clinical Notes & Prescription"
- The AI produces structured SOAP notes and a draft prescription
- Click "Complete & Discharge" when done — the patient's status updates to
COMPLETED
Priority Score = Severity Score + (Minutes Waiting × 0.5)
| Term | Description |
|---|---|
| S | AI-assigned severity (1–100). A crushing chest pain might score 92, a mild cold ~15 |
| T | Minutes the patient has been waiting since check-in |
| × 0.5 | Aging weight — ensures low-severity patients still rise over time (starvation prevention) |
Example: A patient with severity 25 who has waited 40 minutes has a score of 25 + 20 = 45, outranking a new patient with severity 40 who scores 40 + 0 = 40.
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/health |
Health check |
POST |
/api/patients/checkin |
Check in a patient + run AI triage |
GET |
/api/patients |
List all patients |
GET |
/api/patients/:id |
Get patient details |
PUT |
/api/patients/:id/status |
Update patient status |
GET |
/api/queue |
Get current sorted queue |
POST |
/api/patients/:id/notes |
Generate SOAP notes + prescription |
PUT |
/api/patients/:id/complete |
Mark patient as discharged |
POST |
/api/transcribe |
Transcribe audio blob via Gemini |
- Voice transcription requires a working Gemini API key (free tier: ~50 req/day)
- The Web Speech API fallback is not used — all STT goes through Gemini on the backend
- Browser support:
MediaRecorderworks in Chrome, Edge, and Firefox - MongoDB must be running locally; there is no cloud DB fallback
MIT — feel free to use, modify, and distribute.