RP38 - Persistent Longitudinal Patient Memory for Large Language Models

Large language models (LLMs) are increasingly capable of integrating complex clinical information, yet their application to longitudinal patient records remains challenging. Patient histories may span decades, comprise heterogeneous data from multiple clinical systems, and continuously grow as new diagnoses, laboratory results, imaging studies, medications, and clinical documents become available. Repeatedly processing the complete history for every LLM interaction is computationally inefficient, while conventional summarisation or retrieval approaches may omit clinically relevant information. Building on the longitudinal FHIR data available in the local digital health platform (SHIP), this project aims to develop a persistent, incrementally updateable patient memory architecture for long-context LLMs. Patient data will be transformed into a deterministic, token-efficient, provenance-preserving representation of the longitudinal clinical record. Exploiting prefix and key-value (KV) caching mechanisms of modern LLM inference engines, previously processed patient context will be retained as reusable model state, allowing newly generated clinical information to be appended and processed incrementally rather than repeatedly recomputing the complete patient history. Different strategies for context representation, cache persistence and hierarchical storage across GPU memory, system memory and persistent storage will be investigated and benchmarked with respect to computational cost, latency, storage requirements and information fidelity. Particular emphasis will be placed on separating immutable source data from derived model state, preserving traceability to the underlying FHIR resources, and preventing propagation of errors from previous model outputs. Expected outcomes include a reference architecture for persistent patient-level LLM memory, methods for efficient incremental processing of longitudinal FHIR records, and quantitative evidence on the trade-offs between context length, caching, retrieval and summarisation. The resulting approach could enable LLM-based clinical applications to reason efficiently over comprehensive patient histories while continuously incorporating newly generated data, providing a foundation for longitudinal clinical AI systems that maintain an up-to-date representation of the patient’s healthcare journey.


Previous