Skip to main content

TempoQL: Standardized Temporal Queries for ML in Healthcare

Quickstart

You may first want to create a conda environment to install packages in. Use a Python version between 3.10 and 3.14 for compatibility with TempoQL's dependencies. Then run:

pip install tempo-ql

We have had issues in the past running the JupyterLab widget with virtualenv - therefore we recommend using conda.

Online Examples

There are two examples on Google Colab to show you how TempoQL can be used, both involving the MIMIC-IV dataset but in different data formats:

Example Usage

The demo.ipynb and demo_mimiciv_full.ipynb notebooks in the repo (or the Colab examples above) shows how to use the query language using MIMIC-IV in OMOP format. You can run these to explore how TempoQL enables simple, readable and precise queries on EHR data.

You will need a dataset and a dataset specification to start using TempoQL. Then, you can import TempoQL and use it in your Python code like this:

from tempo_ql import QueryEngine, GenericDataset, formats

db_specification = formats.omop() # also available: mimiciv(), eicu()
sql_connection_string = "bigquery://my-project" # or "duckdb://my_local_db", etc.
dataset = GenericDataset(sql_connection_string, db_specification)

query_engine = QueryEngine(dataset)
# see demo.ipynb for further options, such as configuring a variable store

query_engine.list_data_elements(scope="Measurement") # returns a dataframe of Measurement concepts

query_engine.query("{Temperature Celsius; scope = Measurement}") # retrieves temperature measurements

You can access the interactive query authoring environment in a Jupyter notebook (or VSCode IPython notebook) like so:

query_engine.interactive(file_path=..., api_key=...)

Both file_path and api_key are optional. file_path allows you to read and write queries from a local JSON file, enabling you to persist the queries that you create in the interactive session. api_key can be a Gemini API key allowing you to use LLMs to author, update, explain, and debug queries.

Dev Notes

For local install: clone the repo, cd into it and run pip install -e ..

Running the dev server: Make sure you have NodeJS version 20 or later. cd into the client directory, run npm install, then npm run dev. Then in your call to QueryEngine.interactive, set dev=True. Now when you change the frontend source code, the widget will automatically update.

If the Vite dev server stops working after you make some changes (it may show a JavaScript error like 'failed to load model'), check that any imports of TypeScript types are prefixed with the word type.

Metadata

Release files for tempo-ql 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tempo-ql 0.1.3
File Size Uploaded Provenance Actions
tempo_ql-0.1.3.tar.gz 368.0 kB Without provenance Details for tempo_ql-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tempo-ql 0.1.3
File Interpreter ABI Platform Actions
tempo_ql-0.1.3-py3-none-any.whl Python 3 none any Details for tempo_ql-0.1.3-py3-none-any.whl

Total release size: 554.6 kB

Release files / tempo_ql-0.1.3.tar.gz

Download URL tempo_ql-0.1.3.tar.gz
Size 368.0 kB
Tags Source
SHA-256 checksum
How to use checksums
95b6920fb3adc3db6a9001bdd04cf6c1024317cd8584f52bd0699e5f312d22d8
BLAKE2b-256 checksum
How to use checksums
820ca843c5e6f29e2c1266db5ae9008bdfa5c28d6645ad066bb4c6f32cbfdef5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / tempo_ql-0.1.3-py3-none-any.whl

Download URL tempo_ql-0.1.3-py3-none-any.whl
Size 186.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54c81284c3b3523d4b3cf4bcef833439119783477d8fe46d816caac74224979d
BLAKE2b-256 checksum
How to use checksums
d6ecd07cf5a4260fb2bb617cf8ea6fc323dd5ad80a756c25d1699f37ba00a582
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for tempo-ql 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page