Leveraging Locally Deployed LLMs for Structuring Discharge Letters to a HF Patients Database

Georgios Nikolaos Tsakonas1, Athanasios Samaras2, Alexandra Kosvyra3, Georgios Giannakoulas4, Ioanna Chouvarda5
1Lab of Computing, Medical Informatics and Biomedical - Imaging Technologies, School of Medicine, Aristotle University of Thessaloniki, 2Second Department of Cardiology, Aristotle University of Thessaloniki, General Hospital ‘Hippokration', 3Lab of Computing, Medical Informatics and Biomedical - Imaging Technologies, School of Medicine, AUTh, 4First Department of Cardiology, Aristotle University of Thessaloniki, AHEPA University Hospital, 5Aristotle University of Thessaloniki


Abstract

Clinical reports contain valuable health information, yet their unstructured nature limits the efficacy of data-driven models. Large Language Models (LLMs) offer a way to automatically extract and reformat this text into usable structured, machine-readable formats. Due to privacy issues with cloud services, secure, locally deployable alternatives are therefore necessary. This study proposes an end-to-end solution using LLMs focused on converting Heart Failure (HF) clinical reports into structured data formats while preserving patient privacy.

The dataset included over 20,000 hospitalization discharge letters (in Greek) from HF patients. A team of trained clinicians manually reviewed the discharge letters and extracted all relevant clinical information to be used as ground truth. More than 3,250 unique features were created, like symptoms, medications, HFpEF related information, etc. To automate the process of transforming unstructured to structured data, a 3-step pipeline was established, and is running in a secure in-house system and is using locally deployed open source LLMs.

The pre-processing step translates the discharge letters from Greek to English, due to the limited Greek language support by open-source LLMs. The de-identification step uses the language model to remove private information, such as names, dates, etc. Finally, using specific templates provided, the model extracts and stores information in machine-readable structured JSON format.

The de-identification process achieved around 98% accuracy in masking all sensitive information, while preserving the integrity of the clinical content. During the information extraction process, the generated JSON output followed the predefined schemas around each of the clinical categories. Straightforward categories, like medication, reached 90% accuracy. In more complex categories, like medical history, results are very promising, maintaining semantic consistency, while there is space for improvements.

This study validates that its approach supports real-world clinical use on large scales. Its modular design allows for extensibility to additional report types and extraction tasks.