Skip to content
Daniel Carbone edited this page Feb 6, 2025 · 1 revision

Library generated from the output of php-fhir.

Included Versions

This library contains code generated for all

Quick Start

This library may either be used as a composer dependency, or directly.

Composer Dependency

$ composer require dcarbone/php-fhir-generated

Standalone

  1. Check out this repo
  2. Require the generated root autoloader: src/DCarbone/PHPFHIRGenerated/Autoloader.php

Example Using R4

<?php

require __DIR__ . '/src/DCarbone/PHPFHIRGenerated/Autoloader.php';

use DCarbone\PHPFHIRGenerated\Client\Client;
use DCarbone\PHPFHIRGenerated\Client\Config;
use DCarbone\PHPFHIRGenerated\Client\ResponseFormatEnum;
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;

// Building a new Patient
$patient = new FHIRPatient(id: 'patient-1',
                           language: 'en-us',
                           name: [
                               new FHIRHumanName(given: 'Real', family: 'Human')
                           ],
                           /* other fields */);

// Retrieving a patient from a server
$clientConfig = new Config(address: 'http://your-r4-fhir-server', defaultFormat: ResponseFormatEnum::JSON);
$baseClient = new Client($clientConfig);

$client = new VersionClient($baseClient, new Version());

$patient2 = $client->readOnePatient(resourceID: 'patient-2');
Clone this wiki locally