--- type: "fhirpath-function" title: "FHIRPath Function: select" function: "select" category: "Filtering and projection" section: "5.2.2" source: "fhirpath/functions.json" --- # FHIRPath Function: select > This is a [scoped function](#scoped-functions): The `projection` argument is evaluated for each item (setting `$this` and `$index` before each iteration); and the results are included in the output collection. Evaluates the `projection` expression for each item in the input collection. The result of each evaluation is added to the output collection. If the evaluation results in a collection with multiple items, all items are added to the output collection (collections resulting from evaluation of `projection` are _flattened_). This means that if the evaluation for an item results in the empty collection (`{ }`), no item is added to the result, and that if the input collection is empty (`{ }`), the result is empty as well. ``` fhirpath Bundle.entry.select(resource as Patient) ``` This example results in a collection with only the patient resources from the bundle. ``` fhirpath Bundle.entry.select((resource as Patient).telecom.where(system = 'phone')) ``` This example results in a collection with all the telecom elements with system of `phone` for all the patients in the bundle. ``` fhirpath Patient.name.where(use = 'usual').select(given.first() + ' ' + family) ``` This example returns a collection containing, for each "usual" name for the Patient, the concatenation of the first given and family names. ## Summary - **Category**: Filtering and projection - **Section**: `5.2.2` - **Return Type**: `collection` - **Empty Input Result**: `empty` - **Errors on Multiple Input**: `false` ## Description Evaluates the `projection` expression for each item in the input collection. The result of each evaluation is added to the output collection. If the evaluation results in a collection with multiple items, all items are added to the output collection (collections resulting from evaluation of `projection` are _flattened_). ## Arguments - `projection`: `expression` - Expression to project each element ## Type Mapping - `Any-Any` ## Example ```fhirpath Patient.name.where(use = 'usual').select(given.first() + ' ' + family) ```