EHRInsight: A Self-correcting Agent-Based Framework for Querying and Visualizing EHR Data
摘要
The advancement of digital health solutions has led to the development and widespread adoption of EHR standards like FHIR and openEHR. However, as these standards and protocols grow, so too do the challenges they pose. Electronic health record system data is deeply nested and highly interconnected, posing a unique and complicated challenge. These challenges frequently require technical skills to address the deeply nested and complex data, that are short in supply. EHRInsight overcomes this challenge by offering the ability to transform complex and intricate electronic health record data into a more usable information. EHRInsight is interlinked and self-correcting across three core modules: the Query-Generation Agent, the Validation Agent, and the Visualization Agent. Using LLMs and Knowledge Graphs, we help generate more usable data in the form of visualizations that help make complex EHR data more intuitive. EHRInsight uses Neo4j Graph Database to semantically represent FHIR data, a Qdrant vector store to keep records of queries and responses as embeddings, and a HAPI FHIR server to store and validate resources. The heart of EHRInsight is that these were connected and integrated via LangGraph to access seamless functionality. The applications is assessed using a collection of bespoke queries designed to test the efficiency of the Query-Generation Agent across dimensions of the Gemini model. In particular, the evaluation of the queries focused on a number of metrics that were aggregated to obtain a macro-averaged score. The results from the experiment have shown that there is considerable improvement in performance in multiple Gemini models. In particular, the Gemini 2.5 flash model shows balance in performance metrics since precision, recall, F1 score and accuracy are 0.88 on average. In contrast, Gemini 2.5 Pro displays almost perfect performance where precision, recall, F1 score and accuracy are 0.99, 0.98 and 0.99 respectively. The results on the Visualization Agent that involve a collection of categorized challenges confirm that the agent provides a correct and meaningful visualization of the EHR data.