Files
ContecMonitor/fiveparaminte-main/schemas.py
T
prathiyuman 14f3d45e53 feat: real ECG/Pleth waveform streaming + clinical monitor UI redesign
- schemas.py: Add ecg_wave and pleth_wave List[int] fields to NormalizedVitals
- contec_parser.py: Extract raw 8-bit waveform samples from binary packets
  - 286/288-byte (Subtype 21): bytes[8..263] = Pleth waveform (256 samples)
  - 989-byte (Subtype 20): bytes[8..903] = ECG waveform, downsampled 4x -> 224 pts
- dashboard.html: Full clinical monitor redesign
  - Scrolling sweep waveform engine (ECG green, Pleth cyan, Resp amber)
  - Real samples fed from WebSocket ecg_wave / pleth_wave arrays
  - Synthetic fallbacks when no live data
  - Right panel: HR, SpO2, RR, NIBP, Temp with range badges
  - MRN-only verification overlay
  - Minimal-mode support for iframe embedding
2026-07-15 13:37:14 +05:30

46 lines
1.5 KiB
Python

from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime
class NormalizedVitals(BaseModel):
device_id: str
patient_id: str
timestamp: datetime
ip_address: Optional[str] = None
heart_rate: Optional[float] = None
spo2: Optional[float] = None
systolic_bp: Optional[float] = None
diastolic_bp: Optional[float] = None
map_bp: Optional[float] = None
respiratory_rate: Optional[float] = None
temperature: Optional[float] = None
present_fields: Optional[list] = None
# Raw waveform sample arrays (8-bit unsigned, 0-255)
ecg_wave: Optional[List[int]] = None # ECG waveform samples from 989-byte packet
pleth_wave: Optional[List[int]] = None # Pleth/SpO2 waveform samples from 286/288-byte packet
# Patient demographics parsed from HL7 PID/PV1 segments
patient_name: Optional[str] = None # PID-5: "Given Family"
patient_gender: Optional[str] = None # PID-8: M / F / U
patient_dob: Optional[str] = None # PID-7: YYYYMMDD
bed_id: Optional[str] = None # PV1-3: bed / room ID
class DeviceStatus(BaseModel):
device_id: str
ip_address: str
status: str
last_seen: datetime
class Config:
from_attributes = True
class TransmissionLogResponse(BaseModel):
id: int
reading_id: int
status: str
response_code: Optional[int]
error_message: Optional[str]
timestamp: datetime
class Config:
from_attributes = True