< Back

Patient Queries

Health Gorilla APIs provide two main approaches for retrieving data for an individual patient:

  • The $everything operation returns a consolidated Bundle of all FHIR resources associated with the patient.
  • Patient-specific queries retrieve targeted resource types such as medications, conditions, lab results, and documents using standard FHIR search operations.

Together, these methods support both complete record assembly and focused data access for care, analytics, and reporting.

$everything Operation

The $everything operation is available in Health Gorilla’s FHIR R4 and STU3 APIs. It returns a Bundle containing all resources for a patient, including data previously retrieved through $p360-retrieve. Use $everything to assemble a complete, paginated record for downstream use.

Use Cases

  • Combine all retrieved FHIR resources into one structured response, simplify export or downstream processing
  • Prepare patient data for export, transformation, or storage, reduce the number of individual queries
  • Retrieve data in bulk following a $p360-retrieve operation, assemble a complete longitudinal view

FHIR Version Support

FHIR Version$everything
R4Supported
STU3Supported

Request Format

Submit a GET request to the patient-scoped operation. You may include parameters such as _since to filter by last updated date and _count to control page size.

  • R4 Example: GET /fhir/4.0.1/Patient/{id}/$everything?_since={isoDateTime}&_count={n}
  • STU3 Example: GET /fhir/3.0.1/Patient/{id}/$everything?_since={isoDateTime}&_count={n}

Behavior

  • Returns all resources associated with the patient in a paginated Bundle, including Bundle.link navigation for subsequent pages
  • Includes previously aggregated content from $p360-retrieve, normalized and deduplicated where applicable
  • Large result sets should be retrieved incrementally using the next link in the returned Bundle

Operational Guidance

  • Run $everything only after the corresponding $p360-retrieve job completes successfully
  • Expect large payloads for patients with extensive histories; plan for pagination and backoff
  • Respect rate limits and timeouts defined for your environmenttimeouts defined for your environment

Patient-Specific Queries

You can also retrieve structured data for an individual patient using standard FHIR search operations. Each query targets a single resource type and must include the patient reference parameter ?patient={id}.

Search Patterns

Include ?patient={id} in every query, and add indexed parameters to filter results:

  • date or period for temporal filtering
  • code to narrow by clinical concept
  • category to limit by type or purpose
  • _lastUpdated to filter by modification timestamp

Examples

  • GET /fhir/R4/Observation?patient=12345&code=2093-3
  • GET /fhir/R4/DocumentReference?patient=12345&category=clinical-note
  • GET /fhir/R4/MedicationStatement?patient=12345&_lastUpdated=gt2024-01-01

Resource Linkages

Many patient queries return references to other resources that provide context:

  • Encounter references establish care setting and visit details
  • Provenance indicates source and retrieval details
  • DocumentReference includes metadata about associated documents

Follow linked resources to build a timeline or interpret records in context.

Filtering Best Practices

To improve performance and reduce payload size:

  • Use the most specific parameters available, such as code, date, or category
  • Avoid broad queries without filters on high-volume resource types
  • Paginate results with _count and the next link
  • Use _summary=data when metadata is not required
  • Avoid polling unless tracking updates where webhooks cannot be used

Summary

Patient queries provide flexibility for working with individual records. Use $everything to retrieve a patient’s complete history in a single response, and use targeted queries to pull specific clinical resources with fine-grained filters. Both approaches can be combined in workflows to balance completeness and efficiency.