Inspiration
Cardiologists manage hundreds of heart failure patients across fragmented data — vitals from home monitors, lab results from multiple systems, clinical notes, imaging reports, and appointment records. A single missed signal (a 4-pound weight gain over a week, a rising BNP trend, a patient diary entry about orthopnea) can mean the difference between a timely intervention and a preventable hospital readmission. We asked: what if a doctor could just ask a question in plain English and get instant clinical intelligence across all of that data?
The Elasticsearch Agent Builder gave us the perfect foundation. With its ability to orchestrate multi-index queries through natural language, we saw an opportunity to build something that doesn't just store patient data — it reasons over it.
What it does
CardioIQ is an AI-powered cardiology patient intelligence platform with two panels:
Patient Health Vault — Patients input their cardiac health data through intuitive forms: vitals (blood pressure, weight, heart rate, O₂ saturation), lab results across 28 tests in 8 clinical categories, symptom diaries with quick-tap chips, and diagnostic test reports. They can upload medical documents (PDFs and images) that are analyzed by AI vision to extract structured data. Patients also get their own AI companion that answers health questions in plain language with safety guardrails and emergency detection.
Doctor Intelligence Dashboard — Doctors chat with the CardioIQ AI agent using natural language to get instant clinical intelligence across 43,851+ documents in 6 Elasticsearch indices. Ask "Which HFrEF patients are missing guideline-directed medications?" and get a structured table in seconds. Ask "Show me patients showing signs of heart failure decompensation" and it cross-references weight trends, BNP levels, and patient-reported symptoms. A single query replaces what would take 30+ minutes of manual chart review.
Additional doctor tools include real-time risk alerts (6 categories from critical labs to GDMT gaps), population analytics, a calendar with inline SOAP note writing, and an investigation mode that lets doctors drill into any alert with contextual AI prompts.
How we built it
Architecture Overview
Architecture Diagram: https://drive.google.com/file/d/1jVnbcWKL1zaGwKtDA0K7qHqmPF9f2t90/view?usp=sharing Documentation: https://drive.google.com/file/d/1KwfJ-vrA9xkTzz95U2yKMNM8G0fNMO1o/view?usp=sharing
Data Layer: We started with a synthetic dataset generator (generate_data.py) that created 43,851 clinically realistic documents across 6 Elasticsearch Cloud indices — 500 patients with full demographics, 14,380 vitals readings, 18,470 lab results, 3,481 diagnostic tests, 3,271 appointments, and 3,749 clinical notes. Every document includes both patient_id and patient_name for cross-index correlation.
Backend Intelligence (Express.js + Elasticsearch): This is where CardioIQ goes beyond a basic CRUD wrapper:
- Lab enrichment pipeline — Every lab submission is auto-assigned a LOINC code, clinically stratified flag (normal/low/high/critical using age-aware thresholds), trend (rising/stable/falling vs. previous value), and unit. NT-proBNP alone uses 4 age-stratified cutoffs.
- Vitals validation — Weight submissions trigger an Elasticsearch query for the reading from 7 days prior to compute
weight_change_7d— a key heart failure decompensation signal. - NLP symptom extraction — Free-text patient entries are scanned against 9 clinical symptom categories (orthopnea, dyspnea, peripheral edema, chest pain, palpitations, fatigue, weight gain, dizziness, medication noncompliance) using keyword pattern matching. Detected symptoms become structured, queryable tags.
- Document AI — Gemini 2.0 Flash analyzes uploaded medical documents via multimodal vision (images) or text extraction (PDFs), with alias normalization for 20+ lab name variants.
AI Chat: The doctor's chat proxies to the Elasticsearch Agent Builder API, which orchestrates multi-index queries using the CardioIQ system prompt. A custom fallback engine handles 9 intent patterns (patient summaries, GDMT gap analysis, decompensation detection, medication safety cross-referencing, and more) when the agent is unavailable.
Frontend (React + Vite + Tailwind): Dark medical professional theme with role-specific accent colors (emerald for patients, amber for doctors). Recharts for 6 health trend visualizations. Full markdown rendering with table support for AI responses.
Challenges we ran into
Clinical accuracy in enrichment logic — Building the lab flagging system required implementing clinically correct reference ranges with edge cases. NT-proBNP, for example, doesn't have a single "normal" range — it uses age-stratified rule-in/rule-out thresholds (< 300 rule-out, > 450 / > 900 / > 1800 by age bracket). Getting these right for 22 lab tests with proper flag escalation (normal → low/high → critical) took significant research.
Cross-index correlation at query time — A question like "patients showing signs of decompensation" requires simultaneously checking weight trends in vitals-monitoring, BNP levels in lab-results, and symptom tags in clinical_notes, then correlating results by patient_id. Designing Elasticsearch queries that efficiently join across indices while staying performant on 43K+ documents was a core engineering challenge.
Agent Builder reliability — The ES Agent Builder is powerful but occasionally times out on complex multi-index queries. Building a robust fallback engine with 9 intent patterns that produces comparable output quality ensured the demo never breaks during a live presentation.
Balancing patient safety with AI capability — The patient-facing AI companion needed strict guardrails: never diagnose, never prescribe, detect emergencies (chest pain, extreme heart rates, syncope) and immediately direct to 911, while still being genuinely useful for health education and visit preparation.
Accomplishments that we're proud of
- A single natural language query replaces 30+ minutes of manual chart review — doctors get structured, cross-referenced answers instantly
- Server-side enrichment pipeline that transforms raw patient inputs into clinically intelligent data — auto-flagged labs, trend analysis, computed weight deltas, and NLP symptom extraction
- 43,851 documents across 6 indices with full cross-index correlation, proving Elasticsearch's power as a clinical data backbone
- 9-pattern fallback chat engine that matches Agent Builder quality
- Investigation Mode — clicking "Investigate" on any risk alert opens the AI chat with pre-loaded clinical context and tailored investigation prompts
- Document AI that extracts structured labs and vitals from photos of lab reports, complete with alias normalization and user review before indexing
- Patient-facing AI companion with voice input/output, emergency detection, and session summaries that get indexed as clinical notes visible to their doctor
What we learned
- Elasticsearch is a clinical data powerhouse — aggregations, multi-match queries, and range filters map naturally to medical queries. The Agent Builder's ability to orchestrate multi-index searches through natural language is genuinely transformative for healthcare data.
- Data enrichment is the real differentiator — any app can store a lab value; the intelligence comes from auto-flagging it, computing its trend, attaching its LOINC code, and making it queryable by an AI agent. The enrichment pipeline turned raw inputs into clinical intelligence.
- Structured data enables AI reasoning — by extracting symptoms into structured
mentioned_symptoms[]arrays and computingweight_change_7dserver-side, we made it possible for the agent to detect decompensation signals that would be invisible in unstructured text. - Fallback engines are essential for demos — relying solely on an external AI service for a hackathon demo is risky. Our custom fallback engine saved us multiple times.
What's next for CardioIQ
- FHIR integration — connect to real EHR systems (Epic, Cerner) via FHIR R4 APIs to import actual patient data instead of synthetic datasets
- Real-time alerting — Elasticsearch Watcher rules that trigger push notifications when a patient's vitals cross critical thresholds or a lab comes back flagged
- Multi-provider collaboration — shared patient views where cardiologists, PCPs, and specialists can all query the same patient data through CardioIQ's agent
- Predictive risk modeling — use Elasticsearch's ML capabilities to predict 30-day readmission risk based on vitals trends, lab trajectories, and symptom patterns
- Mobile app — a React Native patient companion for daily vitals entry, medication reminders, and instant AI chat from anywhere
- Clinical trial matching — leverage structured patient data to automatically identify candidates for cardiology clinical trials based on diagnosis, labs, and demographics
Built With
- elasticsearch
- elasticsearch-agent-builder
- express.js
- gemini-2.0-flash
- javascript
- jwt
- node.js
- python
- railway
- react
- recharts
- tailwind-css
- vite
Log in or sign up for Devpost to join the conversation.