Review ask

As a clinical trial statistician or programmer, challenge anything in this benchmark: describe a problem in Comments, or propose a fix with the Edit button on any source file.

  1. Task: Would a real study need this derivation, specified this way? Does it follow CDISC ADaM: variable names, controlled terms, record structure? Flag any rule that is ambiguous or that a sponsor would handle differently.
  2. Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
  3. Expected output: Would independent QC programming reproduce every value from these inputs and rules?

The other tabs beside Comments are background for assessment, not under review.

Summary

Lifecycle: reviewedEditUnder review
What this benchmark means
README.md

Goal: derive the start date of new anti-cancer therapy given during the study (NACTDT), its study day relative to the start of study treatment (NACTDY), and a flag marking subjects who started such therapy (NACTFL).

Input: one subject-level table carrying the treatment start date TRTSDT, alongside concomitant medication records carrying a category (CMCAT) and start date (CMSTDTC), plus procedure records carrying a category (PRCAT), subcategory (PRSCAT), and start date (PRSTDTC).

Variables:

  • NACTDT is the earlier of the first qualifying medication start (CMSTDTC with CMCAT equal to ON TREATMENT) and the first qualifying procedure start (PRSTDTC with PRCAT equal to CANCER RELATED and PRSCAT equal to ON TREATMENT); it is absent when the subject started no qualifying therapy during the study. Therapy recorded as PRIOR TREATMENT does not qualify, nor do procedures given for reasons other than the cancer. A qualifying record with no start date is skipped, and one that starts on the treatment start date itself counts, with study day 1.
  • NACTDY is the study day of NACTDT counted from TRTSDT, with the treatment start date itself as day 1; it is absent when NACTDT is absent.
  • NACTFL holds Y when NACTDT is present and is absent otherwise.

Note: a qualifying therapy must start on or after the treatment start date: each aggregate only considers records with CMSTDTC_IMP >= TRTSDT (or PRSTDTC >= TRTSDT), so a flagged therapy start always falls on or after the treatment start date by construction.

Note: the collected medication start CMSTDTC is text and may carry a partial date. The analysis-ready CMSTDTC_IMP completes it under a stated rule: a year-month start is completed to the 15th of that month, and a full date passes through unchanged. Subject 107's 2025-04 becomes 2025-04-15.

Inputs

Under review
3 source files

input/adsl.csv

Edit
7 rows
input/adsl.csv
STUDYIDUSUBJIDTRTSDT
YAMAA-012025-01-06
YAMAA-012025-01-13
YAMAA-012025-01-20
YAMAA-012025-02-03
YAMAA-012025-02-10
YAMAA-012025-03-03
YAMAA-012025-03-10

input/cm.csv

Edit
9 rows
input/cm.csv
STUDYIDUSUBJIDCMSEQCMCATCMSCATCMTRTCMSTDTCCMSTDTC_IMP
YAMAA-011ON TREATMENTCHEMOTHERAPYDOCETAXEL2025-03-102025-03-10
YAMAA-011PRIOR TREATMENTCHEMOTHERAPYCARBOPLATIN2024-11-042024-11-04
YAMAA-012ON TREATMENTCHEMOTHERAPYGEMCITABINE2025-05-052025-05-05
YAMAA-011PRIOR TREATMENTCHEMOTHERAPYCISPLATIN2024-10-222024-10-22
YAMAA-012ON TREATMENTCHEMOTHERAPYVINORELBINE2025-01-102025-01-10
YAMAA-011ON TREATMENTIMMUNOTHERAPYNIVOLUMAB2025-06-012025-06-01
YAMAA-012ON TREATMENTCHEMOTHERAPYPEMETREXED2025-04-152025-04-15
YAMAA-011ON TREATMENTIMMUNOTHERAPYPEMBROLIZUMAB——
YAMAA-011ON TREATMENTCHEMOTHERAPYTRASTUZUMAB2025-042025-04-15

input/pr.csv

