Skip to content

Commit

Permalink
mmi working
Browse files Browse the repository at this point in the history
  • Loading branch information
bex-0-madden committed Sep 26, 2024
1 parent d241ed4 commit 4555ea1
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 36 deletions.
6 changes: 3 additions & 3 deletions 01_control/control_mmi.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ compile_referrals_summary()
compile_non_acceptance_summary()

# Step 5 - Create plots ---------------------------------------------------
#
# create_plots_patients_seen("PT")
# create_plots_patients_seen("CAMHS")
#
#create_plots_patients_seen("PT")
#create_plots_patients_seen("CAMHS")

12 changes: 6 additions & 6 deletions 04_check_modify/add_rtt_eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ add_rtt_eval <- function(df, evalAllData=FALSE) {
ref_acc_last_reported == 1 &
any(
!is.na(!!sym(treat_start_date_o))
) ~ 'seen - active',
) ~ 'seen - active', # not how treat_start_date is really meant to be used..?

#other case is patients seen whose treatment is ongoing
has_ref_rec_date_opti == TRUE &
Expand All @@ -68,7 +68,7 @@ add_rtt_eval <- function(df, evalAllData=FALSE) {
ref_acc_last_reported == 1 &
any(
!is.na(!!sym(treat_start_date_o))
) ~ 'seen - closed',
) ~ 'seen - closed', # not how treat_start_date is really meant to be used..?

#next case is patients seen whose treatment is finished
has_ref_rec_date_opti == TRUE &
Expand Down Expand Up @@ -135,15 +135,15 @@ add_rtt_eval <- function(df, evalAllData=FALSE) {
any(
!is.na(!!sym(app_date_o)) &
!!sym(att_status_o) == 1
) ~ 'rtt not possible - attended app but no purpose',
) ~ 'rtt not possible - attended app but no purpose', # this isn't dependent on only FIRST treatment app

#rtt not possible - no app attendance information
has_any_app_date == TRUE &
has_ref_rec_date_opti == TRUE &
#is_case_closed == FALSE &
ref_acc_last_reported == 1 &
(!!sym(att_status_o) == 99 | is.na(!!sym(att_status_o)))
~ 'rtt not possible - app date but no attendance status',
~ 'rtt not possible - app date but no attendance status', # this isn't dependent on only FIRST treatment app


#case closed due to no attendance
Expand All @@ -154,7 +154,7 @@ add_rtt_eval <- function(df, evalAllData=FALSE) {
any(
!is.na(!!sym(app_date_o)) &
!!sym(att_status_o) %in% c(2,3,5,8)
) ~ 'case closed due to non attendance',
) ~ 'case closed due to non attendance', # would this flag any closed case where ANY (rather than ALL) nonattendance had occurred?

#patients waiting no attendance
has_any_app_date == TRUE &
Expand All @@ -164,7 +164,7 @@ add_rtt_eval <- function(df, evalAllData=FALSE) {
any(
!is.na(!!sym(app_date_o)) &
!!sym(att_status_o) %in% c(2,3,5,8)
) ~ 'waiting - not attended',
) ~ 'waiting - not attended', # again ANY or ALL apps non-attended being flagged here?

