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.
Read and search
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' });searchreturns aPagePromise: await it for{ data, hasMore, total }, orfor awaitfor 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. searchOnereturns the first match ornull.
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);updatereplaces the resource and throwsOvokValidationErrorwhen it has noid.createwithifNoneExistis a conditional create. A retry cannot duplicate it, so it is retried after a network failure. A plaincreateis not.patchtakes 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.typetobatchortransaction. - Check each entry's
response.statusin the result; a batch can succeed in part.
React
useResource, useSearch and useSubscription from @ovok/core/next/react wrap these calls. See React.
Reference
- fhir API reference: every method and type.
- ovok.realtime: subscribe to FHIR changes.
- ovok.measurements: saving readings safely.
- Errors and retries
Last updated on