Offline measurements
The measurement queue is opt-in. When enabled, saveMeasurement() and saveObservations() persist their transaction entries through the configured client storage adapter and try to send them. If a write is still pending, the method returns a queue id so the host app can report that state.
Enable the queue
const client = new OvokClient({
baseUrl: 'https://api.sandbox.ovok.com',
fhirUrlPath: '/fhir/R4/',
storage, // A durable client storage adapter.
offlineQueue: {
enabled: true,
},
});
The queue requires durable storage. Without it, enabling the queue fails instead of silently storing clinical data in memory.
Handle the save result
const result = await client.saveMeasurement(measurementInput);
if (result.status === 'saved') {
showSaved();
} else {
showWaitingToSync(result.queueId);
}
When the device reconnects or the app resumes, flush pending entries:
const flush = await client.flushOfflineMeasurementQueue();
// flush.saved, flush.queued, flush.exhausted, flush.attempted
The host app owns connectivity and resume listeners. The SDK does not start background work by itself.
Retry behavior
The queue uses stable identifiers and conditional Observation creates so a retry after a timeout or process restart does not create a second copy of the same reading. Retry counts and backoff can be configured with maxRetries, retryBackoffMs, and maxRetryBackoffMs. Keep retries bounded and surface entries that have exhausted their attempts for support or reconciliation.
Use flushOfflineMeasurementQueue({ includeExhausted: true, resetExhausted: true }) only when the app has an explicit recovery action. A routine reconnect should use the default flush options.
Queued records contain health data. Select storage, backup, device sharing, and deletion behavior for the app's privacy requirements. Review the project's security requirements alongside FHIR basics and authentication.