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: build one Analysis Data Model (ADaM) adverse events row per
collected adverse event (AE), carrying the coded term (AEDECOD) and
start date (ASTDT) through and adding DTHFL, DTHCAUS, and DTHDT
for the subject's death.
Input: collected adverse events with coded term, outcome, and start date, plus demographics with death date.
Variables:
DTHFLisYon every event of a subject with a fatal event or a death date recorded in demographics; empty otherwise.DTHCAUSnames the fatal event, using the coded term of the subject's event whose outcome is death; empty when no event was reported fatal.DTHDTis the date the subject died: the start date of the fatal event, or, when no event was reported fatal, the death date recorded in demographics; empty when neither exists.
Note: when a subject has more than one fatal event, the latest by
start date supplies the cause and date, and a tie on start date goes to
the highest AESEQ. A death recorded only in demographics gives a date
but no cause, because there is no event term to name.
Inputs
Under review2 source filesinput/ae.csv
Edit10 rows| STUDYID | USUBJID | AESEQ | AEDECOD | AEOUT | ASTDT |
|---|---|---|---|---|---|
| KN189 | 1 | HEART ATTACK | FATAL | 2024-02-15 | |
| KN189 | 2 | NAUSEA | RECOVERED | 2024-01-20 | |
| KN189 | 1 | HEART FAILURE | FATAL | 2024-03-01 | |
| KN189 | 1 | HEADACHE | RECOVERING | 2024-02-10 | |
| KN189 | 1 | DIZZINESS | RECOVERED | 2024-02-12 | |
| KN189 | 1 | HEART FAILURE | FATAL | 2024-02-20 | |
| KN189 | 2 | CARDIAC ARREST | FATAL | 2024-03-02 | |
| KN189 | 1 | RASH | — | 2024-02-25 | |
| KN189 | 1 | STROKE | FATAL | 2024-04-01 | |
| KN189 | 2 | CEREBRAL HAEMORRHAGE | FATAL | 2024-04-01 |
input/dm.csv
Edit4 rows| STUDYID | USUBJID | DTHDT |
|---|---|---|
| KN189 | 2024-02-15 | |
| KN189 | 2024-03-05 | |
| KN189 | 2024-03-10 | |
| KN189 | 2024-03-02 |
Expected output
Under review10 expected rowsexpected/adae.csv
Edit10 rows| STUDYID | USUBJID | AESEQ | AEDECOD | ASTDT | DTHFL | DTHCAUS | DTHDT |
|---|---|---|---|---|---|---|---|
| KN189 | 1 | HEART ATTACK | 2024-02-15 | Y | HEART ATTACK | 2024-02-15 | |
| KN189 | 2 | NAUSEA | 2024-01-20 | Y | HEART ATTACK | 2024-02-15 | |
| KN189 | 1 | HEART FAILURE | 2024-03-01 | Y | HEART FAILURE | 2024-03-01 | |
| KN189 | 1 | HEADACHE | 2024-02-10 | Y | — | 2024-03-10 | |
| KN189 | 1 | DIZZINESS | 2024-02-12 | — | — | — | |
| KN189 | 1 | HEART FAILURE | 2024-02-20 | Y | CARDIAC ARREST | 2024-03-02 | |
| KN189 | 2 | CARDIAC ARREST | 2024-03-02 | Y | CARDIAC ARREST | 2024-03-02 | |
| KN189 | 1 | RASH | 2024-02-25 | — | — | — | |
| KN189 | 1 | STROKE | 2024-04-01 | Y | CEREBRAL HAEMORRHAGE | 2024-04-01 | |
| KN189 | 2 | CEREBRAL HAEMORRHAGE | 2024-04-01 | Y | CEREBRAL HAEMORRHAGE | 2024-04-01 |
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.ASTDT. | Predecessor | |
| ADAE | DTHCAUS | Cause of Death | character | Take AEDECOD from the last AE record matching on STUDYID and USUBJID, where AE.AEOUT = 'FATAL', ordered by AE.ASTDT then AE.AESEQ, and no match yields blank. | Derived | ||
| ADAE | DTHDT | Date of Death | numeric | ISO 8601 | First non-missing of: ASTDT from the last AE record matching on STUDYID and USUBJID, where AE.AEOUT = 'FATAL', ordered by AE.ASTDT then AE.AESEQ, and no match yields blank; DM.DTHDT. | Derived | |
| ADAE | DTHFL | Death Flag | character | Y | "Y" when DTHDT IS NOT NULL; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| DTHFL | Y |
| 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-death/full.md
Edit20 linesFollowing CDISC ADaM standards, use the provided AE and DM datasets 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, DTHFL, DTHCAUS, DTHDT
A fatal event is an event whose outcome is recorded as "FATAL". DTHFL is "Y" on every event of a subject with a fatal event or a death date in DM, and has no value on every other event. DTHCAUS is the coded term of the subject's fatal event, and has no value when no event of the subject was reported fatal. DTHDT is the start date of the subject's fatal event. When the subject has no fatal event, DTHDT is the death date recorded for the subject in DM, and a death recorded only in DM gives a date but no cause. DTHDT has no value when the subject has neither a fatal event nor a death date in DM. When a subject has more than one fatal event, the fatal event with the latest start date supplies DTHCAUS and DTHDT, and a tie on start date goes to the fatal event with the highest AESEQ.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-death/conventions.md
Edit10 linesFollowing CDISC ADaM standards, use the provided AE and DM datasets 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, DTHFL, DTHCAUS, DTHDT
DTHFL 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-death/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided AE and DM datasets 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, DTHFL, DTHCAUS, DTHDT
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-death/result.R
Edit40 lines# Reference solution for the yamaa benchmark adam-adae-death (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(), ASTDT = col_date(), .default = col_character()))dm <- read_csv( "/app/input/dm.csv", col_types = cols(DTHDT = col_date(), .default = col_character()))# The fatal adverse event behind each death: the most recent one, and the# highest AESEQ among those starting that day.fatal <- ae |> filter(AEOUT %in% "FATAL") |> arrange(USUBJID, desc(ASTDT), desc(AESEQ)) |> distinct(USUBJID, .keep_all = TRUE) |> select(USUBJID, DTHCAUS = AEDECOD, FATALDT = ASTDT)# One record per subject who died, from a fatal adverse event, DM, or both.death <- dm |> filter(!is.na(DTHDT)) |> select(USUBJID, DMDTHDT = DTHDT) |> full_join(fatal, by = "USUBJID") |> mutate(DTHFL = "Y", DTHDT = coalesce(FATALDT, DMDTHDT)) |> select(USUBJID, DTHFL, DTHCAUS, DTHDT)adae <- ae |> left_join(death, by = "USUBJID") |> select(STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, DTHFL, DTHCAUS, DTHDT)dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")solutions/adam-adae-death/result.py
Edit89 lines# Reference solution for the yamaa benchmark adam-adae-death (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 an ADAE dataset (one record per adverse event) from AE and DM,deriving the death flag, death cause, and death date per subject.Rules:- A fatal event is an event whose outcome (AEOUT) is "FATAL".- DTHFL is "Y" on every event of a subject who has a fatal event or a death date in DM; it has no value on every other event.- DTHCAUS is the coded term (AEDECOD) of the subject's fatal event; it has no value when no event of the subject was reported fatal.- DTHDT is the start date of the subject's fatal event. When the subject has no fatal event, DTHDT is the death date recorded in DM. It has no value when the subject has neither a fatal event nor a DM death date.- When a subject has more than one fatal event, the fatal event with the latest start date supplies DTHCAUS and DTHDT; a tie on start date goes to the fatal event with the highest AESEQ."""import csvINPUT_DIR = "/app/input"OUTPUT_FILE = "/app/output/adae.csv"def read_rows(path): with open(path, newline="", encoding="utf-8") as handle: return list(csv.DictReader(handle))ae_rows = read_rows(f"{INPUT_DIR}/ae.csv")dm_rows = read_rows(f"{INPUT_DIR}/dm.csv")# Death date recorded in DM, per subject (only non-empty values count).dm_death = {}for row in dm_rows: if row["DTHDT"] != "": dm_death[row["USUBJID"]] = row["DTHDT"]# Chosen fatal event per subject: latest ASTDT, tie broken by highest AESEQ.chosen_fatal = {}for row in ae_rows: if row["AEOUT"] != "FATAL": continue subject = row["USUBJID"] current = chosen_fatal.get(subject) if current is None or (row["ASTDT"], int(row["AESEQ"])) > ( current["ASTDT"], int(current["AESEQ"]), ): chosen_fatal[subject] = rowdef death_flag(subject): return "Y" if subject in chosen_fatal or subject in dm_death else ""def death_cause(subject): return chosen_fatal[subject]["AEDECOD"] if subject in chosen_fatal else ""def death_date(subject): if subject in chosen_fatal: return chosen_fatal[subject]["ASTDT"] return dm_death.get(subject, "")fieldnames = ["STUDYID", "USUBJID", "AESEQ", "AEDECOD", "ASTDT", "DTHFL", "DTHCAUS", "DTHDT"]with open(OUTPUT_FILE, "w", newline="", encoding="utf-8") as handle: writer = csv.DictWriter(handle, fieldnames=fieldnames) writer.writeheader() for row in ae_rows: subject = row["USUBJID"] writer.writerow( { "STUDYID": row["STUDYID"], "USUBJID": subject, "AESEQ": row["AESEQ"], "AEDECOD": row["AEDECOD"], "ASTDT": row["ASTDT"], "DTHFL": death_flag(subject), "DTHCAUS": death_cause(subject), "DTHDT": death_date(subject), } )solutions/adam-adae-death/result.sas
Edit28 lines/* opensas reference solution for the yamaa benchmark adam-adae-death. 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 AEOUT ASTDT $1024; infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AESEQ AEDECOD : $char1024. AEOUT : $char1024. ASTDT : $char1024.;run;data dm; length STUDYID USUBJID DTHDT $1024; infile "/app/input/dm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. DTHDT : $char1024.;run;proc sort data=ae(where=(AEOUT='FATAL')) out=fatal; by STUDYID USUBJID descending ASTDT descending AESEQ; run;data latest; set fatal; by STUDYID USUBJID; if first.USUBJID; run;proc sql; create table result as select a.*,case when not missing(b.USUBJID) or not missing(c.DTHDT) then 'Y' else '' end as DTHFL, b.AEDECOD as DTHCAUS,case when not missing(b.USUBJID) then b.ASTDT else c.DTHDT end as DTHDT from ae as a left join latest as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID left join dm as c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID;quit;proc sql; create table final as select STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, DTHFL, DTHCAUS, DTHDT from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;
yamaa