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.
