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.
- 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.
- Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
- 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
README.mdGoal: flag each concomitant medication taken while the subject is on
treatment, adding ONTRTFL.
Input: the subject's medication records (input/cm.csv) with the
collected start and end dates, plus the subject-level records
(input/adsl.csv) carrying each subject's first and last treatment dates.
A subject whose subject-level record carries empty treatment dates keeps
both treatment dates empty.
Variables:
STUDYID,USUBJID,CMSEQare carried through as collected.CMTRTis the reported medication name, carried through as collected.ASTDTandAENDTare the medication's analysis start and end dates.TRTSDTandTRTEDTare the subject's first and last treatment dates.ONTRTFLisYwhen the medication dates overlap the treatment period; blank otherwise. A medication ending before treatment starts, or starting after treatment ends, is left unflagged.
Note: a medication with a missing start or end date is assumed to overlap unless its known dates rule overlap out. A missing treatment end date leaves the period open-ended, while a subject with no treatment start date is never flagged. The fixture also covers the negative side: a medication with a missing start date that ends before treatment starts is left unflagged.
Inputs
Under review2 source filesinput/adsl.csv
Edit3 rows| STUDYID | USUBJID | TRTSDT | TRTEDT |
|---|---|---|---|
| YAMAA-01 | 2023-03-01 | 2023-06-30 | |
| YAMAA-01 | — | — | |
| YAMAA-01 | 2023-05-15 | — |
input/cm.csv
Edit13 rows| STUDYID | USUBJID | CMSEQ | CMTRT | CMSTDTC | CMENDTC |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | Ibuprofen | 2023-02-20 | 2023-02-28 | |
| YAMAA-01 | 2 | Acetaminophen | 2023-02-25 | 2023-03-01 | |
| YAMAA-01 | 3 | Metformin | 2023-03-01 | 2023-06-30 | |
| YAMAA-01 | 4 | Lisinopril | 2023-04-10 | 2023-04-24 | |
| YAMAA-01 | 5 | Omeprazole | 2023-06-30 | 2023-07-15 | |
| YAMAA-01 | 6 | Atorvastatin | 2023-07-01 | — | |
| YAMAA-01 | 7 | Alendronate | 2023-05-01 | — | |
| YAMAA-01 | 8 | Calcium carbonate | — | — | |
| YAMAA-01 | 9 | Aspirin | — | 2023-02-15 | |
| YAMAA-01 | 1 | Gabapentin | 2023-04-01 | 2023-04-15 | |
| YAMAA-01 | 1 | Sertraline | 2023-04-01 | 2023-05-10 | |
| YAMAA-01 | 2 | Levothyroxine | 2023-05-20 | — | |
| YAMAA-01 | 3 | Vitamin D | — | 2023-06-01 |
Expected output
Under review13 expected rowsexpected/adcm.csv
Edit13 rows| STUDYID | USUBJID | CMSEQ | CMTRT | ASTDT | AENDT | TRTSDT | TRTEDT | ONTRTFL |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | Ibuprofen | 2023-02-20 | 2023-02-28 | 2023-03-01 | 2023-06-30 | — | |
| YAMAA-01 | 2 | Acetaminophen | 2023-02-25 | 2023-03-01 | 2023-03-01 | 2023-06-30 | Y | |
| YAMAA-01 | 3 | Metformin | 2023-03-01 | 2023-06-30 | 2023-03-01 | 2023-06-30 | Y | |
| YAMAA-01 | 4 | Lisinopril | 2023-04-10 | 2023-04-24 | 2023-03-01 | 2023-06-30 | Y | |
| YAMAA-01 | 5 | Omeprazole | 2023-06-30 | 2023-07-15 | 2023-03-01 | 2023-06-30 | Y | |
| YAMAA-01 | 6 | Atorvastatin | 2023-07-01 | — | 2023-03-01 | 2023-06-30 | — | |
| YAMAA-01 | 7 | Alendronate | 2023-05-01 | — | 2023-03-01 | 2023-06-30 | Y | |
| YAMAA-01 | 8 | Calcium carbonate | — | — | 2023-03-01 | 2023-06-30 | Y | |
| YAMAA-01 | 9 | Aspirin | — | 2023-02-15 | 2023-03-01 | 2023-06-30 | — | |
| YAMAA-01 | 1 | Gabapentin | 2023-04-01 | 2023-04-15 | — | — | — | |
| YAMAA-01 | 1 | Sertraline | 2023-04-01 | 2023-05-10 | 2023-05-15 | — | — | |
| YAMAA-01 | 2 | Levothyroxine | 2023-05-20 | — | 2023-05-15 | — | Y | |
| YAMAA-01 | 3 | Vitamin D | — | 2023-06-01 | 2023-05-15 | — | Y |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADCM | STUDYID | Study Identifier | character | Copy value from CM.STUDYID. | Predecessor | ||
| ADCM | USUBJID | Unique Subject Identifier | character | Copy value from CM.USUBJID. | Predecessor | ||
| ADCM | CMSEQ | Sequence Number | numeric | Copy value from CM.CMSEQ. | Predecessor | ||
| ADCM | CMTRT | Reported Name of Drug, Medication, or Therapy | character | Copy value from CM.CMTRT. | Predecessor | ||
| ADCM | ASTDT | Analysis Start Date | numeric | ISO 8601 | Copy value from CM.CMSTDTC. | Predecessor | |
| ADCM | AENDT | Analysis End Date | numeric | ISO 8601 | Copy value from CM.CMENDTC. | Predecessor | |
| ADCM | TRTSDT | Date of First Exposure to Treatment | numeric | ISO 8601 | Copy value from ADSL.TRTSDT. | Predecessor | |
| ADCM | TRTEDT | Date of Last Exposure to Treatment | numeric | ISO 8601 | Copy value from ADSL.TRTEDT. | Predecessor | |
| ADCM | ONTRTFL | On Treatment Record Flag | character | Y | "Y" when TRTSDT IS NOT NULL AND (TRTEDT IS NULL OR ASTDT IS NULL OR ASTDT <= TRTEDT) AND (AENDT IS NULL OR AENDT >= TRTSDT) ; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| ONTRTFL | Y |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 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-adcm-on-treatment/full.md
Edit18 linesFollowing CDISC ADaM standards, use the provided CM and ADSL datasets to create an ADCM dataset with one record per medication.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL
ASTDT and AENDT are the medication's analysis start and end dates. TRTSDT and TRTEDT are the subject's first and last treatment dates. ONTRTFL is Y when the medication dates overlap the treatment period, and has no value otherwise. A medication ending before treatment starts, or starting after treatment ends, is left unflagged. A medication with a missing start or end date is assumed to overlap unless its known dates rule overlap out. A missing treatment end date leaves the period open-ended, while a subject with no treatment start date is never flagged.
Read the source datasets from /app/input and save the completed dataset as /app/output/adcm.csv.
prompts/adam-adcm-on-treatment/conventions.md
Edit10 linesFollowing CDISC ADaM standards, use the provided CM and ADSL datasets to create an ADCM dataset with one record per medication.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL
ONTRTFL is Y or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adcm.csv.
prompts/adam-adcm-on-treatment/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided CM and ADSL datasets to create an ADCM dataset with one record per medication.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL
Read the source datasets from /app/input and save the completed dataset as /app/output/adcm.csv.
run.R
Edit4 lineslibrary(yamaa)adcm <- yamaa_domain("spec.yaml")$outputadcmrun.py
Edit4 linesimport yamaaadcm = yamaa.yamaa_domain("spec.yaml").outputadcmsolutions/adam-adcm-on-treatment/result.R
Edit39 lines# Reference solution for the yamaa benchmark adam-adcm-on-treatment (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)cm <- read_csv( "/app/input/cm.csv", col_types = cols(CMSEQ = col_integer(), .default = col_character()))adsl <- read_csv( "/app/input/adsl.csv", col_types = cols(.default = col_character()))adcm <- cm |> mutate(ASTDT = CMSTDTC, AENDT = CMENDTC) |> left_join(adsl |> select(USUBJID, TRTSDT, TRTEDT), by = "USUBJID") |> mutate( # The medication overlaps the treatment period. A missing medication # date is assumed to overlap unless the known dates rule it out; a # missing treatment end leaves the period open, while no treatment # start is never flagged. ONTRTFL = case_when( is.na(TRTSDT) ~ NA_character_, !is.na(AENDT) & AENDT < TRTSDT ~ NA_character_, !is.na(ASTDT) & !is.na(TRTEDT) & ASTDT > TRTEDT ~ NA_character_, .default = "Y" ) ) |> select( STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL )dir.create("/app/output", showWarnings = FALSE)write_csv(adcm, "/app/output/adcm.csv", na = "")solutions/adam-adcm-on-treatment/result.py
Edit59 lines# Reference solution for the yamaa benchmark adam-adcm-on-treatment (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 plcm = pl.read_csv("/app/input/cm.csv", infer_schema=False).with_columns( pl.col("CMSEQ").cast(pl.Int64))adsl = pl.read_csv("/app/input/adsl.csv", infer_schema=False).select( "USUBJID", "TRTSDT", "TRTEDT")adcm = cm.join(adsl, on="USUBJID", how="left").with_columns( ASTDT=pl.col("CMSTDTC"), AENDT=pl.col("CMENDTC"))# The medication overlaps the treatment period. A missing medication date is# assumed to overlap unless the known dates rule it out; a missing treatment# end leaves the period open, while no treatment start is never flagged.# ISO dates sort as text.adcm = ( adcm.with_columns( ONTRTFL=pl.when(pl.col("TRTSDT").is_null() | (pl.col("TRTSDT") == "")) .then(None) .when( pl.col("AENDT").is_not_null() & (pl.col("AENDT") != "") & (pl.col("AENDT") < pl.col("TRTSDT")) ) .then(None) .when( pl.col("ASTDT").is_not_null() & (pl.col("ASTDT") != "") & pl.col("TRTEDT").is_not_null() & (pl.col("TRTEDT") != "") & (pl.col("ASTDT") > pl.col("TRTEDT")) ) .then(None) .otherwise(pl.lit("Y")) ).select( "STUDYID", "USUBJID", "CMSEQ", "CMTRT", "ASTDT", "AENDT", "TRTSDT", "TRTEDT", "ONTRTFL", ))Path("/app/output").mkdir(exist_ok=True)adcm.write_csv("/app/output/adcm.csv")solutions/adam-adcm-on-treatment/result.sas
Edit27 lines/* opensas reference solution for the yamaa benchmark adam-adcm-on-treatment. 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 TRTEDT $1024; infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. TRTSDT : $char1024. TRTEDT : $char1024.;run;data cm; length STUDYID USUBJID CMTRT CMSTDTC CMENDTC $1024; infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. CMSEQ CMTRT : $char1024. CMSTDTC : $char1024. CMENDTC : $char1024.;run;proc sql; create table joined as select a.*,b.TRTSDT,b.TRTEDT from cm as a left join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;data result; length ASTDT AENDT $10 ONTRTFL $1; set joined; ASTDT=CMSTDTC; AENDT=CMENDTC; if not missing(TRTSDT) and (missing(AENDT) or AENDT>=TRTSDT) and (missing(TRTEDT) or missing(ASTDT) or ASTDT<=TRTEDT) then ONTRTFL='Y';run;proc sql; create table final as select STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL from result;quit;proc export data=final outfile="/app/output/adcm.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions