From 0ad7cf63629b1502b1419ba60d405430e97c3bc7 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Tue, 8 Aug 2023 13:30:33 +0100 Subject: [PATCH 1/4] Update `get_boxi_extract_path` for DN/CMH data --- NAMESPACE | 1 + R/get_boxi_extract_path.R | 71 +++++++++++++++++++++++++-------------- man/get_csv_gz_path.Rd | 23 +++++++++++++ 3 files changed, 69 insertions(+), 26 deletions(-) create mode 100644 man/get_csv_gz_path.Rd diff --git a/NAMESPACE b/NAMESPACE index 6c4f3cd52..ca901a8c2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -22,6 +22,7 @@ export(find_latest_file) export(fy_interval) export(get_boxi_extract_path) export(get_ch_costs_path) +export(get_csv_gz_path) export(get_datazone_pop_path) export(get_dd_path) export(get_dd_period) diff --git a/R/get_boxi_extract_path.R b/R/get_boxi_extract_path.R index 60dd7857a..7606014f9 100644 --- a/R/get_boxi_extract_path.R +++ b/R/get_boxi_extract_path.R @@ -29,37 +29,13 @@ get_boxi_extract_path <- function( )) { type <- match.arg(type) - year_dir <- get_year_dir(year, extracts_dir = TRUE) - if (!check_year_valid(year, type)) { return(get_dummy_boxi_extract_path()) } - 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" - ) + boxi_extract_path_csv_gz <- get_csv_gz_path(year, type, ext = "csv.gz") - boxi_extract_path_csv_gz <- fs::path( - year_dir, - stringr::str_glue("{file_name}-20{year}.csv.gz") - ) - boxi_extract_path_csv <- fs::path( - year_dir, - stringr::str_glue("{file_name}-20{year}.csv") - ) + boxi_extract_path_csv <- get_csv_gz_path(year, type, ext = "csv") # If the csv.gz file doesn't exist look for the unzipped csv. if (fs::file_exists(boxi_extract_path_csv_gz)) { @@ -83,3 +59,46 @@ get_dummy_boxi_extract_path <- function() { create = TRUE ) } + +#' Get path as a csv or csv.gz +#' +#' @param year Year of extract +#' @param type Name of BOXI extract passed from [get_boxi_extract_path] +#' @param ext Choice of extension between csv or csv.gz for zipped extracts +#' +#' @return The file path to boxi extracts. Note for DN and CMH data this is +#' now in an archived folder which is set up to point to this in +#' the selections. +#' @export +#' +get_csv_gz_path <- function(year, type, ext = c("csv", "csv.gz")) { + if (type %in% c("DN", "CMH")) { + dir <- fs::path(get_slf_dir(), "Archived_data") + } else { + dir <- get_year_dir(year, extracts_dir = TRUE) + } + + 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" + ) + + csv_gz_path <- fs::path( + dir, + stringr::str_glue("{file_name}-20{year}.{ext}") + ) + + return(csv_gz_path) +} diff --git a/man/get_csv_gz_path.Rd b/man/get_csv_gz_path.Rd new file mode 100644 index 000000000..6d151e014 --- /dev/null +++ b/man/get_csv_gz_path.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_boxi_extract_path.R +\name{get_csv_gz_path} +\alias{get_csv_gz_path} +\title{Get path as a csv or csv.gz} +\usage{ +get_csv_gz_path(year, type, ext = c("csv", "csv.gz")) +} +\arguments{ +\item{year}{Year of extract} + +\item{type}{Name of BOXI extract passed from \link{get_boxi_extract_path}} + +\item{ext}{Choice of extension between csv or csv.gz for zipped extracts} +} +\value{ +The file path to boxi extracts. Note for DN and CMH data this is +now in an archived folder which is set up to point to this in +the selections. +} +\description{ +Get path as a csv or csv.gz +} From d1e4d603de046879c340a734fab314b55e696800 Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Wed, 9 Aug 2023 11:53:17 +0100 Subject: [PATCH 2/4] Remove extra function --- R/get_boxi_extract_path.R | 76 ++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 45 deletions(-) diff --git a/R/get_boxi_extract_path.R b/R/get_boxi_extract_path.R index 7606014f9..6096525e5 100644 --- a/R/get_boxi_extract_path.R +++ b/R/get_boxi_extract_path.R @@ -29,13 +29,42 @@ get_boxi_extract_path <- function( )) { type <- match.arg(type) + if (type %in% c("DN", "CMH")) { + dir <- fs::path(get_slf_dir(), "Archived_data") + } else { + dir <- get_year_dir(year, extracts_dir = TRUE) + } + if (!check_year_valid(year, type)) { return(get_dummy_boxi_extract_path()) } - boxi_extract_path_csv_gz <- get_csv_gz_path(year, type, ext = "csv.gz") + 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" + ) + + boxi_extract_path_csv_gz <- fs::path( + dir, + stringr::str_glue("{file_name}-20{year}.csv.gz") + ) - boxi_extract_path_csv <- get_csv_gz_path(year, type, ext = "csv") + boxi_extract_path_csv <- fs::path( + dir, + stringr::str_glue("{file_name}-20{year}.csv") + ) # If the csv.gz file doesn't exist look for the unzipped csv. if (fs::file_exists(boxi_extract_path_csv_gz)) { @@ -59,46 +88,3 @@ get_dummy_boxi_extract_path <- function() { create = TRUE ) } - -#' Get path as a csv or csv.gz -#' -#' @param year Year of extract -#' @param type Name of BOXI extract passed from [get_boxi_extract_path] -#' @param ext Choice of extension between csv or csv.gz for zipped extracts -#' -#' @return The file path to boxi extracts. Note for DN and CMH data this is -#' now in an archived folder which is set up to point to this in -#' the selections. -#' @export -#' -get_csv_gz_path <- function(year, type, ext = c("csv", "csv.gz")) { - if (type %in% c("DN", "CMH")) { - dir <- fs::path(get_slf_dir(), "Archived_data") - } else { - dir <- get_year_dir(year, extracts_dir = TRUE) - } - - 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" - ) - - csv_gz_path <- fs::path( - dir, - stringr::str_glue("{file_name}-20{year}.{ext}") - ) - - return(csv_gz_path) -} From 0ccc3e8a8048beb16ed431dca01f6e28eaa9db34 Mon Sep 17 00:00:00 2001 From: Jennit07 Date: Wed, 9 Aug 2023 10:57:09 +0000 Subject: [PATCH 3/4] Update documentation --- NAMESPACE | 1 - man/get_csv_gz_path.Rd | 23 ----------------------- 2 files changed, 24 deletions(-) delete mode 100644 man/get_csv_gz_path.Rd diff --git a/NAMESPACE b/NAMESPACE index ca901a8c2..6c4f3cd52 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -22,7 +22,6 @@ export(find_latest_file) export(fy_interval) export(get_boxi_extract_path) export(get_ch_costs_path) -export(get_csv_gz_path) export(get_datazone_pop_path) export(get_dd_path) export(get_dd_period) diff --git a/man/get_csv_gz_path.Rd b/man/get_csv_gz_path.Rd deleted file mode 100644 index 6d151e014..000000000 --- a/man/get_csv_gz_path.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/get_boxi_extract_path.R -\name{get_csv_gz_path} -\alias{get_csv_gz_path} -\title{Get path as a csv or csv.gz} -\usage{ -get_csv_gz_path(year, type, ext = c("csv", "csv.gz")) -} -\arguments{ -\item{year}{Year of extract} - -\item{type}{Name of BOXI extract passed from \link{get_boxi_extract_path}} - -\item{ext}{Choice of extension between csv or csv.gz for zipped extracts} -} -\value{ -The file path to boxi extracts. Note for DN and CMH data this is -now in an archived folder which is set up to point to this in -the selections. -} -\description{ -Get path as a csv or csv.gz -} From 5225107ecdf6563f00f205da01b4cb8cfe9f0b60 Mon Sep 17 00:00:00 2001 From: James McMahon Date: Mon, 14 Aug 2023 14:15:04 +0000 Subject: [PATCH 4/4] [check-spelling] Update metadata Update for https://github.com/Public-Health-Scotland/source-linkage-files/actions/runs/5856792420/attempts/1 Accepted in https://github.com/Public-Health-Scotland/source-linkage-files/pull/785#issuecomment-1677400900 Signed-off-by: check-spelling-bot --- .github/actions/spelling/expect.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 87300a6a1..51c0a6c6b 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -91,6 +91,7 @@ hjust hms homecare homev +hscdiip hscp hscpnames IDPC