From 7283953a9b00cb800900e6dbd9c486c9868a4758 Mon Sep 17 00:00:00 2001 From: Megan McNicol <43570769+SwiftySalmon@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:13:59 +0100 Subject: [PATCH 1/2] change boxi file names back to capitals (#845) A previous pull request changed all capitals to lowercase - however boxi file names have capitals so it was no longer reading in files. This is a fix Co-authored-by: marjom02 Co-authored-by: Jennit07 <67372904+Jennit07@users.noreply.github.com> --- R/get_boxi_extract_path.R | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/R/get_boxi_extract_path.R b/R/get_boxi_extract_path.R index a4c2e4abc..3c2b4acdc 100644 --- a/R/get_boxi_extract_path.R +++ b/R/get_boxi_extract_path.R @@ -41,19 +41,19 @@ get_boxi_extract_path <- function( file_name <- dplyr::case_match( type, - "ae" ~ "a&e-episode-level-extract", - "ae_cup" ~ "a&e-ucd-cup-extract", - "acute" ~ "acute-episode-level-extract", - "cmh" ~ "community-mh-contact-level-extract", - "dn" ~ "district-nursing-contact-level-extract", - "gp_ooh-c" ~ "gp-ooh-consultations-extract", - "gp_ooh-d" ~ "gp-ooh-diagnosis-extract", - "gp_ooh-o" ~ "gp-ooh-outcomes-extract", - "homelessness" ~ "homelessness-extract", - "maternity" ~ "maternity-episode-level-extract", - "mh" ~ "mental-health-episode-level-extract", - "deaths" ~ "nrs-death-registrations-extract", - "outpatients" ~ "outpatients-episode-level-extract" + "ae" ~ "A&E-episode-level-extract", + "ae_cup" ~ "A&E-UCD-CUP-extract", + "acute" ~ "Acute-episode-level-extract", + "cmh" ~ "Community-MH-contact-level-extract", + "dn" ~ "District-Nursing-contact-level-extract", + "gp_ooh-c" ~ "GP-OoH-consultations-extract", + "gp_ooh-d" ~ "GP-OoH-diagnosis-extract", + "gp_ooh-o" ~ "GP-OoH-outcomes-extract", + "homelessness" ~ "Homelessness-extract", + "maternity" ~ "Maternity-episode-level-extract", + "mh" ~ "Mental-Health-episode-level-extract", + "deaths" ~ "NRS-death-registrations-extract", + "outpatients" ~ "Outpatients-episode-level-extract" ) boxi_extract_path_csv_gz <- fs::path( From 595e6563b887cc9691d9b8a4ab21989574a7c62e Mon Sep 17 00:00:00 2001 From: Zihao Li Date: Wed, 22 Nov 2023 10:13:28 +0000 Subject: [PATCH 2/2] 711 pop estimate eg datazone (#859) * change get_datazone_pop_path to get_pop_path to allow for more types * Update documentation * Style code --------- Co-authored-by: lizihao-anu --- NAMESPACE | 2 +- R/get_lookup_paths.R | 33 ++++++++++++++----- man/get_gpprac_ref_path.Rd | 2 +- man/get_locality_path.Rd | 2 +- man/get_lookups_dir.Rd | 2 +- ...t_datazone_pop_path.Rd => get_pop_path.Rd} | 14 +++++--- man/get_simd_path.Rd | 2 +- man/get_spd_path.Rd | 2 +- 8 files changed, 40 insertions(+), 19 deletions(-) rename man/{get_datazone_pop_path.Rd => get_pop_path.Rd} (71%) diff --git a/NAMESPACE b/NAMESPACE index c9ffc03d2..e6191f84e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,7 +27,6 @@ export(find_latest_file) export(fy_interval) export(get_boxi_extract_path) export(get_ch_costs_path) -export(get_datazone_pop_path) export(get_dd_path) export(get_dd_period) export(get_demographic_cohorts_path) @@ -52,6 +51,7 @@ export(get_locality_path) export(get_lookups_dir) export(get_ltcs_path) export(get_nsu_path) +export(get_pop_path) export(get_practice_details_path) export(get_readcode_lookup_path) export(get_sc_at_episodes_path) diff --git a/R/get_lookup_paths.R b/R/get_lookup_paths.R index cc11f8d4d..fe35a7d2f 100644 --- a/R/get_lookup_paths.R +++ b/R/get_lookup_paths.R @@ -94,10 +94,10 @@ get_simd_path <- function(file_name = NULL, ext = "parquet") { return(simd_path) } -# TODO update this function to look for a specified type of pop estimate e.g. datazone, hscp etc. -#' Datazone Populations File Path + +#' Populations File Path for different types #' -#' @description Get the path to the Datazone populations estimates +#' @description Get the path to the populations estimates #' #' @inheritParams get_file_path #' @@ -105,18 +105,35 @@ get_simd_path <- function(file_name = NULL, ext = "parquet") { #' @export #' #' @family lookup file paths -get_datazone_pop_path <- function(file_name = NULL, ext = "rds") { - datazone_pop_dir <- +get_pop_path <- function(file_name = NULL, + ext = "rds", + type = c( + "datazone", + "hscp", + "ca", + "hb", + "intzone" + )) { + pop_dir <- fs::path(get_lookups_dir(), "Populations", "Estimates") + file_name_re <- dplyr::case_match( + type, + "datazone" ~ stringr::str_glue("DataZone2011_pop_est_2011_\\d+?\\.{ext}"), + "hscp" ~ stringr::str_glue("HSCP2019_pop_est_1981_\\d+?\\.{ext}"), + "ca" ~ stringr::str_glue("CA2019_pop_est_1981_\\d+?\\.{ext}"), + "hb" ~ stringr::str_glue("HB2019_pop_est_1981_\\d+?\\.{ext}"), + "intzone" ~ stringr::str_glue("IntZone_pop_est_2011_\\d+?\\.{ext}") + ) + datazone_pop_path <- get_file_path( - directory = datazone_pop_dir, + directory = pop_dir, file_name = file_name, ext = ext, - file_name_regexp = stringr::str_glue("DataZone2011_pop_est_2001_\\d+?\\.{ext}") + file_name_regexp = file_name_re ) - return(datazone_pop_path) + return(pop_path) } diff --git a/man/get_gpprac_ref_path.Rd b/man/get_gpprac_ref_path.Rd index d8990cd95..a61a4b560 100644 --- a/man/get_gpprac_ref_path.Rd +++ b/man/get_gpprac_ref_path.Rd @@ -17,9 +17,9 @@ Get the path for the centrally held reference file \code{gpprac} } \seealso{ Other lookup file paths: -\code{\link{get_datazone_pop_path}()}, \code{\link{get_locality_path}()}, \code{\link{get_lookups_dir}()}, +\code{\link{get_pop_path}()}, \code{\link{get_simd_path}()}, \code{\link{get_spd_path}()} } diff --git a/man/get_locality_path.Rd b/man/get_locality_path.Rd index a09bad48e..65f809b2f 100644 --- a/man/get_locality_path.Rd +++ b/man/get_locality_path.Rd @@ -19,9 +19,9 @@ Get the path to the centrally held HSCP Localities file. } \seealso{ Other lookup file paths: -\code{\link{get_datazone_pop_path}()}, \code{\link{get_gpprac_ref_path}()}, \code{\link{get_lookups_dir}()}, +\code{\link{get_pop_path}()}, \code{\link{get_simd_path}()}, \code{\link{get_spd_path}()} } diff --git a/man/get_lookups_dir.Rd b/man/get_lookups_dir.Rd index e1748b9a8..4e90472bf 100644 --- a/man/get_lookups_dir.Rd +++ b/man/get_lookups_dir.Rd @@ -14,9 +14,9 @@ Get the path to the lookups directory } \seealso{ Other lookup file paths: -\code{\link{get_datazone_pop_path}()}, \code{\link{get_gpprac_ref_path}()}, \code{\link{get_locality_path}()}, +\code{\link{get_pop_path}()}, \code{\link{get_simd_path}()}, \code{\link{get_spd_path}()} diff --git a/man/get_datazone_pop_path.Rd b/man/get_pop_path.Rd similarity index 71% rename from man/get_datazone_pop_path.Rd rename to man/get_pop_path.Rd index 45b1edbca..ce9c0409c 100644 --- a/man/get_datazone_pop_path.Rd +++ b/man/get_pop_path.Rd @@ -1,10 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/get_lookup_paths.R -\name{get_datazone_pop_path} -\alias{get_datazone_pop_path} -\title{Datazone Populations File Path} +\name{get_pop_path} +\alias{get_pop_path} +\title{Populations File Path for different types} \usage{ -get_datazone_pop_path(file_name = NULL, ext = "rds") +get_pop_path( + file_name = NULL, + ext = "rds", + type = c("datazone", "hscp", "ca", "hb", "intzone") +) } \arguments{ \item{file_name}{The file name (with extension if not supplied to \code{ext})} @@ -15,7 +19,7 @@ get_datazone_pop_path(file_name = NULL, ext = "rds") An \code{\link[fs:path]{fs::path()}} to the populations estimates file } \description{ -Get the path to the Datazone populations estimates +Get the path to the populations estimates } \seealso{ Other lookup file paths: diff --git a/man/get_simd_path.Rd b/man/get_simd_path.Rd index 6d5cc1b93..15e58929e 100644 --- a/man/get_simd_path.Rd +++ b/man/get_simd_path.Rd @@ -20,10 +20,10 @@ Deprivation (SIMD) file. } \seealso{ Other lookup file paths: -\code{\link{get_datazone_pop_path}()}, \code{\link{get_gpprac_ref_path}()}, \code{\link{get_locality_path}()}, \code{\link{get_lookups_dir}()}, +\code{\link{get_pop_path}()}, \code{\link{get_spd_path}()} } \concept{lookup file paths} diff --git a/man/get_spd_path.Rd b/man/get_spd_path.Rd index 70a5f00be..25d46f114 100644 --- a/man/get_spd_path.Rd +++ b/man/get_spd_path.Rd @@ -20,10 +20,10 @@ Get the path to the centrally held Scottish Postcode Directory } \seealso{ Other lookup file paths: -\code{\link{get_datazone_pop_path}()}, \code{\link{get_gpprac_ref_path}()}, \code{\link{get_locality_path}()}, \code{\link{get_lookups_dir}()}, +\code{\link{get_pop_path}()}, \code{\link{get_simd_path}()} } \concept{lookup file paths}