Skip to contents

Returns one row per stool specimen with its collection, receipt and result dates and the rung of the laboratory ladder it has reached. The rungs are:

Usage

afp_specimen_rung(specimens, cols = list())

Arguments

specimens

A cleaned human-specimen table, one row per specimen (from clean_human_spec()).

cols

A named list overriding the default column names, for example list(specimens = list(date_collected = "my_date")). The keys this function reads from specimens are epid ("epid"), date_collected ("date_stool_collected"), date_received ("date_stool_received_in_lab"), culture_date ("date_final_cell_culture_results"), itd_date ("date_itd_result_reported") and sequencing_date ("dateof_sequencing").

Value

A tibble with one row per specimen and the columns epid, collected, received, resulted (dates) and rung (integer 0 to 3).

Details

  • 0: no collection date is recorded.

  • 1, collected: the stool collection date is recorded, and no later date.

  • 2, received: the date the stool was received in the laboratory is recorded, and no result date.

  • 3, resulted: a result date is recorded. A date at any of the final cell culture result, the ITD result or the sequencing date counts, since each means the laboratory has tested the specimen.

A specimen takes the highest rung whose date is present, so a received date without a collection date still places the specimen on rung 2.

See also

afp_specimen_receipt() for the days from collection to laboratory receipt of each specimen; afp_pending_stage() for the rung of a case.

Examples

spec <- tibble::tibble(
  epid = c("A-1", "A-2", "A-3"),
  date_stool_collected = as.Date(c("2025-01-02", "2025-01-02", NA)),
  date_stool_received_in_lab = as.Date(c(NA, "2025-01-06", NA)),
  date_final_cell_culture_results = as.Date(NA),
  date_itd_result_reported = as.Date(c(NA, "2025-01-20", NA)),
  dateof_sequencing = as.Date(NA)
)
afp_specimen_rung(spec)
#> # A tibble: 3 × 5
#>   epid  collected  received   resulted    rung
#>   <chr> <date>     <date>     <date>     <int>
#> 1 A-1   2025-01-02 NA         NA             1
#> 2 A-2   2025-01-02 2025-01-06 2025-01-20     3
#> 3 A-3   NA         NA         NA             0