Skip to content

Commit 2f4db9e

Browse files
authored
Merge pull request #21 from Ardenexal/copilot/implement-fhirpath-type-system
Implement FHIRPath Type System (Phase 7), Service Layer (Phase 8), Optimization (Phase 9), Documentation (Phase 10), Integration (Phase 11), and Final Review (Phase 12)
2 parents 90e2fa0 + 529c356 commit 2f4db9e

5,162 files changed

Lines changed: 45489 additions & 146410 deletions

File tree

Some content is hidden

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

.github/workflows/copilot-setup-steps.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ on:
88
workflow_dispatch:
99
push:
1010
branches:
11-
- 'copilot/**'
11+
- 'copilot/**'
12+
paths:
13+
- .github/workflows/copilot-setup-steps.yml
14+
pull_request:
15+
paths:
16+
- .github/workflows/copilot-setup-steps.yml
17+
1218
jobs:
1319
copilot-setup-steps:
1420
name: Setup PHP Environment for Copilot Agent
@@ -23,15 +29,15 @@ jobs:
2329
uses: actions/checkout@v4
2430
with:
2531
fetch-depth: 0
26-
32+
2733
- name: Setup PHP 8.3
2834
uses: shivammathur/setup-php@v2
2935
with:
3036
php-version: '8.3'
3137
extensions: ctype, iconv, zip, curl, intl
3238
ini-values: memory_limit=-1, max_execution_time=0
3339
coverage: none
34-
40+
3541
- name: Verify PHP installation
3642
run: |
3743
echo "=== PHP Version ==="
@@ -42,23 +48,23 @@ jobs:
4248
echo ""
4349
echo "=== PHP Configuration ==="
4450
php -i | grep -E "(memory_limit|max_execution_time)"
45-
51+
4652
- name: Validate Composer
4753
run: composer --version
48-
54+
4955
- name: Cache Composer packages
5056
uses: actions/cache@v4
5157
with:
5258
path: vendor
5359
key: ${{ runner.os }}-php-8.3-${{ hashFiles('**/composer.lock') }}
5460
restore-keys: |
5561
${{ runner.os }}-php-8.3-
56-
62+
5763
- name: Install Composer dependencies
5864
run: |
5965
composer install --prefer-dist --no-interaction --optimize-autoloader
6066
echo "✅ Composer dependencies installed successfully"
61-
67+
6268
- name: Verify required tools are installed
6369
run: |
6470
echo "=== Checking for required tools ==="
@@ -67,14 +73,14 @@ jobs:
6773
test -f vendor/bin/phpstan.phar && echo "✅ PHPStan found" || exit 1
6874
test -f vendor/bin/pint && echo "✅ Pint found" || exit 1
6975
echo "All required tools are available"
70-
76+
7177
- name: Create required directories
7278
run: |
7379
mkdir -p output var/cache var/log coverage
7480
chmod -R 755 bin/console
7581
chmod -R 777 var/ coverage/
7682
echo "✅ Required directories created"
77-
83+
7884
- name: Verify Symfony Console
7985
run: |
8086
echo "=== Symfony Console Version ==="
@@ -85,13 +91,13 @@ jobs:
8591
echo ""
8692
echo "=== Verifying FHIR Commands ==="
8793
php bin/console list | grep -q "fhir:generate" && echo "✅ FHIR generation command available" || exit 1
88-
94+
8995
- name: Run unit tests
9096
run: |
9197
echo "=== Running Unit Tests ==="
9298
composer run test-unit -- --no-coverage
9399
echo "✅ Unit tests passed"
94-
100+
95101
- name: Display project information
96102
if: always()
97103
run: |

.kiro/steering/product.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Product Overview
2+
3+
PHP FHIRTools is a comprehensive toolkit for working with FHIR (Fast Healthcare Interoperability Resources) in PHP applications. It provides modular components for generating PHP model classes from FHIR StructureDefinitions and serializing/deserializing FHIR resources to/from JSON and XML formats.
4+
5+
## Core Functionality
6+
7+
- **FHIR Code Generation**: Automatically generates PHP model classes from FHIR StructureDefinitions for R4, R4B, and R5 versions
8+
- **FHIR Serialization**: Comprehensive serialization system with JSON/XML support, validation modes, and extension handling
9+
- **FHIRPath Support**: Implementation of FHIRPath expression language for querying FHIR resources
10+
- **Symfony Integration**: Full Symfony Bundle integration with dependency injection and console commands
11+
12+
## Multi-Component Architecture
13+
14+
The project is organized as a monorepo with separate, independently usable components:
15+
16+
- **FHIRBundle**: Symfony Bundle for seamless framework integration
17+
- **CodeGeneration Component**: Standalone FHIR class generator
18+
- **Serialization Component**: Standalone FHIR JSON/XML serialization
19+
- **FHIRPath Component**: FHIRPath expression evaluation engine
20+
- **Models Component**: Generated FHIR model classes for different versions
21+
22+
## Target Users
23+
24+
- Healthcare software developers working with FHIR
25+
- PHP developers building healthcare interoperability solutions
26+
- Organizations implementing FHIR-based APIs and systems
27+
- Developers needing type-safe FHIR resource handling in PHP
28+
29+
## Key Benefits
30+
31+
- Type-safe PHP classes for all FHIR resources
32+
- Standards-compliant serialization following FHIR specifications
33+
- Modular design allowing standalone or integrated usage
34+
- Support for multiple FHIR versions (R4, R4B, R5)
35+
- Comprehensive validation and error handling

