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: draftEditUnder review
What this benchmark means
README.md

Public entries: Python and R. Passing coverage requires an installed inventory.

Goal: build one Disposition (DS) record per subject for each of four study events carried in a single ODM item extract: informed consent and randomization as protocol milestones, and end of treatment and end of study as disposition events. Each event gives its own reported term (DSTERM), controlled term (DSDECOD), category (DSCAT), subcategory (DSSCAT) and date (DSSTDTC), with DSSEQ numbering each subject's records in the order they happened.

Input: one ODM file (input/odm.csv) with one row per collected item value, keyed by study, subject, study event, form and item. The four study events are CONSENT, RAND, EOT and EOS; every form carries a date item (IT.DS.DTC), and the treatment and study forms also carry a completion status (IT.DS.COMP), a reported reason (IT.DS.REASON) and a standardized reason (IT.DS.REASONCD).

Variables:

  • DSSEQ numbers each subject's records in the order they happened, by DSSTDTC and then by DSTERM, so records on the same day keep a fixed order. With STUDYID and USUBJID it identifies the record.
  • DSTERM holds the reported term: the controlled term for a milestone; COMPLETED when the completion status says so, or SCREEN FAILURE at end of study when it says so; else the collected reason.
  • DSDECOD holds the controlled term: the same term as DSTERM for a milestone, a completion or a screen failure, else the collected standardized reason.
  • DSCAT follows the event, not the term: PROTOCOL MILESTONE for consent and randomization, DISPOSITION EVENT for end of treatment and end of study.
  • DSSCAT names the event: INFORMED CONSENT, RANDOMIZATION, END OF TREATMENT or END OF STUDY.
  • DSSTDTC is the collected date item for that record.

Note: each collected form gives one record and an event with no form gives none, so a screen failure has only its consent and end-of-study records.

Provenance: DSCAT/DSSCAT/DSTERM/DSDECOD follow the CDISC SDTMIG DS assumptions (protocol milestones carry the same value in DSTERM and DSDECOD), and the controlled terms follow the FDA Technical Conformance Guide DS guidance. All subjects, dates and reasons are invented fixtures.

Inputs

Under review
1 source file

input/odm.csv

