Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: V4 #115

Closed
wants to merge 96 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
89d32d5
creating method crud
dcarbone May 4, 2024
29b1fa8
more client work
dcarbone May 5, 2024
b13cde8
busted thoughts
dcarbone Jun 7, 2024
c668ec3
fuckin' it all up
dcarbone Jul 19, 2024
751bc78
working through some ideas
dcarbone Jul 19, 2024
56eb8e4
fixing composer.json
dcarbone Jul 19, 2024
8ec8325
more little work
dcarbone Jul 20, 2024
db4bf11
more work, need to carefully consider constants
dcarbone Jul 20, 2024
450dba6
merging in main, some small thoughts
dcarbone Aug 31, 2024
2c861be
lots more work done
dcarbone Sep 1, 2024
ab04f62
little bit more work
dcarbone Sep 2, 2024
e78d88c
more little bits of work
dcarbone Sep 2, 2024
605a7c5
little bit more work
dcarbone Sep 9, 2024
e5e760a
little things
dcarbone Sep 9, 2024
fc26220
moving on along
dcarbone Sep 13, 2024
5b56e13
workin' on it
dcarbone Nov 9, 2024
c4c240a
more small steps
dcarbone Nov 9, 2024
69f6bf0
more thoughts
dcarbone Nov 10, 2024
70338f5
little better.
dcarbone Nov 10, 2024
21e0f0e
more little steps
dcarbone Nov 10, 2024
1e964f9
closer.
dcarbone Nov 12, 2024
7a2d523
few more small things
dcarbone Nov 12, 2024
a3ba859
few lil things
dcarbone Nov 17, 2024
37b97d5
do I even need to bother with an autoloader anymore?
dcarbone Nov 17, 2024
4526ab5
eh.
dcarbone Nov 17, 2024
fb9b50d
few more small fixes
dcarbone Nov 20, 2024
7efb8af
Merge remote-tracking branch 'origin/main' into feature/api-client
dcarbone Nov 20, 2024
ba9140b
more small steps
dcarbone Nov 20, 2024
242053f
more bits of work
dcarbone Dec 6, 2024
3563782
bit of cleanup around type maps and contained types
dcarbone Dec 6, 2024
92324c2
lots of work, utterly broken, need to figure out version config chain
dcarbone Dec 9, 2024
83348f0
coming along with the config...
dcarbone Dec 11, 2024
b850dfa
few little fixups
dcarbone Dec 11, 2024
300b7ac
getting close...
dcarbone Dec 11, 2024
fd3fe4c
sloppy filename stuff
dcarbone Dec 11, 2024
183f0a5
Merge branch 'main' into feature/api-client
dcarbone Dec 11, 2024
dfff869
breaking it to remind myself later.
dcarbone Dec 11, 2024
ce31fff
drastically re-worked autoloader system, working on root config updates
dcarbone Dec 12, 2024
0a33ad2
config and init thoughts, needs rethought-ing.
dcarbone Dec 13, 2024
4f72d79
thoughts, but not convinced.
dcarbone Dec 13, 2024
55fcb96
factory probably done?
dcarbone Dec 17, 2024
9d5fd04
getting there.
dcarbone Dec 18, 2024
4734fa0
getting closer.
dcarbone Dec 18, 2024
6987c1a
some test fixes, need to redo core
dcarbone Dec 18, 2024
7ef2267
derp
dcarbone Dec 18, 2024
252a7ab
derp
dcarbone Dec 18, 2024
e9279f6
small fixes
dcarbone Dec 18, 2024
4670bd1
little bit of cleanup, handling dstu1 Binary type
dcarbone Dec 18, 2024
f4e14e8
some test fixes
dcarbone Dec 18, 2024
686420a
api client fix
dcarbone Dec 18, 2024
95af814
need to define a couple response exceptions
dcarbone Dec 19, 2024
36ed9e0
enum
dcarbone Dec 20, 2024
99088df
adding some typed exceptions
dcarbone Dec 20, 2024
7ec4980
derp
dcarbone Dec 20, 2024
d9694b2
sure.
dcarbone Dec 20, 2024
a133f31
probably need to re-design tests...
dcarbone Dec 21, 2024
056ea90
removing test endpoint from config
dcarbone Dec 21, 2024
c9cbff9
sure.
dcarbone Dec 21, 2024
011f22b
brainfart
dcarbone Dec 21, 2024
8b2ab16
more brain fart
dcarbone Dec 21, 2024
07af562
move test endpoint into phpunit config
dcarbone Dec 21, 2024
6b12d8c
sigh.
dcarbone Dec 21, 2024
e627fb5
siiiiggghhh
dcarbone Dec 21, 2024
05f4c5e
O_O
dcarbone Dec 21, 2024
bc18d5a
disabling validator tests
dcarbone Dec 21, 2024
0535136
don't try to construct abstract parents
dcarbone Dec 21, 2024
c255e74
autoloader improvements, small testing improvements
dcarbone Dec 22, 2024
b391ffd
shut up github action warnings
dcarbone Dec 22, 2024
3f4e032
adding skipped and warning printing
dcarbone Dec 22, 2024
f0b2b0d
use nih for stu3 and r4
dcarbone Dec 22, 2024
c445a97
don't fuss with storing test resources
dcarbone Dec 22, 2024
8071945
fixing github action step id reference
dcarbone Dec 22, 2024
6b9fa90
no fixes, thinking through stuff.
dcarbone Dec 22, 2024
90fd2e6
tests still need some work.
dcarbone Dec 24, 2024
53c965f
fixing a few deprecations, adding 8.4 to test matrix
dcarbone Dec 26, 2024
5308eb3
working on core tests a bit
dcarbone Dec 26, 2024
60e4fb6
skip FHIR sources for Core
dcarbone Dec 26, 2024
eb1e968
thinking what to do with generator
dcarbone Dec 28, 2024
1f2bdb3
cleanup, adding R4B
dcarbone Dec 28, 2024
13f73de
small cleanup
dcarbone Dec 28, 2024
65074a3
much better determination of 'special' dstu1 stuff
dcarbone Dec 28, 2024
09c193a
moving validator from trait to core class
dcarbone Dec 29, 2024
e9b9e3f
r4b test support and better trait output
dcarbone Dec 29, 2024
ec9220d
re-thinking autoloader, config, and execution a bit
dcarbone Dec 29, 2024
43ebe79
sure, mess with it more later.
dcarbone Dec 29, 2024
c325810
enable only testing and generating core classes
dcarbone Dec 29, 2024
7fa882e
fixing core factory test
dcarbone Dec 30, 2024
33ed442
\Iterator -> iterable
dcarbone Dec 30, 2024
368b742
small updates, working on fleshing out client
dcarbone Dec 30, 2024
25bbc95
simplfying templates a bit, adding ID access for resources in client,…
dcarbone Dec 30, 2024
5b0352a
more template coalescing
dcarbone Dec 30, 2024
3243c8b
validations cleanup and fleshing out api client a little bit
dcarbone Dec 30, 2024
bb6fb53
odd php 8.4 error
dcarbone Dec 30, 2024
dd5f057
forgot to update test for 8.4
dcarbone Dec 30, 2024
95dc360
i see what i did.
dcarbone Dec 30, 2024
f591be5
remove explicit phpunit run flags
dcarbone Dec 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
/README.md export-ignore
/output export-ignore
/input export-ignore
/phpunit export-ignore
/phpunit export-ignore
fhir_test_resources.tar.gz export-ignore
13 changes: 1 addition & 12 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
# These are supported funding model platforms

