
Calculate days from stool collection to laboratory receipt by month
Source:R/afp_quality.R
calc_afp_specimen_receipt_monthly.RdFor each month of collection, the number of specimens, the number received
and percentiles of the days from collection to receipt among those
received. There is no threshold. Specimens not yet received are counted in
awaiting, since their intervals can only lengthen the month once they
arrive.
Arguments
- specimens
Cleaned human specimen table from
clean_human_spec(), one row per specimen.- cases
AFP cases whose specimens are wanted. Only specimens whose EPID appears here are kept, so filter
casesto the window first or usefromandto.- 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.- as_of
The reporting date, as a
Dateor a string thatas.Date()reads. Defaults toSys.Date(). Months are judged provisional against it.- probs
Named percentiles to report (default
c(p50 = 0.5, p75 = 0.75, p90 = 0.9)), as quantile type 7.- tail_prob
Percentile whose interval decides when a month is no longer provisional (default 0.9).
- 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 collection month: level,
guid, name, collection_month, specimens, received, one column
per element of probs, awaiting and provisional.
Details
A month is provisional while the overall tail_prob percentile interval
(default the 90th, across all months and units) has not yet passed since
its last day, as of as_of.
Examples
cases <- tibble::tibble(
epid = c("E1", "E2"),
adm0_guid = "G0",
adm0 = "Country",
paralysis_onset_date = as.Date("2025-03-01")
)
specimens <- tibble::tibble(
epid = c("E1", "E1", "E2"),
date_stool_collected = as.Date(
c("2025-03-02", "2025-03-03", "2025-03-04")
),
date_stool_received_in_lab = as.Date(c("2025-03-09", NA, "2025-03-06"))
)
calc_afp_specimen_receipt_monthly(specimens, cases, as_of = "2025-06-30")
#> # A tibble: 1 × 11
#> level guid name collection_month specimens received p50 p75 p90
#> <chr> <chr> <chr> <date> <int> <int> <dbl> <dbl> <dbl>
#> 1 adm0 G0 Country 2025-03-01 3 2 4.5 5.75 6.5
#> # ℹ 2 more variables: awaiting <int>, provisional <lgl>