--- type: "fhirpath-function" title: "FHIRPath Function: single" function: "single" category: "Subsetting" section: "5.3.2" source: "fhirpath/functions.json" --- # FHIRPath Function: single Will return the single item in the input if there is just one item. If the input collection is empty (`{ }`), the result is empty. If there are multiple items, an error is signaled to the evaluation environment. This function is useful for ensuring that an error is returned if an assumption about cardinality is violated at run-time. The following example returns the name of the Patient if there is one. If there are no names, an empty collection, and if there are multiple names, an error is signaled to the evaluation environment: ``` fhirpath Patient.name.single() ``` ## Summary - **Category**: Subsetting - **Section**: `5.3.2` - **Return Type**: `collection` - **Empty Input Result**: `empty` - **Errors on Multiple Input**: `true` ## Description Will return the single item in the input if there is just one item. If there are multiple items, an error is signaled to the evaluation environment. ## Arguments - none ## Type Mapping - `Any-Any` ## Example ```fhirpath Patient.name.single() ```