Skip to content

Commit

Permalink
Update process_extract_ae.R
Browse files Browse the repository at this point in the history
  • Loading branch information
lizihao-anu authored Oct 28, 2024
1 parent 4107720 commit 387fe86
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 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 @@ -216,19 +220,20 @@ process_extract_ae <- function(data, year, write_to_disk = TRUE) {
ae_cup_clean <- ae_cup_file %>%
# Remove any duplicates
dplyr::distinct(.data$record_keydate1,
.data$keytime1,
.data$case_ref_number,
.keep_all = TRUE
)
.data$keytime1,
.data$record_keydate2,
.data$keytime2,
.data$case_ref_number,
.keep_all = 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,
.data$record_keydate1,
Expand Down

0 comments on commit 387fe86

Please sign in to comment.