FHIR R4 search goes well beyond simple parameter matching. Chained parameters let you filter resources by properties of referenced resources, modifiers change how string and token parameters are matched, and composite parameters let you express “and” semantics within a single parameter. All of these patterns have strict syntax rules thatDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dhanyasukumaran1/fhir_query_validator/llms.txt
Use this file to discover all available pages before exploring further.
FHIRQueryValidator checks before a query ever reaches a server. This guide covers each pattern with working examples and explains common mistakes that pass a cursory look but fail validation.
Chained parameters
Chained parameters traverse a reference to filter by properties of the referenced resource. The chain uses dot notation:ResourceType?reference-param.target-param=value.
The validator checks that the reference parameter exists on the source resource and that the target parameter exists on the referenced resource type. A chain like
Observation?patient.unknownparam=x fails validation even though the syntax looks correct.Common chained parameter mistakes
Using a non-reference parameter as the chain root
Using a non-reference parameter as the chain root
Only parameters of type
reference can be chained. Using a string or token parameter as the root fails:Chaining to a parameter that doesn't exist on the target
Chaining to a parameter that doesn't exist on the target
The validator resolves the target resource type and checks the parameter against it:
Search modifiers
Modifiers qualify how a search parameter value is matched. They are appended to the parameter name with a colon:parameter:modifier=value.
- :exact
- :contains
- :missing
- :not
Match the full string with case-sensitive, accent-sensitive comparison. Without
:exact, string searches are case-insensitive and accent-insensitive.Comparison prefixes on date and number parameters
Date and quantity parameters accept a two-character prefix that specifies the comparison operator. The prefix is prepended directly to the value with no separator.| Prefix | Meaning | Example |
|---|---|---|
eq | Equal (default) | birthdate=eq1990-01-01 |
ne | Not equal | birthdate=ne1990-01-01 |
lt | Less than | birthdate=lt2000-01-01 |
le | Less than or equal | birthdate=le2000-01-01 |
gt | Greater than | birthdate=gt1980-01-01 |
ge | Greater than or equal | birthdate=ge1980-01-01 |
sa | Starts after | date=sa2023-01-01 |
eb | Ends before | date=eb2024-01-01 |
ap | Approximately | value-quantity=ap70|http://unitsofmeasure.org|kg |
The
sa (starts after) and eb (ends before) prefixes are specifically designed for period-typed parameters where you care about whether the range starts or ends relative to your search value, not just whether it overlaps.Composite parameters
Composite parameters express an “and” condition between two sub-parameters within a single parameter value, using$ as the separator. They are used when you need both components to apply to the same occurrence of a repeating element.
Composite parameters are defined per resource in the FHIR specification. Not every pair of parameters can be combined with
$. The validator checks that the composite parameter name is defined for the resource and that the sub-values match their expected types._include and _revinclude
_include tells the server to return related resources referenced by the matched resources. _revinclude returns resources that reference the matched resources. Both use the format ResourceType:search-parameter or ResourceType:search-parameter:target-type.
Validate queries with multiple parameters
Multiple search parameters are joined with&. The validator checks each parameter independently and accumulates errors and warnings from all of them.
Common patterns that look correct but fail validation
Using a prefix on a string parameter
Using a prefix on a string parameter
Comparison prefixes are only valid on
date, number, and quantity parameters. Applying one to a string parameter is a validation error:Applying a string modifier to a token parameter
Applying a string modifier to a token parameter
:exact and :contains are string modifiers. Applying them to token parameters like status or code fails:Referencing an unsupported resource in _include
Referencing an unsupported resource in _include
The source resource in
_include must match the resource being searched, and the parameter must be a reference type defined for that resource:Missing the pipe separator in token system|code values
Missing the pipe separator in token system|code values
When specifying a system and code for a token parameter, the pipe character
| separates them. A colon or slash is not valid:Date strings in the wrong format
Date strings in the wrong format
FHIR dates must be in ISO 8601 format (
YYYY, YYYY-MM, or YYYY-MM-DD). Formats like MM/DD/YYYY or DD-MM-YYYY are invalid: