From 8c5cd272108ef4ae87c93cffe3d09d927a38378c Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Wed, 18 Oct 2023 15:25:01 +0100 Subject: [PATCH 01/13] remove rename of hscp - keeps breaking tests --- R/get_existing_data_for_tests.R | 3 --- 1 file changed, 3 deletions(-) diff --git a/R/get_existing_data_for_tests.R b/R/get_existing_data_for_tests.R index ae3c07e16..9e7d06dcd 100644 --- a/R/get_existing_data_for_tests.R +++ b/R/get_existing_data_for_tests.R @@ -51,9 +51,6 @@ get_existing_data_for_tests <- function(new_data, file_version = "episode", anon recids = recids, col_select = variable_names )) - if ("hscp2018" %in% variable_names) { - slf_data <- dplyr::rename(slf_data, "hscp" = "hscp2018") - } } else { slf_data <- suppressMessages(slfhelper::read_slf_individual( year = year, From 82b0c34c244e888b8c65b5496ddfd7a7c36781c8 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Wed, 18 Oct 2023 15:51:43 +0100 Subject: [PATCH 02/13] Add parameter to `write_tests_xlsx` for sorting --- R/write_tests_xlsx.R | 19 +++++++++++++------ man/write_tests_xlsx.Rd | 10 +++++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/R/write_tests_xlsx.R b/R/write_tests_xlsx.R index 68452b0cf..fed9fa5d6 100644 --- a/R/write_tests_xlsx.R +++ b/R/write_tests_xlsx.R @@ -9,19 +9,26 @@ #' the sheet name #' @param year If applicable, the financial year of the data in '1920' format #' this will be prepended to the sheet name. The default is `NULL`. +#' @param workbook_name Split up tests into 4 different workbooks for ease of +#' interpreting. Episode file, individual file, lookup and extract tests. #' #' @return a [tibble][tibble::tibble-package] containing a test comparison. #' #' @family test functions #' @seealso produce_test_comparison -write_tests_xlsx <- function(comparison_data, sheet_name, year = NULL) { +write_tests_xlsx <- function(comparison_data, + sheet_name, + year = NULL, + workbook_name = c("ep_file", "indiv_file", "lookup", "extract")) { # Set up the workbook ---- - tests_workbook_name <- ifelse( - is.null(year), - stringr::str_glue(latest_update(), "_lookups_tests"), - stringr::str_glue(latest_update(), "_{year}_tests") - ) + tests_workbook_name <- dplyr::case_when( + workbook_name == "ep_file" ~ stringr::str_glue(latest_update(), "_ep_file_tests"), + workbook_name == "indiv_file" ~ stringr::str_glue(latest_update(), "_indiv_file_tests"), + workbook_name == "lookup" ~ stringr::str_glue(latest_update(), "_lookups_tests"), + workbook_name == "extract" ~ stringr::str_glue(latest_update(), "_{year}_extract_tests") + ) + tests_workbook_path <- fs::path( get_slf_dir(), diff --git a/man/write_tests_xlsx.Rd b/man/write_tests_xlsx.Rd index eef4d356d..c510e2570 100644 --- a/man/write_tests_xlsx.Rd +++ b/man/write_tests_xlsx.Rd @@ -4,7 +4,12 @@ \alias{write_tests_xlsx} \title{Write out Tests} \usage{ -write_tests_xlsx(comparison_data, sheet_name, year = NULL) +write_tests_xlsx( + comparison_data, + sheet_name, + year = NULL, + workbook_name = c("ep_file", "indiv_file", "lookup", "extract") +) } \arguments{ \item{comparison_data}{produced by \code{\link[=produce_test_comparison]{produce_test_comparison()}}} @@ -14,6 +19,9 @@ the sheet name} \item{year}{If applicable, the financial year of the data in '1920' format this will be prepended to the sheet name. The default is \code{NULL}.} + +\item{workbook_name}{Split up tests into 4 different workbooks for ease of +interpreting. Episode file, individual file, lookup and extract tests.} } \value{ a \link[tibble:tibble-package]{tibble} containing a test comparison. From f007c56fd4461ad3619457e8a7fd654ad2becb32 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Wed, 18 Oct 2023 15:58:40 +0100 Subject: [PATCH 03/13] add parameter for sorting tests into workbooks --- R/process_tests_alarms_telecare.R | 2 +- R/process_tests_care_home.R | 2 +- R/process_tests_cmh.R | 2 +- R/process_tests_delayed_discharges.R | 2 +- R/process_tests_district_nursing.R | 2 +- R/process_tests_episode_file.R | 2 +- R/process_tests_gp_ooh.R | 2 +- R/process_tests_home_care.R | 2 +- R/process_tests_homelessness.R | 2 +- R/process_tests_individual_file.R | 2 +- R/process_tests_it_chi_deaths.R | 2 +- R/process_tests_lookup_gpprac.R | 2 +- R/process_tests_lookup_pc.R | 2 +- R/process_tests_ltcs.R | 2 +- R/process_tests_maternity.R | 2 +- R/process_tests_mental_health.R | 2 +- R/process_tests_nrs_deaths.R | 2 +- R/process_tests_outpatients.R | 2 +- R/process_tests_prescribing.R | 2 +- R/process_tests_sc_ch_episodes.R | 2 +- R/process_tests_sc_client_lookup.R | 2 +- R/process_tests_sc_demographics.R | 2 +- R/process_tests_sds.R | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/R/process_tests_alarms_telecare.R b/R/process_tests_alarms_telecare.R index a0c46ff07..12672c169 100644 --- a/R/process_tests_alarms_telecare.R +++ b/R/process_tests_alarms_telecare.R @@ -16,7 +16,7 @@ process_tests_alarms_telecare <- function(data, year) { ) comparison %>% - write_tests_xlsx(sheet_name = "AT", year) + write_tests_xlsx(sheet_name = "AT", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_care_home.R b/R/process_tests_care_home.R index 3633c9882..b28463cb0 100644 --- a/R/process_tests_care_home.R +++ b/R/process_tests_care_home.R @@ -13,7 +13,7 @@ process_tests_care_home <- function(data, year) { old_data = produce_source_ch_tests(old_data), new_data = produce_source_ch_tests(data) ) %>% - write_tests_xlsx(sheet_name = "CH", year) + write_tests_xlsx(sheet_name = "CH", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_cmh.R b/R/process_tests_cmh.R index 1fa21b71f..7921f30c8 100644 --- a/R/process_tests_cmh.R +++ b/R/process_tests_cmh.R @@ -18,7 +18,7 @@ process_tests_cmh <- function(data, year) { old_data = produce_source_cmh_tests(old_data), new_data = produce_source_cmh_tests(data) ) %>% - write_tests_xlsx(sheet_name = "CMH", year) + write_tests_xlsx(sheet_name = "CMH", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_delayed_discharges.R b/R/process_tests_delayed_discharges.R index b540d1f74..9061018ec 100644 --- a/R/process_tests_delayed_discharges.R +++ b/R/process_tests_delayed_discharges.R @@ -16,7 +16,7 @@ process_tests_delayed_discharges <- function(data, year) { old_data = produce_source_dd_tests(old_data), new_data = produce_source_dd_tests(data) ) %>% - write_tests_xlsx(sheet_name = "DD", year) + write_tests_xlsx(sheet_name = "DD", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_district_nursing.R b/R/process_tests_district_nursing.R index 7f73570e4..b6fe117ec 100644 --- a/R/process_tests_district_nursing.R +++ b/R/process_tests_district_nursing.R @@ -25,7 +25,7 @@ process_tests_district_nursing <- function(data, year) { old_data = produce_source_dn_tests(old_data), new_data = produce_source_dn_tests(data) ) %>% - write_tests_xlsx(sheet_name = "dn", year) + write_tests_xlsx(sheet_name = "dn", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_episode_file.R b/R/process_tests_episode_file.R index bb04cdfc7..eaa946e3e 100644 --- a/R/process_tests_episode_file.R +++ b/R/process_tests_episode_file.R @@ -31,7 +31,7 @@ process_tests_episode_file <- function(data, year) { recid = TRUE ) %>% dplyr::arrange(.data[["recid"]]) %>% - write_tests_xlsx(sheet_name = "ep_file", year) + write_tests_xlsx(sheet_name = "ep_file", year, workbook_name = "ep_file") return(comparison) } diff --git a/R/process_tests_gp_ooh.R b/R/process_tests_gp_ooh.R index e78a353f4..86c83d64a 100644 --- a/R/process_tests_gp_ooh.R +++ b/R/process_tests_gp_ooh.R @@ -17,7 +17,7 @@ process_tests_gp_ooh <- function(data, year) { sum_mean_vars = "cost" ) ) %>% - write_tests_xlsx(sheet_name = "GPOoH", year) + write_tests_xlsx(sheet_name = "GPOoH", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_home_care.R b/R/process_tests_home_care.R index 71938d889..6c797df88 100644 --- a/R/process_tests_home_care.R +++ b/R/process_tests_home_care.R @@ -15,7 +15,7 @@ process_tests_home_care <- function(data, year) { ) comparison %>% - write_tests_xlsx(sheet_name = "home_care", year) + write_tests_xlsx(sheet_name = "home_care", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_homelessness.R b/R/process_tests_homelessness.R index bea7fc881..d6b748f47 100644 --- a/R/process_tests_homelessness.R +++ b/R/process_tests_homelessness.R @@ -14,7 +14,7 @@ process_tests_homelessness <- function(data, year) { old_data = produce_slf_homelessness_tests(old_data), new_data = produce_slf_homelessness_tests(data) ) %>% - write_tests_xlsx(sheet_name = "HL1", year) + write_tests_xlsx(sheet_name = "HL1", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_individual_file.R b/R/process_tests_individual_file.R index a9d193465..d2e5d7a57 100644 --- a/R/process_tests_individual_file.R +++ b/R/process_tests_individual_file.R @@ -35,7 +35,7 @@ process_tests_individual_file <- function(data, year) { old_data = produce_individual_file_tests(old_data), new_data = produce_individual_file_tests(data) ) %>% - write_tests_xlsx(sheet_name = "indiv_file", year) + write_tests_xlsx(sheet_name = "indiv_file", year, workbook_name = "indiv_file") return(comparison) } diff --git a/R/process_tests_it_chi_deaths.R b/R/process_tests_it_chi_deaths.R index d10eadd23..5de2d02c8 100644 --- a/R/process_tests_it_chi_deaths.R +++ b/R/process_tests_it_chi_deaths.R @@ -10,7 +10,7 @@ process_tests_it_chi_deaths <- function(data, update = previous_update()) { ), new_data = produce_it_chi_deaths_tests(data) ) %>% - write_tests_xlsx(sheet_name = "it_chi_deaths") + write_tests_xlsx(sheet_name = "it_chi_deaths", workbook_name = "lookup") return(comparison) } diff --git a/R/process_tests_lookup_gpprac.R b/R/process_tests_lookup_gpprac.R index f66d1dc31..453bcaa24 100644 --- a/R/process_tests_lookup_gpprac.R +++ b/R/process_tests_lookup_gpprac.R @@ -13,7 +13,7 @@ process_tests_lookup_gpprac <- function(data, update = previous_update()) { ), new_data = produce_slf_gpprac_tests(data) ) %>% - write_tests_xlsx(sheet_name = "source_gpprac_lookup") + write_tests_xlsx(sheet_name = "source_gpprac_lookup", workbook_name = "lookup") return(comparison) } diff --git a/R/process_tests_lookup_pc.R b/R/process_tests_lookup_pc.R index 10272e5da..e018af70b 100644 --- a/R/process_tests_lookup_pc.R +++ b/R/process_tests_lookup_pc.R @@ -17,7 +17,7 @@ process_tests_lookup_pc <- function(data, update = previous_update()) { ), new_data = produce_slf_postcode_tests(data) ) %>% - write_tests_xlsx(sheet_name = "source_pc_lookup") + write_tests_xlsx(sheet_name = "source_pc_lookup", workbook_name = "lookup") return(comparison) } diff --git a/R/process_tests_ltcs.R b/R/process_tests_ltcs.R index 9e69c596a..93f35b36d 100644 --- a/R/process_tests_ltcs.R +++ b/R/process_tests_ltcs.R @@ -23,7 +23,7 @@ process_tests_ltcs <- function(data, year) { issue = NA ) %>% # Save test comparisons as an excel workbook - write_tests_xlsx(sheet_name = "ltc", year = year) + write_tests_xlsx(sheet_name = "ltc", year = year, workbook_name = "extract") return(duplicates) } diff --git a/R/process_tests_maternity.R b/R/process_tests_maternity.R index 4fe195af4..2629ead5b 100644 --- a/R/process_tests_maternity.R +++ b/R/process_tests_maternity.R @@ -13,7 +13,7 @@ process_tests_maternity <- function(data, year) { old_data = produce_source_extract_tests(old_data), new_data = produce_source_extract_tests(data) ) %>% - write_tests_xlsx(sheet_name = "02B", year) + write_tests_xlsx(sheet_name = "02B", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_mental_health.R b/R/process_tests_mental_health.R index 2c7e0e25e..520757dca 100644 --- a/R/process_tests_mental_health.R +++ b/R/process_tests_mental_health.R @@ -13,7 +13,7 @@ process_tests_mental_health <- function(data, year) { old_data = produce_source_extract_tests(old_data), new_data = produce_source_extract_tests(data) ) %>% - write_tests_xlsx(sheet_name = "04B", year) + write_tests_xlsx(sheet_name = "04B", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_nrs_deaths.R b/R/process_tests_nrs_deaths.R index fd96fa5c4..851cf7667 100644 --- a/R/process_tests_nrs_deaths.R +++ b/R/process_tests_nrs_deaths.R @@ -13,7 +13,7 @@ process_tests_nrs_deaths <- function(data, year) { old_data = produce_source_nrs_tests(old_data), new_data = produce_source_nrs_tests(data) ) %>% - write_tests_xlsx(sheet_name = "NRS", year) + write_tests_xlsx(sheet_name = "NRS", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_outpatients.R b/R/process_tests_outpatients.R index 5ab3e82db..2ce36172d 100644 --- a/R/process_tests_outpatients.R +++ b/R/process_tests_outpatients.R @@ -21,7 +21,7 @@ process_tests_outpatients <- function(data, year) { add_hscp_count = FALSE ) ) %>% - write_tests_xlsx(sheet_name = "00B", year) + write_tests_xlsx(sheet_name = "00B", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_prescribing.R b/R/process_tests_prescribing.R index 4b4c4dcb3..78007499c 100644 --- a/R/process_tests_prescribing.R +++ b/R/process_tests_prescribing.R @@ -13,7 +13,7 @@ process_tests_prescribing <- function(data, year) { old_data = produce_source_pis_tests(old_data), new_data = produce_source_pis_tests(data) ) %>% - write_tests_xlsx(sheet_name = "PIS", year) + write_tests_xlsx(sheet_name = "PIS", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_sc_ch_episodes.R b/R/process_tests_sc_ch_episodes.R index 5f6f8d346..b66b781f1 100644 --- a/R/process_tests_sc_ch_episodes.R +++ b/R/process_tests_sc_ch_episodes.R @@ -20,7 +20,7 @@ process_tests_sc_ch_episodes <- function(data) { ) comparison %>% - write_tests_xlsx(sheet_name = "all_ch_episodes") + write_tests_xlsx(sheet_name = "all_ch_episodes", workbook_name = "lookup") return(comparison) } diff --git a/R/process_tests_sc_client_lookup.R b/R/process_tests_sc_client_lookup.R index c3e4e70f9..f7d1eca9f 100644 --- a/R/process_tests_sc_client_lookup.R +++ b/R/process_tests_sc_client_lookup.R @@ -16,7 +16,7 @@ process_tests_sc_client_lookup <- function(data, year) { ) comparison %>% - write_tests_xlsx(sheet_name = "sc_client", year) + write_tests_xlsx(sheet_name = "sc_client", year, workbook_name = "lookup") return(comparison) } diff --git a/R/process_tests_sc_demographics.R b/R/process_tests_sc_demographics.R index 30321dc1d..dfb110aa9 100644 --- a/R/process_tests_sc_demographics.R +++ b/R/process_tests_sc_demographics.R @@ -18,7 +18,7 @@ process_tests_sc_demographics <- function(data) { data ) ) %>% - write_tests_xlsx(sheet_name = "sc_demographics") + write_tests_xlsx(sheet_name = "sc_demographics", workbook_name = "lookup") return(comparison) } diff --git a/R/process_tests_sds.R b/R/process_tests_sds.R index 7b969ac7a..659436fd0 100644 --- a/R/process_tests_sds.R +++ b/R/process_tests_sds.R @@ -13,7 +13,7 @@ process_tests_sds <- function(data, year) { old_data = produce_source_sds_tests(old_data), new_data = produce_source_sds_tests(data) ) %>% - write_tests_xlsx(sheet_name = "sds", year) + write_tests_xlsx(sheet_name = "sds", year, workbook_name = "extract") return(comparison) } From d1a9651f7f52bd28d31d708e62b071ecf53f66c8 Mon Sep 17 00:00:00 2001 From: Jennit07 Date: Wed, 18 Oct 2023 15:04:22 +0000 Subject: [PATCH 04/13] Style code --- R/write_tests_xlsx.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/write_tests_xlsx.R b/R/write_tests_xlsx.R index fed9fa5d6..f280aa69c 100644 --- a/R/write_tests_xlsx.R +++ b/R/write_tests_xlsx.R @@ -23,11 +23,11 @@ write_tests_xlsx <- function(comparison_data, # Set up the workbook ---- tests_workbook_name <- dplyr::case_when( - workbook_name == "ep_file" ~ stringr::str_glue(latest_update(), "_ep_file_tests"), - workbook_name == "indiv_file" ~ stringr::str_glue(latest_update(), "_indiv_file_tests"), - workbook_name == "lookup" ~ stringr::str_glue(latest_update(), "_lookups_tests"), - workbook_name == "extract" ~ stringr::str_glue(latest_update(), "_{year}_extract_tests") - ) + workbook_name == "ep_file" ~ stringr::str_glue(latest_update(), "_ep_file_tests"), + workbook_name == "indiv_file" ~ stringr::str_glue(latest_update(), "_indiv_file_tests"), + workbook_name == "lookup" ~ stringr::str_glue(latest_update(), "_lookups_tests"), + workbook_name == "extract" ~ stringr::str_glue(latest_update(), "_{year}_extract_tests") + ) tests_workbook_path <- fs::path( From 9311cd9b8da9b907c9163747e227160ce73bcaf6 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Fri, 27 Oct 2023 11:23:54 +0100 Subject: [PATCH 05/13] Fix bug in `get_source_extract_path --- R/get_source_extract_path.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/get_source_extract_path.R b/R/get_source_extract_path.R index 6be47d61a..b4ccf4920 100644 --- a/R/get_source_extract_path.R +++ b/R/get_source_extract_path.R @@ -64,7 +64,7 @@ get_source_extract_path <- function(year, "pis" ~ "prescribing_file_for_source", "sds" ~ "sds-for-source" ) %>% - stringr::str_glue("-{year}.parquet") + stringr::str_glue("-20{year}.parquet") source_extract_path <- get_file_path( directory = get_year_dir(year), From 710338e5b906832ebb52c9fdd9a14fd5939a0df9 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Fri, 27 Oct 2023 11:24:33 +0100 Subject: [PATCH 06/13] Update indiv tests to use `anon_chi` --- R/process_tests_individual_file.R | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/R/process_tests_individual_file.R b/R/process_tests_individual_file.R index d2e5d7a57..bbd13948c 100644 --- a/R/process_tests_individual_file.R +++ b/R/process_tests_individual_file.R @@ -26,10 +26,9 @@ process_tests_individual_file <- function(data, year) { "cases", "consultations" )) - ) %>% - slfhelper::get_chi() + ) - old_data <- get_existing_data_for_tests(data, file_version = "individual") + old_data <- get_existing_data_for_tests(data, file_version = "individual", anon_chi = TRUE) comparison <- produce_test_comparison( old_data = produce_individual_file_tests(old_data), @@ -61,11 +60,19 @@ produce_individual_file_tests <- function(data) { test_flags <- data %>% # use functions to create HB and partnership flags - create_demog_test_flags() %>% + dplyr::mutate( + unique_anon_chi = dplyr::lag(.data$anon_chi) != .data$anon_chi, + n_missing_anon_chi = is_missing(.data$anon_chi), + n_males = .data$gender == 1L, + n_females = .data$gender == 2L, + n_postcode = !is.na(.data$postcode) | !.data$postcode == "", + n_missing_postcode = is_missing(.data$postcode), + missing_dob = is.na(.data$dob) + ) %>% create_hb_test_flags(.data$hbrescode) %>% create_hb_cost_test_flags(.data$hbrescode, .data$health_net_cost) %>% # keep variables for comparison - dplyr::select(c("valid_chi":dplyr::last_col())) %>% + dplyr::select(c("unique_anon_chi":dplyr::last_col())) %>% # use function to sum new test flags calculate_measures(measure = "sum") From 335d93943a0a7076b9fd52c907818f4b9406fda2 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Fri, 27 Oct 2023 11:40:27 +0100 Subject: [PATCH 07/13] Update workbook name for extracts --- R/process_tests_acute.R | 2 +- R/process_tests_ae.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/process_tests_acute.R b/R/process_tests_acute.R index 734e1d0f9..acdac70e9 100644 --- a/R/process_tests_acute.R +++ b/R/process_tests_acute.R @@ -16,7 +16,7 @@ process_tests_acute <- function(data, year) { old_data = produce_source_extract_tests(old_data), new_data = produce_source_extract_tests(data) ) %>% - write_tests_xlsx(sheet_name = "01B", year) + write_tests_xlsx(sheet_name = "01B", year, workbook_name = "extract") return(comparison) } diff --git a/R/process_tests_ae.R b/R/process_tests_ae.R index 579bdeb2e..c1cf95d92 100644 --- a/R/process_tests_ae.R +++ b/R/process_tests_ae.R @@ -19,7 +19,7 @@ process_tests_ae <- function(data, year) { max_min_vars = c("record_keydate1", "record_keydate2", "cost_total_net") ) ) %>% - write_tests_xlsx(sheet_name = "AE2", year) + write_tests_xlsx(sheet_name = "AE2", year, workbook_name = "extract") return(comparison) } From bd35829a765deb819802b617b471c87e188809a2 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Fri, 27 Oct 2023 14:06:54 +0100 Subject: [PATCH 08/13] Fix typo --- R/produce_source_extract_tests.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/produce_source_extract_tests.R b/R/produce_source_extract_tests.R index 7f8feda92..d9a07c893 100644 --- a/R/produce_source_extract_tests.R +++ b/R/produce_source_extract_tests.R @@ -38,7 +38,7 @@ produce_source_extract_tests <- function(data, create_hb_cost_test_flags(.data$hbtreatcode, .data$cost_total_net) if (add_hscp_count) { - test_flags <- create_hscp_test_flags(test_flags, .data$hscp) + test_flags <- create_hscp_test_flags(test_flags, .data$hscp2018) } test_flags <- test_flags %>% From 5ea80ae82558f294b831e637b64b251ec879d8fa Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Fri, 27 Oct 2023 14:16:08 +0100 Subject: [PATCH 09/13] Fix bug in test where hscp named differently --- R/process_tests_acute.R | 7 +++++++ R/process_tests_ae.R | 7 +++++++ R/process_tests_alarms_telecare.R | 7 +++++++ R/process_tests_care_home.R | 7 +++++++ R/process_tests_cmh.R | 7 +++++++ R/process_tests_delayed_discharges.R | 7 +++++++ R/process_tests_district_nursing.R | 7 +++++++ R/process_tests_gp_ooh.R | 7 +++++++ R/process_tests_home_care.R | 7 +++++++ R/process_tests_homelessness.R | 7 +++++++ R/process_tests_maternity.R | 7 +++++++ R/process_tests_mental_health.R | 7 +++++++ R/process_tests_nrs_deaths.R | 7 +++++++ R/process_tests_outpatients.R | 7 +++++++ R/process_tests_prescribing.R | 7 +++++++ R/process_tests_sds.R | 7 +++++++ 16 files changed, 112 insertions(+) diff --git a/R/process_tests_acute.R b/R/process_tests_acute.R index acdac70e9..52895f174 100644 --- a/R/process_tests_acute.R +++ b/R/process_tests_acute.R @@ -12,6 +12,13 @@ process_tests_acute <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data), new_data = produce_source_extract_tests(data) diff --git a/R/process_tests_ae.R b/R/process_tests_ae.R index c1cf95d92..29c75178b 100644 --- a/R/process_tests_ae.R +++ b/R/process_tests_ae.R @@ -9,6 +9,13 @@ process_tests_ae <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data, sum_mean_vars = "cost", diff --git a/R/process_tests_alarms_telecare.R b/R/process_tests_alarms_telecare.R index 12672c169..b80336980 100644 --- a/R/process_tests_alarms_telecare.R +++ b/R/process_tests_alarms_telecare.R @@ -10,6 +10,13 @@ process_tests_alarms_telecare <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_at_tests(old_data), new_data = produce_source_at_tests(data) diff --git a/R/process_tests_care_home.R b/R/process_tests_care_home.R index b28463cb0..ad6bbbdf9 100644 --- a/R/process_tests_care_home.R +++ b/R/process_tests_care_home.R @@ -9,6 +9,13 @@ process_tests_care_home <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_ch_tests(old_data), new_data = produce_source_ch_tests(data) diff --git a/R/process_tests_cmh.R b/R/process_tests_cmh.R index 7921f30c8..6fcc1c86c 100644 --- a/R/process_tests_cmh.R +++ b/R/process_tests_cmh.R @@ -14,6 +14,13 @@ process_tests_cmh <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_cmh_tests(old_data), new_data = produce_source_cmh_tests(data) diff --git a/R/process_tests_delayed_discharges.R b/R/process_tests_delayed_discharges.R index 9061018ec..9dbe7efae 100644 --- a/R/process_tests_delayed_discharges.R +++ b/R/process_tests_delayed_discharges.R @@ -12,6 +12,13 @@ process_tests_delayed_discharges <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_dd_tests(old_data), new_data = produce_source_dd_tests(data) diff --git a/R/process_tests_district_nursing.R b/R/process_tests_district_nursing.R index b6fe117ec..a9778ad87 100644 --- a/R/process_tests_district_nursing.R +++ b/R/process_tests_district_nursing.R @@ -21,6 +21,13 @@ process_tests_district_nursing <- function(data, year) { ~ tidyr::replace_na(.x, 0.0) )) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_dn_tests(old_data), new_data = produce_source_dn_tests(data) diff --git a/R/process_tests_gp_ooh.R b/R/process_tests_gp_ooh.R index 86c83d64a..cdfac969d 100644 --- a/R/process_tests_gp_ooh.R +++ b/R/process_tests_gp_ooh.R @@ -9,6 +9,13 @@ process_tests_gp_ooh <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data, sum_mean_vars = "cost" diff --git a/R/process_tests_home_care.R b/R/process_tests_home_care.R index 6c797df88..85d1884b9 100644 --- a/R/process_tests_home_care.R +++ b/R/process_tests_home_care.R @@ -9,6 +9,13 @@ process_tests_home_care <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_hc_tests(old_data), new_data = produce_source_hc_tests(data) diff --git a/R/process_tests_homelessness.R b/R/process_tests_homelessness.R index d6b748f47..5309ccb04 100644 --- a/R/process_tests_homelessness.R +++ b/R/process_tests_homelessness.R @@ -10,6 +10,13 @@ process_tests_homelessness <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_slf_homelessness_tests(old_data), new_data = produce_slf_homelessness_tests(data) diff --git a/R/process_tests_maternity.R b/R/process_tests_maternity.R index 2629ead5b..94fafe2d2 100644 --- a/R/process_tests_maternity.R +++ b/R/process_tests_maternity.R @@ -9,6 +9,13 @@ process_tests_maternity <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data), new_data = produce_source_extract_tests(data) diff --git a/R/process_tests_mental_health.R b/R/process_tests_mental_health.R index 520757dca..7b9435437 100644 --- a/R/process_tests_mental_health.R +++ b/R/process_tests_mental_health.R @@ -9,6 +9,13 @@ process_tests_mental_health <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data), new_data = produce_source_extract_tests(data) diff --git a/R/process_tests_nrs_deaths.R b/R/process_tests_nrs_deaths.R index 851cf7667..c749410b7 100644 --- a/R/process_tests_nrs_deaths.R +++ b/R/process_tests_nrs_deaths.R @@ -9,6 +9,13 @@ process_tests_nrs_deaths <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_nrs_tests(old_data), new_data = produce_source_nrs_tests(data) diff --git a/R/process_tests_outpatients.R b/R/process_tests_outpatients.R index 2ce36172d..f4d44b74b 100644 --- a/R/process_tests_outpatients.R +++ b/R/process_tests_outpatients.R @@ -9,6 +9,13 @@ process_tests_outpatients <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data, sum_mean_vars = "cost", diff --git a/R/process_tests_prescribing.R b/R/process_tests_prescribing.R index 78007499c..52cbfaeaf 100644 --- a/R/process_tests_prescribing.R +++ b/R/process_tests_prescribing.R @@ -9,6 +9,13 @@ process_tests_prescribing <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_pis_tests(old_data), new_data = produce_source_pis_tests(data) diff --git a/R/process_tests_sds.R b/R/process_tests_sds.R index 659436fd0..d50eee3a4 100644 --- a/R/process_tests_sds.R +++ b/R/process_tests_sds.R @@ -9,6 +9,13 @@ process_tests_sds <- function(data, year) { old_data <- get_existing_data_for_tests(data) + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename('hscp2018' = 'hscp') + }else{ + data <- data + } + comparison <- produce_test_comparison( old_data = produce_source_sds_tests(old_data), new_data = produce_source_sds_tests(data) From 756768b4c2f138f117b1ba981f04db7b1a32473b Mon Sep 17 00:00:00 2001 From: Jennit07 Date: Fri, 27 Oct 2023 13:23:24 +0000 Subject: [PATCH 10/13] Style code --- R/process_tests_acute.R | 4 ++-- R/process_tests_ae.R | 4 ++-- R/process_tests_alarms_telecare.R | 4 ++-- R/process_tests_care_home.R | 4 ++-- R/process_tests_cmh.R | 4 ++-- R/process_tests_delayed_discharges.R | 4 ++-- R/process_tests_district_nursing.R | 4 ++-- R/process_tests_gp_ooh.R | 4 ++-- R/process_tests_home_care.R | 4 ++-- R/process_tests_homelessness.R | 4 ++-- R/process_tests_maternity.R | 4 ++-- R/process_tests_mental_health.R | 4 ++-- R/process_tests_nrs_deaths.R | 4 ++-- R/process_tests_outpatients.R | 4 ++-- R/process_tests_prescribing.R | 4 ++-- R/process_tests_sds.R | 4 ++-- 16 files changed, 32 insertions(+), 32 deletions(-) diff --git a/R/process_tests_acute.R b/R/process_tests_acute.R index 52895f174..1a4bcb2bc 100644 --- a/R/process_tests_acute.R +++ b/R/process_tests_acute.R @@ -14,8 +14,8 @@ process_tests_acute <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_ae.R b/R/process_tests_ae.R index 29c75178b..037278592 100644 --- a/R/process_tests_ae.R +++ b/R/process_tests_ae.R @@ -11,8 +11,8 @@ process_tests_ae <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_alarms_telecare.R b/R/process_tests_alarms_telecare.R index b80336980..0b7bd80eb 100644 --- a/R/process_tests_alarms_telecare.R +++ b/R/process_tests_alarms_telecare.R @@ -12,8 +12,8 @@ process_tests_alarms_telecare <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_care_home.R b/R/process_tests_care_home.R index ad6bbbdf9..48067f064 100644 --- a/R/process_tests_care_home.R +++ b/R/process_tests_care_home.R @@ -11,8 +11,8 @@ process_tests_care_home <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_cmh.R b/R/process_tests_cmh.R index 6fcc1c86c..8aa290314 100644 --- a/R/process_tests_cmh.R +++ b/R/process_tests_cmh.R @@ -16,8 +16,8 @@ process_tests_cmh <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_delayed_discharges.R b/R/process_tests_delayed_discharges.R index 9dbe7efae..eebb8398d 100644 --- a/R/process_tests_delayed_discharges.R +++ b/R/process_tests_delayed_discharges.R @@ -14,8 +14,8 @@ process_tests_delayed_discharges <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_district_nursing.R b/R/process_tests_district_nursing.R index a9778ad87..912707787 100644 --- a/R/process_tests_district_nursing.R +++ b/R/process_tests_district_nursing.R @@ -23,8 +23,8 @@ process_tests_district_nursing <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_gp_ooh.R b/R/process_tests_gp_ooh.R index cdfac969d..f87dc44d5 100644 --- a/R/process_tests_gp_ooh.R +++ b/R/process_tests_gp_ooh.R @@ -11,8 +11,8 @@ process_tests_gp_ooh <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_home_care.R b/R/process_tests_home_care.R index 85d1884b9..75ff962e6 100644 --- a/R/process_tests_home_care.R +++ b/R/process_tests_home_care.R @@ -11,8 +11,8 @@ process_tests_home_care <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_homelessness.R b/R/process_tests_homelessness.R index 5309ccb04..7a55f4d73 100644 --- a/R/process_tests_homelessness.R +++ b/R/process_tests_homelessness.R @@ -12,8 +12,8 @@ process_tests_homelessness <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_maternity.R b/R/process_tests_maternity.R index 94fafe2d2..982aeb327 100644 --- a/R/process_tests_maternity.R +++ b/R/process_tests_maternity.R @@ -11,8 +11,8 @@ process_tests_maternity <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_mental_health.R b/R/process_tests_mental_health.R index 7b9435437..ad6baf5ce 100644 --- a/R/process_tests_mental_health.R +++ b/R/process_tests_mental_health.R @@ -11,8 +11,8 @@ process_tests_mental_health <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_nrs_deaths.R b/R/process_tests_nrs_deaths.R index c749410b7..6c9e9a061 100644 --- a/R/process_tests_nrs_deaths.R +++ b/R/process_tests_nrs_deaths.R @@ -11,8 +11,8 @@ process_tests_nrs_deaths <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_outpatients.R b/R/process_tests_outpatients.R index f4d44b74b..b2985882d 100644 --- a/R/process_tests_outpatients.R +++ b/R/process_tests_outpatients.R @@ -11,8 +11,8 @@ process_tests_outpatients <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_prescribing.R b/R/process_tests_prescribing.R index 52cbfaeaf..c52618e55 100644 --- a/R/process_tests_prescribing.R +++ b/R/process_tests_prescribing.R @@ -11,8 +11,8 @@ process_tests_prescribing <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } diff --git a/R/process_tests_sds.R b/R/process_tests_sds.R index d50eee3a4..6a12c90e2 100644 --- a/R/process_tests_sds.R +++ b/R/process_tests_sds.R @@ -11,8 +11,8 @@ process_tests_sds <- function(data, year) { if ("hscp" %in% names(data)) { data <- data %>% - dplyr::rename('hscp2018' = 'hscp') - }else{ + dplyr::rename("hscp2018" = "hscp") + } else { data <- data } From 25164923fbe11f828325011802d0fcb03e0547b6 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Mon, 20 Nov 2023 14:20:29 +0000 Subject: [PATCH 11/13] Put `rename_hscp` into a function --- NAMESPACE | 1 + R/rename_hscp.R | 17 +++++++++++++++++ man/rename_hscp.Rd | 17 +++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 R/rename_hscp.R create mode 100644 man/rename_hscp.Rd diff --git a/NAMESPACE b/NAMESPACE index df103f591..43233a564 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -166,6 +166,7 @@ export(read_sc_all_alarms_telecare) export(read_sc_all_care_home) export(read_sc_all_home_care) export(read_sc_all_sds) +export(rename_hscp) export(setup_keyring) export(start_fy) export(start_fy_quarter) diff --git a/R/rename_hscp.R b/R/rename_hscp.R new file mode 100644 index 000000000..1954f7a3d --- /dev/null +++ b/R/rename_hscp.R @@ -0,0 +1,17 @@ +#' Rename hscp where applicable for testing +#' +#' @param data processed data for testing e.g. acute +#' +#' @return data with correct hscp naming. +#' @export +#' +rename_hscp <- function (data) { + +if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename("hscp2018" = "hscp") +} else { + data <- data +} + +} diff --git a/man/rename_hscp.Rd b/man/rename_hscp.Rd new file mode 100644 index 000000000..035041bf8 --- /dev/null +++ b/man/rename_hscp.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rename_hscp.R +\name{rename_hscp} +\alias{rename_hscp} +\title{Rename hscp where applicable for testing} +\usage{ +rename_hscp(data) +} +\arguments{ +\item{data}{processed data for testing e.g. acute} +} +\value{ +data with correct hscp naming. +} +\description{ +Rename hscp where applicable for testing +} From 6bd69dec168b743a067220b2487412ce2f15feea Mon Sep 17 00:00:00 2001 From: Jennit07 Date: Mon, 20 Nov 2023 14:22:09 +0000 Subject: [PATCH 12/13] Style code --- R/rename_hscp.R | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/R/rename_hscp.R b/R/rename_hscp.R index 1954f7a3d..caa5da761 100644 --- a/R/rename_hscp.R +++ b/R/rename_hscp.R @@ -5,13 +5,11 @@ #' @return data with correct hscp naming. #' @export #' -rename_hscp <- function (data) { - -if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") -} else { - data <- data -} - +rename_hscp <- function(data) { + if ("hscp" %in% names(data)) { + data <- data %>% + dplyr::rename("hscp2018" = "hscp") + } else { + data <- data + } } From 24939d6ea35938214efb14e73f1b9ffe01b3cca7 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Mon, 20 Nov 2023 14:30:09 +0000 Subject: [PATCH 13/13] Use `rename_hscp` function --- R/process_tests_acute.R | 7 +------ R/process_tests_ae.R | 7 +------ R/process_tests_alarms_telecare.R | 7 +------ R/process_tests_care_home.R | 7 +------ R/process_tests_cmh.R | 7 +------ R/process_tests_delayed_discharges.R | 7 +------ R/process_tests_district_nursing.R | 7 +------ R/process_tests_gp_ooh.R | 7 +------ R/process_tests_home_care.R | 7 +------ R/process_tests_homelessness.R | 7 +------ R/process_tests_maternity.R | 7 +------ R/process_tests_mental_health.R | 7 +------ R/process_tests_nrs_deaths.R | 7 +------ R/process_tests_outpatients.R | 7 +------ R/process_tests_prescribing.R | 7 +------ R/process_tests_sds.R | 7 +------ 16 files changed, 16 insertions(+), 96 deletions(-) diff --git a/R/process_tests_acute.R b/R/process_tests_acute.R index 1a4bcb2bc..759d866b7 100644 --- a/R/process_tests_acute.R +++ b/R/process_tests_acute.R @@ -12,12 +12,7 @@ process_tests_acute <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data), diff --git a/R/process_tests_ae.R b/R/process_tests_ae.R index 037278592..5bcd6a3c9 100644 --- a/R/process_tests_ae.R +++ b/R/process_tests_ae.R @@ -9,12 +9,7 @@ process_tests_ae <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data, diff --git a/R/process_tests_alarms_telecare.R b/R/process_tests_alarms_telecare.R index 0b7bd80eb..d7f9fa699 100644 --- a/R/process_tests_alarms_telecare.R +++ b/R/process_tests_alarms_telecare.R @@ -10,12 +10,7 @@ process_tests_alarms_telecare <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_at_tests(old_data), diff --git a/R/process_tests_care_home.R b/R/process_tests_care_home.R index 48067f064..2032c2473 100644 --- a/R/process_tests_care_home.R +++ b/R/process_tests_care_home.R @@ -9,12 +9,7 @@ process_tests_care_home <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_ch_tests(old_data), diff --git a/R/process_tests_cmh.R b/R/process_tests_cmh.R index 8aa290314..09a17bdbb 100644 --- a/R/process_tests_cmh.R +++ b/R/process_tests_cmh.R @@ -14,12 +14,7 @@ process_tests_cmh <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_cmh_tests(old_data), diff --git a/R/process_tests_delayed_discharges.R b/R/process_tests_delayed_discharges.R index eebb8398d..c2370eb76 100644 --- a/R/process_tests_delayed_discharges.R +++ b/R/process_tests_delayed_discharges.R @@ -12,12 +12,7 @@ process_tests_delayed_discharges <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_dd_tests(old_data), diff --git a/R/process_tests_district_nursing.R b/R/process_tests_district_nursing.R index 912707787..d3d55a15a 100644 --- a/R/process_tests_district_nursing.R +++ b/R/process_tests_district_nursing.R @@ -21,12 +21,7 @@ process_tests_district_nursing <- function(data, year) { ~ tidyr::replace_na(.x, 0.0) )) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_dn_tests(old_data), diff --git a/R/process_tests_gp_ooh.R b/R/process_tests_gp_ooh.R index f87dc44d5..fd3ec5f59 100644 --- a/R/process_tests_gp_ooh.R +++ b/R/process_tests_gp_ooh.R @@ -9,12 +9,7 @@ process_tests_gp_ooh <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data, diff --git a/R/process_tests_home_care.R b/R/process_tests_home_care.R index 75ff962e6..c1af63e97 100644 --- a/R/process_tests_home_care.R +++ b/R/process_tests_home_care.R @@ -9,12 +9,7 @@ process_tests_home_care <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_hc_tests(old_data), diff --git a/R/process_tests_homelessness.R b/R/process_tests_homelessness.R index 7a55f4d73..4d49f1aa4 100644 --- a/R/process_tests_homelessness.R +++ b/R/process_tests_homelessness.R @@ -10,12 +10,7 @@ process_tests_homelessness <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_slf_homelessness_tests(old_data), diff --git a/R/process_tests_maternity.R b/R/process_tests_maternity.R index 982aeb327..90f0ec449 100644 --- a/R/process_tests_maternity.R +++ b/R/process_tests_maternity.R @@ -9,12 +9,7 @@ process_tests_maternity <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data), diff --git a/R/process_tests_mental_health.R b/R/process_tests_mental_health.R index ad6baf5ce..96283d47b 100644 --- a/R/process_tests_mental_health.R +++ b/R/process_tests_mental_health.R @@ -9,12 +9,7 @@ process_tests_mental_health <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data), diff --git a/R/process_tests_nrs_deaths.R b/R/process_tests_nrs_deaths.R index 6c9e9a061..c1a963dcf 100644 --- a/R/process_tests_nrs_deaths.R +++ b/R/process_tests_nrs_deaths.R @@ -9,12 +9,7 @@ process_tests_nrs_deaths <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_nrs_tests(old_data), diff --git a/R/process_tests_outpatients.R b/R/process_tests_outpatients.R index b2985882d..5787e6884 100644 --- a/R/process_tests_outpatients.R +++ b/R/process_tests_outpatients.R @@ -9,12 +9,7 @@ process_tests_outpatients <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_extract_tests(old_data, diff --git a/R/process_tests_prescribing.R b/R/process_tests_prescribing.R index c52618e55..bac0e3c52 100644 --- a/R/process_tests_prescribing.R +++ b/R/process_tests_prescribing.R @@ -9,12 +9,7 @@ process_tests_prescribing <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_pis_tests(old_data), diff --git a/R/process_tests_sds.R b/R/process_tests_sds.R index 6a12c90e2..f624f504b 100644 --- a/R/process_tests_sds.R +++ b/R/process_tests_sds.R @@ -9,12 +9,7 @@ process_tests_sds <- function(data, year) { old_data <- get_existing_data_for_tests(data) - if ("hscp" %in% names(data)) { - data <- data %>% - dplyr::rename("hscp2018" = "hscp") - } else { - data <- data - } + data <- rename_hscp(data) comparison <- produce_test_comparison( old_data = produce_source_sds_tests(old_data),