Developers Getting Started With i2b2
Space shortcuts
Space Tools

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Table of Contents

Children Display


Overview

The Data Exporter functionality enables an i2b2 user to request patient data for the patients found by a desired query. In the configured workflow, data is requested and generated through new breakdown types that can be selected in the Run Query dialog. Users will see "data request" breakdowns, which send an e-mail to a predefined data manager requesting a type of data. The data manager (Manager user role) processes the request by rerunning the query with a special "data export" breakdown. The patient data is exported as a file and stored in a specified location for retrieval.

The patient data export types, request options, and file specifications are configured in the database using specific request type entries and configuration parameters in the database.


Data Export Workflow

Image RemovedImage Added

Data Request (User Process)

  1. User logs into webclient and

...

  1. Creates creates and runs a query.
  2. Clicks Run query and ticks boxes for a data request

...

  1. In the Run Query dialog box, select one or more Data Request checkboxes
    Image Added
  2. Emails are automatically sent - one to the requester's e-mail, to inform them the request has been made; and one to the specified manager user to inform them to run the user's export request

...

  1. . The query name (in previous queries) is tagged with the query master id

...

Image Removed

Run a query with a data request

...

  1. , so it can be identified by the manager.


Data Export (Manager Process)

  1. The manager logs into the webclient and finds the query from their e-mail by locating the query master id, which is now part of the title of the previous query.
    Manager Image Added

  2. The manager user then re-runs the previous query and clicks on exportThe In the Run Query dialog, the manager selects the requested export option is displayed selected in the Data export breakdown list.Data export runs in the background and

    Info

    It is very important to put the original query master id (or some other identifier that links the export to the request) into the query name. The export letter will contain the query name, and this is the only way to trace the export back to the original request. (Currently there is no way to tie the export directory to the  data requester  query_master_id.) If the data manager runs the query as a query-in-query, the query name will automatically be populated with this identifier.


    Image Added
  3. The data export runs in the background and the file is generated in the folder specified in the HIVE_CELL_PARAM

  4. Manger user manually sends a confirmation email to the user on the file generation and retrieval info.

Image Removed

Data Export options in the Run Query Dialog

Image Removed
Sample Letter generated for Data Manager

  1. a specified folder 

  2. An e-mail is sent to the manager that can be forwarded to the requesting user, to inform them that their export is available and to provide retrieval info. 

Sample Letter generated for Data Manager

Results of the i2b2 request entitled - "Demographics_12_48_52", submitted on Apr 18, 2024 1:47:58 PM, are available.

Important notes about your data:
- Total number of patients returned in your data request: 133
- i2b2 reviewer:

Only persons specifically authorized and selected (as listed at the top of this letter) can download these files. If additional user access is needed, please ensure the person is listed on your project IRB protocol and contact the i2b2 team.

Specifically:
- Remove all PHI from computer, laptop, or mobile device after analysis is completed.
- Do NOT share PHI or PII with anyone who is not listed on the IRB protocol.

Your guideline for the storage of Protected Health Information can be found at: https://www.site.com/guidelines_for_protecting_and_storing_phi.pdf

*To download these files*
- You must be logged onto your site

These results are the data that was requested under the authority of the Institutional Review Board.  The query resulting in this identified patient data is included at the end of this letter.  A copy of this letter is kept on file and is available to the IRB in the event of an audit.

Thank you,

The i2b2 Team 


Example Export files (all data are fake)

Demographics

Image Added

Diagnosis

Image Added

Data Export Configuration

Design and Architecture

