First the Rules, Then the Summary: Computing Questionnaire Results in Code Before a Large Language Model Writes Clinical Summaries

Objective: We evaluated whether computing categories and changes in code before a large language model (LLM) generates text prevents factual errors in summaries of questionnaire data, and identified where errors remained. Materials and Methods: For 25 participants in a suicidal crisis recovery study, a rules-based component calculated all severity categories and changes for 12 questionnaires. Gemma 4 31B, Gemini 3 Flash, and GPT-4.1 drafted summaries. These were compared with a generic-prompt baseline and a dismantling condition in which the model derived categories and changes itself. Structured statements were checked automatically and with LLM-assisted verification; narrative sentences were audited; and 5 clinicians rated Gemma summaries. Results: With the rules-based component, substantive structured-section errors (e.g., wrong category or direction) appeared in 0 of 25 Gemma summaries, 0 of 19 Gemini summaries, and 2 of 25 GPT-4.1 summaries, and nearly every statement cited its source (vs 37.5% uncited in the baseline). When the model derived values itself, 5 of 25 summaries had substantive errors, against 0 of 25 in a same-day control (exploratory P=.06). Narratives contradicted the data in 4 of 25 summaries. Clinician ratings averaged 4.80 to 5.47 out of 7, with low agreement; clinicians flagged 2 of the 3 contradictions the audit found. Discussion: The remaining risk is in the narrative paragraph, which synthesizes findings across assessments and is not read by the automated checker. Conclusion: For data with published scoring rules, substantive errors in the structured sections were rare when values were computed in code. The next step is to move narrative interpretation into code.

Authors

Institutions

Publication Details

Journal
PsyArXiv (OSF Preprints)
Published
2026-12-03
DOI
https://doi.org/10.31234/osf.io/79pum
Primary Topic
Artificial Intelligence in Healthcare and Education
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

First the Rules, Then the Summary: Computing Questionnaire Results in Code Before a Large Language Model Writes Clinical Summaries

Yosef Sokol, Marianne S. Goodman, Amar D. Mandavia, Jaclyn C. Kearns et al.
PsyArXiv (OSF Preprints)
Artificial Intelligence in Healthcare and Education
preprint

First the Rules, Then the Summary: Computing Questionnaire Results in Code Before a Large Language Model Writes Clinical Summaries

Yosef Sokol, Marianne S. Goodman, Amar D. Mandavia, Jaclyn C. Kearns, Sarah Andrusier, Nechama Schwartz, Jacob K. Brackett
preprint en

Abstract

Objective: We evaluated whether computing categories and changes in code before a large language model (LLM) generates text prevents factual errors in summaries of questionnaire data, and identified where errors remained. Materials and Methods: For 25 participants in a suicidal crisis recovery study, a rules-based component calculated all severity categories and changes for 12 questionnaires. Gemma 4 31B, Gemini 3 Flash, and GPT-4.1 drafted summaries. These were compared with a generic-prompt baseline and a dismantling condition in which the model derived categories and changes itself. Structured statements were checked automatically and with LLM-assisted verification; narrative sentences were audited; and 5 clinicians rated Gemma summaries. Results: With the rules-based component, substantive structured-section errors (e.g., wrong category or direction) appeared in 0 of 25 Gemma summaries, 0 of 19 Gemini summaries, and 2 of 25 GPT-4.1 summaries, and nearly every statement cited its source (vs 37.5% uncited in the baseline). When the model derived values itself, 5 of 25 summaries had substantive errors, against 0 of 25 in a same-day control (exploratory P=.06). Narratives contradicted the data in 4 of 25 summaries. Clinician ratings averaged 4.80 to 5.47 out of 7, with low agreement; clinicians flagged 2 of the 3 contradictions the audit found. Discussion: The remaining risk is in the narrative paragraph, which synthesizes findings across assessments and is not read by the automated checker. Conclusion: For data with published scoring rules, substantive errors in the structured sections were rare when values were computed in code. The next step is to move narrative interpretation into code.

PsyArXiv (OSF Preprints)
VA Boston Healthcare System (US), James J. Peters VA Medical Center (US)
Artificial Intelligence in Healthcare and Education
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon