|
2 | 2 | import requests |
3 | 3 | import pandas as pd |
4 | 4 | import os |
| 5 | +from datetime import datetime, timedelta |
5 | 6 |
|
6 | 7 | st.set_page_config(page_title="Patient History", page_icon="🗄️", layout="wide") |
7 | 8 | API_URL = os.getenv("API_URL", "http://localhost:8000") |
8 | 9 | if "hf.space" in os.getenv("SPACE_ID", ""): |
9 | 10 | API_URL = "http://localhost:8000" |
10 | 11 |
|
11 | 12 | st.title("🗄️ Patient Prediction History") |
12 | | -st.markdown("Live database of all patient predictions and vitals logged by the system. Auto-refreshes every 5 seconds.") |
| 13 | +st.markdown("Live database of all patient predictions and vitals logged by the system. Times shown in **IST (UTC+5:30)**.") |
| 14 | + |
| 15 | +def convert_to_ist(utc_time_str): |
| 16 | + try: |
| 17 | + utc_dt = datetime.strptime(utc_time_str, "%Y-%m-%d %H:%M:%S") |
| 18 | + ist_dt = utc_dt + timedelta(hours=5, minutes=30) |
| 19 | + return ist_dt.strftime("%Y-%m-%d %H:%M:%S") |
| 20 | + except: |
| 21 | + return utc_time_str |
13 | 22 |
|
14 | 23 | DISEASE_COLORS = { |
15 | 24 | "Healthy": "background-color: rgba(0, 204, 150, 0.15); color: #00cc96;", |
@@ -43,6 +52,9 @@ def live_history_table(): |
43 | 52 | return |
44 | 53 |
|
45 | 54 | df = pd.DataFrame(history_data) |
| 55 | + if "timestamp" in df.columns: |
| 56 | + df["timestamp"] = df["timestamp"].apply(convert_to_ist) |
| 57 | + |
46 | 58 | cols = ['id', 'timestamp', 'prediction_label', 'confidence', 'heart_rate', 'spo2', 'sys_bp', 'dia_bp', 'temp', 'fall_detection'] |
47 | 59 | df = df[[c for c in cols if c in df.columns]] |
48 | 60 | df.rename(columns=COLUMN_RENAME, inplace=True) |
|
0 commit comments