3.7 Standardize and merge event tables

The following event tables are merged to produce a master event table:

  • Outcome field event table (combination of first occurrence event data and algorithmically defined event data from demographic table)
  • ICD10 code event table
  • OPCS4 code event table
  • Self-reported condition code event table
  • Self-reported operation code event table
  • Custom defined event table for DR
# Standardize
outcome_fields_table_long <- 
  outcome_fields_table_long %>% mutate(type = "outcome_fields") %>% rename(key=field)

ICD_codes_full <- 
  ICD_codes_full %>% mutate(code=as.character(code)) %>% rename(key=code)

OPCS4_codes_long <- 
  OPCS4_codes_long %>% rename(key=code)

selfrep_codes_long <- 
  selfrep_codes_long %>% mutate(code=as.character(code)) %>% rename(key=code)

selfrep_op_codes_long <- 
  selfrep_op_codes_long %>% mutate(code=as.character(code)) %>% rename(key=code)

custom_outcome_fields_table_long <-
  custom_outcome_fields_table_long %>% mutate(type = "custom_fields") %>% rename(key = field)

event_tab <- bind_rows(list(outcome_fields_table_long,ICD_codes_full,
                            OPCS4_codes_long,selfrep_codes_long,selfrep_op_codes_long,
                            custom_outcome_fields_table_long))

Filter out events where the date of event is missing.

event_tab <- event_tab %>% filter(!is.na(event_dt))