Understanding FHIR search

Last updated: Jul 25, 2024
DEVELOPER
PRODUCT OWNER
HEALTH TECH VENDOR

If there were a popularity contest among all the available FHIR® interactions and operations, the clear winner would be a search interaction. Learn the difference between interactions and operations.

In other words, search is the most widely supported and versatile type of interaction, meaning that you can search for most resources.

POST versus GET

Redox supports the POST method for searching. We use POST because it allows for encoded search parameters in the request body instead of the search URL (like a GET method uses).

HL7 recommends the POST method because it mitigates the risk of leaking sensitive information, like PHI, in the request’s URL.

Search parameters

To perform a search, you can populate a request with relevant parameters, using prefixes or modifiers to hone your search. You can also combine parameters to use chained or composite parameters.

When the search parameter matches a path found in one or more resources, those resources are returned as a bundle in a response. Parameters can match one element or many elements in multiple places, as well as derived values. Whenever there’s matching content in any path, the whole resource is returned. You may need to examine the resource to determine which path contains the match.

Some search parameters apply to all resources. Redox supports these parameters for all resources:

Search parameter
Notes
_id
The logical id of the resource, which can be used when specifying the resource type.

The rest are resource-specific parameters.

You can use these to specify your search parameters further:

  • Prefixes
  • Modifiers
  • Chained parameters
  • Composite parameters
  • Result parameters

Responses

The response to your search contains a bundle of resources.

An empty result (i.e., a bundle with zero entries) means that there weren’t any resources that matched the search criteria.

If there’s an error of any kind, you receive an HTTP status code (4XX or 5XX). Then the response body is an OperationOutcome resource with an error description.

Some FHIR® searches may find more results than should reasonably be returned at one time. To avoid lengthy responses, FHIR® relies on pagination, which groups search results into pages. Learn more about FHIR® pagination.

The query response will contain a link array with links to pages that can be fetched using a GET or POST request against that URL. You can't use additional parameters with a pagination query.

You can see how FHIR® pagination links resolve to Redox-centric links in log inspector. Learn about FHIR® pagination resolvers.