Patient Queries
Health Gorilla APIs provide two main approaches for retrieving data for an individual patient:
- The
$everythingoperation 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-retrieveoperation, assemble a complete longitudinal view
FHIR Version Support
| FHIR Version | $everything |
|---|---|
| R4 | Supported |
| STU3 | Supported |
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.linknavigation for subsequent pages - Includes previously aggregated content from
$p360-retrieve, normalized and deduplicated where applicable - Large result sets should be retrieved incrementally using the
nextlink in the returned Bundle
Operational Guidance
- Run
$everythingonly after the corresponding$p360-retrievejob 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:
dateorperiodfor temporal filteringcodeto narrow by clinical conceptcategoryto limit by type or purpose_lastUpdatedto filter by modification timestamp
Examples
GET /fhir/R4/Observation?patient=12345&code=2093-3GET /fhir/R4/DocumentReference?patient=12345&category=clinical-noteGET /fhir/R4/MedicationStatement?patient=12345&_lastUpdated=gt2024-01-01
Resource Linkages
Many patient queries return references to other resources that provide context:
Encounterreferences establish care setting and visit detailsProvenanceindicates source and retrieval detailsDocumentReferenceincludes 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, orcategory - Avoid broad queries without filters on high-volume resource types
- Paginate results with
_countand thenextlink - Use
_summary=datawhen 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.