When you callDocumentation 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.
validate_query() or validate_batch(), FHIR Query Validator does more than check syntax — it runs the query string through a multi-stage pipeline that verifies each structural component against the FHIR R4 specification. Understanding this pipeline helps you interpret validation results accurately, distinguish errors from warnings, and write queries that pass validation cleanly.
The validation pipeline
FHIR Query Validator processes each query string through four sequential stages. A failure at any stage produces an error, and the pipeline continues to later stages to surface as many problems as possible in a single pass.Parse the query string
The validator splits the raw query string into its components: the resource type and the list of parameter-value pairs. Structural problems — such as malformed percent-encoding, missing resource types, or parameter names that contain illegal characters — are caught here before any FHIR-specific checks run.
parse_stage.py
Check the resource type
Once the query is parsed, the validator checks whether the resource type is a known FHIR R4 resource. Resource names are case-sensitive —
patient is not valid; Patient is. If the resource type is unknown, the validator records an error and continues checking the remaining parameters anyway, so you see the full picture of what’s wrong.resource_stage.py
Check search parameters
For each parameter in the query string, the validator verifies that the parameter is defined for the given resource type in the FHIR R4 specification. This includes checking the parameter name itself and any modifier (the
:exact or :missing suffix). Control parameters starting with _ are validated against the set of FHIR-defined control parameters.param_stage.py
Errors vs. warnings
ValidationResult separates problems into two categories with different meanings.
Errors
The query violates the FHIR specification. A FHIR server is likely to reject it outright or return unexpected results. You should fix errors before using the query in production.
Warnings
The query is technically valid but may behave unexpectedly. Warnings highlight patterns that are legal but commonly misused, overly broad, or likely to return more (or fewer) results than intended.
What triggers errors
Unknown resource type
Unknown resource type
The resource type at the start of the query string is not a recognized FHIR R4 resource.
Unknown search parameter
Unknown search parameter
The parameter name is not defined for the specified resource type in the FHIR R4 specification.
Invalid modifier
Invalid modifier
The modifier applied to a parameter is not valid for that parameter’s type. For example, applying
:exact to a date parameter is not supported.Malformed parameter value
Malformed parameter value
The value provided does not match the expected format for the parameter type. This includes invalid dates, unsupported token formats, and malformed reference values.
Invalid enumerated value
Invalid enumerated value
Some FHIR parameters accept only a specific set of string values defined by the specification. Providing an unlisted value is an error.
What triggers warnings
No search parameters provided
No search parameters provided
A query with only a resource type and no filter parameters is valid FHIR but returns all resources of that type. On large datasets this is typically unintentional.
Deprecated search parameter
Deprecated search parameter
The parameter is defined in FHIR R4 but has been marked as deprecated in favor of a newer alternative.
Very broad date range
Very broad date range
A date range spanning many decades is valid but may indicate an inadvertent omission of a boundary that would significantly restrict results.
Chained parameter depth
Chained parameter depth
A chained parameter with many hops is valid FHIR but may not be supported by all servers and can be expensive to execute.
The ValidationResult object
Every call tovalidate_query() returns a ValidationResult object. Every item in the list returned by validate_batch() is also a ValidationResult. The object has three attributes.
result_structure.py
is_valid is True when there are no errors. A query with warnings but no errors is considered valid — is_valid will be True. Warnings indicate potential issues but do not make a query invalid.Working with results
- Single query
- Batch validation
- Assertions in tests
single_query.py
Common validation scenarios
The following examples show query patterns you are likely to encounter and the validation feedback each produces.Token value with code system
Token value with code system
Token parameters accept values in the format
system|code. The pipe character separates the code system URI from the code value. Both parts are optional — you can search by code alone or system alone.Date range with dual parameters
Date range with dual parameters
You can specify a date range by repeating the same parameter with different prefixes. Both instances must be valid.
Reference parameter formats
Reference parameter formats
Reference parameters point to other FHIR resources. They accept a relative reference (
Patient/123), an absolute URL, or a plain ID.Next steps
Basic validation guide
Step-by-step instructions for integrating validation into your Python application.
Validation rules reference
The complete list of error codes and warning codes produced by the validator.