
Calculate days from stool collection to laboratory receipt by area
Source:R/afp_quality.R
calc_afp_specimen_receipt_by_area.RdFor each administrative unit, the number of specimens received and
percentiles of the days from collection to receipt. Units with fewer than
min_received received specimens are left out. Rows are sorted from the
longest interval at the highest percentile in probs, then at the lowest.
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 (default
"adm1", province).- from, to
First and last onset date of the reporting window, or
NULLfor no bound.- probs
Named percentiles to report (default
c(p50 = 0.5, p75 = 0.75, p90 = 0.9)), as quantile type 7.- min_received
Fewest received specimens a unit needs to be listed (default 20).
- 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: level, guid, name,
received and one column per element of probs.
Examples
cases <- tibble::tibble(
epid = c("E1", "E2"),
adm1_guid = c("P1", "P2"),
adm1 = c("Prov A", "Prov B"),
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_by_area(specimens, cases, min_received = 1)
#> # A tibble: 2 × 7
#> level guid name received p50 p75 p90
#> <chr> <chr> <chr> <int> <dbl> <dbl> <dbl>
#> 1 adm1 P1 Prov A 1 7 7 7
#> 2 adm1 P2 Prov B 1 2 2 2