diff --git a/R/process_tests_episode_file.R b/R/process_tests_episode_file.R index b595d1d54..46e9e7171 100644 --- a/R/process_tests_episode_file.R +++ b/R/process_tests_episode_file.R @@ -10,7 +10,7 @@ process_tests_episode_file <- function(data, year) { data <- data %>% dplyr::select( "year", - "chi", + "anon_chi", "gender", "postcode", "hbtreatcode", @@ -20,7 +20,8 @@ process_tests_episode_file <- function(data, year) { "record_keydate1", "record_keydate2", dplyr::contains(c("beddays", "cost", "cij")) - ) + ) %>% + slfhelper::get_chi() old_data <- get_existing_data_for_tests(data) diff --git a/R/run_episode_file.R b/R/run_episode_file.R index 45a4e6ed5..1f2bb33ed 100644 --- a/R/run_episode_file.R +++ b/R/run_episode_file.R @@ -4,11 +4,17 @@ #' @param year The year to process, in FY format. #' @param write_to_disk (optional) Should the data be written to disk default is #' `TRUE` i.e. write the data to disk. +#' @param anon_chi_out (Default:TRUE) Should `anon_chi` be used in the output +#' (instead of chi) #' #' @return a [tibble][tibble::tibble-package] containing the episode file #' @export #' -run_episode_file <- function(processed_data_list, year, write_to_disk = TRUE) { +run_episode_file <- function( + processed_data_list, + year, + write_to_disk = TRUE, + anon_chi_out = TRUE) { episode_file <- dplyr::bind_rows(processed_data_list) %>% create_cost_inc_dna() %>% apply_cost_uplift() %>% @@ -103,6 +109,14 @@ run_episode_file <- function(processed_data_list, year, write_to_disk = TRUE) { join_deaths_data(year) %>% load_ep_file_vars(year) + if (anon_chi_out) { + episode_file <- slfhelper::get_anon_chi( + episode_file, + chi_var = "chi", + drop = TRUE + ) + } + if (write_to_disk) { slf_path <- get_file_path( get_year_dir(year), diff --git a/man/run_episode_file.Rd b/man/run_episode_file.Rd index e85621b59..59d5fea1d 100644 --- a/man/run_episode_file.Rd +++ b/man/run_episode_file.Rd @@ -4,7 +4,12 @@ \alias{run_episode_file} \title{Produce the Source Episode file} \usage{ -run_episode_file(processed_data_list, year, write_to_disk = TRUE) +run_episode_file( + processed_data_list, + year, + write_to_disk = TRUE, + anon_chi_out = TRUE +) } \arguments{ \item{processed_data_list}{containing data from processed extracts.} @@ -13,6 +18,9 @@ run_episode_file(processed_data_list, year, write_to_disk = TRUE) \item{write_to_disk}{(optional) Should the data be written to disk default is \code{TRUE} i.e. write the data to disk.} + +\item{anon_chi_out}{(Default:TRUE) Should \code{anon_chi} be used in the output +(instead of chi)} } \value{ a \link[tibble:tibble-package]{tibble} containing the episode file