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

Update process_extract_ae.R #1020

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Changes from all commits
Commits
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
15 changes: 12 additions & 3 deletions R/process_extract_ae.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ process_extract_ae <- function(data, year, write_to_disk = TRUE) {
col_type = readr::cols(
"ED Arrival Date" = readr::col_date(format = "%Y/%m/%d %T"),
"ED Arrival Time" = readr::col_time(""),
"ED Discharge Date" = readr::col_date(format = "%Y/%m/%d %T"),
"ED Discharge Time" = readr::col_time(""),
"ED Case Reference Number [C]" = readr::col_character(),
"CUP Marker" = readr::col_double(),
"CUP Pathway Name" = readr::col_character()
Expand All @@ -205,6 +207,8 @@ process_extract_ae <- function(data, year, write_to_disk = TRUE) {
dplyr::rename(
record_keydate1 = "ED Arrival Date",
keytime1 = "ED Arrival Time",
record_keydate2 = "ED Discharge Date",
keytime2 = "ED Discharge Time",
case_ref_number = "ED Case Reference Number [C]",
cup_marker = "CUP Marker",
cup_pathway = "CUP Pathway Name"
Expand All @@ -217,6 +221,8 @@ process_extract_ae <- function(data, year, write_to_disk = TRUE) {
# Remove any duplicates
dplyr::distinct(.data$record_keydate1,
.data$keytime1,
.data$record_keydate2,
.data$keytime2,
.data$case_ref_number,
.keep_all = TRUE
)
Expand All @@ -225,9 +231,12 @@ process_extract_ae <- function(data, year, write_to_disk = TRUE) {
# Join data--------------------------------------------

matched_ae_data <- outfile %>%
dplyr::left_join(
ae_cup_clean,
by = c("record_keydate1", "keytime1", "case_ref_number")
dplyr::left_join(ae_cup_clean,
by = c(
"record_keydate1", "keytime1",
"record_keydate2", "keytime2",
"case_ref_number"
)
) %>%
dplyr::arrange(
.data$chi,
Expand Down