FHIRPath Function: select
This is a scoped function: The
projectionargument is evaluated for each item (setting$thisand$indexbefore 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.
Bundle.entry.select(resource as Patient)
This example results in a collection with only the patient resources from the bundle.
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.
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.
<a name="instance-selector"></a>
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
Type Mapping
Example
Patient.name.where(use = 'usual').select(given.first() + ' ' + family)