Structure Definitions Registry
Main class and utilities for managing FHIR structure definitions.
Manifest
Path: fhircraft.fhir.resources.definitions.registry.Manifest
dataclass
Manifest(definitions: Dict[str, ManifestEntry] = dict(), by_url: Dict[str, str] = dict(), by_name: Dict[str, List[str]] = dict())
Manifest index for StructureDefinitions in a FHIR version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
definitions
|
Dict[str, ManifestEntry]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
by_url
|
Dict[str, str]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
by_name
|
Dict[str, List[str]]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
Methods:
| Name | Description |
|---|---|
to_dict |
Convert manifest to dictionary for JSON serialization. |
from_dict |
Create manifest from dictionary. |
save |
Save manifest to JSON file. |
load |
Load manifest from JSON file. |
to_dict
Convert manifest to dictionary for JSON serialization.
Source code in fhircraft/fhir/resources/definitions/registry.py
from_dict
classmethod
Create manifest from dictionary.
Source code in fhircraft/fhir/resources/definitions/registry.py
load
classmethod
Load manifest from JSON file.
Source code in fhircraft/fhir/resources/definitions/registry.py
ManifestEntry
Path: fhircraft.fhir.resources.definitions.registry.ManifestEntry
dataclass
ManifestEntry(url: str, name: str, fhir_version: str, kind: str, filename: str, has_snapshot: bool = False, has_differential: bool = False)
Metadata entry for a single StructureDefinition in the manifest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Canonical URL (primary key) |
required |
name
|
str
|
StructureDefinition name |
required |
fhir_version
|
str
|
FHIR version (e.g., "4.0.1", "4.3.0", "5.0.0") |
required |
kind
|
str
|
Kind (resource, complex-type, primitive-type, etc.) |
required |
filename
|
str
|
Filename where this definition is stored (e.g., "Patient.json") |
required |
has_snapshot
|
bool
|
Whether snapshot is present |
False
|
has_differential
|
bool
|
Whether differential is present |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
url |
str
|
Canonical URL (primary key) |
name |
str
|
StructureDefinition name |
fhir_version |
str
|
FHIR version (e.g., "4.0.1", "4.3.0", "5.0.0") |
kind |
str
|
Kind (resource, complex-type, primitive-type, etc.) |
filename |
str
|
Filename where this definition is stored (e.g., "Patient.json") |
has_snapshot |
bool
|
Whether snapshot is present |
has_differential |
bool
|
Whether differential is present |
filename
instance-attribute
filename: str
Filename where this definition is stored (e.g., "Patient.json")
has_snapshot
class-attribute
instance-attribute
has_snapshot: bool = False
Whether snapshot is present
has_differential
class-attribute
instance-attribute
has_differential: bool = False
Whether differential is present
StructureDefinitionNotFoundError
Path: fhircraft.fhir.resources.definitions.registry.StructureDefinitionNotFoundError
Bases: FileNotFoundError
Raised when a required structure definition cannot be resolved.
StructureDefinitionRegistry
Path: fhircraft.fhir.resources.definitions.registry.StructureDefinitionRegistry
StructureDefinitionRegistry(fhir_release: str)
Registry for managing indexed StructureDefinitions.
Methods:
| Name | Description |
|---|---|
enable_internet_access |
Enable internet access for downloading structure definitions. |
disable_internet_access |
Disable internet access for downloading structure definitions. |
download_url |
Download JSON content from a URL. |
download_package |
Download a package from the registry and add its structure definitions to the registry. |
set_registry_base_url |
Change the package registry base URL. |
parse_canonical_url |
Parse a canonical URL to extract base URL and version. |
Attributes:
| Name | Type | Description |
|---|---|---|
local_manifest |
Manifest
|
Manifest of local definitions |
fhir_release |
str
|
FHIR release version (e.g., "4.0.1", "4.3.0", "5.0.0"). |
structure_definitions_by_url |
Dict[str, StructureDefinition | StructureDefinition | StructureDefinition]
|
Mapping of base URL to version to StructureDefinition instance. |
Source code in fhircraft/fhir/resources/definitions/registry.py
fhir_release
instance-attribute
fhir_release: str = fhir_release
FHIR release version (e.g., "4.0.1", "4.3.0", "5.0.0").
structure_definitions_by_url
instance-attribute
structure_definitions_by_url: Dict[str, StructureDefinition | StructureDefinition | StructureDefinition] = {}
Mapping of base URL to version to StructureDefinition instance.
enable_internet_access
disable_internet_access
download_url
staticmethod
Download JSON content from a URL.
Source code in fhircraft/fhir/resources/definitions/registry.py
download_package
download_package(package_name: str, version: str, skip_invalid: bool = False, include_dependencies: bool = True) -> None
Download a package from the registry and add its structure definitions to the registry.
Source code in fhircraft/fhir/resources/definitions/registry.py
set_registry_base_url
set_registry_base_url(base_url: str) -> None
parse_canonical_url
staticmethod
Parse a canonical URL to extract base URL and version.