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: reviewedEditUnder review
What this benchmark means
README.md

Public entries: Python and R. Passing coverage requires an installed inventory.

Goal: build one record per enrolled subject carrying informed consent date (RFICDTC), first and last exposure dates (RFXSTDTC, RFXENDTC), reference start date (RFSTDTC), last participation date (RFPENDTC), and reference end date (RFENDTC).

Input: collected demographics rows with consent date, exposure rows with start and end dates and sequence number, disposition rows with category and start date, and adverse event rows with end date.

Variables:

  • RFICDTC is the consent date as collected; it is required, so a subject with no consent date stops the run.
  • RFXSTDTC is the earliest exposure start date; missing when no exposure row carries a start date.
  • RFXENDTC is the latest exposure end date; missing when no exposure row carries an end date.
  • RFSTDTC is the reference start date, taken here as the first exposure date, so it is missing whenever RFXSTDTC is.
  • RFPENDTC is the last date the subject is known to have participated: the latest of the last exposure end date, the latest disposition event date, and the latest adverse event end date. A missing one is skipped; it is missing only when all three are.
  • RFENDTC is the reference end date, the end of the subject's reference period. It is missing whenever RFSTDTC is missing, so a subject who never entered the reference period has no end date.

Note: exposure, disposition, and adverse event rows count only for the subject with the same study and subject identifiers, so the same subject identifier in two studies gives two independent records, and a subject with no exposure has missing exposure, reference start, and reference end dates.

Inputs

Under review
4 source files

input/ae.csv

Edit
2 rows
input/ae.csv
STUDYIDUSUBJIDAESEQAETERMAESTDTCAEENDTC
CATH1HEADACHE2025-01-202025-02-03
CATH1NAUSEA2025-04-182025-04-20

input/dm_raw.csv

Edit
6 rows
input/dm_raw.csv
STUDYIDUSUBJIDRFICDTC
CATH2025-01-02
CATH2025-02-01
CATH2025-03-01
CATH2025-04-01
CATH2025-06-01
CATH22025-05-01

input/ds.csv

Edit
5 rows
input/ds.csv
STUDYIDUSUBJIDDSSEQDSCATDSDECODDSSTDTC
CATH1DISPOSITION EVENTCOMPLETED2025-01-29
CATH1DISPOSITION EVENTADVERSE EVENT2025-02-21
CATH2PROTOCOL MILESTONEWEEK 4 VISIT2025-03-10
CATH1DISPOSITION EVENTSCREEN FAILURE2025-03-02
CATH21DISPOSITION EVENTCOMPLETED2025-05-20

input/ex.csv

Edit
6 rows
input/ex.csv
STUDYIDUSUBJIDEXSEQEXTRTEXDOSEEXSTDTCEXENDTC
CATH1VITAMIN D310002025-01-082025-01-14
CATH2VITAMIN D320002025-01-152025-01-28
CATH1PLACEBO02025-02-082025-02-20
CATH1VITAMIN D310002025-04-052025-04-26
CATH1VITAMIN D310002025-06-022025-06-15
CATH21VITAMIN D310002025-05-062025-05-19

Expected output

Under review
6 expected rows

expected/dm.csv

Edit
6 rows
expected/dm.csv
DOMAINSTUDYIDUSUBJIDRFICDTCRFXSTDTCRFXENDTCRFSTDTCRFPENDTCRFENDTC
DMCATH2025-01-022025-01-082025-01-282025-01-082025-02-032025-02-03
DMCATH2025-02-012025-02-082025-02-202025-02-082025-02-212025-02-21
DMCATH2025-03-01———2025-03-02—
DMCATH2025-04-012025-04-052025-04-262025-04-052025-04-262025-04-26
DMCATH2025-06-01—————
DMCATH22025-05-012025-05-062025-05-192025-05-062025-05-202025-05-20
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

