Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename function to convert_sc_sending_location_to_lca #839

Merged
merged 60 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
d9ac7ca
Bump `{slfhelper}` version
Moohan Jul 26, 2023
d731bf7
Remove unnecessary code from `get_anon_chi` (#759)
SwiftySalmon Jul 28, 2023
1269b3b
Set the default reporter for `tar_outdated()` and friends
Moohan Jul 31, 2023
1ea0a1a
Comment out dataset writing targets
Moohan Jul 31, 2023
965f05c
Make sure `year` is added as the first variable
Moohan Jul 31, 2023
d75922a
Correct some documentation (#769)
Moohan Aug 1, 2023
5fd538f
Make some changes suggested by lintr
Moohan Aug 1, 2023
4c9c175
Document
Moohan Aug 1, 2023
6e55e84
Merge branch 'master' into development
Moohan Aug 1, 2023
9644e0e
Fix documentation typo
Moohan Aug 1, 2023
42e461f
Investigate missing datazone from episode file (#773)
Jennit07 Aug 2, 2023
720b20d
Remove some obsolete code (#770)
Moohan Aug 2, 2023
4a03434
Simplify `create_hscp_test_flags` (#772)
Jennit07 Aug 2, 2023
f6be11c
Rewrite case when statements (#780)
SwiftySalmon Aug 3, 2023
bb3dbd5
Update R-CMD-check.yaml (#781)
Moohan Aug 4, 2023
04399a4
added solve for hscp names (#789)
SwiftySalmon Aug 9, 2023
3820c19
Fix locality (#802)
Moohan Aug 14, 2023
f15039c
Merge branch 'development' into sept-update-23
Jennit07 Aug 14, 2023
8ea15c0
Add simple scripts for running targets as a workbench job (#767)
Moohan Aug 14, 2023
80799a2
Fix CHI duplicates of chi in individual file (#791)
lizihao-anu Aug 14, 2023
19779e3
Update NSU code for new 22/23 cohort (#784)
Jennit07 Aug 14, 2023
7e3215d
Amend `get_boxi_extract_path` function for archiving DN and CMH data …
Jennit07 Aug 14, 2023
612e069
Fix increase in total preventable beddays (#779)
lizihao-anu Aug 14, 2023
51a0b05
fix warning on `:=` (#797)
lizihao-anu Aug 15, 2023
0f25195
Add 2324 targets/workbench job file
Moohan Aug 14, 2023
c4a54f8
Use `get_source_extract_path` in homelessness (#796)
Moohan Aug 14, 2023
e36c97c
Correct tests for NSU
Moohan Aug 14, 2023
62a4174
Update script for extracting NSU from SMRA space
Jennit07 Aug 15, 2023
d310dfd
Update year in 99_NSU extract script
Jennit07 Aug 15, 2023
51c4a63
Update news for September 23 update (#811)
Jennit07 Aug 15, 2023
ee3943f
Apply styling
Jennit07 Aug 16, 2023
61283cc
Fix issue with `case_match` types (#810)
Moohan Aug 16, 2023
c88562c
Bug - Outpatients tests failing due to missing HSCP (#816)
Jennit07 Aug 16, 2023
1e06921
fix read_sc_all_alarms_telecare with incorrect format in period (#814)
lizihao-anu Aug 16, 2023
2c6853c
Fix `convert_sending_location_to_lca` example
Moohan Aug 16, 2023
ff4d35f
Use `col_select` instead of `columns` in tests
Jennit07 Sep 1, 2023
53ede24
Add tests for `compute_mid_year_age` (#809)
Moohan Sep 25, 2023
04c2685
Add a new function to set up keyring (#800)
Moohan Sep 25, 2023
9652c69
Add additional tests for `get_file_path` (#808)
Moohan Sep 25, 2023
bc2e4b3
Rename `run_episode_file()` -> `create_episode_file()` (#803)
Moohan Sep 25, 2023
854868e
Remove incorrect references to rds (#798)
Moohan Sep 25, 2023
ad98c3c
Make targets and tarchetypes required packages (#799)
Moohan Sep 25, 2023
a5bc79e
Update episode file functions to pass data through (#754)
Moohan Sep 26, 2023
b7ce1b1
Tests/it extract path (#807)
Moohan Sep 26, 2023
2f6f25c
Update workflow to run against the development branch (#795)
Moohan Sep 26, 2023
50f4ef9
Remove package wide imports of `readr` (#792)
Jennit07 Sep 26, 2023
e76176e
Handle OpenData extracts better (#794)
Moohan Sep 26, 2023
81c2191
Fix the pkgdown site/job (#804)
Moohan Sep 26, 2023
85f9702
Add new 'final' file path functions (#787)
Jennit07 Sep 26, 2023
b1a7e56
Check scripts are in snake case (#793)
Jennit07 Sep 26, 2023
15a7856
transform the python script for sorting BI extracts to R (#833)
lizihao-anu Sep 27, 2023
3208dc3
Merge branch 'master' into development
Jennit07 Sep 28, 2023
dde0708
Use `get_slf_episode_path` in right place
Jennit07 Sep 28, 2023
9d826cd
fix pipe
Jennit07 Sep 28, 2023
36826c5
Fix typo in string
Jennit07 Sep 28, 2023
a55d69a
Update documentation
Jennit07 Sep 28, 2023
c454188
Rename to `convert_sc_sending_location_to_lca`
Jennit07 Sep 29, 2023
297ac88
Update documentation
Jennit07 Sep 29, 2023
1b0922b
Style code
Jennit07 Sep 29, 2023
306446e
Update documentation
Jennit07 Sep 29, 2023
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
85 changes: 0 additions & 85 deletions 00-Sort_BI_Extracts.py

This file was deleted.

50 changes: 50 additions & 0 deletions 00_Sort_BI_Extracts.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Define the source directory and financial year pattern
compress_files <- FALSE
source_dir <- "/conf/sourcedev/Source_Linkage_File_Updates/Extracts Temp"
pattern <- "-20(\\d{4})\\.csv"


# List all the CSV files in the source directory
cat(stringr::str_glue("Looking in '{source_dir}' for csv files."))
csv_files <- list.files(source_dir, pattern = ".csv", full.names = TRUE)
print(stringr::str_glue("Found {length(csv_files)} csv files to process."))

# Create a function to extract the financial year from a filename
extract_financial_year <- function(filename) {
match <- regexpr(pattern, basename(filename))
if (match[[1]][1] > 0) {
financial_year <- substr(basename(filename), match[[1]][1] + 3, match[[1]][1] + 6)
return(financial_year)
} else {
return(NULL)
}
}

# Create directories for each financial year and move files
for (csv_file in csv_files) {
financial_year <- extract_financial_year(csv_file)
# check if year directory exists
if (!is.null(financial_year)) {
financial_year_dir <- file.path("/conf/sourcedev/Source_Linkage_File_Updates", financial_year, "Extracts")
# if not, create the year directory
if (!dir.exists(financial_year_dir)) {
dir.create(financial_year_dir)
}

# compress file
if (compress_files) {
cat("Compressing:", basename(csv_file), "\n")
system2(
command = "gzip",
args = shQuote(csv_file)
)
csv_file <- paste0(csv_file, ".gz")
}

# move file
new_file_path <- file.path(financial_year_dir, basename(csv_file))
file.copy(csv_file, new_file_path)
file.remove(csv_file)
cat("Moved:", csv_file, "to", new_file_path, "\n")
}
}
17 changes: 4 additions & 13 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export(convert_fyyear_to_year)
export(convert_hb_to_hbnames)
export(convert_hscp_to_hscpnames)
export(convert_numeric_to_date)
export(convert_sending_location_to_lca)
export(convert_sc_sending_location_to_lca)
export(convert_year_to_fyyear)
export(create_episode_file)
export(create_homelessness_lookup)
Expand Down Expand Up @@ -47,6 +47,7 @@ export(get_homelessness_completeness_path)
export(get_it_deaths_path)
export(get_it_ltc_path)
export(get_it_prescribing_path)
export(get_la_code_opendata_lookup)
export(get_locality_path)
export(get_lookups_dir)
export(get_ltcs_path)
Expand All @@ -66,7 +67,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)
Expand All @@ -75,7 +78,6 @@ export(get_year_dir)
export(gzip_files)
export(is_date_in_fyyear)
export(is_missing)
export(la_code_lookup)
export(last_date_month)
export(latest_cost_year)
export(latest_update)
Expand Down Expand Up @@ -172,17 +174,6 @@ export(write_file)
importFrom(data.table,.N)
importFrom(data.table,.SD)
importFrom(magrittr,"%>%")
importFrom(readr,col_character)
importFrom(readr,col_date)
importFrom(readr,col_datetime)
importFrom(readr,col_double)
importFrom(readr,col_factor)
importFrom(readr,col_integer)
importFrom(readr,col_logical)
importFrom(readr,col_number)
importFrom(readr,col_time)
importFrom(readr,cols)
importFrom(readr,cols_only)
importFrom(rlang,":=")
importFrom(rlang,.data)
importFrom(tibble,tibble)
2 changes: 1 addition & 1 deletion R/add_nsu_cohort.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @return A data frame containing the Non-Service Users as additional rows
#' @export
#'
#' @family episode file
#' @family episode_file
#' @seealso [get_nsu_path()]
add_nsu_cohort <- function(
data,
Expand Down
2 changes: 1 addition & 1 deletion R/add_ppa_flag.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param data A data frame
#'
#' @return A data frame to use as a lookup of PPAs
#' @family episode file
#' @family episode_file
add_ppa_flag <- function(data) {
check_variables_exist(
data,
Expand Down
2 changes: 1 addition & 1 deletion R/convert_ca_to_lca.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' convert_ca_to_lca(ca)
#'
#' @family code functions
#' @seealso convert_sending_location_to_lca
#' @seealso convert_sc_sending_location_to_lca
convert_ca_to_lca <- function(ca_var) {
lca <- dplyr::case_match(
ca_var,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#'
#' @examples
#' sending_location <- c(100, 120)
#' convert_sending_location_to_lca(sending_location)
#' convert_sc_sending_location_to_lca(sending_location)
#'
#' @family code functions
#'
#' @seealso convert_ca_to_lca
convert_sending_location_to_lca <- function(sending_location) {
convert_sc_sending_location_to_lca <- function(sending_location) {
lca <- dplyr::case_match(
sending_location,
100L ~ "01", # Aberdeen City
Expand Down
2 changes: 2 additions & 0 deletions R/cost_uplift.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @param data episode data
#'
#' @return episode data with uplifted costs
#' @family episode_file
apply_cost_uplift <- function(data) {
data <- data %>%
# attach a uplift scale as the last column
Expand Down Expand Up @@ -34,6 +35,7 @@ apply_cost_uplift <- function(data) {
#' @param data episode data
#'
#' @return episode data with a uplift scale
#' @family episode_file
lookup_uplift <- function(data) {
# We have set uplifts to use for 2020/21, 2021/22 and 2022/23,
# provided by Paul Leak.
Expand Down
9 changes: 1 addition & 8 deletions R/create_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,7 @@ 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)
}
Expand Down
Loading