The existing i2b2 breakdown architecture is has been modified to display breakdowns for the request/Export Options display in the run query dialog corresponding to the entries in the support new breakdown types for data request and export. HIVE_CELL_PARAMS has new parameters for global configuration, the QT_RESULT_TYPE table . When a manager user exports user request option, an export file is generated based on the entries in has new entries for query export types, and the QT_BREAKDOWN_PATH table. Email notification sent to the manager is also based on the entries in the QT_BREAKDOWN_PATH table. The generated file is formatted as per the entries defines the request and export. These are XML documents containing e-mails to send and SQL to execute. These breakdown types display in the run query dialog. User e-mails are sent to the e-mail address of the currently logged-in use. Data Manager e-mails are sent to an address configured in HIVE_CELL_PARAMS, and the data manager e-mail in an export is also saved as a file in the export location. The export file generation location, also configured in HIVE_CELL_PARAMS, is on the local drive hosting the i2b2 application

Database changes

Currently QT_BREAKDOWN_PATH .value column has datatype of varchar(2000). In order to support the XML  structure needed for the Data Exporter, the value column has been modified to CLOB datatype. 


Image Added


Configuring Database Parameters

Request/Export

...

query types: QT_QUERY_RESULT_TYPE

The data request and data export query types are configured as breakdowns in the QT_QUERY_RESULT_TYPE table. VISUAL_ATTRIBUTE_TYPE_ID should be set to LR for Data request and LX for Data export

USER_ROLE_CD should be set to DATA_LDS for Data Request and USER_ROLE_CD should be MANAGER for Data Export display.


NAMEDESCRIPTIONDISPLAYTYPE_IDVISUAL_ATTRIBUTE_TYPE_IDUSER_ROLE_CDCLASSNAME
PATIENT_DEMOGRAPHIC_REQUESTRequest Demographics DataCATNUMLRDATA_LDSedu.harvard.i2b2.crc.dao.setfinder.QueryResultPatientRequest
PATIENT_DEMOGRAPHIC_CSVExport Demographics DataCATNUMLXMANAGERedu.harvard.i2b2.crc.dao.setfinder.QueryResultPatientDownload

...


Info

We recommend data requests be limited to DATA_LDS users (irrespective of Admin path role - admin, user, manager) and data exports be limited to MANAGER users (irrespective of data path role - data_lds, data_agg,data_obf, data_deid). The user role determines if exports/requests are visible and runnable. 

 QT_QUERY_RESULT_TYPEuser roledata requestdata export

 DATA_LDS

DATA_LDS

Success

non-display

MANAGER  

MANAGER

non-display

Success

MANAGER with

DATA_LDS

MANAGER


Success

MANAGER

with DATA_LDS

DATA_LDS

Success




Request/Export file definition details: QT_BREAKDOWN_PATH

QT_BREAKDOWN_PATH Name column hosts 2 type of parameters for each request type: The value column has XML file with email and file specifications defines e-mail content (for request and export) and SQL code (for export) in the following XML format.  Any parameters defined in an export XML override the default in HIVE_CELL_PARAMS (e.g., field separator character.) 

NameValue
  • <request name>_REQUEST
has details on
  • defines the request email
notification
  • generation parameters. 
  • Request email can be configured in PM_USER_DATA parameters to define the email address of the User.
  • User email content configurable in <RequesterEmailMessage>/>xml value parameter
  • Data Manager gets the data manager email (email address configured in the HIVE_CELL_PARAMS)
  • Data manager email content configurable in the <DataManagerEmailMessage>/xml value parameter

<?xml version="1.0"?>
<ValueExporter>
 

<Version><version no><

<Version>[...version number...]</Version>
  <CreationDateTime>08/09/2024 12:00:00</CreationDateTime>
 

<RequestLetter><details sent to

<RequesterEmailMessage>[...details sent to User on data request...]  </RequesterEmailMessage>
  <DataManagerEmailMessage>[...details sent to data Manager on user data

request> 

request...]</

RequestLetter>

DataManagerEmailMessage>
</ValueExporter>

  • <request name>_CSV
