Skip to content

Commit

Permalink
add read_temp_data
Browse files Browse the repository at this point in the history
  • Loading branch information
lizihao-anu committed Oct 7, 2024
1 parent 5ed8c98 commit e6b0fd3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 6 additions & 6 deletions R/create_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() %>%
Expand Down Expand Up @@ -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) %>%
Expand All @@ -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 %>%
Expand Down
9 changes: 9 additions & 0 deletions R/write_temp_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down

0 comments on commit e6b0fd3

Please sign in to comment.