Learn R Programming

lab2clean (version 2.0.0)

harmonize_lab_unit: Harmonizing Laboratory Units of Measurement through Unit Conversion

Description

This function is designed to harmonize the units found in a laboratory data set to either SI or Conventional units, converting the numeric result values in the process and (optionally) updating LOINC codes when mass–molar conversion are required.

Usage

harmonize_lab_unit(
  lab_data,
  loinc_code,
  result_value,
  result_unit,
  preferred_unit_system = "SI",
  report = TRUE
)

Value

A modified `lab_data` data frame with additional columns (original row order preserved): * `harmonized_unit`: Harmonized units according to the preferred unit system. * `OMOP_concept_id`: The concept id of the harmonized unit according to the OMOP Common Data Model. * `new_value`: The result value after the conversion. * `new_loinc_code`: If the unit conversion led to a new loinc code (e.g. in mass-molar conversion). * `property_group_id`: the code of the LOINC group (parent group ID / Group ID). * `cleaning_comments`: Comments about the harmonization and conversion process for each lab result.

Arguments

lab_data

A data frame containing laboratory data.

loinc_code

The column in `lab_data` indicating the LOINC code of the laboratory test.

result_value

The column in `lab_data` with quantitative result values for conversion.

result_unit

The column in `lab_data` with result units in a UCUM-valid format.

preferred_unit_system

A string representing the preference of the user for the unit system used for standardization. Defaults to "SI", the other option is "Conventional".

report

A report is written in the console. Defaults to "TRUE".

Author

Ahmed Zayed <ahmed.zayed@kuleuven.be>, Ilias Sarikakis <sarikakisilias@gmail.com>

Details

The function undergoes the following methodology: 1. Extracting unit parameters (dimension & magnitude) 2. Setting reference unit (LOINC-UCUM mapping) 3. Check compatibility between reported unit and reference unit 4. Executing regular conversion 5. Executing mass<>molar conversion 6. Checking LOINC codes

Internal Datasets: The function uses an internal dataset; `parsed_units_df` which contains 1450 parsed ucum units

See Also

Function 1 for result value cleaning, Function 2 for result validation, Function 3 for unit format standardized to UCUM,