Skip to content

Commit

Permalink
change joining with sc_demog_lookup to right_join and move person_id …
Browse files Browse the repository at this point in the history
…down
  • Loading branch information
lizihao-anu committed Mar 14, 2024
1 parent b829c63 commit c5ca6c1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions R/process_sc_all_alarms_telecare.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c5ca6c1

Please sign in to comment.