There are two ways to build this type of query in i2b2. When you first select this type of query, the following screen will appear, which gives you the option to turn on a tutorial that walks you through how to build this type of query:
The example below will use the ‘Advanced Temporal Query’ build feature. Switch to this feature by clicking on ‘Switch to Advanced Temporal Query’ button on the top right of the workspace.
In this example, we would like to answer the following study question:
How many patients had their first ever inpatient hospitalization after contracting the SARS-CoV-2 virus (COVID-19)?
1. Click on 'Switch to Advanced Temporal Query'
2. The first step is to define the population in which the events in the query should occur. Note that this step is optional and can be left blank. For the purposes of this example, we will define the population as all adults.
3. Click and drag '(adults)>= 18 years old' to Group 1. Our population has now been defined.
4. Next, we will define the events that occur in the query. Click on the dropdown menu and select 'Event 1'
5. We will define our 'Event 1' as contracting the SARS-CoV-2 virus (COVID-19). This inclusion criteria will be defined as patients that have a recorded ICD-10 diagnosis of COVID-19, OR a positive COVID-19 nucleic acid test. First, click and drag the ICD-10 code to Group 1.
6. Click and drag 'ANY Nucleic Acid Lab Test' to Group 1. We have now defined our 'Event 1'
7. Navigate to Event 2. We will define 'Event 2' as an encounter that involved inpatient hospitalization.
8. Click and drag 'Emergency Department Visit Admit To Inpatient' and 'Inpatient Hospital Stay' to Group 1. We have now defined our 'Event 2'.
9. The last step is to define the order in which the events we just defined should occur. This uses logic to define the temporal sequence in which the events should occur. From the drop down menu, select 'Define order or events'.
10. We would like the start of any Event 1 to occur on or before the start of the first ever Event 2. In other words, for a patient to be included in the query, any instance of contracting COVID-19 must have been documented at the same time as or prior to the inpatient hospitalization.
11. Once the logic is defined, click on 'Run Query' to populate the results.