Skip to content

Commit

Permalink
WIP - add sc client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennit07 committed Aug 4, 2023
1 parent f6be11c commit 8aba847
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 4 deletions.
63 changes: 63 additions & 0 deletions R/process_tests_sc_client_lookup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#' Social care client lookup tests
#'
#' @description This script takes the processed processd social care client lookup and

Check failure on line 3 in R/process_tests_sc_client_lookup.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`processd` is not a recognized word. (unrecognized-spelling)
#' produces a test comparison with the previous data. This is written to
#' disk as a CSV.
#'
#' @inherit process_tests_acute
#'
#' @export
process_tests_sc_client_lookup <- function(data, year) {
old_data <- get_existing_data_for_tests(data)

comparison <- produce_test_comparison(
old_data = produce_tests_sc_client_lookup(old_data),
new_data = produce_tests_sc_client_lookup(data)
)

comparison %>%
write_tests_xlsx(sheet_name = "sc_client_lookup", year)

return(comparison)
}


#' Social care Client lookup Tests
#'
#' @description Produce the test for the social care Client all episodes
#'
#' @param data new or old data for testing summary flags
#' (data is from [get_source_extract_path()])
#' @param max_min_vars variables used when selecting 'min-max' from [calculate_measures()]
#' @return a dataframe with a count of each flag.
#'
#' @family social care test functions
produce_tests_sc_client_lookup <- function(data) {

test_flags <- data %>%
# create test flags
dplyr::mutate(
n_sc_living_alone_yes = .data$sc_living_alone == "Yes",
n_sc_living_alone_no = .data$sc_living_alone == "No",
n_sc_living_alone_not_known = .data$sc_living_alone == "Not Known",
n_sc_support_from_unpaid_carer_yes = .data$sc_support_from_unpaid_carer == "Yes",
n_sc_support_from_unpaid_carer_no = .data$sc_support_from_unpaid_carer == "No",
n_sc_support_from_unpaid_carer_not_known = .data$sc_support_from_unpaid_carer == "Not Known",
n_sc_social_worker_yes = .data$sc_social_worker == "Yes",
n_sc_social_worker_no = .data$sc_social_worker == "No",
n_sc_social_worker_not_known = .data$sc_social_worker == "Not Known",
n_sc_meals_yes = .data$sc_meals == "Yes",
n_sc_meals_no = .data$sc_meals == "No",
n_sc_meals_not_known = .data$sc_meals == "Not Known",
n_sc_day_care_yes = .data$sc_day_care == "Yes",
n_sc_day_care_no = .data$sc_day_care == "No",
n_sc_day_care_not_known = .data$sc_day_care == "Not Known",
) %>%
# remove variables that won't be summed
dplyr::select(.data$n_sc_living_alone_yes:.data$n_sc_day_care_not_known) %>%
# use function to sum new test flags
calculate_measures(measure = "sum")

return(test_flags)
}

21 changes: 21 additions & 0 deletions man/process_tests_sc_client_lookup.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/produce_sc_ch_episodes_tests.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/produce_sc_demog_lookup_tests.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/produce_source_at_tests.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/produce_source_sds_tests.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions man/produce_tests_sc_client_lookup.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8aba847

Please sign in to comment.