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: build the CM record for each collected medication from the concomitant-medication form, carrying the reported name, indication, dose, frequency, route, and dates as collected, and the form's "taken before study" and "ongoing" boxes as timing references instead of invented dates.
Input: the medication log for two subjects: each medication is one
repeat of the IG.CM item group, and the repeat number becomes CMSEQ.
The dose is collected as free text, and the frequency and route as the
labels printed on the form (Once daily, Twice daily, By mouth). One
subject reports a single medication with complete dates and a single dose;
the other reports a medication started before the study with only year and
month known and the "ongoing" box checked, plus a medication whose dose was
collected as a range.
Variables:
CMTRTis the medication name as reported, kept exactly as written.CMINDCis the indication as reported.CMDOSEis the collected dose when it is a plain number, such as100; empty otherwise.CMDOSTXTis the collected dose when it is not a plain number, such as the range200-400; empty whenCMDOSEcarries the dose.CMDOSUis the unit of the collected dose.CMDOSFRQis the collected frequency label mapped to controlled terminology:Once dailybecomesQDandTwice dailybecomesBID.CMROUTEis the collected route label mapped to controlled terminology:By mouthbecomesORAL.CMSTDTCis the start of the medication as collected, keeping partial dates at their collected precision: year and month alone stay2023-09.CMENDTCis the end of the medication as collected; empty when no end date was collected.CMSTRTPTisBEFOREwhen the "taken before study" box is checked, andCMSTTPTnames the reference point,SCREENING; both empty otherwise.CMENRTPTisONGOINGwhen the "ongoing" box is checked, andCMENTPTnames the reference point,END OF STUDY; both empty otherwise.
Note: a frequency or route label the mappings do not list stops the
run rather than passing through unmapped. An ongoing medication has no end
date, and CMENRTPT records why, so an empty CMENDTC is never left to
stand for "ongoing" on its own.
Inputs
Under review1 source fileinput/odm.csv
Edit29 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMTRT | ASPIRIN |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMINDC | Headache |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDSTXT | 100 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDOSU | mg |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDOSFRQ | Once daily |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMROUTE | By mouth |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMSTDTC | 2024-03-05 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMENDTC | 2024-03-12 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMPRIOR | N |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMONGO | N |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMTRT | LISINOPRIL |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMINDC | Hypertension |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDSTXT | 10 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDOSU | mg |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDOSFRQ | Once daily |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMROUTE | By mouth |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMSTDTC | 2023-09 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMPRIOR | Y |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMONGO | Y |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMTRT | IBUPROFEN |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMINDC | Back pain |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMDSTXT | 200-400 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMDOSU | mg |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMDOSFRQ | Twice daily |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMROUTE | By mouth |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMSTDTC | 2024-04-02 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMENDTC | 2024-04-09 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMPRIOR | N |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMONGO | N |
Expected output
Under review3 expected rowsexpected/cm.csv
Edit3 rows| DOMAIN | STUDYID | USUBJID | CMSEQ | CMTRT | CMINDC | CMDOSE | CMDOSTXT | CMDOSU | CMDOSFRQ | CMROUTE | CMSTDTC | CMENDTC | CMSTRTPT | CMSTTPT | CMENRTPT | CMENTPT |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CM | YAMAA-01 | 1 | ASPIRIN | Headache | 100 | — | mg | QD | ORAL | 2024-03-05 | 2024-03-12 | — | — | — | — | |
| CM | YAMAA-01 | 1 | LISINOPRIL | Hypertension | 10 | — | mg | QD | ORAL | 2023-09 | — | BEFORE | SCREENING | ONGOING | END OF STUDY | |
| CM | YAMAA-01 | 2 | IBUPROFEN | Back pain | — | 200-400 | mg | BID | ORAL | 2024-04-02 | 2024-04-09 | — | — | — | — |
Human review and assessment
| 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 "CM". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from ODM.SubjectKey. | SDTM | 3 | ||||
| CMSEQ | Sequence Number | Num | Collected | Copy value from ODM.ItemGroupRepeatKey. | SDTM | 4 | ||||
| CMTRT | Reported Name of Drug, Med, or Therapy | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 5 | ||||
| CMINDC | Indication | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 6 | ||||
| CMDOSE | Dose per Administration | Num | Derived | Extract the whole match matching ^[0-9]+(\.[0-9]+)?$ from DSTXT; no match → blank. | SDTM | 7 | ||||
| CMDOSTXT | Dose Description | Char | Derived | If DSTXT IS NOT NULL AND CMDOSE IS NULL then "DSTXT"; otherwise blank. | SDTM | 8 | ||||
| CMDOSU | Dose Units | Char | mg | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 9 | |||
| CMDOSFRQ | Dosing Frequency per Interval | Char | Derived | Recode FRQLBL: "Once daily" → "QD", "Twice daily" → "BID"; missing values stay missing; unlisted values are errors. | SDTM | 10 | ||||
| CMROUTE | Route of Administration | Char | Derived | Recode ROUTELBL: "By mouth" → "ORAL"; missing values stay missing; unlisted values are errors. | SDTM | 11 | ||||
| CMSTDTC | Start Date/Time of Medication | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 12 | ||||
| CMENDTC | End Date/Time of Medication | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 13 | ||||
| CMSTRTPT | Start Relative to Reference Time Point | Char | Derived | If PRIOR = 'Y' then "BEFORE"; otherwise blank. | SDTM | 14 | ||||
| CMSTTPT | Start Reference Time Point | Char | Derived | If CMSTRTPT IS NOT NULL then "SCREENING"; otherwise blank. | SDTM | 15 | ||||
| CMENRTPT | End Relative to Reference Time Point | Char | Derived | If ONGO = 'Y' then "ONGOING"; otherwise blank. | SDTM | 16 | ||||
| CMENTPT | End Reference Time Point | Char | Derived | If CMENRTPT IS NOT NULL then "END OF STUDY"; otherwise blank. | SDTM | 17 |
| Template | Include when | CMTRT | CMINDC | DSTXT | CMDOSU | FRQLBL | ROUTELBL | CMSTDTC | CMENDTC | PRIOR | ONGO |
|---|---|---|---|---|---|---|---|---|---|---|---|
| medication | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMTRT' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMINDC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMDSTXT' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMDOSU' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMDOSFRQ' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMROUTE' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMSTDTC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMENDTC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMPRIOR' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMONGO' |
| Variable | Permitted values |
|---|---|
| CMDOSU | mg |
| 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/sdtm-cm-collected-medications/full.md
Edit30 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per medication.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMINDC, CMDOSE, CMDOSTXT, CMDOSU, CMDOSFRQ, CMROUTE, CMSTDTC, CMENDTC, CMSTRTPT, CMSTTPT, CMENRTPT, CMENTPT
- STUDYID is the study OID and USUBJID is the subject key, each as given.
- CMSEQ is the repeat number of the medication for the subject.
- CMDOSE is the collected dose as a number when the dose text is a plain number, such as "100"; CMDOSE has no value otherwise.
- CMDOSTXT is the collected dose text when it is not a plain number, such as the range "200-400"; CMDOSTXT has no value when CMDOSE carries the dose.
- CMDOSFRQ is the controlled term for the collected frequency label: "Once daily" becomes "QD" and "Twice daily" becomes "BID".
- CMROUTE is the controlled term for the collected route label: "By mouth" becomes "ORAL".
- CMSTDTC is the start of the medication as collected, keeping partial dates at their collected precision: a start known only to year and month stays "2023-09".
- CMENDTC is the end of the medication as collected; CMENDTC has no value when no end date was collected.
- CMSTRTPT is "BEFORE" when the "taken before study" box is checked, and CMSTTPT is "SCREENING" then; both have no value otherwise.
- CMENRTPT is "ONGOING" when the "ongoing" box is checked, and CMENTPT is "END OF STUDY" then; both have no value otherwise.
Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.
prompts/sdtm-cm-collected-medications/conventions.md
Edit16 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per medication.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMINDC, CMDOSE, CMDOSTXT, CMDOSU, CMDOSFRQ, CMROUTE, CMSTDTC, CMENDTC, CMSTRTPT, CMSTTPT, CMENRTPT, CMENTPT
- CMSTDTC keeps a partial date at its collected precision: a start known only to year and month stays "2023-09".
- CMSTRTPT is "BEFORE" or has no value, and CMSTTPT is "SCREENING" or has no value.
- CMENRTPT is "ONGOING" or has no value, and CMENTPT is "END OF STUDY" or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.
prompts/sdtm-cm-collected-medications/brief.md
Edit9 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per medication.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMINDC, CMDOSE, CMDOSTXT, CMDOSU, CMDOSFRQ, CMROUTE, CMSTDTC, CMENDTC, CMSTRTPT, CMSTTPT, CMENRTPT, CMENTPT
Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-cm-collected-medications/result.R
Edit76 lines# Reference solution for the yamaa benchmark sdtm-cm-collected-medications (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)library(stringr)odm <- read_csv( "/app/input/odm.csv", col_types = cols(.default = col_character()))# A plain number carries the dose; anything else (like a range 50-75) stays# as text. Frequency and route labels map to controlled terminology.cm <- odm |> filter(ItemGroupOID == "IG.CM") |> pivot_wider( id_cols = c(StudyOID, SubjectKey, ItemGroupRepeatKey), names_from = ItemOID, values_from = Value, values_fn = first ) |> mutate( CMSEQ = as.integer(ItemGroupRepeatKey), DOSE_RAW = str_trim(`IT.CM.CMDSTXT`), DOSE_PLAIN = str_detect(DOSE_RAW, "^\\d+(\\.\\d+)?$"), # BEFORE/SCREENING when the taken-before-study box is checked; ONGOING/ # END OF STUDY when the ongoing box is checked. An ongoing medication # has no end date. DOMAIN = "CM", STUDYID = StudyOID, USUBJID = SubjectKey, CMTRT = na_if(`IT.CM.CMTRT`, ""), CMINDC = na_if(`IT.CM.CMINDC`, ""), CMDOSE = if_else( DOSE_PLAIN, suppressWarnings(as.numeric(DOSE_RAW)), NA_real_, missing = NA_real_ ), CMDOSTXT = if_else( DOSE_PLAIN, NA_character_, na_if(DOSE_RAW, ""), missing = na_if(DOSE_RAW, "") ), CMDOSU = na_if(`IT.CM.CMDOSU`, ""), CMDOSFRQ = case_when( `IT.CM.CMDOSFRQ` == "Once daily" ~ "QD", `IT.CM.CMDOSFRQ` == "Twice daily" ~ "BID", .default = na_if(`IT.CM.CMDOSFRQ`, "") ), CMROUTE = case_when( `IT.CM.CMROUTE` == "By mouth" ~ "ORAL", .default = na_if(`IT.CM.CMROUTE`, "") ), CMSTDTC = na_if(`IT.CM.CMSTDTC`, ""), CMENDTC = if_else( `IT.CM.CMONGO` == "Y", NA_character_, na_if(`IT.CM.CMENDTC`, ""), missing = na_if(`IT.CM.CMENDTC`, "") ), CMSTRTPT = if_else(`IT.CM.CMPRIOR` == "Y", "BEFORE", NA_character_, missing = NA_character_), CMSTTPT = if_else(`IT.CM.CMPRIOR` == "Y", "SCREENING", NA_character_, missing = NA_character_), CMENRTPT = if_else(`IT.CM.CMONGO` == "Y", "ONGOING", NA_character_, missing = NA_character_), CMENTPT = if_else( `IT.CM.CMONGO` == "Y", "END OF STUDY", NA_character_, missing = NA_character_ ) ) |> arrange(USUBJID, CMSEQ) |> select( DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMINDC, CMDOSE, CMDOSTXT, CMDOSU, CMDOSFRQ, CMROUTE, CMSTDTC, CMENDTC, CMSTRTPT, CMSTTPT, CMENRTPT, CMENTPT )dir.create("/app/output", showWarnings = FALSE)write_csv(cm, "/app/output/cm.csv", na = "")solutions/sdtm-cm-collected-medications/result.py
Edit90 lines# Reference solution for the yamaa benchmark sdtm-cm-collected-medications (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 CM dataset from the long-format ODM extract.One record per medication: a medication is one ItemGroupRepeatKey groupwithin a subject. Reads /app/input/odm.csv and writes /app/output/cm.csv."""import csvimport refrom collections import OrderedDictINPUT = "/app/input/odm.csv"OUTPUT = "/app/output/cm.csv"COLUMNS = [ "DOMAIN", "STUDYID", "USUBJID", "CMSEQ", "CMTRT", "CMINDC", "CMDOSE", "CMDOSTXT", "CMDOSU", "CMDOSFRQ", "CMROUTE", "CMSTDTC", "CMENDTC", "CMSTRTPT", "CMSTTPT", "CMENRTPT", "CMENTPT",]FREQ_MAP = {"Once daily": "QD", "Twice daily": "BID"}ROUTE_MAP = {"By mouth": "ORAL"}PLAIN_NUMBER = re.compile(r"^[+-]?(\d+(\.\d*)?|\.\d+)$")def dose_fields(text): """Split collected dose text into (CMDOSE, CMDOSTXT).""" if text is None or text == "": return "", "" if PLAIN_NUMBER.match(text.strip()): value = float(text) number = str(int(value)) if value == int(value) else repr(value) return number, "" return "", textdef main(): with open(INPUT, newline="", encoding="utf-8") as fh: rows = list(csv.DictReader(fh)) # Group item rows into medication records, preserving collected order. records = OrderedDict() for row in rows: key = (row["StudyOID"], row["SubjectKey"], row["ItemGroupRepeatKey"]) record = records.setdefault(key, {}) record[row["ItemOID"]] = row["Value"] out_rows = [] for (study_oid, subject_key, repeat), items in records.items(): cmdose, cmdostxt = dose_fields(items.get("IT.CM.CMDSTXT")) prior = items.get("IT.CM.CMPRIOR") == "Y" ongoing = items.get("IT.CM.CMONGO") == "Y" out_rows.append({ "DOMAIN": "CM", "STUDYID": study_oid, "USUBJID": subject_key, "CMSEQ": repeat, "CMTRT": items.get("IT.CM.CMTRT", ""), "CMINDC": items.get("IT.CM.CMINDC", ""), "CMDOSE": cmdose, "CMDOSTXT": cmdostxt, "CMDOSU": items.get("IT.CM.CMDOSU", ""), "CMDOSFRQ": FREQ_MAP.get(items.get("IT.CM.CMDOSFRQ", ""), items.get("IT.CM.CMDOSFRQ", "")), "CMROUTE": ROUTE_MAP.get(items.get("IT.CM.CMROUTE", ""), items.get("IT.CM.CMROUTE", "")), "CMSTDTC": items.get("IT.CM.CMSTDTC", ""), "CMENDTC": items.get("IT.CM.CMENDTC", ""), "CMSTRTPT": "BEFORE" if prior else "", "CMSTTPT": "SCREENING" if prior else "", "CMENRTPT": "ONGOING" if ongoing else "", "CMENTPT": "END OF STUDY" if ongoing else "", }) with open(OUTPUT, "w", newline="", encoding="utf-8") as fh: writer = csv.DictWriter(fh, fieldnames=COLUMNS) writer.writeheader() writer.writerows(out_rows)if __name__ == "__main__": main()solutions/sdtm-cm-collected-medications/result.sas
Edit42 lines/* opensas reference solution for the yamaa benchmark sdtm-cm-collected-medications. 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 ItemGroupRepeatKey; run;data wide; length CMTRT CMINDC CMDOSU CMDOSFRQ CMROUTE CMSTDTC CMENDTC CMPRIOR CMONGO DOSETEXT $1024; retain CMTRT CMINDC CMDOSU CMDOSFRQ CMROUTE CMSTDTC CMENDTC CMPRIOR CMONGO DOSETEXT; set ordered; where ItemGroupOID='IG.CM'; by StudyOID SubjectKey ItemGroupRepeatKey; if first.ItemGroupRepeatKey then do; CMTRT=''; CMINDC=''; CMDOSU=''; CMDOSFRQ=''; CMROUTE=''; CMSTDTC=''; CMENDTC=''; CMPRIOR=''; CMONGO=''; DOSETEXT=''; end; if ItemOID='IT.CM.CMTRT' then CMTRT=Value; if ItemOID='IT.CM.CMINDC' then CMINDC=Value; if ItemOID='IT.CM.CMDOSU' then CMDOSU=Value; if ItemOID='IT.CM.CMDOSFRQ' then CMDOSFRQ=Value; if ItemOID='IT.CM.CMROUTE' then CMROUTE=Value; if ItemOID='IT.CM.CMSTDTC' then CMSTDTC=Value; if ItemOID='IT.CM.CMENDTC' then CMENDTC=Value; if ItemOID='IT.CM.CMPRIOR' then CMPRIOR=Value; if ItemOID='IT.CM.CMONGO' then CMONGO=Value; if ItemOID='IT.CM.CMDSTXT' then DOSETEXT=Value; if last.ItemGroupRepeatKey then output;run;data result; set wide; length DOMAIN $2 STUDYID USUBJID CMDOSTXT CMSTRTPT CMSTTPT CMENRTPT CMENTPT $1024;DOMAIN='CM'; STUDYID=StudyOID; USUBJID=SubjectKey; CMSEQ=input(ItemGroupRepeatKey,best32.);if prxmatch('/^[+-]?[0-9]+(\.[0-9]+)?$/',strip(DOSETEXT)) then CMDOSE=input(DOSETEXT,best32.); else CMDOSTXT=DOSETEXT;if CMDOSFRQ='Once daily' then CMDOSFRQ='QD'; if CMDOSFRQ='Twice daily' then CMDOSFRQ='BID'; if CMROUTE='By mouth' then CMROUTE='ORAL';if CMPRIOR='Y' then do; CMSTRTPT='BEFORE'; CMSTTPT='SCREENING'; end;if CMONGO='Y' then do; CMENDTC=''; CMENRTPT='ONGOING'; CMENTPT='END OF STUDY'; end; run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMINDC, CMDOSE, CMDOSTXT, CMDOSU, CMDOSFRQ, CMROUTE, CMSTDTC, CMENDTC, CMSTRTPT, CMSTTPT, CMENRTPT, CMENTPT from result;quit;proc export data=final outfile="/app/output/cm.csv" dbms=csv replace; run;
yamaa