EHRKit: A Python Natural Language Processing Toolkit for Electronic Health Record Texts

Irene Li, Keen You, Xiangru Tang, Yujie Qiao, Lucas Huang, Chiachun Hsieh, Benjamin Rosand, Dragomir R. RadevarXiv 2022 · DOI

Introduction

Electronic Health Records (EHRs) contain a wealth of clinical information, yet much of it remains trapped in unstructured text formats such as clinician notes and discharge summaries. While general-purpose Natural Language Processing (NLP) tools have advanced significantly, their application to the medical domain is often hindered by a fragmented ecosystem of libraries and the specialized nature of clinical terminology. EHRKit is a unified Python-based toolkit designed to bridge this gap, providing a streamlined interface for over 12 clinical NLP tasks and introducing new capabilities for clinical machine translation.

System Architecture

EHRKit is built with a modular design to simplify the workflow for researchers and practitioners. The architecture is divided into two primary components:

  1. MIMIC-III Tasks: This module offers specialized interfaces for the MIMIC-III dataset, a standard in clinical research. It includes utilities for basic statistics, keyword searching, and information extraction tailored to the specific structure of clinical records.
  2. Wrapper Functions: To avoid redundant implementations, EHRKit integrates several high-quality third-party libraries—including Stanza, ScispaCy, and medspaCy—under a consistent API. This allows users to perform complex operations such as Named Entity Recognition (NER), negation detection, and document clustering without needing to master multiple disparate codebases.
Overview of EHRKit modules: MIMIC-III specific tasks and integrated wrapper functions.

In addition to these modules, the toolkit includes newly fine-tuned models for clinical machine translation based on the MarianMT architecture, addressing a historical lack of generative tools in the clinical NLP space.

Experimental Setup and Datasets

The development and evaluation of EHRKit utilized several key datasets:

  • MIMIC-III (NOTEEVENTS): Used for dataset-specific functions and summarization tasks.
  • UFAL Medical Corpus: Employed for training and testing clinical machine translation models across English, Spanish, French, and Romanian.
  • PubMed: Served as a benchmark for biomedical document summarization.
  • MIMIC-CXR: Utilized for radiology-specific summarization evaluation.

Results and Discussion

A central finding of this work is the necessity of domain-specific fine-tuning. While general-purpose models provide a strong baseline, they often struggle with the nuances of medical jargon.

Machine Translation

The authors demonstrated that fine-tuning on the UFAL Medical Corpus led to substantial performance gains. For instance, the English-to-French translation model achieved a 32.40% increase in BLEU score compared to the baseline. On average, fine-tuning resulted in a 16.8% improvement across all tested language pairs.

Improvement in Average BLEU scores for clinical machine translation after fine-tuning on the UFAL Medical Corpus.

Summarization and Usability

In summarization tasks, generalist models like BART showed surprising resilience, achieving the highest ROUGE-1 score (41.70) on the MIMIC-CXR dataset, outperforming domain-specific models like Pegasus. Beyond performance metrics, EHRKit significantly improves usability by consolidating tools for section detection and entity linking, thereby lowering the barrier to entry for clinical researchers.

Conclusion

EHRKit represents a significant software engineering contribution to the clinical NLP community. By unifying disparate tools and addressing the "generation gap" through clinical translation models, it provides a versatile "Swiss Army Knife" for EHR text processing. Future work will focus on expanding language support, integrating multi-document summarization, and exploring medical question-answering capabilities.

Summary updated

BibTeX
@misc{li2022ehrkit,
  author = {Irene Li and Keen You and Xiangru Tang and Yujie Qiao and Lucas Huang and Chiachun Hsieh and Benjamin Rosand and Dragomir R. Radev},
  title = {{EHRKit: A Python Natural Language Processing Toolkit for Electronic Health Record Texts}},
  year = {2022},
  eprint = {2204.06604},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.06604},
}
Figure