github: dcarbone
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: dcarbone
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
ko_fi: dcarbone
7 changes: 3 additions & 4 deletions .github/actions/load-fhir-validator/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ runs:
echo 'url=${{ inputs.base-url }}/${{ inputs.version }}/${{ inputs.filename }}' >> $GITHUB_OUTPUT
echo 'cache-key=fhir-validator-${{ inputs.version }}-2' >> $GITHUB_OUTPUT

- uses: actions/cache@v4
id: cache
- name: 'Init validator cache'
uses: actions/cache@v4
id: validator-cache
with:
path: |
${{ github.workspace }}/bin
/home/runner/.fhir
key: '${{ steps.vars.outputs.cache-key }}'
save-always: true

- name: 'Install Java'
if: steps.cache.outputs.cache-hit != 'true' && steps.cache.outputs.cache-hit != true
Expand Down Expand Up @@ -62,4 +62,3 @@ runs:
java -jar '${{ github.workspace }}/bin/validator_cli.jar' -version 4.3.0
java -jar '${{ github.workspace }}/bin/validator_cli.jar' -version 5.0.0
echo '::endgroup::'

5 changes: 5 additions & 0 deletions .github/actions/load-fhir-xsd/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,10 @@ runs:

unzip -o -qq '${{ steps.vars.outputs.zip-filename }}' -d '${{ steps.vars.outputs.xsd-cache-dir }}'