Edit
5 rows
input/pr.csv
STUDYIDUSUBJIDPRSEQPRCATPRSCATPRTRTPRSTDTC
YAMAA-011CANCER RELATEDON TREATMENTTUMOUR RESECTION2025-02-20
YAMAA-011CANCER RELATEDON TREATMENTRADIOTHERAPY2025-04-02
YAMAA-011CANCER RELATEDPRIOR TREATMENTTUMOUR RESECTION2024-09-30
YAMAA-011CANCER RELATEDON TREATMENTRADIOTHERAPY2025-03-03
YAMAA-012OTHERON TREATMENTSKIN BIOPSY2025-03-05

Expected output

Under review
7 expected rows

expected/adsl.csv

Edit
7 rows
expected/adsl.csv
STUDYIDUSUBJIDTRTSDTNACTDTNACTDYNACTFL
YAMAA-012025-01-062025-02-2046Y
YAMAA-012025-01-132025-05-05113Y
YAMAA-012025-01-202025-04-0273Y
YAMAA-012025-02-03———
YAMAA-012025-02-102025-04-1565Y
YAMAA-012025-03-032025-03-031Y
YAMAA-012025-03-102025-04-1537Y
Shaded columns are derived— = missing value

Comments and assessment materials

Comments

Signed in with GitHub; saved in repository Discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADSLSTUDYIDStudy IdentifiercharacterCopy value from ADSL_RAW.STUDYID.Predecessor
ADSLUSUBJIDUnique Subject IdentifiercharacterCopy value from ADSL_RAW.USUBJID.Predecessor
ADSLTRTSDTDate of First Exposure to TreatmentnumericISO 8601Copy value from ADSL_RAW.TRTSDT.Predecessor
ADSLNACTDTNew Anti-Cancer Therapy Start DatenumericISO 8601Least of CMNACTDT and PRNACTDT.Derived
ADSLNACTDYNew Anti-Cancer Therapy Start Relative DaynumericCDISC study day of NACTDT against TRTSDT as day 1; there is no day zero.Derived
ADSLNACTFLNew Anti-Cancer Therapy FlagcharacterY"Y" when NACTDT IS NOT NULL; blank otherwise.Derived
VariablePermitted values
NACTFLY
VersionDateAuthorDescriptionReviewerSign-off
1.32026-09-29yamaa docs buildShow study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata
1.22026-09-29yamaa docs buildClassify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived
1.12026-09-29yamaa docs buildResolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML
1.0yamaa docs buildInitial generation from spec.yaml

Agent prompt

The request an agent receives with the input files; each tier states no more than the one above

prompts/adam-adsl-new-therapy/full.md

Edit
29 lines

Following CDISC ADaM standards, use the provided ADSL_RAW, CM, and PR datasets to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL

NACTDT is the earlier of the first qualifying medication start (a record with category ON TREATMENT) and the first qualifying procedure start (a record with category CANCER RELATED and subcategory ON TREATMENT). It has no value when the subject started no qualifying therapy during the study.

A qualifying therapy must start on or after the treatment start date: a record dated before it, a PRIOR TREATMENT record, and a procedure recorded for reasons other than the cancer never qualify, and a qualifying record with no start date is skipped. A therapy starting on the treatment start date itself counts.

Read the medication start from the completed start date, which fills a year-month start to the 15th of that month; a full date passes through unchanged.

NACTDY is the study day of NACTDT counted from TRTSDT, with the treatment start date itself as day 1; it has no value when NACTDT has none. NACTFL holds Y when NACTDT is present and has no value otherwise.

Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.

prompts/adam-adsl-new-therapy/conventions.md

Edit
10 lines

Following CDISC ADaM standards, use the provided ADSL_RAW, CM, and PR datasets to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL

NACTFL holds Y or has no value.

Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.

prompts/adam-adsl-new-therapy/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided ADSL_RAW, CM, and PR datasets to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL

Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.

yamaa code

