Review ask

As a clinical trial statistician or programmer, challenge anything in this benchmark: describe a problem in Comments, or propose a fix with the Edit button on any source file.

  1. Task: Would a real study need this derivation, specified this way? Does it follow CDISC ADaM: variable names, controlled terms, record structure? Flag any rule that is ambiguous or that a sponsor would handle differently.
  2. Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
  3. Expected output: Would independent QC programming reproduce every value from these inputs and rules?

The other tabs beside Comments are background for assessment, not under review.

Summary

Lifecycle: reviewedEditUnder review
What this benchmark means
README.md

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

Comments and assessment materials

Comments

Signed in with GitHub; saved in repository 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.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

Derive the subject-level death information from fatal adverse events and the death date in DM, and show it on every adverse event of the subject:

  • DTHFL is Y when the subject has a fatal adverse event or a death date in DM, and has no value otherwise.
  • DTHCAUS contains the coded term of the fatal adverse event. It has no value when the death is recorded only in DM.
  • DTHDT contains the date of death: the start date of the fatal adverse event when there is one, and the DM death date otherwise.
  • When a subject has multiple fatal adverse events, use the most recent event. If multiple fatal events start on the same date, use the 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

Runs the yamaa specification; its result must match the expected output

run.R

Edit
4 lines
library(yamaa)adae <- yamaa_domain("spec.yaml")$outputadae

run.py

Edit
4 lines
import yamaaadae = yamaa.yamaa_domain("spec.yaml").outputadae

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
39 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.from pathlib import Pathimport polars as plae = pl.read_csv("/app/input/ae.csv", infer_schema=False).with_columns(    pl.col("AESEQ").cast(pl.Int64))dm = pl.read_csv("/app/input/dm.csv", infer_schema=False)# The fatal adverse event behind each death: the most recent one, and the# highest AESEQ among those starting that day. ISO dates sort as text.fatal = (    ae.filter(pl.col("AEOUT") == "FATAL")    .sort(["ASTDT", "AESEQ"], descending=True, nulls_last=True)    .unique("USUBJID", keep="first", maintain_order=True)    .select("USUBJID", DTHCAUS="AEDECOD", FATALDT="ASTDT"))# One record per subject who died, from a fatal adverse event, DM, or both.death = (    dm.filter(pl.col("DTHDT").is_not_null())    .select("USUBJID", DMDTHDT="DTHDT")    .join(fatal, on="USUBJID", how="full", coalesce=True)    .with_columns(DTHFL=pl.lit("Y"), DTHDT=pl.coalesce("FATALDT", "DMDTHDT"))    .select("USUBJID", "DTHFL", "DTHCAUS", "DTHDT"))adae = ae.join(death, on="USUBJID", how="left", maintain_order="left").select(    "STUDYID", "USUBJID", "AESEQ", "AEDECOD", "ASTDT", "DTHFL", "DTHCAUS", "DTHDT")Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")

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;