diff --git a/NAMESPACE b/NAMESPACE index b5436d21e..58345b660 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -61,7 +61,9 @@ export(get_slf_ch_name_lookup_path) export(get_slf_chi_deaths_path) export(get_slf_deaths_lookup_path) export(get_slf_dir) +export(get_slf_episode_path) export(get_slf_gpprac_path) +export(get_slf_individual_path) export(get_slf_postcode_path) export(get_source_extract_path) export(get_sparra_path) diff --git a/R/create_episode_file.R b/R/create_episode_file.R index fad4d4584..12e8a1d7e 100644 --- a/R/create_episode_file.R +++ b/R/create_episode_file.R @@ -137,14 +137,8 @@ create_episode_file <- function( } if (write_to_disk) { - # TODO make the slf_path a function - slf_episode_path <- get_file_path( - get_year_dir(year), - stringr::str_glue( - "source-episode-file-{year}.parquet" - ), - check_mode = "write" - ) + slf_episode_path <- get_slf_episode_path(year, check_mode = "write") + write_file(episode_file, slf_episode_path) } @@ -159,6 +153,7 @@ create_episode_file <- function( #' @param vars_to_keep a character vector of the variables to keep, all others #' will be stored. #' + #' @family episode_file #' @return `data` with only the `vars_to_keep` kept store_ep_file_vars <- function(data, year, vars_to_keep) { @@ -197,7 +192,9 @@ store_ep_file_vars <- function(data, year, vars_to_keep) { #' @inheritParams create_episode_file #' @inheritParams store_ep_file_vars #' + #' @family episode_file + #' @return The full SLF data. load_ep_file_vars <- function(data, year) { tempfile_path <- get_file_path( @@ -225,7 +222,9 @@ load_ep_file_vars <- function(data, year) { #' #' @inheritParams store_ep_file_vars #' + #' @family episode_file + #' @return A data frame with CIJ markers filled in for those missing. fill_missing_cij_markers <- function(data) { fixable_data <- data %>% @@ -280,7 +279,9 @@ fill_missing_cij_markers <- function(data) { #' #' @inheritParams store_ep_file_vars #' + #' @family episode_file + #' @return The data with CIJ variables corrected. correct_cij_vars <- function(data) { check_variables_exist( @@ -322,7 +323,9 @@ correct_cij_vars <- function(data) { #' #' @inheritParams store_ep_file_vars #' + #' @family episode_file + #' @return The data with cost including dna. create_cost_inc_dna <- function(data) { check_variables_exist(data, c("cost_total_net", "attendance_status")) @@ -347,6 +350,7 @@ create_cost_inc_dna <- function(data) { #' @inheritParams store_ep_file_vars #' @inheritParams create_demographic_cohorts #' + #' @family episode_file #' @return The data unchanged (the cohorts are written to disk) create_cohort_lookups <- function(data, year, update = latest_update()) { @@ -382,6 +386,7 @@ create_cohort_lookups <- function(data, year, update = latest_update()) { #' #' @inheritParams store_ep_file_vars #' @inheritParams get_demographic_cohorts_path + #' @param demographic_cohort,service_use_cohort The cohort data #' #' @family episode_file diff --git a/R/create_individual_file.R b/R/create_individual_file.R index d4b29eadd..e6ac8d1d1 100644 --- a/R/create_individual_file.R +++ b/R/create_individual_file.R @@ -83,13 +83,7 @@ create_individual_file <- function( } if (write_to_disk) { - slf_indiv_path <- get_file_path( - get_year_dir(year), - stringr::str_glue( - "source-individual-file-{year}.parquet" - ), - check_mode = "write" - ) + slf_indiv_path <- get_slf_individual_path(year, check_mode = "write") write_file(individual_file, slf_indiv_path) } diff --git a/R/get_final_file_paths.R b/R/get_final_file_paths.R new file mode 100644 index 000000000..f47250621 --- /dev/null +++ b/R/get_final_file_paths.R @@ -0,0 +1,34 @@ +#' Get the slf episode file path +#' +#' @param year Financial year +#' @param ... additional arguments passed to [get_file_path()] +#' +#' @return Path to the final episode file. +#' @export +#' +get_slf_episode_path <- function(year, ...) { + slf_episode_path <- get_file_path( + directory = get_year_dir(year), + file_name = stringr::str_glue("source-episode-file-{year}.parquet"), + ... + ) + + return(slf_episode_path) +} + +#' Get the SLF individual file path +#' +#' @param year Financial year +#' @param ... additional arguments passed to [get_file_path()] +#' +#' @return Path to the final individual file +#' @export +#' +get_slf_individual_path <- function(year, ...) { + slf_indiv_path <- get_file_path( + directory = get_year_dir(year), + file_name = stringr::str_glue("source-individual-file-{year}.parquet"), + ... + ) + return(slf_indiv_path) +} diff --git a/man/get_slf_episode_path.Rd b/man/get_slf_episode_path.Rd new file mode 100644 index 000000000..064e47fbb --- /dev/null +++ b/man/get_slf_episode_path.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_final_file_paths.R +\name{get_slf_episode_path} +\alias{get_slf_episode_path} +\title{Get the slf episode file path} +\usage{ +get_slf_episode_path(year, ...) +} +\arguments{ +\item{year}{Financial year} + +\item{...}{additional arguments passed to \code{\link[=get_file_path]{get_file_path()}}} +} +\value{ +Path to the final episode file. +} +\description{ +Get the slf episode file path +} diff --git a/man/get_slf_individual_path.Rd b/man/get_slf_individual_path.Rd new file mode 100644 index 000000000..9b72c6d89 --- /dev/null +++ b/man/get_slf_individual_path.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_final_file_paths.R +\name{get_slf_individual_path} +\alias{get_slf_individual_path} +\title{Get the SLF individual file path} +\usage{ +get_slf_individual_path(year, ...) +} +\arguments{ +\item{year}{Financial year} + +\item{...}{additional arguments passed to \code{\link[=get_file_path]{get_file_path()}}} +} +\value{ +Path to the final individual file +} +\description{ +Get the SLF individual file path +}