TutorialsΒΆ
The cycquery tool allows you to query EHR databases. It is a Python API that that communicates with postgresql databases. It is a wrapper around the SQLAlchemy ORM and uses SQLAlchemy query objects and functions to build queries.
- MIMIC-III tutorial
- Imports and instantiate
MIMICIIIQuerier
- Example 1. Get all male patients with a mortality outcome.
- Example 2. Get all female patient encounters with diagnoses (
gastroenteritis
in ICD-9 long title). - Example 3. Get potassium lab tests for female patients.
- Example 4. Get AaDO2 carevue chart events for male patients that have a
valuenum
of less than 20.
- Imports and instantiate
- MIMIC-IV tutorial
- Imports and instantiate
MIMICIVQuerier
- Example 1. Get all patient admissions from 2021 or later (approx year of admission)
- Example 2. Get all patient encounters with diagnoses (
schizophrenia
in ICD-10 long title), in the year 2015. - Example 3. Advanced - uses
ConditionRegexMatch
fromcycquery.ops
. Get all patient encounters with diagnoses (ICD-9 long title containsschizophrenia
andchronic
), in the year 2015. - Example 4. Get routine vital signs for patients from year 2015.
- Example 5. Get hemoglobin lab tests for patients from year 2009.
- Example 6. Get radiology reports and filter on keywords
lymphadenopathy
andinfectious
occurring together from year 2009. - Example 7. Get all female patient encounters from year 2015, and return batches partitioned and indexed on
subject_id
. - Example 8. Running a raw SQL string.
- Imports and instantiate
- eICU-CRD tutorial
- Imports and instantiate
EICUQuerier
- Example 1. Get all female patients discharged in 2014 (limit to 100 rows).
- Example 2. Get all patient encounters with diagnoses (
schizophrenia
indiagnosisstring
), discharged in the year 2015. - Example 3. Get potassium lab tests for patients discharged in the year 2014, for all teaching hospitals.
- Example 4. Get glucose medications (substring search) for female patients discharged in 2014.
- Imports and instantiate
- OMOP tutorial
- Imports and instantiate
OMOPQuerier
. - Example 1. Get all patient visits in or after 2010.
- Example 2. Get measurements for all visits in or after 2020.
- Imports and instantiate
OMOPQuerier
. - Example 1. Get all patient visits that ended in a mortality outcome in or after 2010.
- Example 2. Get all measurements for female patient visits with
sepsis
diagnoses, that ended in a mortality outcome.
- Imports and instantiate
- GEMINI tutorial
- Imports and instantiate
GEMINIQuerier
. - Example 1a. Create a table with only one hospitalization per patient, keeping the most recent encounter for each patient. Sort the dataset by
patient_id_hashed
anddischarge_date_time
, and then keep the recent record. - Example 1b. From the above set of encounters, take a subset of patients who were discharged between April 1, 2015 and March 31, 2016.
- Example 1c. From the above set of encounters, get the total number of admissions for each hospital.
- Example 2a. How many sodium tests were placed between Apr 1, 2015 and May 31, 2015 at hospital 101?
- Imports and instantiate