From 0ef0eadede6bd0473f0b72af4a48f1ef47378724 Mon Sep 17 00:00:00 2001 From: Zihao Li Date: Thu, 14 Mar 2024 11:46:18 +0000 Subject: [PATCH] change joining with sc_demog_lookup to right_join and move person_id down --- R/process_sc_all_alarms_telecare.R | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/R/process_sc_all_alarms_telecare.R b/R/process_sc_all_alarms_telecare.R index 0c24892d0..77877d584 100644 --- a/R/process_sc_all_alarms_telecare.R +++ b/R/process_sc_all_alarms_telecare.R @@ -73,18 +73,19 @@ process_sc_all_alarms_telecare <- function( convert_sc_sending_location_to_lca(sending_location) ) ] + + # RIGHT_JOIN with sc_demog_lookup + data <- data[sc_demog_lookup, on = .(sending_location, social_care_id)] + + # Replace social_care_id with latest if needed (assuming replace_sc_id_with_latest is a custom function) + data <- replace_sc_id_with_latest(data) + data$person_id <- paste0( data$sending_location, "-", data$social_care_id ) - # Join with sc_demog_lookup - data <- sc_demog_lookup[data, on = .(sending_location, social_care_id)] - - # Replace social_care_id with latest if needed (assuming replace_sc_id_with_latest is a custom function) - data <- replace_sc_id_with_latest(data) - # Deal with episodes that have a package across quarters data[, pkg_count := seq_len(.N), by = .( sending_location,