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: 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 |
Human review and assessment
| 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.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-adcm-on-treatment/full.md
Edit25 linesFollowing CDISC ADaM standards, use the provided ADSL and CM datasets to create an ADCM dataset with one record per concomitant medication.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMSEQ, CMTRT, ASTDT, AENDT, TRTSDT, TRTEDT, ONTRTFL
ASTDT is the medication's analysis start date, the date collected as CMSTDTC, and AENDT is the medication's analysis end date, the date collected as CMENDTC. TRTSDT is the subject's first treatment date and TRTEDT the subject's last treatment date, both from the subject's subject-level record; a subject whose subject-level record has no treatment dates has no value for TRTSDT or TRTEDT. ONTRTFL is "Y" when the medication's dates overlap the subject's treatment period, from TRTSDT through TRTEDT, and has no value otherwise. A medication that ends before TRTSDT, or that starts after TRTEDT, has no value for ONTRTFL; a medication that starts on TRTEDT or ends on TRTSDT does overlap. A medication with no ASTDT or no AENDT is treated as overlapping unless its known dates rule overlap out, so a medication with no ASTDT that ends before TRTSDT has no value for ONTRTFL. A missing TRTEDT leaves the treatment period open-ended. A subject with no TRTSDT is never flagged: ONTRTFL has no value on every record for that subject.
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 ADSL and CM datasets to create an ADCM dataset with one record per concomitant 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 ADSL and CM datasets to create an ADCM dataset with one record per concomitant 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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/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
Edit99 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."""Create ADCM (one record per concomitant medication) from ADSL and CM.ONTRTFL is "Y" when the medication's analysis dates overlap the subject'streatment period (TRTSDT through TRTEDT, inclusive). A medication with amissing start or end date is treated as overlapping unless its known datesrule overlap out. A missing TRTEDT leaves the period open-ended, and asubject with no TRTSDT is never flagged."""import polars as plINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"COLUMNS = [ "STUDYID", "USUBJID", "CMSEQ", "CMTRT", "ASTDT", "AENDT", "TRTSDT", "TRTEDT", "ONTRTFL",]def read_csv(name): frame = pl.read_csv( f"{INPUT_DIR}/{name}", schema_overrides={ "STUDYID": pl.String, "USUBJID": pl.String, "CMSEQ": pl.String, "CMTRT": pl.String, "CMSTDTC": pl.String, "CMENDTC": pl.String, "TRTSDT": pl.String, "TRTEDT": pl.String, }, ) return frame.fill_null("")def main(): adsl = read_csv("adsl.csv") cm = read_csv("cm.csv") trt = { row["USUBJID"]: (row["TRTSDT"], row["TRTEDT"]) for row in adsl.iter_rows(named=True) } records = [] for row in cm.iter_rows(named=True): astdt, aendt = row["CMSTDTC"], row["CMENDTC"] trtsdt, trtedt = trt.get(row["USUBJID"], ("", "")) ontrtfl = "" if trtsdt: ends_before_start = bool(aendt) and aendt < trtsdt starts_after_end = bool(astdt) and bool(trtedt) and astdt > trtedt if not ends_before_start and not starts_after_end: ontrtfl = "Y" records.append( { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "CMSEQ": row["CMSEQ"], "CMTRT": row["CMTRT"], "ASTDT": astdt, "AENDT": aendt, "TRTSDT": trtsdt, "TRTEDT": trtedt, "ONTRTFL": ontrtfl, } ) adcm = pl.DataFrame(records, schema={name: pl.String for name in COLUMNS}) # Write empty values as bare empty fields, not quoted "" strings. adcm = adcm.select( pl.when(pl.col(name) == "") .then(pl.lit(None, dtype=pl.String)) .otherwise(pl.col(name)) .alias(name) for name in COLUMNS ) adcm.write_csv(f"{OUTPUT_DIR}/adcm.csv")if __name__ == "__main__": main()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