Explore documentation

Document Searching

Search patterns across document resources

Set up the SDK server client to run the examples using esus. The REST examples use a session token. To run them with the SDK’s API key, send X-API-Key instead of Authorization.

Supported Search Parameters

Each document resource implements its own set of filters. Parameters not listed here are ignored (they do not cause an error), so a typo silently returns unfiltered results.

ParameterDocumentReferenceDiagnosticReportCompositionMedia
patient✓✓✓✓
status✓✓✓✓
type✓—✓✓
code—✓——
category✓✓——
date✓✓ (effectiveDateTime)✓—
encounter✓✓✓—
author✓———
result—✓——

Matching rules:

  • patient, status and (except on DocumentReference) encounter are exact matches. patient accepts <id> or Patient/<id>.
  • type, code, category, author, result (and encounter on DocumentReference) are substring matches over the stored JSON. Pass a bare code or id (type=34105-7); the system|code token form does not match.
  • date without a prefix matches the same calendar day; the gt, ge, lt, le and ne prefixes are applied (date=ge2026-04-01). Repeating the parameter combines the bounds, so date=ge2026-04-01&date=lt2026-05-01 is a closed range.

Pagination and Result Shaping

  • _count (default 20, max 100) and _offset; the Bundle includes total and a link with relation: "next" when there are more results.
  • _summary=count returns only total; _elements=a,b trims each resource to the listed top-level fields.
  • _sort is not applied by these resources: results come back in database order. Sort client-side if you need a timeline.
  • _include and _revinclude are not supported: they are accepted and ignored, and the Bundle only contains matches. Fetch the referenced Patient or Encounter with its own request.

Full-text search over file contents, chained search, and a per-resource $export are not available. For large exports use the system-level Bulk Export (see Platform Features).

Filter Examples

Discharge summaries

REST
curl "https://api.esus.health/fhir/DocumentReference?patient=3fa85f64-5717-4562-b3fc-2c963f66afa6&type=34105-7" \
  -H "Authorization: Bearer YOUR_TOKEN"
SDK
const { resources, total } = await esus.fhir.search("DocumentReference", {
  "patient": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "type": "34105-7"
});

Clinical notes by author

REST
curl "https://api.esus.health/fhir/DocumentReference?patient=3fa85f64-5717-4562-b3fc-2c963f66afa6&author=a7b1c2d3-e4f5-6789-abcd-ef0123456789" \
  -H "Authorization: Bearer YOUR_TOKEN"
SDK
const { resources, total } = await esus.fhir.search("DocumentReference", {
  "patient": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "author": "a7b1c2d3-e4f5-6789-abcd-ef0123456789"
});

Reports that include a given Observation

REST
curl "https://api.esus.health/fhir/DiagnosticReport?result=aa11bb22-cc33-dd44-ee55-ff6677889900" \
  -H "Authorization: Bearer YOUR_TOKEN"
SDK
const { resources, total } = await esus.fhir.search("DiagnosticReport", {
  "result": "aa11bb22-cc33-dd44-ee55-ff6677889900"
});

Updates, History and Optimistic Concurrency

All four resources support PUT (merge: fields you omit are kept), PATCH (partial object, application/json-patch+json or application/merge-patch+json), DELETE (204), and history via GET /:id/_history and GET /:id/_history/:vid.

PUT and PATCH responses include an ETag: W/"<versionId>" header; on reads, use meta.versionId. Send it back in If-Match and, if the resource has changed in the meantime, the write is rejected with 412 Precondition Failed. Without If-Match the write always proceeds.

Privacy and Access Control

  • Tenant isolation: every query is scoped to your organization (PostgreSQL RLS).
  • RBAC / ABAC: each request is checked against your role and policies; API keys need the matching scope (e.g. DocumentReference.read).
  • Consent: reading, updating or deleting a specific patient’s document requires an active treatment Consent for that patient (admins and API keys are exempt). Search also requires an explicit patient filter and that patient’s active treatment consent; create does not require prior consent.
  • Audit: FHIR accesses and file downloads are written to the audit trail.