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: create one adverse event (AE) record per reported event from long-form Operational Data Model (ODM) item data.
Input: each collected item has its own ODM row. Items belonging to one event share the subject, visit, visit repeat, form, and form repeat identifiers.
Variables:
AESEQnumbers the subject's events from 1 in visit order (screening, then baseline), then by visit repeat and form repeat; an event at any other visit stops the run.AETERMkeeps the free-text term exactly as reported.AESTDTCandAEENDTCcome from the same event occurrence; a missing end date stays blank.AESEVandAESERcome from that occurrence's severity and seriousness items.
Note: each form occurrence is its own event, so a form repeat number reused at a later visit, or the same term reported in two occurrences, still gives separate records. Only AE forms are read, and an occurrence without a reported term contributes no AE record.
Inputs
Under review1 source fileinput/odm.csv
Edit26 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | FormOID | FormRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.DM | 1 | IG.DM | 1 | IT.DM.SEX | F |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AETERM | Headache |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESTDTC | 2025-01-02 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AEENDTC | 2025-01-03 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESEV | MILD |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESER | N |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AETERM | Nausea |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESTDTC | 2025-01-04 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AEENDTC | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESEV | MODERATE |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESER | N |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AETERM | Headache |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESTDTC | 2025-01-10 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AEENDTC | 2025-01-11 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESEV | MILD |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESER | N |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AETERM | Rash |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESTDTC | 2025-02-02 |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AEENDTC | 2025-02-05 |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESEV | SEVERE |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESER | Y |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AETERM | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESTDTC | 2025-02-03 |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AEENDTC | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESEV | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESER | N |
Expected output
Under review4 expected rowsexpected/ae.csv
Edit4 rows| DOMAIN | STUDYID | USUBJID | AESEQ | AETERM | AESTDTC | AEENDTC | AESEV | AESER |
|---|---|---|---|---|---|---|---|---|
| AE | YAMAA-01 | 1 | Headache | 2025-01-02 | 2025-01-03 | MILD | N | |
| AE | YAMAA-01 | 2 | Nausea | 2025-01-04 | — | MODERATE | N | |
| AE | YAMAA-01 | 3 | Headache | 2025-01-10 | 2025-01-11 | MILD | N | |
| AE | YAMAA-01 | 1 | Rash | 2025-02-02 | 2025-02-05 | SEVERE | Y |
Human review and assessment
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| DOMAIN | Domain Abbreviation | Char | Assigned | Set constant value "AE". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from ODM.SubjectKey. | SDTM | 3 | ||||
| AETERM | Reported Term for the Adverse Event | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 4 | ||||
| AESTDTC | Start Date/Time of Adverse Event | Char | ISO 8601 | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 5 | |||
| AEENDTC | End Date/Time of Adverse Event | Char | ISO 8601 | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 6 | |||
| AESEV | Severity/Intensity | Char | MILD, MODERATE, SEVERE | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 7 | |||
| AESER | Serious Event | Char | Y, N | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 8 | |||
| AESEQ | Sequence Number | Num | Derived | Row number within each group of STUDYID, USUBJID, ordered by EVENTORD then EVENTREPEAT then REPEATKEY. | SDTM | 9 |
| Template | Include when | FORM | AETERM | AESTDTC | AEENDTC | AESEV | AESER |
|---|---|---|---|---|---|---|---|
| collected-occurrence | FORM = 'IG.AE' AND AETERM IS NOT NULL | Copy ODM.ItemGroupOID | Read collected ODM item IT.AE.AETERM; no identified record yields blank | Read collected ODM item IT.AE.AESTDTC; no identified record yields blank | Read collected ODM item IT.AE.AEENDTC; no identified record yields blank | Read collected ODM item IT.AE.AESEV; no identified record yields blank | Read collected ODM item IT.AE.AESER; no identified record yields blank |
| Variable | Permitted values |
|---|---|
| AESEV | MILD, MODERATE, SEVERE |
| AESER | Y, N |
| 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/sdtm-ae-odm-repeated/full.md
Edit20 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an AE dataset with one record per reported event.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER
STUDYID is the ODM study OID as given, and USUBJID is the ODM subject key as given. Items belonging to one event share the subject, visit, visit repeat, form, and form repeat identifiers. Only AE forms contribute records, and an occurrence without a reported term contributes no AE record. Each form occurrence is its own event, so a form repeat number reused at a later visit, or the same term reported in two occurrences, still gives separate records. AETERM holds the free-text term exactly as reported. AESTDTC and AEENDTC come from the same event occurrence, and AEENDTC has no value when that occurrence has no end date. AESEV and AESER come from that occurrence's severity and seriousness items. AESEQ numbers the subject's events from 1 in visit order (screening, then baseline), then by visit repeat and form repeat.
Read the source datasets from /app/input and save the completed dataset as /app/output/ae.csv.
prompts/sdtm-ae-odm-repeated/conventions.md
Edit8 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an AE dataset with one record per reported event.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER
Read the source datasets from /app/input and save the completed dataset as /app/output/ae.csv.
prompts/sdtm-ae-odm-repeated/brief.md
Edit8 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an AE dataset with one record per reported event.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER
Read the source datasets from /app/input and save the completed dataset as /app/output/ae.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-ae-odm-repeated/result.R
Edit60 lines# Reference solution for the yamaa benchmark sdtm-ae-odm-repeated (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)library(tidyr)odm <- read_csv( "/app/input/odm.csv", col_types = cols(.default = col_character()))# One event per AE item group occurrence: subject, visit, visit repeat, item# group, and item group repeat key. An occurrence without a reported term# gives no record; a repeat key reused at a later visit starts a new event.events <- odm |> filter(ItemGroupOID == "IG.AE") |> pivot_wider( id_cols = c( StudyOID, SubjectKey, StudyEventOID, StudyEventRepeatKey, ItemGroupRepeatKey ), names_from = ItemOID, values_from = Value, values_fn = first ) |> mutate( AETERM = `IT.AE.AETERM`, AESTDTC = `IT.AE.AESTDTC`, AEENDTC = `IT.AE.AEENDTC`, AESEV = `IT.AE.AESEV`, AESER = `IT.AE.AESER` ) |> filter(!is.na(AETERM) & AETERM != "") |> # Visit order is screening, then baseline; then visit repeat and item # group repeat key. The same term in two occurrences stays two records. mutate( VISITORD = case_when( StudyEventOID == "SCREENING" ~ 0L, StudyEventOID == "BASELINE" ~ 1L, .default = 2L ), VISITREP = as.integer(StudyEventRepeatKey), IGREP = as.integer(ItemGroupRepeatKey) ) |> arrange(SubjectKey, VISITORD, VISITREP, IGREP) |> group_by(SubjectKey) |> mutate(AESEQ = row_number()) |> ungroup() |> mutate(DOMAIN = "AE", STUDYID = StudyOID, USUBJID = SubjectKey) |> select( DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER )dir.create("/app/output", showWarnings = FALSE)write_csv(events, "/app/output/ae.csv", na = "")solutions/sdtm-ae-odm-repeated/result.py
Edit112 lines# Reference solution for the yamaa benchmark sdtm-ae-odm-repeated (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 SDTM AE dataset from the ODM long-format extract.One record per reported event: an event is one item-group occurrence on anAE form occurrence (subject, visit, visit repeat, form, form repeat).Occurrences without a reported term contribute no record."""import csvINPUT_PATH = "/app/input/odm.csv"OUTPUT_PATH = "/app/output/ae.csv"ITEM_NAMES = { "IT.AE.AETERM": "AETERM", "IT.AE.AESTDTC": "AESTDTC", "IT.AE.AEENDTC": "AEENDTC", "IT.AE.AESEV": "AESEV", "IT.AE.AESER": "AESER",}VISIT_ORDER = {"SCREENING": 0, "BASELINE": 1}def repeat_number(value): try: return int(value) except (TypeError, ValueError): return 0def main(): with open(INPUT_PATH, newline="", encoding="utf-8") as handle: rows = list(csv.DictReader(handle)) # Group the AE form items by event occurrence, keeping first-appearance # order of visits for any visit not in the known visit order. events = {} visit_rank_seen = {} for row in rows: if row["FormOID"] != "FO.AE": continue visit = row["StudyEventOID"] if visit not in visit_rank_seen: visit_rank_seen[visit] = len(visit_rank_seen) key = ( row["StudyOID"], row["SubjectKey"], visit, row["StudyEventRepeatKey"], row["FormOID"], row["FormRepeatKey"], row["ItemGroupOID"], row["ItemGroupRepeatKey"], ) event = events.setdefault(key, {}) field = ITEM_NAMES.get(row["ItemOID"]) if field is not None: event[field] = row["Value"] def sort_key(item): key, _event = item (_study, _subject, visit, visit_repeat, _form, form_repeat, _group, group_repeat) = key visit_rank = VISIT_ORDER.get(visit, 100 + visit_rank_seen[visit]) return ( visit_rank, repeat_number(visit_repeat), repeat_number(form_repeat), repeat_number(group_repeat), ) records_by_subject = {} for key, event in events.items(): term = event.get("AETERM", "") if term == "": continue studyid, usubjid = key[0], key[1] records_by_subject.setdefault((studyid, usubjid), []).append( (key, event)) output_rows = [] for (studyid, usubjid), subject_events in records_by_subject.items(): subject_events.sort(key=sort_key) for seq, (_key, event) in enumerate(subject_events, start=1): output_rows.append({ "DOMAIN": "AE", "STUDYID": studyid, "USUBJID": usubjid, "AESEQ": seq, "AETERM": event.get("AETERM", ""), "AESTDTC": event.get("AESTDTC", ""), "AEENDTC": event.get("AEENDTC", ""), "AESEV": event.get("AESEV", ""), "AESER": event.get("AESER", ""), }) fieldnames = ["DOMAIN", "STUDYID", "USUBJID", "AESEQ", "AETERM", "AESTDTC", "AEENDTC", "AESEV", "AESER"] with open(OUTPUT_PATH, "w", newline="", encoding="utf-8") as handle: writer = csv.DictWriter(handle, fieldnames=fieldnames) writer.writeheader() writer.writerows(output_rows)if __name__ == "__main__": main()solutions/sdtm-ae-odm-repeated/result.sas
Edit41 lines/* opensas reference solution for the yamaa benchmark sdtm-ae-odm-repeated. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data odm; length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey FormOID FormRepeatKey ItemGroupOID ItemGroupRepeatKey ItemOID Value $1024; infile "/app/input/odm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input StudyOID : $char1024. MetaDataVersionOID : $char1024. SubjectKey : $char1024. StudyEventOID : $char1024. StudyEventRepeatKey : $char1024. FormOID : $char1024. FormRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey; run;data wide; length AETERM AESTDTC AEENDTC AESEV AESER $1024; retain AETERM AESTDTC AEENDTC AESEV AESER; set ordered; where ItemGroupOID='IG.AE'; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey; if first.ItemGroupRepeatKey then do; AETERM=''; AESTDTC=''; AEENDTC=''; AESEV=''; AESER=''; end; if ItemOID='IT.AE.AETERM' then AETERM=Value; if ItemOID='IT.AE.AESTDTC' then AESTDTC=Value; if ItemOID='IT.AE.AEENDTC' then AEENDTC=Value; if ItemOID='IT.AE.AESEV' then AESEV=Value; if ItemOID='IT.AE.AESER' then AESER=Value; if last.ItemGroupRepeatKey then output;run;data prepared; set wide; if not missing(AETERM);length DOMAIN $2 STUDYID USUBJID $1024; DOMAIN='AE'; STUDYID=StudyOID; USUBJID=SubjectKey;VISITORD=2; if StudyEventOID='SCREENING' then VISITORD=0; if StudyEventOID='BASELINE' then VISITORD=1;VISITREP=input(StudyEventRepeatKey,best32.); IGREP=input(ItemGroupRepeatKey,best32.); run;proc sort data=prepared; by STUDYID USUBJID VISITORD VISITREP IGREP; run;data result; set prepared; by STUDYID USUBJID; retain AESEQ; if first.USUBJID then AESEQ=0; AESEQ+1;run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER from result;quit;proc export data=final outfile="/app/output/ae.csv" dbms=csv replace; run;
yamaa