--- type: "fhir-fhirpath-function" title: "FHIR FHIRPath Function: slice" source: "source/fhirpath.html" --- # FHIR FHIRPath Function: slice This page is part of **FHIR FHIRPath** (FHIR-specific extensions). Base spec lives at [FHIRPath](/fhirpath). `slice(structure : string, name : string) : collection` Returns the input collection filtered to items that conform to the specified profile slice. The `structure` argument is the (possibly versioned) canonical uri of the structure definition that contains the specified slice. The `name` argument is either the `ElementDefinition.sliceName` for the element slice (if the sliceName is unique in the snapshot), or the `ElementDefinition.id` of the element slice. The `structure` argument can also be the special variable `%profile` which refers to the profile in which the ElementDefinition.constraint containing the FHIRPath is defined. (This variable can only be used for FHIRPath appearing in constraints) If the `structure` cannot be resolved, or the `name` of the slice is not present in the profile, or those parameters are empty, the return value will be an empty collection. If the slice does not match any element in the input collection, or if the input collection is empty, the return value will be an empty collection. For example, this invariant could appear in a Patient profile: // ensure that a patient has at least one home phone and one home email (based on the slicing defined in the profile) Patient.telecom.slice(%profile, 'homephone').exists() and Patient.telecom.slice(%profile, 'homeemail').exists() > NOTE: not all FHIRPath engines are in a position to implement `slice()` as implementation requires implementation of a FHIR validation engine, which is not a small undertaking. * * * [Back to FHIR FHIRPath](/fhir-fhirpath)