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.
- Task: Would a real study need this derivation, specified this way? Does it follow CDISC SDTM: variable names, controlled terms, record structure? Flag any rule that is ambiguous or that a sponsor would handle differently.
- Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
- 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
README.mdGoal: derive FASEQ, FATESTCD, FATEST, FAOBJ, FACAT,
FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN,
FASTRESU, FASTAT, FATPT, and FADTC for each solicited
reaction on a vaccine reactogenicity diary in Findings About (FA).
Input: one row per diary day per solicited reaction, carrying the diary day label, the collection date, the reaction, whether the reaction is local or systemic, the occurrence and severity recorded for completed days, the measured diameter for redness and swelling, and whether the diary day was completed.
Variables:
FASEQnumbers the subject's records by diary day, reaction name, and test order (OCCUR,SEV,LDIAM). Output records are grouped by subject, then ordered by that number.FATESTCDisOCCURfor the occurrence record, one per reaction per diary day;SEVfor the severity record, on completed days only; andLDIAMfor the longest-diameter record, only for redness or swelling that occurred on a completed day.FATESTisOccurrence Indicator,Severity/Intensity, andLongest Diameterrespectively.FAOBJcopies the solicited reaction.FACATis alwaysREACTOGENICITY.FASCATisADMINISTRATION SITEfor local reactions andSYSTEMICfor systemic reactions.FAORRESis the recordedY/NforOCCUR, the recorded severity forSEV(NONEunless the reaction occurred), and the measured diameter forLDIAM; it is blank on a missed diary day.FAORRESUis the diameter unit, onLDIAMrecords only.FASTRESCcopiesFAORRES.FASTRESNis the measured diameter as a number, onLDIAMrecords only.FASTRESUcopies the diameter unit, onLDIAMrecords only.FASTATisNOT DONEfor a missed diary day, and blank otherwise.FATPTis the diary day label (END DAY 1, ...).FADTCis the diary collection date.
Note: temperature stays in Vital Signs (VS) and is not a reactogenicity diary record, so it never becomes an FA record here.
Inputs
Under review1 source fileinput/diary.csv
Edit16 rows| STUDYID | USUBJID | DIARYDAY | TPT | DTC | REACTION | CATSRC | OCCUR | SEV | DIAMETER | DIAMUNIT | COMPLETED |
|---|---|---|---|---|---|---|---|---|---|---|---|
| VAX01 | 1 | END DAY 1 | 2025-03-02 | PAIN | LOCAL | Y | MILD | — | — | Y | |
| VAX01 | 1 | END DAY 1 | 2025-03-02 | REDNESS | LOCAL | Y | MODERATE | 35 | mm | Y | |
| VAX01 | 1 | END DAY 1 | 2025-03-02 | SWELLING | LOCAL | N | NONE | — | — | Y | |
| VAX01 | 1 | END DAY 1 | 2025-03-02 | HEADACHE | SYSTEMIC | Y | MILD | — | — | Y | |
| VAX01 | 1 | END DAY 1 | 2025-03-02 | FATIGUE | SYSTEMIC | N | NONE | — | — | Y | |
| VAX01 | 2 | END DAY 2 | 2025-03-03 | PAIN | LOCAL | N | NONE | — | — | Y | |
| VAX01 | 2 | END DAY 2 | 2025-03-03 | REDNESS | LOCAL | Y | MILD | 25 | mm | Y | |
| VAX01 | 2 | END DAY 2 | 2025-03-03 | SWELLING | LOCAL | N | NONE | — | — | Y | |
| VAX01 | 2 | END DAY 2 | 2025-03-03 | HEADACHE | SYSTEMIC | N | NONE | — | — | Y | |
| VAX01 | 2 | END DAY 2 | 2025-03-03 | FATIGUE | SYSTEMIC | Y | MODERATE | — | — | Y | |
| VAX01 | 3 | END DAY 3 | 2025-03-04 | PAIN | LOCAL | — | — | — | — | N | |
| VAX01 | 3 | END DAY 3 | 2025-03-04 | REDNESS | LOCAL | — | — | — | — | N | |
| VAX01 | 3 | END DAY 3 | 2025-03-04 | SWELLING | LOCAL | — | — | — | — | N | |
| VAX01 | 3 | END DAY 3 | 2025-03-04 | HEADACHE | SYSTEMIC | — | — | — | — | N | |
| VAX01 | 3 | END DAY 3 | 2025-03-04 | FATIGUE | SYSTEMIC | — | — | — | — | N | |
| VAX01 | 1 | END DAY 1 | 2025-03-02 | PAIN | LOCAL | Y | MILD | — | — | Y |
Expected output
Under review29 expected rowsexpected/fa.csv
Edit29 rows| DOMAIN | STUDYID | USUBJID | FASEQ | FATESTCD | FATEST | FAOBJ | FACAT | FASCAT | FAORRES | FAORRESU | FASTRESC | FASTRESN | FASTRESU | FASTAT | FATPT | FADTC |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| FA | VAX01 | 1 | OCCUR | Occurrence Indicator | FATIGUE | REACTOGENICITY | SYSTEMIC | N | — | N | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 2 | SEV | Severity/Intensity | FATIGUE | REACTOGENICITY | SYSTEMIC | NONE | — | NONE | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 3 | OCCUR | Occurrence Indicator | HEADACHE | REACTOGENICITY | SYSTEMIC | Y | — | Y | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 4 | SEV | Severity/Intensity | HEADACHE | REACTOGENICITY | SYSTEMIC | MILD | — | MILD | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 5 | OCCUR | Occurrence Indicator | PAIN | REACTOGENICITY | ADMINISTRATION SITE | Y | — | Y | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 6 | SEV | Severity/Intensity | PAIN | REACTOGENICITY | ADMINISTRATION SITE | MILD | — | MILD | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 7 | OCCUR | Occurrence Indicator | REDNESS | REACTOGENICITY | ADMINISTRATION SITE | Y | — | Y | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 8 | SEV | Severity/Intensity | REDNESS | REACTOGENICITY | ADMINISTRATION SITE | MODERATE | — | MODERATE | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 9 | LDIAM | Longest Diameter | REDNESS | REACTOGENICITY | ADMINISTRATION SITE | 35 | mm | 35 | 35 | mm | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 10 | OCCUR | Occurrence Indicator | SWELLING | REACTOGENICITY | ADMINISTRATION SITE | N | — | N | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 11 | SEV | Severity/Intensity | SWELLING | REACTOGENICITY | ADMINISTRATION SITE | NONE | — | NONE | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 12 | OCCUR | Occurrence Indicator | FATIGUE | REACTOGENICITY | SYSTEMIC | Y | — | Y | — | — | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 13 | SEV | Severity/Intensity | FATIGUE | REACTOGENICITY | SYSTEMIC | MODERATE | — | MODERATE | — | — | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 14 | OCCUR | Occurrence Indicator | HEADACHE | REACTOGENICITY | SYSTEMIC | N | — | N | — | — | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 15 | SEV | Severity/Intensity | HEADACHE | REACTOGENICITY | SYSTEMIC | NONE | — | NONE | — | — | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 16 | OCCUR | Occurrence Indicator | PAIN | REACTOGENICITY | ADMINISTRATION SITE | N | — | N | — | — | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 17 | SEV | Severity/Intensity | PAIN | REACTOGENICITY | ADMINISTRATION SITE | NONE | — | NONE | — | — | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 18 | OCCUR | Occurrence Indicator | REDNESS | REACTOGENICITY | ADMINISTRATION SITE | Y | — | Y | — | — | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 19 | SEV | Severity/Intensity | REDNESS | REACTOGENICITY | ADMINISTRATION SITE | MILD | — | MILD | — | — | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 20 | LDIAM | Longest Diameter | REDNESS | REACTOGENICITY | ADMINISTRATION SITE | 25 | mm | 25 | 25 | mm | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 21 | OCCUR | Occurrence Indicator | SWELLING | REACTOGENICITY | ADMINISTRATION SITE | N | — | N | — | — | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 22 | SEV | Severity/Intensity | SWELLING | REACTOGENICITY | ADMINISTRATION SITE | NONE | — | NONE | — | — | — | END DAY 2 | 2025-03-03 | |
| FA | VAX01 | 23 | OCCUR | Occurrence Indicator | FATIGUE | REACTOGENICITY | SYSTEMIC | — | — | — | — | — | NOT DONE | END DAY 3 | 2025-03-04 | |
| FA | VAX01 | 24 | OCCUR | Occurrence Indicator | HEADACHE | REACTOGENICITY | SYSTEMIC | — | — | — | — | — | NOT DONE | END DAY 3 | 2025-03-04 | |
| FA | VAX01 | 25 | OCCUR | Occurrence Indicator | PAIN | REACTOGENICITY | ADMINISTRATION SITE | — | — | — | — | — | NOT DONE | END DAY 3 | 2025-03-04 | |
| FA | VAX01 | 26 | OCCUR | Occurrence Indicator | REDNESS | REACTOGENICITY | ADMINISTRATION SITE | — | — | — | — | — | NOT DONE | END DAY 3 | 2025-03-04 | |
| FA | VAX01 | 27 | OCCUR | Occurrence Indicator | SWELLING | REACTOGENICITY | ADMINISTRATION SITE | — | — | — | — | — | NOT DONE | END DAY 3 | 2025-03-04 | |
| FA | VAX01 | 1 | OCCUR | Occurrence Indicator | PAIN | REACTOGENICITY | ADMINISTRATION SITE | Y | — | Y | — | — | — | END DAY 1 | 2025-03-02 | |
| FA | VAX01 | 2 | SEV | Severity/Intensity | PAIN | REACTOGENICITY | ADMINISTRATION SITE | MILD | — | MILD | — | — | — | END DAY 1 | 2025-03-02 |
Comments and assessment materials
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| DOMAIN | Domain Abbreviation | Char | Assigned | Set constant value "FA". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from DIARY.STUDYID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from DIARY.USUBJID. | SDTM | 3 | ||||
| FATESTCD | Findings About Test Short Name | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 4 | ||||
| FATEST | Findings About Test Name | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 5 | ||||
| FASEQ | Sequence Number | Num | Derived | Row number within each group of STUDYID, USUBJID, ordered by DIARY.DIARYDAY then DIARY.REACTION then TESTORD. | SDTM | 6 | ||||
| FAOBJ | Object of the Observation | Char | Collected | Copy value from DIARY.REACTION. | SDTM | 7 | ||||
| FACAT | Category for Findings About | Char | Assigned | Set constant value "REACTOGENICITY". | SDTM | 8 | ||||
| FASCAT | Subcategory for Findings About | Char | Derived | If DIARY.CATSRC = 'LOCAL' then "ADMINISTRATION SITE"; otherwise "SYSTEMIC". | SDTM | 9 | ||||
| FAORRES | Result or Finding in Original Units | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 10 | ||||
| FAORRESU | Original Units | Char | Derived | If FATESTCD = 'LDIAM' then "DIARY.DIAMUNIT"; otherwise blank. | SDTM | 11 | ||||
| FASTRESC | Character Result/Finding in Std Format | Char | Derived | Copy value from FAORRES. | SDTM | 12 | ||||
| FASTRESN | Numeric Result/Finding in Standard Units | Num | Derived | If FATESTCD = 'LDIAM' then "DIARY.DIAMETER"; otherwise blank. | SDTM | 13 | ||||
| FASTRESU | Standard Units | Char | Derived | Copy value from FAORRESU. | SDTM | 14 | ||||
| FASTAT | Completion Status | Char | Derived | If DIARY.COMPLETED = 'N' then "NOT DONE"; otherwise blank. | SDTM | 15 | ||||
| FATPT | Planned Time Point Name | Char | Collected | Copy value from DIARY.TPT. | SDTM | 16 | ||||
| FADTC | Date/Time of Collection | Char | ISO 8601 | Collected | Copy value from DIARY.DTC. | SDTM | 17 |
| Template | Include when | FATESTCD | FATEST | FAORRES |
|---|---|---|---|---|
| occurrence | Constant "OCCUR" | Constant "Occurrence Indicator" | If DIARY.COMPLETED = 'Y' then "DIARY.OCCUR"; otherwise blank | |
| severity | DIARY.COMPLETED = 'Y' | Constant "SEV" | Constant "Severity/Intensity" | If DIARY.OCCUR = 'Y' then "DIARY.SEV"; otherwise "NONE" |
| longest-diameter | DIARY.COMPLETED = 'Y' AND DIARY.OCCUR = 'Y' AND DIARY.REACTION IN ('REDNESS', 'SWELLING') | Constant "LDIAM" | Constant "Longest Diameter" | Copy DIARY.DIAMETER |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 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/sdtm-fa-reactogenicity-diary/full.md
Edit28 linesFollowing CDISC SDTM standards, use the provided DIARY dataset to create an FA dataset with one record per solicited reaction test on each diary day.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT, FATPT, FADTC
Every diary row gives an occurrence record; completed days also give a severity record, and redness or swelling that occurred on a completed day also gives a longest-diameter record. FATESTCD is OCCUR, SEV, or LDIAM, with FATEST Occurrence Indicator, Severity/Intensity, or Longest Diameter. FAOBJ keeps the solicited reaction. FACAT is always REACTOGENICITY. FASCAT is ADMINISTRATION SITE for local reactions and SYSTEMIC for systemic reactions. FAORRES is the recorded Y or N for OCCUR, the recorded severity for SEV (NONE unless the reaction occurred), and the measured diameter as recorded for LDIAM (a whole number has no decimal point); it has no value on a missed diary day. FAORRESU is the diameter unit, on LDIAM records only. FASTRESC keeps FAORRES. FASTRESN is the measured diameter as a number, on LDIAM records only. FASTRESU keeps the diameter unit, on LDIAM records only. FASTAT is NOT DONE for a missed diary day, and has no value otherwise. FATPT is the diary day label and FADTC is the diary collection date. Temperature stays in Vital Signs and never becomes an FA record here. FASEQ numbers the subject's records by diary day, reaction name, and test order OCCUR, SEV, LDIAM.
Read the source datasets from /app/input and save the completed dataset as /app/output/fa.csv.
prompts/sdtm-fa-reactogenicity-diary/conventions.md
Edit17 linesFollowing CDISC SDTM standards, use the provided DIARY dataset to create an FA dataset with one record per solicited reaction test on each diary day.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT, FATPT, FADTC
FATESTCD is OCCUR, SEV, or LDIAM, with FATEST Occurrence Indicator, Severity/Intensity, or Longest Diameter. FACAT is always REACTOGENICITY. FASCAT is ADMINISTRATION SITE for local reactions and SYSTEMIC for systemic reactions. FAORRES is the recorded Y or N for OCCUR, the recorded severity or NONE for SEV, and the measured diameter as recorded for LDIAM (a whole number has no decimal point). FASTAT is NOT DONE or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/fa.csv.
prompts/sdtm-fa-reactogenicity-diary/brief.md
Edit10 linesFollowing CDISC SDTM standards, use the provided DIARY dataset to create an FA dataset with one record per solicited reaction test on each diary day.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT, FATPT, FADTC
Read the source datasets from /app/input and save the completed dataset as /app/output/fa.csv.
run.R
Edit4 lineslibrary(yamaa)fa <- yamaa_domain("spec.yaml")$outputfarun.py
Edit4 linesimport yamaafa = yamaa.yamaa_domain("spec.yaml").outputfasolutions/sdtm-fa-reactogenicity-diary/result.R
Edit114 lines# Reference solution for the yamaa benchmark sdtm-fa-reactogenicity-diary (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(purrr)diary <- read_csv( "/app/input/diary.csv", col_types = cols(DIARYDAY = col_integer(), .default = col_character()))local_reactions <- c("PAIN", "REDNESS", "SWELLING")one_row <- function(r) { fascat <- if (r$CATSRC %in% "LOCAL") { "ADMINISTRATION SITE" } else if (r$CATSRC %in% "SYSTEMIC") { "SYSTEMIC" } else if (r$REACTION %in% local_reactions) { "ADMINISTRATION SITE" } else { "SYSTEMIC" } base <- tibble( DOMAIN = "FA", STUDYID = r$STUDYID, USUBJID = r$USUBJID, DAY = r$DIARYDAY, REACTION = r$REACTION, FAOBJ = r$REACTION, FACAT = "REACTOGENICITY", FASCAT = fascat, FATPT = r$TPT, FADTC = r$DTC ) clean <- function(x) { if (is.na(x) || x == "") NA_character_ else x } if (is.na(r$COMPLETED) || r$COMPLETED != "Y") { return(base |> mutate( ORDER = 0L, FATESTCD = "OCCUR", FATEST = "Occurrence Indicator", FAORRES = NA_character_, FAORRESU = NA_character_, FASTRESC = NA_character_, FASTRESN = NA_real_, FASTRESU = NA_character_, FASTAT = "NOT DONE" )) } occur <- clean(r$OCCUR) sev <- if (occur %in% "Y") clean(r$SEV) else "NONE" diam <- clean(r$DIAMETER) unit <- clean(r$DIAMUNIT) out <- base |> mutate( ORDER = 0L, FATESTCD = "OCCUR", FATEST = "Occurrence Indicator", FAORRES = occur, FAORRESU = NA_character_, FASTRESC = occur, FASTRESN = NA_real_, FASTRESU = NA_character_, FASTAT = NA_character_ ) out <- bind_rows( out, base |> mutate( ORDER = 1L, FATESTCD = "SEV", FATEST = "Severity/Intensity", FAORRES = sev, FAORRESU = NA_character_, FASTRESC = sev, FASTRESN = NA_real_, FASTRESU = NA_character_, FASTAT = NA_character_ ) ) if (r$REACTION %in% c("REDNESS", "SWELLING") && !is.na(occur) && occur == "Y") { out <- bind_rows( out, base |> mutate( ORDER = 2L, FATESTCD = "LDIAM", FATEST = "Longest Diameter", FAORRES = diam, FAORRESU = unit, FASTRESC = diam, FASTRESN = suppressWarnings(as.numeric(diam)), FASTRESU = unit, FASTAT = NA_character_ ) ) } out}selected <- diary |> filter(REACTION != "TEMPERATURE")empty <- tibble( DOMAIN = character(), STUDYID = character(), USUBJID = character(), DAY = integer(), REACTION = character(), FAOBJ = character(), FACAT = character(), FASCAT = character(), FATPT = character(), FADTC = character(), ORDER = integer(), FATESTCD = character(), FATEST = character(), FAORRES = character(), FAORRESU = character(), FASTRESC = character(), FASTRESN = double(), FASTRESU = character(), FASTAT = character())fa <- bind_rows( empty, map(seq_len(nrow(selected)), ~ one_row(as.list(selected[.x, ])))) |> arrange(STUDYID, USUBJID, DAY, REACTION, ORDER) |> group_by(STUDYID, USUBJID) |> mutate(FASEQ = row_number()) |> ungroup() |> select( DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT, FATPT, FADTC )dir.create("/app/output", showWarnings = FALSE)write_csv(fa, "/app/output/fa.csv", na = "")solutions/sdtm-fa-reactogenicity-diary/result.py
Edit172 lines# Reference solution for the yamaa benchmark sdtm-fa-reactogenicity-diary (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 pldiary = pl.read_csv("/app/input/diary.csv", infer_schema=False).with_columns( pl.col("DIARYDAY").cast(pl.Int64),)test_order = {"OCCUR": 0, "SEV": 1, "LDIAM": 2}test_name = { "OCCUR": "Occurrence Indicator", "SEV": "Severity/Intensity", "LDIAM": "Longest Diameter",}local_reactions = {"PAIN", "REDNESS", "SWELLING"}def is_local(reaction, catsrc): # Local reactions map to ADMINISTRATION SITE; systemic stay SYSTEMIC. if catsrc == "LOCAL": return True if catsrc == "SYSTEMIC": return False return reaction in local_reactionsrows = []for r in diary.filter(pl.col("REACTION") != "TEMPERATURE").to_dicts(): study, subj = r["STUDYID"], r["USUBJID"] day, tpt, dtc = r["DIARYDAY"], r["TPT"], r["DTC"] reaction = r["REACTION"] completed = r["COMPLETED"] missed = completed != "Y" fascat = "ADMINISTRATION SITE" if is_local(reaction, r["CATSRC"]) else "SYSTEMIC" base = { "DOMAIN": "FA", "STUDYID": study, "USUBJID": subj, "DAY": day, "REACTION": reaction, "FAOBJ": reaction, "FACAT": "REACTOGENICITY", "FASCAT": fascat, "FATPT": tpt, "FADTC": dtc, } if missed: rows.append( { **base, "ORDER": 0, "FATESTCD": "OCCUR", "FATEST": test_name["OCCUR"], "FAORRES": None, "FAORRESU": None, "FASTRESC": None, "FASTRESN": None, "FASTRESU": None, "FASTAT": "NOT DONE", } ) continue occur = r["OCCUR"] if r["OCCUR"] not in (None, "") else None sev = (r["SEV"] if r["SEV"] not in (None, "") else None) if occur == "Y" else "NONE" diam = r["DIAMETER"] if r["DIAMETER"] not in (None, "") else None unit = r["DIAMUNIT"] if r["DIAMUNIT"] not in (None, "") else None rows.append( { **base, "ORDER": 0, "FATESTCD": "OCCUR", "FATEST": test_name["OCCUR"], "FAORRES": occur, "FAORRESU": None, "FASTRESC": occur, "FASTRESN": None, "FASTRESU": None, "FASTAT": None, } ) rows.append( { **base, "ORDER": 1, "FATESTCD": "SEV", "FATEST": test_name["SEV"], "FAORRES": sev, "FAORRESU": None, "FASTRESC": sev, "FASTRESN": None, "FASTRESU": None, "FASTAT": None, } ) if reaction in ("REDNESS", "SWELLING") and occur == "Y": try: num = float(diam) if diam is not None else None except ValueError: num = None rows.append( { **base, "ORDER": 2, "FATESTCD": "LDIAM", "FATEST": test_name["LDIAM"], "FAORRES": diam, "FAORRESU": unit, "FASTRESC": diam, "FASTRESN": num, "FASTRESU": unit, "FASTAT": None, } )fa = ( pl.DataFrame( rows, schema={ "DOMAIN": pl.String, "STUDYID": pl.String, "USUBJID": pl.String, "DAY": pl.Int64, "REACTION": pl.String, "FAOBJ": pl.String, "FACAT": pl.String, "FASCAT": pl.String, "FATPT": pl.String, "FADTC": pl.String, "ORDER": pl.Int64, "FATESTCD": pl.String, "FATEST": pl.String, "FAORRES": pl.String, "FAORRESU": pl.String, "FASTRESC": pl.String, "FASTRESN": pl.Float64, "FASTRESU": pl.String, "FASTAT": pl.String, }, ) .sort(["STUDYID", "USUBJID", "DAY", "REACTION", "ORDER"]) .with_columns( pl.int_range(1, pl.len() + 1).over(["STUDYID", "USUBJID"]).alias("FASEQ") ) .select( "DOMAIN", "STUDYID", "USUBJID", "FASEQ", "FATESTCD", "FATEST", "FAOBJ", "FACAT", "FASCAT", "FAORRES", "FAORRESU", "FASTRESC", "FASTRESN", "FASTRESU", "FASTAT", "FATPT", "FADTC", ))Path("/app/output").mkdir(parents=True, exist_ok=True)fa.write_csv("/app/output/fa.csv")solutions/sdtm-fa-reactogenicity-diary/result.sas
Edit27 lines/* opensas reference solution for the yamaa benchmark sdtm-fa-reactogenicity-diary. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data diary; length STUDYID USUBJID DIARYDAY TPT DTC REACTION CATSRC OCCUR SEV DIAMETER DIAMUNIT COMPLETED $1024; infile "/app/input/diary.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. DIARYDAY : $char1024. TPT : $char1024. DTC : $char1024. REACTION : $char1024. CATSRC : $char1024. OCCUR : $char1024. SEV : $char1024. DIAMETER : $char1024. DIAMUNIT : $char1024. COMPLETED : $char1024.;run;data prepared; set diary; if REACTION ne 'TEMPERATURE'; length DOMAIN $2 FATESTCD FATEST FAOBJ FACAT FASCAT FAORRES FAORRESU FASTRESC FASTRESU FASTAT FATPT FADTC $1024;DOMAIN='FA'; FAOBJ=REACTION; FACAT='REACTOGENICITY'; FASCAT=CATSRC; if CATSRC='LOCAL' then FASCAT='ADMINISTRATION SITE'; FATPT=TPT; FADTC=DTC; DAYORD=input(DIARYDAY,best32.);FAORRESU=''; FASTRESU=''; FASTRESN=.; FASTAT=''; FAORRES=''; FATESTCD='OCCUR'; FATEST='Occurrence Indicator'; TESTORD=1;if COMPLETED='Y' then FAORRES=OCCUR; else FASTAT='NOT DONE'; FASTRESC=FAORRES; output;if COMPLETED='Y' then do;FATESTCD='SEV'; FATEST='Severity/Intensity'; TESTORD=2; FAORRES='NONE'; if OCCUR='Y' then FAORRES=SEV; FASTRESC=FAORRES; output;if REACTION in ('REDNESS','SWELLING') and OCCUR='Y' then do; FATESTCD='LDIAM'; FATEST='Longest Diameter'; TESTORD=3; FASTRESN=input(DIAMETER,best32.); FAORRES=strip(put(FASTRESN,best32.)); FASTRESC=FAORRES; FAORRESU=DIAMUNIT; FASTRESU=DIAMUNIT; output; end; end; run;proc sort data=prepared; by STUDYID USUBJID DAYORD REACTION TESTORD; run;data result; set prepared; by STUDYID USUBJID; retain FASEQ; if first.USUBJID then FASEQ=0; FASEQ+1;run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FASCAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FASTAT, FATPT, FADTC from result;quit;proc export data=final outfile="/app/output/fa.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions