
Link stool specimens to AFP cases with the days to laboratory receipt
Source:R/afp_quality.R
afp_specimen_receipt.RdReturns one row per stool specimen of the supplied AFP cases, with the days
from collection to receipt in the laboratory and the case's administrative
unit. A specimen without a collection date is dropped. A receipt dated
before collection is treated as an entry error and its interval set to
NA. Each specimen takes the administrative unit of the first case row
with its EPID.
Usage
afp_specimen_receipt(
specimens,
cases,
level = "adm0",
from = NULL,
to = NULL,
cols = list()
)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.- 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().
See also
afp_specimen_rung() for the laboratory stage each specimen has
reached.
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", NA)),
date_stool_received_in_lab = as.Date(c("2025-03-09", NA, NA))
)
afp_specimen_receipt(specimens, cases)
#> # A tibble: 2 × 8
#> epid collected received days guid name collection_month level
#> <chr> <date> <date> <int> <chr> <chr> <date> <chr>
#> 1 E1 2025-03-02 2025-03-09 7 G0 Country 2025-03-01 adm0
#> 2 E1 2025-03-03 NA NA G0 Country 2025-03-01 adm0