View raw Markdown
type: fhirpath-functionfunction: singlecategory: Subsettingsection: 5.3.2source: 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:

Patient.name.single()

Summary

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

Type Mapping

Example

Patient.name.single()