From dc612b749c88e4fe2793c86102d846c4f659822f Mon Sep 17 00:00:00 2001 From: Linda Nab Date: Mon, 13 Nov 2023 22:52:06 +0000 Subject: [PATCH] fix noncovid covid hosp --- analysis/data_import/process_data.R | 8 ++++++-- lib/functions/define_status_and_fu_all.R | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/analysis/data_import/process_data.R b/analysis/data_import/process_data.R index f63d780..329ff25 100644 --- a/analysis/data_import/process_data.R +++ b/analysis/data_import/process_data.R @@ -258,7 +258,7 @@ process_data <- function(data_extracted, treat_window_days = 4){ # admission, non covid hosp admission is not used as a censoring event in # our study, but we'd like to report how many pt were admitted to the # hospital for a noncovid-y reason before one of the other events - # of note, patients can have allcause hosp before or after covid hosp, + # of note, patients can have allcause (non covid!) hosp before covid hosp, # so the number of noncovid_hosp + covid_hosp is not strictly the number # of allcause_hosp noncovid_hosp_admission_date = @@ -268,7 +268,11 @@ process_data <- function(data_extracted, treat_window_days = 4){ (!is.na(allcause_hosp_admission_date) & !is.na(covid_hosp_admission_date)) & allcause_hosp_admission_date != covid_hosp_admission_date ~ - allcause_hosp_admission_date, + allcause_hosp_admission_date, # in this case individual can + # have both allcause hosp (not covid!) and covid hosp both + # first event for patient and therefore picked up both. + # all cause only includes first admissions so noncovid + covid + # can exceed number of all cause admissions. TRUE ~ NA_Date_), ) %>% # adds column status_all and fu_all diff --git a/lib/functions/define_status_and_fu_all.R b/lib/functions/define_status_and_fu_all.R index c7be0b7..d34eb10 100644 --- a/lib/functions/define_status_and_fu_all.R +++ b/lib/functions/define_status_and_fu_all.R @@ -28,7 +28,8 @@ add_status_and_fu_all <- function(data){ # "noncovid_death": non-covid death min_date_all = pmin(dereg_date, death_date, - allcause_hosp_admission_date, + covid_hosp_admission_date, + noncovid_hosp_admission_date, study_window, na.rm = TRUE), status_all = case_when(