Edit
40 rows
input/odm.csv
StudyOIDMetaDataVersionOIDSubjectKeyStudyEventOIDStudyEventRepeatKeyItemGroupOIDItemGroupRepeatKeyItemOIDValue
YAMAA-01MDV.1001CONSENT1IG.DS1IT.DS.DTC2024-01-05
YAMAA-01MDV.1001CONSENT1IG.DS1IT.DS.COMP—
YAMAA-01MDV.1001CONSENT1IG.DS1IT.DS.REASON—
YAMAA-01MDV.1001CONSENT1IG.DS1IT.DS.REASONCD—
YAMAA-01MDV.1001RAND1IG.DS1IT.DS.DTC2024-01-05
YAMAA-01MDV.1001RAND1IG.DS1IT.DS.COMP—
YAMAA-01MDV.1001RAND1IG.DS1IT.DS.REASON—
YAMAA-01MDV.1001RAND1IG.DS1IT.DS.REASONCD—
YAMAA-01MDV.1001EOT1IG.DS1IT.DS.DTC2024-06-10
YAMAA-01MDV.1001EOT1IG.DS1IT.DS.COMPCOMPLETED
YAMAA-01MDV.1001EOT1IG.DS1IT.DS.REASON—
YAMAA-01MDV.1001EOT1IG.DS1IT.DS.REASONCD—
YAMAA-01MDV.1001EOS1IG.DS1IT.DS.DTC2024-07-15
YAMAA-01MDV.1001EOS1IG.DS1IT.DS.COMPCOMPLETED
YAMAA-01MDV.1001EOS1IG.DS1IT.DS.REASON—
YAMAA-01MDV.1001EOS1IG.DS1IT.DS.REASONCD—
YAMAA-01MDV.1002CONSENT1IG.DS1IT.DS.DTC2024-01-08
YAMAA-01MDV.1002CONSENT1IG.DS1IT.DS.COMP—
YAMAA-01MDV.1002CONSENT1IG.DS1IT.DS.REASON—
YAMAA-01MDV.1002CONSENT1IG.DS1IT.DS.REASONCD—
YAMAA-01MDV.1002RAND1IG.DS1IT.DS.DTC2024-01-09
YAMAA-01MDV.1002RAND1IG.DS1IT.DS.COMP—
YAMAA-01MDV.1002RAND1IG.DS1IT.DS.REASON—
YAMAA-01MDV.1002RAND1IG.DS1IT.DS.REASONCD—
YAMAA-01MDV.1002EOT1IG.DS1IT.DS.DTC2024-03-20
YAMAA-01MDV.1002EOT1IG.DS1IT.DS.COMPDISCONTINUED
YAMAA-01MDV.1002EOT1IG.DS1IT.DS.REASONSevere nausea
YAMAA-01MDV.1002EOT1IG.DS1IT.DS.REASONCDADVERSE EVENT
YAMAA-01MDV.1002EOS1IG.DS1IT.DS.DTC2024-03-25
YAMAA-01MDV.1002EOS1IG.DS1IT.DS.COMPDISCONTINUED
YAMAA-01MDV.1002EOS1IG.DS1IT.DS.REASONSubject moved
YAMAA-01MDV.1002EOS1IG.DS1IT.DS.REASONCDLOST TO FOLLOW-UP
YAMAA-01MDV.1003CONSENT1IG.DS1IT.DS.DTC2024-01-12
YAMAA-01MDV.1003CONSENT1IG.DS1IT.DS.COMP—
YAMAA-01MDV.1003CONSENT1IG.DS1IT.DS.REASON—
YAMAA-01MDV.1003CONSENT1IG.DS1IT.DS.REASONCD—
YAMAA-01MDV.1003EOS1IG.DS1IT.DS.DTC2024-01-14
YAMAA-01MDV.1003EOS1IG.DS1IT.DS.COMPSCREEN FAILURE
YAMAA-01MDV.1003EOS1IG.DS1IT.DS.REASON—
YAMAA-01MDV.1003EOS1IG.DS1IT.DS.REASONCD—

Expected output

Under review
10 expected rows

expected/ds.csv

Edit
10 rows
expected/ds.csv
DOMAINSTUDYIDUSUBJIDDSSEQDSTERMDSDECODDSCATDSSCATDSSTDTC
DSYAMAA-011INFORMED CONSENT OBTAINEDINFORMED CONSENT OBTAINEDPROTOCOL MILESTONEINFORMED CONSENT2024-01-05
DSYAMAA-012RANDOMIZEDRANDOMIZEDPROTOCOL MILESTONERANDOMIZATION2024-01-05
DSYAMAA-013COMPLETEDCOMPLETEDDISPOSITION EVENTEND OF TREATMENT2024-06-10
DSYAMAA-014COMPLETEDCOMPLETEDDISPOSITION EVENTEND OF STUDY2024-07-15
DSYAMAA-011INFORMED CONSENT OBTAINEDINFORMED CONSENT OBTAINEDPROTOCOL MILESTONEINFORMED CONSENT2024-01-08
DSYAMAA-012RANDOMIZEDRANDOMIZEDPROTOCOL MILESTONERANDOMIZATION2024-01-09
DSYAMAA-013Severe nauseaADVERSE EVENTDISPOSITION EVENTEND OF TREATMENT2024-03-20
DSYAMAA-014Subject movedLOST TO FOLLOW-UPDISPOSITION EVENTEND OF STUDY2024-03-25
DSYAMAA-011INFORMED CONSENT OBTAINEDINFORMED CONSENT OBTAINEDPROTOCOL MILESTONEINFORMED CONSENT2024-01-12
DSYAMAA-012SCREEN FAILURESCREEN FAILUREDISPOSITION EVENTEND OF STUDY2024-01-14
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

