FHIR Types Utilities¶
Utility classes and functions for getting and validating FHIR types.
utils ¶
Type checking and conversion utilities for FHIR primitive types.
This module provides convenient functions to check if values conform to FHIR primitive types and to convert between different types. The core conversion logic is implemented here, and FHIRPath conversion functions use these utilities.
Functions:
| Name | Description |
|---|---|
is_fhir_primitive_type |
Check if a value conforms to a primitive FHIR type. |
is_fhir_complex_type |
Check if a value conforms to a complex FHIR type. |
is_fhir_resource_type |
Check if a value conforms to a FHIR resource. |
is_fhir_primitive |
Check if a value is a FHIR primitive type. |
to_boolean |
Convert value to FHIR Boolean. |
to_integer |
Convert value to FHIR Integer. |
to_decimal |
Convert value to FHIR Decimal. |
to_date |
Convert value to FHIR Date. |
to_datetime |
Convert value to FHIR DateTime. |
to_time |
Convert value to FHIR Time. |
to_string |
Convert value to string representation. |
is_fhir_primitive_type ¶
is_fhir_primitive_type(value: Any, fhir_type: type[FHIRBaseModel] | type | TypeAliasType | str, release: str | None = None) -> bool
Check if a value conforms to a primitive FHIR type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to check |
required |
fhir_type
|
type[FHIRBaseModel] | type | TypeAliasType | str
|
The primitive FHIR type (or name thereof) to check against |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Raises:
| Type | Description |
|---|---|
FhirTypeError
|
If the fhir_type is a string and does not correspond to a known primitive type |
is_fhir_complex_type ¶
is_fhir_complex_type(value: Any, fhir_type: type[FHIRBaseModel] | type | TypeAliasType | str, release: str | None = None) -> bool
Check if a value conforms to a complex FHIR type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to check |
required |
fhir_type
|
type[FHIRBaseModel] | type | TypeAliasType | str
|
The complex FHIR type (or name thereof) to check against |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Raises:
| Type | Description |
|---|---|
FhirTypeError
|
If the fhir_type is a string and does not correspond to a known complex type |
is_fhir_resource_type ¶
is_fhir_resource_type(value: Any, fhir_type: type[FHIRBaseModel] | type | TypeAliasType | str, release: str | None = None) -> bool
Check if a value conforms to a FHIR resource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to check |
required |
fhir_type
|
type[FHIRBaseModel] | type | TypeAliasType | str
|
The complex FHIR type (or name thereof) to check against |
required |
release
|
str | None
|
The FHIR release to use when resolving fhir_type if it is given as a string (e.g., "4.0.1", "4.3.0", "5.0.0"). Required if fhir_type is a string. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Raises:
| Type | Description |
|---|---|
FhirTypeError
|
If the fhir_type is a string and does not correspond to a known resource type |
is_fhir_primitive ¶
Check if a value is a FHIR primitive type.