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 whether each subject took rescue medication
(RESCFL), and give the start date of the first rescue medication
(RESCDT), its imputation flag (RESCDTF) and its standardized
name (RESCTRT).
Input: one subject-level table listing the subjects, plus
concomitant medication (CM) records carrying the reported name
(CMTRT), the standardized name (CMDECOD), a category (CMCAT),
a start date (CMSTDTC) collected in full or in part, and a
sequence number (CMSEQ).
Variables:
RESCFLisYwhen the subject has a record whose category (CMCAT) isRESCUE MEDICATION, andNotherwise, including a subject with no medication records at all.RESCDTis the start date of the first rescue medication: the one with the earliest start date, the smaller sequence number (CMSEQ) breaking a tie. A start collected as a year and month completes to the first of the month, and a year alone to 1 January, before the dates are compared. It is empty when the first rescue medication has no start date or the subject took none.RESCDTFisDwhen the day ofRESCDTwas imputed andMwhen the month and day were; empty when the date was collected in full orRESCDTis empty.RESCTRTis the standardized name (CMDECOD) of that first rescue medication; empty when the subject took none, never filled with placeholder text.
Note: a rescue record with no start date still makes the subject
Y, but it is the first rescue medication only when the subject has
no dated one. A duplicated record does not change the answer.
Inputs
Under review2 source filesinput/cm.csv
Edit15 rows| STUDYID | USUBJID | CMSEQ | CMTRT | CMDECOD | CMCAT | CMSTDTC |
|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | LISINOPRIL | LISINOPRIL | CONCOMITANT MEDICATION | 2025-02-10 | |
| YAMAA-01 | 2 | DECADRON | DEXAMETHASONE | RESCUE MEDICATION | 2025-03-20 | |
| YAMAA-01 | 3 | PREDNISONE 20 MG | PREDNISONE | RESCUE MEDICATION | 2025-03-05 | |
| YAMAA-01 | 4 | ALEVE | NAPROXEN SODIUM | RESCUE MEDICATION | 2025-03 | |
| YAMAA-01 | 1 | LIPITOR | ATORVASTATIN | CONCOMITANT MEDICATION | 2025-02-15 | |
| YAMAA-01 | 2 | METFORMIN | METFORMIN | CONCOMITANT MEDICATION | 2025-03-01 | |
| YAMAA-01 | 1 | VENTOLIN | SALBUTAMOL | RESCUE MEDICATION | 2025-04-01 | |
| YAMAA-01 | 2 | ATROVENT | IPRATROPIUM BROMIDE | RESCUE MEDICATION | 2025-04-01 | |
| YAMAA-01 | 3 | OMEPRAZOLE | OMEPRAZOLE | CONCOMITANT MEDICATION | 2025-03-15 | |
| YAMAA-01 | 1 | ZOFRAN | ONDANSETRON | RESCUE MEDICATION | 2025-05-12 | |
| YAMAA-01 | 1 | ZOFRAN | ONDANSETRON | RESCUE MEDICATION | 2025-05-12 | |
| YAMAA-01 | 2 | SYNTHROID | LEVOTHYROXINE SODIUM | CONCOMITANT MEDICATION | 2025-02-20 | |
| YAMAA-01 | 1 | IMODIUM | LOPERAMIDE | RESCUE MEDICATION | — | |
| YAMAA-01 | 2 | IBUPROFEN | IBUPROFEN | CONCOMITANT MEDICATION | 2025-06-01 | |
| YAMAA-01 | 1 | TYLENOL | PARACETAMOL | RESCUE MEDICATION | 2025 |
input/dm.csv
Edit7 rows| STUDYID | USUBJID |
|---|---|
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 |
Expected output
Under review7 expected rowsexpected/adsl.csv
Edit7 rows| STUDYID | USUBJID | RESCFL | RESCDT | RESCDTF | RESCTRT |
|---|---|---|---|---|---|
| YAMAA-01 | Y | 2025-03-01 | D | NAPROXEN SODIUM | |
| YAMAA-01 | N | — | — | — | |
| YAMAA-01 | Y | 2025-04-01 | — | SALBUTAMOL | |
| YAMAA-01 | Y | 2025-05-12 | — | ONDANSETRON | |
| YAMAA-01 | N | — | — | — | |
| YAMAA-01 | Y | — | — | LOPERAMIDE | |
| YAMAA-01 | Y | 2025-01-01 | M | PARACETAMOL |
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 DM.STUDYID. | Predecessor | ||
| ADSL | USUBJID | Unique Subject Identifier | character | Copy value from DM.USUBJID. | Predecessor | ||
| ADSL | RESCFL | Rescue Medication Flag | character | "Y" when CMSEQ IS NOT NULL, with CMSEQ taken from the first CM record matching on STUDYID and USUBJID, where CM.CMCAT = 'RESCUE MEDICATION', ordered by CM.CMSTDT, nulls last then CM.CMSEQ, and no match yields blank; "N" otherwise; "N" when the condition is unknown. | Derived | ||
| ADSL | RESCDT | First Rescue Medication Date | numeric | ISO 8601 | Impute incomplete date from CMSTDTC from the first CM record matching on STUDYID and USUBJID, where CM.CMCAT = 'RESCUE MEDICATION', ordered by CM.CMSTDT, nulls last then CM.CMSEQ, and no match yields blank, defaulting month=1, day=first; invalid text is an error. | Derived | |
| ADSL | RESCDTF | First Rescue Med Date Imputation Flag | character | Date imputation flag for RESCDT: "Y" when the whole date was imputed, "M" when the month and day were, "D" when only the day was; blank when the date was collected in full. | Derived | ||
| ADSL | RESCTRT | First Rescue Medication | character | Take CMDECOD from the first CM record matching on STUDYID and USUBJID, where CM.CMCAT = 'RESCUE MEDICATION', ordered by CM.CMSTDT, nulls last then CM.CMSEQ, and no match yields blank. | Derived |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.8 | 2026-11-19 | yamaa docs build | State open and closed range endpoints, including bounds of zero | ||
| 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-rescue-med/full.md
Edit30 linesFollowing CDISC ADaM standards, use the provided CM and DM datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RESCFL, RESCDT, RESCDTF, RESCTRT
A rescue medication is a CM record whose category (CMCAT) is "RESCUE MEDICATION". RESCFL is "Y" when the subject has a rescue medication record and "N" otherwise, including a subject with no medication records at all. The first rescue medication is the subject's rescue record with the earliest start date (CMSTDTC), with the smaller CMSEQ breaking a tie between records with the same start date. A start date recorded with only a year and month completes to the first day of that month, and one recorded with only a year completes to January 1 of that year, before start dates are compared. A rescue record with no start date is the first rescue medication only when the subject has no rescue record with a start date. A duplicated rescue record does not change the answer.
RESCDT is the completed start date of the first rescue medication; it has no value when that record has no start date or the subject took no rescue medication. RESCDTF is "D" when only the day of RESCDT was completed and "M" when the month and day were; it has no value when the start date was recorded in full or RESCDT has no value. RESCTRT is the standardized medication name (CMDECOD) of the first rescue medication; it has no value when the subject took no rescue medication, and it is 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/conventions.md
Edit14 linesFollowing CDISC ADaM standards, use the provided CM and DM datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RESCFL, RESCDT, RESCDTF, RESCTRT
RESCFL is "Y" or "N". A partial start date completes to the first day of its month, or to January 1 for a year alone, before start dates are compared. RESCTRT is the standardized medication name (CMDECOD) of the subject's first rescue medication, or has no value, and it is 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 CM and DM datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RESCFL, RESCDT, RESCDTF, RESCTRT
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-rescue-med/result.R
Edit48 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()))# A partial start completes to its first possible day: a year and month to# the first of the month (flag D), a year alone to January 1 (flag M).first <- cm |> filter(CMCAT == "RESCUE MEDICATION") |> mutate( RESCDTF = case_when( nchar(CMSTDTC) == 4 ~ "M", nchar(CMSTDTC) == 7 ~ "D", .default = NA_character_ ), RESCDT = as.Date(case_when( nchar(CMSTDTC) == 4 ~ paste0(CMSTDTC, "-01-01"), nchar(CMSTDTC) == 7 ~ paste0(CMSTDTC, "-01"), .default = CMSTDTC )) ) |> # arrange puts a missing date last, so an undated record is first only # when the subject has no dated one. arrange(STUDYID, USUBJID, RESCDT, CMSEQ) |> distinct(STUDYID, USUBJID, .keep_all = TRUE) |> select(STUDYID, USUBJID, RESCDT, RESCDTF, RESCTRT = CMDECOD)adsl <- dm |> left_join(first, by = c("STUDYID", "USUBJID")) |> mutate(RESCFL = if_else(is.na(RESCTRT), "N", "Y")) |> select(STUDYID, USUBJID, RESCFL, RESCDT, RESCDTF, RESCTRT) |> arrange(USUBJID)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")solutions/adam-adsl-rescue-med/result.py
Edit71 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.import csvfrom datetime import datefrom pathlib import PathINPUT = Path("/app/input")OUTPUT = Path("/app/output")def read_rows(name): with open(INPUT / name, newline="", encoding="utf-8") as f: return list(csv.DictReader(f))def complete(text): """A start date completed to its first possible day, with its flag.""" parts = text.split("-") if len(parts) == 1: return date(int(parts[0]), 1, 1), "M" if len(parts) == 2: return date(int(parts[0]), int(parts[1]), 1), "D" return date.fromisoformat(text), ""def main(): dm = read_rows("dm.csv") cm = read_rows("cm.csv") rescue = {} for row in cm: if row["CMCAT"] != "RESCUE MEDICATION": continue key = (row["STUDYID"], row["USUBJID"]) start, flag = complete(row["CMSTDTC"]) if row["CMSTDTC"] else (None, "") # A dated record sorts before an undated one, then by date and # sequence number. sort_key = (start is None, start or date.min, int(row["CMSEQ"])) if key not in rescue or sort_key < rescue[key][0]: rescue[key] = (sort_key, start, flag, row["CMDECOD"]) OUTPUT.mkdir(parents=True, exist_ok=True) with open(OUTPUT / "adsl.csv", "w", newline="", encoding="utf-8") as f: writer = csv.writer(f) writer.writerow( ["STUDYID", "USUBJID", "RESCFL", "RESCDT", "RESCDTF", "RESCTRT"] ) for row in dm: entry = rescue.get((row["STUDYID"], row["USUBJID"])) if entry is None: writer.writerow([row["STUDYID"], row["USUBJID"], "N", "", "", ""]) continue _, start, flag, name = entry writer.writerow( [ row["STUDYID"], row["USUBJID"], "Y", start.isoformat() if start else "", flag, name, ] )if __name__ == "__main__": main()solutions/adam-adsl-rescue-med/result.sas
Edit40 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 CMDECOD CMCAT CMSTDTC $1024; infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. CMSEQ CMTRT : $char1024. CMDECOD : $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;/* A partial start completes to its first possible day: a year and month to the first of the month (flag D), a year alone to January 1 (flag M). */data rescue; length RESCDT $10 RESCDTF $1; set cm; if CMCAT='RESCUE MEDICATION'; RESCDT=''; RESCDTF=''; if lengthn(CMSTDTC)=4 then do; RESCDT=cats(CMSTDTC,'-01-01'); RESCDTF='M'; end; else if lengthn(CMSTDTC)=7 then do; RESCDT=cats(CMSTDTC,'-01'); RESCDTF='D'; end; else RESCDT=CMSTDTC; nodate=missing(RESCDT);run;proc sort data=rescue; by STUDYID USUBJID nodate RESCDT CMSEQ; run;data firstcm; set rescue; by STUDYID USUBJID; if first.USUBJID; run;proc sql; create table result as select a.STUDYID, a.USUBJID, case when b.USUBJID is null then 'N' else 'Y' end as RESCFL length=1, b.RESCDT, b.RESCDTF, b.CMDECOD as RESCTRT from dm as a left join firstcm as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID;quit;proc export data=result outfile="/app/output/adsl.csv" dbms=csv replace; run;
yamaa