ECG
Use this category for an ECG recording, its sampled waveform, and optional associated values.
Support in @ovok/core
- Category key:
ecg(ecg) - Read: Supported through the observation mapping.
- Save: Supported through the typed measurement save workflow.
The category key selects a measurement shape. It does not determine the patient, time range, or source device. For the shared React query and save behavior, see Measurements and health data.
Data shape
The base measurement requires measurementTypeKey. Fields marked optional can be omitted when the source did not provide a value.
| Field | Type | Unit or meaning | Read and save behavior |
|---|---|---|---|
diagramPoints | number[] (optional) | mV samples | Saved as sampled data. The SDK creates timestamped segments for long recordings and joins related observations when reading. |
heartRate | number (optional) | bpm | Mapped to and from a separate heart-rate Observation. |
diagnosticResult | EcgDiagnosticFlag (optional) | Source-provided label | Saved as an interpretation label when a waveform is present; read from the recording Observation. |
duration | number (optional) | seconds | Used with waveform samples to calculate sample timing and the recorded duration. |
recordedAt | Date (optional) | Recording start time | Used as the recording timestamp. An invalid or missing date falls back to the current time. |
Diagnostic flags
The enum values and strings are:
| Enum value | Stored string |
|---|---|
REGULAR | Regular |
POOR_WAVEFORM | Poor Waveform |
LEAD_OFF | Lead Off |
HIGH_HR | High HR |
LOW_HR | Low HR |
RR_IRREGULAR | Irregular RR |
PVC | PVC |
CARDIAC_ARREST | Cardiac Arrest |
ATRIAL_FIBRILLATION | AFIB |
QRS_WIDE | QRS Wide |
QTC_LONG | QRS Long |
QTC_SHORT | QRS Short |
ERROR | ERROR |
These are supplied or stored labels, not clinical interpretation by the SDK. Display them as source results and apply your product’s own review workflow.
Waveform behavior
Provide device-captured waveform values in millivolts and a positive duration in seconds when known. The SDK uses the duration and point count to calculate sample spacing. Without a positive duration, it uses its fallback sample period. A diagnostic label and duration are attached to the waveform recording; a heart-rate-only save does not create a waveform recording.
Read this category
Select MeasurementTypeKey.ecg to map recording observations back to an EcgMeasurement. Related waveform segments are grouped into one result. The mapped values include waveform points, heart rate, diagnostic label, duration, and recording time where present.
Use useObservations() in a client-side component below OvokProvider. It returns mapped measurements, original observations, loading, and error. The hook reference describes its filters and state.
Save this category
Use diagramPoints for the sampled trace, duration for its length, and recordedAt for when recording started. The SDK may split long recordings into multiple linked observations. It does not analyze the trace or validate a diagnosis.
Pass the measurement to OvokClient.saveMeasurement() or, in React, the function returned by useSaveMeasurement(). Common request fields such as patientId and device are described in the measurement overview.
Example
This example uses the configured OvokClient from the get started guide. Supply values in the units listed above.
import { EcgDiagnosticFlag, MeasurementTypeKey } from '@ovok/core';
async function saveEcgRecording() {
return client.saveMeasurement({
measurement: {
measurementTypeKey: MeasurementTypeKey.ecg,
heartRate: 72,
diagramPoints: [0.01, 0.03, 0.02, -0.01], // Illustrative values only.
diagnosticResult: EcgDiagnosticFlag.REGULAR,
duration: 10,
recordedAt: new Date(),
},
});
}
When offline queueing is enabled, inspect the returned status. A queued result means the measurement is pending until the queue is flushed; it is not a completed server save.