> 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/models/namespaces.md).

# Namespace Organization

Generated classes live under the root namespace `Ardenexal\FHIRTools\Component\Models\` and are grouped per FHIR version (`R4`, `R4B`, `R5`). Each version namespace carries the same set of subfolders:

| Subfolder   | Namespace segment | Contents                                     | Example class                         |
| ----------- | ----------------- | -------------------------------------------- | ------------------------------------- |
| `Resource`  | `…\R4\Resource`   | FHIR resources                               | `PatientResource`                     |
| `DataType`  | `…\R4\DataType`   | Complex data types                           | `HumanName`, `Address`                |
| `Primitive` | `…\R4\Primitive`  | Version-specific primitives                  | `StringPrimitive`, `BooleanPrimitive` |
| `Enum`      | `…\R4\Enum`       | Required ValueSet enums                      | `AdministrativeGender`                |
| `Extension` | `…\R4\Extension`  | Named extensions defined by the core spec    | `ADUseExtension`                      |
| `Profile`   | `…\R4\Profile`    | Constraint profiles defined by the core spec | `ActualGroupProfile`                  |

A small set of shared primitives lives **outside** the version folders, directly under `Ardenexal\FHIRTools\Component\Models\Primitive` (for example `FHIRDate`, `FHIRDateTime`, `FHIRInstant`, `FHIRTime`). These are version-agnostic and reused across R4/R4B/R5.

```php
use Ardenexal\FHIRTools\Component\Models\R4\Resource\PatientResource;
use Ardenexal\FHIRTools\Component\Models\R4\DataType\HumanName;
use Ardenexal\FHIRTools\Component\Models\R4\Primitive\StringPrimitive;
use Ardenexal\FHIRTools\Component\Models\R4\Enum\AdministrativeGender;
```

## Backbone elements

A backbone element is an inline nested structure defined within a single resource (for example `Patient.contact`). Generated backbone classes are nested in a sub-namespace named after their parent resource, so they never collide with same-named backbones on other resources:

```
R4/Resource/
├── PatientResource.php          → …\R4\Resource\PatientResource
└── Patient/
    ├── PatientContact.php        → …\R4\Resource\Patient\PatientContact
    ├── PatientCommunication.php  → …\R4\Resource\Patient\PatientCommunication
    └── PatientLink.php           → …\R4\Resource\Patient\PatientLink
```

```php
use Ardenexal\FHIRTools\Component\Models\R4\Resource\Patient\PatientContact;
```

{% hint style="danger" %}
Everything under `src/Component/Models/src/` is generated output. Never hand-edit it — regenerate with `fhir:generate`. See [Generated Output Structure](/code-generation/output-structure.md).
{% endhint %}

Implementation Guide classes are generated into a separate `IG/` tree, not these version folders — see [Generating Implementation Guides](/code-generation/implementation-guides.md).


---

# 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/models/namespaces.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.
