
Calculate the reasons AFP cases had inadequate stools
Source:R/afp_quality.R
calc_afp_specimen_reasons.RdAmong 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.
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
NULLfor 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 examplelist(adequate_value = "YES").- cols
Named list overriding default column names, in the style of
calc_polio_indicators(), for examplelist(cases = list(stool1_condition = "s1_cond")). The defaults are the polished defaults plus the module columns listed under Details ofcalc_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 thancollection_daysdays after onset) andone_or_none(fewer than two stools recorded).Numerator (
n): inadequate cases with the reason.Denominator (
inadequate): cases thatadequacyclasses as inadequate. Cases it cannot assess are left out.The percentage is
NAwhen 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