i2b2 Web Client
Space shortcuts
Space Tools

Versions Compared

Key

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

...

i2b2.ExampTabs.getResults = function () {
     // Refresh the display with info of the SDX record that was DragDropped
if      if (i2b2.ExampTabs.model.dirtyResultsData) {
var      var dropRecord = i2b2.ExampTabs.model.currentRec;

     // hide the directions DIV and show the output DIVs
$$      $$("DIV#ExampTabs-mainDiv DIV.results-directions"

Wiki Markup
)\[
0].hide();
$$      $$("DIV#ExampTabs-mainDiv DIV.results-finished"
Wiki Markup
)\[
0].show();
var
     var sdxDisplay = $$("DIV#ExampTabs-mainDiv DIV#ExampTabs-InfoSDX"
Wiki Markup
)\[
0];
var
     var tempRefDIV = false;
tempRefDIV      tempRefDIV = Element.select(sdxDisplay, '.sdxDisplayName'
Wiki Markup
)\[
0];
tempRefDIV      tempRefDIV.innerHTML = dropRecord.sdxInfo.sdxDisplayName;
tempRefDIV
     tempRefDIV = Element.select(sdxDisplay, '.sdxType'
Wiki Markup
)\[
0];
tempRefDIV      tempRefDIV.innerHTML = dropRecord.sdxInfo.sdxType;
tempRefDIV
     tempRefDIV = Element.select(sdxDisplay, '.sdxControlCell'
Wiki Markup
)\[
0];
tempRefDIV      tempRefDIV.innerHTML = dropRecord.sdxInfo.sdxControlCell;
tempRefDIV
     tempRefDIV = Element.select(sdxDisplay, '.sdxKeyName'
Wiki Markup
)\[
0];
tempRefDIV      tempRefDIV.innerHTML = dropRecord.sdxInfo.sdxKeyName;
tempRefDIV
     tempRefDIV = Element.select(sdxDisplay, '.sdxKeyValue'
Wiki Markup
)\[
0];
tempRefDIV      tempRefDIV.innerHTML = dropRecord.sdxInfo.sdxKeyValue;

     // Escape the XML text or the browser will attempt to interpret it as HTML
var
     var xmlDisplay = i2b2.h.Xml2String(dropRecord.origData.xmlOrig);
xmlDisplay      xmlDisplay = '<pre>'+ i2b2.h.Escape(xmlDisplay)+'</pre>';
Element      Element.select(sdxDisplay, '.originalXML'
Wiki Markup
) \[
0] .innerHTML = xmlDisplay ;
     }

     // optimization – only requery when the input data is changed
i2b2      i2b2.ExampTabs.model.dirtyResultsData = false;
}

...

At this point the example, the plug-in has a working input method, a processing routine, and an output screen. All that is left is to do is to capture an event to initiate processing and displaying of the data.

The most user-transparent event we can capture would be the user switching to the results tab. If the data is dirty when the user switches to the results tab then the input will be reprocessed. The code needed to perform in this way operates as follows:

...

i2b2.ExampTabs.Init = function (loadedDiv) {
     // this function is called after the HTML is loaded into the viewer DIV
i2b2      i2b2.ExampTabs.view.containerDiv = loadedDiv; // save reference for later use
var      var cfgObj = {activeIndex : i2b2.ExampTabs.cfg.config.DefaultTab – 1 };
this     this.yuiTabs = new YAHOO.widget.TabView("ExampTabs-TABS", cfgObj);

     // register DIV as valid DragDrop target for Patient Record Sets (PRS) objects
var      var divName = "ExampTabs-DROPTRGT";

     // register for drop events of the following datatypes
var      var op_trgt = {dropTarget:true};
i2b2      i2b2.sdx.Master.AttachType(divName, 'CONCPT', op_trgt);
i2b2      i2b2.sdx.Master.AttachType(divName, 'QM', op_trgt);
i2b2      i2b2.sdx.Master.AttachType(divName, 'QI', op_trgt);
i2b2      i2b2.sdx.Master.AttachType(divName, 'PRS', op_trgt);
i2b2      i2b2.sdx.Master.AttachType(divName, 'PRC', op_trgt);
i2b2      i2b2.sdx.Master.AttachType(divName, 'PR', op_trgt);
i2b2      i2b2.sdx.Master.AttachType(divName, 'QDEF', op_trgt);
i2b2      i2b2.sdx.Master.AttachType(divName, 'QGDEF', op_trgt);
i2b2      i2b2.sdx.Master.AttachType(divName, 'XML', op_trgt);

     // Use an event router to demultiplex the callbacks to the single
// drop event handler used by by 
     // this plugin. This also recreates a properly
// scoped "this" keyword within the event handler 
     var eventRouterFunct = (function (sdxData) { i2b2.ExampTabs.doDrop(sdxData);});

     // register the event handler via eventRouterFunc
var      var refSDXMaster = i2b2.sdx.Master;
refSDXMaster      refSDXMaster.setHandlerCustom(divName, 'CONCPT', 'DropHandler', eventRouterFunc);
refSDXMaster      refSDXMaster.setHandlerCustom(divName, 'QM', 'DropHandler', eventRouterFunc);
refSDXMaster      refSDXMaster.setHandlerCustom(divName, 'QI', 'DropHandler', eventRouterFunc);
refSDXMaster      refSDXMaster.setHandlerCustom(divName, 'PRS', 'DropHandler', eventRouterFunc);
refSDXMaster      refSDXMaster.setHandlerCustom(divName, 'PRC', 'DropHandler', eventRouterFunc);
refSDXMaster      refSDXMaster.setHandlerCustom(divName, 'PR', 'DropHandler', eventRouterFunc);
refSDXMaster      refSDXMaster.setHandlerCustom(divName, 'QDEF', 'DropHandler', eventRouterFunc);
refSDXMaster      refSDXMaster.setHandlerCustom(divName, 'QGDEF', 'DropHandler', eventRouterFunc);
refSDXMaster      refSDXMaster.setHandlerCustom(divName, 'XML', 'DropHandler', eventRouterFunc);

     // Start Processing when user switches to the results tab IF the data is dirty
this      this.yuiTabs.on('activeTabChange', function(ev) {
     //Tabs have changed
if      if (ev.newValue.get('id')== "ExampTabs-TAB1") {
          // user switched to Results tab
          if (i2b2.ExampTabs.model.currectRec) {
          // gather statistics only if we have data
          if (i2b2.ExampTabs.model.dirtyResultsData) {
               // recalculate the results only if the input data has changed
i2b2               i2b2.ExampTabs.getResults();
          }
        }
     }
     });
};



Plug-in Example #3 – PDO Example

...