{
  "page_note": "Pronouns about the trial participant were changed to 'the subject' in 2 places in the quoted output; nothing else was edited.",
  "id": "ae-narrative-from-structured-data",
  "title": "Draft a death narrative from SDTM AE, DM and EX rows for one subject",
  "study": {
    "name": "CDISCPILOT01 (CDISC SDTM/ADaM Pilot Project, xanomeline TTS in Alzheimer's disease)",
    "source_url": "https://github.com/cdisc-org/sdtm-adam-pilot-project",
    "licence_note": "Datasets and narratives are CDISC Pilot Project materials, used unmodified and attributed to CDISC under the Terms of Use in the repository README (no modification, no sale of the data, attribution required). The study is a CDISC mock submission with fictional dates. Not legal advice."
  },
  "task": "Turn the SDTM DM, AE and EX rows of one subject who died (01-701-1211) into a CSR-style death narrative, and list what the data cannot support.",
  "time_to_try_minutes": {
    "minutes": 20,
    "label": "estimate, not measured: about 5 to paste and run, 15 to filter one subject's rows from each dataset and check the day arithmetic"
  },
  "good": {
    "input_excerpt": "Source: CDISCPILOT01 SDTM datasets (sdtm_dm.xpt, sdtm_ae.xpt, sdtm_ex.xpt), subject 01-701-1211 only. All rows for this subject are shown. Blank = missing in the dataset.\n\nDM (1 row)\nUSUBJID=01-701-1211; STUDYID=CDISCPILOT01; SITEID=701; COUNTRY=USA; AGE=76; AGEU=YEARS; SEX=F; RACE=WHITE; ETHNIC=NOT HISPANIC OR LATINO\nARM=Xanomeline Low Dose; ACTARM=Xanomeline Low Dose\nRFSTDTC=2012-11-15; RFXSTDTC=2012-11-15; RFXENDTC=2013-01-12; RFENDTC=2013-01-14; RFPENDTC=2013-01-14\nDTHDTC=2013-01-14; DTHFL=Y; RFICDTC=(blank); DMDTC=2012-10-30; DMDY=-16\n\nEX (2 rows)\nEXSEQ|EXTRT|EXDOSE|EXDOSU|EXDOSFRM|EXDOSFRQ|EXROUTE|VISIT|EXSTDTC|EXENDTC|EXSTDY|EXENDY\n1|XANOMELINE|54|mg|PATCH|QD|TRANSDERMAL|BASELINE|2012-11-15|2012-11-28|1|14\n2|XANOMELINE|54|mg|PATCH|QD|TRANSDERMAL|WEEK 2|2012-11-29|2013-01-12|15|59\n\nAE (9 rows; AESTDY and AEENDY are study days of AE start and end)\nAESEQ|AETERM (verbatim)|AEDECOD (preferred term)|AEBODSYS|AESEV|AESER|AEACN|AEREL|AEOUT|AESDTH|AESLIFE|AESHOSP|AESTDTC|AEENDTC|AESTDY|AEENDY\n1|APPLICATION SITE PRURITUS|APPLICATION SITE PRURITUS|GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONS|MILD|N||POSSIBLE|NOT RECOVERED/NOT RESOLVED|N|N|N|2012-11-16||2|\n2|JOINT DISLOCATION|JOINT DISLOCATION|INJURY, POISONING AND PROCEDURAL COMPLICATIONS|MODERATE|N||NONE|RECOVERED/RESOLVED|N|N|N|2012-11-21|2012-11-21|7|7\n3|SHOULDER PAIN|SHOULDER PAIN|MUSCULOSKELETAL AND CONNECTIVE TISSUE DISORDERS|MILD|N||NONE|NOT RECOVERED/NOT RESOLVED|N|N|N|2012-11-21||7|\n4|INCONTINENCE|INCONTINENCE|RENAL AND URINARY DISORDERS|MILD|N||NONE|NOT RECOVERED/NOT RESOLVED|N|N|N|2012-11-22||8|\n5|APPLICATION SITE ERYTHEMA|APPLICATION SITE ERYTHEMA|GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONS|MILD|N||POSSIBLE|NOT RECOVERED/NOT RESOLVED|N|N|N|2012-11-29||15|\n6|SKIN LACERATION|SKIN LACERATION|INJURY, POISONING AND PROCEDURAL COMPLICATIONS|MILD|N||NONE|NOT RECOVERED/NOT RESOLVED|N|N|N|2012-12-09||25|\n7|CONFUSIONAL STATE|CONFUSIONAL STATE|PSYCHIATRIC DISORDERS|MODERATE|N||NONE|NOT RECOVERED/NOT RESOLVED|N|N|N|2013-01-11||58|\n8|DYSPNOEA|DYSPNOEA|RESPIRATORY, THORACIC AND MEDIASTINAL DISORDERS|MODERATE|N||NONE|NOT RECOVERED/NOT RESOLVED|N|N|N|2013-01-11||58|\n9|SUDDEN DEATH|SUDDEN DEATH|GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONS|SEVERE|N||NONE|FATAL|Y|Y|N|2013-01-14|2013-01-14|61|61",
    "input_excerpt_words": 155,
    "prompt": "Write a death narrative for a clinical study report (CSR) from the SDTM rows below, for one subject. Use only facts in the rows. Calculate study days and intervals yourself and show how (e.g. last dose to death). Write in past tense, third person, plain regulatory style, one narrative of 200 to 300 words. Include: demographics and arm, exposure (dose, route, dates), the fatal event with onset, outcome, seriousness and causality as recorded, and relevant other AEs before death (group by timing and say whether ongoing). Where the data are missing, conflict, or look inconsistent, do not guess: after the narrative add a short list headed \"Not in the data / queries\" with each gap or conflict. Do not state cause of death beyond what the data record, and do not invent medical history, concomitant medications, labs, circumstances, or autopsy findings.\n\n[excerpt pasted here]",
    "output": "Narrative: Subject 01-701-1211\n\nSubject 01-701-1211 was a 76-year-old White, not Hispanic or Latino woman enrolled at Site 701 (USA) and assigned to, and treated with, Xanomeline Low Dose. The subject received xanomeline 54 mg transdermal patch once daily from 15 November 2012 (Day 1) to 12 January 2013 (Day 59), a treatment duration of 59 days (Days 1-14 and Days 15-59 per the two exposure records).\n\nDuring Days 2 to 25, the subject had mild or moderate events that were not serious. Application site pruritus (Day 2, possibly related) and application site erythema (Day 15, possibly related) were mild and not recovered at the last record. On Day 7, a moderate joint dislocation (not related) began and resolved the same day, and mild shoulder pain (not related) began and was not recovered. Mild incontinence (Day 8) and mild skin laceration (Day 25) were also not related and not recovered.\n\nOn 11 January 2013 (Day 58), 1 day before the last dose, moderate confusional state and moderate dyspnoea began, both considered not related and not recovered at the last record. Neither event has an end date.\n\nOn 14 January 2013 (Day 61), a severe event of sudden death was recorded, with onset and end on the same day. Its outcome was fatal, causality was recorded as none, and it was flagged as resulting in death and as life-threatening. Death was dated 14 January 2013, which is Day 61 (15 November to 14 January is 60 days, plus 1 for Day 1). Death occurred 2 days after the last dose (14 January minus 12 January) and 3 days after onset of confusional state and dyspnoea (14 January minus 11 January). The data record no cause of death beyond \"sudden death\".\n\nNot in the data / queries\n\n- The serious flag (AESER) is N for sudden death, but death and life-threatening flags are Y. Please confirm seriousness.\n- Action taken with study drug (AEACN) is blank for all AEs, including the fatal event.\n- No cause of death, circumstances, place of death, autopsy, or adjudication is recorded. The investigator's causality is \"none\" with no rationale.\n- The relationship between the confusional state, dyspnoea and the death is not stated. Whether either event was still present at death is not recorded, as the outcome is \"not recovered\" with no end date.\n- Confusional state and dyspnoea began on the same day, and no dose is recorded for 13 or 14 January. It is unclear whether dosing was stopped on 12 January or was simply not recorded.\n- Informed consent date (RFICDTC) is blank. The demographics date was Day -16 (30 October 2012), which checks out.\n- The second exposure record is labelled \"WEEK 2\" but covers Days 15-59. Please confirm the visit labelling.\n- No medical history, concomitant medication, laboratory, vital sign or ECG data were provided, so none are described.",
    "trim_note": "The excerpt is every row for that subject in the three domains (about 155 words, below the 300 to 600 word target, because that is all the data there is). Values are copied unmodified from sdtm_dm.xpt, sdtm_ae.xpt and sdtm_ex.xpt; only the columns a narrative needs were kept and columns empty for this subject were dropped. Medical history, concomitant medication, labs, DS and DD were not supplied.",
    "contamination_note": "The cold run was a separate subagent told to use no tools; it saw only the excerpt and the prompt. The builder chose the subject by listing the three subject IDs with DTHFL=Y in sdtm_dm (AESDTH=Y in sdtm_ae agreed) and took the first, so the subject was not picked to flatter the output. The CDISC narratives.txt (the answer key) was not opened until the cold answer was in hand, but that answer was held in the conversation and not saved to a file before the key was read. The bad run was also a no-tools subagent given only the lazy request. Both agents' no-tools status rests on the instruction, not on a removed tool list. One subject and one run each: this shows the method, not a reliability rate."
  },
  "bad": {
    "input": "write the AE narrative for the subject who died using the SDTM data",
    "output": "I can't write the actual narrative yet. No SDTM datasets were provided in this request, and you asked me not to use tools, so I couldn't look in the project folder. I won't invent subject details for a fatal event. Below is a template with the SDTM source for each field. If you give me the subject's records (DM, AE, EX, DS, DD, LB, VS, CM, MH, as CSV or pasted rows) or the folder path, I'll fill it in.\n\nWhere each field comes from in SDTM\n- Demographics (age, sex, race, country, arm, first and last dose dates): DM (AGE, SEX, RACE, COUNTRY, ARM/ACTARM, RFXSTDTC, RFXENDTC, DTHDTC, DTHFL)\n- Fatal event and its details: AE (AETERM, AEDECOD, AESTDTC, AEENDTC, AESEV, AESER, AESDTH, AEREL, AEACN, AEOUT)\n- Study treatment exposure: EX (EXTRT, EXDOSE, EXSTDTC, EXENDTC)\n- Date and cause of death: DS (DSDECOD = DEATH) and DD (DDTESTCD, DDORRES), plus DM.DTHDTC\n- Relevant history: MH\n- Concomitant medications: CM\n- Labs and vitals around the event: LB, VS, EG\n- Study day: derive from RFSTDTC, with AESTDY and DTHDY if present\n\nNarrative template\n\nSubject [USUBJID] was a [AGE]-year-old [RACE] [SEX] from [COUNTRY], randomized to [ARM] in Study [STUDYID]. Relevant medical history included [MHTERM list, or \"none reported\"]. The subject received first dose of [EXTRT] [EXDOSE EXDOSU] on [date] (Day 1) and last dose on [date] (Day [n]), for a total of [n] doses.\n\nOn [AESTDTC] (Day [AESTDY]), [n] days after the last dose, the subject experienced [AETERM / AEDECOD] of [severity] intensity, assessed by the investigator as [related / not related] to study treatment. [Describe presentation, relevant labs, vitals, and evaluations from LB/VS/EG and any other domains.] Concomitant medications at the time included [CM list]. Action taken with study treatment was [AEACN]. [Treatments given for the event, if recorded.]\n\nThe subject died on [DTHDTC] (Day [DTHDY]). The cause of death was reported as [DDORRES / AEDECOD]. [Autopsy performed: yes / no / not reported.] The investigator considered the event [related / not related] to study treatment. The AE outcome was fatal (AEOUT = FATAL, AESDTH = Y).\n\nChecks I'll run once I have the data\n- DM.DTHDTC, DS death record, and the AE end date agree.\n- AESDTH = Y and AEOUT = FATAL on the fatal AE. Other AEs that were ongoing at death have outcomes recorded sensibly.\n- Study day numbers are calculated correctly, with no Day 0.\n- Causality and action taken match across AE and EX.\n- Nothing in the narrative goes beyond what the datasets record. Where a field is missing I'll say \"not reported\" rather than guess.",
    "what_went_wrong": [
      "No data was pasted, so the assistant had nothing to write from. This model declined to invent a narrative, which is the honest outcome; another tool could fill the gaps with plausible but made-up detail.",
      "What came back is a template with bracketed fields, not a narrative. A statistician still has to do all the work.",
      "'The subject who died' and 'the SDTM data' identify nothing: no subject, no file, no domains. The reply guessed at DS, DD, LB, VS, CM and MH, which are not in the files available here.",
      "The template asks for total number of doses, treatments given and autopsy, which no supplied domain contains, and has no instruction to flag conflicts such as AESER versus AESDTH."
    ]
  },
  "what_changed": [
    "Input: 'the SDTM data' became the actual rows (DM, EX and all 9 AE rows) for one named subject, with blanks marked as blank.",
    "Output: a bracketed template became a finished narrative of about 280 words with days and intervals computed.",
    "The prompt asked for a 'Not in the data / queries' list, so gaps and a data conflict (AESER=N with AESDTH=Y) were raised instead of smoothed over.",
    "The prompt banned invented history, medication, labs and cause of death, and the cold run kept to that.",
    "Length and structure were fixed (one narrative, 200 to 300 words, grouped by timing), so the output could be compared to the CDISC narrative."
  ],
  "check_before_trust": [
    "Check every date and study day against the raw rows yourself (here the 59-day exposure, Day 58 and Day 61 were all correct).",
    "Confirm that seriousness, causality and outcome are quoted as recorded and that any conflict between flags is queried, not resolved by the writer.",
    "Look for facts that are not in the rows you pasted (history, concomitant medication, cause of death). Any such sentence came from the model, not the data.",
    "The CDISC narrative contains facts from other sources (dementia diagnosis year, diabetes, 'no action taken'). Do not expect a data-only narrative to match it; decide which sources a narrative must use.",
    "Filter by USUBJID and paste unmodified rows; on a real study, follow your data policy and remove direct identifiers before using any outside tool.",
    "A narrative is a regulated document. A named medical writer or clinician must review it, and the sponsor's template and style guide override this prompt."
  ],
  "verification": {
    "answer_key": "narratives.txt, second paragraph (CDISC pilot death narratives file). Opened only after the cold answer was produced.",
    "rows": [
      {
        "output": "good",
        "claim": "76-year-old woman, White, not Hispanic or Latino, Site 701, USA, Xanomeline Low Dose",
        "verdict": "Correct",
        "cite": "sdtm_dm.xpt AGE, SEX, RACE, ETHNIC, SITEID, COUNTRY, ACTARM; narratives.txt para 2 (76-year-old woman, low dose)"
      },
      {
        "output": "good",
        "claim": "Xanomeline 54 mg patch QD, first dose 15 Nov 2012 (Day 1), last dose 12 Jan 2013 (Day 59), 59 days",
        "verdict": "Correct",
        "cite": "sdtm_ex.xpt rows 1 and 2 (EXSTDTC 2012-11-15, EXENDY 59); narratives.txt gives start 15 November 2012"
      },
      {
        "output": "good",
        "claim": "Eight earlier AEs, all non-serious, with listed terms, severities, study days, relatedness and outcomes",
        "verdict": "Correct",
        "cite": "sdtm_ae.xpt AESEQ 1 to 8, checked row by row; narratives.txt para 2 'Eight other adverse events ... none ... serious'"
      },
      {
        "output": "good",
        "claim": "Confusional state and dyspnoea began 11 Jan 2013 (Day 58), 1 day before last dose, both ongoing",
        "verdict": "Correct",
        "cite": "sdtm_ae.xpt AESEQ 7 and 8"
      },
      {
        "output": "good",
        "claim": "Sudden death 14 Jan 2013, Day 61, severe, fatal, causality NONE (not related)",
        "verdict": "Correct",
        "cite": "sdtm_ae.xpt AESEQ 9 (AEREL NONE, AEOUT FATAL); narratives.txt: 'sudden death on 14 January 2013 ... unrelated to study medication'"
      },
      {
        "output": "good",
        "claim": "Day arithmetic: death Day 61, 2 days after last dose, 3 days after onset of confusion and dyspnoea",
        "verdict": "Correct",
        "cite": "Recomputed from the dates in Python; AESTDY 61 in sdtm_ae.xpt"
      },
      {
        "output": "good",
        "claim": "Fatal event flagged both death (AESDTH=Y) and life-threatening (AESLIFE=Y)",
        "verdict": "Correct",
        "cite": "sdtm_ae.xpt AESEQ 9"
      },
      {
        "output": "good",
        "claim": "Query: AESER=N on the fatal event conflicts with AESDTH=Y",
        "verdict": "Correct",
        "cite": "sdtm_ae.xpt AESEQ 9. A real conflict in the data. The answer key does not mention it"
      },
      {
        "output": "good",
        "claim": "Query: AEACN is blank on every AE including the fatal one",
        "verdict": "Correct",
        "cite": "sdtm_ae.xpt (AEACN missing in all 9 rows)"
      },
      {
        "output": "good",
        "claim": "Answer key states 'no action was taken and study medication was not discontinued prior to death'",
        "verdict": "Not in source",
        "cite": "Cannot be derived from AE (AEACN blank). Last dose 12 Jan is consistent but not proof. The cold run correctly did not claim it and flagged it as unknown"
      },
      {
        "output": "good",
        "claim": "Answer key states Alzheimer's dementia diagnosed 2010 and mild non-insulin dependent diabetes",
        "verdict": "Not in source",
        "cite": "Needs MH or similar domains; not among the three supplied. The cold run correctly said no history was provided and wrote none"
      },
      {
        "output": "good",
        "claim": "Query: second exposure record labelled WEEK 2 though it covers Days 15 to 59",
        "verdict": "False gap",
        "cite": "sdtm_ex.xpt VISIT. The label is the visit at which the record was captured, not the span. A reviewer would not query this"
      },
      {
        "output": "good",
        "claim": "Query: informed consent date RFICDTC is blank",
        "verdict": "Correct",
        "cite": "sdtm_dm.xpt RFICDTC blank. True but not relevant to the death narrative"
      },
      {
        "output": "good",
        "claim": "Query: no cause of death, autopsy or circumstances recorded",
        "verdict": "Correct",
        "cite": "No DS or DD data supplied; narratives.txt also gives no cause beyond 'sudden death'"
      },
      {
        "output": "good",
        "claim": "Query: relationship of confusion and dyspnoea to death is not stated",
        "verdict": "Partly",
        "cite": "True of the three domains. The answer key states the investigator found none of the eight contributed; that sentence comes from outside the supplied rows"
      }
    ],
    "errors_found": [
      "No factual errors in the cold narrative against sdtm_dm, sdtm_ae and sdtm_ex (all dates, study days, terms, severities and relatedness checked row by row; day arithmetic recomputed).",
      "One low-value query (WEEK 2 visit label) is a false gap; the consent-date query is true but irrelevant to a death narrative.",
      "The narrative is about 2.7 times longer than the CDISC one (about 105 words) because it lists all eight earlier AEs; a medical writer may want to shorten that.",
      "Facts in the CDISC narrative that the cold run could not have (dementia diagnosis year 2010, mild diabetes, no action taken, other AEs judged not to contribute) are absent from it; it flagged the absence rather than guessing."
    ],
    "summary": "Cold run on three domains for one subject: every checkable fact matched the data, and the flagged conflict (AESER=N versus AESDTH=Y) is real. It cannot match the published narrative's history sentences, which need other domains. One of eight queries was a false gap. Contamination: the builder chose the subject by listing the three subject IDs with DTHFL=Y in sdtm_dm (AESDTH=Y in sdtm_ae agreed) and took the first; narratives.txt was not opened until the cold answer was in hand, but that answer was held in the conversation, not saved to a file, before the key was read. The cold run was a separate no-tools subagent that saw only the excerpt and prompt. The bad run was also a no-tools subagent given only the lazy request. One subject, one run each: this shows the method, not a reliability rate."
  },
  "run": {
    "generated_by": "Claude (Anthropic), run as a subagent on 2026-10-20",
    "not_tested_in": "Microsoft 365 Copilot"
  }
}