Skip to contents

Multiplies every feature flagged by check_unit_sanity() whose median matches a named conversion (umol/L creatinine, mmol/L urea, mmol/L glucose, ...) by its suspect_factor. Features flagged for an unexplained reason are left untouched and listed with rescaled = FALSE for review. features is not modified. Mirror of Python omop_etl.unit_guard.harmonize_contract_units.

Usage

harmonize_contract_units(features, sanity = NULL, reference_medians = NULL,
  recompute_derived = TRUE)

Arguments

features

data.frame of features.

sanity

Output of check_unit_sanity(); computed here (without a warning) when NULL.

reference_medians

Passed to check_unit_sanity() when sanity is NULL.

recompute_derived

If TRUE (default), a rescaled creatinine also refreshes lab_egfr (CKD-EPI 2021; needs age and gender_concept_id) and a rescaled sodium / chloride / bicarbonate refreshes lab_anion_gap, so they do not keep the values computed from the unharmonized inputs. Refreshed columns are listed in applied with rescaled = FALSE.

Value

A list: features (the rescaled data.frame) and applied (data.frame: feature, factor, rescaled, hint).