Searching & Filtering

Most FHIR resources in the Health Gorilla API support search operations using query parameters. This allows clients to retrieve only the relevant subset of records for a specific patient or clinical context.

A FHIR search is typically performed using the pattern:
GET /[ResourceType]?[parameter]=[value]

For example, the query
GET /Observation?patient=123456&code=72166-2
returns observation records for patient 123456 where the LOINC code corresponds to “Body temperature”.

Required Parameter: patient

For nearly all clinical resources, the patient parameter is required to scope the query. This ensures data isolation and returns only those resources linked to the specified patient.

Common Parameter Types

TypeDescriptionExample
tokenCoded values (status, code, category)status=active
referenceLinked resource IDpatient=Patient/12345
dateTemporal filters on clinical eventsrecordedDate=ge2023-01-01
stringText-based search on names or identifiersname=smith
quantityNumeric search values (used rarely)value-quantity=gt5.0

Date Filtering

Date parameters support prefixes for range-based filtering:

PrefixMeaningExample
eqEqual tobirthdate=eq1980-01-01
geGreater than or equal torecordedDate=ge2022-01-01
leLess than or equal toonset=le2023-12-31

If no prefix is provided, FHIR treats the date as eq by default.

Multiple Values

To search for multiple values, use comma separation (a logical OR): GET /Condition?clinicalStatus=active,recurrence

To require all values (logical AND), repeat the parameter: GET /Condition?code=12345&code=67890

Modifier Support

Some parameters support modifiers that change how values are interpreted:

ModifierDescriptionExample
:exactMatch value exactlyname:exact=Smith
:containsMatch substringscode:contains=lipid
:notExclude a specific valueclinicalStatus:not=resolved

Not all modifiers are supported across all resource types.

Combining Parameters

All parameters in a query are combined using a logical AND, for example: GET /Observation?patient=12345&code=72166-2&date=e2023-01-01. This returns observations that match all three criteria.

Best Practices

  • Always include patient in patient-scoped queries
  • Use coded values (status, code, category) whenever possible
  • Use date ranges rather than exact dates to avoid missing records
  • Avoid overly broad queries — they may be paginated or rate-limited