dcarbone/php-fhir-generated
Composer 安装命令:
composer require dcarbone/php-fhir-generated
包简介
Pre-generated classes from dcarbone/php-fhir
README 文档
README
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 — complete with JSON/XML serialization, field validation, and a built-in REST client.
Features
- All major FHIR versions — DSTU1, DSTU2, STU3, R4, R4B, and R5
- Strongly-typed models — every resource, element, and primitive as a PHP class with full constructor support
- JSON & XML serialization — encode/decode resources using native PHP extensions
- Built-in FHIR REST client — read, create, update, patch, and delete resources via cURL
- Automatic resource parsing — detect and unserialize arbitrary FHIR responses by
resourceTypeor XML element name - Schema-driven validation — built-in rules derived from the FHIR schema, with support for custom rules
- PHP 8.1+ named arguments — clean, readable type construction without positional
nullpadding
Supported FHIR Versions
| Version | FHIR Spec |
|---|---|
| DSTU1 | v0.x |
| DSTU2 | v1.x |
| STU3 | v3.x |
| R4 | v4.0 |
| R4B | v4.3 |
| R5 | v5.x |
Requirements
- PHP 8.1 or newer
- Extensions:
curl,dom,json,libxml,simplexml,xmlreader,xmlwriter
Installation
Via Composer (recommended)
composer require dcarbone/php-fhir-generated
Standalone
Clone or download this repository and require the built-in autoloader:
require __DIR__ . '/src/DCarbone/PHPFHIRGenerated/Autoloader.php';
Quick Start
Constructing a Resource
<?php use DCarbone\PHPFHIRGenerated\Versions\R4\Types\FHIRElement\FHIRHumanName; use DCarbone\PHPFHIRGenerated\Versions\R4\Types\FHIRResource\FHIRDomainResource\FHIRPatient; $patient = new FHIRPatient( id: 'patient-1', language: 'en-us', name: [ new FHIRHumanName(given: ['Real'], family: 'Human'), ], );
Serializing to JSON
echo json_encode($patient, JSON_PRETTY_PRINT);
Unserializing from JSON
$patient = FHIRPatient::jsonUnserialize('{"resourceType":"Patient","id":"patient-1"}');
Fetching from a FHIR Server
<?php use DCarbone\PHPFHIRGenerated\Client\Client; use DCarbone\PHPFHIRGenerated\Client\Config; use DCarbone\PHPFHIRGenerated\Encoding\SerializeFormatEnum; use DCarbone\PHPFHIRGenerated\Versions\R4\Version; use DCarbone\PHPFHIRGenerated\Versions\R4\VersionClient; $config = new Config( address: 'https://hapi.fhir.org/baseR4', defaultFormat: SerializeFormatEnum::JSON, ); $client = new VersionClient(new Client($config), new Version()); $patient = $client->readOnePatient(resourceID: 'example');
Validating a Resource
$errors = $patient->_getValidationErrors(); if ([] === $errors) { echo "Resource is valid!\n"; } else { foreach ($errors as $path => $fieldErrors) { foreach ($fieldErrors as $rule => $message) { echo "{$path}: {$message}\n"; } } }
Documentation
Full documentation is available on the Wiki:
- Configuration — Version, serialization, and unserialization options
- Constructing Types — Creating resource, element, and primitive instances
- Serialization — Encoding and decoding resources in JSON and XML
- FHIR Client — Built-in HTTP client for FHIR REST operations
- Resource Parsing — Automatically parsing arbitrary FHIR responses
- Validation — Built-in and custom validation rules
- Type System — Type hierarchy and interfaces
- Autoloading — Class loading with and without Composer
- Migrating from v2 — Breaking changes and upgrade guide from the previous major version
Related Projects
| Project | Description |
|---|---|
| dcarbone/php-fhir | The code generator that produces this library from FHIR schema definitions |
| HL7 FHIR | The FHIR specification itself |
License
dcarbone/php-fhir-generated 适用场景与选型建议
dcarbone/php-fhir-generated 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 508.99k 次下载、GitHub Stars 达 44, 最近一次更新时间为 2016 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「hl7」 「ehr」 「fhir」 「php-fhir」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dcarbone/php-fhir-generated 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dcarbone/php-fhir-generated 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dcarbone/php-fhir-generated 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A port of the PEAR Net_HL7 library to PHP5.3+
Pre-generated FHIR model classes for R4, R4B, and R5 versions
Official PHP SDK for the DrChrono API - Complete EHR/Practice Management integration
Official Aqua-io API library client for PHP (ICD-9 and ICD-10)
Shared interfaces, attributes and utilities for FHIR packages
PHP representation of HL7 FHIR R4 (v4.0.1)
统计信息
- 总下载量: 508.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 44
- 点击次数: 26
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2016-04-28