Skip to contents

Adds one logical column per component of stool collection, computed from the collection dates rather than the cleaned intervals, so a stool collected long after onset is still seen as late.

Usage

afp_stool_components(
  cases,
  collection_days = 14,
  min_days_apart = 1,
  adequacy = "polis_field",
  adequacy_args = list(),
  cols = list()
)

Arguments

cases

Cleaned AFP cases, one row per case (data.frame or tibble).

collection_days

Latest day after onset at which a stool counts as collected in time (default 14).

min_days_apart

Fewest days between the two collection dates for apart (default 1).

adequacy

Stool adequacy definition passed to afp_stool_adequacy() (default "polis_field", which the rise-afg stool collection page used).

adequacy_args

Named list of further arguments for afp_stool_adequacy(), for example list(adequate_value = "YES").

cols

Named list overriding default column names, in the style of calc_polio_indicators(), for example list(cases = list(stool1_condition = "s1_cond")). The defaults are the polished defaults plus the module columns listed under Details of calc_afp_timeliness().

Value

cases as a tibble with the seven columns above added; existing columns of the same names are replaced.

Details

  • two: both collection dates are recorded.

  • first_in_window: stool 1 was collected 0 to collection_days days after onset.

  • both_in_window: both stools were collected 0 to collection_days days after onset.

  • apart: both stools are recorded at least min_days_apart days apart.

  • adequate: the result of afp_stool_adequacy() under adequacy.

  • late: either stool was collected more than collection_days days after onset.

  • one_or_none: fewer than two collection dates are recorded.

Examples

cases <- tibble::tibble(
  paralysis_onset_date = as.Date("2025-03-01"),
  stool1collection_date = as.Date("2025-03-03"),
  stool2collection_date = as.Date(c("2025-03-04", NA)),
  adequate_stool_with_condition = c("Yes", "No")
)
afp_stool_components(cases)
#> # A tibble: 2 × 11
#>   paralysis_onset_date stool1collection_date stool2collection_date
#>   <date>               <date>                <date>               
#> 1 2025-03-01           2025-03-03            2025-03-04           
#> 2 2025-03-01           2025-03-03            NA                   
#> # ℹ 8 more variables: adequate_stool_with_condition <chr>, two <lgl>,
#> #   first_in_window <lgl>, both_in_window <lgl>, apart <lgl>, adequate <lgl>,
#> #   late <lgl>, one_or_none <lgl>