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

786 duplicates of chi in individual files #791

Merged
merged 11 commits into from
Aug 14, 2023
18 changes: 15 additions & 3 deletions R/create_individual_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ create_individual_file <- function(
remove_blank_chi() %>%
add_cij_columns() %>%
add_all_columns() %>%
aggregate_ch_episodes_zihao() %>%
aggregate_ch_episodes() %>%
clean_up_ch(year) %>%
recode_gender() %>%
aggregate_by_chi() %>%
Expand Down Expand Up @@ -741,13 +741,25 @@ join_sc_client <- function(
sc_demographics %>%
dplyr::select("sending_location", "social_care_id", "chi"),
by = c("sending_location", "social_care_id")
)
) %>%
dplyr::mutate(count_not_known = rowSums(dplyr::select(., all_of(
c(
"sc_living_alone",
"sc_support_from_unpaid_carer",
"sc_social_worker",
"sc_meals",
"sc_day_care"
)
)) == "Not Known")) %>%
dplyr::arrange(chi, count_not_known) %>%
dplyr::distinct(chi, .keep_all = TRUE)

# Match on client variables by chi
individual_file <- individual_file %>%
dplyr::left_join(
join_client_demog,
by = "chi"
by = "chi",
relationship = "one-to-one"
) %>%
dplyr::select(!c("sending_location", "social_care_id", "sc_latest_submission"))

Expand Down
16 changes: 12 additions & 4 deletions R/process_tests_individual_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ produce_individual_file_tests <- function(data) {
create_demog_test_flags() %>%
create_hb_test_flags(.data$hbrescode) %>%
create_hb_cost_test_flags(.data$hbrescode, .data$health_net_cost) %>%
create_hscp_test_flags(.data$hscp2018) %>%
# keep variables for comparison
dplyr::select("valid_chi":dplyr::last_col()) %>%
dplyr::select(c("valid_chi":dplyr::last_col())) %>%
# use function to sum new test flags
calculate_measures(measure = "sum")

Expand All @@ -86,7 +85,9 @@ produce_individual_file_tests <- function(data) {

min_max_measures <- data %>%
calculate_measures(
vars = "health_net_cost",
vars = c(
"health_net_cost"
),
measure = "min-max"
)

Expand All @@ -99,11 +100,18 @@ produce_individual_file_tests <- function(data) {
measure = "sum"
)

dup_chi <- data.frame(
measure = "duplicated chi number",
value = duplicated(data$chi) %>%
sum() %>% as.integer()
)

join_output <- list(
test_flags,
all_measures,
min_max_measures,
sum_measures
sum_measures,
dup_chi
) %>%
purrr::reduce(dplyr::full_join, by = c("measure", "value"))

Expand Down
Loading