Incorporating Number Of Studies Query capability in i2b2
Space shortcuts
Space Tools

Author: Peter R /(viv)

Started Date: April 25, 2013

Introduction

We have created and integrated in the i2b2 CRC’s a new query result type termed “Number of studies”. This query result type represents the count of the number of distinct encounters, specified in the query interface by the operator. Please refer to the original CRC for details.

In order for the new query type to appear in the user interface query selection windows, a record is inserted in the QT_QUERY_RESULT_TYPE table.

a)      Inserting a new record in the Query result type table

INSERT INTO i2b2demodata.QT_QUERY_RESULT_TYPE

  (RESULT_TYPE_ID, NAME, DESCRIPTION, DISPLAY_TYPE_ID, VISUAL_ATTRIBUTE_TYPE_ID)

VALUES

  (10,'ENCOUNTER_COUNT_XML', 'Number of Studies', 'CATNUM', 'LA');

 

In order for the java middle layer to receive and handle the query properly a new entry is added in the CRCApplicationContext.xml file.

b)      Modify
   etc\spring\CRCApplicationContext.xml
in the CRC module, adding the following entry next to PATIENT_COUNT_XML entry

<entry>
  <key><value>ENCOUNTER_COUNT_XML</value></key>
  <value>

     edu.harvard.i2b2.crc.dao.setfinder.QueryResultEncounterCountGenerator
  </value>

</entry>

 

Implement the following class to handle IOC communication.

 

c)      Introduced a class QueryResultEncounterCountGenerator following the convention from the QueryResultPatientCountGenerator class.

 

Implement the logic based on the new result type and modify the setfinder package logic to handle the new type. The new type is handled by properly setting and propagating the encounterSet flag along the call chain, and composing the correct SQL queried, based on the requested result type, and temporary table usage scenarios.

d)      Modified classes:

edu.harvard.i2b2.crc.dao.setfinder.querybuilder.BuildTotalOccuranceSql ’s buildTotalOccuranceSql method to take into account the “group by” clause.

e)      Modify edu.harvard.i2b2.crc.datavo.db.QtQueryResultType class, adding the constant
public final static String ENCOUNTER_COUNT_XML = "ENCOUNTER_COUNT_XML";

 

f)        Introduced getEncounterSetResultDAO method in the edu.harvard.i2b2.crc.dao.SetFinderDAOFactory interface and implementation, to be called from the QueryResultEncounterCountGenerator class.

 

g)      Changed edu.harvard.i2b2.crc.dao.setfinder.querybuilder. RecursiveBuild class’s execQuery method to properly passed the previously ignored encounterSetOutputFlag flag:

queryTool =

  new QueryToolUtilNew(

    dataSourceLookup,  requestXML, encounterSetOutputFlag);
 

h)      Modified the edu.harvard.i2b2.crc.dao.setfinder.QueryExecutorHelperDao ’s executeQuery method to take into account the result type when generating records in the result table.

 

i)        Modified the edu.harvard.i2b2.crc.dao.setfinder.QueryExecutorDao ’s executeSql method to take into account the encounterSetFlag .

 

j)        Modified the CheckSkipTempTable class to accommodate the new ENCOUNTER_COUNT_XML constant.

Miscellaneous actions

  • Renamed class CalulateQueryTiming to Cal c ulateQueryTiming

Building and deployment

After checking out the modified java sources, follow the build procedure outlined in HIVE installation manual.