From c0f83475120a85cd358215baa095db66de430e07 Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Thu, 30 Jan 2025 14:02:49 -0600 Subject: [PATCH] gimping dstu1 as it isn't worth the effort. --- template/core/client/class_client.php | 49 ++++++++++--------- template/tests/versions/types/class.php | 11 +++-- .../versions/core/class_version_client.php | 22 +++++++-- 3 files changed, 50 insertions(+), 32 deletions(-) diff --git a/template/core/client/class_client.php b/template/core/client/class_client.php index be444f17..b56111af 100644 --- a/template/core/client/class_client.php +++ b/template/core/client/class_client.php @@ -24,17 +24,20 @@ $coreFiles = $config->getCoreFiles(); $imports = $coreFile->getImports(); -$imports->addCoreFileImportsByName( - PHPFHIR_CLIENT_CLASSNAME_CONFIG, - PHPFHIR_CLIENT_CLASSNAME_REQUEST, - PHPFHIR_CLIENT_CLASSNAME_RESPONSE, - PHPFHIR_CLIENT_ENUM_HTTP_METHOD, -); -$confClass = $coreFiles->getCoreFileByEntityName(PHPFHIR_CLIENT_CLASSNAME_CONFIG); -$reqClass = $coreFiles->getCoreFileByEntityName(PHPFHIR_CLIENT_CLASSNAME_REQUEST); -$respClass = $coreFiles->getCoreFileByEntityName(PHPFHIR_CLIENT_CLASSNAME_RESPONSE); -$htMethodEnum = $coreFiles->getCoreFileByEntityName(PHPFHIR_CLIENT_ENUM_HTTP_METHOD); +$clientInterface = $coreFiles->getCoreFileByEntityName(PHPFHIR_CLIENT_INTERFACE_CLIENT); +$clientConfigClass = $coreFiles->getCoreFileByEntityName(PHPFHIR_CLIENT_CLASSNAME_CONFIG); +$clientRequestClass = $coreFiles->getCoreFileByEntityName(PHPFHIR_CLIENT_CLASSNAME_REQUEST); +$clientResponseClass = $coreFiles->getCoreFileByEntityName(PHPFHIR_CLIENT_CLASSNAME_RESPONSE); +$clientHTTPMethodEnum = $coreFiles->getCoreFileByEntityName(PHPFHIR_CLIENT_ENUM_HTTP_METHOD); + +$imports->addCoreFileImports( + $clientInterface, + $clientConfigClass, + $clientRequestClass, + $clientResponseClass, + $clientHTTPMethodEnum, +); ob_start(); echo 'declare(strict_types=1); @@ -46,12 +49,12 @@ /** - * Class + * Class getEntityName(); ?> * - * Basic implementation of the interface. + * Basic implementation of the getEntityName(); ?> interface. */ -class implements +class getEntityName(); ?> implements getEntityName(); ?> { private const _PARAM_FORMAT = '_format'; @@ -64,33 +67,33 @@ class implements 'php-fhir client (build: getStandardDate(); ?>;)', ]; - protected $_config; + protected getEntityName(); ?> $_config; /** - * Constructor + * getEntityName(); ?> Constructor * - * @param string|getFullyQualifiedName(true); ?> $config Fully qualified address of FHIR server, or configuration object. + * @param string|getFullyQualifiedName(true); ?> $config Fully qualified address of FHIR server, or configuration object. */ - public function __construct(string| $config) + public function __construct(string|getEntityName(); ?> $config) { if (is_string($config)) { - $config = new (address: $config); + $config = new getEntityName(); ?>(address: $config); } $this->_config = $config; } - public function getConfig(): + public function getConfig(): getEntityName(); ?> { return $this->_config; } /** - * @param getFullyQualifiedName(true); ?> $request - * @return getFullyQualifiedName(true); ?> + * @param getFullyQualifiedName(true); ?> $request + * @return getFullyQualifiedName(true); ?> */ - public function exec( $request): + public function exec(getEntityName(); ?> $request): getEntityName(); ?> { $queryParams = array_merge($this->_config->getQueryParams(), $request->queryParams ?? []); @@ -106,7 +109,7 @@ public function exec( $request): $queryParams[self::_PARAM_COUNT] = $request->count; } - $rc = new (); + $rc = new getEntityName(); ?>(); $url = "{$this->_config->getAddress()}{$request->path}?" . http_build_query($queryParams, '', '&', PHP_QUERY_RFC3986); diff --git a/template/tests/versions/types/class.php b/template/tests/versions/types/class.php index ee8855fc..80df692f 100644 --- a/template/tests/versions/types/class.php +++ b/template/tests/versions/types/class.php @@ -46,9 +46,6 @@ if ($type->isResourceType()) { $imports - ->addVersionTypeImports( - $bundleType - ) ->addCoreFileImportsByName( PHPFHIR_CLIENT_CLASSNAME_CONFIG, PHPFHIR_CLIENT_CLASSNAME_CLIENT, @@ -61,6 +58,12 @@ PHPFHIR_VERSION_CLASSNAME_VERSION_CLIENT, PHPFHIR_VERSION_ENUM_VERSION_TYPES, ); + + if (!$version->getSourceMetadata()->isDSTU1()) { + $imports->addVersionTypeImports( + $bundleType + ); + } } $typeKind = $type->getKind(); @@ -145,7 +148,7 @@ public function testCanSetValueFromString() $this->assertEquals('', (string)$n); } -isResourceType() && !$type->getKind()->isResourceContainer($version)) : ?> +getSourceMetadata()->isDSTU1() && $type->isResourceType() && !$type->getKind()->isResourceContainer($version)) : ?> public function testCanTranscodeBundleJSON() { diff --git a/template/versions/core/class_version_client.php b/template/versions/core/class_version_client.php index 189447d3..5fe8a452 100644 --- a/template/versions/core/class_version_client.php +++ b/template/versions/core/class_version_client.php @@ -21,6 +21,8 @@ /** @var \DCarbone\PHPFHIR\Version $version */ /** @var \DCarbone\PHPFHIR\CoreFile $coreFile */ +$sourceMeta = $version->getSourceMetadata(); + $types = $version->getDefinition()->getTypes(); $idType = $types->getTypeByName('id'); @@ -46,7 +48,7 @@ ); foreach($types->getIterator() as $type) { - if ($type->isResourceType() && !$type->isAbstract() && !$type->getKind()->isResourceContainer($version)) { + if (($type->isResourceType() || $type->hasResourceTypeParent()) && !$type->isAbstract() && !$type->getKind()->isResourceContainer($version)) { $imports->addVersionTypeImports($type); } } @@ -98,12 +100,12 @@ public function __construct( $clie } /** - * Queries for one or more resources of a given type, returning the raw response fromm the server. + * Queries for one isDSTU1()) : ?>resourceor more resources of a given type, returning the raw response fromm the server. * * @see https://www.hl7.org/fhir/http.html#read * * @param getFullyQualifiedName(true); ?> $resourceType - * @param null|string|getFullyQualifiedClassName(true); ?>|getFullyQualifiedClassName(true); ?> $resourceID + * @param isDSTU1()) : ?>null|string|getFullyQualifiedClassName(true); ?>|getFullyQualifiedClassName(true); ?> $resourceID * @param null|int $count * @param null|string|getFullyQualifiedName(true); ?> $sort May be a string value if your server supports non-standard sorting methods * @param null|getFullyQualifiedName(true); ?> $format @@ -114,7 +116,7 @@ public function __construct( $clie * @throws \Exception */ public function readRaw( $resourceType, - null|string|getClassName(); ?>|getClassName(); ?> $resourceID = null, + isDSTU1()) : ?>null|string|getClassName(); ?>|getClassName(); ?> $resourceIDisDSTU1()) : ?> = null, null|int $count = null, null|string| $sort = null, null| $format = null, @@ -124,6 +126,13 @@ public function readRaw( $resou { $path = "/{$resourceType->value}"; +isDSTU1()) : ?> + $resourceID = trim((string)$resourceID); + if ('' === $resourceID) { + throw new \InvalidArgumentException('Resource ID must be null or valued.'); + } + $path .= "/{$resourceID}"; + if (null !== $resourceID) { $resourceID = trim((string)$resourceID); if ('' === $resourceID) { @@ -131,6 +140,7 @@ public function readRaw( $resou } $path .= "/{$resourceID}"; } + $req = new ( method: ::GET, path: $path, @@ -153,6 +163,7 @@ public function readRaw( $resou return $this->_client->exec($req); } +isDSTU1()) : ?> /** * Queries for one or more resources of a given type, returning the unserialized response from the server. * @@ -183,6 +194,7 @@ public function read( $resource return ::parse($this->_version, $rc->resp); } + /** * @param getFullyQualifiedName(true); ?> $rc * @throws getFullyQualifiedName(true); ?> @@ -200,7 +212,7 @@ protected function _requireOK( $ } } getDefinition()->getTypes()->getNameSortedIterator() as $rsc) : - if (!$rsc->isResourceType() || $rsc->isAbstract() || $rsc->getKind()->isResourceContainer($version)) { + if (!($rsc->isResourceType() || $rsc->hasResourceTypeParent()) || $rsc->isAbstract() || $rsc->getKind()->isResourceContainer($version)) { continue; }