Skip to content

Commit

Permalink
Add check_year_valid to update_refs script
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennit07 committed Oct 29, 2024
1 parent e2482e9 commit 8064909
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 55 deletions.
57 changes: 57 additions & 0 deletions R/00-update_refs.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,63 @@ end_date <- function() {
}


#' 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
Expand Down
55 changes: 0 additions & 55 deletions R/check_year_valid.R

This file was deleted.

0 comments on commit 8064909

Please sign in to comment.