logo


58.1.8 Query Tutorial: Using Sets


Sets are saved selections. They reside in memory and are VERY fast in operation. They allow you to create a new set based on the combination of two sets. This combining of sets can be done as many times as you like - until you have created the selection of records you require.

A common required task for any Query in STATIC is to create several sets of records for a particular time interval...

And for this time interval find the admissions that:

a Survived Hospital

b Died in Hospital

c Died in ICU

We will use sets (and some Join Set commands) to create all the required selections of Records:

USING SETS

||.Comment: Get All ICU Records in this time interval.||

QUERY [ICURecord] AND [ICURecord]Adm_Date >= 01/01/1999 Result: M_ICURecord_1

QUERY [ICURecord] AND [ICURecord]Adm_Date <= 31/12/2000 Result: M_ThisYearAll_3

This creates a set of ICURecords called M_ThisYearAll_3 for the time interval specified - note that we have created a named set clicking the E Button to edit the Set Name.

 

||.Comment: Get all Admissions that have ever been to ICU.||

QUERY [Location] AND [Location]Current_Area_Type = Adult_ICU Result: M_Location_4

JOIN SET From Set M_Location_4[Location] To Set M_ICU_5[ICURecord]

INTERSECTION using M_ThisYearAll_3 and M_ICU_5 Result: M_ICU_5

Here we use the [Location] Table to find all ICU admissions that have ever been to Adult_ICU. Remember that the [Location] record will tell you what level of ICU a patient has been admitted to (the patient may have been in both levels of ICU within the same admission).

The Join Set then gives us the selection of [ICURecord] records that have had an Adult_ICU Admission. We create a set M_ICU_5 and then Intersect this with the time interval set M_ThisYearAll_3 to find all admissions that have been in Adult_ICU within the time interval we require.

Note that we have reused the M_ICU_5 set for the Results set - that is perfectly OK to do as long as you do not need the contents of the original set.

 

||.Comment: Get all Admissions that survived Hospital.||

QUERY [HospitalRecord] AND [HospitalRecord]Disch_Outcome # Died Result: M_HospitalRecord_6

JOIN SET From Set M_HospitalRecord_6[HospitalRecord] To Set M_HospitalAlive_37[ICURecord]

We search for any [HospitalRecord] records that did not Die. Through the Join Set this gives us all [ICURecord] records that have survived. We save this as a set - M_HospitalAlive_37.

 

||.Comment: Get all Admissions that Died in Hospital.||

QUERY [HospitalRecord] AND [HospitalRecord]Disch_Outcome = Died Result: M_HospitalRecord_7

JOIN SET From Set M_HospitalRecord_7[HospitalRecord] To Set M_HospitalDied_39[ICURecord]

We search for any [HospitalRecord] records that Died. Through the Join Set this gives us all [ICURecord] records that have Died. We save this as a set - M_HospitalDied_39.

 

||.Comment: Get all Admissions that survived ICU.||

QUERY [ICURecord] AND [ICURecord]Disch_Outcome # Died in ICU Result: M_ICUAlive_40

We search for any [ICURecord] records that did not Die. We save this as a set - M_ICUAlive_40.

 

||.Comment: Get all Admissions that Died in ICU.||

QUERY [ICURecord] AND [ICURecord]Disch_Outcome = Died in ICU Result: M_ICUDied_42

We search for any [ICURecord] records that Died. We save this as a set - M_ICUDied_42.

 

||.Comment: Final Alive.||

INTERSECTION using M_HospitalAlive_37 and M_ICUAlive_40 Result: M_FINALALIVE_45

INTERSECTION using M_FINALALIVE_45 and M_ThisYearAll_3 Result: M_FINALALIVE_45

Here we do an intersection between the ICUAlive and the HospitalAlive sets. This does not need to be done unless you suspect errors in your data and want to eliminate some of these before preceding. If you do suspect problems then the Query needs to be constructed differently - Query successively for all possible outcomes using a series of OR Queries. You could also look for completed records only using the completion fields. In short you can make your filters as complicated as you like. The best filter of all is having good reliable data in the first place!

 

||.Comment: Final ICU Death.||

INTERSECTION using M_ICUDied_42 and M_ThisYearAll_3 Result: M_FINALICUDied_49

Doing an Intersection with the Interval Set gives us the admissions that Died in ICU

 

||.Comment: Final Hospital Died.||

INTERSECTION using M_HospitalDied_39 and M_ICUAlive_40 Result: M_FINALHOSPITALDIED_52

INTERSECTION between M_FINALHOSPITALDIED_52 and M_ThisYearAll_3 Result: M_FINALHOSPITALDIED_52

Here we do an intersection between the ICUAlive and the HospitalDied sets. This will give us a set of admissions that survived ICU but subsequently died on the Ward.

This is quite a long example, but it illustrates how you can construct your Queries to get what you want.



Harrowex Pty Ltd
http://www.hxmedical.com
Voice:+ 61 4 27 344 279
Fax: +61 3 52 439 019
static@hxmedical.com