Variable NameVariable LabelTypeLengthControlled Terms or FormatOriginCoreConversion DefinitionVariable TypeVariable OrderComments for Define
DOMAINDomain AbbreviationCharDSAssignedSet constant value "DS".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from ODM.StudyOID.SDTM2
USUBJIDUnique Subject IdentifierCharDerivedFill the template "{STUDYID}-{SUBJKEY}".SDTM3
DSTERMReported Term for the Disposition EventCharDerivedSet per constructed row; see the Row construction sheet.SDTM4
DSDECODStandardized Disposition TermCharINFORMED CONSENT OBTAINED, RANDOMIZED, COMPLETED, ADVERSE EVENT, LOST TO FOLLOW-UP, SCREEN FAILUREDerivedSet per constructed row; see the Row construction sheet.SDTM5
DSCATCategory for Disposition EventCharPROTOCOL MILESTONE, DISPOSITION EVENTDerivedSet per constructed row; see the Row construction sheet.SDTM6
DSSCATSubcategory for Disposition EventCharINFORMED CONSENT, RANDOMIZATION, END OF TREATMENT, END OF STUDYDerivedSet per constructed row; see the Row construction sheet.SDTM7
DSSTDTCStart Date/Time of Disposition EventCharISO 8601DerivedSet per constructed row; see the Row construction sheet.SDTM8
DSSEQSequence NumberNumDerivedRow number within each group of STUDYID, USUBJID, ordered by DSSTDTC then DSTERM.SDTM9
TemplateInclude whenEVENTCOMPSTATDSTERMDSDECODDSCATDSSCATDSSTDTC
consentEVENT = 'CONSENT'Copy ODM.StudyEventOIDAggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.COMP'Constant "INFORMED CONSENT OBTAINED"Constant "INFORMED CONSENT OBTAINED"Constant "PROTOCOL MILESTONE"Constant "INFORMED CONSENT"Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.DTC'
randomizationEVENT = 'RAND'Copy ODM.StudyEventOIDAggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.COMP'Constant "RANDOMIZED"Constant "RANDOMIZED"Constant "PROTOCOL MILESTONE"Constant "RANDOMIZATION"Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.DTC'
end_of_treatmentEVENT = 'EOT'Copy ODM.StudyEventOIDAggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.COMP'If COMPSTAT = 'COMPLETED' then "COMPLETED"; otherwise aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.REASON'If COMPSTAT = 'COMPLETED' then "COMPLETED"; otherwise aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.REASONCD'Constant "DISPOSITION EVENT"Constant "END OF TREATMENT"Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.DTC'
end_of_studyEVENT = 'EOS'Copy ODM.StudyEventOIDAggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.COMP'If COMPSTAT = 'COMPLETED' then "COMPLETED"; If COMPSTAT = 'SCREEN FAILURE' then "SCREEN FAILURE"; otherwise aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.REASON'If COMPSTAT = 'COMPLETED' then "COMPLETED"; If COMPSTAT = 'SCREEN FAILURE' then "SCREEN FAILURE"; otherwise aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.REASONCD'Constant "DISPOSITION EVENT"Constant "END OF STUDY"Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.DS.DTC'
VariablePermitted values
DOMAINDS
DSDECODINFORMED CONSENT OBTAINED, RANDOMIZED, COMPLETED, ADVERSE EVENT, LOST TO FOLLOW-UP, SCREEN FAILURE
DSCATPROTOCOL MILESTONE, DISPOSITION EVENT
DSSCATINFORMED CONSENT, RANDOMIZATION, END OF TREATMENT, END OF STUDY
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/sdtm-ds-multi-form-disposition/full.md

Edit
29 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject per study event.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSTERM, DSDECOD, DSCAT, DSSCAT, DSSTDTC