Runs the yamaa specification; its result must match the expected output

run.R

Edit
4 lines
library(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadsl

run.py

Edit
4 lines
import yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadsl

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/adam-adsl-new-therapy/result.R

Edit
62 lines
# Reference solution for the yamaa benchmark adam-adsl-new-therapy (R track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.library(dplyr, warn.conflicts = FALSE)library(readr)adsl_raw <- read_csv(  "/app/input/adsl.csv",  col_types = cols(TRTSDT = col_date(), .default = col_character()))cm <- read_csv(  "/app/input/cm.csv",  col_types = cols(CMSTDTC_IMP = col_date(), .default = col_character()))pr <- read_csv(  "/app/input/pr.csv",  col_types = cols(PRSTDTC = col_date(), .default = col_character()))# A qualifying medication starts on or after treatment start; a record# with no start date is skipped. The completed start fills a year-month# to the 15th, so the IMP column is the comparison date.cm_min <- cm |>  inner_join(select(adsl_raw, STUDYID, USUBJID, TRTSDT), by = c("STUDYID", "USUBJID")) |>  filter(CMCAT == "ON TREATMENT", !is.na(CMSTDTC_IMP), CMSTDTC_IMP >= TRTSDT) |>  group_by(STUDYID, USUBJID) |>  summarise(CMNACTDT = min(CMSTDTC_IMP), .groups = "drop")# A qualifying procedure is cancer related and on treatment, also on or# after treatment start.pr_min <- pr |>  inner_join(select(adsl_raw, STUDYID, USUBJID, TRTSDT), by = c("STUDYID", "USUBJID")) |>  filter(    PRCAT == "CANCER RELATED", PRSCAT == "ON TREATMENT",    !is.na(PRSTDTC), PRSTDTC >= TRTSDT  ) |>  group_by(STUDYID, USUBJID) |>  summarise(PRNACTDT = min(PRSTDTC), .groups = "drop")adsl <- adsl_raw |>  left_join(cm_min, by = c("STUDYID", "USUBJID")) |>  left_join(pr_min, by = c("STUDYID", "USUBJID")) |>  mutate(    NACTDT = case_when(      !is.na(CMNACTDT) & !is.na(PRNACTDT) ~ pmin(CMNACTDT, PRNACTDT),      !is.na(CMNACTDT) ~ CMNACTDT,      !is.na(PRNACTDT) ~ PRNACTDT,      .default = as.Date(NA)    )  ) |>  mutate(    NACTDY = as.integer(NACTDT - TRTSDT) + 1L,    NACTFL = if_else(is.na(NACTDT), NA_character_, "Y")  ) |>  select(STUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL) |>  arrange(USUBJID)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")

solutions/adam-adsl-new-therapy/result.py

Edit
66 lines
# Reference solution for the yamaa benchmark adam-adsl-new-therapy (Python track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.from pathlib import Pathimport polars as pladsl_raw = pl.read_csv("/app/input/adsl.csv", infer_schema=False, null_values="").with_columns(    TRTSDT=pl.col("TRTSDT").str.to_date(strict=False),)cm = pl.read_csv("/app/input/cm.csv", infer_schema=False, null_values="").with_columns(    CMSTDTC_IMP=pl.col("CMSTDTC_IMP").str.to_date(strict=False),)pr = pl.read_csv("/app/input/pr.csv", infer_schema=False, null_values="").with_columns(    PRSTDTC=pl.col("PRSTDTC").str.to_date(strict=False),)# A qualifying medication starts on or after treatment start; a record# with no start date is skipped. The completed start fills a year-month# to the 15th, so the IMP column is the comparison date.cm_min = (    cm.join(adsl_raw.select("STUDYID", "USUBJID", "TRTSDT"), on=["STUDYID", "USUBJID"], how="left")    .filter(        (pl.col("CMCAT") == "ON TREATMENT")        & pl.col("CMSTDTC_IMP").is_not_null()        & (pl.col("CMSTDTC_IMP") >= pl.col("TRTSDT"))    )    .group_by(["STUDYID", "USUBJID"])    .agg(CMNACTDT=pl.col("CMSTDTC_IMP").min()))# A qualifying procedure is cancer related and on treatment, also on or# after treatment start.pr_min = (    pr.join(adsl_raw.select("STUDYID", "USUBJID", "TRTSDT"), on=["STUDYID", "USUBJID"], how="left")    .filter(        (pl.col("PRCAT") == "CANCER RELATED")        & (pl.col("PRSCAT") == "ON TREATMENT")        & pl.col("PRSTDTC").is_not_null()        & (pl.col("PRSTDTC") >= pl.col("TRTSDT"))    )    .group_by(["STUDYID", "USUBJID"])    .agg(PRNACTDT=pl.col("PRSTDTC").min()))adsl = (    adsl_raw.join(cm_min, on=["STUDYID", "USUBJID"], how="left")    .join(pr_min, on=["STUDYID", "USUBJID"], how="left")    .with_columns(        NACTDT=pl.min_horizontal("CMNACTDT", "PRNACTDT"),    )    .with_columns(        NACTDY=(pl.col("NACTDT") - pl.col("TRTSDT")).dt.total_days() + 1,        NACTFL=pl.when(pl.col("NACTDT").is_not_null())        .then(pl.lit("Y"))        .otherwise(None),    )    .select("STUDYID", "USUBJID", "TRTSDT", "NACTDT", "NACTDY", "NACTFL")    .sort("USUBJID"))Path("/app/output").mkdir(parents=True, exist_ok=True)adsl.write_csv("/app/output/adsl.csv", null_value="")

solutions/adam-adsl-new-therapy/result.sas

Edit
51 lines
/* opensas reference solution for the yamaa benchmark adam-adsl-new-therapy.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adsl;  length STUDYID USUBJID TRTSDT $1024;  infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. TRTSDT : $char1024.;run;data cm;  length STUDYID USUBJID CMCAT CMSCAT CMTRT CMSTDTC CMSTDTC_IMP $1024;  infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. CMSEQ CMCAT : $char1024. CMSCAT : $char1024. CMTRT : $char1024. CMSTDTC : $char1024. CMSTDTC_IMP : $char1024.;run;data pr;  length STUDYID USUBJID PRCAT PRSCAT PRTRT PRSTDTC $1024;  infile "/app/input/pr.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. PRSEQ PRCAT : $char1024. PRSCAT : $char1024. PRTRT : $char1024. PRSTDTC : $char1024.;run;data medication;  length therapy $10;  set cm;  if CMCAT='ON TREATMENT';  /* Use the supplied completed date, including its collected corrections. */  therapy='';  if lengthn(CMSTDTC_IMP)>=10 then therapy=substr(CMSTDTC_IMP,1,10);run;data procedure;  length therapy $10;  set pr;  if PRCAT='CANCER RELATED' and PRSCAT='ON TREATMENT';  therapy=substr(PRSTDTC,1,10);run;data therapies; set medication procedure; keep STUDYID USUBJID therapy; run;proc sql;  create table firsttherapy as select a.STUDYID,a.USUBJID,min(b.therapy) as NACTDT from adsl as a inner join therapies as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID where a.TRTSDT ne '' and b.therapy ne '' and b.therapy>=a.TRTSDT group by a.STUDYID,a.USUBJID;  create table joined as select a.*,b.NACTDT from adsl as a left join firsttherapy as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID;quit;data result;  length NACTFL $1; set joined;  NACTFL=''; NACTDY=.;  if not missing(NACTDT) then do; NACTFL='Y'; NACTDY=input(NACTDT,yymmdd10.)-input(TRTSDT,yymmdd10.)+1; end;run;proc sql;  create table final as select STUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL from result;quit;proc export data=final outfile="/app/output/adsl.csv" dbms=csv replace; run;