7 Make outcome-specific code dictionary

In this chapter, we create outcome-specific dictionaries. To do this, we define the following:

  • inclusion codes or code patterns
  • exclusion codes or code patterns
  • inclusion keywords or keyword patterns
  • exclusion keywords or keyword patterns

Using these, we subset the master dictionary (full_dict.RDS) to generate outcome-specific dictionary. The following are the event tables that require the primary care data and thus require outcome-specific dictionary:

  • Diabetes event table
  • Diabetic eye disease table for capturing diabetic eye disease cases
  • Kidney disease case event table for capturing diabetic kidney disease cases
  • Non-diabetic eye disease table for excluding controls from time-to-event data for DR
  • Kidney disease event table for excluding controls from time-to-event data for DKD

We generate the following outcome-specific dictionaries:

  • diabetes specific dictionary
  • diabetic eye disease dictionary
  • kidney disease case dictionary
  • non-diabetic eye disease dictionary
  • kidney disease control exclusion event dictionary

Load packages.

library(tidyverse)
library(data.table)
library(readxl)

Import the master dictionary.

full_dict <- readRDS("generated_data/full_dict.RDS")

We first define the global exclusion keywords which we will be used to exclude certain codes from all of the outcome-specific dictionaries. These codes are related to the absence of a condition, screening for a condition, normal result for a condition, family history of a condition, various administrative statuses and more, and are not wanted when we capture the codes that are specific to certain outcomes.

global_exclusion_keyword_patterns <- " normal| absent|inspection|examination|evaluation|referral|^no |^O/E- no |^O/E - no |excluded|not seen|seen by|not examined|did not attend|assessable|offered|^trauma| trauma|malnutrition|screening for|^FH|family history|interpret|under care|refused|unsuitable|at risk|resolved|disease screening|not indicated|letter|excepted|exception|fear of|education|sharing consent|tumour|pregnancy|gestational|diabetic child|complication of care|steriod-induced|lymphoma|cytomegalovirus|rubella|blastoma|histoplasm|toxoplasm|neoplasm|herpes|tubercul|pediculus| observation$|injury|streptococcal"