View raw Markdown
type: docsource: source/search_filter.html

[%settitle _filter Parameter%] [%file newheader%] [%file newnavbar%]

_filter Parameter

Responsible Owner: [[%wgt fhir%]]([%wg fhir%]) Work GroupStandards Status:Normative

Introduction

_filter is a parameter that can be used with the Search Operation. Filter requests have access to the same set of search parameters that are available to the search operation in that resource context on the server (e.g., standard parameters, parameters for each resource, etc.). The _filter parameter provides a syntax for expressing a set of query expressions on the underlying resources.

Examples of filters:

The _filter syntax has the following features:

Note: The only difference between a "string" value and a "token" value is that a string can contain spaces and ')' and ']'. There is otherwise no significant difference between them.

Formal grammar for the syntax:

filter = paramExp / logExp / ("not") "(" filter ")" logExp = filter ("and" / "or" filter)+ paramExp = paramValue SP compareOp SP compValue compareOp = (see table below) compValue = string / numberOrDate / token string = json string token = any sequence of non-whitespace characters (by Unicode rules) except "]" and ")" paramValue = hasSpecifier / paramPath hasSpecifier = "_has:" resource ":" index ":" index resource = ALPHA (DIGIT / ALPHA)* index = nameCharStart (nameChar)* paramPath = paramName (("[" filter "]") "." paramValue) paramName = nameCharStart (nameChar)* nameCharStart = "_" / ALPHA nameChar = "_" / "-" / DIGIT / ALPHA numberOrDate = DIGIT (DateChar)* dateChar = DIGIT / "T" / "-" / "." / "+" / ":" / "Z"

Notes about using the syntax:

Operators

This table summarizes the comparison operations available:

OperationDefinition
eqan item in the set has an equal value
neAn item in the set has an unequal value
coAn item in the set contains this value
swAn item in the set starts with this value
ewAn item in the set ends with this value
gt / lt / ge / leA value in the set is (greater than, less than, greater or equal, less or equal) the given value
apA value in the set is approximately the same as this value. <br/> Note that the recommended value for the approximation is 10% of the stated value (or for a date, 10% of the gap between now and the date), but systems may choose other values where appropriate
saThe value starts after the specified value
ebThe value ends before the specified value
prThe set is empty or not (value is false or true)
poTrue if a (implied) date period in the set overlaps with the implied period in the value
ssTrue if the value subsumes a concept in the set
sbTrue if the value is subsumed by a concept in the set
inTrue if one of the concepts is in the nominated value set by URI, either a relative, literal or logical vs
niTrue if none of the concepts are in the nominated value set by URI, either a relative, literal or logical vs
reTrue if one of the references in set points to the given URL

For detailed rules about the operators eq, ne, le, ge, lt, gt, sa, and eb see Search Prefixes.

The interpretation of the operation depends on the type of the search parameter it is being evaluated against. This table contains those details:

OperationStringNumberDateTokenReferenceQuantity
eqCharacter sequence is the same (case insensitive)Number is the same incl same precisionDate is the same including same precision and timezone if providedToken is the same, including namespace if specified (case insensitive)n/aUnit and value are the same
ne(same)
CoCharacter sequence matches somewhere (case insensitive)An item in the set's implicit imprecision includes the stated valueAn item in the set's implicit period includes the stated valuen/an/an/a?
swCharacter sequence matches from first digit (left most, when L->R) (case insensitive)n/an/an/an/an/a
ewCharacter sequence matches up to last digit (right most, when L->R) (case insensitive)n/an/an/an/an/a
gt / lt / ge / leBased on Integer comparison of Unicode code points of starting character (trimmed) (case insensitive)Based on numerical comparisonBased on date period comparison per 2.2.2.3n/an/aBased on numerical comparison if units are the same (or are canonicalized)
pr
pon/an/aBased on date period comparison per 2.2.2.3n/an/a
ssn/an/an/aBased on logical subsumption; potentially catering for mapping between txn/an/a
sbn/an/an/aBased on logical subsumption; potentially catering for mapping between txn/an/a
inn/an/an/aBased on logical subsumption; potentially catering for mapping between txn/an/a
ren/an/an/an/aRelative or absolute urln/a

Note:

[%file newfooter%]