Skip to content

Commit

Permalink
Check scripts are in snake case (#793)
Browse files Browse the repository at this point in the history
* Update `get_boxi_extract_path` for DN/CMH data

* Remove extra function

* Update documentation

* change `get_boxi_extract_path` to snake_case

* change `get_source_extract_path` to snake_case

* Update documentation

* Update targets with snake_case

* Fix typo

* Style code

---------

Co-authored-by: Jennit07 <[email protected]>
Co-authored-by: James McMahon <[email protected]>
Co-authored-by: Megan McNicol <[email protected]>
Co-authored-by: SwiftySalmon <[email protected]>
  • Loading branch information
5 people authored Sep 26, 2023
1 parent 85f9702 commit b1a7e56
Show file tree
Hide file tree
Showing 53 changed files with 140 additions and 137 deletions.
2 changes: 1 addition & 1 deletion R/create_individual_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ join_slf_lookup_vars <- function(individual_file,
join_sc_client <- function(
individual_file,
year,
sc_client = read_file(get_source_extract_path(year, "Client")),
sc_client = read_file(get_source_extract_path(year, "client")),
sc_demographics = read_file(get_sc_demog_lookup_path(),
col_select = c("sending_location", "social_care_id", "chi")
)) {
Expand Down
54 changes: 27 additions & 27 deletions R/get_boxi_extract_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
get_boxi_extract_path <- function(
year,
type = c(
"AE",
"AE_CUP",
"Acute",
"CMH",
"Deaths",
"DN",
"GP_OoH-c",
"GP_OoH-d",
"GP_OoH-o",
"Homelessness",
"Maternity",
"MH",
"Outpatients"
"ae",
"ae_cup",
"acute",
"cmh",
"deaths",
"dn",
"gp_ooh-c",
"gp_ooh-d",
"gp_ooh-o",
"homelessness",
"maternity",
"mh",
"outpatients"
)) {
type <- match.arg(type)

if (type %in% c("DN", "CMH")) {
if (type %in% c("dn", "cmh")) {
dir <- fs::path(get_slf_dir(), "Archived_data")
} else {
dir <- get_year_dir(year, extracts_dir = TRUE)
Expand All @@ -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(
Expand Down
82 changes: 42 additions & 40 deletions R/get_source_extract_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@
#' @export
#'
#' @family extract file paths
get_source_extract_path <- function(
year,
type = c(
"Acute",
"AE",
"AT",
"CH",
"Client",
"CMH",
"DD",
"Deaths",
"DN",
"GPOoH",
"HC",
"Homelessness",
"Maternity",
"MH",
"Outpatients",
"PIS",
"SDS"
),
...) {
get_source_extract_path <- function(year,
type = c(
"acute",
"ae",
"at",
"ch",
"client",
"cmh",
"dd",
"deaths",
"dn",
"gp_ooh",
"hc",
"homelessness",
"maternity",
"mh",
"outpatients",
"pis",
"sds"
),
...) {

if (year %in% type) {
cli::cli_abort("{.val {year}} was supplied to the {.arg year} argument.")
}
Expand All @@ -46,24 +46,26 @@ get_source_extract_path <- function(

file_name <- dplyr::case_match(
type,
"Acute" ~ "acute_for_source",
"AE" ~ "a_and_e_for_source",
"AT" ~ "alarms-telecare-for-source",
"CH" ~ "care_home_for_source",
"CMH" ~ "cmh_for_source",
"Client" ~ "client_for_source",
"DD" ~ "delayed_discharge_for_source",
"Deaths" ~ "deaths_for_source",
"DN" ~ "district_nursing_for_source",
"GPOoH" ~ "gp_ooh_for_source",
"HC" ~ "home_care_for_source",
"Homelessness" ~ "homelessness_for_source",
"Maternity" ~ "maternity_for_source",
"MH" ~ "mental_health_for_source",
"Outpatients" ~ "outpatients_for_source",
"PIS" ~ "prescribing_for_source",
"SDS" ~ "sds_for_source"
) %>%
"acute" ~ "acute_for_source",
"ae" ~ "a_and_e_for_source",
"at" ~ "alarms-telecare-for-source",
"ch" ~ "care_home_for_source",
"cmh" ~ "cmh_for_source",
"client" ~ "client_for_source",
"dd" ~ "delayed_discharge_for_source",
"deaths" ~ "deaths_for_source",
"dn" ~ "district_nursing_for_source",
"gp_ooh" ~ "gp_ooh_for_source",
"hc" ~ "home_care_for_source",
"homelessness" ~ "homelessness_for_source",
"maternity" ~ "maternity_for_source",
"mh" ~ "mental_health_for_source",
"dd" ~ "dd_for_source",
"outpatients" ~ "outpatients_for_source",
"pis" ~ "prescribing_file_for_source",
"sds" ~ "sds-for-source"
)
%>%
stringr::str_glue("-{year}.parquet")

source_extract_path <- get_file_path(
Expand Down
2 changes: 1 addition & 1 deletion R/link_delayed_discharge_eps.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
link_delayed_discharge_eps <- function(
episode_file,
year,
dd_data = read_file(get_source_extract_path(year, "DD"))) {
dd_data = read_file(get_source_extract_path(year, "dd"))) {
episode_file <- episode_file %>%
dplyr::mutate(
# remember to revoke the cij_end_date with dummy_cij_end
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_acute.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ process_extract_acute <- function(data, year, write_to_disk = TRUE) {
if (write_to_disk) {
write_file(
acute_processed,
get_source_extract_path(year, "Acute", check_mode = "write")
get_source_extract_path(year, "acute", check_mode = "write")
)
}

Expand Down
7 changes: 4 additions & 3 deletions R/process_extract_ae.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ process_extract_ae <- function(data, year, write_to_disk = TRUE) {
# Read in data---------------------------------------

ae_cup_file <- read_file(
path = get_boxi_extract_path(year, "AE_CUP"),
path = get_boxi_extract_path(year, "ae_cup),
col_type = readr::cols(
"ED Arrival Date" = readr::col_date(format = "%Y/%m/%d %T"),
"ED Arrival Time" = readr::col_time(""),
Expand Down Expand Up @@ -292,11 +292,12 @@ process_extract_ae <- function(data, year, write_to_disk = TRUE) {
)
if (write_to_disk) {
write_file(
ae_processed,
get_source_extract_path(year, "AE", check_mode = "write")
get_source_extract_path(year, "ae", check_mode = "write")
)
}
}
return(ae_processed)
}
2 changes: 1 addition & 1 deletion R/process_extract_alarms_telecare.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ process_extract_alarms_telecare <- function(
if (write_to_disk) {
at_data %>%
write_file(
get_source_extract_path(year, type = "AT", check_mode = "write")
get_source_extract_path(year, type = "at", check_mode = "write")
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_care_home.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ process_extract_care_home <- function(
if (write_to_disk) {
write_file(
ch_processed,
get_source_extract_path(year, type = "CH", check_mode = "write")
get_source_extract_path(year, type = "ch", check_mode = "write")
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_cmh.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ process_extract_cmh <- function(data,
if (write_to_disk) {
write_file(
cmh_processed,
get_source_extract_path(year, "CMH", check_mode = "write")
get_source_extract_path(year, "cmh", check_mode = "write")
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_delayed_discharges.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ process_extract_delayed_discharges <- function(
if (write_to_disk) {
write_file(
dd_final,
get_source_extract_path(year, "DD", check_mode = "write")
get_source_extract_path(year, "dd", check_mode = "write")
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_district_nursing.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ process_extract_district_nursing <- function(

if (write_to_disk) {
dn_episodes %>%
write_file(get_source_extract_path(year, "DN", check_mode = "write"))
write_file(get_source_extract_path(year, "dn", check_mode = "write"))
}

return(dn_episodes)
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_gp_ooh.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ process_extract_gp_ooh <- function(year, data_list, write_to_disk = TRUE) {

if (write_to_disk) {
final_data %>%
write_file(get_source_extract_path(year, "GPOoH", check_mode = "write"))
write_file(get_source_extract_path(year, "gp_ooh", check_mode = "write"))
}

return(final_data)
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_home_care.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ process_extract_home_care <- function(
if (write_to_disk) {
write_file(
hc_processed,
get_source_extract_path(year, type = "HC", check_mode = "write")
get_source_extract_path(year, type = "hc", check_mode = "write")
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_maternity.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ process_extract_maternity <- function(data, year, write_to_disk = TRUE) {
if (write_to_disk) {
write_file(
maternity_processed,
get_source_extract_path(year, "Maternity", check_mode = "write")
get_source_extract_path(year, "maternity", check_mode = "write")
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_mental_health.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ process_extract_mental_health <- function(data, year, write_to_disk = TRUE) {
if (write_to_disk) {
write_file(
mh_processed,
get_source_extract_path(year, "MH", check_mode = "write")
get_source_extract_path(year, "mh", check_mode = "write")
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_nrs_deaths.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ process_extract_nrs_deaths <- function(data, year, write_to_disk = TRUE) {

if (write_to_disk) {
deaths_clean %>%
write_file(get_source_extract_path(year, "Deaths", check_mode = "write"))
write_file(get_source_extract_path(year, "deaths", check_mode = "write"))
}

return(deaths_clean)
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_outpatients.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ process_extract_outpatients <- function(data, year, write_to_disk = TRUE) {
if (write_to_disk) {
write_file(
outpatients_processed,
get_source_extract_path(year, "Outpatients", check_mode = "write")
get_source_extract_path(year, "outpatients", check_mode = "write")
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_prescribing.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ process_extract_prescribing <- function(data, year, write_to_disk = TRUE) {
if (write_to_disk) {
write_file(
pis_clean,
get_source_extract_path(year, "PIS", check_mode = "write")
get_source_extract_path(year, "pis", check_mode = "write")
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_sds.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ process_extract_sds <- function(

if (write_to_disk) {
outfile %>%
write_file(get_source_extract_path(year, type = "SDS", check_mode = "write"))
write_file(get_source_extract_path(year, type = "sds", check_mode = "write"))
}

return(outfile)
Expand Down
2 changes: 1 addition & 1 deletion R/process_lookup_deaths.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
process_slf_deaths_lookup <- function(
year,
nrs_deaths_data = read_file(
get_source_extract_path(year, "Deaths"),
get_source_extract_path(year, "deaths"),
col_select = c("chi", "record_keydate1")
),
chi_deaths_data = read_file(get_slf_chi_deaths_path()),
Expand Down
2 changes: 1 addition & 1 deletion R/process_lookup_sc_client.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ process_lookup_sc_client <- function(data, year, write_to_disk = TRUE) {
if (write_to_disk) {
write_file(
sc_client_lookup,
get_source_extract_path(year, "Client", check_mode = "write")
get_source_extract_path(year, "client", check_mode = "write")
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/read_extract_acute.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @return a [tibble][tibble::tibble-package].
#'
#' @export
read_extract_acute <- function(year, file_path = get_boxi_extract_path(year = year, type = "Acute")) {
read_extract_acute <- function(year, file_path = get_boxi_extract_path(year = year, type = "acute")) {
# Read BOXI extract
extract_acute <- read_file(file_path,
col_type = readr::cols(
Expand Down
2 changes: 1 addition & 1 deletion R/read_extract_ae.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#'
read_extract_ae <- function(
year,
file_path = get_boxi_extract_path(year = year, type = "AE")) {
file_path = get_boxi_extract_path(year = year, type = "ae")) {
extract_ae <- read_file(file_path,
col_type = readr::cols(
"Arrival Date" = readr::col_date(format = "%Y/%m/%d %T"),
Expand Down
2 changes: 1 addition & 1 deletion R/read_extract_cmh.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @export
read_extract_cmh <- function(
year,
file_path = get_boxi_extract_path(year = year, type = "CMH")) {
file_path = get_boxi_extract_path(year = year, type = "cmh")) {
# Specify years available for running
if (file_path == get_dummy_boxi_extract_path()) {
return(tibble::tibble())
Expand Down
2 changes: 1 addition & 1 deletion R/read_extract_district_nursing.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @export
read_extract_district_nursing <- function(
year,
file_path = get_boxi_extract_path(year = year, type = "DN")) {
file_path = get_boxi_extract_path(year = year, type = "dn")) {
if (file_path == get_dummy_boxi_extract_path()) {
return(tibble::tibble())
}
Expand Down
Loading

0 comments on commit b1a7e56

Please sign in to comment.