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: write one dose record of a population PK dataset for each exposure record that covers repeated administrations of one dose: the date/time of the first administration (ADTM), the dose (AMT), the hours between administrations (II) and how many administrations follow the first (ADDL).

Input: exposure (EX) records with the dose (EXDOSE), the dosing frequency (EXDOSFRQ: QD once a day, BID twice a day, ONCE a single dose) and the start and end of dosing (EXSTDTC, EXENDTC), each collected with or without a time of day. A record with a dose above zero gives one dose record, identified by its sequence number (EXSEQ).

Variables:

  • ADTM: the first administration, the start as collected; a start with no time of day is taken at 00:00:00.
  • ATMF: H when the time of day of ADTM was not collected; empty otherwise.
  • EVID: 1, a dose record.
  • AMT: the dose given at each administration.
  • II: the hours between administrations; 0 when ADDL is 0, since a record of one dose has no interval.
  • ADDL: the number of administrations after the first, one every interval of the frequency (24 hours for QD, 12 for BID) for as long as the next one is not after the end of dosing. An end with no time of day covers its whole day. 0 for a single dose and for a record with no end.

Note: the end of dosing only bounds the administrations and is not one itself, so a record ending before the day's dose time has its last administration the day before.

Inputs

Under review
1 source file

input/ex.csv

Edit
8 rows
input/ex.csv
STUDYIDUSUBJIDEXSEQEXTRTEXDOSEEXDOSUEXDOSFRQEXSTDTCEXENDTC
YAMAA-011DRUG X100mgQD2025-03-10T08:002025-03-16T08:00
YAMAA-012DRUG X50mgBID2025-03-17T08:002025-03-19T20:00
YAMAA-011DRUG X100mgQD2025-03-10T08:002025-03-14T07:00
YAMAA-012DRUG X0mgQD2025-03-15T08:002025-03-16T08:00
YAMAA-011DRUG X100mgQD2025-03-10T09:002025-03-12
YAMAA-012DRUG X100mgONCE2025-03-20T08:30—
YAMAA-011DRUG X100mgQD2025-03-102025-03-13T10:00
YAMAA-012DRUG X100mgQD2025-03-20T08:00—

Expected output

Under review
7 expected rows

expected/adppk.csv

Edit
7 rows
expected/adppk.csv
STUDYIDUSUBJIDEXSEQADTMATMFEVIDAMTIIADDL
YAMAA-0112025-03-10T08:00:00—1100246
YAMAA-0122025-03-17T08:00:00—150125
YAMAA-0112025-03-10T08:00:00—1100243
YAMAA-0112025-03-10T09:00:00—1100242
YAMAA-0122025-03-20T08:30:00—110000
YAMAA-0112025-03-10T00:00:00H1100243
YAMAA-0122025-03-20T08:00:00—110000
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
ADPPKSTUDYIDStudy IdentifiercharacterCopy value from EX.STUDYID.Predecessor
ADPPKUSUBJIDUnique Subject IdentifiercharacterCopy value from EX.USUBJID.Predecessor
ADPPKEXSEQSequence NumbernumericCopy value from EX.EXSEQ.Predecessor
ADPPKADTMAnalysis Date/TimenumericISO 8601Impute incomplete datetime from EX.EXSTDTC, giving each time part the source lacks its earliest value; a source without a complete date gives blank; invalid text is an error.Derived
ADPPKATMFAnalysis Time Imputation FlagcharacterHTime imputation flag for ADTM: "H" when the whole time was imputed, "M" when the minutes were; blank when the minutes were collected, since the study does not collect seconds.Derived
ADPPKEVIDEvent IDnumericSet constant value "1".Assigned
ADPPKAMTActual Amount of Dose ReceivednumericCopy value from EX.EXDOSE.Predecessor
ADPPKADDLNumber of Additional DosesnumericIf FREQH = 0 then "0"; otherwise compute FLOOR(SPANH / FREQH).Derived
ADPPKIIDosing Interval (h)numericIf ADDL = 0 then "0"; otherwise "FREQH".Derived
VariablePermitted values
ATMFH
VersionDateAuthorDescriptionReviewerSign-off
1.82026-11-19yamaa docs buildState open and closed range endpoints, including bounds of zero
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-adppk-dose-intervals/full.md

Edit
33 lines

Following CDISC ADaM standards, use the provided EX dataset to create an ADPPK dataset with one record per EX record with a dose (EXDOSE) above zero.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, EXSEQ, ADTM, ATMF, EVID, AMT, II, ADDL

