Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export(get_gpprac_opendata)
export(get_gpprac_ref_path)
export(get_hc_costs_path)
export(get_hc_raw_costs_path)
export(get_hhg_data)
export(get_hhg_path)
export(get_homelessness_completeness_path)
export(get_it_deaths_path)
Expand Down
6 changes: 4 additions & 2 deletions R/create_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @param write_to_disk (optional) Should the data be written to disk default is
#' `TRUE` i.e. write the data to disk.
#' @param write_temp_to_disk write intermediate data for investigation or debug
#' @param BYOC_MODE BYOC mode
#' @inheritParams add_nsu_cohort
#' @inheritParams fill_geographies
#' @inheritParams join_cohort_lookups
Expand All @@ -30,20 +31,21 @@
),
sc_client = read_file(get_sc_client_lookup_path(year)),
write_to_disk = TRUE,
write_temp_to_disk = FALSE
write_temp_to_disk = FALSE,
BYOC_MODE

Check warning on line 35 in R/create_episode_file.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create_episode_file.R,line=35,col=3,[object_name_linter] Variable and function name style should match snake_case or symbols.
) {
log_ep_substage("Create episode file", "started", year)

processed_data_list <- purrr::discard(processed_data_list, ~ is.null(.x) | identical(.x, tibble::tibble()))

Check warning on line 39 in R/create_episode_file.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create_episode_file.R,line=39,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 109 characters.

episode_file <- dplyr::bind_rows(processed_data_list) %>%

Check warning on line 41 in R/create_episode_file.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create_episode_file.R,line=41,col=57,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
write_temp_data(year, file_name = "ep_temp1", write_temp_to_disk) %>%

Check warning on line 42 in R/create_episode_file.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create_episode_file.R,line=42,col=71,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
add_homelessness_flag(year, lookup = homelessness_lookup) %>%

Check warning on line 43 in R/create_episode_file.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create_episode_file.R,line=43,col=63,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
add_homelessness_date_flags(year, lookup = homelessness_lookup) %>%

Check warning on line 44 in R/create_episode_file.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create_episode_file.R,line=44,col=69,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
link_delayed_discharge_eps(year, dd_data) %>%

Check warning on line 45 in R/create_episode_file.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create_episode_file.R,line=45,col=47,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
write_temp_data(year, file_name = "ep_temp1-2", write_temp_to_disk) %>%

Check warning on line 46 in R/create_episode_file.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create_episode_file.R,line=46,col=73,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
add_nsu_cohort(year, nsu_cohort) %>%

Check warning on line 47 in R/create_episode_file.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create_episode_file.R,line=47,col=38,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
create_cost_inc_dna() %>%

Check warning on line 48 in R/create_episode_file.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create_episode_file.R,line=48,col=27,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
apply_cost_uplift()

if (!check_year_valid(year, type = c("ch", "hc", "at", "sds"))) {
Expand Down Expand Up @@ -160,7 +162,7 @@
write_temp_data(year, file_name = "ep_temp4", write_temp_to_disk) %>%
create_cohort_lookups(year) %>%
join_cohort_lookups(year) %>%
join_sparra_hhg(year) %>%
join_sparra_hhg(year, BYOC_MODE = BYOC_MODE) %>%
fill_geographies(
slf_pc_lookup,
slf_gpprac_lookup
Expand Down
6 changes: 4 additions & 2 deletions R/create_individual_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @param episode_file Tibble containing episodic data.
#' @param homelessness_lookup the lookup file for homelessness
#' @param write_temp_to_disk write intermediate data for investigation or debug
#' @param BYOC_MODE BYOC mode
#' @inheritParams create_episode_file
#'
#' @return The processed individual file
Expand All @@ -15,7 +16,8 @@ create_individual_file <- function(
year,
homelessness_lookup = create_homelessness_lookup(year),
write_to_disk = TRUE,
write_temp_to_disk
write_temp_to_disk,
BYOC_MODE
) {
log_ind_substage("Create individual file", "started", year)

Expand Down Expand Up @@ -89,7 +91,7 @@ create_individual_file <- function(
add_homelessness_flag(year, lookup = homelessness_lookup) %>%
match_on_ltcs(year) %>%
join_deaths_data(year) %>%
join_sparra_hhg(year) %>%
join_sparra_hhg(year, BYOC_MODE = BYOC_MODE) %>%
write_temp_data(year, file_name = "indiv_temp4", write_temp_to_disk) %>%
join_slf_lookup_vars() %>%
dplyr::mutate(year = year) %>%
Expand Down
35 changes: 35 additions & 0 deletions R/get_sparra_hhg_paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,41 @@ get_hhg_path <- function(year, ...) {
return(hhg_file_path)
}


#' HHG Extract File data
#'
#' @description Get the path to the HHG extract
#'
#' @param year Year of extract
#' @param denodo_connect connection to denodo
#' @param BYOC_MODE BYOC MODE
#'
#' @return The path to the HHG extract as an [fs::path()]
#' @export
#' @family extract file paths
#' @seealso [get_file_path()] for the generic function.
get_hhg_data <- function(year,
denodo_connect = get_denodo_connection(BYOC_MODE = BYOC_MODE),
BYOC_MODE) {
year <- check_year_format(year, format = "fyyear")
c_year <- convert_fyyear_to_year(year)

on.exit(try(DBI::dbDisconnect(denodo_connect), silent = TRUE), add = TRUE)

if (isTRUE(BYOC_MODE)) {
extract_hhg <- dplyr::tbl(
denodo_connect,
dbplyr::in_schema("sdl", "sdl_hhg_source") ### TODO: confirm table name ###
) %>%
dplyr::filter(risk_financial_year == c_year) %>% ### TODO: confirm filter ###
dplyr::collect()
} else {
extract_hhg <- read_file(get_hhg_path(year))
}
return(extract_hhg)
}


#' SPARRA Extract File Path
#'
#' @description Get the path to the SPARRA extract
Expand Down
8 changes: 5 additions & 3 deletions R/join_sparra_hhg.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#'
#' @return The data including the SPARRA and HHG variables matched
#' on to the episode file.
join_sparra_hhg <- function(data, year) {
join_sparra_hhg <- function(data,
year,
BYOC_MODE = BYOC_MODE) {
if (check_year_valid(year, "sparra")) {
data <- dplyr::left_join(
data,
Expand Down Expand Up @@ -34,7 +36,7 @@ join_sparra_hhg <- function(data, year) {
if (check_year_valid(year, "hhg")) {
data <- dplyr::left_join(
data,
read_file(get_hhg_path(year)) %>%
get_hhg_data(year, BYOC_MODE = BYOC_MODE) %>%
dplyr::rename(hhg_start_fy = "hhg_score"),
by = c("anon_chi"),
na_matches = "never",
Expand All @@ -47,7 +49,7 @@ join_sparra_hhg <- function(data, year) {
if (check_year_valid(next_fy(year), "hhg")) {
data <- dplyr::left_join(
data,
read_file(get_hhg_path(next_fy(year))) %>%
get_hhg_data(next_fy(year), BYOC_MODE = BYOC_MODE) %>%
dplyr::rename(hhg_end_fy = "hhg_score"),
by = c("anon_chi"),
na_matches = "never",
Expand Down
5 changes: 4 additions & 1 deletion man/create_episode_file.Rd

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

5 changes: 4 additions & 1 deletion man/create_individual_file.Rd

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

1 change: 1 addition & 0 deletions man/get_boxi_extract_path.Rd

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

38 changes: 38 additions & 0 deletions man/get_hhg_data.Rd

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

1 change: 1 addition & 0 deletions man/get_hhg_path.Rd

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

1 change: 1 addition & 0 deletions man/get_it_deaths_path.Rd

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

1 change: 1 addition & 0 deletions man/get_it_ltc_path.Rd

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

1 change: 1 addition & 0 deletions man/get_it_prescribing_path.Rd

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

1 change: 1 addition & 0 deletions man/get_source_extract_path.Rd

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

1 change: 1 addition & 0 deletions man/get_sparra_path.Rd

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

2 changes: 1 addition & 1 deletion man/join_sparra_hhg.Rd

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

Loading