usePatientDeviceTelemetryHistory
Loads historical telemetry observations for one device.
When to use it
An undefined device ID disables the request; use the history query to scope time range and paging.
Setup
Call it from a client-side React component below OvokProvider so it uses the client configured at that provider boundary.
Hook arguments
| Argument | Type | Details |
|---|---|---|
deviceId | string | undefined | Device ID; pass undefined to keep the request disabled. |
params (optional) | OvokPatientTelemetryHistoryQuery | Optional time-range and paging controls. |
TypeScript signature
(deviceId: string | undefined, params?: OvokPatientTelemetryHistoryQuery): OvokRequestState<OvokPatientTelemetryHistory>
Request state
The response payload is OvokPatientTelemetryHistory. A successful empty result, a failed request, and a request that has not returned data are distinct states.
| Field | Meaning |
|---|---|
data | Latest successful response, or undefined before one is available. |
loading | Whether the request is in progress. |
error | Request error as an Error, or undefined when no request has failed. |
reload | Repeats the request with the current arguments. |
Request behavior
The hook loads when its required inputs are available and reloads when those inputs change. Use reload for an explicit refresh; render loading, error, and successful no-result states separately.
Example
Handle the hook's loading and error states before rendering the result.
import { usePatientDeviceTelemetryHistory } from '@ovok/core';
export function PatientDeviceTelemetryHistoryExample({ deviceId, params }: { deviceId: Parameters<typeof usePatientDeviceTelemetryHistory>[0]; params?: Parameters<typeof usePatientDeviceTelemetryHistory>[1] }) {
const { data, loading, error, reload } = usePatientDeviceTelemetryHistory(deviceId, params);
if (loading) return <p>Loading…</p>;
if (error) return <p role="alert">{error.message}</p>;
return <section><button onClick={reload}>Reload</button><pre>{JSON.stringify(data, null, 2)}</pre></section>;
}
Related
- Generated API reference for overloads and exact input and response types.
- React applications for provider setup and application patterns.
- Hook guide index for related hooks.