Each output record is the dose record of one EX record, which covers repeated administrations of one dose, and is identified by the EXSEQ of that EX record. The dosing frequency (EXDOSFRQ) is "QD" once a day, "BID" twice a day or "ONCE" a single dose. The start and the end of dosing (EXSTDTC, EXENDTC) are each collected with or without a time of day.

  • ADTM is the date/time of the first administration, in the form YYYY-MM-DDThh:mm:ss: the start of dosing as collected, with seconds 00. A start with no time of day is taken at 00:00:00.
  • ATMF is "H" when the time of day of ADTM was not collected and has no value otherwise. Seconds are never collected in this study, so a time collected to the minute is not flagged.
  • EVID is 1, a dose record.
  • AMT is the dose given at each administration, EXDOSE.
  • ADDL is the number of administrations after the first. They follow one every interval of the frequency, 24 hours for "QD" and 12 hours for "BID", for as long as the next one is not after the end of dosing; one exactly at the end counts. An end with no time of day covers its whole day. The end only bounds the administrations and is not one itself, so a record ending before the day's dose time has its last administration the day before. ADDL is 0 for a single dose and for a record with no end.
  • II is the hours between administrations, 24 or 12, and 0 when ADDL is 0, since a record of one dose has no interval.

Read the source datasets from /app/input and save the completed dataset as /app/output/adppk.csv.

prompts/adam-adppk-dose-intervals/conventions.md

Edit
13 lines

Following CDISC ADaM standards, use the provided EX dataset to create an ADPPK dataset with one record per EX record with a dose (EXDOSE) above zero.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, EXSEQ, ADTM, ATMF, EVID, AMT, II, ADDL

  • ADTM is in the form YYYY-MM-DDThh:mm:ss.
  • ATMF is "H" or has no value.
  • EVID is 1.
  • II is 24, 12, or 0.

Read the source datasets from /app/input and save the completed dataset as /app/output/adppk.csv.

prompts/adam-adppk-dose-intervals/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided EX dataset to create an ADPPK dataset with one record per EX record with a dose (EXDOSE) above zero.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, EXSEQ, ADTM, ATMF, EVID, AMT, II, ADDL

Read the source datasets from /app/input and save the completed dataset as /app/output/adppk.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-adppk-dose-intervals/result.R

Edit
66 lines
# Reference solution for the yamaa benchmark adam-adppk-dose-intervals (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.suppressPackageStartupMessages({  library(dplyr)  library(readr)  library(stringr)})ex <- read_csv(  "/app/input/ex.csv",  col_types = cols(.default = col_character()),  na = c("", "NA"))has_time <- function(x) !is.na(x) & str_detect(x, "T[0-9]{2}")to_datetime <- function(x) {  date <- str_sub(x, 1, 10)  time <- if_else(has_time(x), str_sub(x, 12), "00:00")  time <- case_when(    str_detect(time, "^[0-9]{2}$") ~ paste0(time, ":00:00"),    str_detect(time, "^[0-9]{2}:[0-9]{2}$") ~ paste0(time, ":00"),    TRUE ~ str_sub(time, 1, 8)  )  as.POSIXct(    if_else(is.na(x), NA_character_, paste(date, time)),    format = "%Y-%m-%d %H:%M:%S",    tz = "UTC"  )}adppk <- ex %>%  mutate(    EXSEQ = as.numeric(EXSEQ),    EXDOSE = as.numeric(EXDOSE)  ) %>%  filter(!is.na(EXDOSE), EXDOSE > 0) %>%  mutate(    start = to_datetime(EXSTDTC),    end_time = has_time(EXENDTC),    end = to_datetime(EXENDTC),    interval = case_when(      EXDOSFRQ == "QD" ~ 24,      EXDOSFRQ == "BID" ~ 12,      TRUE ~ NA_real_    ),    span = as.numeric(difftime(end, start, units = "secs")),    count = if_else(      end_time,      floor(span / (interval * 3600)),      ceiling((span + 86400) / (interval * 3600)) - 1    ),    ADTM = format(start, "%Y-%m-%dT%H:%M:%S"),    ATMF = if_else(has_time(EXSTDTC), NA_character_, "H"),    EVID = 1,    AMT = EXDOSE,    ADDL = if_else(is.na(count) | count < 0, 0, count),    II = if_else(ADDL > 0, interval, 0)  ) %>%  select(STUDYID, USUBJID, EXSEQ, ADTM, ATMF, EVID, AMT, II, ADDL)write_csv(adppk, "/app/output/adppk.csv", na = "")

solutions/adam-adppk-dose-intervals/result.py

