updated with new file names

This commit is contained in:
Raika Furude 2025-10-18 18:25:25 -04:00
parent f5421a1f21
commit 0ea742df99
3 changed files with 1390 additions and 8 deletions

View File

@ -9,6 +9,7 @@
VitalLink is an intelligent ER patient monitoring system that uses smart wristbands to continuously track patient vital signs and automatically prioritize care based on real-time health data. The system supports both physical BLE wristbands and simulated devices for testing and demonstration.
### Key Features
- ✅ **Real-time vital sign monitoring** (Heart Rate, SpO₂, Temperature, Activity)
- ✅ **Automatic patient prioritization** based on condition severity
- ✅ **Three-tier alert system** (Normal, Alert, Emergency)
@ -21,6 +22,7 @@ VitalLink is an intelligent ER patient monitoring system that uses smart wristba
---
## 📁 Project Structure
```
vitallink/
├── backend/ # Backend API Server
@ -59,7 +61,7 @@ vitallink/
├── .venv/ # Python virtual environment (UV)
├── requirements.txt # Python dependencies
├── start_everything.sh # Master startup script
├── link-start.sh # Master startup script
├── stop_everything.sh # Master shutdown script
└── README.md # This file
```
@ -67,6 +69,7 @@ vitallink/
---
## 🔄 System Architecture & Data Flow
```
┌─────────────────────────────────────────────────────────────────┐
│ PATIENT CHECK-IN FLOW │
@ -119,9 +122,11 @@ vitallink/
### Backend (`backend/`)
#### `server.py`
**Purpose:** Core backend API server
**Technology:** FastAPI + Uvicorn
**Key Functions:**
- Patient registration and management
- Vital signs data ingestion and storage
- Priority queue calculation algorithm
@ -129,6 +134,7 @@ vitallink/
- RESTful API endpoints for all operations
**Main Endpoints:**
- `POST /api/checkin` - Register new patient
- `POST /api/vitals` - Receive vital signs data
- `GET /api/queue` - Get prioritized patient queue
@ -142,9 +148,11 @@ vitallink/
### Wristband System (`simulator/`)
#### `wristband_simulator.py`
**Purpose:** Original standalone wristband simulator
**Technology:** Python asyncio
**Key Functions:**
- Generates realistic vital sign data
- Simulates 5 patient condition profiles (stable, deteriorating, critical, etc.)
- Creates proper 16-byte BLE packets with checksums
@ -155,9 +163,11 @@ vitallink/
---
#### `wristband_manager.py`
**Purpose:** Unified wristband management system
**Technology:** Python asyncio + Bleak (for BLE)
**Key Functions:**
- **Manages both real and simulated wristbands** with identical interface
- Scans for real BLE devices
- Decodes 16-byte packets according to spec
@ -165,6 +175,7 @@ vitallink/
- Auto-assigns wristbands to new patients
**Key Classes:**
- `BaseWristband` - Abstract interface for all wristbands
- `RealWristband` - Connects to physical BLE devices
- `SimulatedWristband` - Software simulation for testing
@ -174,15 +185,18 @@ vitallink/
---
#### `config_system.py`
**Purpose:** Configuration management and CLI tools
**Technology:** Python + PyYAML
**Key Functions:**
- Loads wristband inventory from YAML config
- Command-line tools for managing wristbands
- BLE device scanning and discovery
- Add/remove wristbands without code changes
**CLI Commands:**
```bash
python config_system.py --inventory # Show configured wristbands
python config_system.py --scan # Scan for real BLE devices
@ -192,9 +206,11 @@ python config_system.py --add-simulated # Add a simulated wristband
---
#### `main_runner.py`
**Purpose:** Main system orchestrator
**Technology:** Python asyncio
**Key Functions:**
- **Auto-detects new patient check-ins** from backend
- **Auto-assigns wristbands** (prefers real, falls back to simulated)
- Creates emergency simulated bands if inventory depleted
@ -206,9 +222,11 @@ python config_system.py --add-simulated # Add a simulated wristband
---
#### `wristband_config.yaml`
**Purpose:** Wristband inventory configuration
**Technology:** YAML configuration file
**Structure:**
```yaml
backend_url: "http://localhost:8000"
auto_scan_ble: true # Scan for real bands on startup
@ -230,9 +248,11 @@ real_bands: # Physical BLE devices
### Frontend (`frontend/`)
#### `dashboard/src/App.jsx`
**Purpose:** Staff monitoring dashboard
**Technology:** React + Vite + Tailwind CSS
**Key Features:**
- **Patients Tab:**
- Real-time vital signs display
- Color-coded alert tiers (🟢 Normal, 🟡 Alert, 🔴 Emergency)
@ -246,30 +266,34 @@ real_bands: # Physical BLE devices
- Decoded packet fields
- Flag visualization (emergency, alert, battery, etc.)
**Port:** http://localhost:5173
**Port:** <http://localhost:5173>
---
#### `kiosk/src/App.jsx`
**Purpose:** Patient self-service check-in
**Technology:** React + Vite + Tailwind CSS
**Key Features:**
- User-friendly check-in wizard
- Symptom selection
- Severity rating
- Wristband assignment confirmation
- Next steps guidance
**Port:** http://localhost:5174
**Port:** <http://localhost:5174>
---
### Tests (`tests/`)
#### `test_suite.py`
**Purpose:** Comprehensive system testing
**Technology:** Python asyncio
**Test Coverage:**
- Patient data validation
- Packet generation and checksums
- Tier classification logic
@ -284,9 +308,11 @@ real_bands: # Physical BLE devices
### Scripts
#### `start_everything.sh`
#### `link-start.sh`
**Purpose:** Master startup script - **ONE COMMAND TO START ENTIRE SYSTEM**
**What it does:**
1. ✅ Activates Python virtual environment
2. ✅ Starts backend API server (port 8000)
3. ✅ Starts wristband management system
@ -299,8 +325,10 @@ real_bands: # Physical BLE devices
---
#### `stop_everything.sh`
**Purpose:** Clean shutdown of all services
**What it does:**
1. Stops backend server
2. Stops wristband system
3. Stops frontend dev servers
@ -313,6 +341,7 @@ real_bands: # Physical BLE devices
## 🔗 How Components Connect
### 1. Patient Check-In Flow
```
Kiosk (React)
→ POST /api/checkin
@ -323,6 +352,7 @@ Kiosk (React)
```
### 2. Vital Signs Data Flow
```
Wristband (Real or Simulated)
→ Generates 16-byte BLE packet
@ -334,6 +364,7 @@ Wristband (Real or Simulated)
```
### 3. Priority Queue Flow
```
Backend calculates priority scores every 3 seconds based on:
- Tier (Emergency=100, Alert=50, Normal=0)
@ -346,6 +377,7 @@ Backend calculates priority scores every 3 seconds based on:
```
### 4. Wristband Inventory Flow
```
Main Runner reports inventory every 10 seconds:
→ POST /api/wristband-details (full inventory + packet data)
@ -376,22 +408,26 @@ Main Runner reports inventory every 10 seconds:
## 🚀 Quick Start
### 1. Start Everything
```bash
./start_everything.sh
```
### 2. Access Interfaces
- **Staff Dashboard:** http://localhost:5173
- **Check-in Kiosk:** http://localhost:5174
- **API Documentation:** http://localhost:8000/docs
- **Staff Dashboard:** <http://localhost:5173>
- **Check-in Kiosk:** <http://localhost:5174>
- **API Documentation:** <http://localhost:8000/docs>
### 3. Test the System
1. Open kiosk, check in a patient
2. Watch dashboard - patient appears with assigned wristband
3. Click "Wristbands" tab to see inventory
4. Click any wristband to view raw packet data
### 4. Stop Everything
```bash
./stop_everything.sh
```
@ -401,7 +437,9 @@ Main Runner reports inventory every 10 seconds:
## 🔧 Configuration
### Adding Simulated Wristbands
Edit `simulator/wristband_config.yaml`:
```yaml
simulated_bands:
- band_id: "MOCK-SIM4"
@ -409,11 +447,15 @@ simulated_bands:
```
### Adding Real Wristbands
1. Scan for devices:
```bash
python simulator/config_system.py --scan
```
2. Add to config when prompted, or manually:
```yaml
real_bands:
- band_id: "VitalLink-A3B2"
@ -421,6 +463,7 @@ simulated_bands:
```
### Changing Priority Preferences
```yaml
prefer_real_bands: true # Use real bands first
auto_scan_ble: true # Scan on startup
@ -446,6 +489,7 @@ VitalLink wristbands transmit 16-byte packets over BLE:
| 15 | Reserved | uint8 | Future use |
**Example Packet:**
```
01 2A 00 87 D6 12 00 02 4E 61 3D 0E B4 00 BA 00
```
@ -457,7 +501,9 @@ VitalLink wristbands transmit 16-byte packets over BLE:
## 📝 Development Notes
### For Hardware Integration
When you get physical wristbands:
1. Power on wristbands (remove from charger)
2. Run: `python simulator/config_system.py --scan`
3. Add discovered bands to config
@ -465,12 +511,16 @@ When you get physical wristbands:
5. Restart system - real bands will be used automatically!
### Mixed Mode Testing
You can run **1 real + 5 simulated** simultaneously:
- Real wristband: For actual patient (you wearing it)
- Simulated: For demo patients with various conditions
### Packet Debugging
View raw packets in real-time:
1. Dashboard → Wristbands tab
2. Click any active wristband
3. See hex dump + decoded fields
@ -481,6 +531,7 @@ View raw packets in real-time:
## 🎓 For Capstone Presentation
### Demo Flow
1. **Start system:** `./start_everything.sh`
2. **Show kiosk:** Check in yourself as a patient
3. **Show dashboard:** You appear in queue with assigned wristband
@ -491,6 +542,7 @@ View raw packets in real-time:
8. **Show priority queue:** Emergency patients automatically moved to top
### Key Talking Points
- ✅ Real-time vital sign monitoring
- ✅ Automatic triage prioritization
- ✅ Seamless real/simulated wristband mixing
@ -503,7 +555,7 @@ View raw packets in real-time:
## 📚 Additional Resources
- **BLE Protocol Details:** See uploaded specification document
- **API Documentation:** http://localhost:8000/docs (when running)
- **API Documentation:** <http://localhost:8000/docs> (when running)
- **Wristband Inventory:** `python simulator/config_system.py --inventory`
- **System Logs:** `tail -f logs/*.log`

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,133 @@
⚠️ Bleak not installed. Real wristbands disabled. Install with: pip install bleak
✓ Loaded configuration from wristband_config.yaml
================================================================================
VitalLink System Initialization
================================================================================
✓ Backend is running at http://localhost:8000
Added simulated band MOCK-SIM1 (stable)
Added simulated band MOCK-SIM2 (mild_anxiety)
Added simulated band MOCK-SIM3 (deteriorating)
================================================================================
WRISTBAND INVENTORY
================================================================================
🟢 MOCK-SIM1 | AVAILABLE
🟢 MOCK-SIM2 | AVAILABLE
🟢 MOCK-SIM3 | AVAILABLE
================================================================================
Total: 3 | Real: 0 | Simulated: 3 | Active: 0
================================================================================
================================================================================
VitalLink System Running
================================================================================
✓ Monitoring for new patients from kiosk check-ins
✓ Auto-assigning wristbands (prefer real: False)
Press Ctrl+C to stop
================================================================================
🔍 Monitoring for new patient check-ins...
[Status] Active: 0 monitoring | Available: 3 bands | Real: 0 | Sim: 3
[Status] Active: 0 monitoring | Available: 3 bands | Real: 0 | Sim: 3
[Status] Active: 0 monitoring | Available: 3 bands | Real: 0 | Sim: 3
🆕 New patient detected: P100001 (test bbb)
✓ MOCK-SIM1 assigned to patient P100001
✓ Assigned MOCK-SIM1 (simulated)
🟢 Starting simulated wristband MOCK-SIM1 (stable)
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3
[Status] Active: 1 monitoring | Available: 2 bands | Real: 0 | Sim: 3