Skip to contents

A function to generate oak_id_vars

Usage

generate_oak_id_vars(raw_dat, pat_var, raw_src)

Arguments

raw_dat

The raw dataset (dataframe)

pat_var

Variable that holds the patient number

raw_src

Name of the raw source

Value

dataframe

Examples

raw_dataset <-
  tibble::tribble(
    ~patnum, ~MDRAW,
    101L, "BABY ASPIRIN",
    102L, "CORTISPORIN",
    103L, NA_character_,
    104L, "DIPHENHYDRAMINE HCL"
  )

# Generate oak_id_vars
generate_oak_id_vars(
  raw_dat = raw_dataset,
  pat_var = "patnum",
  raw_src = "Concomitant Medication"
)
#> # A tibble: 4 × 5
#>   oak_id raw_source             patient_number patnum MDRAW              
#>    <int> <chr>                           <int>  <int> <chr>              
#> 1      1 Concomitant Medication            101    101 BABY ASPIRIN       
#> 2      2 Concomitant Medication            102    102 CORTISPORIN        
#> 3      3 Concomitant Medication            103    103 NA                 
#> 4      4 Concomitant Medication            104    104 DIPHENHYDRAMINE HCL