Skip to contents

Adds the open flag and the dates a case has reached to a cleaned AFP table. No date is imputed.

Usage

afp_pending_dates(
  cases,
  known_rule = c("itd", "hq"),
  pending_classes = c("PENDING", "LAB PENDING"),
  cols = list()
)

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 matches calc_polio_indicators().

cols

A named list overriding the default column names, in the same style as calc_polio_indicators(), for example list(cases = list(itd_date = "my_itd")). The keys this function reads from cases are class ("classification_all"), notification_date ("notification_date"), itd_date ("epi_date_itd_results_received"), hq_date ("date_notificationto_hq") and isolation_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 by afp_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. Under known_rule = "itd" this is the date the ITD result was received, or the date of notification to headquarters where that is missing. Under known_rule = "hq" the order is reversed. It is NA for every case that is not positive.

  • resolved: the date the case stopped being pending. It is NA while the case is open, equals known for 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>