From 8974ac5d1852bf3fb178e257f0797fe972e79d48 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Wed, 9 Oct 2024 12:24:41 +0100 Subject: [PATCH] Refine cli messages --- R/add_activity_after_death_flag.R | 2 +- R/add_hri_variables.R | 2 +- R/add_keep_population_flag.R | 2 +- R/add_nsu_cohort.R | 2 +- R/add_ppa_flag.R | 2 +- R/aggregate_by_chi.R | 4 +-- R/correct_demographics.R | 2 +- R/cost_uplift.R | 2 +- R/create_episode_file.R | 16 ++++----- R/create_individual_file.R | 60 +++++++++++++++---------------- R/fill_geographies.R | 2 +- R/join_deaths_data.R | 2 +- R/join_sparra_hhg.R | 2 +- R/link_delayed_discharge_eps.R | 2 +- R/match_on_ltcs.R | 2 +- R/process_lookup_homelessness.R | 6 ++-- 16 files changed, 55 insertions(+), 55 deletions(-) diff --git a/R/add_activity_after_death_flag.R b/R/add_activity_after_death_flag.R index 871cc03a2..72216a611 100644 --- a/R/add_activity_after_death_flag.R +++ b/R/add_activity_after_death_flag.R @@ -92,7 +92,7 @@ add_activity_after_death_flag <- function( dplyr::select(-death_date_boxi) %>% dplyr::distinct() - cli::cli_alert_info("Add activity after death flag function started at {Sys.time()}") + cli::cli_alert_info("Add activity after death flag function finished at {Sys.time()}") return(final_data) } diff --git a/R/add_hri_variables.R b/R/add_hri_variables.R index 7f4017bcd..fd37fba19 100644 --- a/R/add_hri_variables.R +++ b/R/add_hri_variables.R @@ -46,7 +46,7 @@ flag_non_scottish_residents <- function( ) %>% dplyr::select(-"dummy_postcode", -"eng_prac") - cli::cli_alert_info("Add HRI variables function started at {Sys.time()}") + cli::cli_alert_info("Add HRI variables function finished at {Sys.time()}") return(return_data) } diff --git a/R/add_keep_population_flag.R b/R/add_keep_population_flag.R index 15de6b4da..2f665c954 100644 --- a/R/add_keep_population_flag.R +++ b/R/add_keep_population_flag.R @@ -139,7 +139,7 @@ add_keep_population_flag <- function(individual_file, year) { ) } - cli::cli_alert_info("Add keep population function started at {Sys.time()}") + cli::cli_alert_info("Add keep population function finished at {Sys.time()}") return(individual_file) } diff --git a/R/add_nsu_cohort.R b/R/add_nsu_cohort.R index 78a22cb9b..b573c14ac 100644 --- a/R/add_nsu_cohort.R +++ b/R/add_nsu_cohort.R @@ -116,7 +116,7 @@ add_nsu_cohort <- function( ) %>% dplyr::select(-dplyr::contains("_nsu"), -"has_chi") - cli::cli_alert_info("Add NSU cohort function started at {Sys.time()}") + cli::cli_alert_info("Add NSU cohort function finished at {Sys.time()}") return(return_df) } diff --git a/R/add_ppa_flag.R b/R/add_ppa_flag.R index be176e8e8..3d3c7eeaf 100644 --- a/R/add_ppa_flag.R +++ b/R/add_ppa_flag.R @@ -225,7 +225,7 @@ add_ppa_flag <- function(data) { .data$cij_ppa )) - cli::cli_alert_info("Add PPA flag function started at {Sys.time()}") + cli::cli_alert_info("Add PPA flag function finished at {Sys.time()}") return(ppa_cij_data) } diff --git a/R/aggregate_by_chi.R b/R/aggregate_by_chi.R index 39739161c..010ff5bad 100644 --- a/R/aggregate_by_chi.R +++ b/R/aggregate_by_chi.R @@ -197,7 +197,7 @@ aggregate_by_chi <- function(episode_file, year, exclude_sc_var = FALSE) { ) individual_file <- individual_file[, year := year] - cli::cli_alert_info("Aggregate by CHI function started at {Sys.time()}") + cli::cli_alert_info("Aggregate by CHI function finished at {Sys.time()}") # convert back to tibble return(dplyr::as_tibble(individual_file)) @@ -272,7 +272,7 @@ aggregate_ch_episodes <- function(episode_file) { # Convert back to tibble if needed episode_file <- tibble::as_tibble(episode_file) - cli::cli_alert_info("Aggregate ch episodes function started at {Sys.time()}") + cli::cli_alert_info("Aggregate ch episodes function finished at {Sys.time()}") return(episode_file) } diff --git a/R/correct_demographics.R b/R/correct_demographics.R index 8e20dcd7a..d7322b164 100644 --- a/R/correct_demographics.R +++ b/R/correct_demographics.R @@ -100,7 +100,7 @@ correct_demographics <- function(data, year) { data_chi ) - cli::cli_alert_info("Correct demographics function started at {Sys.time()}") + cli::cli_alert_info("Correct demographics function finished at {Sys.time()}") return(data) } diff --git a/R/cost_uplift.R b/R/cost_uplift.R index 24d003308..ea3df4abe 100644 --- a/R/cost_uplift.R +++ b/R/cost_uplift.R @@ -27,7 +27,7 @@ apply_cost_uplift <- function(data) { # remove the last uplift column dplyr::select(-"uplift") - cli::cli_alert_info("Apply cost uplift function started at {Sys.time()}") + cli::cli_alert_info("Apply cost uplift function finished at {Sys.time()}") return(data) } diff --git a/R/create_episode_file.R b/R/create_episode_file.R index 1b27690e6..2d560449b 100644 --- a/R/create_episode_file.R +++ b/R/create_episode_file.R @@ -289,7 +289,7 @@ store_ep_file_vars <- function(data, year, vars_to_keep) { path = tempfile_path ) - cli::cli_alert_info("Store episode file variables function started at {Sys.time()}") + cli::cli_alert_info("Store episode file variables function finished at {Sys.time()}") return( dplyr::select( @@ -324,7 +324,7 @@ load_ep_file_vars <- function(data, year) { fs::file_delete(tempfile_path) - cli::cli_alert_info("Load episode file variable function started at {Sys.time()}") + cli::cli_alert_info("Load episode file variable function finished at {Sys.time()}") return(full_data) } @@ -380,7 +380,7 @@ fill_missing_cij_markers <- function(data) { return_data <- dplyr::bind_rows(non_fixable_data, fixed_data) - cli::cli_alert_info("Fill missing cij markers function started at {Sys.time()}") + cli::cli_alert_info("Fill missing cij markers function finished at {Sys.time()}") return(return_data) } @@ -425,7 +425,7 @@ correct_cij_vars <- function(data) { ) ) - cli::cli_alert_info("Correct cij variables function started at {Sys.time()}") + cli::cli_alert_info("Correct cij variables function finished at {Sys.time()}") return(data) } @@ -452,7 +452,7 @@ create_cost_inc_dna <- function(data) { ) ) - cli::cli_alert_info("Create cost inc dna function started at {Sys.time()}") + cli::cli_alert_info("Create cost inc dna function finished at {Sys.time()}") return(data) } @@ -478,7 +478,7 @@ create_cohort_lookups <- function(data, year, update = latest_update()) { write_to_disk = TRUE ) - cli::cli_alert_info("Create cohort lookups function started at {Sys.time()}") + cli::cli_alert_info("Create cohort lookups function finished at {Sys.time()}") return(data) } @@ -514,7 +514,7 @@ join_cohort_lookups <- function( by = "chi" ) - cli::cli_alert_info("Join cohort lookups function started at {Sys.time()}") + cli::cli_alert_info("Join cohort lookups function finished at {Sys.time()}") return(join_cohort_lookups) } @@ -554,7 +554,7 @@ join_sc_client <- function(data, ) } - cli::cli_alert_info("Join social care client function started at {Sys.time()}") + cli::cli_alert_info("Join social care client function finished at {Sys.time()}") return(data_file) } diff --git a/R/create_individual_file.R b/R/create_individual_file.R index b167aca73..f010de562 100644 --- a/R/create_individual_file.R +++ b/R/create_individual_file.R @@ -18,7 +18,7 @@ create_individual_file <- function( write_to_disk = TRUE, anon_chi_in = TRUE, anon_chi_out = TRUE) { - cli::cli_alert_info("Create individual file function started at {Sys.time()}") + cli::cli_alert_info("Create individual file function finished at {Sys.time()}") if (anon_chi_in) { episode_file <- slfhelper::get_chi( @@ -183,7 +183,7 @@ remove_blank_chi <- function(episode_file) { dplyr::mutate(chi = dplyr::na_if(.data$chi, "")) %>% dplyr::filter(!is.na(.data$chi)) - cli::cli_alert_info("Remove blank CHI function started at {Sys.time()}") + cli::cli_alert_info("Remove blank CHI function finished at {Sys.time()}") return(episode_file) } @@ -224,7 +224,7 @@ add_cij_columns <- function(episode_file) { ) ) - cli::cli_alert_info("Add cij columns function started at {Sys.time()}") + cli::cli_alert_info("Add cij columns function finished at {Sys.time()}") return(episode_file) } @@ -282,7 +282,7 @@ add_all_columns <- function(episode_file, year) { ) ) - cli::cli_alert_info("Add all columns function started at {Sys.time()}") + cli::cli_alert_info("Add all columns function finished at {Sys.time()}") return(episode_file) } @@ -294,7 +294,7 @@ add_all_columns <- function(episode_file, year) { #' @param condition Condition to create new columns based on #' @family individual_file add_acute_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add acute columns function started at {Sys.time()}") + cli::cli_alert_info("Add acute columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -307,7 +307,7 @@ add_acute_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_mat_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add maternity columns function started at {Sys.time()}") + cli::cli_alert_info("Add maternity columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -320,7 +320,7 @@ add_mat_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_mh_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add mental health columns function started at {Sys.time()}") + cli::cli_alert_info("Add mental health columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -333,7 +333,7 @@ add_mh_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_gls_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add geriatric long stay columns function started at {Sys.time()}") + cli::cli_alert_info("Add geriatric long stay columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -346,7 +346,7 @@ add_gls_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_op_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add outpatient columns function started at {Sys.time()}") + cli::cli_alert_info("Add outpatient columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file <- episode_file %>% @@ -371,7 +371,7 @@ add_op_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_ae_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add A&E columns function started at {Sys.time()}") + cli::cli_alert_info("Add A&E columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -384,7 +384,7 @@ add_ae_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_pis_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add prescribing columns function started at {Sys.time()}") + cli::cli_alert_info("Add prescribing columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -397,7 +397,7 @@ add_pis_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_ooh_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add out of hours columns function started at {Sys.time()}") + cli::cli_alert_info("Add out of hours columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file <- episode_file %>% @@ -434,7 +434,7 @@ add_ooh_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_dn_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add district nursing columns function started at {Sys.time()}") + cli::cli_alert_info("Add district nursing columns function finished at {Sys.time()}") condition <- substitute(condition) if ("total_no_dn_contacts" %in% names(episode_file)) { @@ -459,7 +459,7 @@ add_dn_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_cmh_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add communicty mental health columns function started at {Sys.time()}") + cli::cli_alert_info("Add communicty mental health columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -472,7 +472,7 @@ add_cmh_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_dd_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add delayed discharges columns function started at {Sys.time()}") + cli::cli_alert_info("Add delayed discharges columns function finished at {Sys.time()}") condition <- substitute(condition) condition_delay <- substitute(condition & primary_delay_reason != "9") @@ -495,7 +495,7 @@ add_dd_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_nsu_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add non service users columns function started at {Sys.time()}") + cli::cli_alert_info("Add non service users columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -508,7 +508,7 @@ add_nsu_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_nrs_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add nrs columns function started at {Sys.time()}") + cli::cli_alert_info("Add nrs columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -521,7 +521,7 @@ add_nrs_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_hl1_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add homelessness columns function started at {Sys.time()}") + cli::cli_alert_info("Add homelessness columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -533,7 +533,7 @@ add_hl1_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_ch_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add care home columns function started at {Sys.time()}") + cli::cli_alert_info("Add care home columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -565,7 +565,7 @@ add_ch_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_hc_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add home care columns function started at {Sys.time()}") + cli::cli_alert_info("Add home care columns function finished at {Sys.time()}") condition <- substitute(condition) @@ -611,7 +611,7 @@ add_hc_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_at_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add alarms telecare columns function started at {Sys.time()}") + cli::cli_alert_info("Add alarms telecare columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -627,7 +627,7 @@ add_at_columns <- function(episode_file, prefix, condition) { #' @inheritParams add_acute_columns #' @family individual_file add_sds_columns <- function(episode_file, prefix, condition) { - cli::cli_alert_info("Add SDS columns function started at {Sys.time()}") + cli::cli_alert_info("Add SDS columns function finished at {Sys.time()}") condition <- substitute(condition) episode_file %>% @@ -651,7 +651,7 @@ add_sds_columns <- function(episode_file, prefix, condition) { #' cij_pattype (lgl) #' @family individual_file add_ipdc_cols <- function(episode_file, prefix, condition, ipdc_d = TRUE, elective = TRUE) { - cli::cli_alert_info("Add ipdc columns function started at {Sys.time()}") + cli::cli_alert_info("Add ipdc columns function finished at {Sys.time()}") condition_i <- substitute(eval(condition) & ipdc == "I") episode_file <- episode_file %>% @@ -697,7 +697,7 @@ add_ipdc_cols <- function(episode_file, prefix, condition, ipdc_d = TRUE, electi #' @param cost Whether to create prefix_cost col, e.g. "Acute_cost" #' @family individual_file add_standard_cols <- function(episode_file, prefix, condition, episode = FALSE, cost = FALSE) { - cli::cli_alert_info("Add standard columns function started at {Sys.time()}") + cli::cli_alert_info("Add standard columns function finished at {Sys.time()}") if (episode) { episode_file <- dplyr::mutate(episode_file, "{prefix}_episodes" := dplyr::if_else(eval(condition), 1L, NA_integer_)) @@ -748,7 +748,7 @@ clean_up_ch <- function(episode_file, year) { ) %>% dplyr::select(-c("fy_end", "fy_start", "term_1", "term_2")) - cli::cli_alert_info("Clean up CH function started at {Sys.time()}") + cli::cli_alert_info("Clean up CH function finished at {Sys.time()}") return(episode_file) } @@ -769,7 +769,7 @@ recode_gender <- function(episode_file) { ) ) - cli::cli_alert_info("Recode Gender function started at {Sys.time()}") + cli::cli_alert_info("Recode Gender function finished at {Sys.time()}") return(episode_file) } @@ -785,7 +785,7 @@ condition_cols <- function() { date_cols <- paste0(conditions, "_date") all_cols <- c(conditions, date_cols) - cli::cli_alert_info("Return condition columns function started at {Sys.time()}") + cli::cli_alert_info("Return condition columns function finished at {Sys.time()}") return(all_cols) } @@ -831,7 +831,7 @@ clean_individual_file <- function(individual_file, year) { clean_up_gender() %>% dplyr::mutate(age = compute_mid_year_age(year, .data$dob)) - cli::cli_alert_info("Clean individual file function started at {Sys.time()}") + cli::cli_alert_info("Clean individual file function finished at {Sys.time()}") return(individual_file) } @@ -850,7 +850,7 @@ clean_up_gender <- function(individual_file) { ) ) - cli::cli_alert_info("Clean up gender column function started at {Sys.time()}") + cli::cli_alert_info("Clean up gender column function finished at {Sys.time()}") return(individual_file) } @@ -882,7 +882,7 @@ join_slf_lookup_vars <- function(individual_file, ) %>% dplyr::rename(hbrescode = hbrescode_var) - cli::cli_alert_info("Join slf lookup variables function started at {Sys.time()}") + cli::cli_alert_info("Join slf lookup variables function finished at {Sys.time()}") return(individual_file) } diff --git a/R/fill_geographies.R b/R/fill_geographies.R index f29413971..7d3d71aa6 100644 --- a/R/fill_geographies.R +++ b/R/fill_geographies.R @@ -39,7 +39,7 @@ fill_geographies <- function( ) ) - cli::cli_alert_info("Fill geographies function started at {Sys.time()}") + cli::cli_alert_info("Fill geographies function finished at {Sys.time()}") return(data) } diff --git a/R/join_deaths_data.R b/R/join_deaths_data.R index 72f912bad..55a412d8b 100644 --- a/R/join_deaths_data.R +++ b/R/join_deaths_data.R @@ -19,7 +19,7 @@ join_deaths_data <- function( relationship = "many-to-one" ) - cli::cli_alert_info("Join deaths data function started at {Sys.time()}") + cli::cli_alert_info("Join deaths data function finished at {Sys.time()}") return(data) } diff --git a/R/join_sparra_hhg.R b/R/join_sparra_hhg.R index 1e0b25d4f..3218d6be7 100644 --- a/R/join_sparra_hhg.R +++ b/R/join_sparra_hhg.R @@ -61,7 +61,7 @@ join_sparra_hhg <- function(data, year) { data <- dplyr::mutate(data, hhg_end_fy = NA_integer_) } - cli::cli_alert_info("Join SPARRA and HHG function started at {Sys.time()}") + cli::cli_alert_info("Join SPARRA and HHG function finished at {Sys.time()}") return(data) } diff --git a/R/link_delayed_discharge_eps.R b/R/link_delayed_discharge_eps.R index 3d5142a3b..49103ab56 100644 --- a/R/link_delayed_discharge_eps.R +++ b/R/link_delayed_discharge_eps.R @@ -374,7 +374,7 @@ link_delayed_discharge_eps <- function( )) %>% dplyr::select(-c("has_dd", "delay_dd", "original_admission_date", "amended_dates")) - cli::cli_alert_info("Link delayed discharge to episode file function started at {Sys.time()}") + cli::cli_alert_info("Link delayed discharge to episode file function finished at {Sys.time()}") return(linked_data) } diff --git a/R/match_on_ltcs.R b/R/match_on_ltcs.R index 4bf658d69..51c280966 100644 --- a/R/match_on_ltcs.R +++ b/R/match_on_ltcs.R @@ -30,7 +30,7 @@ match_on_ltcs <- function( ) %>% dplyr::select(-tidyselect::ends_with("_ltc")) - cli::cli_alert_info("Match on LTCs function started at {Sys.time()}") + cli::cli_alert_info("Match on LTCs function finished at {Sys.time()}") return(matched) } diff --git a/R/process_lookup_homelessness.R b/R/process_lookup_homelessness.R index a51fb12cd..c1adfed0d 100644 --- a/R/process_lookup_homelessness.R +++ b/R/process_lookup_homelessness.R @@ -22,7 +22,7 @@ create_homelessness_lookup <- function( tidyr::drop_na(.data$chi) %>% dplyr::mutate(hl1_in_fy = 1L) - cli::cli_alert_info("Create homelessness lookup function started at {Sys.time()}") + cli::cli_alert_info("Create homelessness lookup function finished at {Sys.time()}") return(homelessness_lookup) } @@ -55,7 +55,7 @@ add_homelessness_flag <- function(data, year, ) %>% dplyr::mutate(hl1_in_fy = tidyr::replace_na(.data$hl1_in_fy, 0L)) - cli::cli_alert_info("Add homelessness flag function started at {Sys.time()}") + cli::cli_alert_info("Add homelessness flag function finished at {Sys.time()}") return(data) } @@ -131,7 +131,7 @@ add_homelessness_date_flags <- function(data, year, lookup = create_homelessness ) ) - cli::cli_alert_info("Add homelessness date flags function started at {Sys.time()}") + cli::cli_alert_info("Add homelessness date flags function finished at {Sys.time()}") return(data) }