-
Notifications
You must be signed in to change notification settings - Fork 2
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
Clean test folder #1021
base: december-2024
Are you sure you want to change the base?
Clean test folder #1021
Changes from all commits
e2482e9
8064909
c4947b5
218121e
bce2267
2e324b0
cbf87d9
e9a2807
9f0507d
01a2df0
908c6cf
53055c7
a0a1734
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,109 @@ | ||
################################################################################ | ||
# # Name of file - 00-update_refs.R | ||
# Original Authors - Jennifer Thom, Zihao Li | ||
# Original Date - August 2021 | ||
# Update - Oct 2024 | ||
# | ||
# Written/run on - RStudio Server | ||
# Version of R - 4.1.2 | ||
# | ||
# Description - Use this script to update references needed for the SLF update. | ||
# | ||
# Manual changes needed to the following Essential Functions: | ||
# # End_date | ||
# # Check_year_valid | ||
# # Delayed_discharges_period | ||
# # Latest_update | ||
# | ||
################################################################################ | ||
|
||
#' End date | ||
#' | ||
#' @return Get the end date of the latest update period | ||
#' @export End date as dmy | ||
#' | ||
end_date <- function() { | ||
## UPDATE ## | ||
# Last date in reporting period | ||
# Q1 June = 30062024 | ||
# Q2 September = 30092024 | ||
# Q3 December = 31122024 | ||
# Q4 March = 31032024 | ||
lubridate::dmy(30062024) | ||
} | ||
|
||
|
||
#' Check data exists for a year | ||
#' | ||
#' @description Check there is data available for a given year | ||
#' as some extracts are year dependent. E.g Homelessness | ||
#' is only available from 2016/17 onwards. | ||
#' | ||
#' @param year Financial year | ||
#' @param type name of extract | ||
#' | ||
#' @return A logical TRUE/FALSE | ||
check_year_valid <- function( | ||
year, | ||
type = c( | ||
"acute", | ||
"ae", | ||
"at", | ||
"ch", | ||
"client", | ||
"cmh", | ||
"cost_dna", | ||
"dd", | ||
"deaths", | ||
"dn", | ||
"gpooh", | ||
"hc", | ||
"homelessness", | ||
"hhg", | ||
"maternity", | ||
"mh", | ||
"nsu", | ||
"outpatients", | ||
"pis", | ||
"sds", | ||
"sparra" | ||
)) { | ||
if (year <= "1415" && type %in% c("dn", "sparra")) { | ||
return(FALSE) | ||
} else if (year <= "1516" && type %in% c("cmh", "homelessness", "dd")) { | ||
return(FALSE) | ||
} else if (year <= "1617" && type %in% c("ch", "hc", "sds", "at", "client", "cost_dna")) { | ||
return(FALSE) | ||
} else if (year <= "1718" && type %in% "hhg") { | ||
return(FALSE) | ||
} else if (year >= "2122" && type %in% c("cmh", "dn")) { | ||
return(FALSE) | ||
} else if (year >= "2324" && type %in% c("nsu", "hhg")) { | ||
return(FALSE) | ||
} else if (year >= "2425" && type %in% "nsu") { | ||
return(FALSE) | ||
} else if (year >= "2526" && type %in% c("ch", "hc", "sds", "at", "sparra")) { | ||
return(FALSE) | ||
} | ||
|
||
return(TRUE) | ||
} | ||
|
||
|
||
#' Delayed Discharge period | ||
#' | ||
#' @description Get the period for Delayed Discharge | ||
#' | ||
#' @return The period for the Delayed Discharge file | ||
#' as MMMYY_MMMYY | ||
#' @export | ||
#' | ||
#' @family initialisation | ||
get_dd_period <- function() { | ||
"Jul16_Jun24" | ||
} | ||
|
||
|
||
#' Latest update | ||
#' | ||
#' @description Get the date of the latest update, e.g 'Jun_2022' | ||
|
@@ -10,6 +116,7 @@ latest_update <- function() { | |
"Sep_2024" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could automate this using |
||
} | ||
|
||
|
||
#' Previous update | ||
#' | ||
#' @param months_ago Number of months since the previous update | ||
|
@@ -51,19 +158,34 @@ previous_update <- function(months_ago = 3L, override = NULL) { | |
return(previous_update) | ||
} | ||
|
||
#' Delayed Discharge period | ||
|
||
#' Extract latest FY from end_date | ||
#' | ||
#' @description Get the period for Delayed Discharge | ||
#' @return fy in format "2024" | ||
#' @export | ||
#' | ||
#' @return The period for the Delayed Discharge file | ||
#' as MMMYY_MMMYY | ||
fy <- function() { | ||
# Latest FY | ||
fy <- phsmethods::extract_fin_year(end_date()) %>% substr(1, 4) | ||
} | ||
|
||
|
||
#' Extract latest quarter from end_date | ||
#' | ||
#' @return qtr in format "Q1" | ||
#' @export | ||
#' | ||
#' @family initialisation | ||
get_dd_period <- function() { | ||
"Jul16_Jun24" | ||
#' @examples | ||
qtr <- function() { | ||
# Latest Quarter | ||
qtr <- lubridate::quarter(end_date(), fiscal_start = 4) | ||
|
||
qtr <- stringr::str_glue("Q{qtr}") | ||
|
||
return(qtr) | ||
} | ||
|
||
|
||
#' The year list for slf to update | ||
#' | ||
#' @description Get the vector of years to update slf | ||
|
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could also automate this - will add an issue for both