diff --git a/R/dr.lab.functions.R b/R/dr.lab.functions.R index 36df2c88..85218a4a 100644 --- a/R/dr.lab.functions.R +++ b/R/dr.lab.functions.R @@ -578,7 +578,9 @@ clean_lab_data_regional <- function(lab_data, cli::cli_process_start("Filtering nonsensical dates") lab_data5 <- lab_data5 |> dplyr::filter( - (DateStoolCollected >= ParalysisOnsetDate | is.na(ParalysisOnsetDate)), + (is.na(DateStoolCollected) | + DateStoolCollected >= ParalysisOnsetDate | + is.na(ParalysisOnsetDate)), # (lubridate::year(DateFinalCellCultureResult) <= 2023 | is.na(DateFinalCellCultureResult)), # remove a blank specimen row !is.na(EPID) diff --git a/R/kpi.main.functions.R b/R/kpi.main.functions.R index 4bbd522e..27015a07 100644 --- a/R/kpi.main.functions.R +++ b/R/kpi.main.functions.R @@ -329,7 +329,7 @@ generate_kpi_template <- function(output_path, name, edav) { "# Obtaining shapefiles in long format ----", "# Ensure st.year is the year of your start date.", ctry_sf, dist_sf, "\n", - "# Cleaning lab data ----", + "# Use cleaned lab data ----", paste0("start_date <- ", start_date), paste0("end_date <- ", end_date), "\n", 'lab_data <- clean_lab_data(lab_data, start_date, end_date, raw_data$afp)\n', "# Generate GPSAP C1-C4 tables ----", diff --git a/R/kpi.table.functions.R b/R/kpi.table.functions.R index 5c4a882c..697a9afc 100644 --- a/R/kpi.table.functions.R +++ b/R/kpi.table.functions.R @@ -313,10 +313,9 @@ generate_wild_vdpv_summary <- function(raw_data, start_date, end_date, #' @returns `tibble` lab data with timeliness columns. #' #' @keywords internal -generate_kpi_lab_timeliness <- function(lab_data, start_date, end_date, afp_data) { +generate_kpi_lab_timeliness <- function(lab_data, start_date, end_date, afp_data = NULL) { start_date <- lubridate::as_date(start_date) end_date <- lubridate::as_date(end_date) - lab_data <- clean_lab_data(lab_data, start_date, end_date, afp_data) lab_data <- lab_data |> dplyr::mutate( diff --git a/inst/rmarkdown/templates/desk-review-template/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/desk-review-template/skeleton/skeleton.Rmd index a873ddd3..5b858d51 100644 --- a/inst/rmarkdown/templates/desk-review-template/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/desk-review-template/skeleton/skeleton.Rmd @@ -119,10 +119,8 @@ For ISS/eSURV data, it is advisable to take a look at the data before cleaning, ```{r data.cleaning} ctry.data <- clean_ctry_data(ctry.data) -lab_data <- clean_lab_data(lab_data, start_date, end_date, - ctry.data$afp.all.2, Sys.getenv("DR_COUNTRY") - ) -# NOTE: if lab data is cleaned, you may need to manually filter to the countries of interest +lab_data <- sirfunctions::edav_io("read", file_loc = get_constant("CLEANED_LAB_DATA")) |> + dplyr::filter(!is.na(EPID)) ctry.data$iss.data <- clean_iss_data(ctry.data$iss.data, start_date, end_date) ``` diff --git a/man/generate_kpi_lab_timeliness.Rd b/man/generate_kpi_lab_timeliness.Rd index 09803944..c22f2647 100644 --- a/man/generate_kpi_lab_timeliness.Rd +++ b/man/generate_kpi_lab_timeliness.Rd @@ -4,8 +4,7 @@ \alias{generate_kpi_lab_timeliness} \title{Generate KPI lab intervals} \usage{ -generate_kpi_lab_timeliness(lab_data, start_date, end_date, afp_data) -} +generate_kpi_lab_timeliness(lab_data, start_date, end_date, afp_data = NULL) \arguments{ \item{lab_data}{\code{tibble} Lab data containing information of ES or AFP samples.}