Edit
72 lines
# Reference solution for the yamaa benchmark adam-adppk-dose-intervals (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 datetime import datetime, timedeltaimport pandas as pdINTERVAL_HOURS = {"QD": 24, "BID": 12}def parse(dtc):    """Return (datetime, has_time) for an ISO 8601 date or date/time, or (None, False)."""    dtc = (dtc or "").strip()    if not dtc:        return None, False    if "T" in dtc:        date, time = dtc.split("T", 1)        parts = [int(p) for p in time.split(":") if p != ""]        if parts:            parts += [0] * (3 - len(parts))            return datetime.fromisoformat(date) + timedelta(                hours=parts[0], minutes=parts[1], seconds=parts[2]            ), True        dtc = date    return datetime.fromisoformat(dtc), Falsedef derive(row):    start, start_has_time = parse(row["EXSTDTC"])    end, end_has_time = parse(row["EXENDTC"])    if end is not None and not end_has_time:        end += timedelta(days=1) - timedelta(seconds=1)    interval = INTERVAL_HOURS.get(row["EXDOSFRQ"].strip().upper())    addl = 0    if interval is not None and start is not None and end is not None and end >= start:        addl = int((end - start) // timedelta(hours=interval))    ii = interval if addl > 0 else 0    return pd.Series(        {            "ADTM": start.strftime("%Y-%m-%dT%H:%M:%S") if start is not None else "",            "ATMF": "" if start_has_time or start is None else "H",            "EVID": 1,            "AMT": row["EXDOSE"],            "II": ii,            "ADDL": addl,        }    )def main():    ex = pd.read_csv(        "/app/input/ex.csv",        dtype={"STUDYID": str, "USUBJID": str, "EXDOSFRQ": str, "EXSTDTC": str, "EXENDTC": str},        keep_default_na=False,        na_values={"EXDOSE": [""]},    )    ex = ex[ex["EXDOSE"] > 0].reset_index(drop=True)    derived = ex.apply(derive, axis=1)    out = pd.concat([ex[["STUDYID", "USUBJID", "EXSEQ"]], derived], axis=1)    out["AMT"] = ex["EXDOSE"]    out = out.astype({"EVID": int, "II": int, "ADDL": int})    out = out[["STUDYID", "USUBJID", "EXSEQ", "ADTM", "ATMF", "EVID", "AMT", "II", "ADDL"]]    out.to_csv("/app/output/adppk.csv", index=False)if __name__ == "__main__":    main()

solutions/adam-adppk-dose-intervals/result.sas

Edit
58 lines
/* opensas reference solution for the yamaa benchmark adam-adppk-dose-intervals.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adppk;  infile "/app/input/ex.csv" dsd dlm=',' firstobs=2 truncover;  length STUDYID $20 USUBJID $40 EXSEQ 8 EXTRT $40 EXDOSE 8 EXDOSU $20         EXDOSFRQ $20 EXSTDTC $30 EXENDTC $30         ADTM $19 ATMF $1 EVID 8 AMT 8 II 8 ADDL 8;  input STUDYID $ USUBJID $ EXSEQ EXTRT $ EXDOSE EXDOSU $ EXDOSFRQ $ EXSTDTC $ EXENDTC $;  EXSTDTC = strip(compress(EXSTDTC, '0D'x));  EXENDTC = strip(compress(EXENDTC, '0D'x));  EXDOSFRQ = upcase(strip(compress(EXDOSFRQ, '0D'x)));  if EXDOSE > 0;  stdt = input(substr(EXSTDTC, 1, 10), yymmdd10.);  if index(EXSTDTC, 'T') = 11 and length(EXSTDTC) >= 16 then do;    sth = input(substr(EXSTDTC, 12, 2), 2.);    stm = input(substr(EXSTDTC, 15, 2), 2.);    ATMF = ' ';  end;  else do;    sth = 0;    stm = 0;    ATMF = 'H';  end;  stdtm = stdt * 86400 + sth * 3600 + stm * 60;  ADTM = substr(EXSTDTC, 1, 10) || 'T' || put(sth, z2.) || ':' || put(stm, z2.) || ':00';  EVID = 1;  AMT = EXDOSE;  if EXDOSFRQ = 'QD' then step = 24;  else if EXDOSFRQ = 'BID' then step = 12;  else step = 0;  ADDL = 0;  if step > 0 and EXENDTC ne ' ' then do;    endt = input(substr(EXENDTC, 1, 10), yymmdd10.);    if index(EXENDTC, 'T') = 11 and length(EXENDTC) >= 16 then      endtm = endt * 86400 + input(substr(EXENDTC, 12, 2), 2.) * 3600              + input(substr(EXENDTC, 15, 2), 2.) * 60;    else endtm = endt * 86400 + 86399;    if endtm >= stdtm then ADDL = floor((endtm - stdtm) / (step * 3600));  end;  if ADDL > 0 then II = step;  else II = 0;  keep STUDYID USUBJID EXSEQ ADTM ATMF EVID AMT II ADDL;run;data adppk;  retain STUDYID USUBJID EXSEQ ADTM ATMF EVID AMT II ADDL;  set adppk;run;proc export data=adppk outfile="/app/output/adppk.csv" dbms=csv replace;run;