Skip to content

Commit 4052421

Browse files
committed
latest output from v4
1 parent 3a00cd3 commit 4052421

File tree

11,396 files changed

+99030
-97066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

11,396 files changed

+99030
-97066
lines changed

src/DCarbone/PHPFHIRGenerated/Autoloader.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* This class was generated with the PHPFHIR library (https://github.com/dcarbone/php-fhir) using
77
* class definitions from HL7 FHIR (https://www.hl7.org/fhir/)
88
*
9-
* Class creation date: February 12th, 2025 19:32+0000
9+
* Class creation date: February 22nd, 2025 18:56+0000
1010
*
1111
* PHPFHIR Copyright:
1212
*
@@ -76,14 +76,12 @@ abstract class Autoloader
7676
'DCarbone\PHPFHIRGenerated\Client\UnexpectedResponseCodeException' => __DIR__ . '/Client/UnexpectedResponseCodeException.php',
7777
'DCarbone\PHPFHIRGenerated\Client\HTTPMethodEnum' => __DIR__ . '/Client/HTTPMethodEnum.php',
7878
'DCarbone\PHPFHIRGenerated\Client\Config' => __DIR__ . '/Client/Config.php',
79-
'DCarbone\PHPFHIRGenerated\Client\ResponseFormatEnum' => __DIR__ . '/Client/ResponseFormatEnum.php',
8079
'DCarbone\PHPFHIRGenerated\Client\ClientErrorException' => __DIR__ . '/Client/ClientErrorException.php',
81-
'DCarbone\PHPFHIRGenerated\VersionEnum' => __DIR__ . '/VersionEnum.php',
80+
'DCarbone\PHPFHIRGenerated\FHIRVersion' => __DIR__ . '/FHIRVersion.php',
8281
'DCarbone\PHPFHIRGenerated\Types\PrimitiveContainerTypeInterface' => __DIR__ . '/Types/PrimitiveContainerTypeInterface.php',
83-
'DCarbone\PHPFHIRGenerated\Types\DSTU1PrimitiveContainerTypeInterface' => __DIR__ . '/Types/DSTU1PrimitiveContainerTypeInterface.php',
82+
'DCarbone\PHPFHIRGenerated\Types\ResourceIDTypeInterface' => __DIR__ . '/Types/ResourceIDTypeInterface.php',
8483
'DCarbone\PHPFHIRGenerated\Types\ValueContainerTrait' => __DIR__ . '/Types/ValueContainerTrait.php',
8584
'DCarbone\PHPFHIRGenerated\Types\ValueContainerTypeInterface' => __DIR__ . '/Types/ValueContainerTypeInterface.php',
86-
'DCarbone\PHPFHIRGenerated\Types\DSTU1TypeInterface' => __DIR__ . '/Types/DSTU1TypeInterface.php',
8785
'DCarbone\PHPFHIRGenerated\Types\TypeInterface' => __DIR__ . '/Types/TypeInterface.php',
8886
'DCarbone\PHPFHIRGenerated\Types\SourceXMLNamespaceTrait' => __DIR__ . '/Types/SourceXMLNamespaceTrait.php',
8987
'DCarbone\PHPFHIRGenerated\Types\CommentContainerTrait' => __DIR__ . '/Types/CommentContainerTrait.php',
@@ -113,6 +111,7 @@ abstract class Autoloader
113111
'DCarbone\PHPFHIRGenerated\Encoding\XMLSerializationOptionsTrait' => __DIR__ . '/Encoding/XMLSerializationOptionsTrait.php',
114112
'DCarbone\PHPFHIRGenerated\Encoding\XMLWriter' => __DIR__ . '/Encoding/XMLWriter.php',
115113
'DCarbone\PHPFHIRGenerated\Encoding\UnserializeConfig' => __DIR__ . '/Encoding/UnserializeConfig.php',
114+
'DCarbone\PHPFHIRGenerated\Encoding\SerializeFormatEnum' => __DIR__ . '/Encoding/SerializeFormatEnum.php',
116115
];
117116

118117
private static bool $_registered = false;

src/DCarbone/PHPFHIRGenerated/Client/AbstractClientException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* This class was generated with the PHPFHIR library (https://github.com/dcarbone/php-fhir) using
77
* class definitions from HL7 FHIR (https://www.hl7.org/fhir/)
88
*
9-
* Class creation date: February 12th, 2025 19:32+0000
9+
* Class creation date: February 22nd, 2025 18:56+0000
1010
*
1111
* PHPFHIR Copyright:
1212
*

src/DCarbone/PHPFHIRGenerated/Client/Client.php

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* This class was generated with the PHPFHIR library (https://github.com/dcarbone/php-fhir) using
77
* class definitions from HL7 FHIR (https://www.hl7.org/fhir/)
88
*
9-
* Class creation date: February 12th, 2025 19:32+0000
9+
* Class creation date: February 22nd, 2025 18:56+0000
1010
*
1111
* PHPFHIR Copyright:
1212
*
@@ -26,6 +26,9 @@
2626
*
2727
*/
2828

29+
use DCarbone\PHPFHIRGenerated\Encoding\SerializeFormatEnum;
30+
use DCarbone\PHPFHIRGenerated\FHIRVersion;
31+
use DCarbone\PHPFHIRGenerated\Types\ResourceTypeInterface;
2932

3033
/**
3134
* Class Client
@@ -41,7 +44,7 @@ class Client implements ClientInterface
4144
private const _BASE_CURL_OPTS = [
4245
CURLOPT_FOLLOWLOCATION => true,
4346
CURLOPT_RETURNTRANSFER => true,
44-
CURLOPT_USERAGENT => 'php-fhir client (build: February 12th, 2025 19:32+0000;)',
47+
CURLOPT_USERAGENT => 'php-fhir client (build: February 22nd, 2025 18:56+0000;)',
4548
];
4649

4750
protected Config $_config;
@@ -70,62 +73,66 @@ public function getConfig(): Config
7073
*/
7174
public function exec(Request $request): Response
7275
{
73-
$queryParams = array_merge($this->_config->getQueryParams(), $request->queryParams ?? []);
74-
76+
$queryParams = array_merge($this->_config->getDefaultQueryParams(), $request->queryParams ?? []);
7577
$format = $request->format ?? $this->_config->getDefaultFormat();
76-
if (null !== $format) {
77-
$queryParams[self::_PARAM_FORMAT] = $format;
78-
}
78+
$parseResponseHeaders = match(true) {
79+
isset($request->parseResponseHeaders) => $request->parseResponseHeaders,
80+
default => $this->_config->getParseResponseHeaders(),
81+
};
82+
83+
$queryParams[self::_PARAM_FORMAT] = $format->value;
7984
if (isset($request->sort)) {
8085
$queryParams[self::_PARAM_SORT] = $request->sort;
8186
}
8287
if (isset($request->count)) {
8388
$queryParams[self::_PARAM_COUNT] = $request->count;
8489
}
8590

86-
$rc = new Response();
87-
8891
$url = "{$this->_config->getAddress()}{$request->path}?" . http_build_query($queryParams, '', '&', PHP_QUERY_RFC3986);
8992

90-
$curlOpts = self::_BASE_CURL_OPTS
91-
+ [CURLOPT_CUSTOMREQUEST => $request->method]
92-
+ array_merge($this->_config->getCurlOpts(), $request->options ?? []);
93+
$rc = new Response($request->method, $url, $format);
9394

94-
$parseResponseHeaders = ($this->_config->getParseResponseHeaders()
95-
&& (!isset($req->parseResponseHeaders) || $req->parseResponseHeaders))
96-
|| (isset($req->parseResponseHeaders) && $req->parseResponseHeaders);
95+
$curlOpts = self::_BASE_CURL_OPTS + array_merge($this->_config->getCurlOpts(), $request->options ?? []);
9796

9897
if ($parseResponseHeaders) {
98+
$rc->headers = new ResponseHeaders();
9999
$curlOpts[CURLOPT_HEADER] = 1;
100100
$curlOpts[CURLOPT_HEADERFUNCTION] = function($ch, string $line) use (&$rc): int {
101101
return $rc->headers->addLine($line);
102102
};
103-
} else {
104-
$curlOpts[CURLOPT_HEADER] = 0;
103+
}
104+
105+
if (!isset($curlOpts[CURLOPT_HTTPHEADER])) {
106+
$curlOpts[CURLOPT_HTTPHEADER] = [];
107+
}
108+
109+
if (HTTPMethodEnum::GET !== $request->method) {
110+
$curlOpts[CURLOPT_CUSTOMREQUEST] = $request->method->value;
111+
$curlOpts[CURLOPT_HTTPHEADER][] = "X-HTTP-Method-Override: {$request->method->value}";
112+
}
113+
114+
$curlOpts[CURLOPT_HTTPHEADER][] = $this->_buildAcceptHeader($request, $format);
115+
116+
if (isset($request->resource)) {
117+
$curlOpts[CURLOPT_HTTPHEADER][] = $this->_buildContentTypeHeader($request, $format);
105118
}
106119

107120
$ch = curl_init($url);
108121
if (!curl_setopt_array($ch, $curlOpts)) {
109122
throw new \DomainException(sprintf(
110-
'Error setting curl opts for query "%s" with value: %s',
123+
'curl_setopt_array returned false for "%s" with options: %s',
111124
$url,
112125
var_export($curlOpts, true),
113126
));
114127
}
115128

116129
$resp = curl_exec($ch);
117-
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
118-
$err = curl_error($ch);
119-
$errno = curl_errno($ch);
130+
$rc->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
131+
$rc->err = curl_error($ch);
132+
$rc->errno = curl_errno($ch);
120133
curl_close($ch);
121134

122-
$rc->method = $request->method;
123-
$rc->url = $url;
124-
$rc->code = $code;
125-
$rc->err = $err;
126-
$rc->errno = $errno;
127-
128-
if (0 === $errno) {
135+
if (0 === $rc->errno) {
129136
if ($parseResponseHeaders) {
130137
$rc->resp = substr($resp, $rc->headers->getLength());
131138
} else {
@@ -135,4 +142,43 @@ public function exec(Request $request): Response
135142

136143
return $rc;
137144
}
145+
146+
protected function _buildAcceptHeader(Request $request,
147+
SerializeFormatEnum $format): string
148+
{
149+
$ver = match(true) {
150+
isset($request->version) => $request->version,
151+
isset($request->resource) => $request->resource->_getFHIRVersion(),
152+
default => null,
153+
};
154+
if (null === $ver) {
155+
return "Accept: application/{$format->value}+json, application/json+{$format->value}";
156+
} else if ($ver->getFHIRVersionInteger() < FHIRVersion::STU3_MIN_VERSION_INTEGER) {
157+
return "Accept: application/{$format->value}+fhir; fhirVersion={$ver->getFHIRShortVersion()}";
158+
} else {
159+
return "Accept: application/fhir+{$format->value}; fhirVersion={$ver->getFHIRShortVersion()}";
160+
}
161+
}
162+
163+
protected function _buildContentTypeHeader(Request $request,
164+
SerializeFormatEnum $format): string
165+
{
166+
$ver = $request->resource->_getFHIRVersion();
167+
if (HTTPMethodEnum::PATCH === $request->method) {
168+
return "Content-Type: application/{$format->value}-patch+{$format->value}; fhirVersion={$ver->getFHIRShortVersion()}";
169+
} else if ($ver->getFHIRVersionInteger() < FHIRVersion::STU3_MIN_VERSION_INTEGER) {
170+
return "Content-Type: application/{$format->value}+fhir; fhirVersion={$ver->getFHIRShortVersion()}";
171+
} else {
172+
return "Content-Type: application/fhir+{$format->value}; fhirVersion={$ver->getFHIRShortVersion()}";
173+
}
174+
}
175+
176+
protected function _buildBody(ResourceTypeInterface $resource,
177+
SerializeFormatEnum $format): string
178+
{
179+
return match ($format) {
180+
SerializeFormatEnum::JSON => json_encode($resource),
181+
SerializeFormatEnum::XML => $resource->xmlSerialize(config: $this->_version->getConfig()->getSerializeConfig()),
182+
};
183+
}
138184
}

src/DCarbone/PHPFHIRGenerated/Client/ClientErrorException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* This class was generated with the PHPFHIR library (https://github.com/dcarbone/php-fhir) using
77
* class definitions from HL7 FHIR (https://www.hl7.org/fhir/)
88
*
9-
* Class creation date: February 12th, 2025 19:32+0000
9+
* Class creation date: February 22nd, 2025 18:56+0000
1010
*
1111
* PHPFHIR Copyright:
1212
*

src/DCarbone/PHPFHIRGenerated/Client/ClientInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* This class was generated with the PHPFHIR library (https://github.com/dcarbone/php-fhir) using
77
* class definitions from HL7 FHIR (https://www.hl7.org/fhir/)
88
*
9-
* Class creation date: February 12th, 2025 19:32+0000
9+
* Class creation date: February 22nd, 2025 18:56+0000
1010
*
1111
* PHPFHIR Copyright:
1212
*

src/DCarbone/PHPFHIRGenerated/Client/Config.php

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* This class was generated with the PHPFHIR library (https://github.com/dcarbone/php-fhir) using
77
* class definitions from HL7 FHIR (https://www.hl7.org/fhir/)
88
*
9-
* Class creation date: February 12th, 2025 19:32+0000
9+
* Class creation date: February 22nd, 2025 18:56+0000
1010
*
1111
* PHPFHIR Copyright:
1212
*
@@ -26,6 +26,8 @@
2626
*
2727
*/
2828

29+
use DCarbone\PHPFHIRGenerated\Encoding\SerializeFormatEnum;
30+
2931
/**
3032
* Class Config
3133
*
@@ -34,35 +36,30 @@
3436
*/
3537
class Config
3638
{
37-
/** @var string */
3839
private string $_address;
39-
/** @var array */
4040
private array $_curlOpts;
41-
/** @var array */
42-
private array $_queryParams;
43-
/** @var null|\DCarbone\PHPFHIRGenerated\Client\ResponseFormatEnum */
44-
private null|ResponseFormatEnum $_defaultFormat;
45-
/** @var bool */
41+
private array $_defaultQueryParams;
42+
private SerializeFormatEnum $_defaultFormat;
4643
private bool $_parseResponseHeaders;
4744

4845
/**
4946
* Config Constructor
5047
*
5148
* @param string $address Fully qualified address of FHIR server, including scheme, port, and any path prefix.
52-
* @param null|\DCarbone\PHPFHIRGenerated\Client\ResponseFormatEnum $defaultFormat Default format to request from server. If not provided, server default will be used. May be overridden by an individual request.
53-
* @param array $queryParams Base query parameters array. These will be added to every request. May be overridden by an individual request.
49+
* @param \DCarbone\PHPFHIRGenerated\Encoding\SerializeFormatEnum $defaultFormat Default serialization format. Defaults to XML.
50+
* @param array $defaultQueryParams Base query parameters array. These will be added to every request. May be overridden by an individual request.
5451
* @param array $curlOpts Base curl options array. These will be added to every request. May be overridden by an individual request.
55-
* @param bool $parseResponseHeaders Whether or not to parse headers from response. This adds a small amount of overhead, so it is recommended to only set to true if actually used.
52+
* @param bool $parseResponseHeaders Whether or not to parse headers from response. This adds overhead to parsing each response, but is also necessary to extract response version information.
5653
*/
5754
public function __construct(string $address,
58-
null|ResponseFormatEnum $defaultFormat = null,
59-
array $queryParams = [],
55+
SerializeFormatEnum $defaultFormat = SerializeFormatEnum::XML,
56+
array $defaultQueryParams = [],
6057
array $curlOpts = [],
61-
bool $parseResponseHeaders = false)
58+
bool $parseResponseHeaders = true)
6259
{
6360
$this->_address = $address;
6461
$this->_defaultFormat = $defaultFormat;
65-
$this->_queryParams = $queryParams;
62+
$this->_defaultQueryParams = $defaultQueryParams;
6663
$this->_curlOpts = $curlOpts;
6764
$this->_parseResponseHeaders = $parseResponseHeaders;
6865
}
@@ -76,19 +73,19 @@ public function getAddress(): string
7673
}
7774

7875
/**
79-
* @return null|\DCarbone\PHPFHIRGenerated\Client\ResponseFormatEnum
76+
* @return \DCarbone\PHPFHIRGenerated\Encoding\SerializeFormatEnum
8077
*/
81-
public function getDefaultFormat(): null|ResponseFormatEnum
78+
public function getDefaultFormat(): SerializeFormatEnum
8279
{
8380
return $this->_defaultFormat;
8481
}
8582

8683
/**
8784
* @return array
8885
*/
89-
public function getQueryParams(): array
86+
public function getDefaultQueryParams(): array
9087
{
91-
return $this->_queryParams;
88+
return $this->_defaultQueryParams;
9289
}
9390

9491
/**

src/DCarbone/PHPFHIRGenerated/Client/HTTPMethodEnum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* This class was generated with the PHPFHIR library (https://github.com/dcarbone/php-fhir) using
77
* class definitions from HL7 FHIR (https://www.hl7.org/fhir/)
88
*
9-
* Class creation date: February 12th, 2025 19:32+0000
9+
* Class creation date: February 22nd, 2025 18:56+0000
1010
*
1111
* PHPFHIR Copyright:
1212
*

0 commit comments

Comments
 (0)