onconova.interoperability.fhir._generate_models
FHIR Resource Model Generator
This script generates Python model classes from FHIR StructureDefinition JSON files using the fhircraft library. It processes Onconova-specific FHIR profiles and creates corresponding Python model files.
Usage
python _generate_models.py
Example
python _generate_models.py ./fhir_definitions --fail-fast --verbose
EXCLUDED_PATTERNS
module-attribute
¶
FHIR_PACKAGES
module-attribute
¶
STRUCTURE_DEFINITION_PREFIX
module-attribute
¶
factory
module-attribute
¶
logger
module-attribute
¶
configure_fhir_factory(input_dir, files)
¶
Configure the FHIR factory with repository files and load required packages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Path
|
Path to the input directory containing StructureDefinition files |
required |
|
List[Path]
|
List of StructureDefinition files to include in the factory |
required |
Source code in onconova/interoperability/fhir/_generate_models.py
get_structure_definition_files(input_dir)
¶
Find all valid StructureDefinition JSON files in the input directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Path
|
Path to the input directory |
required |
Returns:
| Type | Description |
|---|---|
List[Path]
|
List of Paths to valid StructureDefinition files |
Source code in onconova/interoperability/fhir/_generate_models.py
main()
¶
Main execution function.
Source code in onconova/interoperability/fhir/_generate_models.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
process_structure_definition(input_path, output_dir, fail_fast)
¶
Process a single StructureDefinition file and generate Python model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Path
|
Path to the input StructureDefinition JSON file |
required |
|
Path
|
Path to the output directory |
required |
|
bool
|
Whether to exit on error |
required |
Returns:
| Type | Description |
|---|---|
Tuple[bool, str]
|
Tuple of (success: bool, output_filename: str) |
Source code in onconova/interoperability/fhir/_generate_models.py
setup_argument_parser()
¶
Configure and return the argument parser.
Source code in onconova/interoperability/fhir/_generate_models.py
validate_input_directory(input_dir)
¶
Validate that the input directory exists and is accessible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Path
|
Path to the input directory |
required |
Raises:
| Type | Description |
|---|---|
SystemExit
|
If the directory doesn't exist or is not accessible |