Detection of multiple 28-disease episodes for the same children

write(" o Detection of multiple 28-disease episodes for the same children", stderr())
qc_df <- NULL
qc_df2 <- NULL
cleaned_df <- NULL
multiple_enrolment_data <- day0_data %>%
  dplyr::filter( prev_id != "" ) %>%
  timci::concatenate_names()
qc_df <- multiple_enrolment_data[order(multiple_enrolment_data$date_visit,
                                       na.last = TRUE,
                                       decreasing = FALSE),] %>%
  dplyr::rename(date = date_visit) %>% 
  dplyr::group_by(prev_id) %>% 
  dplyr::mutate(row_n = row_number()) %>%
  tidyr::pivot_wider(prev_id,
                     names_from = row_n,
                     values_from = c(date, child_id, name, mother_name, uuid))
qc_df <- day0_data %>%
  timci::concatenate_names() %>%
  dplyr::select(child_id, date_visit, name, mother_name) %>%
  dplyr::rename(date = date_visit) %>% 
  merge(qc_df,
        by.x = "child_id",
        by.y = "prev_id",
        all.y = TRUE)
timci::quality_check_export(df = qc_df,
                            idx = qc_multiple_enrolment_id,
                            label = "multiple_enrolments",
                            cdir = qc_dir,
                            description = "Multiple enrolments")
merge_cond <- timci::is_not_empty(qc_df) & "child_id_1" %in% colnames(qc_df)
qc_df1 <- qc_df %>% 
  dplyr::filter(child_id != child_id_1) %>%
  dplyr::select_if(~!(all(is.na(.)) | all(. == "")))
if ( timci::is_not_empty(qc_df1) ) {
  qc_df <- qc_df %>%
    dplyr::select(-date, -name, -mother_name) %>% 
    merge(qc_df1,
          by.x = "child_id_1",
          by.y = "child_id",
          all.x = TRUE)
}
timci::quality_check_export(df = qc_df,
                            idx = qc_multiple_enrolment_id,
                            label = "multiple_enrolments1",
                            cdir = qc_dir,
                            description = "Multiple enrolments")


Thaliehln/timci documentation built on April 8, 2024, 3:38 p.m.