A **GitHub### Advanced Configuration
- name: Expand FHIR CapabilityStatement
id: expand
uses: Gefyra/capabilityStatement-expander@v0 # or @v0.0.2 for specific version
with:
input_directory: './implementation-guide/input'
output_directory: './build/expanded'
capability_statement_url: 'https://example.org/fhir/CapabilityStatement/MyCapability'
verbose: 'true' # Enable detailed logging for debugging
python_version: '3.10'
- name: Show Results
run: |
echo "Expanded files: ${{ steps.expand.outputs.expanded_files_count }}"
echo "CapabilityStatement: ${{ steps.expand.outputs.expanded_capability_statement }}"Enable detailed logging to troubleshoot expansion issues:
- name: Debug Expansion Process
uses: Gefyra/capabilityStatement-expander@v0
with:
input_directory: './resources'
output_directory: './output'
capability_statement_url: 'https://example.org/fhir/CapabilityStatement/MyCS'
verbose: 'true' # Shows detailed processing stepsWith verbose: 'true' you get:
- π Detailed file processing information
- π Step-by-step import resolution
- π Resource collection statistics
- π§© Profile and example discovery details
β οΈ Warning messages for missing resources
Bonus Feature: Verbose logging is automatically enabled when you activate GitHub Actions debug logging!
# No need to set verbose: 'true' when using GitHub debug mode
- name: Expand CapabilityStatement (with auto-verbose)
uses: Gefyra/capabilityStatement-expander@v0
with:
input_directory: './resources'
output_directory: './output'
capability_statement_url: 'https://example.org/fhir/CapabilityStatement/MyCS'
# verbose automatically enabled when ACTIONS_STEP_DEBUG=trueTo activate both debug modes:
- π§ Repository Settings β Actions β General β "Enable debug logging"
- π Run workflow β Both GitHub Actions debug + FHIR verbose logging active automatically!ursively expands FHIR CapabilityStatements by resolving all
importsand collecting all referenced resources. Perfect for FHIR Implementation Guide development and distribution.
- π Recursive Import Resolution: Automatically resolves all
importsandinstantiatesreferences - π·οΈ Canonical URL Support: Uses FHIR-compliant canonical URLs for resource identification
- π§© Complete Resource Extraction: Automatically collects:
- β StructureDefinitions (profiles)
- β ValueSets and CodeSystems (including from StructureDefinition bindings)
- β SearchParameters and OperationDefinitions
- β Examples and other referenced resources
- π Smart Example Detection: Finds examples via
meta.profilereferences to collected profiles - π§Ή Import Cleanup: Removes
imports/_importsfrom the final expanded CapabilityStatement - β‘ GitHub Action Ready: Directly usable as a reusable action
- π Iterative Analysis: Multi-layered analysis for nested dependencies
- π Detailed Logging: Complete traceability of the expansion process
name: Expand FHIR CapabilityStatement
on:
workflow_dispatch:
inputs:
capability_statement_url:
description: 'Canonical URL of the CapabilityStatement'
required: true
jobs:
expand:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Expand CapabilityStatement
uses: Gefyra/capabilityStatement-expander@v0 # or @v0.0.2 for specific version
with:
input_directory: './fhir-resources'
output_directory: './expanded-resources'
capability_statement_url: ${{ github.event.inputs.capability_statement_url }}
- name: Upload Results
uses: actions/upload-artifact@v4
with:
name: expanded-fhir-resources
path: './expanded-resources'name: Expand Multiple FHIR CapabilityStatements
on:
push:
branches: [ main ]
jobs:
expand:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Expand Multiple CapabilityStatements
uses: Gefyra/capabilityStatement-expander@v0
with:
input_directory: './fhir-resources'
output_directory: './expanded-resources'
# Use toJSON() to convert YAML list to JSON array
capability_statement_url: ${{ toJSON(fromJSON('[
"https://example.org/fhir/CapabilityStatement/ServerCapability",
"https://example.org/fhir/CapabilityStatement/ClientCapability"
]')) }}
- name: Upload Results
uses: actions/upload-artifact@v4
with:
name: expanded-fhir-resources
path: './expanded-resources'name: Expand CapabilityStatements with Matrix
on:
push:
branches: [ main ]
jobs:
expand:
runs-on: ubuntu-latest
strategy:
matrix:
capability_statement_urls:
- https://gematik.de/fhir/isik/CapabilityStatement/ISiKCapabilityStatementBasis
- https://gematik.de/fhir/isik/CapabilityStatement/ISiKCapabilityStatementSubscription
steps:
- uses: actions/checkout@v4
- name: Expand CapabilityStatement
uses: Gefyra/capabilityStatement-expander@v0
with:
input_directory: './Resources/fsh-generated/resources'
output_directory: './publisher-input/resources'
# Convert YAML list to JSON array
capability_statement_url: ${{ toJSON(matrix.capability_statement_urls) }}- name: Expand FHIR CapabilityStatement
id: expand
uses: Gefyra/capabilityStatement-expander@v0 # or @v0.0.2 for specific version
with:
input_directory: './implementation-guide/input'
output_directory: './build/expanded'
capability_statement_url: 'https://example.org/fhir/CapabilityStatement/MyCapability'
verbose: 'true'
python_version: '3.11'
- name: Show Results
run: |
echo "Expanded files: ${{ steps.expand.outputs.expanded_files_count }}"
echo "CapabilityStatement: ${{ steps.expand.outputs.expanded_capability_statement }}"This action supports semantic versioning with automatic major version tags:
# Latest within major version (recommended for most use cases)
uses: Gefyra/capabilityStatement-expander@v0
# Specific version (recommended for production)
uses: Gefyra/capabilityStatement-expander@v0.0.2
# Latest release (not recommended)
uses: Gefyra/capabilityStatement-expander@mainπ Version Strategy:
@v0- Always points to the latestv0.x.xrelease (automatic updates)@v0.0.2- Fixed to specific version (no automatic updates)@main- Development branch (may be unstable)
| Input | Description | Required | Default |
|-------|-------------|----------|---------||
| input_directory | Directory with FHIR JSON files | β
| ./input |
| output_directory | Target directory for expanded resources | β
| ./output |
| capability_statement_url | Canonical URL(s) of the CapabilityStatement(s) to expand.
Can be:
β’ Single URL: "https://example.org/CS"
β’ JSON array: ["url1", "url2"]
β’ YAML list (use toJSON()): ${{ toJSON(matrix.urls) }} | β
| - |
| verbose | Enable verbose logging | β | false |
| no_clean | Do not clean output directory before expansion (by default, directory is cleaned) | β | false |
| expectation_filter | Filter imports by minimum expectation level.SHALL = only SHALLSHOULD = SHALL + SHOULDMAY = SHALL + SHOULD + MAY
Default: import all expectations
Note: SHOULD-NOT is never imported | β | - |
| python_version | Python version for execution | β | 3.11 |
| Output | Description |
|---|---|
expanded_files_count |
Number of created files |
output_directory |
Path to output directory |
expanded_capability_statement |
Filename of the expanded CapabilityStatement |
You can also run the script locally:
python capability_statement_expander.py <input_dir> <output_dir> <capability_statement_url>Parameters:
input_dir: Directory with JSON files (CapabilityStatements, profiles, etc.)output_dir: Target directory for expanded resourcescapability_statement_url: Canonical URL(s) of the CapabilityStatement(s) to expand- Single URL:
"https://example.org/CS" - JSON array:
'["url1", "url2"]'(note the quotes!)
- Single URL:
Options:
--verboseor-v: Enables detailed logging--no-clean: Do not clean output directory before expansion (by default, the output directory is cleaned to avoid stale files)--expectation-filter {SHALL|SHOULD|MAY}: Filter imports by minimum expectation level.SHALLimports only SHALL,SHOULDimports SHALL+SHOULD,MAYimports SHALL+SHOULD+MAY. Default: import all expectations. Note:SHOULD-NOTis never imported regardless of filter.
Single CapabilityStatement:
python capability_statement_expander.py ./fhir-resources ./output "http://example.org/CapabilityStatement/MyCapabilityStatement" --verboseMultiple CapabilityStatements:
python capability_statement_expander.py ./fhir-resources ./output '["http://example.org/CapabilityStatement/CS1", "http://example.org/CapabilityStatement/CS2"]' --verboseThe project includes automated tests:
# Run tests
python test_expander.py
# For ISiK tests (if ISiK resources are available)
python capability_statement_expander.py ./isik_resources ./output_isik "https://gematik.de/fhir/isik/CapabilityStatement/ISiKCapabilityStatementSubscriptionServerAkteur"input/
βββ CapabilityStatement-MyCS.json
βββ CapabilityStatement-ImportedCS.json
βββ profiles/
β βββ Patient-Profile.json
β βββ Observation-Profile.json
βββ examples/
β βββ Patient-Example.json
β βββ Observation-Example.json
βββ terminology/
βββ ValueSet-Codes.json
βββ CodeSystem-MySystem.json
output/
βββ CapabilityStatement-example-base-capability-expanded.json # β¨ Expanded CapabilityStatement
βββ StructureDefinition-PatientProfile.json # ποΈ Patient profile
βββ StructureDefinition-ObservationProfile.json # ποΈ Observation profile
βββ ValueSet-PatientStatus.json # π Patient status values
βββ SearchParameter-Patient-identifier.json # π Patient identifier search
βββ CapabilityStatement-example-base-capability.json # π Original CapabilityStatement
βββ CapabilityStatement-imported-capability.json # π₯ Imported CapabilityStatement
βββ Patient-example-1.json # π€ Example detected via meta.profile
βββ Observation-example-1.json # π Example detected via meta.profile
π Note: The expanded CapabilityStatement has:
- File name: Original ID +
-expandedsuffix (e.g.,CapabilityStatement-MyCS-expanded.json) - Resource ID: Original ID +
-expandedsuffix (e.g.,"id": "MyCS-expanded") - Canonical URL: Original URL +
-expandedsuffix (e.g.,"url": "https://example.org/CS-expanded") - Name & Title: Original +
Expandedsuffix (e.g.,"name": "MyCSExpanded") - No imports: All
importsand_importsfields are removed after expansion
The expander performs the following steps:
- Initial Analysis: Loads the base CapabilityStatement and analyzes its structure
- Import Resolution: Recursively resolves all
importsandinstantiatesreferences- Supports multi-level imports (CS1 β CS2 β CS3, CS4)
- Respects expectation filters (SHALL/SHOULD/MAY)
- Profile Collection: Extracts all StructureDefinition references from
supportedProfilefields - Binding Analysis: Analyzes StructureDefinitions for ValueSet and CodeSystem bindings
- Dependency Resolution: Follows references in SearchParameters and OperationDefinitions
- Example Detection: Searches for Examples via
meta.profilereferences to collected profiles - Iterative Processing: Repeats analysis until no new resources are found
- Final Assembly: Creates expanded CapabilityStatement with modified metadata:
- Canonical URL:
{original-url}-expanded(e.g.,https://example.org/CS-expanded) - Resource ID:
{original-id}-expanded - Name/Title:
{original}Expanded/{original} (Expanded) - Removes all
importsand_importsfields
- Canonical URL:
- Resource Copy: Copies all referenced resources (profiles, ValueSets, examples, etc.)
The expander includes intelligent example detection that:
- Scans all resources in the directory structure
- Identifies resources with
meta.profilereferences - Matches these references against collected
supportedProfileURLs - Automatically includes matching examples in the expanded output
For example, if your CapabilityStatement references:
"supportedProfile": [
"http://example.org/StructureDefinition/PatientProfile"
]And you have an example like:
{
"resourceType": "Patient",
"meta": {
"profile": ["http://example.org/StructureDefinition/PatientProfile"]
},
// ... rest of example
}The example will be automatically detected and included in the expanded package.
The script supports the following import mechanisms from the FHIR standard:
{
"resourceType": "CapabilityStatement",
"imports": [
"http://example.org/CapabilityStatement/BaseCapability",
"CapabilityStatement/AnotherCapability"
]
}{
"resourceType": "CapabilityStatement",
"instantiates": [
"http://hl7.org/fhir/CapabilityStatement/base"
]
}- π₯ Implementation Guide Development: Automatically collect all dependencies
- π¦ FHIR Package Creation: Complete resource collections for distribution
- β Validation: Verify completeness of CapabilityStatements
- π CI/CD: Automated processing in GitHub Actions workflows
# Clone repository
git clone https://github.com/patrickwerner/CapabilityStatementExpander.git
cd CapabilityStatementExpander
# Run tests
python test_expander.py
# Test local development
python capability_statement_expander.py ./examples ./output_test "http://example.org/CapabilityStatement/example-base-capability" --verboseMIT License - see LICENSE for details.
Contributions are welcome! Please create an issue or submit a pull request.
Created for the FHIR Community π₯β¨