#case closed prior to app
has_any_app_date == FALSE &
Expand Down
2 changes: 1 addition & 1 deletion 06_calculations/calculate_adjusted_rtt_waits.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ calculate_adjusted_rtt_waits <- function(df){
df_reset <- df_rtt |>
mutate(dna_date = if_else(#app_purpose %in% c(2, 3) & removing - should reset for treatment and assessment app d/cna/w
att_status %in% c(3, 5, 8) &
app_date < first_treat_app,
app_date < first_treat_app, # should this <= instead?
app_date, NA_Date_)) |> # makes a column with dates for any D/CNA/W # will need to add cancellation date here

filter(!is.na(dna_date)) |> # removes gaps between dnas so lag doesn't get interrupted
Expand Down
2 changes: 2 additions & 0 deletions 07_publication/script/chapters/2_load_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ source('./07_publication/script/functions/get_forpub_refs_agesex.R')
#### Functions for MMI only ----------------------------------------------------

source('./07_publication/script/functions/summarise_patients_seen.R')
source('./07_publication/script/functions/compile_pat_seen_adj_excel_summary.R')
source('./07_publication/script/functions/compile_pat_seen_unadj_excel_summary.R')
5 changes: 3 additions & 2 deletions 07_publication/script/chapters/3_set_constants.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ apps_att_dir <- paste0(shorewise_pub_data_dir, "/appointments_att/")
basic_opti_dir <- paste0(shorewise_pub_data_dir, "/basic_v_opti/")
markdown_dir <- paste0(root_dir, "/markdown/")
open_dir <- paste0(shorewise_pub_data_dir, "/open_cases/")
pat_seen_dir <- paste0(shorewise_pub_data_dir, "/patients_seen/")

# 4 - Reference -----------------------------------------------------------

Expand Down Expand Up @@ -65,8 +66,8 @@ df_ds_hb_name <- cross_join(as.data.frame(vec_dataset_type),
rename(dataset_type = vec_dataset_type,
hb_name = hb_vector) |>
mutate(hb_name = factor(hb_name, levels = hb_vector))
filter(!(#dataset_type == "CAMHS" &
hb_name == "NHS 24")) # remove invalid combo
# filter(!(#dataset_type == "CAMHS" &
# hb_name == "NHS 24")) # remove invalid combo

# with time columns
df_time <- data.frame(month = date_range) |>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ compile_pat_seen_adj_summary <- function(){
#filnames <- list.files(ref_dir)

# load parquet files
p1 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_all.parquet"))
p2 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_all_sex.parquet"))
p3 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_all_age.parquet"))
p4 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_all_simd.parquet"))
p1 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_all.parquet"))
p2 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_all_sex.parquet"))
p3 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_all_age.parquet"))
p4 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_all_simd.parquet"))

p5 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_mth.parquet"))
p6 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_mth_sex.parquet"))
p7 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_mth_age.parquet"))
p8 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_mth_simd.parquet"))
p5 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_mth.parquet"))
p6 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_mth_sex.parquet"))
p7 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_mth_age.parquet"))
p8 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_mth_simd.parquet"))

p9 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_qt.parquet"))
p10 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_qt_sex.parquet"))
p11 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_qt_age.parquet"))
p12 <- read_parquet(paste0(pat_seen_dir, "adj_wait_grp_qt_simd.parquet"))
p9 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_qt.parquet"))
p10 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_qt_sex.parquet"))
p11 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_qt_age.parquet"))
p12 <- read_parquet(paste0(pat_seen_dir, "pat_seen_adj_wait_grp_qt_simd.parquet"))

# name tabs
list_tabs <- list(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ compile_pat_seen_unadj_summary <- function(){
#filnames <- list.files(ref_dir)

# load parquet files
p1 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_all.parquet"))
p2 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_all_sex.parquet"))
p3 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_all_age.parquet"))
p4 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_all_simd.parquet"))
p1 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_all.parquet"))
p2 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_all_sex.parquet"))
p3 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_all_age.parquet"))
p4 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_all_simd.parquet"))

p5 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_mth.parquet"))
p6 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_mth_sex.parquet"))
p7 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_mth_age.parquet"))
p8 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_mth_simd.parquet"))
p5 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_mth.parquet"))
p6 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_mth_sex.parquet"))
p7 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_mth_age.parquet"))
p8 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_mth_simd.parquet"))

p9 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_qt.parquet"))
p10 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_qt_sex.parquet"))
p11 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_qt_age.parquet"))
p12 <- read_parquet(paste0(pat_seen_dir, "unadj_wait_grp_qt_simd.parquet"))
p9 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_qt.parquet"))
p10 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_qt_sex.parquet"))
p11 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_qt_age.parquet"))
p12 <- read_parquet(paste0(pat_seen_dir, "pat_seen_unadj_wait_grp_qt_simd.parquet"))

# name tabs
list_tabs <- list(
Expand Down

0 comments on commit 4555ea1

Please sign in to comment.