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

Merge March 24 update into Master #933

Merged
merged 68 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
7d05ce9
Remove redundant code
Jennit07 Jan 16, 2024
d1718f0
Update documentation
Jennit07 Jan 16, 2024
6aec7b1
Style code
Jennit07 Jan 16, 2024
65e8caa
Reorder when we match on client variables
Jennit07 Jan 22, 2024
35bcddc
Update documentation
Jennit07 Jan 22, 2024
800083a
Style code
Jennit07 Jan 22, 2024
996db4c
Revert "Update logic to use end of Quarter"
Jennit07 Jan 22, 2024
d10376d
Style code
Jennit07 Jan 22, 2024
b8e1dd2
Update documentation
Jennit07 Jan 22, 2024
3591aca
add check comment (TO DO for this PR)
Jennit07 Jan 22, 2024
47769e3
Remove `check_quarter_format` function
Jennit07 Jan 22, 2024
85c22ad
Remove `check_quarter_format`
Jennit07 Jan 22, 2024
e4d9128
Add chi parameter to `create_demog_test_flags`
Jennit07 Jan 22, 2024
daa9ee7
Style code
Jennit07 Jan 22, 2024
702225f
Use CHI parameter for ep/indiv tests
Jennit07 Jan 22, 2024
d0fb3cd
Use CHI parameter for extract tests (chi)
Jennit07 Jan 22, 2024
bbf28dd
Change test sheet names to lowercase
Jennit07 Jan 23, 2024
b3d826b
Change date to lowercase
Jennit07 Jan 23, 2024
4ca03b7
Update documentation
Jennit07 Jan 23, 2024
c589786
Merge branch 'master' into mar-23-update
Jennit07 Jan 24, 2024
1e87385
Merge branch 'mar-23-update' into remove-redundant-code
Jennit07 Jan 24, 2024
0e69e50
Update documentation
Jennit07 Jan 24, 2024
0586dd7
Merge branch 'mar-23-update' into bug-client-vars
SwiftySalmon Jan 24, 2024
cbf5ae4
Update documentation
SwiftySalmon Jan 24, 2024
cde4b3d
Bug - match on client variables before NSU (#896)
SwiftySalmon Jan 24, 2024
63f6333
Merge branch 'mar-23-update' into check_snake_case
Jennit07 Jan 24, 2024
e6c83f0
Merge branch 'mar-23-update' into review_demog_test_flags
SwiftySalmon Jan 24, 2024
3233bfb
Review `create_demog_test_flags` function (#898)
SwiftySalmon Jan 24, 2024
3055d54
Style code
Jennit07 Jan 29, 2024
acb2639
Merge branch 'mar-23-update' into check_snake_case
Jennit07 Jan 29, 2024
287e782
Amend test workbooks to be in the format snake case (#903)
SwiftySalmon Jan 29, 2024
30cb567
Fix pick variables
Jennit07 Feb 5, 2024
00ae978
Merge branch 'mar-23-update' into remove-redundant-code
Jennit07 Feb 5, 2024
3b38160
Remove redundant code (#894)
SwiftySalmon Feb 6, 2024
d0712d1
Merge branch 'mar-23-update' into bug-service_use_cohort
SwiftySalmon Feb 6, 2024
744bbc0
SC Demographics and SDS (#900)
SwiftySalmon Feb 7, 2024
cd8b359
Sc all at speedup (#904)
lizihao-anu Feb 7, 2024
b1a9523
Add case_when statement for `high_cc` cohort
Jennit07 Feb 7, 2024
6829c1a
Bug - `high_cc` in demographic cohort showing `NAs` instead of `TRUE/…
Jennit07 Feb 12, 2024
c7a1400
added a casewhen to update property type description for homelessness
Feb 13, 2024
ea19220
Update documentation
SwiftySalmon Feb 13, 2024
a634ea7
Style code
SwiftySalmon Feb 13, 2024
c1f2a36
Merge branch 'mar-23-update' into hl1_property_type_description
SwiftySalmon Feb 13, 2024
842e616
Added property type description for homelessness (#912)
SwiftySalmon Feb 13, 2024
760e2e5
Merge branch 'mar-23-update' into bug-service_use_cohort
Jennit07 Feb 14, 2024
1defb2b
Bug - NSUs being assigned psychiatry in the service use cohort (#908)
SwiftySalmon Feb 14, 2024
14cde16
Bug - deal with missing variables (#914)
Jennit07 Feb 16, 2024
625402b
Bug - Fix get pop path failing and preventing the indiv file from run…
Jennit07 Feb 16, 2024
36c5e74
correct file hscp file path
Jennit07 Feb 16, 2024
63e2caf
Merge branch 'mar-23-update' into review_check_qtr_format
Jennit07 Feb 16, 2024
c684b81
Review `check_qtr_format` function (#897)
rchlv Feb 16, 2024
ad629b2
Update process_sc_all_home_care.R
lizihao-anu Feb 26, 2024
640548b
Update process_sc_all_alarms_telecare.R
lizihao-anu Feb 26, 2024
e0da70c
remove duplicate columns
lizihao-anu Feb 26, 2024
9699394
Fix targets (#892)
lizihao-anu Feb 27, 2024
aa83adb
Merge branch 'mar-23-update' into lizihao-anu-patch-1
lizihao-anu Feb 27, 2024
f5c7448
remove cases that start date is later than end date
lizihao-anu Feb 27, 2024
612a409
Update process_sc_all_home_care.R (#916)
SwiftySalmon Feb 27, 2024
b7e7138
Update Refs for March24 SLF update
Jennit07 Feb 27, 2024
6dab611
758 investigate extracts to identify areas of code which can be cut d…
lizihao-anu Feb 28, 2024
95241b8
Update homelessness completeness path
Jennit07 Mar 1, 2024
889f867
Update check_year_valid function
Jennit07 Mar 4, 2024
b829c63
920 issues with file permissions need constant monitoring (#921)
lizihao-anu Mar 6, 2024
c5ca6c1
change joining with sc_demog_lookup to right_join and move person_id …
lizihao-anu Mar 14, 2024
54b61a7
Merge branch 'master' into mar-23-update
Jennit07 Mar 19, 2024
3aa3198
Archive social care extracts (#927)
Jennit07 Mar 20, 2024
847e5ec
Update excel sg completeness tabs
Jennit07 Mar 21, 2024
2762e3d
Bug - HL1 filtering to east ayrshire data only in 22/23 (#931)
SwiftySalmon Mar 26, 2024
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
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ Encoding: UTF-8
Language: en-GB
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1

1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export(get_nsu_path)
export(get_pop_path)
export(get_practice_details_path)
export(get_readcode_lookup_path)
export(get_sandpit_extract_path)
export(get_sc_at_episodes_path)
export(get_sc_ch_episodes_path)
export(get_sc_client_lookup_path)
Expand Down
4 changes: 2 additions & 2 deletions R/00-update_refs.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#'
#' @family initialisation
latest_update <- function() {
"Dec_2023"
"Mar_2024"
}

#' Previous update
Expand All @@ -34,11 +34,11 @@

latest_update_date <- lubridate::my(latest_update())

previous_update_year <- lubridate::year(

Check warning on line 37 in R/00-update_refs.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/00-update_refs.R,line=37,col=3,[object_usage_linter] local variable 'previous_update_year' assigned but may not be used
latest_update_date - lubridate::period(months_ago, "months")
)

previous_update_month <- lubridate::month(

Check warning on line 41 in R/00-update_refs.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/00-update_refs.R,line=41,col=3,[object_usage_linter] local variable 'previous_update_month' assigned but may not be used
latest_update_date - lubridate::period(months_ago, "months"),
label = TRUE,
abbr = TRUE
Expand All @@ -61,7 +61,7 @@
#'
#' @family initialisation
get_dd_period <- function() {
"Jul16_Sep23"
"Jul16_Dec23"
}

#' The latest financial year for Cost uplift setting
Expand Down
2 changes: 1 addition & 1 deletion R/add_hri_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#' \itemize{
#' \item{keep_flag = 0 when resident is Scottish}
#' \item{keep_flag = 1 when resident is not Scottish}
#' \item{keep_flag = 2 when the postcode is missing or a dummy, and the gpprac is missing}

Check warning on line 7 in R/add_hri_variables.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/add_hri_variables.R,line=7,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 90 characters.
#' \item{keep_flag = 3 when the gpprac is not English and the postcode is missing}

Check warning on line 8 in R/add_hri_variables.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/add_hri_variables.R,line=8,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 82 characters.
#' \item{keep_flag = 4 when the gpprac is not English and the postcode is a dummy}

Check warning on line 9 in R/add_hri_variables.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/add_hri_variables.R,line=9,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 82 characters.
#' }
#' The intention is to only keep the records where keep_flag = 0
#'
Expand All @@ -22,20 +22,20 @@
# of the postcode
pc_areas <- slf_pc_lookup %>%
dplyr::mutate(
pc_area = stringr::str_match(postcode, "^[A-Z]{1,3}"),

Check warning on line 25 in R/add_hri_variables.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/add_hri_variables.R,line=25,col=36,[object_usage_linter] no visible binding for global variable 'postcode'
scot_flag = TRUE
) %>%
dplyr::distinct(pc_area, scot_flag)

Check warning on line 28 in R/add_hri_variables.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/add_hri_variables.R,line=28,col=21,[object_usage_linter] no visible binding for global variable 'pc_area'

Check warning on line 28 in R/add_hri_variables.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/add_hri_variables.R,line=28,col=30,[object_usage_linter] no visible binding for global variable 'scot_flag'

# Create a flag, 'keep_flag', to determine whether individuals are Scottish
# residents or not
return_data <- data %>%
dplyr::mutate(pc_area = stringr::str_match(postcode, "^[A-Z]{1,3}")) %>%

Check warning on line 33 in R/add_hri_variables.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/add_hri_variables.R,line=33,col=48,[object_usage_linter] no visible binding for global variable 'postcode'
dplyr::left_join(pc_areas, by = "pc_area") %>%
dplyr::mutate(
dummy_postcode = .data$postcode %in% c("BF010AA", "NF1 1AB", "NK010AA") |
stringr::str_sub(.data$postcode, 1, 4) %in% c("ZZ01", "ZZ61"),
eng_prac = .data$gpprac %in% c(99942, 99957, 99961, 99976, 99981, 99995, 99999),

Check warning on line 38 in R/add_hri_variables.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/add_hri_variables.R,line=38,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 86 characters.
scottish_resident = dplyr::case_when(
.data$scot_flag ~ 0L,
(is_missing(.data$postcode) | .data$dummy_postcode) & is.na(.data$gpprac) ~ 2L,
Expand Down Expand Up @@ -82,7 +82,7 @@
"mh_episodes",
"gls_episodes",
"op_newcons_attendances",
# op_newcons_dnas,
"op_newcons_dnas",
"ae_attendances",
"pis_paid_items",
"ooh_cases"
Expand Down
2 changes: 1 addition & 1 deletion R/add_keep_population_flag.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
} else {
## Obtain the population estimates for Locality AgeGroup and Gender.
pop_estimates <-
readr::read_rds(get_datazone_pop_path("DataZone2011_pop_est_2011_2021.rds")) %>%
readr::read_rds(get_pop_path(type = "datazone")) %>%
dplyr::select(year, datazone2011, sex, age0:age90plus)

# Step 1: Obtain the population estimates for Locality, AgeGroup, and Gender
Expand Down Expand Up @@ -105,7 +105,7 @@
) %>%
dplyr::filter(keep_nsu == 1L) %>%
dplyr::ungroup() %>%
dplyr::select(-flag_to_remove)

Check notice on line 108 in R/add_keep_population_flag.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`Line` matches candidate pattern `(?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})` (candidate-pattern)

# step 3: match the flag back onto the slf
individual_file <- individual_file %>%
Expand Down
7 changes: 4 additions & 3 deletions R/aggregate_by_chi.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @importFrom data.table .SD
#'
#' @inheritParams create_individual_file
aggregate_by_chi <- function(episode_file, exclude_sc_var = FALSE) {
aggregate_by_chi <- function(episode_file, year, exclude_sc_var = FALSE) {
cli::cli_alert_info("Aggregate by CHI function started at {Sys.time()}")

# Convert to data.table
Expand Down Expand Up @@ -89,6 +89,7 @@ aggregate_by_chi <- function(episode_file, exclude_sc_var = FALSE) {
"episodes",
"beddays",
"cost",
"_dnas",
"attendances",
"attend",
"contacts",
Expand All @@ -109,8 +110,7 @@ aggregate_by_chi <- function(episode_file, exclude_sc_var = FALSE) {
vars_start_with(
episode_file,
"sds_option"
),
"health_net_cost_inc_dnas"
)
)
cols4 <- cols4[!(cols4 %in% "ch_cis_episodes")]
if (exclude_sc_var) {
Expand Down Expand Up @@ -187,6 +187,7 @@ aggregate_by_chi <- function(episode_file, exclude_sc_var = FALSE) {
individual_file_cols5[, chi := NULL],
individual_file_cols6[, chi := NULL]
)
individual_file <- individual_file[, year := year]

# convert back to tibble
return(dplyr::as_tibble(individual_file))
Expand Down
4 changes: 1 addition & 3 deletions R/calculate_stay.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ calculate_stay <- function(year, start_date, end_date, sc_qtr = NULL) {
if (anyNA(sc_qtr)) {
cli::cli_abort("Some of the submitted quarters are missing")
}
# else {
# sc_qtr <- check_quarter_format(sc_qtr)
# }

# Set Quarters
qtr_end <- lubridate::add_with_rollback(
Expand All @@ -51,6 +48,7 @@ calculate_stay <- function(year, start_date, end_date, sc_qtr = NULL) {
lubridate::period(1L, "days")
)

# check logic here for care home methodology
dummy_end_date <- dplyr::case_when(
# If end_date is not missing use the end date
!is.na(end_date) ~ end_date,
Expand Down
2 changes: 1 addition & 1 deletion R/check_year_valid.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ check_year_valid <- function(
return(FALSE)
} else if (year >= "2425" && type %in% "sparra") {
return(FALSE)
} else if (year >= "2324" && type %in% c("ch", "hc", "sds", "at")) {
} else if (year >= "2425" && type %in% c("ch", "hc", "sds", "at")) {
return(FALSE)
}

Expand Down
10 changes: 5 additions & 5 deletions R/create_demog_test_flags.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
#' @description Create the demographic flags for testing
#'
#' @param data a dataframe containing demographic variables e.g. chi
#' @param chi Specify chi or anon_chi.
#'
#' @return a dataframe with flag (1 or 0) for each demographic variable.
#' Missing value flag from [is_missing()]
#'
#' @family flag functions
create_demog_test_flags <- function(data) {
create_demog_test_flags <- function(data, chi = c(chi, anon_chi)) {
data %>%
dplyr::arrange(.data$chi) %>%
dplyr::arrange({{ chi }}) %>%
# create test flags
dplyr::mutate(
valid_chi = phsmethods::chi_check(.data$chi) == "Valid CHI",
unique_chi = dplyr::lag(.data$chi) != .data$chi,
n_missing_chi = is_missing(.data$chi),
unique_chi = dplyr::lag({{ chi }}) != {{ chi }},
n_missing_chi = is_missing({{ chi }}),
n_males = .data$gender == 1L,
n_females = .data$gender == 2L,
n_postcode = !is.na(.data$postcode) | !.data$postcode == "",
Expand Down
11 changes: 7 additions & 4 deletions R/create_demographic_lookup.R
Original file line number Diff line number Diff line change
Expand Up @@ -344,18 +344,21 @@ assign_d_cohort_high_cc <- function(dementia,
liver,
cancer,
spec) {
high_cc <-
high_cc <- dplyr::case_when(
spec == "G5" ~ TRUE,
# FOR FUTURE: PhysicalandSensoryDisabilityClientGroup or LearningDisabilityClientGroup = "Y",
# then high_cc_cohort = TRUE
# FOR FUTURE: Care home removed, here's the code: .data$recid = "CH" & age < 65
rowSums(dplyr::pick(c(
(rowSums(dplyr::pick(c(
"dementia",
"hefailure",
"refailure",
"liver",
"cancer"
)), na.rm = TRUE) >= 1L |
spec == "G5"
)), na.rm = TRUE) >= 1L) ~ TRUE,
.default = FALSE
)

return(high_cc)
}

Expand Down
10 changes: 7 additions & 3 deletions R/create_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ create_episode_file <- function(
"mar_beddays"
)
) %>%
# match on sc client variables
join_sc_client(year, sc_client = sc_client, file_type = "episode") %>%
# Check chi is valid using phsmethods function
# If the CHI is invalid for whatever reason, set the CHI to NA
dplyr::mutate(
Expand Down Expand Up @@ -135,15 +137,15 @@ create_episode_file <- function(
year,
slf_deaths_lookup
) %>%
join_sc_client(year, sc_client = sc_client, file_type = "episode") %>%
load_ep_file_vars(year)

if (!check_year_valid(year, type = c("ch", "hc", "at", "sds"))) {
episode_file <- episode_file %>%
dplyr::mutate(
ch_chi_cis = NA,
sc_id_cis = NA,
ch_sc_id_cis = NA,
ch_name = NA,
ch_postcode = NA,
ch_adm_reason = NA,
ch_provider = NA,
ch_nursing = NA,
Expand All @@ -158,7 +160,9 @@ create_episode_file <- function(
hc_cost_q4 = NA,
hc_provider = NA,
hc_reablement = NA,
sds_option_4 = NA,
person_id = NA,
sc_latest_submission = NA,
sc_send_lca = NA,
sc_living_alone = NA,
sc_support_from_unpaid_carer = NA,
sc_social_worker = NA,
Expand Down
12 changes: 7 additions & 5 deletions R/create_individual_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ create_individual_file <- function(
))) %>%
remove_blank_chi() %>%
add_cij_columns() %>%
add_all_columns()
add_all_columns(year = year)

if (!check_year_valid(year, type = c("ch", "hc", "at", "sds"))) {
individual_file <- individual_file %>%
Expand All @@ -82,7 +82,7 @@ create_individual_file <- function(
individual_file <- individual_file %>%
aggregate_ch_episodes() %>%
clean_up_ch(year) %>%
aggregate_by_chi(exclude_sc_var = FALSE)
aggregate_by_chi(year = year, exclude_sc_var = FALSE)
}

individual_file <- individual_file %>%
Expand Down Expand Up @@ -202,7 +202,7 @@ add_cij_columns <- function(episode_file) {
#' of prefixed column names created based on some condition.
#' @family individual_file
#' @inheritParams create_individual_file
add_all_columns <- function(episode_file) {
add_all_columns <- function(episode_file, year) {
cli::cli_alert_info("Add all columns function started at {Sys.time()}")

episode_file <- episode_file %>%
Expand Down Expand Up @@ -483,8 +483,10 @@ add_ch_columns <- function(episode_file, prefix, condition) {
ch_ep_end = dplyr::if_else(
eval(condition),
.data$record_keydate2,
lubridate::NA_Date_ ),
# If end date is missing use the first day of next FY quarter
lubridate::NA_Date_
),
# check logic here for care home methodology
# If end date is missing use the end of the FY quarter
ch_ep_end = dplyr::if_else(
eval(condition) & is.na(.data$ch_ep_end),
start_next_fy_quarter(.data$sc_latest_submission),
Expand Down
8 changes: 7 additions & 1 deletion R/create_service_use_lookup.R
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,13 @@ assign_cohort_names <- function(data) {
# Situation where no cost is greater than another,
# so the maximum is the same as the mean
.data$cost_max == rowSums(
dplyr::pick("psychiatry_cost":"residential_care_cost")
dplyr::pick(c(
"psychiatry_cost", "maternity_cost", "geriatric_cost",
"elective_inpatient_cost", "limited_daycases_cost",
"routine_daycase_cost", "single_emergency_cost",
"multiple_emergency_cost", "prescribing_cost",
"outpatient_cost", "ae2_cost", "residential_care_cost"
))
) / 12.0 ~ "Unassigned",
.data$cost_max == .data$psychiatry_cost ~ "Psychiatry",
.data$cost_max == .data$maternity_cost ~ "Maternity",
Expand Down
8 changes: 4 additions & 4 deletions R/fix_sc_dates.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @return A date vector with replaced end dates
fix_sc_start_dates <- function(start_date, period_start) {
# Fix sds_start_date is missing by setting start_date to be the start of
# financial year
# financial period
start_date <- dplyr::if_else(
is.na(start_date),
period_start,
Expand All @@ -30,12 +30,12 @@ fix_sc_start_dates <- function(start_date, period_start) {
#' @param period Social care latest submission period.
#'
#' @return A date vector with replaced end dates
fix_sc_end_dates <- function(start_date, end_date, period) {
fix_sc_end_dates <- function(start_date, end_date, period_end_date) {
# Fix sds_end_date is earlier than sds_start_date by setting end_date to be
# the end of financial year
end_date <- dplyr::if_else(
start_date > end_date,
end_fy(year = stringr::str_sub(period, 1L, 4L), "alternate"),
period_end_date,
end_date
)

Expand All @@ -57,7 +57,7 @@ fix_sc_end_dates <- function(start_date, end_date, period) {
#' @return A date vector with replaced end dates
fix_sc_missing_end_dates <- function(end_date, period_end) {
# Fix sds_end_date is earlier than sds_start_date by setting end_date to be
# the end of financial year
# the end of financial period
end_date <- dplyr::if_else(
is.na(end_date),
period_end,
Expand Down
33 changes: 0 additions & 33 deletions R/get_fy_quarter_dates.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
start_fy_quarter <- function(quarter) {
quarter_unique <- unique(quarter)

#check_quarter_format(quarter)

cal_quarter_date_unique <- lubridate::yq(quarter_unique)

fy_quarter_date_unique <- lubridate::add_with_rollback(
Expand Down Expand Up @@ -47,8 +45,6 @@ start_fy_quarter <- function(quarter) {
end_fy_quarter <- function(quarter) {
quarter_unique <- unique(quarter)

#check_quarter_format(quarter)

cal_quarter_date_unique <- lubridate::yq(quarter_unique)

fy_quarter_date_unique <- lubridate::add_with_rollback(
Expand Down Expand Up @@ -80,8 +76,6 @@ end_fy_quarter <- function(quarter) {
start_next_fy_quarter <- function(quarter) {
quarter_unique <- unique(quarter)

#check_quarter_format(quarter)

cal_quarter_date_unique <- lubridate::yq(quarter_unique)

fy_quarter_date_unique <- lubridate::add_with_rollback(
Expand Down Expand Up @@ -112,8 +106,6 @@ start_next_fy_quarter <- function(quarter) {
end_next_fy_quarter <- function(quarter) {
quarter_unique <- unique(quarter)

#check_quarter_format(quarter)

cal_quarter_date_unique <- lubridate::yq(quarter_unique)

fy_quarter_date_unique <- lubridate::add_with_rollback(
Expand All @@ -128,28 +120,3 @@ end_next_fy_quarter <- function(quarter) {

return(end_next_fy_quarter)
}

#' Check quarter format
#'
#' @inheritParams start_fy_quarter
#'
#' @return `quarter` invisibly if no issues were found
#'
#' @family date functions
# check_quarter_format <- function(quarter) {
# stopifnot(typeof(quarter) == "character")
#
# if (any(
# stringr::str_detect(quarter, "^\\d{4}Q[1-4]$", negate = TRUE),
# na.rm = TRUE
# )) {
# cli::cli_abort(
# c("{.var quarter} must be in the format {.val YYYYQx}
# where {.val x} is the quarter number.",
# "v" = "For example {.val 2019Q1}."
# )
# )
# }
#
# return(invisible(quarter))
# }
2 changes: 1 addition & 1 deletion R/get_lookup_paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ get_pop_path <- function(file_name = NULL,
"intzone" ~ stringr::str_glue("IntZone_pop_est_2011_\\d+?\\.{ext}")
)

datazone_pop_path <- get_file_path(
pop_path <- get_file_path(
directory = pop_dir,
file_name = file_name,
ext = ext,
Expand Down
Loading
Loading