This creates the full folder structure and copies all required templates.
TRIAL_ABC/
TRIAL_ABC.Rproj
run_coregage.R
rules/
config/
rule_registry.xlsx <- fill in your checks here
project_config.R <- paths auto-filled
trial/ <- write trial-level check scripts here
study/ <- write study-level check scripts here
inputs/ <- drop domain data files here
outputs/
reports/ <- Excel reports written here
feedback/
DM/ MW/ SDTM/ ADAM/ <- reviewers place feedback here
Open rules/config/rule_registry.xlsx. It has two sheets:
Trial and Study.
| Column | Purpose |
|---|---|
| Category | Domain grouping e.g. Adverse Events |
| Subcategory | Check type e.g. Date Checks |
| ID | Unique check identifier e.g. AECHK001 |
| Active | Yes = run, No = skip |
| DM_Report | Yes = include in DM report |
| MW_Report | Yes = include in Medical Writing report |
| SDTM_Report | Yes = include in SDTM report |
| ADAM_Report | Yes = include in ADaM report |
| Rule_Set | Name of the .R file e.g. AE |
| Description | Plain English check description |
| Notes | Free text notes |
Copy rules/trial/Check_Template.R, rename it to match
your Rule_Set, and implement your check logic:
check_AE <- function(state, cfg) {
domains <- state$domains
active_rules <- state$active_rules
if (isTRUE(active_rules["AECHK001"])) {
AECHK001 <- domains$ae |>
dplyr::filter(is.na(AESEV) | trimws(AESEV) == "") |>
dplyr::mutate(
subj_id = USUBJID,
vis_id = NA_real_,
description = paste0("AESEV missing for: ", AETERM)
) |>
dplyr::select(subj_id, vis_id, description)
state <- collect_findings(state, AECHK001, id = "AECHK001")
}
state
}DM_issues.xlsx to the Data Manageroutputs/feedback/DM/source("run_coregage.R")