Skip to content

Commit

Permalink
Make episode file output with anon_chi (#747)
Browse files Browse the repository at this point in the history
I've added this as a parameter so you can output CHI if desired, but the default is for anon_chi.

For the tests, it swaps back to CHI as there are some tests which specifically us the CHI number.

Co-authored-by: Jennit07 <[email protected]>
  • Loading branch information
Moohan and Jennit07 authored Jul 18, 2023
1 parent 3b2c54d commit d09efcd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
5 changes: 3 additions & 2 deletions R/process_tests_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ process_tests_episode_file <- function(data, year) {
data <- data %>%
dplyr::select(
"year",
"chi",
"anon_chi",
"gender",
"postcode",
"hbtreatcode",
Expand All @@ -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)

Expand Down
16 changes: 15 additions & 1 deletion R/run_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() %>%
Expand Down Expand Up @@ -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),
Expand Down
10 changes: 9 additions & 1 deletion man/run_episode_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d09efcd

Please sign in to comment.