Variable NameVariable LabelTypeLengthControlled Terms or FormatOriginCoreConversion DefinitionVariable TypeVariable OrderComments for Define
DOMAINDomain AbbreviationCharAssignedSet constant value "DM".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from DM_RAW.STUDYID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from DM_RAW.USUBJID.SDTM3
RFICDTCDate/Time of Informed ConsentCharISO 8601CollectedCopy value from DM_RAW.RFICDTC.SDTM4
RFXSTDTCDate/Time of First Study TreatmentCharISO 8601DerivedAggregate MIN(EX.EXSTDTC) over records matching on the shared output keys.SDTM5
RFXENDTCDate/Time of Last Study TreatmentCharISO 8601DerivedTake EXENDTC from the last EX record matching on STUDYID and USUBJID, where EX.EXENDTC IS NOT NULL, ordered by EX.EXENDTC then EX.EXSEQ, and no match yields blank.SDTM6
RFSTDTCSubject Reference Start Date/TimeCharISO 8601DerivedCopy value from RFXSTDTC.SDTM7
RFPENDTCDate/Time of Last Study ParticipationCharISO 8601DerivedGreatest of RFXENDTC, DSDT0 and AEDT0.SDTM8
RFENDTCSubject Reference End Date/TimeCharISO 8601DerivedIf RFSTDTC IS NULL then "None"; otherwise "RFPENDTC".SDTM9
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/sdtm-dm-dates/full.md

Edit
30 lines

Following CDISC SDTM standards, use the provided AE, DM_RAW, DS, and EX datasets to create a DM dataset with one record per enrolled subject.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC

DOMAIN is "DM". Exposure, disposition, and adverse event records count only for the subject with the same STUDYID and USUBJID.

RFXSTDTC is the earliest exposure start date, and has no value when no exposure record of the subject carries a start date. RFXENDTC is the latest exposure end date, and has no value when no exposure record of the subject carries an end date. RFSTDTC is the first exposure date: the same date as RFXSTDTC, with no value whenever RFXSTDTC has no value.

RFPENDTC is the last date the subject is known to have participated: the latest of the last exposure end date, the latest disposition event date, and the latest adverse event end date. A disposition event is a disposition record whose category is "DISPOSITION EVENT", and its date is the record's start date. A date that has no value is left out, and RFPENDTC has no value only when all three dates have no value.

RFENDTC is the end of the subject's reference period: it is the same date as RFPENDTC, and it has no value whenever RFSTDTC has no value, so a subject who never entered the reference period has no reference end date.

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

prompts/sdtm-dm-dates/conventions.md

Edit
11 lines

Following CDISC SDTM standards, use the provided AE, DM_RAW, DS, and EX datasets to create a DM dataset with one record per enrolled subject.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC

DOMAIN is "DM".

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

prompts/sdtm-dm-dates/brief.md

Edit
9 lines

Following CDISC SDTM standards, use the provided AE, DM_RAW, DS, and EX datasets to create a DM dataset with one record per enrolled subject.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC

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