.kiro/steering/structure.md

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
# Project Structure
2+
3+
## Multi-Component Monorepo Architecture
4+
5+
PHP FHIRTools is organized as a monorepo containing multiple independent components that can be used standalone or together through the Symfony Bundle.
6+
7+
## Root Directory Structure
8+
9+
```
10+
php-fhir-tools/
11+
├── src/ # Source code
12+
│ ├── Bundle/FHIRBundle/ # Symfony Bundle integration
13+
│ ├── Component/ # Standalone components
14+
│ │ ├── CodeGeneration/ # FHIR class generation
15+
│ │ ├── Serialization/ # FHIR JSON/XML serialization
16+
│ │ ├── FHIRPath/ # FHIRPath expression engine
17+
│ │ └── Models/ # Generated FHIR model classes
18+
│ ├── Exception/ # Root-level exceptions
19+
│ └── (legacy files) # Backward compatibility
20+
├── tests/ # Test suites
21+
├── docs/ # Documentation
22+
├── config/ # Symfony configuration
23+
├── bin/ # Console entry points
24+
├── public/ # Web entry point
25+
├── var/ # Runtime files (cache, logs)
26+
├── vendor/ # Composer dependencies
27+
└── composer.json # Root package definition
28+
```
29+
30+
## Component Organization
31+
32+
### FHIRBundle (`src/Bundle/FHIRBundle/`)
33+
Symfony Bundle for framework integration:
34+
```
35+
FHIRBundle/
36+
├── FHIRBundle.php # Bundle class
37+
├── DependencyInjection/ # Service configuration
38+
│ ├── FHIRExtension.php # Bundle extension
39+
│ ├── Configuration.php # Configuration tree
40+
│ └── Compiler/ # Compiler passes
41+
├── Command/ # Console commands
42+
├── Resources/config/ # Service definitions
43+
├── Compatibility/ # Version compatibility
44+
├── composer.json # Bundle package definition
45+
└── README.md # Bundle documentation
46+
```
47+
48+
### CodeGeneration Component (`src/Component/CodeGeneration/`)
49+
Standalone FHIR class generator:
50+
```
51+
CodeGeneration/
52+
├── src/ # Component source
53+
│ ├── Generator/ # Code generators
54+
│ ├── Package/ # FHIR package handling
55+
│ ├── Context/ # Generation context
56+
│ ├── Configuration/ # Generator configuration
57+
│ ├── Service/ # Core services
58+
│ ├── Command/ # Console commands
59+
│ ├── Attributes/ # PHP attributes
60+
│ └── Exception/ # Component exceptions
61+
├── tests/ # Component tests
62+
├── output/ # Generated code output
63+
├── composer.json # Component package definition
64+
└── README.md # Component documentation
65+
```
66+
67+
### Serialization Component (`src/Component/Serialization/`)
68+
Standalone FHIR serialization:
69+
```
70+
Serialization/
71+
├── src/ # Component source
72+
│ ├── Normalizer/ # Symfony normalizers
73+
│ ├── Validator/ # FHIR validators
74+
│ ├── Context/ # Serialization context
75+
│ ├── Metadata/ # Type metadata
76+
│ ├── Exception/ # Component exceptions
77+
│ ├── FHIRSerializationService.php
78+
│ ├── FHIRTypeResolver.php
79+
│ └── FHIRTypeResolverInterface.php
80+
├── tests/ # Component tests
81+
├── composer.json # Component package definition
82+
└── README.md # Component documentation
83+
```
84+
85+
### FHIRPath Component (`src/Component/FHIRPath/`)
86+
FHIRPath expression evaluation:
87+
```
88+
FHIRPath/
89+
├── src/ # Component source
90+
│ ├── Parser/ # Expression parsing
91+
│ ├── Evaluator/ # Expression evaluation
92+
│ ├── Function/ # FHIRPath functions
93+
│ ├── Expression/ # Expression types
94+
│ ├── Type/ # FHIRPath type system
95+
│ ├── Service/ # Core services
96+
│ ├── Cache/ # Expression caching
97+
│ └── Exception/ # Component exceptions
98+
├── tests/ # Component tests
99+
├── composer.json # Component package definition
100+
└── README.md # Component documentation
101+
```
102+
103+
## Test Organization
104+
105+
```
106+
tests/
107+
├── Unit/ # Unit tests
108+
│ ├── Bundle/FHIRBundle/ # Bundle unit tests
109+
│ ├── Component/ # Component unit tests
110+
│ │ ├── CodeGeneration/ # CodeGeneration tests
111+
│ │ ├── Serialization/ # Serialization tests
112+
│ │ └── Models/ # Models tests
113+
│ └── Exception/ # Exception tests
114+
├── Integration/ # Integration tests
115+
│ ├── Package/ # Package integration
116+
│ ├── FHIRModelGeneratorIntegrationTest.php
117+
│ ├── FHIRSerializationIntegrationTest.php
118+
│ └── CommandIntegrationTest.php
119+
├── FHIR/ # FHIR-specific tests
120+
├── Fixtures/ # Test data
121+
│ ├── FHIR/ # FHIR test resources
122+
│ ├── OfficialFHIR/ # Official FHIR examples
123+
│ └── StructureDefinitions/ # Test structure definitions
124+
├── Utilities/ # Test utilities
125+
└── bootstrap.php # Test bootstrap
126+
```
127+
128+
## Configuration Structure
129+
130+
```
131+
config/
132+
├── bundles.php # Bundle registration
133+
├── services.yaml # Service configuration
134+
├── packages/ # Package configurations
135+
├── routes/ # Routing configuration
136+
├── recipes/fhir-bundle/ # Symfony Flex recipe
137+
└── services/ # FHIR-specific services
138+
├── fhir_bundle_commands.yaml
139+
├── fhir_code_generation.yaml
140+
├── fhir_path.yaml
141+
└── fhir_serialization.yaml
142+
```
143+
144+
## Documentation Structure
145+
146+
```
147+
docs/
148+
├── architecture.md # Multi-project architecture
149+
├── migration-guide.md # Migration instructions
150+
├── FHIR-Serialization-Guide.md # Serialization guide
151+
├── component-guides/ # Component-specific guides
152+
│ ├── fhir-bundle.md # Bundle guide
153+
│ ├── code-generation.md # CodeGeneration guide
154+
│ ├── serialization.md # Serialization guide
155+
│ └── fhir-path.md # FHIRPath guide
156+
└── FHIRPATH_*.md # FHIRPath documentation
157+
```
158+
159+
## Namespace Conventions
160+
161+
### Component Namespaces
162+
- **Root**: `Ardenexal\FHIRTools\`
163+
- **Bundle**: `Ardenexal\FHIRTools\Bundle\FHIRBundle\`
164+
- **CodeGeneration**: `Ardenexal\FHIRTools\Component\CodeGeneration\`
165+
- **Serialization**: `Ardenexal\FHIRTools\Component\Serialization\`
166+
- **FHIRPath**: `Ardenexal\FHIRTools\Component\FHIRPath\`
167+
- **Models**: `Ardenexal\FHIRTools\Component\Models\`
168+
169+
### Generated Code Namespaces
170+
Generated FHIR classes use configurable namespaces:
171+
- **Default Pattern**: `{BaseNamespace}\{Version}\{ResourceType}`
172+
- **Example**: `App\FHIR\R4\Patient`
173+
174+
## File Naming Conventions
175+
176+
### PHP Classes
177+
- **PascalCase**: `FHIRModelGenerator.php`
178+
- **Suffix Patterns**:
179+
- Commands: `*Command.php`
180+
- Services: `*Service.php`
181+
- Exceptions: `*Exception.php`
182+
- Interfaces: `*Interface.php`
183+
184+
### Test Files
185+
- **Pattern**: `{ClassUnderTest}Test.php`
186+
- **Integration**: `*IntegrationTest.php`
187+
- **Property Tests**: `*PropertyTest.php`
188+
189+
### Configuration Files
190+
- **YAML**: `.yaml` extension preferred
191+
- **Environment**: `.env` files for configuration
192+
- **Composer**: `composer.json` for package definitions
193+
194+
## Output Organization
195+
196+
Generated FHIR models are organized by version and type:
197+
```
198+
output/
199+
└── Ardenexal/FhirTools/
200+
├── R4/ # FHIR R4 models
201+
├── R4B/ # FHIR R4B models
202+
└── R5/ # FHIR R5 models
203+
```
204+
205+
## Dependency Boundaries
206+
207+
### Component Independence
208+
- Each component can be used standalone
209+
- Clear interface definitions between components
210+
- Minimal cross-component dependencies
211+
212+
### Bundle Integration
213+
- FHIRBundle depends on all components
214+
- Components do not depend on the bundle
215+
- Symfony-specific code isolated in bundle

0 commit comments

Comments
 (0)