Safety fix: grade_lab() now grades against published criteria

0.0.0.9000 shipped only a demonstration grading table in pharmaverseadam units, and nothing in the installed package said so. A user could grade a study with it believing it was NCI-CTCAE. It was not, and it never should have been used that way.

  • grade_lab() now defaults to grading = "ctcv5" and grades by calling admiral::derive_var_atoxgr_dir() and admiral::derive_var_atoxgr() with the criteria admiral ships as data. The toxicity logic is admiral’s; this package no longer implements any published standard itself. "ctcv4" (admiral::atoxgr_criteria_ctcv4), "ctcv5" (atoxgr_criteria_ctcv5), "ctcv5_uscv" (atoxgr_criteria_ctcv5_uscv, US conventional units) and "daids" (atoxgr_criteria_daids) are selectable, as is a sponsor-amended copy of any of them passed as a data frame.
  • Scope, and it is narrower than “CTCAE”. These are the laboratory toxicity criteria only. "ctcv5" covers 40 terms across 3 SOCs (Blood and lymphatic system disorders, Investigations, Metabolism and nutrition disorders). That is not the full NCI-CTCAE v5 term set: non-laboratory CTCAE terms are not present and cannot be graded by this package. A term not in the table returns NA, never "0".
  • Grading against criteria requires the criteria term on each record (ATOXDSCL / ATOXDSCH). This package does not guess terms from PARAMCD; merge your own lookup on first, as admiral’s ADLB template does. grade_lab() now checks up front that every variable the criteria reference (VAR_CHECK) is present and names the missing ones.
  • Input row order is restored after grading. admiral::derive_var_atoxgr_dir() returns rows regrouped by term, which silently breaks positional joins. Variable label attributes dropped by admiral’s internal bind_rows() are also restored, so the result still hands straight to xportr.
  • Measured against pharmaverseadam::adlb (83,652 rows), which admiral’s ADLB template grades with CTCAE v4.03: grade_lab(adlb, "ctcv4") reproduces its ATOXGR, ATOXGRL and ATOXGRH on 100.00% of rows. "ctcv5" agrees on 92.72% of all rows (97.10% of rows both sides grade); the difference is real and expected — Hypophosphatemia and Hyperglycemia were dropped in CTCAE v5 and the Creatinine increased criterion changed. "ctcv5_uscv" agrees on 74.78% because that dataset reports SI units, and "daids" grades nothing at all on it because DAIDS uses its own term names ("ALT, High"), not CTCAE terms.
  • The threshold-table feature is unchanged and still supported for sponsor criteria that are not one of the published sets, including the strict > THRESHOLD / < THRESHOLD boundary behaviour and monotonicity checking.
  • inst/extdata/grading_table.csv is renamed demo_grading_table.csv and is labelled a demo everywhere it appears. It is a threshold fixture in pharmaverseadam units, it is not NCI-CTCAE, and it must not be used to grade a study. It is retained only so the threshold path has a test fixture.
  • grading_table() gained a style attribute ("criteria" / "threshold") and its print() method states the scope limit for criteria tables and states that no published standard is implied by a threshold table.

Known limits in 0.1.0

  • Laboratory terms only; non-lab CTCAE terms are out of scope (see above).
  • No PARAMCD-to-term lookup is provided; ATOXDSCL/ATOXDSCH must already be populated. Terms are matched by exact string, so DAIDS criteria need DAIDS term names.
  • Unit matching is exact against the criteria UNIT_CHECK; a result in a unit the chosen table does not list grades to NA, not "0". Pick the table that matches your units ("ctcv5" for SI, "ctcv5_uscv" for US conventional).
  • "ctcv4" is CTCAE v4.03 as admiral encodes it. This package does not independently validate admiral’s transcription of any published standard.

Initial development version.

  • grade_lab() assigns laboratory toxicity grades from a grading table supplied as data. Derives ATOXGRL, ATOXGRH and the combined ATOXGR, which carries a low-direction toxicity as a negative grade, matching admiral::derive_var_atoxgr(). Missing results and parameters absent from the grading table stay missing rather than becoming grade 0; thresholds are strict, so a value exactly on a threshold is not graded.
  • grading_table() validates a grading table (directions, grades 1-4, duplicate rows, thresholds monotone within parameter and direction) and prints it.
  • collapse_ae_episodes() collapses adverse event records into episodes by interval merging against the running maximum end date, carrying earliest onset, latest resolution, worst severity, worst causality, record count and an ONGOING flag. Handles overlapping, adjacent, gapped and open-ended records, and keeps records with a missing onset date as their own episodes.
  • derive_pop_flags() assigns population flags from a rules table of flag names and condition expressions, applied in order so a flag can be used by later rules. An unevaluable condition errors naming the flag.
  • pop_rules() validates a rules table (names, duplicates, parsable conditions) and prints it.
  • sas_note() reports which SAS macro idiom each derivation replaces; the same text is in each function’s help page.
  • Example fixtures in inst/extdata so every example and test runs without study data; pharmaverseadam used as an optional realistic input.