An intelligent system for real-time ambulance routing based on patient condition, location, and hospital capacity using AI-powered decision making.
SwiftER connects ambulances with hospitals through an intelligent coordination system that:
- Captures voice reports from EMTs and converts them to structured patient data
- Analyzes patient condition, severity, and required capabilities
- Evaluates real-time hospital capacity and specializations
- Routes ambulances to the optimal hospital using AI (Wood Wide AI)
- Tracks ambulance locations in real-time on an interactive map
┌─────────────────────────────────────────────────────────────────────────────┐
│ AMBULANCE APP │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Wispr STT │→ │ Patient Form │→ │ Navigation │ │
│ │ (Voice Input) │ │ (Structured) │ │ (Turn-by-turn) │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
│ │ │ │ │
│ └────────────────────┼────────────────────┘ │
│ ↓ │
└────────────────────────────────┼─────────────────────────────────────────────┘
│ Location Updates
↓
┌─────────────────────────────────────────────────────────────────────────────┐
│ SUPABASE │
│ ┌─────────────────────────┐ ┌─────────────────────────┐ │
│ │ patient_incidents │ │ hospitals │ │
│ │ (Patient data, GPS) │ │ (Capacity, Resources) │ │
│ └─────────────────────────┘ └─────────────────────────┘ │
└────────────────────────────────────────────────────────────────────────────┘
│ │
↓ ↓
┌─────────────────────────────────────────────────────────────────────────────┐
│ BACKEND SERVICES │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────────┐ │
│ │ Reasoning Agent │ │ Capacity Agent │ │ Woodwide Reasoning Agent │ │
│ │ (NLP Extraction)│ │(Hospital Status)│ │ (AI Routing via Wood Wide) │ │
│ │ Port 8000 │ │ │ │ Port 8001 │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────────────────┘ │
└────────────────────────────────────────────────────────────────────────────┘
│
↓ Routing Decision
┌─────────────────────────────────────────────────────────────────────────────┐
│ FRONTEND APPS │
│ ┌──────────────────────────┐ ┌────────────────────────────────────────┐ │
│ │ Maps Dashboard │ │ Hospital Dashboards │ │
│ │ (Real-time tracking) │ │ (Presbyterian, Mercy, etc.) │ │
│ │ Port 5173 │ │ Ports 3001, 3002 │ │
│ └──────────────────────────┘ └────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
SwiftER/
├── apps/ # Frontend Applications
│ ├── ambulance/ # EMT tablet app
│ │ ├── src/components/ # Wispr STT, Navigation, Patient Form
│ │ └── src/services/ # API client, Supabase client
│ │
│ ├── maps-dashboard/ # Real-time ambulance tracking
│ │ ├── src/services/ # Ambulance service, Hospital API
│ │ └── src/hooks/ # Real-time location hooks
│ │
│ ├── hospital-dashboard-presbyterian/ # UPMC Presbyterian dashboard
│ └── hospital-dashboard-mercy/ # UPMC Mercy dashboard
│
├── services/ # Backend Microservices
│ └── agents/
│ ├── reasoning-agent/ # Transcription → Structured data
│ ├── capacity-agent/ # Hospital capacity management
│ └── woodwide-reasoning-agent/ # AI-powered routing decisions
│
├── infrastructure/ # Database schemas, Docker configs
├── shared/ # Shared domain models
└── docs/ # Documentation
- Node.js 18+
- Python 3.10+
- Supabase account (for database)
- Wood Wide AI API key (for routing)
- Wispr API key (for voice transcription)
git clone <repository-url>
cd SwiftERcd services/agents/reasoning-agent
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp env.example .env
# Edit .env with your OPENAI_API_KEY, SUPABASE_URL, SUPABASE_ANON_KEY
python main.pycd services/agents/woodwide-reasoning-agent
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp env.example .env
# Edit .env with WOODWIDE_API_KEY, SUPABASE_URL, SUPABASE_ANON_KEY, ROUTING_MODEL_ID
python run.pycd apps/maps-dashboard
npm install
cp env.example .env.local
# Edit .env.local with VITE_SUPABASE_URL, VITE_SUPABASE_ANON_KEY
npm run devcd apps/ambulance
npm install
cp env.example .env.local
# Edit .env.local with VITE_WISPR_API_KEY, VITE_SUPABASE_URL, etc.
npm run dev# Presbyterian
cd apps/hospital-dashboard-presbyterian
npm install
cp env.example .env.local
npm run dev
# Mercy
cd apps/hospital-dashboard-mercy
npm install
cp env.example .env.local
npm run dev| Variable | Description | Used In |
|---|---|---|
VITE_SUPABASE_URL |
Supabase project URL | All frontend apps |
VITE_SUPABASE_ANON_KEY |
Supabase anonymous key | All frontend apps |
VITE_WISPR_API_KEY |
Wispr Flow API key | Ambulance app |
VITE_API_BASE_URL |
Reasoning agent URL | Ambulance app |
VITE_WOODWIDE_API_BASE_URL |
Woodwide agent URL | Ambulance app |
WOODWIDE_API_KEY |
Wood Wide AI API key | Woodwide agent |
ROUTING_MODEL_ID |
Trained routing model ID | Woodwide agent |
SUPABASE_URL |
Supabase URL | Backend agents |
SUPABASE_ANON_KEY |
Supabase key | Backend agents |
| Column | Type | Description |
|---|---|---|
| incident_id | UUID | Primary key |
| ambulance_id | VARCHAR | Ambulance identifier |
| latitude | FLOAT | Current GPS latitude |
| longitude | FLOAT | Current GPS longitude |
| status | VARCHAR | Hospital name (when routed) |
| severity_level | INT | 1-5 severity scale |
| age | INT | Patient age |
| gender | VARCHAR | Patient gender |
| timestamp | TIMESTAMP | Last update time |
| Column | Type | Description |
|---|---|---|
| hospital_id | VARCHAR | Hospital identifier |
| hospital_name | VARCHAR | Hospital display name |
| latitude | FLOAT | Hospital location |
| longitude | FLOAT | Hospital location |
| er_beds_available | INT | Available ER beds |
| icu_beds_available | INT | Available ICU beds |
| last_updated | TIMESTAMP | Last capacity update |
- Voice-to-Text: Wispr Flow STT captures EMT reports
- Patient Form: Auto-populated structured patient data
- Live Navigation: Turn-by-turn directions to routed hospital
- Real-time Location: GPS updates sent to Supabase every 2 seconds
- Interactive Map: MapLibre GL JS with Pittsburgh focus
- Live Ambulances: Red markers showing active transports
- Hospital Status: Color-coded capacity indicators
- Click Details: Modal with patient/hospital information
- Real-time Updates: Polling every 2 seconds for ambulance positions
- AI-Powered Routing: Wood Wide AI for optimal hospital selection
- Multi-factor Analysis: Distance, ETA, capacity, patient needs
- Road Distance: OSRM integration for actual road distances (not straight-line)
- Supabase Integration: Fetches live patient and hospital data
The system uses OSRM (Open Source Routing Machine) for accurate road-based distances:
Patient Location → OSRM API → Actual Road Distance & ETA
(accounts for rivers, roads, traffic)
This is critical in Pittsburgh where straight-line distances can be misleading due to rivers and terrain.
- EMT speaks patient report → Wispr STT → Text
- Text → Reasoning Agent → Structured patient data in Supabase
- User clicks "Submit for Routing" → Woodwide Agent:
- Fetches patient data from Supabase
- Fetches hospital capacity from Supabase
- Calculates road distances via OSRM
- Runs Wood Wide AI model for optimal hospital
- Returns routing decision
- Ambulance app navigates to selected hospital
- Maps Dashboard shows ambulance moving in real-time
curl -X POST http://localhost:8001/route/from-supabase/<incident_id># Update ambulance location in Supabase
# Maps dashboard will reflect changes within 2 seconds| Layer | Technology |
|---|---|
| Frontend | React, TypeScript, Vite, TailwindCSS |
| Maps | MapLibre GL JS |
| Voice | Wispr Flow STT |
| Backend | Python, FastAPI |
| Database | Supabase (PostgreSQL) |
| AI/ML | Wood Wide AI |
| Routing | OSRM (road distances) |
[Add license information]