-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhealth_metrics.py
More file actions
40 lines (33 loc) · 1.43 KB
/
health_metrics.py
File metadata and controls
40 lines (33 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import math
class HealthMetrics:
@staticmethod
def calculate_all(bpm, spo2):
"""
Calculates estimated health parameters based on BPM and SpO2.
Note: These are mathematical estimations for research purposes.
"""
metrics = {}
# 1. Estimated Glucose Level (mg/dL)
# Research shows a statistical correlation between HR and glucose.
# Simplified linear model for estimation:
metrics['glucose'] = round((bpm * 0.5) + 65.0, 2)
# 2. Perfusion Index (PI) - Estimated
# Usually derived from AC/DC ratio; estimated here based on pulse stability
# Normal range is 0.02% to 20%
metrics['pi'] = round(max(0.1, (spo2 / bpm) * 1.5), 2)
# 3. Heart Rate Variability (HRV) - Estimated
# HRV usually has an inverse relationship with resting heart rate.
# Formula: Estimated RMSSD (ms)
metrics['hrv'] = round(60000 / (bpm * 1.2), 2)
# 4. Respiratory Rate (RR) - Estimated
# Normal adults: 12-20 breaths per minute.
# Often approx 1/4 of heart rate at rest.
metrics['respiratory_rate'] = round(bpm / 4.5, 1)
# 5. Hypoxia Status
if spo2 >= 95:
metrics['status'] = "Normal"
elif 90 <= spo2 < 95:
metrics['status'] = "Mild Hypoxia"
else:
metrics['status'] = "Consult Doctor"
return metrics