Skip to content

Commit

Permalink
fix noncovid covid hosp
Browse files Browse the repository at this point in the history
  • Loading branch information
Linda Nab committed Nov 13, 2023
1 parent 3a00d1a commit dc612b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions analysis/data_import/process_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/functions/define_status_and_fu_all.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit dc612b7

Please sign in to comment.