Edit
81 lines
# Reference solution for the yamaa benchmark sdtm-dm-dates (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_raw <- read_csv(  "/app/input/dm_raw.csv",  col_types = cols(.default = col_character()))ex <- read_csv(  "/app/input/ex.csv",  col_types = cols(.default = col_character()))ds <- read_csv(  "/app/input/ds.csv",  col_types = cols(.default = col_character()))ae <- read_csv(  "/app/input/ae.csv",  col_types = cols(.default = col_character()))ex_sum <- ex |>  mutate(    EXSTDTC = suppressWarnings(as.Date(EXSTDTC)),    EXENDTC = suppressWarnings(as.Date(EXENDTC))  ) |>  group_by(STUDYID, USUBJID) |>  summarise(    RFXSTDTC = suppressWarnings(min(EXSTDTC, na.rm = TRUE)),    RFXENDTC = suppressWarnings(max(EXENDTC, na.rm = TRUE)),    .groups = "drop"  ) |>  mutate(    RFXSTDTC = as.Date(ifelse(is.infinite(as.numeric(RFXSTDTC)), NA, RFXSTDTC), origin = "1970-01-01"),    RFXENDTC = as.Date(ifelse(is.infinite(as.numeric(RFXENDTC)), NA, RFXENDTC), origin = "1970-01-01")  )ds_sum <- ds |>  filter(DSCAT == "DISPOSITION EVENT") |>  mutate(DSSTDTC = suppressWarnings(as.Date(DSSTDTC))) |>  group_by(STUDYID, USUBJID) |>  summarise(    DS_MAX = suppressWarnings(max(DSSTDTC, na.rm = TRUE)),    .groups = "drop"  ) |>  mutate(    DS_MAX = as.Date(ifelse(is.infinite(as.numeric(DS_MAX)), NA, DS_MAX), origin = "1970-01-01")  )ae_sum <- ae |>  mutate(AEENDTC = suppressWarnings(as.Date(AEENDTC))) |>  group_by(STUDYID, USUBJID) |>  summarise(    AE_MAX = suppressWarnings(max(AEENDTC, na.rm = TRUE)),    .groups = "drop"  ) |>  mutate(    AE_MAX = as.Date(ifelse(is.infinite(as.numeric(AE_MAX)), NA, AE_MAX), origin = "1970-01-01")  )dm <- dm_raw |>  left_join(ex_sum, by = c("STUDYID", "USUBJID")) |>  left_join(ds_sum, by = c("STUDYID", "USUBJID")) |>  left_join(ae_sum, by = c("STUDYID", "USUBJID")) |>  mutate(    DOMAIN = "DM",    RFSTDTC = RFXSTDTC,    RFPENDTC = pmax(RFXENDTC, DS_MAX, AE_MAX, na.rm = TRUE),    RFPENDTC = as.Date(ifelse(is.infinite(as.numeric(RFPENDTC)), NA, RFPENDTC), origin = "1970-01-01"),    RFENDTC = ifelse(!is.na(RFSTDTC), as.character(RFPENDTC), NA),    RFENDTC = suppressWarnings(as.Date(RFENDTC, origin = "1970-01-01"))  ) |>  select(DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC)dir.create("/app/output", showWarnings = FALSE)write_csv(dm, "/app/output/dm.csv", na = "")

solutions/sdtm-dm-dates/result.py

Edit
151 lines
# Reference solution for the yamaa benchmark sdtm-dm-dates (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 the DM dataset (one record per enrolled subject) from DM_RAW,EX, DS, and AE source datasets, following CDISC SDTM conventions.Reads /app/input/dm_raw.csv, ex.csv, ds.csv, ae.csv and writes/app/output/dm.csv with columns:DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC,RFPENDTC, RFENDTC."""import csvimport osfrom datetime import dateINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"def read_csv(name):    path = os.path.join(INPUT_DIR, name)    with open(path, newline="", encoding="utf-8") as f:        return list(csv.DictReader(f))def clean(value):    """Return the stripped string, or None when the value is missing."""    if value is None:        return None    value = value.strip()    return value if value else Nonedef parse_date(value):    """Parse an ISO date string to a date for comparison; None if absent."""    value = clean(value)    if value is None:        return None    try:        return date.fromisoformat(value)    except ValueError:        return Nonedef main():    dm_raw = read_csv("dm_raw.csv")    ex = read_csv("ex.csv")    ds = read_csv("ds.csv")    ae = read_csv("ae.csv")    def key(row):        return (clean(row.get("STUDYID")), clean(row.get("USUBJID")))    # Per-subject exposure dates.    ex_starts = {}    ex_ends = {}    for row in ex:        k = key(row)        start = parse_date(row.get("EXSTDTC"))        if start is not None:            ex_starts.setdefault(k, []).append((start, clean(row.get("EXSTDTC"))))        end = parse_date(row.get("EXENDTC"))        if end is not None:            ex_ends.setdefault(k, []).append((end, clean(row.get("EXENDTC"))))    # Per-subject latest disposition event date (category DISPOSITION    # EVENT; the date is the record's start date).    ds_event_dates = {}    for row in ds:        if clean(row.get("DSCAT")) != "DISPOSITION EVENT":            continue        d = parse_date(row.get("DSSTDTC"))        if d is not None:            ds_event_dates.setdefault(key(row), []).append(                (d, clean(row.get("DSSTDTC")))            )    # Per-subject latest adverse event end date.    ae_end_dates = {}    for row in ae:        d = parse_date(row.get("AEENDTC"))        if d is not None:            ae_end_dates.setdefault(key(row), []).append(                (d, clean(row.get("AEENDTC")))            )    def earliest(pairs):        return min(pairs)[1] if pairs else ""    def latest(pairs):        return max(pairs)[1] if pairs else ""    out_rows = []    for row in dm_raw:        k = key(row)        rfxstdtc = earliest(ex_starts.get(k, []))        rfxendtc = latest(ex_ends.get(k, []))        rfstdtc = rfxstdtc        candidates = []        if ex_ends.get(k):            candidates.append(max(ex_ends[k]))        if ds_event_dates.get(k):            candidates.append(max(ds_event_dates[k]))        if ae_end_dates.get(k):            candidates.append(max(ae_end_dates[k]))        rfpendtc = max(candidates)[1] if candidates else ""        # The reference end date exists only for a subject who entered        # the reference period (RFSTDTC present).        rfendtc = rfpendtc if rfstdtc else ""        out_rows.append(            {                "DOMAIN": "DM",                "STUDYID": clean(row.get("STUDYID")) or "",                "USUBJID": clean(row.get("USUBJID")) or "",                "RFICDTC": clean(row.get("RFICDTC")) or "",                "RFXSTDTC": rfxstdtc,                "RFXENDTC": rfxendtc,                "RFSTDTC": rfstdtc,                "RFPENDTC": rfpendtc,                "RFENDTC": rfendtc,            }        )    fieldnames = [        "DOMAIN",        "STUDYID",        "USUBJID",        "RFICDTC",        "RFXSTDTC",        "RFXENDTC",        "RFSTDTC",        "RFPENDTC",        "RFENDTC",    ]    os.makedirs(OUTPUT_DIR, exist_ok=True)    out_path = os.path.join(OUTPUT_DIR, "dm.csv")    with open(out_path, "w", newline="", encoding="utf-8") as f:        writer = csv.DictWriter(f, fieldnames=fieldnames)        writer.writeheader()        writer.writerows(out_rows)if __name__ == "__main__":    main()

