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 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:

  • DTHFL is Y on every event of a subject with a fatal event or a death date recorded in demographics; empty otherwise.
  • DTHCAUS names the fatal event, using the coded term of the subject's event whose outcome is death; empty when no event was reported fatal.
  • DTHDT is 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 review
2 source files

input/ae.csv

Edit
10 rows
input/ae.csv
STUDYIDUSUBJIDAESEQAEDECODAEOUTASTDT
KN1891HEART ATTACKFATAL2024-02-15
KN1892NAUSEARECOVERED2024-01-20
KN1891HEART FAILUREFATAL2024-03-01
KN1891HEADACHERECOVERING2024-02-10
KN1891DIZZINESSRECOVERED2024-02-12
KN1891HEART FAILUREFATAL2024-02-20
KN1892CARDIAC ARRESTFATAL2024-03-02
KN1891RASH—2024-02-25
KN1891STROKEFATAL2024-04-01
KN1892CEREBRAL HAEMORRHAGEFATAL2024-04-01

input/dm.csv

Edit
4 rows
input/dm.csv
STUDYIDUSUBJIDDTHDT
KN1892024-02-15
KN1892024-03-05
KN1892024-03-10
KN1892024-03-02

Expected output

Under review
10 expected rows

expected/adae.csv

Edit
10 rows
expected/adae.csv
STUDYIDUSUBJIDAESEQAEDECODASTDTDTHFLDTHCAUSDTHDT
KN1891HEART ATTACK2024-02-15YHEART ATTACK2024-02-15
KN1892NAUSEA2024-01-20YHEART ATTACK2024-02-15
KN1891HEART FAILURE2024-03-01YHEART FAILURE2024-03-01
KN1891HEADACHE2024-02-10Y—2024-03-10
KN1891DIZZINESS2024-02-12———
KN1891HEART FAILURE2024-02-20YCARDIAC ARREST2024-03-02
KN1892CARDIAC ARREST2024-03-02YCARDIAC ARREST2024-03-02
KN1891RASH2024-02-25———
KN1891STROKE2024-04-01YCEREBRAL HAEMORRHAGE2024-04-01
KN1892CEREBRAL HAEMORRHAGE2024-04-01YCEREBRAL HAEMORRHAGE2024-04-01
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

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADAESTUDYIDStudy IdentifiercharacterCopy value from AE.STUDYID.Predecessor
ADAEUSUBJIDUnique Subject IdentifiercharacterCopy value from AE.USUBJID.Predecessor
ADAEAESEQSequence NumbernumericCopy value from AE.AESEQ.Predecessor
ADAEAEDECODDictionary-Derived TermcharacterCopy value from AE.AEDECOD.Predecessor
ADAEASTDTAnalysis Start DatenumericISO 8601Copy value from AE.ASTDT.Predecessor
ADAEDTHCAUSCause of DeathcharacterTake 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
ADAEDTHDTDate of DeathnumericISO 8601First 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
ADAEDTHFLDeath FlagcharacterY"Y" when DTHDT IS NOT NULL; blank otherwise.Derived
VariablePermitted values
DTHFLY
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/adam-adae-death/full.md

Edit
20 lines

Following 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

Edit
10 lines

Following 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

Edit
8 lines

Following 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.

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/adam-adae-death/result.R

Edit
40 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

Edit
89 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

Edit
28 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;