
Calculate 60-day follow-up of inadequate AFP cases by month of onset
Source:R/afp_quality.R
calc_afp_followup.RdFor each month of onset in the window, and each unit at level, counts of
cases with inadequate stools that are due for follow-up and where each
stands. The window is the window_months months of onset ending with the
last month holding a case already due, that is the month of
as_of - due_days, so recent months with nothing yet due are not listed.
The case flags are those of afp_followup_status().
Usage
calc_afp_followup(
cases,
as_of = Sys.Date(),
window_months = 6,
level = "adm0",
due_days = 60,
on_time_days = c(60, 90),
adequacy = "followup",
adequacy_args = list(),
compatible_classes = "COMPATIBLE",
review_classes = c("NPAFP", "PENDING", "LAB PENDING"),
review_findings = c("Residual weakness/paralysis", "Died before follow-up",
"Lost to follow-up"),
review_max_age_months = 60,
review_min_doses = 3,
dose_unknown = 99,
cols = list()
)Arguments
- cases
Cleaned AFP cases, one row per case (data.frame or tibble).
- as_of
The reporting date, as a
Dateor a string thatas.Date()reads. Defaults toSys.Date(). Every day count runs to it.- window_months
Months of onset to report (default 6).
- 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.- due_days
Days after onset from which follow-up of an inadequate case is due (default 60).
- on_time_days
First and last day after onset at which a follow-up is on time (default
c(60, 90)).- adequacy
Stool adequacy definition passed to
afp_stool_adequacy()(default"followup").- adequacy_args
Named list of further arguments for
afp_stool_adequacy(), for examplelist(adequate_value = "YES").- compatible_classes
Classifications counted as compatible, matched ignoring case (default
"COMPATIBLE").- review_classes
Classifications the review screen keeps, matched ignoring case (default
c("NPAFP", "PENDING", "LAB PENDING")). A blank classification is always kept.- review_findings
Follow-up findings that keep a case under review (default residual weakness or paralysis, died before follow-up, and lost to follow-up, in POLIS wording).
- review_max_age_months
Age in months at and above which the screen drops a case (default 60).
- review_min_doses
Fewest doses that count as vaccinated when routine and campaign OPV counts are missing (default 3).
- dose_unknown
Dose value that means unknown (default 99).
- 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 month of onset: level, guid,
name, onset_month, the counts above and partial. Every month of the
window appears for every unit with a case, with zero counts where the
month has none.
Details
records: cases with onset in the month.inadequate: cases classed inadequate byadequacy.due: inadequate cases at leastdue_days(default 60) days past onset.completed: due cases followed up. Completion iscompleted / due.mature: due cases more thanon_time_days[2](default 90) days past onset, whose follow-up window has closed;mature_completedis those followed up. Completion read asmature_completed / matureis not pulled down by recent months.on_time: due cases followed upon_time_days[1]toon_time_days[2]days after onset. Timeliness ison_time / due.no_followupandoverdue: due cases not followed up, and those of them paston_time_days[2]days.compatibleandreview: compatible cases, and cases the review screen keeps.partial: the month's last day has not yet reacheddue_days.
This differs from fup_insa_cases_pct in calc_polio_indicators(), which
takes every case with code 0 under the "polished" adequacy rule as its
denominator whether or not follow-up is yet due, and counts a case as
followed up when a follow-up interval is recorded, at any day.
Examples
cases <- tibble::tibble(
adm0_guid = "G0",
adm0 = "Country",
paralysis_onset_date = as.Date(c("2025-03-10", "2025-04-02")),
onset_to_stool1 = c(20, 2),
onset_to_stool2 = c(21, 3),
stool1_to_stool2 = 1,
stool1condition = "Good",
stool2condition = "Good",
classification_all = "NPAFP",
followup_date = as.Date(c("2025-05-20", NA)),
followup_findings = NA_character_
)
calc_afp_followup(cases, as_of = "2025-07-15", window_months = 3)
#> # A tibble: 3 × 16
#> level guid name onset_month records inadequate due completed mature
#> <chr> <chr> <chr> <date> <int> <int> <int> <int> <int>
#> 1 adm0 G0 Country 2025-03-01 1 1 1 1 1
#> 2 adm0 G0 Country 2025-04-01 1 0 0 0 0
#> 3 adm0 G0 Country 2025-05-01 0 0 0 0 0
#> # ℹ 7 more variables: mature_completed <int>, on_time <int>, no_followup <int>,
#> # overdue <int>, compatible <int>, review <int>, partial <lgl>