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: mark each subject's end-of-treatment record for every laboratory
test (EOTFL), carrying the protocol endpoint qualifier it rests on
(ENDPOINT).
Input: laboratory (LB) records carry a numeric sequence number, a test
code (LBTESTCD), a visit number (VISITNUM), and a numeric result.
Supplemental laboratory
qualifier (SUPPLB) records carry the same sequence as eight-character,
space-padded text, one qualifier name and value per record; only the
protocol endpoint qualifier is read.
Variables:
AVALis the numeric laboratory result.ENDPOINTisYwhen a supplemental endpoint qualifier with the same study, subject, and sequence number marks the record; empty otherwise.EOTFLisYon one record per subject and test: the endpoint-marked record when there is one, otherwise the record from the latest visit. Every other record is empty.
Note: the endpoint qualifier decides the choice even when a later visit exists, so the flag can sit before the subject's last visit. A record wins the flag even when its result is missing, and a group with a single record still gets the flag. Other qualifiers on the same record, and endpoint qualifiers for records the laboratory data does not hold, change nothing.
Inputs
Under review2 source filesinput/lb.csv
Edit12 rows| STUDYID | USUBJID | LBSEQ | LBTESTCD | VISITNUM | LBSTRESN |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | ALB | 1 | 4 | |
| YAMAA-01 | 2 | ALB | 2 | 4.2 | |
| YAMAA-01 | 3 | ALB | 3 | 4.1 | |
| YAMAA-01 | 4 | CREAT | 1 | 80 | |
| YAMAA-01 | 5 | CREAT | 2 | 82 | |
| YAMAA-01 | 6 | CREAT | 3 | 85 | |
| YAMAA-01 | 1 | ALB | 1 | 3.9 | |
| YAMAA-01 | 2 | ALB | 2 | 4 | |
| YAMAA-01 | 1 | ALB | 1 | 4.3 | |
| YAMAA-01 | 1 | ALB | 1 | — | |
| YAMAA-01 | 2 | ALB | 2 | 4.4 | |
| YAMAA-01 | 1 | CREAT | 3 | 95 |
input/supplb.csv
Edit6 rows| STUDYID | RDOMAIN | USUBJID | IDVAR | IDVARVAL | QNAM | QLABEL | QVAL |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | LB | LBSEQ | 2 | ENDPOINT | Protocol Endpoint Record | Y | |
| YAMAA-01 | LB | LBSEQ | 2 | LBTMSHI | Result to Upper Limit Ratio | 0.9 | |
| YAMAA-01 | LB | LBSEQ | 1 | LBTMSHI | Result to Upper Limit Ratio | 0.8 | |
| YAMAA-01 | LB | LBSEQ | 7 | ENDPOINT | Protocol Endpoint Record | Y | |
| YAMAA-01 | LB | LBSEQ | 1 | ENDPOINT | Protocol Endpoint Record | Y | |
| YAMAA-01 | LB | LBSEQ | 1 | ENDPOINT | Protocol Endpoint Record | Y |
Expected output
Under review12 expected rowsexpected/adlb.csv
Edit12 rows| STUDYID | USUBJID | LBSEQ | LBTESTCD | VISITNUM | AVAL | ENDPOINT | EOTFL |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | ALB | 1 | 4 | — | — | |
| YAMAA-01 | 2 | ALB | 2 | 4.2 | Y | Y | |
| YAMAA-01 | 3 | ALB | 3 | 4.1 | — | — | |
| YAMAA-01 | 4 | CREAT | 1 | 80 | — | — | |
| YAMAA-01 | 5 | CREAT | 2 | 82 | — | — | |
| YAMAA-01 | 6 | CREAT | 3 | 85 | — | Y | |
| YAMAA-01 | 1 | ALB | 1 | 3.9 | — | — | |
| YAMAA-01 | 2 | ALB | 2 | 4 | — | Y | |
| YAMAA-01 | 1 | ALB | 1 | 4.3 | — | Y | |
| YAMAA-01 | 1 | ALB | 1 | — | Y | Y | |
| YAMAA-01 | 2 | ALB | 2 | 4.4 | — | — | |
| YAMAA-01 | 1 | CREAT | 3 | 95 | Y | Y |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADLB | STUDYID | Study Identifier | character | Copy value from LB.STUDYID. | Predecessor | ||
| ADLB | USUBJID | Unique Subject Identifier | character | Copy value from LB.USUBJID. | Predecessor | ||
| ADLB | LBSEQ | Sequence Number | numeric | Copy value from LB.LBSEQ. | Predecessor | ||
| ADLB | LBTESTCD | Lab Test or Examination Short Name | character | Copy value from LB.LBTESTCD. | Predecessor | ||
| ADLB | VISITNUM | Visit Number | numeric | Copy value from LB.VISITNUM. | Predecessor | ||
| ADLB | AVAL | Analysis Value | numeric | Copy value from LB.LBSTRESN. | Predecessor | ||
| ADLB | ENDPOINT | Protocol Endpoint Record | character | Take ENDPOINT from the LB record matching on STUDYID, USUBJID and LBSEQ, where ENDPOINT is derived as QVAL from the SUPPLB record whose STUDYID equals LB.STUDYID, USUBJID equals LB.USUBJID and IDVARVAL equals LB.LBSEQ padded on the left with spaces to at least 8 characters, where SUPPLB.QNAM = 'ENDPOINT', blank when unmatched, and a row with no match is an error. | Derived | ||
| ADLB | EOTFL | End of Treatment Record Flag | character | "Y" when EOT_SEQ = 1, with EOT_SEQ taken from the LB record matching on STUDYID, USUBJID and LBSEQ, where EOT_SEQ is derived as row number within each group of LB.USUBJID, LB.LBTESTCD, ordered by ENDPOINT descending then LB.VISITNUM descending, and a row with no match is an error; blank otherwise. | Derived |
| 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-adlb-end-of-treatment/full.md
Edit21 linesFollowing CDISC ADaM standards, use the provided LB and SUPPLB datasets to create an ADLB dataset with one record per laboratory record.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, LBTESTCD, VISITNUM, AVAL, ENDPOINT, EOTFL
AVAL is the numeric laboratory result. ENDPOINT is "Y" when SUPPLB holds a qualifier with QNAM "ENDPOINT" for the same study, subject, and sequence number as the record; ENDPOINT has no value otherwise. In SUPPLB the sequence number is eight-character, space-padded text. EOTFL is "Y" on one record per subject and test: the endpoint-marked record when there is one, otherwise the record from the latest visit. Every other record has no value for EOTFL. The endpoint mark decides the choice even when a later visit exists, so the flag can sit before the subject's last visit. A record wins the flag even when its result is missing, and a subject and test with a single record still gets the flag. Other qualifiers on the same record, and endpoint qualifiers for records the laboratory data does not hold, change nothing.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-end-of-treatment/conventions.md
Edit11 linesFollowing CDISC ADaM standards, use the provided LB and SUPPLB datasets to create an ADLB dataset with one record per laboratory record.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, LBTESTCD, VISITNUM, AVAL, ENDPOINT, EOTFL
ENDPOINT is "Y" or has no value. EOTFL is "Y" or has no value. In SUPPLB the sequence number is eight-character, space-padded text.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-end-of-treatment/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided LB and SUPPLB datasets to create an ADLB dataset with one record per laboratory record.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, LBTESTCD, VISITNUM, AVAL, ENDPOINT, EOTFL
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adlb-end-of-treatment/result.R
Edit67 lines# Reference solution for the yamaa benchmark adam-adlb-end-of-treatment (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(stringr)lb <- read_csv( "/app/input/lb.csv", col_types = cols( LBSEQ = col_integer(), VISITNUM = col_integer(), LBSTRESN = col_double(), .default = col_character() ))supp <- read_csv( "/app/input/supplb.csv", col_types = cols(.default = col_character()))# ENDPOINT is Y when a supplemental endpoint qualifier with the same# study, subject, and sequence number marks the record. Only the protocol# endpoint qualifier is read.endpoint_keys <- supp |> filter(QNAM %in% "ENDPOINT") |> transmute( STUDYID, USUBJID, SEQ_TRIM = str_trim(IDVARVAL), ENDPOINT = "Y" )marked <- lb |> mutate(SEQ_TRIM = as.character(LBSEQ), AVAL = LBSTRESN) |> left_join(endpoint_keys, by = c("STUDYID", "USUBJID", "SEQ_TRIM")) |> select(-SEQ_TRIM)# EOTFL is Y on one record per subject and test: the endpoint-marked# record when there is one, otherwise the record from the latest visit.endpoint_winners <- marked |> filter(ENDPOINT %in% "Y") |> group_by(STUDYID, USUBJID, LBTESTCD) |> summarise(WIN_ENDPOINT = min(LBSEQ), .groups = "drop")latest_winners <- marked |> arrange(desc(VISITNUM), desc(LBSEQ)) |> distinct(STUDYID, USUBJID, LBTESTCD, .keep_all = TRUE) |> transmute(STUDYID, USUBJID, LBTESTCD, WIN_LATEST = LBSEQ)winners <- latest_winners |> left_join(endpoint_winners, by = c("STUDYID", "USUBJID", "LBTESTCD")) |> mutate(WIN_LBSEQ = coalesce(WIN_ENDPOINT, WIN_LATEST), EOTFL = "Y") |> select(STUDYID, USUBJID, LBTESTCD, WIN_LBSEQ, EOTFL)adlb <- marked |> left_join( winners, by = c("STUDYID", "USUBJID", "LBTESTCD", "LBSEQ" = "WIN_LBSEQ") ) |> arrange(USUBJID, LBTESTCD, LBSEQ) |> select(STUDYID, USUBJID, LBSEQ, LBTESTCD, VISITNUM, AVAL, ENDPOINT, EOTFL)dir.create("/app/output", showWarnings = FALSE)write_csv(adlb, "/app/output/adlb.csv", na = "")solutions/adam-adlb-end-of-treatment/result.py
Edit70 lines# Reference solution for the yamaa benchmark adam-adlb-end-of-treatment (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 csvINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"COLUMNS = ["STUDYID", "USUBJID", "LBSEQ", "LBTESTCD", "VISITNUM", "AVAL", "ENDPOINT", "EOTFL"]def read_csv(path): with open(path, newline="") as f: return list(csv.DictReader(f))def main(): lb = read_csv(INPUT_DIR + "/lb.csv") supplb = read_csv(INPUT_DIR + "/supplb.csv") # Endpoint-marked keys: (STUDYID, USUBJID, LBSEQ as int). In SUPPLB the # sequence number is eight-character, space-padded text. endpoint_keys = set() for row in supplb: if row["QNAM"] == "ENDPOINT": endpoint_keys.add( (row["STUDYID"], row["USUBJID"], int(row["IDVARVAL"].strip())) ) records = [] for row in lb: key = (row["STUDYID"], row["USUBJID"], int(row["LBSEQ"])) records.append({ "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "LBSEQ": row["LBSEQ"], "LBTESTCD": row["LBTESTCD"], "VISITNUM": row["VISITNUM"], "AVAL": row["LBSTRESN"], "ENDPOINT": "Y" if key in endpoint_keys else "", "EOTFL": "", "_visit": int(row["VISITNUM"]), }) # One EOTFL "Y" per subject and test: the endpoint-marked record when # there is one, otherwise the record from the latest visit. groups = {} for i, rec in enumerate(records): groups.setdefault((rec["USUBJID"], rec["LBTESTCD"]), []).append(i) for idxs in groups.values(): marked = [i for i in idxs if records[i]["ENDPOINT"] == "Y"] if marked: winner = marked[0] else: winner = max(idxs, key=lambda i: records[i]["_visit"]) records[winner]["EOTFL"] = "Y" with open(OUTPUT_DIR + "/adlb.csv", "w", newline="") as f: writer = csv.DictWriter(f, fieldnames=COLUMNS) writer.writeheader() for rec in records: writer.writerow({c: rec[c] for c in COLUMNS})if __name__ == "__main__": main()solutions/adam-adlb-end-of-treatment/result.sas
Edit29 lines/* opensas reference solution for the yamaa benchmark adam-adlb-end-of-treatment. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data lb; length STUDYID USUBJID LBTESTCD $1024; infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. LBSEQ LBTESTCD : $char1024. VISITNUM LBSTRESN;run;data supplb; length STUDYID RDOMAIN USUBJID IDVAR IDVARVAL QNAM QLABEL QVAL $1024; infile "/app/input/supplb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. RDOMAIN : $char1024. USUBJID : $char1024. IDVAR : $char1024. IDVARVAL : $char1024. QNAM : $char1024. QLABEL : $char1024. QVAL : $char1024.;run;data supplb_key; set supplb; PARENTSEQ=input(IDVARVAL,?? best32.); run;proc sql; create table joined as select a.*,a.LBSTRESN as AVAL,b.QVAL as ENDPOINT from lb as a left join supplb_key as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and b.RDOMAIN='LB' and b.IDVAR='LBSEQ' and a.LBSEQ=b.PARENTSEQ and b.QNAM='ENDPOINT';quit;data ordered; set joined; priority=0; if ENDPOINT='Y' then priority=1; run;proc sort data=ordered; by STUDYID USUBJID LBTESTCD descending priority descending VISITNUM LBSEQ; run;data result; length EOTFL $1; set ordered; by STUDYID USUBJID LBTESTCD; if first.LBTESTCD then EOTFL='Y'; run;proc sql; create table final as select STUDYID, USUBJID, LBSEQ, LBTESTCD, VISITNUM, AVAL, ENDPOINT, EOTFL from result;quit;proc export data=final outfile="/app/output/adlb.csv" dbms=csv replace; run;
yamaa