> For the complete documentation index, see [llms.txt](https://php-fhir-tools.ardenexal.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://php-fhir-tools.ardenexal.net/fhirpath/functions/existence.md).

# Existence & Collection

Functions that test for the presence, count, and ordering relationships of items in a collection. Most return a single Boolean.

| Function             | Description                                                                                            | Example                                    |
| -------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------ |
| `empty()`            | True when the input collection has no items.                                                           | `Patient.name.empty()`                     |
| `exists([criteria])` | True when the collection is non-empty; with an optional filter expression, true when any item matches. | `Patient.telecom.exists(system = 'phone')` |
| `all(criteria)`      | True when every item matches the given expression (true for an empty input).                           | `Patient.name.all(use = 'official')`       |
| `count()`            | Returns the number of items as an Integer.                                                             | `Patient.name.count()`                     |
| `allTrue()`          | True when every Boolean item is true.                                                                  | `Patient.active.allTrue()`                 |
| `anyTrue()`          | True when at least one Boolean item is true.                                                           | `(true \| false).anyTrue()`                |
| `allFalse()`         | True when every Boolean item is false.                                                                 | `(false \| false).allFalse()`              |
| `anyFalse()`         | True when at least one Boolean item is false.                                                          | `(true \| false).anyFalse()`               |
| `subsetOf(other)`    | True when every item in the input also exists in `other`.                                              | `name.subsetOf(%context.name)`             |
| `supersetOf(other)`  | True when every item in `other` also exists in the input.                                              | `name.supersetOf(%context.name)`           |
| `isDistinct()`       | True when the collection contains no duplicate items.                                                  | `Patient.name.given.isDistinct()`          |
| `not()`              | Logical negation of a single Boolean input (function form of `!`).                                     | `Patient.active.not()`                     |

{% hint style="info" %}
The tree-traversal helper `repeat()` is documented under [Tree Navigation & Utility](/fhirpath/functions/navigation.md).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://php-fhir-tools.ardenexal.net/fhirpath/functions/existence.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
