How FHIR search on Medplum answers clinical lookups
Most app teams that build on Medplum start with a clinical lookup: find the patients with a given condition, the encounters in the last week, the active medications for one patient, or the latest observations that feed a care gap rule. Medplum's FHIR R4 search covers most of these lookups through basic search parameters, chained search, _include and _revinclude, _filter and paging, so a team can often answer the question in one request without building a separate data store. Search is the right tool when the result set is bounded, the criteria are known at request time, and the caller needs a page of resources it can display or act on. It is not the right tool for moving an entire population out of Medplum, where a Bulk FHIR export is designed for that job, and it is not the only way to fetch linked data, where the GraphQL API may return a related graph in one call. Confirm the exact parameter, modifier and chaining support against the Medplum docs for the version you run, because self-hosted servers can lag the hosted release by the upgrade path you have chosen.
Before writing queries, map each lookup to the resource types, search parameters and reference paths it depends on, and note which of them are standard FHIR R4 parameters and which Medplum supports as extensions. Chained and reverse-chained searches are where the cost of a query tends to rise, because each link adds work on the server and can widen the result set in ways that are easy to miss in testing with small data. Ask your engineers to run representative queries against a copy of production-scale data and record response times, the number of resources returned per page, and how the next-page link behaves when criteria change between calls. Those measurements also show whether a lookup belongs in a synchronous API path or in a scheduled job.
The search design also determines how access control and cost are experienced by users and by your platform team. Every search runs under the access policies of the calling client, so a query that looks correct in a developer project can return different results for a clinician, a bot or an integration account. Medplum's hosted plans and self-hosted deployments also carry different operational limits, and the rate limits and server capacity you choose will shape how many searches your application can make under load. Ask the Medplum team or your implementation partner to confirm the quotas that apply to your plan or deployment, and agree on a rule for when a screen should batch or cache a lookup rather than issue a fresh search on every page view.
Which search technique fits which clinical lookup
This table compares the FHIR search techniques Medplum exposes, from basic parameters to paging, and pairs each with the clinical lookup it serves and its main cost or access risk. Check each row against the Medplum FHIR search documentation for the version you deploy, because parameter support and defaults can change between releases.
| Technique | What it does | Typical clinical lookup | Main cost or access risk |
|---|---|---|---|
| Basic search parameters | Filters one resource type by common elements such as identifier, name, birthdate or status | Find a patient by MRN or date of birth before opening a chart | Broad or unindexed queries can return large result sets and slow the server |
| Advanced modifiers | Adds modifiers such as :exact, :contains, :missing or date prefixes to narrow matches | Find active medication requests started after a given date | Modifiers may change index use, so confirm each one performs acceptably on your data volume |
| Chained search | Filters on a referenced resource's fields in a single request, such as Observation where subject.name matches | List lab results for patients in a named care team or panel | Each chain adds a lookup, and access policies apply to the chained resources too, so results can be narrower than expected |
| _include | Returns referenced resources, such as the Patient, alongside the matching search results | Build a worklist of encounters with the patient name shown on each row | Included resources count toward response size, and the caller must also be allowed to read them |
| _revinclude | Returns resources that reference the matches, such as Observations pointing at a Patient | Load a patient's labs, allergies and conditions in one request for a summary view | Reverse includes can return many more resources than the primary match, which raises response size and access exposure |
| _filter | Applies a more expressive filter language to a search when standard parameters cannot express the condition | Select observations within a value range or a combined set of conditions | Support and performance vary by resource and version, so confirm supported syntax before depending on it in production |
| Paging with _count and next links | Returns results in pages and follows links to the next set of matches | Scroll through a large census or claim list in a clinical dashboard | Deep paging is costly, and pages can shift if data changes between requests, so use stable sort order |
| Search quotas and result limits | Caps how many searches and results a client can use within its limits | Frequent refresh of a patient list by many users at once | Heavy searches under shared limits can throttle other clients, so confirm the limits configured for your deployment |
How a search request moves through Medplum
A search starts in the client application, which obtains an access token through OAuth or a client credentials grant from Medplum Auth. The request then reaches the FHIR API, where access policies filter what the caller may see before results leave the server. The search layer translates the query into work against PostgreSQL, and the response returns as a Bundle whose next links continue paging. Check the token's scopes and the policy filters first when results look incomplete.
Search requests pass token checks and access policy filtering before PostgreSQL returns matches.
Search patterns for common clinical app situations
Illustrative case: a worklist of adults with an active diagnosis of type 2 diabetes who have no HbA1c result in the recent period. The team combines a Condition search on code and clinical status with an Observation search on code and date. The result is a Bundle of Condition resources, each pointing to a patient through subject, so the app still needs patient names and a second query or an include to show them.
- Condition filter:
Condition?code=...&clinical-status=activelimits the list to active problems using the code system the team has agreed on. - Observation check:
Observation?code=...&date=ge...looks for recent results, and the team decides whether an empty result means no test or a missing lab feed. - Patient include:
_include=Condition:subjectaddsPatientresources to the same Bundle so names render without an extra request. - Paging:
_countsets the page size, and the app follows thenextlink in the Bundle to load later pages.
Before release, confirm that the sort order is stable and that the page size holds when records change between requests.
Illustrative case: a clinic view of a practitioner's encounters that are currently in progress today. The team combines an Encounter search on participant, status and date, then includes the patient so the schedule shows names. The result is a Bundle of Encounter resources, each with a subject reference. The main care point is that the practitioner is recorded in different ways across sources, so a search that works in test can miss visits in production.
- Participant reference:
participantmatches encounters where the practitioner appears, so confirm whether your data usesPractitionerorPractitionerRolereferences. - Status filter:
status=in-progresskeeps the list to open visits and avoids paging through finished encounters. - Date boundary: the clinic's time zone changes which encounters fall on a given day, so pass explicit offsets in the date value.
- Patient include:
_include=Encounter:subjectreturns patient records in the same Bundle as the encounters.
Before you rely on this search, load a sample of production-shaped data and compare the results with what the clinic sees on its own schedule.
Illustrative case: a care coordinator wants referrals (ServiceRequest) for patients whose family name starts with a given value, placed by a particular referring clinician. A chained search lets the server follow the subject and requester references, so the app does not fetch patients or practitioners first. The result is a Bundle of ServiceRequest resources. Chains are the part of FHIR search most likely to become slow, because each link adds work the server must do before it can apply the next filter.
- Patient chain:
ServiceRequest?subject:Patient.family=...searches the patient's name from the referral side. - Requester chain:
requester:Practitioner.name=...follows the referring clinician reference to match on the practitioner's name. - Selective first parameter: add a status or date filter so the server narrows the candidate set before it follows a chain.
- Iterate includes:
_include:iteratecan pull referenced resources one level deeper, but confirm that the Medplum version in use supports it for your query.
Before release, run the chained queries against a dataset of production-like size and record the response times for each chain you plan to expose.
Illustrative case: a discharge follow-up report that lists recent encounters, each patient's active medication requests, and the most recent observations. The team combines _include for the patient on each encounter with _revinclude for resources that point back to the patient. The result is one Bundle that mixes primary matches with supporting resources, and the screen has to sort them apart. Reverse includes are where page weight grows quickly, because each matched patient can bring many resources with it.
- Forward include:
_include=Encounter:subjectbrings the referenced patient into the Bundle for each encounter. - Reverse include:
_revinclude=MedicationRequest:subjectreturns medication requests that point back to each matched patient. - Match versus include: each Bundle entry carries a search mode, so the screen can separate primary results from included resources.
- Page weight:
_countlimits the matches, but reverse includes can add many resources per match, so narrow them with_filteror date bounds.
Before you release the report, measure the payload size and response time with the largest patient panels you expect the screen to handle.
Setting up and testing FHIR search in order
This sequence takes a team from a confirmed Medplum server version to a tested set of search queries, with includes, chained lookups and paging checked against access rules before any app depends on them.
Confirm server version and search support
The platform engineer records the Medplum server version in use, whether it is a hosted or self-hosted deployment, and the release notes for that version. For self-hosted deployments, confirm the version against the upgrading guide so that the server is on a supported minor version in sequence. Check the server's FHIR capability statement and confirm which search parameters, modifiers and result features the version exposes for each resource type you plan to query. Record the list in your test plan. Done when the team has a written version number and a capability list that the later queries are checked against.
Create client application and scoped access policy
The security or platform engineer creates a dedicated client application for the search workload and attaches an access policy that limits which resource types, compartments and fields it can read. Do not reuse an administrator login or a broad project-wide client for testing. Decide which identity method the client uses, such as client credentials for server-to-server access or a configured identity provider for user-facing apps, and confirm the method against the authentication documentation. Done when a token issued to this client can read the intended resource types and is refused for at least one resource type it should not see.
Seed test data and build the query set
The developer loads a synthetic dataset that includes patients, encounters, practitioners, observations and linked resources, with deliberate edge cases such as missing references, duplicate names and resources outside the access policy. Build each query shape your app needs as a separate, named request: basic parameters, chained parameters such as a reference followed by a search field,
_includeand_revincludelookups,_filterexpressions and sorted, paged searches. Store the requests in version control. Done when every planned query shape has a saved request and an expected result count written against the seeded data.Verify basic and chained results
The developer runs each basic and chained query with the scoped client and compares the returned resource IDs with the expected list from the seed data. Confirm that chained queries match only resources reachable through the reference chain and that a resource the policy hides does not appear through a chain, even when the parent is visible. Note any modifier or parameter the server rejects and map it back to the capability list from step one. Done when every chained query returns the expected IDs and the hidden-resource case returns nothing.
Test includes and reverse includes against permissions
The developer runs
_includeand_revincludequeries under the scoped client and inspects every included resource in the bundle. The security reviewer checks that included resources of restricted types are absent and that no sensitive field is returned through an included entry that the policy would block on a direct read. Repeat the same include query with a second client that has broader rights and confirm the difference is exactly what the policy allows. Done when the reviewer signs off on a list of included resource types for each query and the restricted resources are missing from the bundles.Check paging links across a full result set
The developer runs a paged search with a page size that forces several pages, then follows the
nextlinks until none remain. Collect every resource ID across pages and compare the total against the expected count from the seed data, checking for duplicates and gaps. Repeat with a sort parameter, because unstable ordering can cause resources to repeat or disappear between pages. Confirm that the paging links keep the same query parameters and access scope. Done when the union of all pages equals the expected set with no duplicates and each page is returned under the same client scope.Measure query behavior before go-live
The platform engineer runs the saved query set against a staging deployment sized like production, recording response times, result sizes and the number of included resources per request. Compare heavy queries, especially broad includes and unbounded chained searches, against the search limits and rate limits documented for the deployment, and confirm with the vendor or your own environment any quota that applies to your plan. Remove or narrow queries that return more data than the screen needs. Done when each query has a recorded baseline, an agreed upper bound, and a note on which queries need a narrower shape before release.
Why chained search and includes change the cost of a query
A chained parameter or an _include changes the cost of a query because the server has to resolve references the client never named in the request. A search such as Observation?subject.name=Smith first finds matching Patient resources, then returns the Observations that point to them. A search with _include=Observation:subject adds the referenced Patient resources to the Bundle. Each extra hop means more index lookups, more resources loaded and more rows in the response, so one request can return far more data than its top-level result count suggests. _revinclude works in the opposite direction and can pull in large sets of child resources for every parent, which is where response sizes tend to surprise teams.
These extra resources interact with three other controls. Page size, set with _count, limits only the matched primary resources in most cases, so included resources can make a page much heavier than the number requested. Access policies also apply to every resource the server touches: a user may see a Patient match but not the Observations or related resources included with it, so the result set a client receives depends on the caller's permissions as well as the query. Any quota, rate limit or request size limit that your deployment applies counts this work too, so a query that looks cheap in a test database can exhaust a budget in production. Confirm how your self-hosted configuration sets these limits, and check the current search behavior in the Medplum documentation for the release you run.
Measure these queries on your own data volumes instead of relying on general guidance. Build a test dataset that matches your patient counts, reference density and the number of child resources per parent, then time each lookup your app runs with and without _include or _revinclude, at several page sizes, under the access policies your real users hold. Record response size and resource counts, not only latency. Repeat the test after each Medplum upgrade, since search behavior and index use can change between releases, and set your page size and included resource limits from those results.
What drives the cost of searches under FHIR quotas
Every FHIR search on Medplum costs something against the platform's limits, and the cost depends on how the query is built and how often it runs. The cards below cover the parts of a search design that move that cost up, and what to confirm with Medplum or your own team before the design goes into production.
Parameter count and chaining
Each search parameter narrows or widens the work the server does, and a chained search such as Observation?subject.name=... makes the server resolve a second resource before it can filter the first. More parameters and deeper chains usually mean more database work per request. Ask Medplum how chained searches are counted against quotas and whether any chain depth is capped. Test your heaviest clinical lookups with realistic parameter combinations before you commit to them.
Include and revinclude depth
_include and _revinclude return linked resources in the same response, which saves round trips but enlarges the payload and the work behind it. Each added include level can multiply the number of resources returned for a single search. Confirm whether includes count as separate operations or as part of one search request. Keep include depth to what the screen actually renders.
Page size and result set size
The _count value sets how many matches come back per page, and a broad search with no filters can return a very large result set across many pages. Large pages cost more memory and bandwidth on each call, while small pages multiply the number of calls needed to read the full set. Ask how each page request is counted and whether result set size affects the quota differently from request volume. Set a sensible default page size in your client code.
Polling frequency and subscriptions
An app that reruns the same search every few seconds spends quota on work that often returns nothing new. Subscriptions can replace polling for change events, but they add their own processing load and their own limits. Confirm which Medplum mechanism fits each use case and what rate limits apply to polling and subscription traffic on your plan. Cache results on the client where the clinical workflow allows it.
Access policy complexity
Access policies decide which resources a caller can see, and the server applies them to each search result. Policies that depend on compartments, referenced resources or several conditions can slow searches that would otherwise be fast. Test search performance under the real access policy for each client application, not only under an administrator account. Measure the difference between an admin search and a restricted-client search before you size your deployment.
Plan tier and rate limit terms
Hosted Medplum plans and self-hosted deployments are priced and limited differently, so the same search design can have different cost and throughput outcomes depending on where it runs. Quota definitions, burst handling and overage rules belong in your written agreement, not in assumptions. Request the quota, rate limit and counting rules in writing for your plan and deployment model before you estimate search cost. Ask whether limits differ between development and production environments.
Medplum pricingQuestions teams ask before building FHIR search on Medplum
How much effort does building FHIR search queries on Medplum take?
Effort depends mostly on how many distinct lookups the app needs and how many of them combine parameters, chains or includes. A small set of basic searches by patient, encounter or date is a short build. Each chained search, _revinclude or _filter expression adds design, testing and tuning work. No effort figure was supplied for this topic, so ask a prospective partner to break the estimate down by query: each lookup, its parameters, its expected result size and its test cases. That breakdown is what makes a quote comparable across firms.
How long does a typical FHIR search integration take?
Duration follows the number of clinical lookups, the resource types involved and how many of them must return correct results at scale. A team that already knows FHIR can move faster on basic parameters, while chained search and paging across large patient sets need more validation against realistic data. Confirm the timeline against a written scope that lists each query, the test data you will provide, and who signs off on results. No timeline was supplied for this topic, so treat any duration that is not tied to a written scope with caution.
What does the client's team need to provide for search work?
The work needs a clear list of clinical questions the app must answer, sample or de-identified data that resembles production, access to a Medplum environment with the right project and access policies, and a named reviewer who understands the clinical meaning of results. Your team should also decide which identifiers and resource types are in scope, because search results inherit the access rules of the account that runs them. Confirm that your environment, whether Medplum Cloud or self-hosted, can be reached from the build team's tooling.
Can our own developers build these FHIR searches without a partner?
Yes, if they have working knowledge of FHIR resource models, search parameter types and the Medplum SDK. The most common gaps are chained search that returns more rows than expected, _include and _revinclude that pull in unrelated resources, and paging that skips or repeats results under load. Teams that build in-house should plan time for query testing against realistic data and for reviewing access policy effects. A partner adds value mainly when the team lacks FHIR depth or needs independent review before clinical users depend on the results.
How does chained search differ from a GraphQL query on Medplum?
Chained search uses FHIR search syntax to filter one resource type by a property of a referenced resource, for example finding observations whose subject patient has a given name. A GraphQL query instead asks for a graph of linked resources and returns the shape the client selects. Chained search fits filtering and lookup, while GraphQL fits fetching linked data for one screen in a single request. Many apps use both. Confirm which pattern your app needs before design, because the access policy and performance characteristics differ, and review the Medplum FHIR GraphQL API guidance for the GraphQL side.
What makes search results slow or incomplete under FHIR quotas?
Results slow down or truncate when queries are unbounded, when chains traverse many references, or when _include and _revinclude pull large sets of related resources into each page. Incomplete results often come from paging assumptions that do not match the server's page links, or from access policies that hide resources from the calling account. Ask your partner or internal team to measure each query against your data volume, record the quota behavior you observe in your deployment, and set explicit page sizes and filters. Confirm quota and rate limit settings for your plan or self-hosted configuration before go-live.
Does search work need a separate Medplum environment for testing?
A separate non-production environment is strongly advisable because search tests can create load, and test data should not mix with live patient records. The environment should mirror the production access policies, project settings and search parameter configuration so results match what users will see. Confirm with Medplum's documentation whether your plan or self-hosted setup supports the separation you need, and confirm how test data will be loaded and removed.
How access control and logging apply to search results
Search results are shaped by the access policies and client scopes of the calling application, not only by the search itself. A chained search or an _include can therefore return nothing for a resource that the caller cannot read, even when the parent resource it hangs from is fully visible. Plan for this during design: a lookup that joins an Observation to its Patient through a chain may silently drop rows for an application whose access policy covers only some patients or some resource types. Test each search with the exact client application, project and SMART scopes that will run in production, and compare results with an administrator account so the difference is visible rather than discovered by a clinician.
Every search should be treated as an auditable event. Confirm how the deployed Medplum version writes audit events for FHIR search requests, including which fields are recorded (the calling identity, the resource type, and the search parameters) and how long those records are retained in your own infrastructure. Search parameters frequently carry PHI, such as a patient name, date of birth or identifier, and those values can end up in query strings, proxy and load balancer logs, and application logs. Decide up front which logs capture full URLs, redact or hash identifiers in query strings, and who may read each log store. Ask your Medplum contact to confirm the logging behavior for your version before you write retention rules.
Confirm two behaviors on your own deployment before go-live: whether access policies are applied to resources returned through _include and _revinclude, and whether the next and previous paging links preserve the caller's access context and do not expose resources outside it. Run a paged search as a restricted client and check that every page, and every included resource on every page, falls inside its scope. Record the results as part of your release evidence, and repeat the check after each Medplum upgrade because search behavior can change between versions. The Medplum compliance documentation describes the shared responsibility model, which places the configuration and verification of these controls with your team.
Limits to confirm for FHIR search in your environment
FHIR search behavior on Medplum depends on the deployed version, the query shape and how the deployment is run. The cards below list the limits a team should measure in its own test environment before committing an application's clinical lookups to a specific search pattern.
Supported parameters and modifiers
Confirm which search parameters, modifiers and prefixes the deployed Medplum version supports for each resource type your app queries. Support can differ between the FHIR R4 API and the GraphQL layer, and between major versions. Run each lookup your application needs against a copy of the deployed version, and record any parameter that returns an error or silently ignores a filter.
Versions and release policyChained and reverse-include behavior
Chained search and _revinclude can fan out into several internal queries, and their cost grows with the size of the matched sets. Test each chained query with realistic patient volumes and check the result counts against a known dataset. Confirm whether includes return the expected resources and whether the result set changes when a referenced resource is missing or restricted by access policy.
Page size and paging links
Check the default page size, the maximum _count the server accepts, and whether next and previous links preserve the original search parameters. Paging links that drop a filter or change sort order produce incomplete worklists without any error. Walk every page of a large result set in the test environment and compare the total against an independent count.
Quota and rate limit settings
Find out which request limits apply to your plan or deployment, and whether they are set in configuration you control or by the hosting provider. Ask how limits are counted per client, per project and per IP address. Simulate the peak request rate of your busiest screen so that a burst of lookups does not trigger throttling in production.
Medplum pricingIndex maintenance on large datasets
Search performance depends on the database indexes that exist for each search parameter, and on whether those indexes are rebuilt or updated after upgrades and large imports. Ask who owns index creation and monitoring in a self-hosted deployment, and how long index work takes on a dataset close to production size. Measure query plans and latency for your heaviest chained searches before go-live.
Upgrading guideCloud versus self-hosted differences
Confirm which search behaviors, limits and tuning settings are managed by Medplum on its cloud service and which are your responsibility when you self-host. Settings for database sizing, cache, rate limits and index work can sit with your operations team. Write down the responsibility split for each limit in your own runbook, so that a search regression after an upgrade has a clear owner.
Compliance docsHow DeployOpen scopes and delivers Medplum search work
DeployOpen approaches FHIR search on Medplum as a scoped piece of work: first the clinical lookups the application needs, then the query patterns, includes and paging that serve them. The work is planned in a written scope and delivered inside the client's own self-hosted or chosen infrastructure.
How we scope
- Inventory the lookups the application must answer, such as patient-to-encounter or patient-to-observation queries.
- Map which search parameters, chained references and _include or _revinclude calls each lookup needs.
- Agree in writing which pagination approach, result limits and FHIR quota expectations apply to each screen.
How we build
- Write and test each search request against a non-production Medplum project using representative sample data.
- Measure result counts, response times and quota use for chained and included queries before they reach users.
- Document access policy interactions so each query returns only the resources the signed-in role may read.
How we hand over
- Deliver a catalog of approved search patterns with parameters, examples and known limits for the development team.
- Provide test cases that rerun the searches after each Medplum upgrade or schema or profile change.
- Walk the engineering team through paging, include behavior and quota troubleshooting before the scope closes.
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
- Ongoing support, upgrades and continuous testing of search behavior are available as a retainer.
- Ask any partner to confirm how search quotas apply to your Medplum plan and deployment before committing scope.

