diff --git a/R/create_episode_file.R b/R/create_episode_file.R index 28ab574e6..5a5ae0fd8 100644 --- a/R/create_episode_file.R +++ b/R/create_episode_file.R @@ -39,7 +39,7 @@ create_episode_file <- function( episode_file <- dplyr::bind_rows(processed_data_list) %>% slfhelper::get_chi() %>% - write_temp_data(data, year, file_name = "ep_temp1", test_mode) %>% + write_temp_data(year, file_name = "ep_temp1", test_mode) %>% create_cost_inc_dna() %>% apply_cost_uplift() %>% @@ -124,18 +124,18 @@ create_episode_file <- function( # PC8 format may still be used. Ensure here that all datasets are in PC7 format. postcode = phsmethods::format_postcode(.data$postcode, "pc7") ) %>% - write_temp_data(data, year, file_name = "ep_temp2", test_mode) %>% + write_temp_data(year, file_name = "ep_temp2", test_mode) %>% correct_cij_vars() %>% fill_missing_cij_markers() %>% add_homelessness_flag(year, lookup = homelessness_lookup) %>% add_homelessness_date_flags(year, lookup = homelessness_lookup) %>% add_ppa_flag() %>% - write_temp_data(data, year, file_name = "ep_temp3", test_mode) %>% + write_temp_data(year, file_name = "ep_temp3", test_mode) %>% link_delayed_discharge_eps(year, dd_data) %>% add_nsu_cohort(year, nsu_cohort) %>% match_on_ltcs(year, ltc_data) %>% correct_demographics(year) %>% - write_temp_data(data, year, file_name = "ep_temp4", test_mode) %>% + write_temp_data(year, file_name = "ep_temp4", test_mode) %>% create_cohort_lookups(year) %>% join_cohort_lookups(year) %>% join_sparra_hhg(year) %>% @@ -147,13 +147,13 @@ create_episode_file <- function( year, slf_deaths_lookup ) %>% - write_temp_data(data, year, file_name = "ep_temp5", test_mode) %>% + write_temp_data(year, file_name = "ep_temp5", test_mode) %>% add_activity_after_death_flag(year, deaths_data = read_file(get_combined_slf_deaths_lookup_path()) %>% slfhelper::get_chi() ) %>% load_ep_file_vars(year) %>% - write_temp_data(data, year, file_name = "ep_temp6", test_mode) + write_temp_data(year, file_name = "ep_temp6", test_mode) if (!check_year_valid(year, type = c("ch", "hc", "at", "sds"))) { episode_file <- episode_file %>% diff --git a/R/write_temp_data.R b/R/write_temp_data.R index b8c834c44..a0fb0652d 100644 --- a/R/write_temp_data.R +++ b/R/write_temp_data.R @@ -23,6 +23,15 @@ write_temp_data <- return(data) } +read_temp_data <- function(year, file_name, test_mode){ + full_file_name <- stringr::str_glue("{file_name}.parquet") + file_path <- file.path(get_year_dir(year), + full_file_name) %>% + add_test_to_filename(test_mode) + + return(read_file(file_path)) +} + #' Add "TEST-" to the file name of a file Path #'