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: mark each Analysis Data Model (ADaM) adverse event record
with AFTIDXFL when it starts after the subject's index event -- the
subject's first occurrence of a designated term (in the sample data,
COVID-19).
Input: one record per adverse event (AE), carrying the coded term
AEDECOD and the event start date AESTDTC (kept in the output as
ASTDT).
Variables:
AFTIDXFL:Yfor an event ordered strictly after the subject's index event: a later start date, or the same start date with a higher sequence number. Blank otherwise: the index event itself, every record of a subject with no index event, and any record with no start date.
Note: ordering is within each subject by start date, with the
sequence number (AESEQ) breaking ties on the same date.
Inputs
Under review1 source fileinput/ae.csv
Edit11 rows| STUDYID | USUBJID | AESEQ | AEDECOD | AESTDTC |
|---|---|---|---|---|
| YAMAA-01 | 1 | HEADACHE | 2023-01-10 | |
| YAMAA-01 | 2 | COVID-19 | 2023-01-15 | |
| YAMAA-01 | 3 | COUGH | 2023-01-15 | |
| YAMAA-01 | 4 | FATIGUE | 2023-01-20 | |
| YAMAA-01 | 5 | NAUSEA | — | |
| YAMAA-01 | 1 | NAUSEA | 2023-02-01 | |
| YAMAA-01 | 2 | FATIGUE | 2023-02-04 | |
| YAMAA-01 | 1 | COVID-19 | 2023-03-01 | |
| YAMAA-01 | 2 | COVID-19 | 2023-03-01 | |
| YAMAA-01 | 3 | PYREXIA | 2023-03-03 | |
| YAMAA-01 | 1 | COVID-19 | 2023-04-05 |
Expected output
Under review11 expected rowsexpected/adae.csv
Edit11 rows| STUDYID | USUBJID | AESEQ | AEDECOD | ASTDT | AFTIDXFL |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | HEADACHE | 2023-01-10 | — | |
| YAMAA-01 | 2 | COVID-19 | 2023-01-15 | — | |
| YAMAA-01 | 3 | COUGH | 2023-01-15 | Y | |
| YAMAA-01 | 4 | FATIGUE | 2023-01-20 | Y | |
| YAMAA-01 | 5 | NAUSEA | — | — | |
| YAMAA-01 | 1 | NAUSEA | 2023-02-01 | — | |
| YAMAA-01 | 2 | FATIGUE | 2023-02-04 | — | |
| YAMAA-01 | 1 | COVID-19 | 2023-03-01 | — | |
| YAMAA-01 | 2 | COVID-19 | 2023-03-01 | Y | |
| YAMAA-01 | 3 | PYREXIA | 2023-03-03 | Y | |
| YAMAA-01 | 1 | COVID-19 | 2023-04-05 | — |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADAE | STUDYID | Study Identifier | character | Copy value from AE.STUDYID. | Predecessor | ||
| ADAE | USUBJID | Unique Subject Identifier | character | Copy value from AE.USUBJID. | Predecessor | ||
| ADAE | AESEQ | Sequence Number | numeric | Copy value from AE.AESEQ. | Predecessor | ||
| ADAE | AEDECOD | Dictionary-Derived Term | character | Copy value from AE.AEDECOD. | Predecessor | ||
| ADAE | ASTDT | Analysis Start Date | numeric | ISO 8601 | Copy value from AE.AESTDTC. | Predecessor | |
| ADAE | AFTIDXFL | After Index Event Flag | character | "Y" when ASTDT > AESTDTC OR (ASTDT = AESTDTC AND AESEQ > AESEQ), with AESTDTC taken from the first AE record matching on STUDYID and USUBJID, where AE.AEDECOD = 'COVID-19', ordered by AE.AESTDTC then AE.AESEQ, and no match yields blank and AESEQ taken from the first AE record matching on STUDYID and USUBJID, where AE.AEDECOD = 'COVID-19', ordered by AE.AESTDTC then AE.AESEQ, and no match yields blank; blank otherwise. | 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-adae-post-index/full.md
Edit18 linesFollowing CDISC ADaM standards, use the provided AE dataset to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, AFTIDXFL
The index event for a subject is the subject's first record with AEDECOD "COVID-19", ordered within the subject by ASTDT, with AESEQ breaking ties between records that share a start date.
AFTIDXFL is "Y" for a record ordered strictly after the subject's index event: a record with a later ASTDT than the index event, or the same ASTDT and a higher AESEQ. AFTIDXFL has no value otherwise: for the index event itself, for every record of a subject with no index event, and for any record with no start date.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-post-index/conventions.md
Edit10 linesFollowing CDISC ADaM standards, use the provided AE dataset to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, AFTIDXFL
AFTIDXFL is "Y" or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-post-index/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided AE dataset to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, AFTIDXFL
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adae-post-index/result.R
Edit37 lines# Reference solution for the yamaa benchmark adam-adae-post-index (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)ae <- read_csv( "/app/input/ae.csv", col_types = cols(AESEQ = col_integer(), .default = col_character()))# Each subject's index event: the earliest start date, with the# higher sequence number ordered after on the same date.first_index <- ae |> filter(AEDECOD %in% "COVID-19", !is.na(AESTDTC), AESTDTC != "") |> arrange(USUBJID, AESTDTC, AESEQ) |> distinct(USUBJID, .keep_all = TRUE) |> select(USUBJID, FIRST_DT = AESTDTC, FIRST_SEQ = AESEQ)adae <- ae |> left_join(first_index, by = "USUBJID") |> mutate( ASTDT = if_else(is.na(AESTDTC) | AESTDTC == "", NA_character_, AESTDTC), AFTIDXFL = if_else( !is.na(ASTDT) & !is.na(FIRST_DT) & (ASTDT > FIRST_DT | (ASTDT == FIRST_DT & AESEQ > FIRST_SEQ)), "Y", NA_character_ ) ) |> select(STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, AFTIDXFL)dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")solutions/adam-adae-post-index/result.py
Edit78 lines# Reference solution for the yamaa benchmark adam-adae-post-index (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."""Create ADAE from AE: flag records strictly after each subject'sindex event (first COVID-19 record by ASTDT, AESEQ breaking ties)."""import csvfrom datetime import dateINPUT_AE = "/app/input/ae.csv"OUTPUT_ADAE = "/app/output/adae.csv"COLUMNS = ["STUDYID", "USUBJID", "AESEQ", "AEDECOD", "ASTDT", "AFTIDXFL"]def parse_date(text): text = (text or "").strip() if not text: return None return date.fromisoformat(text)def main(): with open(INPUT_AE, newline="", encoding="utf-8") as f: rows = list(csv.DictReader(f)) for row in rows: row["_astdt"] = parse_date(row["AESTDTC"]) row["_aeseq"] = int(row["AESEQ"]) # Index event per subject: first COVID-19 record ordered by ASTDT, # AESEQ breaking ties; records with no start date order last. index = {} for row in rows: if row["AEDECOD"] != "COVID-19": continue key = ( row["_astdt"] is None, row["_astdt"] or date.min, row["_aeseq"], ) subject = row["USUBJID"] if subject not in index or key < index[subject][0]: index[subject] = (key, row) out = [] for row in rows: flag = "" subject = row["USUBJID"] if subject in index and row["_astdt"] is not None: _, idx = index[subject] if row["_astdt"] > idx["_astdt"] or ( row["_astdt"] == idx["_astdt"] and row["_aeseq"] > idx["_aeseq"] ): flag = "Y" out.append( { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "AESEQ": row["AESEQ"], "AEDECOD": row["AEDECOD"], "ASTDT": row["_astdt"].isoformat() if row["_astdt"] else "", "AFTIDXFL": flag, } ) with open(OUTPUT_ADAE, "w", newline="", encoding="utf-8") as f: writer = csv.DictWriter(f, fieldnames=COLUMNS) writer.writeheader() writer.writerows(out)if __name__ == "__main__": main()solutions/adam-adae-post-index/result.sas
Edit22 lines/* opensas reference solution for the yamaa benchmark adam-adae-post-index. 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 AEDECOD AESTDTC $1024; infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AESEQ AEDECOD : $char1024. AESTDTC : $char1024.;run;proc sort data=ae(where=(AEDECOD='COVID-19' and AESTDTC ne '')) out=indices; by STUDYID USUBJID AESTDTC AESEQ; run;data firstindex; set indices; by STUDYID USUBJID; if first.USUBJID; run;proc sql; create table result as select a.*,a.AESTDTC as ASTDT, case when not missing(a.AESTDTC) and not missing(b.AESTDTC) and (a.AESTDTC>b.AESTDTC or (a.AESTDTC=b.AESTDTC and a.AESEQ>b.AESEQ)) then 'Y' else '' end as AFTIDXFL from ae as a left join firstindex as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID;quit;proc sql; create table final as select STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, AFTIDXFL from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;
yamaa