-
-
Notifications
You must be signed in to change notification settings - Fork 10
Home
Daniel Carbone edited this page Apr 2, 2026
·
4 revisions
Pre-generated PHP classes for HL7 FHIR resources, produced by dcarbone/php-fhir.
This library provides strongly-typed PHP models for every FHIR resource, element, and primitive across multiple FHIR versions, along with built-in serialization, validation, and an HTTP client.
| Version | FHIR Spec |
|---|---|
| DSTU1 | v0.x |
| DSTU2 | v1.x |
| STU3 | v3.x |
| R4 | v4.0 |
| R4B | v4.3 |
| R5 | v5.x |
- PHP 8.1+
- Extensions:
curl,dom,json,libxml,simplexml,xmlreader,xmlwriter
composer require dcarbone/php-fhir-generated- Clone or download this repository
- Require the root autoloader:
require __DIR__ . '/src/DCarbone/PHPFHIRGenerated/Autoloader.php';<?php
use DCarbone\PHPFHIRGenerated\Client\Client;
use DCarbone\PHPFHIRGenerated\Client\Config;
use DCarbone\PHPFHIRGenerated\Encoding\SerializeFormatEnum;
use DCarbone\PHPFHIRGenerated\Versions\R4\Types\FHIRElement\FHIRHumanName;
use DCarbone\PHPFHIRGenerated\Versions\R4\Types\FHIRResource\FHIRDomainResource\FHIRPatient;
use DCarbone\PHPFHIRGenerated\Versions\R4\Version;
use DCarbone\PHPFHIRGenerated\Versions\R4\VersionClient;
// Build a Patient locally
$patient = new FHIRPatient(
id: 'patient-1',
language: 'en-us',
name: [
new FHIRHumanName(given: ['Real'], family: 'Human'),
],
);
// Fetch a Patient from a FHIR server
$config = new Config(
address: 'https://your-r4-fhir-server',
defaultFormat: SerializeFormatEnum::JSON,
);
$client = new VersionClient(new Client($config), new Version());
$patient = $client->readOnePatient(resourceID: 'patient-2');- Configuration — Version configuration, serialization and unserialization options
- Constructing Types — Creating FHIR resource, element, and primitive instances
- Serialization — Encoding and decoding resources in JSON and XML
- FHIR Client — Using the built-in HTTP client to interact with FHIR servers
- Resource Parsing — Automatically parsing arbitrary FHIR responses
- Validation — Built-in validation rules and custom rule creation
- Type System — Understanding the type hierarchy and interfaces
- Autoloading — How class loading works with and without Composer
- dcarbone/php-fhir — The generator that produces this library
- HL7 FHIR Specification — The FHIR standard itself
Apache-2.0 — see LICENSE.