# Measurements

Canonical page: https://docs.ovok.com/flutter-sdk/measurements

`ovok.measurements` turns device readings into FHIR Observations and saves them so a
reading is never lost or duplicated.

```dart
final result = await ovok.measurements.save(
  BuildObservationsParams(
    patientId: patientId,
    measurement: {
      'measurementTypeKey': 'body-weight',
      'bodyWeight': 72.4,
    },
  ),
);

if (result.status == 'queued') {
  await ovok.measurements.offlineQueue.flush();
}
```

- **Build without saving:** `build(...)` returns the Observations a measurement maps
  to, using the same codes as the other Ovok SDKs.
- **Conditional writes:** saves are conditional on the reading's identifier, so saving
  the same reading twice stores it once. Large readings are split across requests.
- **Grouped readings:** `saveObservationGroups(...)` keeps each reading together,
  sends main observations before linked members, and returns one combined bundle.
- **Offline:** a save that fails for a retryable reason is queued in the secure store
  and reported as `queued`. Call `offlineQueue.flush()` when the device is back online.
- **Reading back:** `latest`, `lastForPatient` and `codesFor` read recent values and
  the codes a measurement type uses.
