FHIR Types Registries¶
Registry classes and functions for managing FHIR types.
registry ¶
Index-based FHIR type registry.
Provides a per-release :class:TypeRegistry that maps type names and canonical
URLs to Python classes, backed by the existing .manifest.json definition index.
Classes:
| Name | Description |
|---|---|
TypeRegistry |
Per-release index mapping FHIR type names and canonical URLs to Python types. |
Functions:
| Name | Description |
|---|---|
get_registry |
Return the :class: |
get_fhir_type |
Get the FHIR type (primitive, complex, or resource) by its string name. |
get_fhir_type_by_url |
Return the FHIR type (primitive, complex, or resource) for a canonical URL. |
TypeRegistry
Path: fhircraft.fhir.resources.datatypes.registry.TypeRegistry
TypeRegistry(release: str)
Per-release index mapping FHIR type names and canonical URLs to Python types.
All classes are imported lazily on first access.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
release
|
str
|
FHIR release string, e.g. |
required |
Methods:
| Name | Description |
|---|---|
get_by_name |
Return the Python type for a FHIR type name, or |
get_by_url |
Return the Python type for a canonical FHIR URL, or |
get_entry |
Return the :class: |
all_urls |
Return all canonical URLs known to this registry. |
all_names |
Return all type names known to this registry. |
get_by_name ¶
get_by_name(name: str) -> type[FHIRBaseModel] | None
Return the Python type for a FHIR type name, or None.
Accepts both the Python PascalCase name used in the datatypes modules
("Boolean", "Observation") and the manifest camelCase name used
for primitive types ("boolean", "dateTime").
get_by_url ¶
get_by_url(url: str) -> type[FHIRBaseModel] | None
Return the Python type for a canonical FHIR URL, or None.
The factory singleton's construction_cache is checked first so that
profiled resources built via :class:~fhircraft.fhir.resources.factory.FHIRModelFactory
are also reachable by their canonical URL alongside built-in types.
get_entry ¶
get_entry(url: str) -> ManifestEntry | None
Return the :class:ManifestEntry for a canonical URL without loading the class.
Useful for inspecting metadata (kind, fhir_version, has_snapshot,
etc.) cheaply, without triggering a module import.
get_registry ¶
get_registry(release: str = 'R4B') -> TypeRegistry
Return the :class:TypeRegistry singleton for the given FHIR release.
Registries are constructed lazily on first access and then reused.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
release
|
str
|
FHIR release string — one of |
'R4B'
|
Returns:
| Type | Description |
|---|---|
TypeRegistry
|
The singleton :class: |
get_fhir_type ¶
get_fhir_type(type_str: str, release: str, fail_if_not_found: Literal[True] = True) -> type[FHIRBaseModel]
get_fhir_type(type_str: str, release: str, fail_if_not_found: Literal[False] = False) -> type[FHIRBaseModel] | None
get_fhir_type(type_str: str, release: str, fail_if_not_found: bool = True) -> type[FHIRBaseModel] | None
Get the FHIR type (primitive, complex, or resource) by its string name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_str
|
str
|
The FHIR type name. |
required |
release
|
str
|
The FHIR release version, e.g. |
required |
fail_if_not_found
|
bool
|
Whether to raise an error if the type is not found (default: True). |
True
|
Returns:
| Type | Description |
|---|---|
type[FHIRBaseModel] | None
|
The corresponding FHIR type class, or None if not found and fail_if_not_found is False. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If the type is not found and |
get_fhir_type_by_url ¶
get_fhir_type_by_url(url: str, release: str, fail_if_not_found: Literal[True] = True) -> type[FHIRBaseModel]
get_fhir_type_by_url(url: str, release: str, fail_if_not_found: Literal[False] = False) -> type[FHIRBaseModel] | None
get_fhir_type_by_url(url: str, release: str, fail_if_not_found: bool = True) -> type[FHIRBaseModel] | None
Return the FHIR type (primitive, complex, or resource) for a canonical URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The canonical FHIR URL, e.g. |
required |
release
|
str
|
The FHIR release version, e.g. |
required |
fail_if_not_found
|
bool
|
Whether to raise an error if the type is not found (default: True). |
True
|
Returns:
| Type | Description |
|---|---|
type[FHIRBaseModel] | None
|
The corresponding Python type class. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If no type is found for the given URL and |