Skip to content

Commit 1f2bdb3

Browse files
committed
cleanup, adding R4B
1 parent eb1e968 commit 1f2bdb3

Some content is hidden

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

55 files changed

+380
-426
lines changed

.github/workflows/tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
- 'DSTU2'
3737
- 'STU3'
3838
- 'R4'
39+
- 'R4B'
3940
- 'R5'
4041

4142
name: 'Download ${{ matrix.test-target }} Source'
@@ -74,6 +75,7 @@ jobs:
7475
- 'DSTU2'
7576
- 'STU3'
7677
- 'R4'
78+
- 'R4B'
7779
- 'R5'
7880
include:
7981
- php-version: '8.1'

bin/config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
'sourceUrl' => 'https://hl7.org/fhir/R4/fhir-all-xsd.zip',
8080
'namespace' => 'Versions\\R4',
8181
],
82+
'R4B' => [
83+
'sourceUrl' => 'https://hl7.org/fhir/R4B/fhir-all-xsd.zip',
84+
'namespace' => 'Versions\\R4B',
85+
],
8286
'R5' => [
8387
'sourceUrl' => 'https://hl7.org/fhir/R5/fhir-all-xsd.zip',
8488
'namespace' => 'Versions\\R5',

phpunit/R4B.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
bootstrap="bootstrap.php"
5+
colors="true"
6+
stopOnFailure="false"
7+
displayDetailsOnIncompleteTests="true"
8+
displayDetailsOnTestsThatTriggerDeprecations="true"
9+
displayDetailsOnTestsThatTriggerWarnings="true"
10+
displayDetailsOnTestsThatTriggerErrors="true"
11+
displayDetailsOnTestsThatTriggerNotices="true">
12+
<php>
13+
<ini name="memory_limit" value="2048M"/>
14+
<env name="PHPFHIR_TEST_INTEGRATION_ENDPOINT" value="https://lforms-fhir.nlm.nih.gov/baseR4" force="true"/>
15+
</php>
16+
<testsuites>
17+
<testsuite name="R4B">
18+
<directory>../output/DCarbone/PHPFHIRGenerated/Versions/R4B/Tests</directory>
19+
</testsuite>
20+
</testsuites>
21+
<source>
22+
<include>
23+
<directory suffix=".php">../src</directory>
24+
</include>
25+
</source>
26+
</phpunit>

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Config implements LoggerAwareInterface
7171
* @param array $params
7272
* @param \Psr\Log\LoggerInterface|null $logger
7373
*/
74-
public function __construct(array $params = [], LoggerInterface $logger = null)
74+
public function __construct(array $params = [], null|LoggerInterface $logger = null)
7575
{
7676
foreach (ConfigKeyEnum::required() as $key) {
7777
if (!isset($params[$key->value])) {

src/Enum/AttributeName.php renamed to src/Enum/AttributeNameEnum.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818
* limitations under the License.
1919
*/
2020

21-
/**
22-
* Class AttributeNameEnum
23-
* @package DCarbone\PHPFHIR\Enum
24-
*/
25-
enum AttributeName : string
21+
enum AttributeNameEnum : string
2622
{
2723
case NAME = 'name';
2824
case VALUE = 'value';
@@ -38,10 +34,10 @@ enum AttributeName : string
3834
case NAMESPACE = 'namespace';
3935

4036
/**
41-
* @param \DCarbone\PHPFHIR\Enum\AttributeName|string ...$other
37+
* @param \DCarbone\PHPFHIR\Enum\AttributeNameEnum|string ...$other
4238
* @return bool
4339
*/
44-
public function isOneOf(AttributeName|string ...$other): bool
40+
public function isOneOf(AttributeNameEnum|string ...$other): bool
4541
{
4642
return in_array($this, $other, true) || in_array($this->value, $other, true);
4743
}

src/Enum/ElementName.php renamed to src/Enum/ElementNameEnum.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* See the License for the specific language governing permissions and
1818
* limitations under the License.
1919
*/
20-
enum ElementName : string
20+
enum ElementNameEnum : string
2121
{
2222
case _INCLUDE = 'include';
2323
case IMPORT = 'import';
@@ -47,10 +47,10 @@ enum ElementName : string
4747
case ANY = 'any';
4848

4949
/**
50-
* @param \DCarbone\PHPFHIR\Enum\ElementName|string ...$other
50+
* @param \DCarbone\PHPFHIR\Enum\ElementNameEnum|string ...$other
5151
* @return bool
5252
*/
53-
public function isOneOf(ElementName|string ...$other): bool
53+
public function isOneOf(ElementNameEnum|string ...$other): bool
5454
{
5555
return in_array($this, $other, true) || in_array($this->value, $other, true);
5656
}

src/Enum/PropertyUse.php renamed to src/Enum/PropertyUseEnum.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,17 @@
1818
* limitations under the License.
1919
*/
2020

21-
/**
22-
* Class PropertyUseEnum
23-
* @package DCarbone\PHPFHIR\Enum
24-
*/
25-
enum PropertyUse: string
21+
enum PropertyUseEnum: string
2622
{
2723
case PROHIBITED = 'prohibited';
2824
case OPTIONAL = 'optional';
2925
case REQUIRED = 'required';
3026

3127
/**
32-
* @param \DCarbone\PHPFHIR\Enum\PropertyUse|string ...$other
28+
* @param \DCarbone\PHPFHIR\Enum\PropertyUseEnum|string ...$other
3329
* @return bool
3430
*/
35-
public function isOneOf(PropertyUse|string ...$other): bool
31+
public function isOneOf(PropertyUseEnum|string ...$other): bool
3632
{
3733
return in_array($this, $other, true) || in_array($this->value, $other, true);
3834
}

src/Enum/TypeKind.php

Lines changed: 0 additions & 157 deletions
This file was deleted.

src/Enum/TypeKindEnum.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace DCarbone\PHPFHIR\Enum;
4+
5+
/*
6+
* Copyright 2016-2024 Daniel Carbone (daniel.p.carbone@gmail.com)
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
enum TypeKindEnum: string
22+
{
23+
// this represents an actual value: string, int, etc.
24+
case PRIMITIVE = 'primitive';
25+
26+
// these represent types that exist to wrap a primitive
27+
case PRIMITIVE_CONTAINER = 'primitive_container';
28+
29+
// primitive type with limited possible value set
30+
case LIST = 'list';
31+
32+
// complex types
33+
case BASE = 'Base';
34+
case EXTENSION = 'Extension';
35+
case ELEMENT = 'Element';
36+
case BINARY = 'Binary';
37+
case BACKBONE_ELEMENT = 'BackboneElement';
38+
case RESOURCE = 'Resource';
39+
case RESOURCE_CONTAINER = 'ResourceContainer';
40+
case RESOURCE_INLINE = 'Resource.Inline';
41+
case QUANTITY = 'Quantity';
42+
43+
// this indicates a type that is an immediate child of a resource and not used elsewhere
44+
case RESOURCE_COMPONENT = 'resource_component';
45+
46+
// treated a bit different
47+
case PHPFHIR_XHTML = 'phpfhir_xhtml';
48+
49+
private const CONTAINER_TYPES = [
50+
self::RESOURCE_CONTAINER,
51+
self::RESOURCE_INLINE,
52+
];
53+
54+
/**
55+
* Returns true if the provided FHIR type name is the "container" type for the provided version.
56+
*
57+
* @param string $fhirName
58+
* @return bool
59+
*/
60+
public static function isContainerTypeName(string $fhirName): bool
61+
{
62+
return in_array($fhirName, self::_containerTypeStrings(), true);
63+
}
64+
65+
/**
66+
* @param \DCarbone\PHPFHIR\Enum\TypeKindEnum|string ...$other
67+
* @return bool
68+
*/
69+
public function isOneOf(TypeKindEnum|string ...$other): bool
70+
{
71+
return in_array($this, $other, true) || in_array($this->value, $other, true);
72+
}
73+
74+
/**
75+
* Returns true if this kind is the "container" kind for the provided FHIR version.
76+
*
77+
* @return bool
78+
*/
79+
public function isContainer(): bool
80+
{
81+
return in_array($this, self::CONTAINER_TYPES, true);
82+
}
83+
84+
private static function _containerTypeStrings(): array
85+
{
86+
return array_map(function (TypeKindEnum $tk): string { return $tk->value; }, self::CONTAINER_TYPES);
87+
}
88+
}

0 commit comments

Comments
 (0)