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

# Using Generated Models

Generated resources are plain PHP objects with a promoted-property constructor, so you build them with named arguments. Complex types, primitives, and enums each have their own classes — see [Namespace Organization](/models/namespaces.md).

```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;

$patient = new PatientResource(
    name: [
        new HumanName(
            family: new StringPrimitive(value: 'Doe'),
            given: [new StringPrimitive(value: 'John')],
        ),
    ],
);
```

## Accessing properties

Properties are public, so you read them directly. Primitive-typed properties are wrapped objects exposing a `->value`:

```php
echo $patient->name[0]->family->value; // 'Doe'
```

{% hint style="info" %}
Some scalar properties (such as `id`) are plain PHP types (`?string`), while others (such as `family`) are primitive wrapper objects (`StringPrimitive`) so they can carry FHIR extensions. Check the generated class to see which a given property uses.
{% endhint %}

## Enums

Coded value sets are generated as PHP enums:

```php
$gender = AdministrativeGender::Male;
$cases  = AdministrativeGender::cases(); // all enum values
```

## Next steps

* [Serialization](/serialization/overview.md) — read and write these objects as JSON or XML.
* [Validation](/validation/overview.md) — check them against the specification and profiles.


---

# 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/usage.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.
