Review ask

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

Lifecycle: draftEditUnder review
What this benchmark means
README.md

Public 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:

  • ASTDTC is the start as ISO 8601 text at the precision it was collected: 2001-03-04 for a full date and 2001-03 for a month alone. It is empty when no start was collected.
  • ASTDT is 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 review
1 source file

input/cm.csv

Edit
7 rows
input/cm.csv
STUDYIDUSUBJIDCMSEQCMTRTCMSTDAT
YAMAA-011Paracetamol2001-03-04
YAMAA-012Ibuprofen04MAR2001
YAMAA-011Omeprazole03/04/2001
YAMAA-012Loratadine20010304
YAMAA-011AmoxicillinMAR2001
YAMAA-012Cetirizine04mar2001
YAMAA-013Metformin—

Expected output

Under review
7 expected rows

expected/adcm.csv

Edit
7 rows
expected/adcm.csv
STUDYIDUSUBJIDCMSEQCMTRTCMSTDATASTDTCASTDT
YAMAA-011Paracetamol2001-03-042001-03-042001-03-04
YAMAA-012Ibuprofen04MAR20012001-03-042001-03-04
YAMAA-011Omeprazole03/04/20012001-03-042001-03-04
YAMAA-012Loratadine200103042001-03-042001-03-04
YAMAA-011AmoxicillinMAR20012001-032001-03-01
YAMAA-012Cetirizine04mar20012001-03-042001-03-04
YAMAA-013Metformin———
Shaded columns are derived— = missing value

Human review and assessment

Your review

3 questions and your comments · View benchmark discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADCMSTUDYIDStudy IdentifiercharacterCopy value from CM.STUDYID.Predecessor
ADCMUSUBJIDUnique Subject IdentifiercharacterCopy value from CM.USUBJID.Predecessor
ADCMCMSEQSequence NumbernumericCopy value from CM.CMSEQ.Predecessor
ADCMCMTRTReported Name of Drug, Medication, or TherapycharacterCopy value from CM.CMTRT.Predecessor
ADCMCMSTDATCollected Start DatecharacterCopy value from CM.CMSTDAT.Predecessor
ADCMASTDTCAnalysis Start Date TextcharacterRead 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
ADCMASTDTAnalysis Start DatenumericISO 8601Impute incomplete date from ASTDTC, defaulting day=first; a year alone gives blank; invalid text is an error.Derived
VersionDateAuthorDescriptionReviewerSign-off
1.72026-10-20yamaa docs buildRead 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.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName 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.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
1.32026-09-29yamaa docs buildShow study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata
1.22026-09-29yamaa docs buildClassify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived
1.12026-09-29yamaa docs buildResolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML
1.0yamaa docs buildInitial generation from spec.yaml

Agent prompt

The request an agent receives with the input files; each tier states no more than the one above

prompts/adam-adcm-free-text-start-date/full.md

Edit
26 lines

Following 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

Edit
11 lines

Following 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

Edit
9 lines

Following 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.

yamaa code

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/adam-adcm-free-text-start-date/result.R

Edit
61 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

Edit
89 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

Edit
41 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;