DOMAIN is "DS". STUDYID is the ODM study OID, and USUBJID is the study OID and the subject key joined with a hyphen. Each collected form gives one record, and a study event with no form gives none. The study event names the event: "CONSENT" is informed consent, "RAND" is randomization, "EOT" is end of treatment and "EOS" is end of study. DSCAT is "PROTOCOL MILESTONE" for informed consent and randomization and "DISPOSITION EVENT" for end of treatment and end of study. DSSCAT is "INFORMED CONSENT" for informed consent, "RANDOMIZATION" for randomization, "END OF TREATMENT" for end of treatment and "END OF STUDY" for end of study. For a protocol milestone, DSTERM and DSDECOD both hold the controlled term, "INFORMED CONSENT OBTAINED" for informed consent and "RANDOMIZED" for randomization. For end of treatment and end of study, DSTERM is "COMPLETED" when the form's completion status is "COMPLETED", and at end of study it is "SCREEN FAILURE" when the completion status is "SCREEN FAILURE"; otherwise DSTERM is the reason reported on the form. DSDECOD holds the same term as DSTERM for a milestone, a completion or a screen failure, and otherwise the standardized reason collected on the form. DSSTDTC is the date collected on the form. DSSEQ numbers each subject's records from 1 in the order they happened, by DSSTDTC and then by DSTERM, so records on the same day keep a fixed order.

Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.

prompts/sdtm-ds-multi-form-disposition/conventions.md

Edit
14 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject per study event.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSTERM, DSDECOD, DSCAT, DSSCAT, DSSTDTC

DOMAIN is "DS". DSCAT is "PROTOCOL MILESTONE" or "DISPOSITION EVENT". DSSCAT is "INFORMED CONSENT", "RANDOMIZATION", "END OF TREATMENT" or "END OF STUDY". DSTERM and DSDECOD take the controlled terms "INFORMED CONSENT OBTAINED" and "RANDOMIZED", and DSTERM also takes "COMPLETED" and "SCREEN FAILURE".

Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.

prompts/sdtm-ds-multi-form-disposition/brief.md

Edit
8 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject per study event.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSTERM, DSDECOD, DSCAT, DSSCAT, DSSTDTC

Read the source datasets from /app/input and save the completed dataset as /app/output/ds.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/sdtm-ds-multi-form-disposition/result.R

Edit
79 lines
# Reference solution for the yamaa benchmark sdtm-ds-multi-form-disposition (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(tidyr)odm <- read_csv(  "/app/input/odm.csv",  col_types = cols(.default = col_character()))wide <- odm |>  group_by(StudyOID, SubjectKey, StudyEventOID) |>  summarise(    DTC = Value[ItemOID == "IT.DS.DTC"][1],    COMP = Value[ItemOID == "IT.DS.COMP"][1],    REASON = Value[ItemOID == "IT.DS.REASON"][1],    REASONCD = Value[ItemOID == "IT.DS.REASONCD"][1],    .groups = "drop"  )ds <- wide |>  rowwise() |>  mutate(    DSTERM = case_when(      StudyEventOID == "CONSENT" ~ "INFORMED CONSENT OBTAINED",      StudyEventOID == "RAND" ~ "RANDOMIZED",      StudyEventOID == "EOT" & COMP == "COMPLETED" ~ "COMPLETED",      StudyEventOID == "EOT" ~ REASON,      StudyEventOID == "EOS" & COMP == "COMPLETED" ~ "COMPLETED",      StudyEventOID == "EOS" & COMP == "SCREEN FAILURE" ~ "SCREEN FAILURE",      StudyEventOID == "EOS" ~ REASON,      .default = NA_character_    ),    DSDECOD = case_when(      StudyEventOID == "CONSENT" ~ "INFORMED CONSENT OBTAINED",      StudyEventOID == "RAND" ~ "RANDOMIZED",      StudyEventOID == "EOT" & COMP == "COMPLETED" ~ "COMPLETED",      StudyEventOID == "EOT" ~ REASONCD,      StudyEventOID == "EOS" & COMP == "COMPLETED" ~ "COMPLETED",      StudyEventOID == "EOS" & COMP == "SCREEN FAILURE" ~ "SCREEN FAILURE",      StudyEventOID == "EOS" ~ REASONCD,      .default = NA_character_    ),    DSCAT = case_when(      StudyEventOID %in% c("CONSENT", "RAND") ~ "PROTOCOL MILESTONE",      StudyEventOID %in% c("EOT", "EOS") ~ "DISPOSITION EVENT",      .default = NA_character_    ),    DSSCAT = case_when(      StudyEventOID == "CONSENT" ~ "INFORMED CONSENT",      StudyEventOID == "RAND" ~ "RANDOMIZATION",      StudyEventOID == "EOT" ~ "END OF TREATMENT",      StudyEventOID == "EOS" ~ "END OF STUDY",      .default = NA_character_    )  ) |>  ungroup() |>  filter(StudyEventOID %in% c("CONSENT", "RAND", "EOT", "EOS")) |>  mutate(    DOMAIN = "DS",    STUDYID = StudyOID,    USUBJID = paste(StudyOID, SubjectKey, sep = "-"),    DSSTDTC = suppressWarnings(as.Date(na_if(DTC, ""))),    DSTERM = na_if(DSTERM, ""),    DSDECOD = na_if(DSDECOD, "")  ) |>  arrange(USUBJID, DSSTDTC, DSTERM) |>  group_by(USUBJID) |>  mutate(DSSEQ = row_number()) |>  ungroup() |>  select(DOMAIN, STUDYID, USUBJID, DSSEQ, DSTERM, DSDECOD, DSCAT, DSSCAT, DSSTDTC)dir.create("/app/output", showWarnings = FALSE)write_csv(ds, "/app/output/ds.csv", na = "")

