Table of Contents
Fetching ...

TempoQL: A Readable, Precise, and Portable Query System for Electronic Health Record Data

Ziyong Ma, Richard D. Boyce, Adam Perer, Venkatesh Sivaraman

TL;DR

TempoQL introduces a Python-based, human-readable query language for EHR data that is portable across data standards such as OMOP, MEDS, MIMIC, and eICU. It combines a Dataset Specification with a data-element grammar and precise temporal transformations to enable robust, reproducible cohort extraction and time-series feature generation for ML4H pipelines. In evaluations, TempoQL achieves performance comparable to traditional SQL systems and benefits from an LLM-assisted authoring workflow that improves generation accuracy and reduces code length, while exposing interpretable intermediate representations. The work demonstrates TempoQL's potential to lower barriers to cross-dataset EHR research by providing portable, readable, and debuggable data-extraction tooling that integrates smoothly with interactive notebooks and future graphical interfaces.

Abstract

Electronic health record (EHR) data is an essential data source for machine learning for health, but researchers and clinicians face steep barriers in extracting and validating EHR data for modeling. Existing tools incur trade-offs between expressivity and usability and are typically specialized to a single data standard, making it difficult to write temporal queries that are ready for modern model-building pipelines and adaptable to new datasets. This paper introduces TempoQL, a Python-based toolkit designed to lower these barriers. TempoQL provides a simple, human-readable language for temporal queries; support for multiple EHR data standards, including OMOP, MEDS, and others; and an interactive notebook-based query interface with optional large language model (LLM) authoring assistance. Through a performance evaluation and two use cases on different datasets, we demonstrate that TempoQL simplifies the creation of cohorts for machine learning while maintaining precision, speed, and reproducibility.

TempoQL: A Readable, Precise, and Portable Query System for Electronic Health Record Data

TL;DR

TempoQL introduces a Python-based, human-readable query language for EHR data that is portable across data standards such as OMOP, MEDS, MIMIC, and eICU. It combines a Dataset Specification with a data-element grammar and precise temporal transformations to enable robust, reproducible cohort extraction and time-series feature generation for ML4H pipelines. In evaluations, TempoQL achieves performance comparable to traditional SQL systems and benefits from an LLM-assisted authoring workflow that improves generation accuracy and reduces code length, while exposing interpretable intermediate representations. The work demonstrates TempoQL's potential to lower barriers to cross-dataset EHR research by providing portable, readable, and debuggable data-extraction tooling that integrates smoothly with interactive notebooks and future graphical interfaces.

Abstract

Electronic health record (EHR) data is an essential data source for machine learning for health, but researchers and clinicians face steep barriers in extracting and validating EHR data for modeling. Existing tools incur trade-offs between expressivity and usability and are typically specialized to a single data standard, making it difficult to write temporal queries that are ready for modern model-building pipelines and adaptable to new datasets. This paper introduces TempoQL, a Python-based toolkit designed to lower these barriers. TempoQL provides a simple, human-readable language for temporal queries; support for multiple EHR data standards, including OMOP, MEDS, and others; and an interactive notebook-based query interface with optional large language model (LLM) authoring assistance. Through a performance evaluation and two use cases on different datasets, we demonstrate that TempoQL simplifies the creation of cohorts for machine learning while maintaining precision, speed, and reproducibility.

Paper Structure

This paper contains 26 sections, 8 figures, 6 tables.

Figures (8)

  • Figure 1: Overview of TempoQL's query authoring process.
  • Figure 2: TempoQL data element queries are computed by retrieving data from Source Tables according to a predefined Dataset Specification. This specification allows for querying multiple underlying data models using a consistent query structure.
  • Figure 3: TempoQL's temporal aggregation syntax consists of an aggregation function, the Events or Intervals to be aggregated, the aggregation bounds at each timestep, and the timestep definition. The query above produces a rolling average of the patient's temperature for each hour in their stay.
  • Figure 4: Difference in execution time between TempoQL and BigQuery SQL across dataset sizes, averaged over three trials.
  • Figure 5: (a) Process for generating parallel datasets for sepsis outcome prediction from three databases with different formats; (b) example of debugging a performance drop in the EHRSHOT dataset for a model predicting time to discharge.
  • ...and 3 more figures