As a clinical trial statistician or programmer, answer three short questions in Your review: the task, the inputs and outputs, and the AI-assisted review. Agreeing with all three approves this benchmark; disagreeing with any needs a comment. Propose a fix with the Edit button on any source file, or add it to your comments.
We suggest spending no more than 5 minutes on a review. The other tabs beside Your review are background for assessment, not under review.
Summary
README.mdPublic entries: Python and R. Passing coverage requires an installed inventory.
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:
NACTDTis the earlier of the first qualifying medication start (CMSTDTCwithCMCATequal toON TREATMENT) and the first qualifying procedure start (PRSTDTCwithPRCATequal toCANCER RELATEDandPRSCATequal toON TREATMENT); it is absent when the subject started no qualifying therapy during the study. Therapy recorded asPRIOR TREATMENTdoes 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.NACTDYis the study day ofNACTDTcounted fromTRTSDT, with the treatment start date itself as day 1; it is absent whenNACTDTis absent.NACTFLholdsYwhenNACTDTis 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 review3 source filesinput/adsl.csv
Edit7 rows| STUDYID | USUBJID | TRTSDT |
|---|---|---|
| YAMAA-01 | 2025-01-06 | |
| YAMAA-01 | 2025-01-13 | |
| YAMAA-01 | 2025-01-20 | |
| YAMAA-01 | 2025-02-03 | |
| YAMAA-01 | 2025-02-10 | |
| YAMAA-01 | 2025-03-03 | |
| YAMAA-01 | 2025-03-10 |
input/cm.csv
Edit9 rows| STUDYID | USUBJID | CMSEQ | CMCAT | CMSCAT | CMTRT | CMSTDTC | CMSTDTC_IMP |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | ON TREATMENT | CHEMOTHERAPY | DOCETAXEL | 2025-03-10 | 2025-03-10 | |
| YAMAA-01 | 1 | PRIOR TREATMENT | CHEMOTHERAPY | CARBOPLATIN | 2024-11-04 | 2024-11-04 | |
| YAMAA-01 | 2 | ON TREATMENT | CHEMOTHERAPY | GEMCITABINE | 2025-05-05 | 2025-05-05 | |
| YAMAA-01 | 1 | PRIOR TREATMENT | CHEMOTHERAPY | CISPLATIN | 2024-10-22 | 2024-10-22 | |
| YAMAA-01 | 2 | ON TREATMENT | CHEMOTHERAPY | VINORELBINE | 2025-01-10 | 2025-01-10 | |
| YAMAA-01 | 1 | ON TREATMENT | IMMUNOTHERAPY | NIVOLUMAB | 2025-06-01 | 2025-06-01 | |
| YAMAA-01 | 2 | ON TREATMENT | CHEMOTHERAPY | PEMETREXED | 2025-04-15 | 2025-04-15 | |
| YAMAA-01 | 1 | ON TREATMENT | IMMUNOTHERAPY | PEMBROLIZUMAB | — | — | |
| YAMAA-01 | 1 | ON TREATMENT | CHEMOTHERAPY | TRASTUZUMAB | 2025-04 | 2025-04-15 |
input/pr.csv
Edit5 rows| STUDYID | USUBJID | PRSEQ | PRCAT | PRSCAT | PRTRT | PRSTDTC |
|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | CANCER RELATED | ON TREATMENT | TUMOUR RESECTION | 2025-02-20 | |
| YAMAA-01 | 1 | CANCER RELATED | ON TREATMENT | RADIOTHERAPY | 2025-04-02 | |
| YAMAA-01 | 1 | CANCER RELATED | PRIOR TREATMENT | TUMOUR RESECTION | 2024-09-30 | |
| YAMAA-01 | 1 | CANCER RELATED | ON TREATMENT | RADIOTHERAPY | 2025-03-03 | |
| YAMAA-01 | 2 | OTHER | ON TREATMENT | SKIN BIOPSY | 2025-03-05 |
Expected output
Under review7 expected rowsexpected/adsl.csv
Edit7 rows| STUDYID | USUBJID | TRTSDT | NACTDT | NACTDY | NACTFL |
|---|---|---|---|---|---|
| YAMAA-01 | 2025-01-06 | 2025-02-20 | 46 | Y | |
| YAMAA-01 | 2025-01-13 | 2025-05-05 | 113 | Y | |
| YAMAA-01 | 2025-01-20 | 2025-04-02 | 73 | Y | |
| YAMAA-01 | 2025-02-03 | — | — | — | |
| YAMAA-01 | 2025-02-10 | 2025-04-15 | 65 | Y | |
| YAMAA-01 | 2025-03-03 | 2025-03-03 | 1 | Y | |
| YAMAA-01 | 2025-03-10 | 2025-04-15 | 37 | Y |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADSL | STUDYID | Study Identifier | character | Copy value from ADSL_RAW.STUDYID. | Predecessor | ||
| ADSL | USUBJID | Unique Subject Identifier | character | Copy value from ADSL_RAW.USUBJID. | Predecessor | ||
| ADSL | TRTSDT | Date of First Exposure to Treatment | numeric | ISO 8601 | Copy value from ADSL_RAW.TRTSDT. | Predecessor | |
| ADSL | NACTDT | New Anti-Cancer Therapy Start Date | numeric | ISO 8601 | Least of CMNACTDT and PRNACTDT. | Derived | |
| ADSL | NACTDY | New Anti-Cancer Therapy Start Relative Day | numeric | CDISC study day of NACTDT against TRTSDT as day 1; there is no day zero. | Derived | ||
| ADSL | NACTFL | New Anti-Cancer Therapy Flag | character | Y | "Y" when NACTDT IS NOT NULL; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| NACTFL | Y |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.7 | 2026-10-20 | yamaa docs build | Read a specification in the 1.0 surface as its 0.5 counterpart; state that missing values stay missing where a mapping declares no missing handler, and leave out a declared missing answer that restates a handler's default | ||
| 1.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name collected precision in words instead of letter codes; state imputation fallbacks, minimum source precision, bounds ignored outside the collected period, and invalid text with no handler as an error; describe date and datetime shifts, imputation flag codes, and partial text giving no date part | ||
| 1.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 1.3 | 2026-09-29 | yamaa docs build | Show study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata | ||
| 1.2 | 2026-09-29 | yamaa docs build | Classify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived | ||
| 1.1 | 2026-09-29 | yamaa docs build | Resolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML | ||
| 1.0 | yamaa docs build | Initial generation from spec.yaml |
prompts/adam-adsl-new-therapy/full.md
Edit23 linesFollowing CDISC ADaM standards, use the provided ADSL, 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
A medication record qualifies when its CMCAT is "ON TREATMENT", and a procedure record qualifies when its PRCAT is "CANCER RELATED" and its PRSCAT is "ON TREATMENT". Therapy recorded as "PRIOR TREATMENT" does not qualify, and neither does a procedure given for a reason other than the cancer. A qualifying record counts only when its start date is on or after TRTSDT. A qualifying record with no start date does not count. Where a medication start is recorded as a year and month only, the start date is the 15th of that month; a full recorded start date stands as recorded. NACTDT is the earlier of the subject's earliest qualifying medication start date and earliest qualifying procedure start date. NACTDT has no value when no qualifying record counts for the subject. NACTDY is the study day of NACTDT counted from TRTSDT, and has no value when NACTDT has no value. NACTFL is "Y" when NACTDT has a value 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
Edit11 linesFollowing CDISC ADaM standards, use the provided ADSL, 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
NACTDY is the study day of NACTDT counted from TRTSDT. NACTFL is "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
Edit8 linesFollowing CDISC ADaM standards, use the provided ADSL, 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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adsl-new-therapy/result.R
Edit62 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
Edit122 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."""Create an ADSL dataset with new anticancer therapy variables.Reads the ADSL, CM and PR datasets from /app/input and writes/app/output/adsl.csv with one record per subject and the columnsSTUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL.A medication record qualifies when its CMCAT is "ON TREATMENT". Aprocedure record qualifies when its PRCAT is "CANCER RELATED" and itsPRSCAT is "ON TREATMENT". A qualifying record counts only when itsstart date is on or after TRTSDT; a qualifying record with no startdate does not count. A start recorded as a year and month only isimputed to the 15th of that month; a full recorded start date standsas recorded.NACTDT is the earlier of the subject's earliest qualifying medicationstart date and earliest qualifying procedure start date, and has novalue when no qualifying record counts. NACTDY is the study day ofNACTDT counted from TRTSDT (TRTSDT itself is day 1). NACTFL is "Y"when NACTDT has a value and has no value otherwise."""import csvfrom datetime import datefrom pathlib import PathINPUT_DIR = Path("/app/input")OUTPUT_DIR = Path("/app/output")def parse_start_date(value): """Return a date from an ISO 8601 date string, or None. A full date (YYYY-MM-DD) stands as recorded. A year-and-month value (YYYY-MM) is imputed to the 15th of that month. A missing value returns None. """ value = (value or "").strip() if not value: return None parts = value.split("-") if len(parts) == 3: year, month, day = (int(part) for part in parts) return date(year, month, day) if len(parts) == 2: year, month = (int(part) for part in parts) return date(year, month, 15) return Nonedef read_csv(path): with open(path, newline="", encoding="utf-8") as handle: return list(csv.DictReader(handle))def main(): adsl = read_csv(INPUT_DIR / "adsl.csv") cm = read_csv(INPUT_DIR / "cm.csv") pr = read_csv(INPUT_DIR / "pr.csv") trtsdt_by_subject = { row["USUBJID"]: parse_start_date(row["TRTSDT"]) for row in adsl } # Earliest counting start date per subject across both sources. earliest = {} def consider(usubjid, start): if start is None: return trtsdt = trtsdt_by_subject.get(usubjid) if trtsdt is None or start < trtsdt: return if usubjid not in earliest or start < earliest[usubjid]: earliest[usubjid] = start for row in cm: if (row.get("CMCAT") or "").strip() != "ON TREATMENT": continue consider(row["USUBJID"], parse_start_date(row.get("CMSTDTC", ""))) for row in pr: if (row.get("PRCAT") or "").strip() != "CANCER RELATED": continue if (row.get("PRSCAT") or "").strip() != "ON TREATMENT": continue consider(row["USUBJID"], parse_start_date(row.get("PRSTDTC", ""))) OUTPUT_DIR.mkdir(parents=True, exist_ok=True) fieldnames = ["STUDYID", "USUBJID", "TRTSDT", "NACTDT", "NACTDY", "NACTFL"] with open(OUTPUT_DIR / "adsl.csv", "w", newline="", encoding="utf-8") as handle: writer = csv.DictWriter(handle, fieldnames=fieldnames) writer.writeheader() for row in adsl: usubjid = row["USUBJID"] trtsdt = trtsdt_by_subject[usubjid] nactdt = earliest.get(usubjid) if nactdt is None: nactdt_text, nactdy_text, nactfl = "", "", "" else: nactdt_text = nactdt.isoformat() nactdy_text = str((nactdt - trtsdt).days + 1) nactfl = "Y" writer.writerow( { "STUDYID": row["STUDYID"], "USUBJID": usubjid, "TRTSDT": row["TRTSDT"], "NACTDT": nactdt_text, "NACTDY": nactdy_text, "NACTFL": nactfl, } )if __name__ == "__main__": main()solutions/adam-adsl-new-therapy/result.sas
Edit51 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;
yamaa