has details on export file generation   
  • defines the data export email parameters and the SQL to for the export file generation.   
  • The data export email has detailed info on the file location and access info and can be customized according to your local institution's policies. 
  • The exported file(s) are generated in a secure location on the server's file system along with the data export email file in a zipped folder
  • Email content and export SQL are configurable in the XML entries for the request/export in the Value parameters.
  •  Multiple SQL statements can be configured in the Value <file></file> tags as one SQL statement per file tag
<?xml version="1.0"?>
<ValueExporter>
 
<Version><version no><
<Version>[...version number...]</Version>
  <CreationDateTime><date value></CreationDateTime>
 
<RequesterEmailLetter>details
<DataManagerEmailMessage>details sent to
user
data Manager on data request</
RequesterEmailLetter>
    <LetterFilename><name of the file></LetterFilename>
  <Letter> <letter content></Letter>
  <Table>
<Filename>filename</Filename>
<Query><SQL
DataManagerEmailMessage>
  <File>
<Filename>[... filename specification..]</Filename>
<Query>[... SQL query to generate the data export
content><
content...]</Query>
     
<SeparatorCharacter><file format seperator><
<SeparatorCharacter>[...file format seperator...]</SeparatorCharacter>
  </
Table>
File>
</ValueExporter>



Example

...

Requests

NAMEVALUE
PATIENT_MEDICATION_CSV<?xml version="1.0"?>
<ValueExporter>
 
<Version>3.02</Version>
 
<CreationDateTime>08/09/2024 12:00:00</CreationDateTime>
 
<RequesterEmailLetter>Your
<RequesterEmailMessage>Your request on {{{PROJECT_ID}}} requested i2b2 request
 entitled - "{{{QUERY_NAME}}}", submitted on {{{QUERY_STARTDATE}}}, with the query master of {{{QUERY_ID}}}</
RequesterEmailLetter>
RequesterEmailMessage>
 
<RequestLetter>This
<DataManagerEmailMessage>This user {{{USER_NAME}}} in project {{{PROJECT_ID}}} requested i2b2 request
 entitled - "{{{QUERY_NAME}}}", submitted on {{{QUERY_STARTDATE}}}, with the query master of {{{QUERY_ID}}}.
  </
RequestLetter>
DataManagerEmailMessage>
  <LetterFilename>/{{{USER_NAME}}}/{{{QUERY_MASTER_ID}}}/Readme.txt</LetterFilename>
  <Letter>
Results of the i2b2 request entitled - "{{{QUERY_NAME}}}", submitted on {{{QUERY_STARTDATE}}}, are available.

Important notes about your data:
- Total number of patients returned in your data request: {{{PATIENT_COUNT}}}
- i2b2 reviewer:

Only persons specifically authorized and selected (as listed at the top of this letter) can download these files. If additional user access is needed, please ensure the person is listed on your project IRB protocol and contact the i2b2 team.

Specifically:
- Remove all PHI from computer, laptop, or mobile device after analysis is completed.
- Do NOT share PHI or PII with anyone who is not listed on the IRB protocol.

Your guideline for the storage of Protected Health Information can be found at: https://www.site.com/guidelines_for_protecting_and_storing_phi.pdf

*To download these files*
- You must be logged onto your site

These results are the data that was requested under the authority of the Institutional Review Board.  The query resulting in this identified patient data is included at the end of this letter.  A copy of this letter is kept on file and is available to the IRB in the event of an audit.

Thank you,

The i2b2 Team
</Letter>
 
