--- type: "fhirpath-function" title: "FHIRPath Function: ofType" function: "ofType" category: "Filtering and projection" section: "5.2.7" source: "fhirpath/functions.json" --- # FHIRPath Function: ofType Returns a collection that contains all items in the input collection that are of the given type or a subclass thereof. If the input collection is empty (`{ }`), the result is empty. The `type` argument is an identifier that must resolve to the name of a type in a model. For implementations with compile-time typing, this requires special-case handling when processing the argument to treat it as type specifier rather than an identifier expression: ``` fhirpath Bundle.entry.resource.ofType(Patient) ``` In the above example, the symbol `Patient` must be treated as a type identifier rather than a reference to a Patient in context. ## Summary - **Category**: Filtering and projection - **Section**: `5.2.7` - **Return Type**: `collection` - **Empty Input Result**: `empty` - **Errors on Multiple Input**: `false` ## Description Returns a collection that contains all items in the input collection that are of the given type or a subclass thereof. ## Arguments - `type`: `type specifier` - Type to filter elements by ## Type Mapping - `Any-Any` ## Example ```fhirpath Bundle.entry.resource.ofType(Patient) ```