Adds the open flag and the dates a case has reached to a cleaned AFP table. No date is imputed.
Arguments
- cases
A cleaned AFP table, one row per case (from
clean_afp()).- known_rule
Which date marks a positive result as known:
"itd"(the default and the programme standard) or"hq".- pending_classes
Classification labels that mean the case is still pending. The default,
c("PENDING", "LAB PENDING"), is the programme standard and matchescalc_polio_indicators().- cols
A named list overriding the default column names, in the same style as
calc_polio_indicators(), for examplelist(cases = list(itd_date = "my_itd")). The keys this function reads fromcasesareclass("classification_all"),notification_date("notification_date"),itd_date("epi_date_itd_results_received"),hq_date("date_notificationto_hq") andisolation_date("epi_date_isolation_results_received").
Value
cases as a tibble with the columns is_open, positive,
notified, known and resolved added or replaced.
Details
The columns added are:
is_open: the case is still awaiting classification, as defined byafp_pending_open().positive: the case is classified and its classification names a wild poliovirus or a vaccine-derived poliovirus (it contains"WPV"or"VDPV", ignoring case).notified: the notification date.known: for a positive case only, the date the polio-positive result reached the programme. Underknown_rule = "itd"this is the date the ITD result was received, or the date of notification to headquarters where that is missing. Underknown_rule = "hq"the order is reversed. It isNAfor every case that is not positive.resolved: the date the case stopped being pending. It isNAwhile the case is open, equalsknownfor a positive case, and is the date the isolation result was received for any other classified case.
Examples
cases <- tibble::tibble(
classification_all = c("WPV1", "NPAFP", "PENDING"),
notification_date = as.Date("2025-01-05"),
epi_date_itd_results_received = as.Date(c("2025-02-01", NA, NA)),
date_notificationto_hq = as.Date(c("2025-02-03", NA, NA)),
epi_date_isolation_results_received = as.Date(c(NA, "2025-01-30", NA))
)
afp_pending_dates(cases)
#> # A tibble: 3 × 10
#> classification_all notification_date epi_date_itd_results_received
#> <chr> <date> <date>
#> 1 WPV1 2025-01-05 2025-02-01
#> 2 NPAFP 2025-01-05 NA
#> 3 PENDING 2025-01-05 NA
#> # ℹ 7 more variables: date_notificationto_hq <date>,
#> # epi_date_isolation_results_received <date>, is_open <lgl>, positive <lgl>,
#> # notified <date>, known <date>, resolved <date>
