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: 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:Hwhen the time of day ofADTMwas not collected; empty otherwise.EVID: 1, a dose record.AMT: the dose given at each administration.II: the hours between administrations; 0 whenADDLis 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 forQD, 12 forBID) 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 review1 source fileinput/ex.csv
Edit8 rows| STUDYID | USUBJID | EXSEQ | EXTRT | EXDOSE | EXDOSU | EXDOSFRQ | EXSTDTC | EXENDTC |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | DRUG X | 100 | mg | QD | 2025-03-10T08:00 | 2025-03-16T08:00 | |
| YAMAA-01 | 2 | DRUG X | 50 | mg | BID | 2025-03-17T08:00 | 2025-03-19T20:00 | |
| YAMAA-01 | 1 | DRUG X | 100 | mg | QD | 2025-03-10T08:00 | 2025-03-14T07:00 | |
| YAMAA-01 | 2 | DRUG X | 0 | mg | QD | 2025-03-15T08:00 | 2025-03-16T08:00 | |
| YAMAA-01 | 1 | DRUG X | 100 | mg | QD | 2025-03-10T09:00 | 2025-03-12 | |
| YAMAA-01 | 2 | DRUG X | 100 | mg | ONCE | 2025-03-20T08:30 | — | |
| YAMAA-01 | 1 | DRUG X | 100 | mg | QD | 2025-03-10 | 2025-03-13T10:00 | |
| YAMAA-01 | 2 | DRUG X | 100 | mg | QD | 2025-03-20T08:00 | — |
Expected output
Under review7 expected rowsexpected/adppk.csv
Edit7 rows| STUDYID | USUBJID | EXSEQ | ADTM | ATMF | EVID | AMT | II | ADDL |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | 2025-03-10T08:00:00 | — | 1 | 100 | 24 | 6 | |
| YAMAA-01 | 2 | 2025-03-17T08:00:00 | — | 1 | 50 | 12 | 5 | |
| YAMAA-01 | 1 | 2025-03-10T08:00:00 | — | 1 | 100 | 24 | 3 | |
| YAMAA-01 | 1 | 2025-03-10T09:00:00 | — | 1 | 100 | 24 | 2 | |
| YAMAA-01 | 2 | 2025-03-20T08:30:00 | — | 1 | 100 | 0 | 0 | |
| YAMAA-01 | 1 | 2025-03-10T00:00:00 | H | 1 | 100 | 24 | 3 | |
| YAMAA-01 | 2 | 2025-03-20T08:00:00 | — | 1 | 100 | 0 | 0 |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADPPK | STUDYID | Study Identifier | character | Copy value from EX.STUDYID. | Predecessor | ||
| ADPPK | USUBJID | Unique Subject Identifier | character | Copy value from EX.USUBJID. | Predecessor | ||
| ADPPK | EXSEQ | Sequence Number | numeric | Copy value from EX.EXSEQ. | Predecessor | ||
| ADPPK | ADTM | Analysis Date/Time | numeric | ISO 8601 | Impute 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 | |
| ADPPK | ATMF | Analysis Time Imputation Flag | character | H | Time 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 | |
| ADPPK | EVID | Event ID | numeric | Set constant value "1". | Assigned | ||
| ADPPK | AMT | Actual Amount of Dose Received | numeric | Copy value from EX.EXDOSE. | Predecessor | ||
| ADPPK | ADDL | Number of Additional Doses | numeric | If FREQH = 0 then "0"; otherwise compute FLOOR(SPANH / FREQH). | Derived | ||
| ADPPK | II | Dosing Interval (h) | numeric | If ADDL = 0 then "0"; otherwise "FREQH". | Derived |
| Variable | Permitted values |
|---|---|
| ATMF | H |
| 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-adppk-dose-intervals/full.md
Edit33 linesFollowing 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
Edit13 linesFollowing 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
Edit8 linesFollowing 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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adppk-dose-intervals/result.R
Edit66 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
Edit72 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
Edit58 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;
yamaa