Skip to main content

Health data import

The @ovok/native/data-sync subpath provides authorization components and import components for Apple HealthKit and Android Health Connect. Import is opt-in: the app chooses which data types to read, explains the permission request, and handles authorization state.

Health import uses the active OvokClient and patient profile from @ovok/core. It does not choose a patient, persist credentials for the app, or replace project access rules.

Map source records​

dataToSync maps an Ovok measurement key to one or more platform identifiers and an Observation code. Set the terminology system explicitly when the code belongs to one; do not infer a code system from the shape of the code.

import { HKQuantityTypeIdentifier } from '@kingstinct/react-native-healthkit';

const dataToSync = {
bodyWeight: {
typeIdentifiers: [
{
typeIdentifier: HKQuantityTypeIdentifier.bodyMass,
code: '29463-7',
system: 'http://loinc.org',
},
],
minDate: new Date('2026-01-01T00:00:00.000Z'),
},
};

Use HealthKit identifiers on iOS and Health Connect record types on Android. The app remains responsible for declaring and requesting the matching read permissions.

Compose authorization and sync​

import { DataSync } from '@ovok/native/data-sync';

export function HealthImport() {
return (
<DataSync.AppleHealthAuthorizationProvider
readIdentifiers={iosReadIdentifiers}
onAuthorizationStatusChange={setAuthorization}
fallback={<LoadingState />}
>
<DataSync.AppleHealthSync
dataToSync={iosDataToSync}
chunkSize={500}
onProgress={setProgress}
onError={setError}
/>
</DataSync.AppleHealthAuthorizationProvider>
);
}

Use the Android authorization and sync components for Health Connect. Each platform requires its own identifier types and native permission declarations; do not reuse the iOS mapping on Android without adapting it.

Import behavior to plan for​

  • minDate sets the initial read boundary. Later imports use server watermarks to avoid rereading the same history unnecessarily.
  • Daily totals and summaries can omit the current day while its total is still changing.
  • Session records such as sleep and workouts are represented as separate observations.
  • Platform source details are retained when available; unsupported record shapes may require an explicit application mapping.
  • A permission result is a UI state, not proof that records exist on the device.

Health records are sensitive. Request only the data the feature needs, explain the purpose, and provide a clear way to stop importing. See FHIR basics for how Ovok represents observations.