<Table>
<File>
<Filename>/{{{USER_NAME}}}/{{{QUERY_MASTER_ID}}}/Medication.csv</Filename>
<Query>SELECT to_char(a.PATIENT_NUM) as "I2B2_PATIENT_NUMBER"
        ,a.start_date as "START_DATE"
        ,a.start_date as "END_DATE"
        ,b.name_char as "MEDICATION_NAME"
        ,b.concept_cd as "NDC_CODE"
        ,a.units_cd as "UNIT"
        ,a.quantity_num as "DOSE_QUANTITY"       
        ,a.modifier_cd as "MODIFIER"
        ,m.name_char as "MODIFIER_NAME"
        ,a.instance_num as "INSTANCE_NUM"
        ,a.location_cd as "FACILITY"
        ,case v.inout_cd  when 'O' then 'Outpatient' when 'I' then 'Inpatient' else 'Unknown' end as "ENCOUNTER_TYPE"
        ,p.name_char as "PROVIDER"
        ,a.encounter_num as "ENCOUNTER_NUMBER"
    FROM observation_fact  a
    INNER  JOIN concept_dimension b on a.concept_cd = b.concept_cd and b.concept_path like '\i2b2\Medications\%'
    JOIN {{{DX}}} c on a.patient_num = c.patient_num
    LEFT OUTER JOIN provider_dimension p on a.provider_id = p.provider_id
    JOIN visit_dimension v on a.encounter_num = v.encounter_num and a.patient_num = v.patient_num
    LEFT OUTER JOIN modifier_dimension m on a.modifier_cd = m.modifier_cd</Query>
      <SeparatorCharacter>\t</SeparatorCharacter>
  </
Table>
File>

</ValueExporter>
PATIENT_MEDICATION_REQUEST<?xml version="1.0"?>
<ValueExporter>
  <Version>3.02</Version>
 <CreationDateTime>08
 <CreationDateTime>08/09/2024 12:00:00</CreationDateTime>
 
<RequesterEmailLetter>Your
<RequesterEmailMessage>Your request on {{{PROJECT_
MASTER_
ID}}} requested i2b2 request

 entitled
entitled - "{{{QUERY_NAME}}}", submitted on {{{QUERY_STARTDATE}}}, with the query master of {{{QUERY_MASTER_ID}}}</
RequesterEmailLetter>
RequesterEmailMessage>
 
<RequestLetter>This
<DataManagerEmailMessage>This user {{{USER_NAME}}} in project {{{PROJECT_ID}}} requested i2b2 request

 entitled
entitled - "{{{QUERY_NAME}}}", submitted on {{{QUERY_STARTDATE}}}, with the query master of {{{QUERY_MASTER_ID}}}.
  </
RequestLetter>
DataManagerEmailMessage>
</ValueExporter>



Export file format/location and Email parameters set-upHIVE_CELL_PARAMS

Export File format, location and email server parameters are configurable in the HIVE_CELL_PARAMS

Info

The <Filename> parameter  in the QT_BREAKDOWN_PATH  definition will override the default value specified in the HIVE_CELL_PARAMS. 

Wildfly must be restarted for changes to the HIVE_CELL_PARAMs to take effect.



Cell IDParameter NameExample ValueNotes
CRCedu.harvard.i2b2.crc.exportcsv.datamanageremailuserid@partners.orgEmail address used for sending request/export e-mails
CRCedu.harvard.i2b2.crc.smtp.hostsmtp.partners.orgSMTP host
CRCedu.harvard.i2b2.crc.smtp.port25SMTP port
CRCedu.harvard.i2b2.crc.smtp.ssl.enableenabledFALSETRUE will enable SSL
CRCedu.harvard.i2b2.crc.smtp.authFALSETRUE will enable SMTP authentication
CRCedu.harvard.i2b2.crc.smtp.usernamenoneSMTP username (required for SMTP authentication)
CRCedu.harvard.i2b2.crc.smtp.passwordnoneSMTP password (required for SMTP authentication)
CRCedu.harvard.i2b2.crc.smtp.enabledFALSETRUE will enable e-mails
CRCedu.harvard.i2b2.crc.smtp.from.fullnameData ManagerName that e-mails will be sent from.
CRCedu.harvard.i2b2.crc.smtp.from.emaildatamanager@site.orgE-mail address that e-mails will be sent from.
CCedu.harvard.i2b2.crc.smtp.subjecti2b2 Data RequestSubject line for e-mails.
CRCedu.harvard.i2b2.crc.exportcsv.defaultescapecharacter"Escape character for export files
CRCedu.harvard.i2b2.crc.exportcsv.maxfetchrows-1Maximum number of rows to export, or -1 for no limit
CRCedu.harvard.i2b2.crc.exportcsv.defaultlineend\nLine ending for export files
CRCedu.harvard.i2b2.crc.exportcsv.defaultseperator\tField separator for export files
CRCedu.harvard.i2b2.crc.exportcsv.resultfetchsize50000Number of records retrieved during each database fetch.
CRCedu.harvard.i2b2.crc.exportcsv.filename/tmp/{{{PROJECT_ID}}}/{{{DATE_yyyyMMdd}}}_{{{FULL_NAME}}}.tsvParameterized template for export file names. If the extension is .zip, the file is zipped.
CRCedu.harvard.i2b2.crc.exportcsv.defaultquotechar"Quote character for export files
CRCedu.harvard.i2b2.crc.exportcsv.workfolder/tmp/i2b2Folder on the i2b2 server for data exports
CRCedu.harvard.i2b2.crc.exportcsv.zipencryptmethodnone

