--- type: "fhirpath-function" title: "FHIRPath Function: where" function: "where" category: "Filtering and projection" section: "5.2.1" source: "fhirpath/functions.json" --- # FHIRPath Function: where > This is a [scoped function](#scoped-functions): The `criteria` argument is evaluated for each item (setting `$this` and `$index` before each iteration); those that return `true` are included in the output collection. Returns a collection containing only those items in the input collection for which the stated `criteria` expression evaluates to `true`. Items for which the expression evaluates to `false` or empty (`{ }`) are not included in the result. If the input collection is empty (`{ }`), the result is empty. If the result of evaluating the condition is other than a single boolean value, the evaluation will end and signal an error to the calling environment, consistent with singleton evaluation of collections behavior. The following example returns the list of `telecom` elements that have a `use` element with the value of `'official'`: ``` fhirpath Patient.telecom.where(use = 'official') ``` ## Summary - **Category**: Filtering and projection - **Section**: `5.2.1` - **Return Type**: `collection` - **Empty Input Result**: `empty` - **Errors on Multiple Input**: `false` ## Description Returns a collection containing only those elements in the input collection for which the stated `criteria` expression evaluates to `true`. Elements for which the expression evaluates to `false` or empty (`{ }`) are not included in the result. ## Arguments - `criteria`: `expression` - Expression to filter the elements ## Type Mapping - `Any-Any` ## Example ```fhirpath Patient.telecom.where(use = 'official') ```