<p>This section describes the layout and contents of this view.</p>
<p> </p>
<p> </p>
<h3><aname="qtLayout"id="qtLayout"></a>Layout of the Query Tool View</h3>
<p>The <b>Query Tool view</b> is used to define and run a "select query" that will retrieve information from the database associated to the i2b2 Web Client.
<p>The name of a query will be assigned when it is run and will display in the <b>Query Name</b> field.
</p>
<p> </p>
<p>The only time a query name will appear prior to running the query is when you drag a <b>previous query</b> from either the<b> Previous Query</b> or <b>Workplace views</b> and drop it into the Query Name field.
<p>A panel is the section of the Query Tool view that contains information about a group of concepts. The panel can be broken down into the following sections.
<p>The content in the information box will change depending on whether or not a term is listed in the panel / group.
</p>
<p> </p>
<ol>
<li>No term(s) listed</li>
<ul>
<li>The message will appear as "<b>drop a term on here</b>"</li>
<li>The color of the box will be yellow</li>
</ul>
<p> </p>
<p> </p>
<li>Term(s) listed</li>
<ul>
<li>The message will appear as "<b>one or more of these</b>"</li>
<li>The color of the box will be green</li>
<li>An additional information box will appear between panels</li>
</ul>
</ol>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
Once you add an item to a panel, an additional information box will appear between the two panels containing the text "AND". This is to indicate that each panel will be joined with an AND operator when the SQL query is created.
<p>On the toolbar for the Query Tool there is a single button for running and canceling a query. Depending on the circumstances defined below the label on this button and its associated action will change to one of the following: (1) <b>Run Query</b> or (2) <b>Cancel Query</b>.
<p>Once you start running a query, the label will change to <b>Cancel Query</b>. Clicking on the button when it says <b>Cancel Query</b> will cancel the query and free up the Query Tool / Web client so that you can continue to do other things.
</p>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
Clicking on Cancel Query in the Query Tool will only cancel the web client piece of the process. The server side will continue to run.
<p>The <b>Clear button</b> will reset the view to the default; this includes deleting the concepts listed in the panel and removing any constraint that have been defined.
<h3><aname="qtStatusView"id="qtStatusView"></a>Query Status View</h3>
<p>The <b>Query Status view</b> is located below the <i>Query Tool view</i> and contains information regarding the status of a query that is either running or has just finished as well as the results of a previous query.
<p>Once the query has finished, the number of patients meeting the search criteria will appear in this view. You will also see the length of time it took to retrieve the requested information. This is a display only view.
<p>Users can define how long to wait before a query will time out. This setting is defined in the <i>Query Tool Options</i>, which can be accessed by clicking on the <b>Show Options button</b><spanstyle="color:#CCCCCC">(<imgsrc="images/options.png"alt="options"/>)</span>.
<p>The default setting is 180 seconds, which means the web client will wait for a response from the server for 180 seconds. Once it reaches that time it will display a message saying the query has timed out and will continue to run in the background.
</p>
<p> </p>
<p> </p>
<p> </p>
<h2><aname="qtCreateQuery"id="qtCreateQuery"></a>Creating a Query</h2>
<p>This section describes the process of adding items to the query tool, "AND" / "OR" operators and setting constraints.
<p>In order to create your query, you will need to define what information will be retrieved from the databases. Selected items from other i2b2 Web Client views can be dragged and dropped (copied) into the <b>Query Tool view</b>.
</p>
<p> </p>
<ol>
<li>Concepts</li>
<p><b>Concepts</b><spanstyle="color:#CCCCCC">(<imgsrc="images/leaf.png"alt="leaf"/>)</span> can be defined as terms, results, providers, etc. They can be added as a group (folder <spanstyle="color:#CCCCCC">(<imgsrc="images/folder.png"alt="folder"/>)</span>) or individually by dragging the item(s) from <b>Navigate Terms</b>, <b>Find Terms</b>, and <b>Workplace views</b>.
</p>
<p> </p>
<p> </p>
<li>Modifiers</li>
<p><b>Modifiers</b><spanstyle="color:#CCCCCC">(<imgsrc="images/modifier.png"alt="leaf"/>)</span> are associated with a concept or group of concepts. They can be added as a group ( modifier folder <spanstyle="color:#CCCCCC">(<imgsrc="images/modifierFolder.png"alt="folder"/>)</span>) or individually by dragging the item(s) from <b>Navigate Terms</b>, <b>Find Terms</b>, and <b>Workplace views</b>.
</p>
<p> </p>
<p> </p>
<li>Previous Query</li>
<p>A new query can be created from one that has already been run by dragging the <b>previous query </b><spanstyle="color:#CCCCCC">(<imgsrc="images/prevQuery.jpg"alt="prevQuery"/>)</span> from <b>Previous Query</b> and <b>Workplace</b> views.
</p>
<p> </p>
<p> </p>
<li>Patient Set</li>
<p>A <b>patient set</b><spanstyle="color:#CCCCCC">(<imgsrc="images/ptSet.png"alt="leaf"/>)</span> can be can be used in a query by dragging the patient set from <b>Previous Query</b> and <b>Workplace</b> views . When you run the query it will use the patient set to query against<b></b>.
</p>
<p> </p>
<p> </p>
<li>Encounter Set</li>
<p> An <b>encounter set</b><spanstyle="color:#CCCCCC">(<imgsrc="images/ptSet.png"alt="leaf"/>)</span> can be used in a query by dragging the patient set from <b>Previous Query</b><b></b> and <b>Workplace views</b>. When you run the query it will use the encounter set to query against.
<p>There are two operators, known as <b>SQL Logical Operators</b>, which are necessary when running a query that has more than one item. These operators provide a way to specify exactly what you want to retrieve. The operators are the '<b>AND</b>' and '<b>OR</b>' operators.
</p>
<p> </p>
<p> </p>
<tableid=important>
<tr>
<td>
<pclass=ImportantHeading>IMPORTANT: </p>
<pclass=ImportantParagraph>
The query tool knows which operator to use based on the panels used when defining the query. It is important to verify you are setting up your query correctly as each operator will return different results.
<p>The <b>AND operator</b> returns a record if both the first condition <i>and</i> the second conditions are true.
</p>
<p> </p>
<p>The query tool uses the AND operator when concepts are listed in different panels.</p>
<p> </p>
<p><i>Example:</i></p>
<p> </p>
<p><b>WHAT:</b> Return only those patients who have Acute Myocardial Infarction <b>AND</b> Angina Pectoris.
</p>
<p> </p>
<p><b>HOW:</b> In the query tool add the concept Acute Myocardial Infarction to <i><b>Group 1</b></i> and then add the concept Angina Pectoris to <i><b>Group 2</b></i>.
</p>
<p> </p>
<p><b>RESULT:</b> The population is limited by requiring the patients fulfill both requirements.</p>
<h5><aname="qtAddConceptFromNt"id="qtAddConceptFromNt"></a>Add Concept From Navigate Terms View</h5>
<p> </p>
<ol>
<li>In the <b>Navigate Terms view</b>, expand the folder(s) that contains the concept or grouping of concepts you want to add.
</li>
<li>Highlight the <b>concept</b><spanstyle="color:#CCCCCC">(<imgsrc="images/leaf.png"alt="leaf"/>)</span> or <b>folder</b><spanstyle="color:#CCCCCC">(<imgsrc="images/folder.png"alt="Folder"/>)</span> by clicking on its name.
</li>
<li>While holding the <i>left mouse button</i> down, drag the item over to the <b>Query Tool view</b></li>
<li>Drop the item into the <b>panel</b> labeled <b>Group 1</b>.</li>
For detailed information on how to search for terms, please see the i2b2 Find Terms help.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<h5><aname="qtAddConceptFromFt"id="qtAddConceptFromFt"></a>Add Concept From Find Terms View</h5>
<p> </p>
<ol>
<li>In the <b>Find Terms view</b>, search for the item(s) you want to add.</li>
<li>Highlight the <b>concept</b><spanstyle="color:#CCCCCC">(<imgsrc="images/leaf.png"alt="leaf"/>)</span> or <b>folder</b><spanstyle="color:#CCCCCC">(<imgsrc="images/folder.png"alt="Folder"/>)</span> by clicking on its name.
</li>
<li>While holding the <i>left mouse button</i> down, drag the item over to the <b>Query Tool view</b></li>
<li>Drop the item into the <b>panel</b> labeled <b>Group 1</b>.</li>
<p>Information in the <b>workplace</b> is related to the most common concepts, modifiers, and queries that an individual uses and in essence becomes their personal workplace.
<h5><aname="qtAddConceptFromWp"id="qtAddConceptFromWp"></a>Add Concept From Workplace View</h5>
<p> </p>
<ol>
<li>In the <b>Workplace view</b>, expand the folder(s) that contains the concept or grouping of concepts you want to add.
</li>
<li>Highlight the <b>concept</b><spanstyle="color:#CCCCCC">(<imgsrc="images/leaf.png"alt="leaf"/>)</span> or <b>folder</b><spanstyle="color:#CCCCCC">(<imgsrc="images/folder.png"alt="Folder"/>)</span> by clicking on its name.
</li>
<li>While holding the <i>left mouse button</i> down, drag the item over to the <b>Query Tool view</b></li>
<li>Drop the item into the <b>panel</b> labeled <b>Group 1</b>.</li>
<h5><aname="qtAddModFromNt"id="qtAddModFromNt"></a>Add Modifier From Navigate Terms View</h5>
<p> </p>
<ol>
<li>In the <b>Navigate Terms view</b>, expand the folder(s) that contains the modifier or grouping of grouping of modifiers you want to add.
</li>
<li>Highlight the <b>modifier</b><spanstyle="color:#CCCCCC">(<imgsrc="images/modifier.png"alt="modifier"/>)</span> or <b>modifier folder</b><spanstyle="color:#CCCCCC">(<imgsrc="images/modifierFolder.png"alt="Folder"/>)</span> by clicking on its name.
</li>
<li>While holding the <i>left mouse button</i> down, drag the item over to the <b>Query Tool view</b></li>
<li>Drop the item into the <b>panel</b> labeled <b>Group 1</b>.</li>
For detailed information on how to search for terms and modifiers, please see the i2b2 Find Terms help.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<h5><aname="qtAddModFromFt"id="qtAddModFromFt"></a>Add Modifier From Find Terms View</h5>
<p> </p>
<ol>
<li>In the <b>Find Terms view</b>, search for the term(s) and modifier you want to add.</li>
<li>Highlight the <b>modifier</b><spanstyle="color:#CCCCCC">(<imgsrc="images/modifier.png"alt="modifier"/>)</span> or <b>modifier folder</b><spanstyle="color:#CCCCCC">(<imgsrc="images/modifierFolder.png"alt="Folder"/>)</span> by clicking on its name.
</li>
<li>While holding the <i>left mouse button</i> down, drag the item over to the <b>Query Tool view</b></li>
<li>Drop the item into the <b>panel</b> labeled <b>Group 1</b>.</li>
<p>Information in the <b>workplace</b> is related to the most common concepts, modifiers, and queries that an individual uses and in essence becomes their personal workplace.
<h5><aname="qtAddModFromWp"id="qtAddModFromWp"></a>Add Modifier From Workplace View</h5>
<p> </p>
<ol>
<li>In the <b>Workplace view</b>, expand the folder(s) that contains the modifier or grouping of modifiers you want to add.
</li>
<li>Highlight the <b>modifier</b><spanstyle="color:#CCCCCC">(<imgsrc="images/modifier.png"alt="modifier"/>)</span> or <b>modifier folder</b><spanstyle="color:#CCCCCC">(<imgsrc="images/modifierFolder.png"alt="Folder"/>)</span> by clicking on its name.
</li>
<li>While holding the <i>left mouse button</i> down, drag the item over to the <b>Query Tool view</b></li>
<li>Drop the item into the <b>panel</b> labeled <b>Group 1</b>.</li>
<p>A <b>previous query</b> can be used to run a new query or as an item within a query (query-in-query). To add a previous query to the <i>Query Tool view</i> simply drag the query name from one of the following views.
</p>
<p> </p>
<ul>
<li> Previous Query view</li>
<li> Workplace view</li>
</ul>
<p> </p>
<p>Within the Query Tool view, the previous query can be added to one of the following two locations.</p>
<td>The items and constraints from the original query will be used to create a new query. This information can be edited to make a new query or can be used as is to run the query again.
</td>
</tr>
<tr>
<td><b>Panel (Group)</b></td>
<td>Used within a new query (query-in-query). The information associated with the previous query can not be edited. Add additional search criteria (items) to be used in the new query.
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p>How to add a previous query from each of the views listed above is explained in the next few sections.
<h5><aname="qtAddPqFromPq"id="qtAddPqFromPq"></a>Add Previous Query From Previous Query View (New Query)</h5>
<ol>
<li>In the <b>Previous Query view</b> highlight the <b>previous query</b><spanstyle="color:#CCCCCC">(<imgsrc="images/prevQuery.jpg"alt="prevQuery"/>)</span> by clicking on its name.
</li>
<li>While holding the <i>left mouse button</i> down, drag the item over to the <b>Query Tool view</b></li>
<li>Drop the previous query into the<strong></strong><b>Query Name</b>.</li>
<li>The item(s) associated with the previous query will display in the appropriate group(s), the name of the query will appear at <b>Query Name</b>, and any constraints that were defined when the original query was run will now default with the new query.
When you run the query it will receive a new name. This is to distinguish the first previous query from the second.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<h5><aname="qtAddPqFromPqPanel"id="qtAddPqFromPqPanel"></a>Add Previous Query From Previous Query View (Query-in-Query)</h5>
<ol>
<li>In the <b>Previous Query view</b> highlight the <b>previous query</b><spanstyle="color:#CCCCCC">(<imgsrc="images/prevQuery.jpg"alt="prevQuery"/>)</span> by clicking on its name.
</li>
<li>While holding the <i>left mouse button</i> down, drag the item over to the <b>Query Tool view</b></li>
<li>Drop the previous query into the<strong></strong><b>panel</b> labeled <b>Group 1</b>.</li>
<p>Information in the workplace is related to the most common concepts, modifiers, and queries that an individual uses and in essence becomes their personal workplace.
<li>The item(s) associated with the previous query will display in the appropriate group(s), the name of the query will appear at <b>Query Name</b>, and any constraints that were defined when the original query was run will now default with the new query.
<h5><aname="qtAddPtListFromPq"id="qtAddPtListFromPq"></a>Add Patient Set From Previous Query View</h5>
<ol>
<li>In the <b>Previous Query view</b> click on the plus sign <spanstyle="color:#CCCCCC">(<imgsrc="images/plusSign.png"alt="plusSign"/>)</span> next to the name of the previous query that contains the patient set.
</li>
<li>Click on the plus sign <spanstyle="color:#CCCCCC">(<imgsrc="images/plusSign.png"alt="plusSign"/>)</span> next to the results folder.
</li>
<li>Highlight the <b>Patient set</b><spanstyle="color:#CCCCCC">(<imgsrc="images/ptSet.png"alt="ptSet"/>)</span> by clicking on its name.
</li>
<li>While holding the <i>left mouse button</i> down, drag the item over to the <b>Query Tool view</b></li>
<li>Drop the item into the<strong></strong><b>panel</b> labeled <b>Group 1</b>.</li>
<p>Information in the workplace is related to the most common concepts, modifiers, and queries that an individual uses and in essence becomes their personal workplace.
<h5><aname="qtAddEncFromPq"id="qtAddEncFromPq"></a>Add Encounter Set From Previous Query View</h5>
<ol>
<li>In the <b>Previous Query view</b> click on the plus sign <spanstyle="color:#CCCCCC">(<imgsrc="images/plusSign.png"alt="plusSign"/>)</span> next to the name of the previous query that contains the patient set.
</li>
<li>Click on the plus sign <spanstyle="color:#CCCCCC">(<imgsrc="images/plusSign.png"alt="plusSign"/>)</span> next to the results folder.
</li>
<li>Highlight the <b>Encounter set</b><spanstyle="color:#CCCCCC">(<imgsrc="images/ptSet.png"alt="ptSet"/>)</span> by clicking on its name.
</li>
<li>While holding the <i>left mouse button</i> down, drag the item over to the <b>Query Tool view</b></li>
<li>Drop the item into the<strong></strong><b>panel</b> labeled <b>Group 1</b>.</li>
<p>Information in the workplace is related to the most common concepts, modifiers, and queries that an individual uses and in essence becomes their personal workplace.
<p>On the toolbar at the bottom of the view, there are additional navigational buttons that will become active when more than three panels are being used.
<p>There are three options for removing a concept from the <b>Query Tool view</b>. Users can (1) reset all the groups, (2) clear all items in a panel, or (3) delete an individual item from the group.
<li>All the groups will be reset, the temporal constraint will return to the default setting, and the query name will be removed (if one exists).
</li>
</ol>
<p> </p>
<p> </p>
<tableid=warning>
<tr>
<td>
<pclass=WarningHeading>WARNING: </p>
<pclass=WarningParagraph>
Once you click on the clear button, all items in every group; and the constraints will be removed, therefore you need to make sure you want to delete ALL items.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<h4><aname="qtClearPanel"id="qtClearPanel"></a>Clear Items in a Panel / Group</h4>
<p> </p>
<ol>
<li>Click on the <b>Delete button <spanstyle="color:#CCCCCC">(<imgsrc="images/buttonDelete.png"alt="delete"/>)</span></b> located in the top right corner of the panel (next to the Group name)<i></i>.
</li>
<li>The group will be reset.</li>
</ol>
<p> </p>
<p> </p>
<tableid=warning>
<tr>
<td>
<pclass=WarningHeading>WARNING: </p>
<pclass=WarningParagraph>
Once you click on the delete button, all items in every group; and the constraints will be removed, therefore you need to make sure you want to delete ALL items.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<h4><aname="qtDeleteItem"id="qtDeleteItem"></a>Delete Single Item</h4>
<p> </p>
<ol>
<li>Using the <i>right mouse button</i>, click on the name of the item to be removed.</li>
<p><b>Constraints</b> are used to narrow down the search criteria to a particular time frame, number of occurrences or a specific value or range of values. In i2b2, there are several types of constraints that can be defined in the Query Tool view.
<td>Constraint is defined on the query level and utilizes the patient encounters and / or instance number when determining eligibility.
</td>
</tr>
<tr>
<td>Panel Timing</td>
<td>Constraint is defined on the panel level and utilizes the patient encounters and / or instance number when determining eligibility.
</td>
</tr>
<tr>
<td>Date</td>
<td>Constraint uses a date range when determining eligibility.</td>
</tr>
<tr>
<td>Occurrence</td>
<td>Constraint is by the number of occurrences an item is documented.</td>
</tr>
<tr>
<td>Exclusion</td>
<td>Constraint will not include patients with the concepts listed in the panel.</td>
</tr>
<tr>
<td>Value</td>
<td>Constraint is by the value associated to a concept or modifier. Not all items have values.</td>
</tr>
</table>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
In the client, the value constraints are currently the only ones that directly correspond to a single concept. All others are defined on the query or panel level.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<h4><aname="qtTempPanelConstraints"id="qtTempPanelConstraints"></a>Temporal and Panel Timing Constraints</h4>
<p>Both temporal and panel constraints are very similar in that both utilize the visit / encounter information along with the concepts defined to determine if a patient meets the search criteria.
</p>
<p> </p>
<p>The main difference between a <b>temporal</b> and a <b>panel timing constraint</b> is that temporal constraints are defined at the <i>query level</i> and panel timing constraints are defined at the <i>panel level</i>.
<p>Users can select one of three available options:</p>
<p> </p>
<ol>
<li>Treat all groups independently</li>
<ul>
<li>The items (facts) can occur at <b>any time</b> in the patient's history.</li>
</ul>
<p> </p>
<p> </p>
<li>Selected items occur in the same financial encounter</li>
<ul>
<li>The items (facts) occur during the <b>same visit</b> (financial encounter).</li>
</ul>
<p> </p>
<p> </p>
<li>Items instance will be the same</li>
<ul>
<li>The items (facts) occur during the <b>same visit</b> (financial encounter) <i>AND</i> the <b>same instance</b>.
</li>
<li>Can only be selected if a modifier is listed in a panel.</li>
</ul>
</ol>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
In order to be considered the same instance, the facts have to have the same patient number, encounter number, concept, provider, start date, and instance number.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<h6><aname="qtTempConstraintAnyVisit"id="qtTempConstraintAnyVisit"></a>Treat All Groups Independently</h6>
<p> </p>
<ul>
<li><i>Panel timing constraint</i> will default to <b>Treat Independently</b></li>
<li><i>Panel timing constraint</i> can not be changed</li>
<li>Items defined in the panels can occur at <b>any time</b> in the patients history</li>
<p>Patient has a medication with a dose greater than 500 mg <i><b>and</b></i> a medication that is taken once a day documented at <i><b>any time</b></i> in their history.
<p><b>RESULTS:</b> there are 47 patients who have had a medication with a dose of 500 mg and a frequency of once a day entered as a fact in the observation_fact table, where medication dose and frequency have the <i><u>same</u></i><b>patient_num</b>.
<p>Patient has a medication with a dose greater than 500 mg <i><b>and</b></i> a medication that is taken once a day documented during the <i><b>same visit</b></i>.
<p><b>RESULTS:</b> there are 41 patients who have had a medication with a dose of 500 mg and a frequency of once a day entered as a fact in the observation_fact table, where the medication dose and frequency have the <i><u>same</u></i><b>encounter_num</b>.
<p>Patient has a medication with a dose greater than 500 mg <i><b>and</b></i> a medication that is taken once a day documented during the <i><b>same instance</b></i>.
<p><b>RESULTS:</b> there are 36 patients who have had a medication with a dose of 500 mg and a frequency of once a day entered as a fact in the observation_fact table, where the medication dose and frequency have the <i><u>same</u></i><b>encounter_num</b> , <b>concept_cd</b>, <b>provider_id</b>, <b>start_date</b>, <i>AND</i><b>instance_num</b>.
<p>As stated in the previous section the <b>Panel Timing Constraint</b> is defined at the <i>panel level</i> and can only be changed when the <i>temporal constraint</i> is defined as <b>Selected groups occur in the same financial encounter</b> or <b>Items instance will be the same</b>.
</p>
<p> </p>
<p> </p>
<p>Users can select one of three available options:</p>
<p> </p>
<ol>
<li>Treat all groups independently</li>
<ul>
<li>The items (facts) can occur at <b>any time</b> in the patient's history.</li>
</ul>
<p> </p>
<p> </p>
<li>Selected items occur in the same financial encounter</li>
<ul>
<li>The items (facts) occur during the <b>same visit</b> (financial encounter).</li>
<li>Temporal constraint has to be set to Same financial encounter in order to be available for selection.
</li>
</ul>
<p> </p>
<p> </p>
<li>Items instance will be the same</li>
<ul>
<li>The items (facts) occur during the <b>same visit</b> (financial encounter) <i>AND</i> the <b>same instance</b>.
</li>
<li>Temporal constraint has to be set to Items instance will be the same in order to be available for selection.
</li>
</ul>
</ol>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
In order to be considered the same instance, the facts have to have the same patient number, encounter number, concept, provider, start date, and instance number.
<p>In the example shown below, the items (facts) listed in the panel for Group 1 can occur at <i>any time</i> in the patient's history while the items in Group 2 and 3 have to occur during the <i>same visit</i>.
</p>
<p> </p>
<p><b>Example:</b></p>
<p>Patient has a diagnosis of Acute MI documented at <b><i>any time</i></b> in their history and they have a medication with a dose greater than 500 mg <b><i>and</i></b> a medication that is taken once a day documented during the <b><i>same visit</i></b>.
<p><b>RESULTS:</b> there are 4 patients who have had a medication with a dose greater than 500 mg and a frequency of once a day entered as a fact in the observation_fact table, where the medication dose and frequency have the <i><u>same</u></i><b>encounter_num</b><i>AND</i> the diagnosis of acute MI, the medication dose and frequency all have the <i><u>same</u></i><b>patient_num</b>
<p>In the example shown below, the items (facts) listed in the panel for Group 1 can occur at <i>any time</i> in the patient's history while the items in Group 2 and 3 have to occur during the <i>same instance</i>.
</p>
<p> </p>
<p><b>Example:</b></p>
<p>Patient has a diagnosis of Acute MI documented at <b><i>any time</i></b> in their history and they have a medication with a dose greater than 500 mg <b><i>and</i></b> a medication that is taken once a day documented during the <b><i>same instance</i></b>.
<p><b>RESULTS:</b> there are 3 patients who have had a medication with a dose of 500 mg and a frequency of once a day entered as a fact in the observation_fact table, where the medication dose and frequency have the <i><u>same</u></i><b>encounter_num</b> , <b>concept_cd</b>, <b>provider_id</b>, <b>start_date</b>, <i>AND</i><b>instance_num</b><i>AND</i> the diagnosis of acute MI, the medication dose and frequency all have the <i><u>same</u></i><b>patient_num</b>
<p>In this example, if a patient has a diagnosis of Acute Myocardial Infarction (MI) entered on their record from 01/01/2001 to 12/31/2005 then their data will be included. If the patient does have an MI diagnosis but it was entered prior to 01/01/2001 or after 12/31/2005 then their information will not be included.
</p>
<p> </p>
<p> </p>
<p> </p>
<h6><aname="qtDateConstraintSetFromTo"id="qtDateConstraintSetFromTo"></a>Setting the Date Constraint (FROM / TO Date Range)</h6>
<p> </p>
<ol>
<li>Click on the <b>Dates button</b> located in the selection criteria section of the panel.</li>
<li>Click the <b>check box</b> next to the date in the <b>From box</b>.</li>
<li>At this point there are two methods of entering your <i>starting</i> date.</li>
<oltype="a">
<li>Manually type it in the text box.</li>
<li>Click on the <b>drop-down arrow</b><spanstyle="color:#CCCCCC">(<imgsrc="images/dropDownArrow.png"alt="dropDownArrow"/>)</span> to open the calendar view and click on the desired date.
<p>In this example, if a patient has a diagnosis of Acute Myocardial Infarction (MI) entered on their record any time on or after 01/01/2001 then their data will be included. If the diagnosis was entered prior to 01/01/2001 then it will not be included.
</p>
<p> </p>
<p></p>
<h6><aname="qtDateConstraintSetFrom"id="qtDateConstraintSetFrom"></a>Setting the Date Constraint (FROM Date only)</h6>
<p> </p>
<ol>
<li>Click on the <b>Dates button</b> located in the selection criteria section of the panel.</li>
<li>Click the <b>check box</b> next to the date in the <b>From box</b>.</li>
<li>At this point there are two methods of entering your <i>starting</i> date.</li>
<oltype="a">
<li>Manually type it in the text box.</li>
<li>Click on the <b>drop-down arrow</b><spanstyle="color:#CCCCCC">(<imgsrc="images/dropDownArrow.png"alt="dropDownArrow"/>)</span> to open the calendar view and click on the desired date.
<p>In this example, if a patient has a diagnosis of Acute Myocardial Infarction (MI) entered on their record prior to and including 12/31/2005 then their data will be included. If the diagnosis was entered after 12/31/2005 then it will not be included.
</p>
<p> </p>
<p> </p>
<p> </p>
<h6><aname="qtDateConstraintSetTo"id="qtDateConstraintSetTo"></a>Setting the Date Constraint (TO Date only)</h6>
<p> </p>
<ol>
<li>Click on the <b>Dates button</b> located in the selection criteria section of the panel.</li>
<li>Click the <b>check box</b> next to the date in the <b>To box</b>.</li>
<li>At this point there are two methods of entering your <i>ending</i> date.</li>
<oltype="a">
<li>Manually type it in the text box.</li>
<li>Click on the <b>drop-down arrow</b><spanstyle="color:#CCCCCC">(<imgsrc="images/dropDownArrow.png"alt="dropDownArrow"/>)</span> to open the calendar view and click on the desired date.
<p>Value constraints can be associated with concept and modifiers but not all of them will have values. For instance, the diagnosis of Acute Myocardial Infarction does not have a value but the tests used to make the diagnosis do have values (high, low, numeric, etc.).
</p>
<p> </p>
<p>For those items that do have values there are different types of values that may be associated with it.
</p>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
The different types of constraints and how they work are the same regardless of whether or not it is associated with a concept or a modifier.
<p><b>Flags</b> are defined in the source system when the value is entered. The following are some examples that can be found in the i2b2 Demo database.
</p>
<p> </p>
<ul>
<li>High</li>
<li>Low</li>
<li>Abnormal</li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<h6><aname="qtFlagValueConstraintSetConcept"id="qtFlagValueConstraintSetConcept"></a>Setting the Value Constraint (Flag) for a Concept</h6>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
The value constraint window will open automatically when you drop a concept into a panel in the Query Tool view. This will only happen if the concept is set up in the database with XML metadata. The first three steps can be used if you did not add a value constraint when you added the item or if you wish to edit an existing item.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<ol>
<li>Using the <i>right mouse button</i>, click on the item listed in the panel.</li>
<h6><aname="qtFlagValueConstraintSetModifier"id="qtFlagValueConstraintSetModifier"></a>Setting the Value Constraint (Flag) for a Modifier</h6>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
The modifier value constraint window will open automatically when you drop a modifier into a panel in the Query Tool view. This will only happen if the modifier is set up in the database with XML metadata. The first three steps can be used if you did not add a value constraint when you added the item or if you wish to edit an existing item.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<ol>
<li>Using the <i>right mouse button</i>, click on the item listed in the panel.</li>
<p>The<b> text value</b> is defined in the source system when the value is entered. The following are some examples that can be found in the i2b2 Demo database.
</p>
<p> </p>
<ul>
<li>Test Not Performed</li>
<li>Borderline</li>
<li>Positive</li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<h6><aname="qtTextValueConstraintSetConcept"id="qtTextValueConstraintSetConcept"></a>Setting the Value Constraint (Text) for a Concept</h6>
<p> </p>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
The value constraint window will open automatically when you drop a concept into a panel in the Query Tool view. This will only happen if the concept is set up in the database with XML metadata. The first three steps can be used if you did not add a value constraint when you added the item or if you wish to edit an existing item.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<ol>
<li>Using the <i>right mouse button</i>, click on the item listed in the panel.</li>
To select more than one you can hold down the <Ctrl> key while clicking on each name. On the Macintosh you can hold down the command key instead of the <Ctrl> key.
<h6><aname="qtTextValueConstraintSetModifier"id="qtTextValueConstraintSetModifier"></a>Setting the Value Constraint (Text) for a Modifier</h6>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
The modifier value constraint window will open automatically when you drop a modifier into a panel in the Query Tool view. This will only happen if the modifier is set up in the database with XML metadata. The first three steps can be used if you did not add a value constraint when you added the item or if you wish to edit an existing item.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<ol>
<li>Using the <i>right mouse button</i>, click on the item listed in the panel.</li>
<li>A pop-up menu will open.</li>
<li>Select <b>Set Modifier Value</b> from the list.</li>
To select more than one you can hold down the <Ctrl> key while clicking on each name. On the Macintosh you can hold down the command key instead of the <Ctrl> key.
<p>The <b>numeric value</b> is defined in the source system when the result is entered. The following are some example formats that can be found in the i2b2 Demo database.
</p>
<p> </p>
<ul>
<li>200</li>
<li>1.3</li>
</ul>
<p> </p>
<p> </p>
<p>Unlike flag and text values, numeric values use operators, such as greater than or less than when setting the constraints. The following is a listing of operators currently in use.
<td>Any value less than or equal to the number entered (inclusive).</td>
</tr>
<tr>
<td>Equal To (=)</td>
<td>An exact match to the number entered.</td>
</tr>
<tr>
<td>Between</td>
<td>Any value in the range of numbers entered.</td>
</tr>
<tr>
<td>Greater Than (>)</td>
<td>Any value greater than the number entered.</td>
</tr>
<tr>
<td>Greater Than or Equal To (>=)</td>
<td>Any value greater than or equal to the number entered (inclusive).</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<h6><aname="qtNumValueConstraintSetConcept"id="qtNumValueConstraintSetConcept"></a>Setting the Value Constraint (Numeric) for a Concept</h6>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
The value constraint window will open automatically when you drop a concept into a panel in the Query Tool view. This will only happen if the concept is set up in the database with XML metadata. The first three steps can be used if you did not add a value constraint when you added the item or if you wish to edit an existing item.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p></p>
<ol>
<li>Using the <i>right mouse button</i>, click on the item listed in the panel.</li>
<h6><aname="qtNumValueConstraintSetModifier"id="qtNumValueConstraintSetModifier"></a>Setting the Value Constraint (Numeric) for a Modifier</h6>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
The modifier value constraint window will open automatically when you drop a modifier into a panel in the Query Tool view. This will only happen if the modifier is set up in the database with XML metadata. The first three steps can be used if you did not add a value constraint when you added the item or if you wish to edit an existing item.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p></p>
<ol>
<li>Using the <i>right mouse button</i>, click on the item listed in the panel.</li>
<li>A pop-up menu will open.</li>
<li>Select <b>Set Modifier Value</b> from the list.</li>
<h5><aname="qtNumValueConstraintUnits"id="qtNumValueConstraintUnits"></a>Using Units In Value Constraints</h5>
<p>Units in regards to i2b2 are the standard units of measurement associated with a value. For instance, a medication may have "mg" listed as the unit for the dose, while a HGB lab test may have "gm/dL".
</p>
<p> </p>
<p>The units are defined in the source system and although it is recommended that all numerical facts are stored in normalized units it is recognized that this is not always feasible. Therefore, the Web Client has the ability to convert the units when running a query.
</p>
<p> </p>
<p>In order for this feature to work a parameter called CRC_ENABLE_UNITCD_CONVERSION must be defined for the project. If this is not defined you need to contact your system administrator.
</p>
<p> </p>
<p> </p>
<p> </p>
<h6><aname="qtNumValueConstraintUnitsSet"id="qtNumValueConstraintUnitsSet"></a>Defining the Units When Running a Query</h6>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
The modifier value constraint window will open automatically when you drop a modifier into a panel in the Query Tool view. This will only happen if the modifier is set up in the database with XML metadata. The first three steps can be used if you did not add a value constraint when you added the item or if you wish to edit an existing item.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<ol>
<li>Using the <i>right mouse button</i>, click on the item listed in the panel.</li>
<li>A pop-up menu will open.</li>
<li>Select <b>Set Modifier Value</b> from the list.</li>
<p>In the above scenario, the normal units are "mg". When setting up the value constraint the units were changed to "gm" and the numerical value was set to 5. Upon saving the value constraint, the Web Client converted 5 gm to 5000 mg. When the query is run it will look at those facts that have both 5 gm and 5000 mg defined in the observation_fact table.
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
The unit conversion information is specific to the term and is defined in the i2b2 metadata table.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<h2><aname="qtRunningQuery"id="qtRunningQuery"></a>Running a Query</h2>
<p> </p>
<p>This section describes the process of running a query and the output.</p>
<p>When you run a query you need to select what type of result the server will return. There are several <b>result types</b> available, each of which will yield a different output.
<p>This option will return a set of encounters for those patients who meet the defined criteria and will display the appropriate information in the following views.
</p>
<p> </p>
<ol>
<li><b>Query Status View</b></li>
<p> </p>
<ul>
<li>The encounter set information will appear as soon as the query has finished running.</li>
<li>It will also appear in this view when you drag a previous query to the <i>Query Name field</i> in the <b>Query Tool view</b>.
<h4><aname="qtResultTypePtCount"id="qtResultTypePtCount"></a>Number of Patients</h4>
<p> </p>
<p>This option will return a total count for those patients who meet the defined criteria and will display the appropriate information in the following views.
</p>
<p> </p>
<ol>
<li><b>Query Status View</b></li>
<p> </p>
<ul>
<li>The patient count information will appear as soon as the query has finished running.</li>
<li>It will also appear in this view when you drag a previous query to the <i>Query Name field</i> in the <b>Query Tool view</b>.
<p>This option will return a breakdown by gender for those patients who meet the defined criteria and will display the appropriate information in the following views.
</p>
<p> </p>
<ol>
<li><b>Query Status View</b></li>
<p> </p>
<ul>
<li>The information for the gender patient breakdown will appear as soon as the query has finished running.
</li>
<li>It will also appear in this view when you drag a previous query to the <i>Query Name field</i> in the <b>Query Tool view</b>.
<h4><aname="qtResultTypeVitalStatus"id="qtResultTypeVitalStatus"></a>Vital Status Patient Breakdown</h4>
<p> </p>
<p>This option will return a breakdown by vital status for those patients who meet the defined criteria and will display the appropriate information in the following views.
</p>
<p> </p>
<ol>
<li><b>Query Status View</b></li>
<p> </p>
<ul>
<li>The information for the vital status patient breakdown will appear as soon as the query has finished running.
</li>
<li>It will also appear in this view when you drag a previous query to the <i>Query Name field</i> in the <b>Query Tool view</b>.
<p>This option will return a breakdown by race for those patients who meet the defined criteria and will display the appropriate information in the following views.
</p>
<p> </p>
<ol>
<li><b>Query Status View</b></li>
<p> </p>
<ul>
<li>The information for the race patient breakdown will appear as soon as the query has finished running.
</li>
<li>It will also appear in this view when you drag a previous query to the <i>Query Name field</i> in the <b>Query Tool view</b>.
<p>This option will return a breakdown by age for those patients who meet the defined criteria and will display the appropriate information in the following views.
</p>
<p> </p>
<ol>
<li><b>Query Status View</b></li>
<p> </p>
<ul>
<li>The information for the age patient breakdown will appear as soon as the query has finished running.
</li>
<li>It will also appear in this view when you drag a previous query to the <i>Query Name field</i> in the <b>Query Tool view</b>.
<p>Once the query criterion has been defined, the final steps are to click on the <b>Run Query button</b>, select the result type(s), and click on the <b>OK button</b> to run the query.
</p>
<p> </p>
<ol>
<li>Once you have defined the search criteria click on the <b>Run Query button</b> located on the toolbar at the bottom of the <i>Query Tool view</i>.
<li>A name for the query will default at the query name field.</li>
<li>Either change the name of the query or accept the default.</li>
<li>In the query result type section, click on the <b>checkboxes</b> for those <b>result types</b> you want to include when the query is run.
</li>
<li>Click on the <b>OK button</b>.</li>
<li>The Run Query window will close and the querying process will begin.</li>
</ol>
<p> </p>
<p> </p>
<p>Once you begin the process of running the query the <i>Query Status view</i> will display "<b>Running Query</b>", the name of the query, and the time that has elapsed.
<p>A <b>previous query</b><spanstyle="color:#CCCCCC">(<imgsrc="images/prevQuery.jpg"alt="previousQuery"/>)</span> is created automatically when a query is run from the <i>Query Tool</i>. The query is stored in the database and displayed in the <i>Previous Query view</i>.
</p>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
Previous queries can also be seen in Workplace view if the user copied it to their workplace or shared folder in workplace view.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<ol>
<li>Run a query.</li>
<li>Go to the <b>Previous Query view</b>.</li>
<li>The query you just ran will now appear in the list of previous queries.</li>
<p> </p>
<p><imgsrc="images/pqView.png"alt="pqView"/></p>
</ol>
<p> </p>
<p> </p>
<tableid=note>
<tr>
<td>
<pclass=NoteHeading>NOTE: </p>
<pclass=NoteParagraph>
If the previous query does not appear in the list automatically you can refresh the view to update the list. This is done by using the right mouse button and clicking anywhere in the Previous Query view.
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<h2><aname="qtPrintQuery"id="qtPrintQuery"></a>Printing a Query</h2>
<p> </p>
<p>Users are able to print out the query information if they wish to have a hard copy of the search criteria defined for a query.
</p>
<p> </p>
<p>When printing a query you can either print the information for a current query or you can drag a previous query to the query tool view and print the information associated with that query.
</p>
<p> </p>
<p>The following steps outline the process of printing a query once you have the appropriate query in the Query Tool.
</p>
<p> </p>
<p> </p>
<ol>
<li>Click on the <b>Print Query button</b> located on the toolbar at the bottom of the <i>Query Tool view</i>