fix: reliable cloud sync and connection pooling for Render live dashboard

This commit is contained in:
2026-09-17 16:41:52 +05:30
parent 68bda2519f
commit 37445d2ae9
8 changed files with 286 additions and 48 deletions
+30 -1
View File
@@ -657,10 +657,39 @@ async def _persist_and_forward_bg(vitals, should_persist):
patient.patient_type = vitals.patient_type
if vitals.device_id:
patient.device_id = vitals.device_id
if patient:
if not vitals.patient_id or vitals.patient_id == "UNKNOWN":
vitals.patient_id = patient.mrn or patient.patient_id
if not vitals.patient_name or vitals.patient_name == "Unknown":
vitals.patient_name = patient.name
if not vitals.patient_gender and patient.gender:
vitals.patient_gender = patient.gender
if not vitals.patient_dob and patient.dob:
vitals.patient_dob = patient.dob
if not vitals.bed_id and patient.bed_id:
vitals.bed_id = patient.bed_id
if not getattr(vitals, "patient_type", None) and getattr(patient, "patient_type", None):
vitals.patient_type = patient.patient_type
# Backfill non-null vitals from device cache so REST forwarders always get complete vitals
cached = device_cache.get(vitals.device_id)
if cached:
if vitals.heart_rate is None and cached.heart_rate is not None:
vitals.heart_rate = cached.heart_rate
if vitals.spo2 is None and cached.spo2 is not None:
vitals.spo2 = cached.spo2
if vitals.systolic_bp is None and cached.systolic_bp is not None:
vitals.systolic_bp = cached.systolic_bp
vitals.diastolic_bp = cached.diastolic_bp
vitals.map_bp = cached.map_bp
if vitals.respiratory_rate is None and cached.respiratory_rate is not None:
vitals.respiratory_rate = cached.respiratory_rate
if vitals.temperature is None and cached.temperature is not None:
vitals.temperature = cached.temperature
reading = VitalReading(
device_id=vitals.device_id,
patient_id=vitals.patient_id,
patient_id=vitals.patient_id or (patient.mrn if patient else "UNKNOWN"),
timestamp=vitals.timestamp,
heart_rate=vitals.heart_rate,
spo2=vitals.spo2,