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: give one row for each adverse event and each medication that the
related-records dataset relates to it: the event's sequence number and
reported term (AESEQ, AETERM), the medication's sequence number and name
(CMSEQ, CMTRT), and the relationship they share (RELID).
Input: collected adverse events (AE), concomitant medications (CM) and related records (RELREC), one record for each member of a relationship: the subject, the domain and sequence number of the related record and the relationship's identifier.
Variables:
AETERM: the reported term of the adverse event.CMTRT: the reported name of the medication.RELID: the identifier of the subject's relationship that relates the event and the medication.
Note: every event of a relationship pairs with every medication of the same subject's same relationship, so a relationship of two events and two medications gives four rows, and a medication related to two events through two relationships appears once with each. Relationship identifiers count within a subject: two subjects' relationships with the same identifier are different relationships.
Inputs
Under review3 source filesinput/ae.csv
Edit5 rows| STUDYID | DOMAIN | USUBJID | AESEQ | AETERM |
|---|---|---|---|---|
| TOY | AE | 1 | HEADACHE | |
| TOY | AE | 2 | NAUSEA | |
| TOY | AE | 3 | RASH | |
| TOY | AE | 4 | PRURITUS | |
| TOY | AE | 1 | FEVER |
input/cm.csv
Edit5 rows| STUDYID | DOMAIN | USUBJID | CMSEQ | CMTRT |
|---|---|---|---|---|
| TOY | CM | 1 | PARACETAMOL | |
| TOY | CM | 2 | ONDANSETRON | |
| TOY | CM | 3 | LORATADINE | |
| TOY | CM | 1 | PARACETAMOL | |
| TOY | CM | 2 | IBUPROFEN |
input/relrec.csv
Edit11 rows| STUDYID | RDOMAIN | USUBJID | IDVAR | IDVARVAL | RELTYPE | RELID |
|---|---|---|---|---|---|---|
| TOY | AE | AESEQ | 1 | — | 1 | |
| TOY | AE | AESEQ | 2 | — | 1 | |
| TOY | CM | CMSEQ | 1 | — | 1 | |
| TOY | CM | CMSEQ | 2 | — | 1 | |
| TOY | AE | AESEQ | 3 | — | 2 | |
| TOY | CM | CMSEQ | 3 | — | 2 | |
| TOY | AE | AESEQ | 4 | — | 3 | |
| TOY | CM | CMSEQ | 3 | — | 3 | |
| TOY | AE | AESEQ | 1 | — | 1 | |
| TOY | CM | CMSEQ | 1 | — | 1 | |
| TOY | CM | CMSEQ | 2 | — | 1 |
Expected output
Under review8 expected rowsexpected/adaecm.csv
Edit8 rows| STUDYID | USUBJID | AESEQ | AETERM | CMSEQ | CMTRT | RELID |
|---|---|---|---|---|---|---|
| TOY | 1 | HEADACHE | 1 | PARACETAMOL | 1 | |
| TOY | 1 | HEADACHE | 2 | ONDANSETRON | 1 | |
| TOY | 2 | NAUSEA | 1 | PARACETAMOL | 1 | |
| TOY | 2 | NAUSEA | 2 | ONDANSETRON | 1 | |
| TOY | 3 | RASH | 3 | LORATADINE | 2 | |
| TOY | 4 | PRURITUS | 3 | LORATADINE | 3 | |
| TOY | 1 | FEVER | 1 | PARACETAMOL | 1 | |
| TOY | 1 | FEVER | 2 | IBUPROFEN | 1 |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADAECM | STUDYID | Study Identifier | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADAECM | USUBJID | Unique Subject Identifier | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADAECM | AESEQ | Sequence Number of the Adverse Event | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADAECM | CMSEQ | Sequence Number of the Medication | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADAECM | RELID | Relationship Identifier | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADAECM | AETERM | Reported Term for the Adverse Event | character | Copy value from AE.AETERM. | Predecessor | ||
| ADAECM | CMTRT | Reported Name of Drug, Med, or Therapy | character | Copy value from CM.CMTRT. | Predecessor |
| Template | Include when | STUDYID | USUBJID | AESEQ | CMSEQ | RELID |
|---|---|---|---|---|---|---|
| pairs | Copy STUDYID from the AEMEM record matching on USUBJID and RELID, where STUDYID is derived as STUDYID from the RELREC record matching on the shared output keys, where RELREC.RDOMAIN = 'AE' AND RELREC.IDVAR = 'AESEQ', blank when unmatched, and no match yields blank | Copy USUBJID from the AEMEM record matching on USUBJID and RELID, where USUBJID is derived as USUBJID from the RELREC record matching on the shared output keys, where RELREC.RDOMAIN = 'AE' AND RELREC.IDVAR = 'AESEQ', blank when unmatched, and no match yields blank | Copy AESEQ from the AEMEM record matching on USUBJID and RELID, where AESEQ is derived as SEQ from the RELREC record matching on the shared output keys, where RELREC.RDOMAIN = 'AE' AND RELREC.IDVAR = 'AESEQ', blank when unmatched, and no match yields blank | Copy CMSEQ from the AEMEM record matching on USUBJID and RELID, where CMSEQ is derived as SEQ from the RELREC record matching on the shared output keys, where RELREC.RDOMAIN = 'CM' AND RELREC.IDVAR = 'CMSEQ', blank when unmatched, and no match yields blank | Copy RELID from the AEMEM record matching on USUBJID and RELID, where RELID is derived as RELID from the RELREC record matching on the shared output keys, where RELREC.RDOMAIN = 'AE' AND RELREC.IDVAR = 'AESEQ', blank when unmatched, and no match yields blank |
| 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-adaecm-related-pairs/full.md
Edit28 linesFollowing CDISC ADaM standards, use the provided AE, CM, and RELREC datasets to create an ADAECM dataset with one record per adverse event and medication related to it, per relationship that relates them.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AETERM, CMSEQ, CMTRT, RELID
Each RELREC record is one member of a subject's relationship: a record with RDOMAIN "AE" and IDVAR "AESEQ" names an adverse event by the AESEQ in IDVARVAL, and a record with RDOMAIN "CM" and IDVAR "CMSEQ" names a medication by its CMSEQ.
- Every event of a relationship pairs with every medication of the same subject's same relationship, so a relationship of two events and two medications gives four records.
- A medication related to two events through two relationships appears once with each.
- Relationship identifiers count within a subject: two subjects' relationships with the same identifier are different relationships.
- AESEQ and CMSEQ are the sequence numbers of the event in AE and of the medication in CM, as RELREC names them; they are not renumbered.
- AETERM is the reported term of the adverse event, and CMTRT is the reported name of the medication.
- RELID is the identifier of the subject's relationship that relates the event and the medication, exactly as RELREC holds it.
Read the source datasets from /app/input and save the completed dataset as /app/output/adaecm.csv.
prompts/adam-adaecm-related-pairs/conventions.md
Edit12 linesFollowing CDISC ADaM standards, use the provided AE, CM, and RELREC datasets to create an ADAECM dataset with one record per adverse event and medication related to it, per relationship that relates them.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AETERM, CMSEQ, CMTRT, RELID
RELID is the identifier of the subject's relationship, exactly as RELREC holds it.
Read the source datasets from /app/input and save the completed dataset as /app/output/adaecm.csv.
prompts/adam-adaecm-related-pairs/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided AE, CM, and RELREC datasets to create an ADAECM dataset with one record per adverse event and medication related to it, per relationship that relates them.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AETERM, CMSEQ, CMTRT, RELID
Read the source datasets from /app/input and save the completed dataset as /app/output/adaecm.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adaecm-related-pairs/result.R
Edit48 lines# Reference solution for the yamaa benchmark adam-adaecm-related-pairs (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.read_text <- function(name) { read.csv( file.path("/app/input", name), colClasses = "character", na.strings = character(0), check.names = FALSE )}ae <- read_text("ae.csv")cm <- read_text("cm.csv")relrec <- read_text("relrec.csv")events <- relrec[relrec$RDOMAIN == "AE" & relrec$IDVAR == "AESEQ", c("STUDYID", "USUBJID", "RELID", "IDVARVAL")]names(events)[4] <- "AESEQ"medications <- relrec[relrec$RDOMAIN == "CM" & relrec$IDVAR == "CMSEQ", c("STUDYID", "USUBJID", "RELID", "IDVARVAL")]names(medications)[4] <- "CMSEQ"# Every event of a relationship with every medication of the same subject's# same relationship.pairs <- merge(events, medications, by = c("STUDYID", "USUBJID", "RELID"))pairs$AESEQ <- as.integer(pairs$AESEQ)pairs$CMSEQ <- as.integer(pairs$CMSEQ)pairs$AETERM <- ae$AETERM[match( paste(pairs$STUDYID, pairs$USUBJID, pairs$AESEQ, sep = "\r"), paste(ae$STUDYID, ae$USUBJID, as.integer(ae$AESEQ), sep = "\r"))]pairs$CMTRT <- cm$CMTRT[match( paste(pairs$STUDYID, pairs$USUBJID, pairs$CMSEQ, sep = "\r"), paste(cm$STUDYID, cm$USUBJID, as.integer(cm$CMSEQ), sep = "\r"))]adaecm <- pairs[order(pairs$STUDYID, pairs$USUBJID, pairs$AESEQ, pairs$CMSEQ, method = "radix"), c("STUDYID", "USUBJID", "AESEQ", "AETERM", "CMSEQ", "CMTRT", "RELID")]dir.create("/app/output", showWarnings = FALSE, recursive = TRUE)write.csv(adaecm, "/app/output/adaecm.csv", row.names = FALSE, na = "")solutions/adam-adaecm-related-pairs/result.py
Edit67 lines# Reference solution for the yamaa benchmark adam-adaecm-related-pairs (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.import csvfrom pathlib import PathINPUT_DIR = Path("/app/input")OUTPUT_DIR = Path("/app/output")COLUMNS = ["STUDYID", "USUBJID", "AESEQ", "AETERM", "CMSEQ", "CMTRT", "RELID"]def read(name: str) -> list[dict[str, str]]: with open(INPUT_DIR / name, newline="", encoding="utf-8") as handle: return list(csv.DictReader(handle))def main() -> None: ae = read("ae.csv") cm = read("cm.csv") relrec = read("relrec.csv") terms = {(r["STUDYID"], r["USUBJID"], int(r["AESEQ"])): r["AETERM"] for r in ae} names = {(r["STUDYID"], r["USUBJID"], int(r["CMSEQ"])): r["CMTRT"] for r in cm} events = [r for r in relrec if r["RDOMAIN"] == "AE" and r["IDVAR"] == "AESEQ"] medications = [ r for r in relrec if r["RDOMAIN"] == "CM" and r["IDVAR"] == "CMSEQ" ] # Every event of a relationship with every medication of the same # subject's same relationship. rows = [] for event in events: for medication in medications: if (event["STUDYID"], event["USUBJID"], event["RELID"]) != ( medication["STUDYID"], medication["USUBJID"], medication["RELID"], ): continue aeseq = int(event["IDVARVAL"]) cmseq = int(medication["IDVARVAL"]) rows.append( { "STUDYID": event["STUDYID"], "USUBJID": event["USUBJID"], "AESEQ": aeseq, "AETERM": terms[(event["STUDYID"], event["USUBJID"], aeseq)], "CMSEQ": cmseq, "CMTRT": names[(event["STUDYID"], event["USUBJID"], cmseq)], "RELID": event["RELID"], } ) rows.sort(key=lambda r: (r["STUDYID"], r["USUBJID"], r["AESEQ"], r["CMSEQ"])) OUTPUT_DIR.mkdir(parents=True, exist_ok=True) with open(OUTPUT_DIR / "adaecm.csv", "w", newline="", encoding="utf-8") as handle: writer = csv.writer(handle, lineterminator="\n") writer.writerow(COLUMNS) for row in rows: writer.writerow([row[column] for column in COLUMNS])if __name__ == "__main__": main()solutions/adam-adaecm-related-pairs/result.sas
Edit70 lines/* opensas reference solution for the yamaa benchmark adam-adaecm-related-pairs. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ae; length STUDYID DOMAIN USUBJID $40 AETERM $200; infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char40. DOMAIN : $char40. USUBJID : $char40. AESEQ AETERM : $char200.;run;data cm; length STUDYID DOMAIN USUBJID $40 CMTRT $200; infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char40. DOMAIN : $char40. USUBJID : $char40. CMSEQ CMTRT : $char200.;run;data relrec; length STUDYID RDOMAIN USUBJID IDVAR IDVARVAL RELTYPE RELID $40; infile "/app/input/relrec.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char40. RDOMAIN : $char40. USUBJID : $char40. IDVAR : $char40. IDVARVAL : $char40. RELTYPE : $char40. RELID : $char40.;run;/* The events and the medications each relationship names, with their numeric sequence numbers. Function calls in join predicates were rejected by the release, and comparisons between identically named columns of a self-join gave incorrect results, so the two member lists are separate tables with their keys calculated before joining. */data relae; set relrec; if RDOMAIN = 'AE' and IDVAR = 'AESEQ'; AESEQ = input(IDVARVAL, best32.); keep STUDYID USUBJID RELID AESEQ;run;data relcm; set relrec; if RDOMAIN = 'CM' and IDVAR = 'CMSEQ'; CMSEQ = input(IDVARVAL, best32.); keep STUDYID USUBJID RELID CMSEQ;run;proc sql; /* Every event of a relationship with every medication of the same subject's same relationship. */ create table pairs as select e.STUDYID, e.USUBJID, e.AESEQ, m.CMSEQ, e.RELID from relae as e inner join relcm as m on m.STUDYID = e.STUDYID and m.USUBJID = e.USUBJID and m.RELID = e.RELID; /* The event's reported term. */ create table aepairs as select p.STUDYID, p.USUBJID, p.AESEQ, a.AETERM, p.CMSEQ, p.RELID from pairs as p left join ae as a on a.STUDYID = p.STUDYID and a.USUBJID = p.USUBJID and a.AESEQ = p.AESEQ; /* The medication's reported name. */ create table adaecm as select p.STUDYID, p.USUBJID, p.AESEQ, p.AETERM, p.CMSEQ, c.CMTRT, p.RELID from aepairs as p left join cm as c on c.STUDYID = p.STUDYID and c.USUBJID = p.USUBJID and c.CMSEQ = p.CMSEQ order by p.STUDYID, p.USUBJID, p.AESEQ, p.CMSEQ, p.RELID;quit;proc export data=adaecm outfile='/app/output/adaecm.csv' dbms=csv replace; run;
yamaa