Namespaces

ovok.fhir

Read, search, write and batch FHIR resources through the Ovok API.

  • Stable unknown
  • Release candidate since 0.4.49-rc.4
  • Development since 0.4.49-dev.517+4645a0a

Typed FHIR R4 access for any app. The FHIR base path comes from the client's fhirPath option (default fhir). What a user can see or change is decided by their access policy on the server.

const patient = await ovok.fhir.read('Patient', id);

const page = await ovok.fhir.search('Observation', { patient: `Patient/${id}`, _count: 50 });

for await (const observation of ovok.fhir.search('Observation', { patient: `Patient/${id}` })) {
  // every page, fetched as you go
}

const first = await ovok.fhir.searchOne('Patient', { identifier: 'urn:mrn|123' });
  • search returns a PagePromise: await it for { data, hasMore, total }, or for await for every item.
  • Included resources are left out of data.
  • A list value repeats its parameter, which FHIR reads as AND: date: ['ge2026-01-01', 'le2026-02-01']. For OR, write one comma-separated string.
  • searchOne returns the first match or null.

Create, update, patch, delete

await ovok.fhir.create(observation, { ifNoneExist: 'identifier=urn:device|42' });
await ovok.fhir.update(patient);
await ovok.fhir.patch('Patient', id, [{ op: 'replace', path: '/active', value: false }]);
await ovok.fhir.delete('Patient', id);
  • update replaces the resource and throws OvokValidationError when it has no id.
  • create with ifNoneExist is a conditional create. A retry cannot duplicate it, so it is retried after a network failure. A plain create is not.
  • patch takes JSON Patch operations.

Batch and transaction bundles

const result = await ovok.fhir.batch(bundle);
  • Posts the bundle to the FHIR base and returns the response bundle. Set bundle.type to batch or transaction.
  • Check each entry's response.status in the result; a batch can succeed in part.

React

useResource, useSearch and useSubscription from @ovok/core/next/react wrap these calls. See React.

Reference

Last updated on

On this page