solutions/sdtm-dm-dates/result.sas

Edit
39 lines
/* opensas reference solution for the yamaa benchmark sdtm-dm-dates.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ae;  length STUDYID USUBJID AETERM AESTDTC AEENDTC $1024;  infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. AESEQ AETERM : $char1024. AESTDTC : $char1024. AEENDTC : $char1024.;run;data dm_raw;  length STUDYID USUBJID RFICDTC $1024;  infile "/app/input/dm_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. RFICDTC : $char1024.;run;data ds;  length STUDYID USUBJID DSCAT DSDECOD DSSTDTC $1024;  infile "/app/input/ds.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. DSSEQ DSCAT : $char1024. DSDECOD : $char1024. DSSTDTC : $char1024.;run;data ex;  length STUDYID USUBJID EXTRT EXSTDTC EXENDTC $1024;  infile "/app/input/ex.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. EXSEQ EXTRT : $char1024. EXDOSE EXSTDTC : $char1024. EXENDTC : $char1024.;run;proc sql;create table starts as select STUDYID,USUBJID,min(EXSTDTC) as RFXSTDTC from ex where not missing(EXSTDTC) group by STUDYID,USUBJID;create table ends as select STUDYID,USUBJID,max(EXENDTC) as RFXENDTC from ex group by STUDYID,USUBJID;create table alldates as select STUDYID,USUBJID,EXENDTC as DTC from ex union all select STUDYID,USUBJID,DSSTDTC as DTC from ds where DSCAT='DISPOSITION EVENT' union all select STUDYID,USUBJID,AEENDTC as DTC from ae;create table lastdate as select STUDYID,USUBJID,max(DTC) as RFPENDTC from alldates group by STUDYID,USUBJID;create table joined as select a.*,b.RFXSTDTC,c.RFXENDTC,d.RFPENDTC from dm_raw a left join starts b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID left join ends c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID left join lastdate d on a.STUDYID=d.STUDYID and a.USUBJID=d.USUBJID; quit;data result; set joined; length DOMAIN $2 RFSTDTC RFENDTC $1024; DOMAIN='DM'; RFSTDTC=RFXSTDTC; if not missing(RFSTDTC) then RFENDTC=RFPENDTC; run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC from result;quit;proc export data=final outfile="/app/output/dm.csv" dbms=csv replace; run;