Explore documentation

Find patients

Find a record by name, identifier, or other details.

The Esus FHIR API supports a pragmatic subset of the FHIR search specification: search parameters for the most common clinical and administrative fields, combined filters, and offset-based pagination. Advanced features such as custom search modifiers (:exact, :contains) and chained search are not supported today.

Set up the SDK server client to run the examples using esus.

Get all patients (paginated):

REST
curl -X GET https://api.esus.health/fhir/Patient \
  -H "Authorization: Bearer YOUR_TOKEN"
SDK
const { resources, total } = await esus.fhir.search("Patient");

Response (Bundle):

{
  "resourceType": "Bundle",
  "type": "searchset",
  "total": 2,
  "entry": [
    {
      "resource": {
        "resourceType": "Patient",
        "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "name": [{ "family": "Smith", "given": ["John"] }]
      }
    },
    {
      "resource": {
        "resourceType": "Patient",
        "id": "b8c2d3e4-f5a6-7890-bcde-f01234567890",
        "name": [{ "family": "Johnson", "given": ["Mary"] }]
      }
    }
  ]
}

Search Parameters

By Name

REST
# Patients with "Smith" anywhere in their name
GET /fhir/Patient?name=Smith

# Several words: all of them must match
GET /fhir/Patient?name=John%20Smith
SDK
await esus.fhir.search("Patient", { name: "Smith" });
await esus.fhir.search("Patient", { name: "John Smith" });

Names are encrypted, so search compares whole words: it ignores case but not accents, and Smi does not find Smith. given and family behave like name (they match any part of the name).

By Identifier

REST
# By value
GET /fhir/Patient?identifier=30123456

# By system and value
GET /fhir/Patient?identifier=urn:oid:2.16.32.1.2.1|30123456
SDK
await esus.fhir.search("Patient", { identifier: "30123456" });
await esus.fhir.search("Patient", {
  identifier: "urn:oid:2.16.32.1.2.1|30123456",
});

Matching is exact: 3012 does not find 30123456. The same applies to phone (only digits are compared) and email.

By Gender and Birth Date

Birth-date supports the standard FHIR date prefixes (eq, ne, gt, lt, ge, le):

REST
# Male patients born after 1990-01-01
GET /fhir/Patient?gender=male&birthdate=gt1990-01-01

# Born in the 1990s (repeat the parameter for a range)
GET /fhir/Patient?birthdate=ge1990-01-01&birthdate=lt2000-01-01
SDK
await esus.fhir.search("Patient", { gender: "male", birthdate: "gt1990-01-01" });
await esus.fhir.search("Patient", {
  birthdate: ["ge1990-01-01", "lt2000-01-01"],
});

Pagination

Pagination is offset-based. Use _count to control page size (20 by default, 100 at most) and _offset to skip results.

REST
# First page, 20 items
GET /fhir/Patient?_count=20

# Next page (offset by one page)
GET /fhir/Patient?_count=20&_offset=20
SDK
const first = await esus.fhir.search("Patient", { _count: 20 });
const next = await first.next?.();

The Bundle includes navigation links (self, next, and previous). These URLs keep your search filters (for example name) plus the page’s _count and _offset, so you can follow link.next until it is absent.

{
  "link": [
    { "relation": "self", "url": "/fhir/Patient?_count=20&_offset=0" },
    { "relation": "next", "url": "/fhir/Patient?_count=20&_offset=20" }
  ]
}

Common Search Parameters

ParameterDescription
_idFilter by resource id (UUID)
_countPage size (items per response)
_offsetItems to skip (for pagination)
name, given, familySearch by whole words of the name
genderFilter by administrative gender
birthdateFilter by date of birth, with date prefixes
identifierSearch by external identifier (value or system|value)
phoneSearch by phone number
emailSearch by email
telecomSearch by phone or email: matches an email (exact, case-insensitive) or a phone number (digits only)
activeFilter by active/inactive status

Next Steps

Next, learn how to update and delete test records.