if [ -d '${{ steps.vars.outputs.xsd-cache-dir }}/fhir-all-xsd' ]; then
mv '${{ steps.vars.outputs.xsd-cache-dir }}/fhir-all-xsd'/* '${{ steps.vars.outputs.xsd-cache-dir }}'
rmdir '${{ steps.vars.outputs.xsd-cache-dir }}/fhir-all-xsd'
fi

ls -l '${{ steps.vars.outputs.cache-dir}}'
ls -l '${{ steps.vars.outputs.xsd-cache-dir }}'
62 changes: 47 additions & 15 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,25 @@ on:

jobs:
load-fhir-source:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
fhir-version: [ 'DSTU1', 'DSTU2', 'STU3', 'R4', 'R5' ]

name: 'Download ${{ matrix.fhir-version }} Source'
test-target:
- 'DSTU1'
- 'DSTU2'
- 'STU3'
- 'R4'
- 'R4B'
- 'R5'

name: 'Download ${{ matrix.test-target }} Source'
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/load-fhir-xsd
with:
version: '${{ matrix.fhir-version }}'
version: '${{ matrix.test-target }}'


# load-fhir-validator:
Expand All @@ -58,24 +64,39 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: [ '8.1', '8.2', '8.3' ]
fhir-version: [ 'DSTU1', 'DSTU2', 'STU3', 'R4', 'R5' ]
php-version:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
test-target:
- 'Core'
- 'DSTU1'
- 'DSTU2'
- 'STU3'
- 'R4'
- 'R4B'
- 'R5'
include:
- php-version: '8.1'
phpunit-version: '10.5'
- php-version: '8.2'
phpunit-version: '11.1'
- php-version: '8.3'
phpunit-version: '11.1'
name: '${{ matrix.fhir-version }} - PHP ${{ matrix.php-version }} - PHPUnit ${{ matrix.phpunit-version }}'
- php-version: '8.4'
phpunit-version: '11.1'

name: '${{ matrix.test-target }} - PHP ${{ matrix.php-version }} - PHPUnit ${{ matrix.phpunit-version }}'
steps:
- name: 'Check the stuff out'
uses: actions/checkout@v4

- name: 'Load FHIR ${{ matrix.fhir-version }} Source'
- name: 'Load FHIR ${{ matrix.test-target }} Source'
if: matrix.test-target != 'Core'
uses: ./.github/actions/load-fhir-xsd
with:
version: '${{ matrix.fhir-version }}'
version: '${{ matrix.test-target }}'

# - name: 'Install FHIR validator'
# uses: ./.github/actions/load-fhir-validator
Expand Down Expand Up @@ -105,23 +126,34 @@ jobs:
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: 'Cache Composer Stuff'
- name: 'Init composer dep cache'
id: cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.phpunit-version }}-${{ hashFiles('composer.lock') }}"
save-always: true

- name: 'Install Composer deps'
# language=sh
run: |
rm composer.lock
composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: 'Generate code'
- name: 'Save composer dep cache'
if: steps.cache.outputs.cache-hit != 'true' && steps.cache.outputs.cache-hit != true
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.phpunit-version }}-${{ hashFiles('composer.lock') }}"

- name: "Generate ${{ matrix.test-target }} code"
# language=sh
run: |
./bin/generate.sh --useExisting --versions '${{ matrix.fhir-version }}'
if [ '${{ matrix.test-target }}' == 'Core' ]; then
./bin/generate.sh --useExisting --onlyCore
else
./bin/generate.sh --useExisting --versions '${{ matrix.test-target }}'
fi

# - name: 'Install Java'
# uses: actions/setup-java@v4
Expand All @@ -132,4 +164,4 @@ jobs:
- name: 'Run tests'
# language=sh
run: |
./vendor/bin/phpunit -c 'phpunit/${{ matrix.fhir-version }}.xml'
./vendor/bin/phpunit -c 'phpunit/${{ matrix.test-target }}.xml'
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ You can view an example config array here: [bin/config.php](./bin/config.php).
// first, build new configuration class
$config = new \DCarbone\PHPFHIR\Config(require 'config.php');

// if you wish to limit the versions generated to a subset of those configured:
// $config->setVersionsToGenerate(['DSTU2', 'STU3']);

// next, iterate through all configured versions and render code:
foreach ($config->getVersions() as $versionConfig) {
foreach ($config->getVersionsIterator() as $versionConfig) {
$versionConfig->getDefinition()->getBuilder()->render();
}
```
Expand Down
82 changes: 50 additions & 32 deletions bin/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,51 +20,69 @@
*/
return [
// The path to look look for and optionally download source XSD files to
'schemaPath' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'input/',
'schemaPath' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'input' . DIRECTORY_SEPARATOR,

// The path to place generated type class files
'classesPath' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'output/',
// The path to place generated files
'outputPath' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'output' . DIRECTORY_SEPARATOR,

// If true, will use a noop null logger
'silent' => false,
// The root namespace for all generated classes
'rootNamespace' => '\\DCarbone\\PHPFHIRGenerated',

// If true, will skip generation of test classes
'skipTests' => false,
// If true, will use a noop null logger
'silent' => false,

// If you wish to specify alternative libxml opts, do so here.
'libxmlOpts' => LIBXML_NONET | LIBXML_BIGLINES | LIBXML_PARSEHUGE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NOXMLDECL,
// The libxml opts to use for parsing source XSD's.
'libxmlOpts' => LIBXML_NONET | LIBXML_BIGLINES | LIBXML_PARSEHUGE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NOXMLDECL,

// Map of versions and configurations to generate
// Each entry in this map will grab the latest revision of that particular version. If you wish to use a specific
// version, please see https://www.hl7.org/fhir/directory.html
'versions' => [
// Map of versions and configurations to generate.
// Each entry in this map will grab the latest revision of that particular version.
//
// For a list of base versions, see here: https://www.hl7.org/fhir/directory.html
'versions' => [
'DSTU1' => [
// Source URL
'url' => 'https://hl7.org/fhir/DSTU1/fhir-all-xsd.zip',
// Namespace to prefix the generated classes with
'namespace' => '\\HL7\\FHIR\\DSTU1',
// if defined, enables integration and validation test generation against the provided endpoint.
'testEndpoint' => '',
'sourceUrl' => 'https://hl7.org/fhir/DSTU1/fhir-all-xsd.zip',
// Namespace to generate classes into
'namespace' => 'Versions\\DSTU1',

// The default configuration for all instances of this version. May be overridden per version during
// instantiation.
'defaultConfig' => [
'unserializeConfig' => [
// Libxml options to use when unserializing types from XML
'libxmlOptMask' => 'LIBXML_NONET | LIBXML_BIGLINES | LIBXML_PARSEHUGE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NOXMLDECL',
// Maximum depth to allow when decoding JSON
'jsonDecodeMaxDepth' => 512,
],
'serializeConfig' => [
// If true, will override the default xmlns value with the value provided in the rootXmlns key
'overrideSourceXMLNS' => false,
// If overrideSourceXmlns is true, this value will be used as the root xmlns value
'rootXMLNS' => 'http://hl7.org/fhir',
// Libxml options to use when serializing XHTML content
'xhtmlLibxmlOptMask' => 'LIBXML_NONET | LIBXML_BIGLINES | LIBXML_PARSEHUGE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NOXMLDECL',
]
]
],
'DSTU2' => [
'url' => 'https://hl7.org/fhir/DSTU2/fhir-all-xsd.zip',
'namespace' => '\\HL7\\FHIR\\DSTU2',
'testEndpoint' => 'https://hapi.fhir.org/baseDstu2',
'sourceUrl' => 'https://hl7.org/fhir/DSTU2/fhir-all-xsd.zip',
'namespace' => 'Versions\\DSTU2',
],
'STU3' => [
'sourceUrl' => 'https://hl7.org/fhir/STU3/fhir-all-xsd.zip',
'namespace' => 'Versions\\STU3',
],
'STU3' => [
'url' => 'https://hl7.org/fhir/STU3/fhir-all-xsd.zip',
'namespace' => '\\HL7\\FHIR\\STU3',
'testEndpoint' => 'https://hapi.fhir.org/baseDstu3',
'R4' => [
'sourceUrl' => 'https://hl7.org/fhir/R4/fhir-all-xsd.zip',
'namespace' => 'Versions\\R4',
],
'R4' => [
'url' => 'https://hl7.org/fhir/R4/fhir-all-xsd.zip',
'namespace' => '\\HL7\\FHIR\\R4',
'testEndpoint' => 'https://hapi.fhir.org/baseR4',
'R4B' => [
'sourceUrl' => 'https://hl7.org/fhir/R4B/fhir-all-xsd.zip',
'namespace' => 'Versions\\R4B',
],
'R5' => [
'url' => 'https://hl7.org/fhir/R5/fhir-all-xsd.zip',
'namespace' => '\\HL7\\FHIR\\R5',
'testEndpoint' => 'https://hapi.fhir.org/baseR5',
'sourceUrl' => 'https://hl7.org/fhir/R5/fhir-all-xsd.zip',
'namespace' => 'Versions\\R5',
]

// 'Build' => [
Expand Down
Loading
Loading