By Christian McDonald, Assistant Professor of Practice
School of Journalism and Media, Moody College of Communication
University of Texas at Austin


This THCIC analysis will need various lists of columns and ICD-10 codes. This notebook defines them and write them to rds where they can be use in later analysis.

Of note, to turn a single-column rds import into a vector, use the following:

new_list <- read_rds("procedures-lists/filename.rds") %>% .$col_name_from_df
library(tidyverse)
library(janitor)

THCIC column lists

The diagnostic and surgical procedure columns from the THCIC data are frequently used in case_when() statements and other vectors. This writes them to csv and rds for use later. I use my test data as a base point to find the columns.

There is an example data dictionary in the resources directory of this repo, or avialable online labeled as User Manual, 2019.

Import test data for column generation

testdata <- read_rds("data-test/ahrq_del_all_loop_test.rds")

Diagnostic columns

Values are all the names of diagnostics columns from the data in a singe tibble with column named diag.

cols_diag <- testdata %>% 
  select(contains("_DIAG"), -starts_with("POA")) %>%
  names() %>% 
  tibble::enframe(name = NULL) %>% 
  rename(diag = value)

cols_diag %>% 
  write_csv("procedures-lists/cols_diag.csv")

cols_diag %>% 
  write_rds("procedures-lists/cols_diag.rds")

Surgical procedure columns

Values are all the names of surgical procedure columns from the data in a singe tibble with column named surg.

cols_surg <- testdata %>% 
  select(contains("SURG_PROC_CODE")) %>%
  names() %>% 
  tibble::enframe(name = NULL) %>% 
  rename(surg = value)

cols_surg %>% 
  write_csv("procedures-lists/cols_surg.csv")

cols_surg %>% 
  write_rds("procedures-lists/cols_surg.rds")

AHRQ lists

These can come from AHRQ IQI 22 and 33. Some are in both. In addition to the links below they available in the resources directory of this repo.

All deliveries (DELOCMD)

All deliveries, identified by any-listed ICD-10-CM diagnosis code for outcome of delivery (DELOCMD). In IQI 33 (2020).

delocmd_list <- c(
  "Z370",
  "Z371",
  "Z372",
  "Z373",
  "Z374",
  "Z3750",
  "Z3751",
  "Z3752",
  "Z3753",
  "Z3754",
  "Z3759",
  "Z3760",
  "Z3761",
  "Z3762",
  "Z3763",
  "Z3764",
  "Z3769",
  "Z377",
  "Z379"
) %>%  
  tibble::enframe(name = NULL) %>% 
  rename(delocmd = value)

delocmd_list %>% 
  write_rds("procedures-lists/ahrq_delocmd.rds")

delocmd_list %>% nrow()
## [1] 19

Abnormal presentations (PRCSECD)

We first need the list of PRCSECD codes from resources/IQI_Appendix_A_v2020.pdf: “Abnormal presentation, fetal death, and multiple gestation diagnosis codes: (PRCSECD).”

The list of codes was extracted from the PDF and cleaned in OpenRefine to get the full list. The OpenRefine project is available in the procedures/iqi-appendex-a folder.

prcsecd_list <- read_csv("procedures-lists/IQI_Appendix_A.csv") %>% rename(prcsecd = codes)
## Parsed with column specification:
## cols(
##   codes = col_character()
## )
prcsecd_list %>% 
  write_rds("procedures-lists/ahrq_prcsecd.rds")

prcsecd_list %>% nrow()
## [1] 276

Cesarean delivery procedure codes: (PRCSECP)

As defined in 1Q1 33 Primary Cesarean Delivery Rate, Uncomplicated (2020). These values update those above. Need to ensure they catch cesarean deliveries in prior years. Basically in 2020 they removed one of the previous options to use MS-DRG codes (which was easier.)

prcsecp_list <- c(
  "10D00Z0",
  "10D00Z1",
  "10D00Z2"
) %>%  
  tibble::enframe(name = NULL) %>% 
  rename(prcsecp = value)

prcsecp_list %>% 
  write_rds("procedures-lists/ahrq_prcsecp.rds")

prcsecp_list %>% nrow()
## [1] 3

Hysterotomy procedure codes: (PRCSE2P)

