Skip to contents

Inspects unit_source_value (else the concept_name of unit_concept_id) for every feature with a rule and classifies the distinct units as scaled / canonical / no_unit / unrecognized. With create_view, a temporary view view_name is created with value_as_number (and range_low / range_high) multiplied to the canonical unit plus harmonization_factor and unit_harmonized. The source table is never modified, and unrecognized units are left unscaled (factor 1) and flagged, never guessed. Feed the view to extract_measurements() through measurement_table. Mirror of omop_etl.measurement_filter.harmonize_measurement_units.

Usage

harmonize_measurement_units(
  con,
  features = NULL,
  unit_rules = NULL,
  measurement_table = "measurement",
  view_name = "measurement_harmonized",
  create_view = TRUE
)

Arguments

con

DuckDB DBI connection.

features

Named list feature -> LOINC codes / concept ids; default DEFAULT_LAB_LOINCS + DEFAULT_VITAL_LOINCS.

unit_rules

Named list overriding / extending DEFAULT_UNIT_RULES.

measurement_table, view_name, create_view

Source table, view name and whether to create the view.

Value

Data frame feature, unit, canonical_unit, factor, status, n.