solutions/sdtm-ds-multi-form-disposition/result.py

Edit
93 lines
# Reference solution for the yamaa benchmark sdtm-ds-multi-form-disposition (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."""Build the SDTM DS dataset from the collected ODM extract.One record per subject per collected form (study event). Reads/app/input/odm.csv (long EAV form: one row per collected item) andwrites /app/output/ds.csv."""import csvimport osfrom collections import OrderedDictINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"# StudyEventOID -> (DSCAT, DSSCAT, controlled term for a milestone)EVENT_INFO = {    "CONSENT": ("PROTOCOL MILESTONE", "INFORMED CONSENT",                "INFORMED CONSENT OBTAINED"),    "RAND": ("PROTOCOL MILESTONE", "RANDOMIZATION", "RANDOMIZED"),    "EOT": ("DISPOSITION EVENT", "END OF TREATMENT", None),    "EOS": ("DISPOSITION EVENT", "END OF STUDY", None),}COLUMNS = ["DOMAIN", "STUDYID", "USUBJID", "DSSEQ", "DSTERM", "DSDECOD",           "DSCAT", "DSSCAT", "DSSTDTC"]def main():    with open(os.path.join(INPUT_DIR, "odm.csv"), newline="") as f:        rows = list(csv.DictReader(f))    # Group the EAV rows into forms: one form per subject, study event    # and repeat keys. A study event with no form gives no record.    forms = OrderedDict()    for row in rows:        key = (row["StudyOID"], row["SubjectKey"], row["StudyEventOID"],               row["StudyEventRepeatKey"], row["ItemGroupOID"],               row["ItemGroupRepeatKey"])        forms.setdefault(key, {})[row["ItemOID"]] = row["Value"] or ""    records = []    for (study_oid, subject_key, event_oid, *_), items in forms.items():        dscat, dsscat, milestone_term = EVENT_INFO[event_oid]        completion = items.get("IT.DS.COMP", "")        if milestone_term is not None:            dsterm = dsdecod = milestone_term        elif completion == "COMPLETED":            dsterm = dsdecod = "COMPLETED"        elif event_oid == "EOS" and completion == "SCREEN FAILURE":            dsterm = dsdecod = "SCREEN FAILURE"        else:            dsterm = items.get("IT.DS.REASON", "")            dsdecod = items.get("IT.DS.REASONCD", "")        records.append({            "DOMAIN": "DS",            "STUDYID": study_oid,            "USUBJID": "{}-{}".format(study_oid, subject_key),            "DSTERM": dsterm,            "DSDECOD": dsdecod,            "DSCAT": dscat,            "DSSCAT": dsscat,            "DSSTDTC": items.get("IT.DS.DTC", ""),        })    # DSSEQ numbers each subject's records from 1 in the order they    # happened, by DSSTDTC and then by DSTERM.    by_subject = OrderedDict()    for record in records:        by_subject.setdefault(record["USUBJID"], []).append(record)    out_rows = []    for subject_records in by_subject.values():        subject_records.sort(key=lambda r: (r["DSSTDTC"], r["DSTERM"]))        for seq, record in enumerate(subject_records, start=1):            record["DSSEQ"] = seq            out_rows.append(record)    os.makedirs(OUTPUT_DIR, exist_ok=True)    with open(os.path.join(OUTPUT_DIR, "ds.csv"), "w", newline="") as f:        writer = csv.DictWriter(f, fieldnames=COLUMNS)        writer.writeheader()        for record in out_rows:            writer.writerow({col: record[col] for col in COLUMNS})if __name__ == "__main__":    main()