As defined in 1Q1 33 Primary Cesarean Delivery Rate, Uncomplicated. (2020)

prcse2p_list <- c(
  "10A00ZZ",
  "10A03ZZ",
  "10A04ZZ"
) %>%  
  tibble::enframe(name = NULL) %>% 
  rename(prcse2p = value)

prcse2p_list %>% 
  write_rds("procedures-lists/ahrq_prcse2p.rds")

prcse2p_list %>% nrow()
## [1] 3

Previous Cesarean delivery diagnosis codes: (PRVBACD)

As defined in 1Q1 33 Primary Cesarean Delivery Rate, Uncomplicated (2020). Also used for IQI 22 Vaginal Birth After Cesarean (VBAC) Delivery Rate, Uncomplicated (2020).

  • with any-listed ICD-10-CM diagnosis codes for previous Cesarean delivery (PRVBACD*)
prvbacd_list <- c(
  "O3421",
  "O34211",
  "O34212",
  "O34219",
  "O6641"
) %>%  
  tibble::enframe(name = NULL) %>% 
  rename(prvbacd = value)

prvbacd_list %>% 
  write_rds("procedures-lists/ahrq_prvbacd.rds")

prvbacd_list %>% nrow()
## [1] 5

Vaginal delivery procedure codes: (VAGDELP)

From IQI 22 Vaginal Birth After Cesarean (VBAC) Delivery Rate, Uncomplicated (2020).

vagdelp_list <- c(
  "10D07Z3",
  "10D07Z4",
  "10D07Z5",
  "10D07Z6",
  "10D07Z7",
  "10D07Z8",
  "10E0XZZ"
) %>%  
  tibble::enframe(name = NULL) %>% 
  rename(vagdelp = value)

vagdelp_list %>% 
  write_rds("procedures-lists/ahrq_vagdelp.rds")

vagdelp_list %>% nrow()
## [1] 7

Leapfrog Episiotomy lists

These definitions come from Leapfrog Hospital survey measure specifications. There is also a copy in the resources directory of this repo.

Vaginal MS_DRG codes

vag_msdrg_list <- c(
  "768",
  "796",
  "797",
  "798",
  "805",
  "806",
  "807"
) %>%  
  tibble::enframe(name = NULL) %>% 
  rename(vag_msdrg = value)

vag_msdrg_list %>% 
  write_rds("procedures-lists/lf_vag_msdrg.rds")

vag_msdrg_list %>% nrow()
## [1] 7

Vaginal APR_DRG codes

vag_aprdrg_list <- c(
  "541",
  "542",
  "560"
) %>%  
  tibble::enframe(name = NULL) %>% 
  rename(vag_aprdrg = value)

vag_aprdrg_list %>% 
  write_rds("procedures-lists/lf_vag_aprdrg.rds")

vag_aprdrg_list %>% nrow()
## [1] 3

Vaginal birth exclusions

Obstructed labor due to shoulder dystocia.

vag_excl_list <- c(
  "O660"
) %>%  
  tibble::enframe(name = NULL) %>% 
  rename(vag_excl = value)

vag_excl_list %>% 
  write_rds("procedures-lists/lf_vag_excl.rds")

vag_excl_list %>% nrow()
## [1] 1

Episiotomy

epi_list <- c(
  "0W8NXZZ"
) %>%  
  tibble::enframe(name = NULL) %>% 
  rename(epi = value)

epi_list %>% 
  write_rds("procedures-lists/lf_epi.rds")

epi_list %>% nrow()
## [1] 1

Other lists used

Child-bearing age codes

Researchers at the Office of Health Affairs-Population Health, The University of Texas System work with the THCIC file daily and they suggest filtering deliveries to women of normal child-bearing age, 15-49.

The codes for the ages 15-49 include 05-12. For HIV or drug patients it includes 23 (18-44 yrs).

age_list <- c(
  "05",
  "06",
  "07",
  "08",
  "09",
  "10",
  "11",
  "12",
  "23"
) %>%  
  tibble::enframe(name = NULL) %>% 
  rename(age = value)

age_list %>% 
  write_rds("procedures-lists/utoha_age.rds")

age_list %>% nrow()
## [1] 9

Closing out

beepr::beep(4)