Skip to contents

Flags lab/vital features whose median is more than max_ratio times above or below the reference median, which is how an unharmonized unit (mmol/L or umol/L where mg/dL is expected) shows up before physiologic bounds silently clip it. Mirror of Python omop_etl.unit_guard.check_unit_sanity.

Usage

check_unit_sanity(
  features,
  reference_medians = NULL,
  max_ratio = 3,
  min_n = 20L,
  warn = TRUE
)

Arguments

features

data.frame of features.

reference_medians

Named numeric overriding/adding to REFERENCE_MEDIANS.

max_ratio

Flag when site/reference is above this or below its inverse.

min_n

Skip features with fewer non-missing values.

warn

Emit a warning naming flagged features.

Value

data.frame: feature, n, site_median, reference_median, ratio, flag, hint, suspect_factor (the multiplier that brings a flagged column to the contract unit, NA when no named conversion matches).