Variables for File name entries 

Image RemovedImage Removed

Java Changes

Two new breakdown classes are designed to perform the file export process

  • edu.harvard.i2b2.crc.dao.setfinder.QueryResultPatientRequest
  • edu.harvard.i2b2.crc.dao.setfinder.QueryResultPatientDownload

Example Export files

Demographics

Image Removed

Diagnosis

Image Removed

Encryption method for the exported ZIP file. One of STANDARD, NONE, or AES.


Export query definition variables

These variables can be used in HIVE_CELL_PARAMS entries and in query export definitions: 

Value

Description

{{{USER_NAME}}}

Current user running query

{{{PROJECT_ID}}}

The project name

{{{RANDOM_xxx}}}

A random integer where xxx is the max integer size

{{{DATE_xxx}}}

Date/Time format, where xxx can be from the table below.  The string yyyy-MM-dd would output dates that look like 2022-07-26

{{{QUERY_NAME}}}

Query Name

{{{QUERY_STARTDATE}}}

Query Start date/time

{{{QUERY_ENDDATE}}}

Query End date/time

{{{PATIENT_COUNT}}}

Number of patients. 

{{{FULL_NAME}}}

Fullname of user who ran query

{{{QUERY_MASTER_ID}}}

The query Master ID

{{{QUERY_RUNTIME}}}

Time to run the query

{{{FULL_SCHEMA }}}Used in SQL export definitions. Inserts the full schema name (e.g., 'i2b2.dbo.'). Needed to be sure i2b2 accesses the correct data tables!


Table of allowable characters in {{{DATE_xxx}}} strings:

ValueDescriptionValueDescription
GeraKhour-of-am-pm (0-11)
uyearkclock-hour-of-am-pm (1-24)
yyyy4-digit yearHhour-of-day (0-23)
Dday-of-yearmminute-of-hour
M/Lmonth-of-yearssecond-of-minute
dday-of-monthSfraction-of-second
Q/qquarter-of-yearAmilli-of-day
Yweek-based-yearnnano-of-second
wweek-of-week-based-yearNnano-of-day
Wweek-of-monthVtime-zone ID
Eday-of-weekztime-zone name
e/clocalized day-of-weekOlocalized zone-offset
Fweek-of-monthXzone-offset 'Z' for zero
aam-pm-of-dayxzone-offset
hclock-hour-of-am-pm (1-12)Zzone-offset


ppad next


Software Changes:

  • Data: New entries in HIVE_CELL_PARAMS, QT_QUERY_RESULT_TYPE, and QT_BREAKDOWN_PATH define the exporter configuration.
  • Java code: New breakdown classes and updates to existing java classes to support the data exporter functionality.