Wearables
Loop Health integrates with multiple wearable devices and continuous glucose monitors to provide a complete picture of a patient’s daily health metrics. Wearable data contributes 40% of the composite health score.
Supported Devices
| Device | Type | Metrics | OAuth |
|---|---|---|---|
| Oura Ring | Smart ring | Sleep, readiness, activity, HRV | OAuth 2.0 |
| Whoop | Fitness band | Recovery, strain, sleep, HRV, workouts | OAuth 2.0 |
| Dexcom CGM | Glucose monitor | Continuous glucose readings | OAuth 2.0 |
| Libre CGM | Glucose monitor | Continuous glucose readings | OAuth 2.0 |
Future support is planned for Garmin, Fitbit, and Apple Health.
Architecture
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Oura API │ │ Whoop API │ │ Dexcom API │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
│ │ │
▼ ▼ ▼
┌──────────────────────────────────────────────────────────┐
│ OAuth Token Storage │
│ patient_graph.wearable_data │
└──────────────────────────┬───────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────┐
│ Trigger.dev Sync Jobs │
│ syncWearablesDaily · syncWhoopData · syncCgmReadings │
└──────────────────────────┬───────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────┐
│ patient_graph.wearable_data │
│ patient_wearable_readings · patient_wearable_daily_stats │
└──────────────────────────┬───────────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
Health Score Luna AI Dashboard
(40% weight) Insights VisualizationsData Flow
- Connect — User initiates OAuth flow from the consumer app
- Authorize — User authorizes Loop Health on the device provider’s site
- Callback — OAuth tokens received and stored in the Patient Graph
- Sync — Trigger.dev jobs run daily (3 AM UTC) to fetch latest data
- Store — Metrics stored in
wearable_datatable with device source and type - Aggregate — Daily stats computed and stored in
patient_wearable_daily_stats - Score —
@loop/health-scoreincorporates wearable data (40% weight) - Insights — Luna AI accesses data via
getWearableInsightstool
Metrics Collected
| Metric Type | Devices | Description |
|---|---|---|
sleep | Oura, Whoop | Duration, efficiency, stages, latency |
recovery | Oura, Whoop | Recovery score, readiness |
hrv | Oura, Whoop | Heart rate variability (ms) |
activity | Oura, Whoop | Active calories, steps, activity score |
strain | Whoop | Daily strain (0–21 scale) |
glucose | Dexcom, Libre | Continuous glucose (mg/dL) |
readiness | Oura | Readiness score (0–100) |
Database Schema
wearable_data
Stores raw wearable metrics with source attribution:
| Column | Type | Description |
|---|---|---|
id | uuid | Record ID |
customerId | uuid | Patient ID |
source | enum | Device source (oura, whoop, dexcom, etc.) |
metricType | enum | Metric type (sleep, recovery, hrv, etc.) |
metrics | jsonb | Device-specific metric values |
recordedAt | timestamp | When the data was recorded |
patient_wearable_daily_stats
Aggregated daily statistics for dashboard display and trend analysis.
patient_wearable_readings
Individual readings (primarily used for CGM data points).