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: carry each subject's first rescue medication in RESCTRT.
Input: one subject-level table listing the subjects, plus
medication records carrying a treatment name (CMTRT), a category
(CMCAT), a start date (CMSTDTC), and a sequence number (CMSEQ).
Variables:
RESCTRTis the treatment name of the subject's first rescue medication: a record whose category (CMCAT) isRESCUE MEDICATION, picked by the earliest start date (CMSTDTC), with the smaller sequence number (CMSEQ) breaking a tie. It is left blank, never filled with placeholder text, when the subject took no rescue medication, whether the subject took other medications or has no medication records at all. A rescue record with no recorded start date still counts; a duplicated record does not change the answer. A start date with only year and month compares as written, so it falls before any full date in the same month.
Inputs
Under review2 source filesinput/cm.csv
Edit14 rows| STUDYID | USUBJID | CMSEQ | CMTRT | CMCAT | CMSTDTC |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | LISINOPRIL | CONCOMITANT MEDICATION | 2025-02-10 | |
| YAMAA-01 | 2 | DEXAMETHASONE | RESCUE MEDICATION | 2025-03-20 | |
| YAMAA-01 | 3 | PREDNISONE | RESCUE MEDICATION | 2025-03-05 | |
| YAMAA-01 | 4 | NAPROXEN | RESCUE MEDICATION | 2025-03 | |
| YAMAA-01 | 1 | ATORVASTATIN | CONCOMITANT MEDICATION | 2025-02-15 | |
| YAMAA-01 | 2 | METFORMIN | CONCOMITANT MEDICATION | 2025-03-01 | |
| YAMAA-01 | 1 | ALBUTEROL | RESCUE MEDICATION | 2025-04-01 | |
| YAMAA-01 | 2 | SALBUTAMOL | RESCUE MEDICATION | 2025-04-01 | |
| YAMAA-01 | 3 | OMEPRAZOLE | CONCOMITANT MEDICATION | 2025-03-15 | |
| YAMAA-01 | 1 | ONDANSETRON | RESCUE MEDICATION | 2025-05-12 | |
| YAMAA-01 | 1 | ONDANSETRON | RESCUE MEDICATION | 2025-05-12 | |
| YAMAA-01 | 2 | LEVOTHYROXINE | CONCOMITANT MEDICATION | 2025-02-20 | |
| YAMAA-01 | 1 | LOPERAMIDE | RESCUE MEDICATION | — | |
| YAMAA-01 | 2 | IBUPROFEN | CONCOMITANT MEDICATION | 2025-06-01 |
input/dm.csv
Edit6 rows| STUDYID | USUBJID |
|---|---|
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 |
Expected output
Under review6 expected rowsexpected/adsl.csv
Edit6 rows| STUDYID | USUBJID | RESCTRT |
|---|---|---|
| YAMAA-01 | NAPROXEN | |
| YAMAA-01 | — | |
| YAMAA-01 | ALBUTEROL | |
| YAMAA-01 | ONDANSETRON | |
| YAMAA-01 | — | |
| YAMAA-01 | LOPERAMIDE |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADSL | STUDYID | Study Identifier | character | Copy value from DM.STUDYID. | Predecessor | ||
| ADSL | USUBJID | Unique Subject Identifier | character | Copy value from DM.USUBJID. | Predecessor | ||
| ADSL | RESCTRT | Rescue Medication | character | Copy value from CM.CMTRT where CM.CMCAT = 'RESCUE MEDICATION', keeping the first ordered by CM.CMSTDTC then CM.CMSEQ. | Predecessor |
| 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-adsl-rescue-med/full.md
Edit20 linesFollowing CDISC ADaM standards, use the provided DM and CM datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RESCTRT
RESCTRT is the treatment name of the subject's first rescue medication: a record with category RESCUE MEDICATION, picked by the earliest start date, with the smaller sequence number breaking a tie. It is left blank, never filled with placeholder text, when the subject took no rescue medication, whether the subject took other medications or has no medication records at all.
A rescue record with no recorded start date still counts, and a duplicated record does not change the answer. A start date holding only year and month compares as written, so it falls before any full date in the same month.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-rescue-med/conventions.md
Edit11 linesFollowing CDISC ADaM standards, use the provided DM and CM datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RESCTRT
RESCTRT is a treatment name, or is left blank, never filled with placeholder text.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-rescue-med/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided DM and CM datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RESCTRT
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
run.R
Edit4 lineslibrary(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadslrun.py
Edit4 linesimport yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadslsolutions/adam-adsl-rescue-med/result.R
Edit36 lines# Reference solution for the yamaa benchmark adam-adsl-rescue-med (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)dm <- read_csv( "/app/input/dm.csv", col_types = cols(.default = col_character()))cm <- read_csv( "/app/input/cm.csv", col_types = cols(CMSEQ = col_integer(), .default = col_character()))# The first rescue medication by earliest start date, with the smaller# sequence number breaking a tie. A start holding only year and month# compares as written, so it falls before any full date in the same# month; a record with no start date still counts.first <- cm |> filter(CMCAT == "RESCUE MEDICATION") |> mutate(sortkey = coalesce(CMSTDTC, "")) |> arrange(sortkey, CMSEQ) |> distinct(STUDYID, USUBJID, .keep_all = TRUE) |> select(STUDYID, USUBJID, RESCTRT = CMTRT)adsl <- dm |> left_join(first, by = c("STUDYID", "USUBJID")) |> select(STUDYID, USUBJID, RESCTRT) |> arrange(USUBJID)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")solutions/adam-adsl-rescue-med/result.py
Edit36 lines# Reference solution for the yamaa benchmark adam-adsl-rescue-med (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 pldm = pl.read_csv("/app/input/dm.csv", infer_schema=False, null_values="")cm = pl.read_csv("/app/input/cm.csv", infer_schema=False, null_values="").with_columns( pl.col("CMSEQ").cast(pl.Int64, strict=False),)# The first rescue medication by earliest start date, with the smaller# sequence number breaking a tie. A start holding only year and month# compares as written, so it falls before any full date in the same# month; a record with no start date still counts. Comparing the# collected text with empty sorting first keeps both rules.first = ( cm.filter(pl.col("CMCAT") == "RESCUE MEDICATION") .with_columns(__sortkey=pl.col("CMSTDTC").fill_null("")) .sort(["__sortkey", "CMSEQ"], nulls_last=False) .unique(["STUDYID", "USUBJID"], keep="first", maintain_order=True) .select("STUDYID", "USUBJID", RESCTRT="CMTRT"))adsl = ( dm.join(first, on=["STUDYID", "USUBJID"], how="left", maintain_order="left") .select("STUDYID", "USUBJID", "RESCTRT") .sort("USUBJID"))Path("/app/output").mkdir(parents=True, exist_ok=True)adsl.write_csv("/app/output/adsl.csv", null_value="")solutions/adam-adsl-rescue-med/result.sas
Edit25 lines/* opensas reference solution for the yamaa benchmark adam-adsl-rescue-med. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data cm; length STUDYID USUBJID CMTRT CMCAT CMSTDTC $1024; infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. CMSEQ CMTRT : $char1024. CMCAT : $char1024. CMSTDTC : $char1024.;run;data dm; length STUDYID USUBJID $1024; infile "/app/input/dm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024.;run;data rescue; set cm; if CMCAT='RESCUE MEDICATION'; nodate=missing(CMSTDTC); run;proc sort data=rescue; by STUDYID USUBJID nodate CMSTDTC CMSEQ; run;data firstcm; set rescue; by STUDYID USUBJID; if first.USUBJID; run;proc sql; create table result as select a.*,b.CMTRT as RESCTRT from dm as a left join firstcm as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;proc sql; create table final as select STUDYID, USUBJID, RESCTRT from result;quit;proc export data=final outfile="/app/output/adsl.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions