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: one row per concomitant medication with its analysis start as
ISO 8601 text (ASTDTC) and as a date (ASTDT), read from a start the
sites recorded as free text in several spellings.
Input: concomitant medication records, each identified by its sequence
number (CMSEQ), carrying the reported name (CMTRT) and the collected
start (CMSTDAT) as the site wrote it.
Variables:
ASTDTCis the start as ISO 8601 text at the precision it was collected:2001-03-04for a full date and2001-03for a month alone. It is empty when no start was collected.ASTDTis the analysis start date: the collected date, or the first day of the month when only a month was collected. It is empty when no start was collected.
Note: five spellings of the start are accepted: an ISO 8601 date such as
2001-03-04; a two-digit day, three-letter month and four-digit year such
as 04MAR2001, the month in any letter case; a slashed date such as
03/04/2001, which reads month first; eight digits such as 20010304; and
a three-letter month and year such as MAR2001. A start written in any
other spelling stops the run rather than being guessed.
Inputs
Under review1 source fileinput/cm.csv
Edit7 rows| STUDYID | USUBJID | CMSEQ | CMTRT | CMSTDAT |
|---|---|---|---|---|
| YAMAA-01 | 1 | Paracetamol | 2001-03-04 | |
| YAMAA-01 | 2 | Ibuprofen | 04MAR2001 | |
| YAMAA-01 | 1 | Omeprazole | 03/04/2001 | |
| YAMAA-01 | 2 | Loratadine | 20010304 | |
| YAMAA-01 | 1 | Amoxicillin | MAR2001 | |
| YAMAA-01 | 2 | Cetirizine | 04mar2001 | |
| YAMAA-01 | 3 | Metformin | — |
Expected output
Under review7 expected rowsexpected/adcm.csv
Edit7 rows| STUDYID | USUBJID | CMSEQ | CMTRT | CMSTDAT | ASTDTC | ASTDT |
|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | Paracetamol | 2001-03-04 | 2001-03-04 | 2001-03-04 | |
| YAMAA-01 | 2 | Ibuprofen | 04MAR2001 | 2001-03-04 | 2001-03-04 | |
| YAMAA-01 | 1 | Omeprazole | 03/04/2001 | 2001-03-04 | 2001-03-04 | |
| YAMAA-01 | 2 | Loratadine | 20010304 | 2001-03-04 | 2001-03-04 | |
| YAMAA-01 | 1 | Amoxicillin | MAR2001 | 2001-03 | 2001-03-01 | |
| YAMAA-01 | 2 | Cetirizine | 04mar2001 | 2001-03-04 | 2001-03-04 | |
| YAMAA-01 | 3 | Metformin | — | — | — |
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 | CMSTDAT | Collected Start Date | character | Copy value from CM.CMSTDAT. | Predecessor | ||
| ADCM | ASTDTC | Analysis Start Date Text | character | Read CM.CMSTDAT as ISO 8601 date text from ISO 8601 date text, day-month-year text such as 04MAR2001, month-first slashed dates such as 03/04/2001 for March 4, eight digits such as 20010304 or month-year text such as MAR2001 for a month alone; blank when it is blank; any other spelling is an error. | Derived | ||
| ADCM | ASTDT | Analysis Start Date | numeric | ISO 8601 | Impute incomplete date from ASTDTC, defaulting day=first; a year alone gives blank; invalid text is an error. | Derived |
| 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-free-text-start-date/full.md
Edit26 linesFollowing CDISC ADaM standards, use the provided CM dataset to create an ADCM dataset with one record per concomitant medication, identified by USUBJID and CMSEQ.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMSEQ, CMTRT, CMSTDAT, ASTDTC, ASTDT
The sites recorded the collected start, CMSTDAT, as free text in one of five spellings:
- an ISO 8601 date, such as "2003-05-06";
- a two-digit day, a three-letter English month abbreviation and a four-digit year, such as "06MAY2003", the month in any letter case, so "06may2003" is the same date;
- a slashed date, which reads month first: "05/06/2003" is 6 May 2003;
- eight digits, year then month then day, such as "20030506";
- a three-letter month abbreviation and a four-digit year, such as "MAY2003", which records a month alone.
ASTDTC is the start as ISO 8601 text at the precision it was collected: "YYYY-MM-DD" for a full date, such as "2003-05-06", and "YYYY-MM" for a month alone, such as "2003-05". ASTDT is the analysis start date: the collected date, or the first day of the month when only a month was collected. ASTDTC and ASTDT have no value when CMSTDAT has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adcm.csv.
prompts/adam-adcm-free-text-start-date/conventions.md
Edit11 linesFollowing CDISC ADaM standards, use the provided CM dataset to create an ADCM dataset with one record per concomitant medication, identified by USUBJID and CMSEQ.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMSEQ, CMTRT, CMSTDAT, ASTDTC, ASTDT
ASTDTC is ISO 8601 text, "YYYY-MM-DD" or "YYYY-MM", or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adcm.csv.
prompts/adam-adcm-free-text-start-date/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided CM dataset to create an ADCM dataset with one record per concomitant medication, identified by USUBJID and CMSEQ.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMSEQ, CMTRT, CMSTDAT, ASTDTC, ASTDT
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-free-text-start-date/result.R
Edit61 lines# Reference solution for the yamaa benchmark adam-adcm-free-text-start-date (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()))months <- c("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC")# The month a three-letter abbreviation names, in any letter case.month_of <- function(abbreviation) match(toupper(abbreviation), months)# A date written as ISO 8601 text; an impossible date is an error.iso_date <- function(year, month, day) { value <- as.Date(sprintf("%04d-%02d-%02d", as.integer(year), as.integer(month), as.integer(day)), format = "%Y-%m-%d") if (is.na(value)) stop("not a date: ", year, "-", month, "-", day) format(value, "%Y-%m-%d")}# The start as ISO 8601 text at the precision collected.read_start <- function(text) { if (is.na(text) || text == "") return(NA_character_) if (grepl("^[0-9]{4}-[0-9]{2}-[0-9]{2}$", text)) { return(iso_date(substr(text, 1, 4), substr(text, 6, 7), substr(text, 9, 10))) } if (grepl("^[0-9]{2}[A-Za-z]{3}[0-9]{4}$", text) && !is.na(month_of(substr(text, 3, 5)))) { return(iso_date(substr(text, 6, 9), month_of(substr(text, 3, 5)), substr(text, 1, 2))) } if (grepl("^[0-9]{2}/[0-9]{2}/[0-9]{4}$", text)) { # The month comes first. return(iso_date(substr(text, 7, 10), substr(text, 1, 2), substr(text, 4, 5))) } if (grepl("^[0-9]{8}$", text)) { return(iso_date(substr(text, 1, 4), substr(text, 5, 6), substr(text, 7, 8))) } if (grepl("^[A-Za-z]{3}[0-9]{4}$", text) && !is.na(month_of(substr(text, 1, 3)))) { # A month alone. return(sprintf("%s-%02d", substr(text, 4, 7), month_of(substr(text, 1, 3)))) } stop("CMSTDAT is in none of the five spellings: ", text)}adcm <- cm |> mutate( ASTDTC = vapply(CMSTDAT, read_start, character(1), USE.NAMES = FALSE), # A month alone starts on its first day. ASTDT = if_else(nchar(ASTDTC) == 7, paste0(ASTDTC, "-01"), ASTDTC) ) |> select(STUDYID, USUBJID, CMSEQ, CMTRT, CMSTDAT, ASTDTC, ASTDT)dir.create("/app/output", showWarnings = FALSE)write_csv(adcm, "/app/output/adcm.csv", na = "")solutions/adam-adcm-free-text-start-date/result.py
Edit89 lines# Reference solution for the yamaa benchmark adam-adcm-free-text-start-date (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."""Build ADCM from CM, reading a free-text start date in five spellings."""import csvimport refrom datetime import dateINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"MONTHS = [ "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC",]def month_number(abbreviation): """The month a three-letter abbreviation names, in any letter case.""" upper = abbreviation.upper() return MONTHS.index(upper) + 1 if upper in MONTHS else Nonedef iso_date(year, month, day): return date(int(year), int(month), int(day)).isoformat()def read_start(text): """The start as ISO 8601 text at the precision collected, or "".""" if not text: return "" if re.fullmatch(r"[0-9]{4}-[0-9]{2}-[0-9]{2}", text): return iso_date(text[:4], text[5:7], text[8:]) match = re.fullmatch(r"([0-9]{2})([A-Za-z]{3})([0-9]{4})", text) if match and month_number(match[2]): return iso_date(match[3], month_number(match[2]), match[1]) match = re.fullmatch(r"([0-9]{2})/([0-9]{2})/([0-9]{4})", text) if match: # The month comes first. return iso_date(match[3], match[1], match[2]) if re.fullmatch(r"[0-9]{8}", text): return iso_date(text[:4], text[4:6], text[6:]) match = re.fullmatch(r"([A-Za-z]{3})([0-9]{4})", text) if match and month_number(match[1]): # A month alone. return f"{match[2]}-{month_number(match[1]):02d}" raise ValueError(f"CMSTDAT {text!r} is in none of the five spellings")def main(): with open(f"{INPUT_DIR}/cm.csv", newline="") as handle: cm = list(csv.DictReader(handle)) fieldnames = ["STUDYID", "USUBJID", "CMSEQ", "CMTRT", "CMSTDAT", "ASTDTC", "ASTDT"] with open(f"{OUTPUT_DIR}/adcm.csv", "w", newline="") as handle: writer = csv.DictWriter(handle, fieldnames=fieldnames) writer.writeheader() for row in cm: astdtc = read_start(row["CMSTDAT"]) # A month alone starts on its first day. astdt = astdtc + "-01" if len(astdtc) == 7 else astdtc writer.writerow( { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "CMSEQ": row["CMSEQ"], "CMTRT": row["CMTRT"], "CMSTDAT": row["CMSTDAT"], "ASTDTC": astdtc, "ASTDT": astdt, } )if __name__ == "__main__": main()solutions/adam-adcm-free-text-start-date/result.sas
Edit41 lines/* opensas reference solution for the yamaa benchmark adam-adcm-free-text-start-date. 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 CMSTDAT $1024; infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. CMSEQ CMTRT : $char1024. CMSTDAT : $char1024.;run;/* The start is read in five spellings: YYYY-MM-DD, DDMONYYYY and MONYYYY (the month in any letter case), MM/DD/YYYY with the month first, and YYYYMMDD. MONYYYY gives a month alone, which starts on its first day. */data result; length ASTDTC $10 ASTDT $10 TEXT $1024; set cm; TEXT=upcase(strip(CMSTDAT)); ASTDTC=''; ASTDT=''; len=lengthn(TEXT); day=.; if len=10 and substr(TEXT, 5, 1)='-' then day=input(TEXT, yymmdd10.); else if len=9 then day=input(TEXT, date9.); else if len=10 and substr(TEXT, 3, 1)='/' then day=input(TEXT, mmddyy10.); else if len=8 then day=input(TEXT, yymmdd8.); else if len=7 then do; first=input(cats('01', TEXT), date9.); if not missing(first) then do; ASTDTC=substr(put(first, yymmdd10.), 1, 7); ASTDT=put(first, yymmdd10.); end; end; if not missing(day) then do; ASTDTC=put(day, yymmdd10.); ASTDT=ASTDTC; end;run;proc sql; create table final as select STUDYID, USUBJID, CMSEQ, CMTRT, CMSTDAT, ASTDTC, ASTDT from result;quit;proc export data=final outfile="/app/output/adcm.csv" dbms=csv replace; run;
yamaa