write(" o Manual corrections", stderr())
out <- list(to_correct_df, NULL, NULL) corrected_df <- NULL edited_records <- NULL discarded_edits <- NULL valid_edits <- NULL non_valid_edits <- NULL valid_is_not_empty <- FALSE valid_partial_disp <- FALSE valid_full_disp <- FALSE non_valid_is_not_empty <- FALSE non_valid_partial_disp <- FALSE non_valid_full_disp <- FALSE n_mc <- 0 mc_status_update <- ""
corrections_from_field <- c("correct_device_ids", "correct_spo2_meas1", "correct_spo2_meas2") is_not_from_field <- (!correction_type %in% corrections_from_field) deletions <- c("delete_training_data", "delete_day0_records", "delete_day7_records", "delete_day28_records", "delete_hospit_records", "delete_repeat_records") is_deletion <- (correction_type %in% deletions) multiple_uuids <- c("delete_day0_records", "edit_day0_child_ids_to_correct_duplicates", "convert_screening_from_day0_to_repeat") has_multiple_uuids <- (correction_type %in% multiple_uuids)
r if (is_not_from_field) { paste0('---') }
::: {custom-style="redparagraph"} Manual corrections :::
[Correction description:]{custom-style="underlined"} r mc_description
out <- timci::correct_device_ids(to_correct_df)
out <- timci::correct_day0_non_valid_facilities(to_correct_df)
out <- timci::delete_day0_records(to_correct_df, csv_prefix = "day0_training_deletion")
out <- timci::edit_day0_to_repeat(to_correct_df) # Parameters for the quality check following manual corrections qc_rule <- action_alert_no_modification
out <- timci::edit_day0_child_ids(to_correct_df, csv_prefix = "day0_childID_correction_inconsistent_facility_check1") # Parameters for the quality check following manual corrections qc_rule <- action_alert_no_modification
out <- timci::edit_day0_child_ids(to_correct_df, csv_prefix = "day0_childID_correction_inconsistent_facility_check2")
out <- timci::delete_day0_records(to_correct_df, csv_prefix = "day0_true_duplicate_deletion")
out <- timci::edit_day0_child_ids(to_correct_df, csv_prefix = "day0_duplicate_correction")
out <- timci::correct_day0_inconsistent_facilities(to_correct_df, csv_prefix = "day0_facility_correction1")
out <- timci::correct_day0_inconsistent_facilities(to_correct_df, csv_prefix = "day0_facility_correction2")
out <- timci::correct_day0_inconsistent_facilities(to_correct_df, csv_prefix = "day0_facility_correction3")
out <- timci::correct_spo2_values(to_correct_df, csv_prefix = "day0_spo2_meas1", meas = 1)
out <- timci::correct_spo2_values(to_correct_df, csv_prefix = "day0_spo2_meas2", meas = 2)
out <- timci::correct_day0_drug_data(to_correct_df, drug_data)
out <- timci::correct_day7_duplicates(to_correct_df, csv_prefix = "day7_non_valid_pid_correction")
out <- timci::correct_day7_duplicates(to_correct_df, csv_prefix = "day7_inconsistent_names_correction")
out <- timci::delete_day0_records(to_correct_df, csv_prefix = "day7_inconsistent_names_deletion")
out <- timci::correct_day28_duplicates(to_correct_df, csv_prefix = "day28_non_valid_pid_correction")
out <- timci::correct_day28_duplicates(to_correct_df, csv_prefix = "day28_inconsistent_names_correction")
out <- timci::delete_day0_records(to_correct_df, csv_prefix = "day28_inconsistent_names_deletion")
out <- timci::correct_hospit_ids(to_correct_df, csv_prefix = "hospit_non_valid_pid_correction")
out <- timci::correct_hospit_ids(to_correct_df, csv_prefix = "hospit_inconsistent_names_correction")
out <- timci::delete_day0_records(to_correct_df, csv_prefix = "hospit_inconsistent_names_deletion")
out <- timci::correct_repeat_ids(to_correct_df, csv_prefix = "day0_repeat_non_valid_pid_correction")
out <- timci::correct_repeat_ids(to_correct_df, csv_prefix = "day0_repeat_inconsistent_names_correction")
out <- timci::delete_repeat_records(to_correct_df, csv_prefix = "day0_repeat_inconsistent_names_deletion")
out <- timci::correct_spa_sco_fids(to_correct_df, csv_prefix = "spa_sco_facility_correction")
out <- timci::correct_tf_inconsistent_facilities(to_correct_df, csv_prefix = "tf_facility_correction")
corrected_df <- out[[1]] edited_records <- out[[2]] discarded_edits <- out[[3]]
edit_is_not_empty <- timci::is_not_empty(edited_records) discarded_is_not_empty <- timci::is_not_empty(discarded_edits)
cols <- colnames(edited_records) disp_cols <- c() if ( 'child_id' %in% cols ) { disp_cols <- c(disp_cols, "child_id") } if ( 'old_child_id' %in% cols ) { disp_cols <- c(disp_cols, "old_child_id") } disp_cols <- c(disp_cols, "uuid") if ( 'new_child_id' %in% cols ) { disp_cols <- c(disp_cols, "new_child_id") } if ( 'new_fid' %in% cols ) { disp_cols <- c(disp_cols, "new_fid") } n_mc <- nrow(edited_records)
valid_edits <- edited_records[edited_records$uuid %in% qc_reuse_df$uuid,] %>% distinct(uuid, .keep_all = TRUE) valid_is_not_empty <- timci::is_not_empty(valid_edits) non_valid_edits <- edited_records[!edited_records$uuid %in% qc_reuse_df$uuid,] %>% distinct(uuid, .keep_all = TRUE) non_valid_is_not_empty <- timci::is_not_empty(non_valid_edits)
uuid_cols <- grep("uuid", names(qc_reuse_df)) valid_edits <- edited_records[edited_records$uuid %in% unname((unlist(qc_reuse_df[colnames(qc_reuse_df[uuid_cols])]))),] valid_is_not_empty <- timci::is_not_empty(valid_edits) non_valid_edits <- edited_records[!edited_records$uuid %in% unname((unlist(qc_reuse_df[colnames(qc_reuse_df[uuid_cols])]))),] non_valid_is_not_empty <- timci::is_not_empty(non_valid_edits)
valid_partial_disp <- valid_is_not_empty & ( nrow(valid_edits) > 10 ) valid_full_disp <- valid_is_not_empty & ( nrow(valid_edits) <= 10 )
mc_status_update <- paste0('**', n_mc, '** record(s) manually edited in the ', db_name, ' database.')
mc_status_update <- paste0('**', n_mc, '** record(s) manually edited in the ', db_name, ' database: **', nrow(valid_edits), '** edits that corrected instances detected by the check and **', nrow(non_valid_edits),'** edits that corrected instances not detected by the check.')
mc_status_update <- paste0('**', n_mc, '** record(s) manually deleted in the ', db_name, ' database: **', nrow(valid_edits), '** deletions that corrected instances detected by the check and **', nrow(non_valid_edits),'** deletions that corrected instances not detected by the check.')
r mc_status_update
valid_edits %>% dplyr::select(disp_cols) %>% knitr::kable(row.names = FALSE, caption = "Corrected records detected by the check")
valid_edits %>% dplyr::select(disp_cols) %>% head(5) %>% knitr::kable(row.names = FALSE, caption = "Five first records detected by the check and corrected")
valid_edits %>% dplyr::select(disp_cols) %>% tail(5) %>% knitr::kable(row.names = FALSE, caption = "Five last records detected by the check and corrected")
non_valid_edits %>% dplyr::select(disp_cols) %>% knitr::kable(row.names = FALSE, caption = "Records NOT detected by the check and corrected")
discarded_edits %>% dplyr::select(disp_cols) %>% knitr::kable(row.names = FALSE, caption = "Corrections entered but NOT done")
write(" o Check after manual corrections", stderr())
r if (is_not_from_field) { paste0('---') }
r if (is_not_from_field) { paste0('::: {custom-style="redparagraph"}\n\nCheck after manual edits ', qc_idx, '\n\n:::')}
df <- corrected_df qc_export_label <- paste0(qc_export_label, "_after_manual_corrections") cat(knitr::knit_child('database_export_sub_quality_check.Rmd', envir = environment(), quiet = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.