Extraction of Medication and Temporal Relation from Clinical Text using Neural Language Models

Hangyu Tu, Lifeng Han, Goran Nenadic

Abstract

The MedTem project introduces a robust pipeline for extracting medication names and their temporal relations from unstructured clinical text. By integrating hybrid deep learning architectures—specifically CNN-BiLSTM for Named Entity Recognition (NER) and BERT-CNN for Relation Extraction (RE)—with rule-based post-processing, the system converts electronic medical records (EMRs) into structured patient timelines. Evaluation on i2b2 benchmarks demonstrates strong performance, with F1 scores of 78.17 for NER and 65.03 for RE, highlighting the potential for automated clinical data extraction.

Introduction

Electronic Medical Records (EMRs) are a critical source of clinical data, yet much of this information is locked in unstructured "free text" notes. For clinicians, understanding a patient’s treatment history requires knowing not just which drugs were prescribed, but when they were taken. Manually extracting these timelines is labor-intensive and error-prone. The MedTem project addresses this by tackling two complex Natural Language Processing (NLP) tasks: Medication Entity Recognition (NER) and Temporal Relation Extraction (RE).

Methodology

The authors developed the MedTem pipeline to automate the extraction of medication information and its chronological context.

NER and Relation Extraction Models

For NER, the system compares BiLSTM-CRF and CNN-BiLSTM architectures. The CNN-BiLSTM model is particularly effective as it uses a Convolutional Neural Network to extract character-level features—useful for identifying medical prefixes and suffixes—before processing context with a Bidirectional Long Short-Term Memory network.

For Relation Extraction, a BERT-CNN architecture was implemented. This model utilizes a pre-trained BERT encoder for deep semantic understanding and a CNN layer to identify specific patterns signaling temporal relationships like BEFORE, AFTER, or OVERLAP.

Post-processing

To convert model outputs into structured data, a rule-based system uses admission and discharge dates as "anchors" to determine a patient's current medication status (e.g., "ON" or "OFF").

The MedTem methodology pipeline for clinical text processing

Datasets and Evaluation

The models were trained and evaluated on two well-known clinical NLP benchmarks: i2b2-2009 (for medication NER) and i2b2-2012 (for temporal relation extraction). These datasets provide annotated discharge summaries and complex temporal links (TLINKs) between events and time expressions.

Key Results

The empirical investigation yielded strong baseline results for clinical automation:

  • NER Performance: The CNN-BiLSTM model achieved a Macro Average F1 score of 78.17 on the i2b2-2009 task.
  • Relation Extraction: The BERT-CNN model reached a Macro Average F1 score of 65.03 on the i2b2-2012 test set.
  • Training Stability: The models showed healthy convergence during training, as seen in the loss and accuracy curves for the BiLSTM-CRF model.
Loss and CRF Accuracy curves for the BiLSTM-CRF model on the i2b2-2009 dataset

Discussion and Future Work

Hybrid architectures proved superior, with character-level features and pre-trained word embeddings (like GloVe) providing significant performance boosts. However, challenges remain, particularly with data imbalance for rare temporal relations and the limitations of rule-based post-processing, which currently succeeds in only about 30% of cases. Future work, dubbed MedTem 2.0, will explore domain-specific models like Med-BERT and prompt-based engineering with larger language models.

Summary updated

BibTeX
@inproceedings{tu2023extraction,
  author = {Hangyu Tu and Lifeng Han and Goran Nenadic},
  title = {{Extraction of Medication and Temporal Relation from Clinical Text using Neural Language Models}},
  booktitle = {IEEE Big Data},
  year = {2023},
  doi = {10.1109/bigdata59044.2023.10386489},
}
Figure