solutions/sdtm-ds-multi-form-disposition/result.sas

Edit
44 lines
/* opensas reference solution for the yamaa benchmark sdtm-ds-multi-form-disposition.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data odm;  length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey ItemOID Value $1024;  infile "/app/input/odm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input StudyOID : $char1024. MetaDataVersionOID : $char1024. SubjectKey : $char1024. StudyEventOID : $char1024. StudyEventRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey StudyEventOID; run;data wide;  length COMP DTC REASON REASONCD $1024;  retain COMP DTC REASON REASONCD;  set ordered;  by StudyOID SubjectKey StudyEventOID;  if first.StudyEventOID then do;    COMP=''; DTC=''; REASON=''; REASONCD='';  end;    if ItemOID='IT.DS.COMP' then COMP=Value;  if ItemOID='IT.DS.DTC' then DTC=Value;  if ItemOID='IT.DS.REASON' then REASON=Value;  if ItemOID='IT.DS.REASONCD' then REASONCD=Value;  if last.StudyEventOID then output;run;data prepared; set wide; length DOMAIN $2 STUDYID USUBJID DSTERM DSDECOD DSCAT DSSCAT DSSTDTC $1024;DOMAIN='DS'; STUDYID=StudyOID; USUBJID=SubjectKey; DSCAT='DISPOSITION EVENT'; DSSTDTC=DTC; DSTERM=REASON; DSDECOD=REASONCD;if COMP='COMPLETED' then do; DSTERM='COMPLETED'; DSDECOD='COMPLETED'; end;USUBJID=catx('-',StudyOID,SubjectKey);if StudyEventOID='CONSENT' then do; DSTERM='INFORMED CONSENT OBTAINED'; DSDECOD=DSTERM; DSCAT='PROTOCOL MILESTONE'; DSSCAT='INFORMED CONSENT'; end;if StudyEventOID='RAND' then do; DSTERM='RANDOMIZED'; DSDECOD=DSTERM; DSCAT='PROTOCOL MILESTONE'; DSSCAT='RANDOMIZATION'; end;if StudyEventOID='EOT' then DSSCAT='END OF TREATMENT';if StudyEventOID='EOS' then do; DSSCAT='END OF STUDY'; if COMP='SCREEN FAILURE' then do; DSTERM='SCREEN FAILURE'; DSDECOD=DSTERM; end; end; run;proc sort data=prepared; by STUDYID USUBJID DSSTDTC DSTERM; run;data result; set prepared; by STUDYID USUBJID; retain DSSEQ;  if first.USUBJID then DSSEQ=0;  DSSEQ+1;run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, DSSEQ, DSTERM, DSDECOD, DSCAT, DSSCAT, DSSTDTC from result;quit;proc export data=final outfile="/app/output/ds.csv" dbms=csv replace; run;