Download the PHP package dcarbone/php-fhir without Composer
On this page you can find all versions of the php package dcarbone/php-fhir. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-fhir
php-fhir
Tools for creating PHP classes from the HL7 FHIR Specification
If you're looking to use the classes generated by this library, you may want the php-fhir-generated repo instead.
- php-fhir
- Install as Standalone Generator
- Install as Library
- Version Table
- Basic Usage
- Class Generation
- Generation Example
- Data Querying
- Response Parsing
- Parsing Example
- Serialization
- JSON Serialization
- XML Serialization
- Testing
- TODO
- Suggestions and help
Install as Standalone Generator
If you wish to use this package as a standalone generator:
- Check out the desired branch or tag
- Execute
composer install
from root of project directory - Execute
./bin/generate.sh
- Answer all prompts
- If no custom configuration file is defined, definitions will be downloaded to
./input
and classes will be generated under./output
- You can execute
./bin/generate.sh --help
for details on how to utilize this script - You can configure various aspects of this script by altering the values in ./bin/config.php
- If no custom configuration file is defined, definitions will be downloaded to
This script will download configured major versions of FHIR into the input
folder and
generate classes for every version in the output
folder.
Install as Library
If you wish to use the generator as part of a project, you can include it as a composer dependency:
From there, you can reference the Example block for a quick example on how to configure and execute the generator.
Version Table
PHPFHIR Version | PHP Versions | FHIR Versions |
---|---|---|
v2 | 5.4-7.4 | DSTU1, DSTU2, STU3, R4 (<v4.3.0) |
v3 | 8.1+ | DSTU1, DSTU2, STU3, R4, R5 |
Basic Usage
The first step is to determine the version of the FHIR spec your implementation supports. Once done, download the appropriate class definition XSDs from http://hl7.org/fhir/directory.html.
Uncompress the XSD's and place them in a directory that is readable by PHP's runtime user.
Next comes the fun:
Class Generation
The class generator utility included with this library is designed to parse the XSD's provided by the FHIR group into PHP classes, complete with markup and type hinting.
There are 2 important things to note with this section:
- Your exact implementation will probably vary, don't hesitate to ask if you need some help
- The class generation should be run ONCE per FHIR version. Once the classes have been generated they should only ever be re-generated if your server switches to a new FHIR spec
Generation Example
You can view an example config array here: bin/config.php.
Data Querying
Currently only a very simple client intended for debugging use is generated. A future goal is to generate a more fully-featured client.
Response Parsing
As part of the class generation above, a response parsing class called PHPFHIRResponseParser
will be created
and added into the root namespace directory. It currently supports JSON and XML response types.
The parser class takes a single optional boolean argument that will determine if it should attempt to load up the generated Autoloader class. By default it will do so, but you are free to configure your own autoloader and not use the generated one if you wish.
Parsing Example
Serialization
JSON Serialization
XML Serialization
XML Serialization utilizes XMLWriter.
Testing
As part of class generation, a directory & namespace called PHPFHIRTests
is created under the root namespace and
output directory.
TODO
- Implement event or pull-based XML parsing for large responses
Suggestions and help
If you have some suggestions for how this lib could be made more useful, more applicable, easier to use, etc, please let me know.
All versions of php-fhir with dependencies
ext-ctype Version *
ext-curl Version *
ext-json Version *
ext-libxml Version *
ext-simplexml Version *
psr/log Version ^3.0