onconova.interoperability.fhir.utils
COMMON_CLINICAL_UNITS
module-attribute
¶
construct_fhir_codeable_concept(concept)
¶
Construct a FHIR CodeableConcept from a CodedConcept or Coding object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
CodedConcept | Coding
|
The concept to convert. Can be either a CodedConcept or a Coding object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
CodeableConcept |
CodeableConcept
|
A FHIR CodeableConcept containing the provided concept as a coding element. |
Examples:
>>> coded_concept = CodedConcept(...)
>>> codeable = construct_fhir_codeable_concept(coded_concept)
>>>
>>> coding = Coding(...)
>>> codeable = construct_fhir_codeable_concept(coding)
Source code in onconova/interoperability/fhir/utils.py
get_common_ucum_equivalent(internal_unit)
¶
get_unit_type_category(unit)
¶
Categorize a unit by type for better organization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Unit string (internal or UCUM format) |
required |
Returns:
| Type | Description |
|---|---|
str
|
Unit category string |
Source code in onconova/interoperability/fhir/utils.py
internal_to_ucum(unit)
¶
Convert internal unit representation to UCUM format.
Maps internal unit strings used in measures.py to their UCUM equivalents. Handles both simple units and bidimensional units (e.g., mg__dl -> mg/dL).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Internal unit string representation |
required |
Returns:
| Type | Description |
|---|---|
str
|
UCUM-formatted unit string |
Examples:
>>> internal_to_ucum("mg__dl")
'mg/dL'
>>> internal_to_ucum("IU")
'[iU]'
>>> internal_to_ucum("square_meter")
'm2'
Source code in onconova/interoperability/fhir/utils.py
normalize_unit_string(unit)
¶
Normalize a unit string by handling common variations and case issues.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Unit string to normalize |
required |
Returns:
| Type | Description |
|---|---|
str
|
Normalized unit string |
Source code in onconova/interoperability/fhir/utils.py
ucum_to_internal(unit)
¶
Convert UCUM unit format to internal representation.
Maps UCUM unit strings to internal format used in measures.py. Handles both simple units and compound units with division.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
UCUM-formatted unit string |
required |
Returns:
| Type | Description |
|---|---|
str
|
Internal unit string representation |
Examples:
>>> ucum_to_internal("mg/dL")
'mg__dl'
>>> ucum_to_internal("[iU]")
'IU'
>>> ucum_to_internal("m2")
'square_meter'
Source code in onconova/interoperability/fhir/utils.py
validate_bidirectional_conversion(internal_unit)
¶
Validate that a unit conversion works bidirectionally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Internal format unit to test |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if conversion is bidirectional, False otherwise |