Detecting emergencies in patient portal messages using large language models and knowledge graph-based retrieval-augmented generation
- PMID: 40220286
- PMCID: PMC12089757
- DOI: 10.1093/jamia/ocaf059
Detecting emergencies in patient portal messages using large language models and knowledge graph-based retrieval-augmented generation
Abstract
Objectives: This study aims to develop and evaluate an approach using large language models (LLMs) and a knowledge graph to triage patient messages that need emergency care. The goal is to notify patients when their messages indicate an emergency, guiding them to seek immediate help rather than using the patient portal, to improve patient safety.
Materials and methods: We selected 1020 messages sent to Vanderbilt University Medical Center providers between January 1, 2022 and March 7, 2023. We developed four models to triage these messages for emergencies: (1) Prompt-Only: the patient message was input with a prompt directly into the LLM; (2) Naïve Retrieval Augmented Generation (RAG): provided retrieved information as context to the LLM; (3) RAG from Knowledge Graph with Local Search: a knowledge graph was used to retrieve locally relevant information based on semantic similarities; (4) RAG from Knowledge Graph with Global Search: a knowledge graph was used to retrieve globally relevant information through hierarchical community detection. The knowledge base was a triage book covering 225 protocols.
Results: The RAG from Knowledge Graph model with global search outperformed other models, achieving an accuracy of 0.99, a sensitivity of 0.98, and a specificity of 0.99. It demonstrated significant improvements in triaging emergency messages compared to LLM without RAG and naïve RAG.
Discussion: The traditional LLM without any retrieval mechanism underperformed compared to models with RAG, which aligns with the expected benefits of augmenting LLMs with domain-specific knowledge sources. Our results suggest that providing external knowledge, especially in a structured manner and in community summaries, can improve LLM performance in triaging patient portal messages.
Conclusion: LLMs can effectively assist in triaging emergency patient messages after integrating with a knowledge graph about a nurse triage book. Future research should focus on expanding the knowledge graph and deploying the system to evaluate its impact on patient outcomes.
Keywords: clinical decision support; knowledge graph; large language model; message content; patient portal; patient-doctor communication; primary health care; retrieval augmented generation.
© The Author(s) 2025. Published by Oxford University Press on behalf of the American Medical Informatics Association.
Conflict of interest statement
None declared.
Figures


Similar articles
-
Improving Dietary Supplement Information Retrieval: Development of a Retrieval-Augmented Generation System With Large Language Models.J Med Internet Res. 2025 Mar 19;27:e67677. doi: 10.2196/67677. J Med Internet Res. 2025. PMID: 40106799 Free PMC article.
-
MKRAG: Medical Knowledge Retrieval Augmented Generation for Medical Question Answering.AMIA Annu Symp Proc. 2025 May 22;2024:1011-1020. eCollection 2024. AMIA Annu Symp Proc. 2025. PMID: 40417500 Free PMC article.
-
Use of Retrieval-Augmented Large Language Model for COVID-19 Fact-Checking: Development and Usability Study.J Med Internet Res. 2025 Apr 30;27:e66098. doi: 10.2196/66098. J Med Internet Res. 2025. PMID: 40306628 Free PMC article.
-
Use of SNOMED CT in Large Language Models: Scoping Review.JMIR Med Inform. 2024 Oct 7;12:e62924. doi: 10.2196/62924. JMIR Med Inform. 2024. PMID: 39374057 Free PMC article.
-
[Optimized interaction with Large Language Models : A practical guide to Prompt Engineering and Retrieval-Augmented Generation].Radiologie (Heidelb). 2025 Apr;65(4):235-242. doi: 10.1007/s00117-025-01416-2. Epub 2025 Feb 21. Radiologie (Heidelb). 2025. PMID: 39982460 Review. German.
Cited by
-
Using Generative Artificial Intelligence in Health Economics and Outcomes Research: A Primer on Techniques and Breakthroughs.Pharmacoecon Open. 2025 Jul;9(4):501-517. doi: 10.1007/s41669-025-00580-4. Epub 2025 Apr 29. Pharmacoecon Open. 2025. PMID: 40301283 Free PMC article.
-
Harnessing the power of large language models for clinical tasks and synthesis of scientific literature.J Am Med Inform Assoc. 2025 Jun 1;32(6):983-984. doi: 10.1093/jamia/ocaf071. J Am Med Inform Assoc. 2025. PMID: 40390622 No abstract available.
References
MeSH terms
Grants and funding
LinkOut - more resources
Full Text Sources