Skip to contents

Among cases whose stools were inadequate, the share with each of two reasons. A case can carry both, so the shares need not sum to 100.

Usage

calc_afp_specimen_reasons(
  cases,
  level = "adm0",
  from = NULL,
  to = NULL,
  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).

level

Administrative level to group by: "adm0" (country, the default), "adm1" (province) or "adm2" (district). Cases with no identifier at that level are left out.

from, to

First and last onset date of the reporting window, or NULL for no bound.

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

A tibble with one row per unit and reason: level, guid, name, reason, n, inadequate and pct. pct is on a scale of 0 to 100. Units with no inadequate case are left out.

Details

  • Reasons: late (a stool collected more than collection_days days after onset) and one_or_none (fewer than two stools recorded).

  • Numerator (n): inadequate cases with the reason.

  • Denominator (inadequate): cases that adequacy classes as inadequate. Cases it cannot assess are left out.

  • The percentage is NA when there are no inadequate cases.

Examples

cases <- tibble::tibble(
  adm0_guid = "G0",
  adm0 = "Country",
  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")
)
calc_afp_specimen_reasons(cases)
#> # A tibble: 2 × 7
#>   level guid  name    reason          n inadequate   pct
#>   <chr> <chr> <chr>   <chr>       <int>      <int> <dbl>
#> 1 adm0  G0    Country late            0          1     0
#> 2 adm0  G0    Country one_or_none     1          1   100