Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
webclient.js-i2b2.cells.CRC.CRC_ctrlr_QryTool.js Maven / Gradle / Ivy
/**
* @projectDescription Event controller for CRC's Query Tool.
* @inherits i2b2.CRC.ctrlr
* @namespace i2b2.CRC.ctrlr.QT
* @author Nick Benik, Griffin Weber MD PhD
* @version 1.3
* ----------------------------------------------------------------------------------------
* updated 9-15-08: RC4 launch [Nick Benik]
*/
console.group('Load & Execute component file: CRC > ctrlr > QueryTool');
console.time('execute time');
i2b2.CRC.ctrlr.QT = new QueryToolController();
function QueryToolController() {
i2b2.CRC.model.queryCurrent = {};
this.queryIsDirty = true;
this.queryIsRunning = false;
this.queryNamePrompt = false;
this.queryTiming = 'ANY';
this.temporalGroup = 0;
this.tenporalBuilders = 0;
this.hasModifier = false;
this.queryNameDefault = 'New Query';
this.queryStatusDefaultText = 'Drag query items to one or more groups then click Run Query.';
this.panelControllers = [];
this.panelControllers[0] = new i2b2_PanelController(this);
this.panelControllers[1] = new i2b2_PanelController(this);
this.panelControllers[2] = new i2b2_PanelController(this);
this.sCompiledResultsTest = ""; // snm0 - this is the text for the graph display
// ================================================================================================== //
this.doSetQueryName = function(inName) {
this.queryIsDirty = true;
$('queryName').innerHTML = inName;
i2b2.CRC.model.queryCurrent.name = inName;
}
// ================================================================================================== //
this.doUpdateDatesInPanel = function(panelIndex) { // nw096 - date constraints over
var dm = i2b2.CRC.model.queryCurrent.panels[i2b2.CRC.ctrlr.QT.temporalGroup][panelIndex];
}
// ================================================================================================== //
this.doQueryClear = function() {
// function to clear query from memory
delete i2b2.CRC.model.queryCurrent;
i2b2.CRC.model.queryCurrent = {};
i2b2.CRC.ctrlr.QT.temporalGroup = 0;
var dm = i2b2.CRC.model.queryCurrent;
dm.panels = [];
dm.panels[0] = new Array();
dm.panels[1] = new Array();
dm.panels[2] = new Array();
this.doSetQueryName.call(this,'');
this.doShowFrom(0);
this._redrawPanelCount();
this.queryNamePrompt = false;
this.queryIsDirty = true;
this.hasModifier = false;
$('infoQueryStatusText').innerHTML = "";
$('infoQueryStatusChart').innerHTML = "";
$('crc.temoralBuilder').hide();
$('crc.innerQueryPanel').show();
this.panelControllers[0].refTitle.innerHTML = 'Group 1';
$("defineTemporal-button").innerHTML = "Population in which events occur";
i2b2.CRC.view.QT.setQueryTiming(0);
i2b2.CRC.view.QT.clearTemportal();
$('temporalbuilders').innerHTML = "";
this.tenporalBuilders = -1;
this.queryTiming = 'ANY';
this.doAddTemporal();
this.sCompiledResultsTest = ""; // snm0 - this is the text for the graph display
// tdw9: 1707c - adding changes to clear to handle simple temporal query UI
jQuery("#temporalUIToggleDiv").hide(); // hide temporal query mode toggle when clear is pressed.
jQuery("#toggleTemporalQueryModeSpan").html("Switch to Advanced Temporal Query"); // reset toggle button text
i2b2.CRC.view.QT.isShowingTemporalQueryUI = false; // tdw9: 1707c:show reset state, which is not temporal query
i2b2.CRC.view.QT.isShowingClassicTemporalQueryUI = false;
// reset tutorial
jQuery(".highlighted").removeClass("highlighted"); // remove all highlighteds if they are not already removed
jQuery("#simpleTemporalQueryPointyArrow").hide();
jQuery('#tutorialShowMeLink').hide();
jQuery("#populationLabel").hide();
if (i2b2.CRC.view.QT.isTutorial)
i2b2.CRC.view.QT.toggleTutorial();
i2b2.CRC.view.QT.deleteAllEvents();
i2b2.CRC.view.QT.resetTemporalQueryUI();
i2b2.CRC.view.QT.tutorialState = 0; // reset tutorial state
// hide new temporal sequence UI
jQuery("#outerTemporalSequenceUI").hide();
jQuery("#populationLabel").hide();
// show classic UI
jQuery("#queryBalloonBox").show(); // show baloons
var length = i2b2.CRC.ctrlr.QT.panelControllers.length;
for (var i = 0; i < length; i++)
i2b2.CRC.ctrlr.QT.panelControllers[i].refTiming.set('disabled', false);
jQuery(".qryPanel").show(); // make sure panels are visible
jQuery("#crc\\.innerQueryPanel").css('height', 'auto'); // set "crc.innerQueryPanel" height to be auto
// re-initialize SIMPLE temporal query
i2b2.CRC.view.QT.deleteAllEvents();
i2b2.CRC.view.QT.resetTemporalQueryUI();
i2b2.CRC.view.QT.splitterDragged(); // tdw9: 1707c: resize query-timing button
// tdw9 1707c: end changes to handle SIMPLE temporal query UI
}
// ================================================================================================== //
// tdw9 1707c: clear only the temporal component of the ADVANCED query model
this.doClearTemporalComponent= function( )
{
// save the population component of the temporal query
var populationComponent = i2b2.CRC.model.queryCurrent.panels[0]
// function to clear query from memory
delete i2b2.CRC.model.queryCurrent;
i2b2.CRC.model.queryCurrent = {};
i2b2.CRC.ctrlr.QT.temporalGroup = 0;
var dm = i2b2.CRC.model.queryCurrent;
dm.panels = [];
dm.panels[0] = populationComponent;
dm.panels[1] = new Array();
dm.panels[2] = new Array();
this.doSetQueryName.call(this,'');
this.doShowFrom(0);
this._redrawPanelCount();
this.queryNamePrompt = false;
this.queryIsDirty = true;
this.hasModifier = false;
$('infoQueryStatusText').innerHTML = "";
$('infoQueryStatusChart').innerHTML = "";
$('crc.temoralBuilder').hide();
$('crc.innerQueryPanel').show();
this.panelControllers[0].refTitle.innerHTML = 'Group 1';
$("defineTemporal-button").innerHTML = "Population in which events occur";
// taken from the function i2b2.CRC.view.QT.clearTemportal
var t = defineTemporalButton.getMenu().getItems();
if (t.length > 4)
{
defineTemporalButton.getMenu().clearContent();
defineTemporalButton.getMenu().addItems([{ text: "Population in which events occur" , value: "0" }]);
defineTemporalButton.getMenu().addItems([{ text: "Event 1" , value: "1" }]);
defineTemporalButton.getMenu().addItems([{ text: "Event 2" , value: "2" }]);
defineTemporalButton.getMenu().addItems([{ text: "Define order of events" , value: "BUILDER" }]);
defineTemporalButton.getMenu().render();
}
i2b2.CRC.view.QT.ResizeHeight();
$('temporalbuilders').innerHTML = "";
this.tenporalBuilders = -1;
this.queryTiming = 'ANY';
this.doAddTemporal();
this.sCompiledResultsTest = ""; // snm0 - this is the text for the graph display
}
// ================================================================================================== //
// tdw9 1707: checks if an Event contains number constraints.
this.eventContainsNumberConstraint = function(qd)
{
for (var i=1; i 1)
return true;
}
return false;
};
this.eventContainsNonConceptItems = function(qd)
{
for (var i=1; i support
itm.dateFrom = po.dateFrom;
if (po.dateTo == false)
itm.dateTo = i2b2.CRC.view.QT.parseDateString(i2b2.h.getXNodeVal(pi[i2], 'constrain_by_date/date_to'));
else // WEBCLIENT-162: Backwards compatible support
itm.dateTo = po.dateTo;
if ((pi.length == 1) && (i2 == 0)) {
if (typeof i2b2.h.getXNodeVal(pi[i2], 'constrain_by_date/date_from' === "undefined"))
allDateFromsAreSame = false;
if (typeof i2b2.h.getXNodeVal(pi[i2], 'constrain_by_date/date_to' === "undefined"))
allDateTosAreSame = false;
}
// Set panel date by looking at item dates
if ((pi.length > 1) && (i2 < pi.length - 1) && allDateFromsAreSame && allDateTosAreSame) {
if (i2b2.h.getXNodeVal(pi[i2], 'constrain_by_date/date_from') != i2b2.h.getXNodeVal(pi[i2 + 1], 'constrain_by_date/date_from')) {
allDateFromsAreSame = false;
} else {
allDateFroms = itm.dateFrom;
}
if (i2b2.h.getXNodeVal(pi[i2], 'constrain_by_date/date_to') != i2b2.h.getXNodeVal(pi[i2 + 1], 'constrain_by_date/date_to')) {
allDateTosAreSame = false;
} else {
allDateTos = itm.dateTo;
}
}
var item = {};
// get the item's details from the ONT Cell
var ckey = i2b2.h.getXNodeVal(pi[i2], 'item_key');
// Determine what item this is
if (ckey.startsWith("query_master_id")) {
var o = new Object;
o.name = i2b2.h.getXNodeVal(pi[i2], 'item_name');
o.id = ckey.substring(16);
o.result_instance_id = o.PRS_id;
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('QM', o);
po.items.push(sdxDataNode);
} else if (ckey.startsWith("masterid")) {
var o = new Object;
o.name = i2b2.h.getXNodeVal(pi[i2], 'item_name');
o.id = ckey;
o.result_instance_id = o.PRS_id;
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('QM', o);
po.items.push(sdxDataNode);
} else if (ckey.startsWith("patient_set_coll_id")) {
var o = new Object;
o.titleCRC = i2b2.h.getXNodeVal(pi[i2], 'item_name');
o.PRS_id = ckey.substring(20);
o.result_instance_id = o.PRS_id;
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('PRS', o);
po.items.push(sdxDataNode);
} else if (ckey.startsWith("patient_set_enc_id")) {
var o = new Object;
o.titleCRC = i2b2.h.getXNodeVal(pi[i2], 'item_name');
o.PRS_id = ckey.substring(19);
o.result_instance_id = o.PRS_id;
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('ENS', o);
po.items.push(sdxDataNode);
}
else
{
// WE MUST QUERY THE ONT CELL TO BE ABLE TO DISPLAY THE TREE STRUCTURE CORRECTLY
var o = new Object;
o.level = i2b2.h.getXNodeVal(pi[i2], 'hlevel');
o.name = i2b2.h.getXNodeVal(pi[i2], 'item_name');
o.tooltip = i2b2.h.getXNodeVal(pi[i2], 'tooltip');
// nw096 - If string starts with path \\, lookup path in Ontology cell
if (o.name.slice(0, 2) == '\\\\') {
var results = i2b2.ONT.ajax.GetTermInfo("ONT", { ont_max_records: 'max="1"', ont_synonym_records: 'false', ont_hidden_records: 'false', concept_key_value: o.name }).parse();
if (results.model.length > 0) {
o.name = results.model[0].origData.name;
o.tooltip = results.model[0].origData.tooltip;
}
}
o.key = i2b2.h.getXNodeVal(pi[i2], 'item_key');
o.synonym_cd = i2b2.h.getXNodeVal(pi[i2], 'item_is_synonym');
if (o.synonym_cd == "false") // tdw9 bug fix for non-synonym terms showing blue text: HTML rendering checks to see if synonym is "N," not "false"
o.synonym_cd = "N";
o.hasChildren = i2b2.h.getXNodeVal(pi[i2], 'item_icon');
// Lab Values processing
var lvd = i2b2.h.XPath(pi[i2], 'descendant::constrain_by_value');
if ((lvd.length > 0) && (i2b2.h.XPath(pi[i2], 'descendant::constrain_by_modifier').length == 0))
o.LabValues = this.parseValueConstraint( lvd );
// sdx encapsulate
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('CONCPT', o);
if (o.LabValues)
sdxDataNode.LabValues = o.LabValues;
// set item date
if (itm.dateFrom)
sdxDataNode.dateFrom = itm.dateFrom;
if (itm.dateTo)
sdxDataNode.dateTo = itm.dateTo;
// parse for modifier
if (i2b2.h.XPath(pi[i2], 'descendant::constrain_by_modifier').length > 0)
{
sdxDataNode.origData.parent = {};
sdxDataNode.origData.parent.key = o.key;
//sdxDataNode.origData.parent.LabValues = o.LabValues;
sdxDataNode.origData.parent.hasChildren = o.hasChildren;
sdxDataNode.origData.parent.level = o.level;
sdxDataNode.origData.parent.name = o.name;
sdxDataNode.origData.key = i2b2.h.getXNodeVal(pi[i2], 'constrain_by_modifier/modifier_key');
sdxDataNode.origData.applied_path = i2b2.h.getXNodeVal(pi[i2], 'constrain_by_modifier/applied_path');
sdxDataNode.origData.name = i2b2.h.getXNodeVal(pi[i2], 'constrain_by_modifier/modifier_name');
sdxDataNode.origData.isModifier = true;
this.hasModifier = true;
// Mod Values processing
var lvd = i2b2.h.XPath(pi[i2], 'descendant::constrain_by_modifier/constrain_by_value');
if (lvd.length > 0)
o.ModValues = this.parseValueConstraint( lvd );
if (o.ModValues)
sdxDataNode.ModValues = o.ModValues;
}
po.items.push(sdxDataNode); // write to po.items
}
}
// Set panel date by looking at item dates
if (allDateFromsAreSame && allDateTosAreSame)
{
if (typeof allDateTos !== "undefined")
po.dateTo = allDateTos;
if (typeof allDateFroms !== "undefined")
po.dateFrom = allDateFroms;
}
};
this.doLoadPopulationQuery = function( qd, dObj, qm_id )
{
for (var j = 0; j < 1; j++)
{
dObj.panels = [];
if (j == 0)
var qp = i2b2.h.XPath(qd[j], 'panel');
else
var qp = i2b2.h.XPath(qd[j], 'descendant::panel');
var total_panels = qp.length;
for (var i1 = 0; i1 < total_panels; i1++)
{
i2b2.CRC.ctrlr.QT.temporalGroup = j;
i2b2.CRC.ctrlr.QT._redrawAllPanels();
// extract the data for each panel
var po = {};
po.panel_num = i2b2.h.getXNodeVal(qp[i1], 'panel_number');
var t = i2b2.h.getXNodeVal(qp[i1], 'invert');
po.exclude = (t == "1");
//po.timing = i2b2.h.getXNodeVal(qp[i1],'panel_timing');
// 1.4 queries don't have panel_timing, and undefined doesn't work
// so default to ANY
po.timing = i2b2.h.getXNodeVal(qp[i1], 'panel_timing') || 'ANY';
i2b2.CRC.view.QT.setPanelTiming(po.panel_num, po.timing);
var t = i2b2.h.getXNodeVal(qp[i1], 'total_item_occurrences');
po.occurs = (1 * t) - 1;
var t = i2b2.h.getXNodeVal(qp[i1], 'panel_accuracy_scale');
po.relevance = t;
// check, parse, and set "panel dates" for panelObj
po.dateFrom = i2b2.CRC.view.QT.parseDateString(i2b2.h.getXNodeVal(qp[i1], 'panel_date_from'));
po.dateTo = i2b2.CRC.view.QT.parseDateString(i2b2.h.getXNodeVal(qp[i1], 'panel_date_to'));
// tdw9: load items into panel
this.loadItemsIntoPanel(po, qp, i1);
dObj.panels[po.panel_num] = po;
}
// reindex the panels index (panel [1,3,5] should be [0,1,2])
dObj.panels = dObj.panels.compact();
i2b2.CRC.model.queryCurrent.panels[j] = dObj.panels;
}
// populate the panels yuiTrees
try {
var qpc = i2b2.CRC.ctrlr.QT.panelControllers[0];
var dm = i2b2.CRC.model.queryCurrent;
for (var k = 0; k < dm.panels.length; k++) {
for (var pi = 0; pi < dm.panels[k].length; pi++) {
// create a treeview root node and connect it to the treeview controller
dm.panels[k][pi].tvRootNode = new YAHOO.widget.RootNode(qpc.yuiTree);
qpc.yuiTree.root = dm.panels[k][pi].tvRootNode;
dm.panels[k][pi].tvRootNode.tree = qpc.yuiTree;
qpc.yuiTree.setDynamicLoad(i2b2.CRC.ctrlr.QT._loadTreeDataForNode, 1);
// load the treeview with the data
var tvRoot = qpc.yuiTree.getRoot();
for (var pii = 0; pii < dm.panels[k][pi].items.length; pii++) {
var withRenderData = qpc._addConceptVisuals(dm.panels[k][pi].items[pii], tvRoot, false);
if (dm.panels[k][pi].items[pii].ModValues) {
withRenderData.ModValues = dm.panels[k][pi].items[pii].ModValues;
}
if (dm.panels[k][pi].items[pii].LabValues) {
withRenderData.LabValues = dm.panels[k][pi].items[pii].LabValues;
}
if (dm.panels[k][pi].items[pii].dateFrom) {
withRenderData.dateFrom = dm.panels[k][pi].items[pii].dateFrom;
}
if (dm.panels[k][pi].items[pii].dateTo) {
withRenderData.dateTo = dm.panels[k][pi].items[pii].dateTo;
}
dm.panels[k][pi].items[pii] = withRenderData;
}
}
}
} catch (e) { }
i2b2.CRC.ctrlr.QT.temporalGroup = 0;
i2b2.CRC.ctrlr.QT._redrawAllPanels();
i2b2.CRC.ctrlr.QT._redrawPanelCount(); // tdw9 1707c: update panel count
i2b2.CRC.view.QT.ResizeHeight();
//Load the query status
i2b2.CRC.ctrlr.QT.laodQueryStatus(qm_id, dObj.name);
};
// ================================================================================================== //
this.doQueryLoad = function(qm_id) { // function to load query from history
// clear existing query
i2b2.CRC.ctrlr.QT.doQueryClear();
// show on GUI that work is being done
//i2b2.h.LoadingMask.show();
// callback processor
var scopedCallback = new i2b2_scopedCallback();
scopedCallback.scope = this;
scopedCallback.callback = function(results) {
var cl_queryMasterId = qm_id;
// THIS function is used to process the AJAX results of the getChild call
// results data object contains the following attributes:
// refXML: xmlDomObject <--- for data processing
// msgRequest: xml (string)
// msgResponse: xml (string)
// error: boolean
// errorStatus: string [only with error=true]
// errorMsg: string [only with error=true]
i2b2.CRC.view.QT.queryRequest = results.msgRequest;
i2b2.CRC.view.QT.queryResponse = results.msgResponse;
// switch to status tab
i2b2.CRC.view.status.showDisplay();
// did we get a valid query definition back?
var qd = i2b2.h.XPath(results.refXML, 'descendant::query_name/..');
if (qd.length != 0) {
i2b2.CRC.ctrlr.QT.doQueryClear();
var dObj = {};
dObj.name = i2b2.h.getXNodeVal(results.refXML,'name');
this.doSetQueryName(dObj.name); // BUG FIX - WEBCLIENT-102
dObj.timing = i2b2.h.XPath(qd[0],'descendant-or-self::query_timing/text()');
// dObj.timing = dObj.timing[0].nodeValue; //will cause a null-pointer or undefined obj exception when dObj.timing has no length!
if($("crcQueryToolBox.bodyBox")){
var userId = i2b2.h.getXNodeVal(results.refXML,'user_id');
var existingUserIdElemList = $$("#userIdElem");
if(existingUserIdElemList)
{
existingUserIdElemList.each(function(existingUserIdElem){
existingUserIdElem.remove();
});
}
$("crcQueryToolBox.bodyBox").insert(new Element('input',{'type':'hidden','id':'userIdElem','value':userId}));
}
//i2b2.CRC.view.QT.queryTimingButtonset("label", dObj.timing);
// i2b2.CRC.view.QT.setQueryTiming(dObj.timing); //must check to prevent null-pointer or undefined obj exception that'll result in hang
if (dObj.timing && 0 < dObj.timing.length) i2b2.CRC.view.QT.setQueryTiming(dObj.timing[0].nodeValue);//to prevent null-ptr or undefined exception
dObj.specificity = i2b2.h.getXNodeVal(qd[0],'specificity_scale');
//dObj.panels = new Array(new Array());
var sqc = i2b2.h.XPath(qd[0], 'subquery_constraint');
// tdw9 1707c: add decision maker for Temporal Query and if so, whether we use SIMPLE vs ADVANCED
if (sqc.length > 0)
{
i2b2.CRC.view.QT.setQueryTiming("TEMPORAL");
if ( !this.eventContainsNumberConstraint(qd) &&
!this.eventContainsNonConceptItems(qd) &&
!this.eventContainsNonModifierItemsInNonFirstPanels(qd) &&
!this.eventContainsNonSameInstanceTimingInNonFirstPanels(qd) &&
this.queryContainsValidSequence(results.refXML))
{
// tdw9 1707c: showing dialog to load query
i2b2.CRC.view.QT.showDialog("Loading Your Query...", "","", "=none=", {}, true, true);
// load temporal query into SIMPLE mode
this.doLoadSimpleTemporalQuery(qd, dObj, cl_queryMasterId);
jQuery("#toggleTemporalQueryModeSpan").html("Switch to Advanced Temporal Query"); // tdw9: fix JIRA bug 4 (https://biobankportaldev.partners.org/jira/browse/BPTEMPQUER-4)
return;
}
else
{
jQuery("#temporalUIToggleDiv").show();
//i2b2.CRC.view.QT.isShowingClassicTemporalQueryUI = true; // make sure we show the classic UI
if (!i2b2.CRC.view.QT.isShowingTemporalQueryUI)
i2b2.CRC.view.QT.toggleTemporalQueryUI();
if (!i2b2.CRC.view.QT.isShowingClassicTemporalQueryUI )
i2b2.CRC.view.QT.doToggleTemporalQueryMode(); // call the version that does not delay to prevent asynchronous changes to data model (i2b2.CRC.model.queryCUrrent)
}
}
for (var j=3; j < qd.length; j++)
i2b2.CRC.view.QT.addNewTemporalGroup();
for (var j=1; j < sqc.length; j++)
i2b2.CRC.ctrlr.QT.doAddTemporal();
for (var j=0; j support
itm.dateFrom = po.dateFrom;
}
if(po.dateTo == false){
var t = i2b2.h.getXNodeVal(pi[i2],'constrain_by_date/date_to');
if (t) {
itm.dateTo = {};
itm.dateTo.Year = t.substring(0,4); //t[0];
itm.dateTo.Month = t.substring(5,7); // t[1];
itm.dateTo.Day = t.substring(8,10);// t[2];
}
} else { // WEBCLIENT-162: Backwards compatible support
itm.dateTo = po.dateTo;
}
if ((pi.length == 1) && (i2 == 0)){
if(typeof i2b2.h.getXNodeVal(pi[i2],'constrain_by_date/date_from' === "undefined"))
allDateFromsAreSame = false;
if(typeof i2b2.h.getXNodeVal(pi[i2],'constrain_by_date/date_to' === "undefined"))
allDateTosAreSame = false;
}
// Set panel date by looking at item dates
if ((pi.length > 1) && (i2 < pi.length - 1) && allDateFromsAreSame && allDateTosAreSame){
if(i2b2.h.getXNodeVal(pi[i2],'constrain_by_date/date_from') != i2b2.h.getXNodeVal(pi[i2 + 1],'constrain_by_date/date_from')){
allDateFromsAreSame = false;
} else {
allDateFroms = itm.dateFrom;
}
if(i2b2.h.getXNodeVal(pi[i2],'constrain_by_date/date_to') != i2b2.h.getXNodeVal(pi[i2 + 1],'constrain_by_date/date_to')){
allDateTosAreSame = false;
} else {
allDateTos = itm.dateTo;
}
}
var item = {};
// get the item's details from the ONT Cell
var ckey = i2b2.h.getXNodeVal(pi[i2],'item_key');
// Determine what item this is
if (ckey.toLowerCase().startsWith("query_master_id")) {
var o = new Object;
o.name =i2b2.h.getXNodeVal(pi[i2],'item_name');
o.id = ckey.substring(16);
o.result_instance_id = o.PRS_id ;
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('QM',o);
po.items.push(sdxDataNode);
} else if (ckey.toLowerCase().startsWith("masterid")) {
var o = new Object;
o.name =i2b2.h.getXNodeVal(pi[i2],'item_name');
o.id = ckey;
o.result_instance_id = o.PRS_id ;
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('QM',o);
po.items.push(sdxDataNode);
} else if (ckey.toLowerCase().startsWith("folder")) {
var o = new Object;
//o.titleCRC = ckey.substring(8);
o.titleCRC = i2b2.h.getXNodeVal(pi[i2],'item_name');
o.PRS_id = ckey.substring(19);
o.result_instance_id = o.PRS_id ;
o.id = ckey;
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('PRS',o);
po.items.push(sdxDataNode);
} else if (ckey.toLowerCase().startsWith("patient_set_coll_id")) {
var o = new Object;
o.titleCRC =i2b2.h.getXNodeVal(pi[i2],'item_name');
o.PRS_id = ckey.substring(20);
o.result_instance_id = o.PRS_id ;
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('PRS',o);
po.items.push(sdxDataNode);
} else if (ckey.toLowerCase().startsWith("patient_set_enc_id")) {
var o = new Object;
o.titleCRC =i2b2.h.getXNodeVal(pi[i2],'item_name');
o.PRS_id = ckey.substring(19);
o.result_instance_id = o.PRS_id ;
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('ENS',o);
po.items.push(sdxDataNode);
} else if (ckey.toLowerCase().startsWith("patient")) {
var o = new Object;
//o.titleCRC = ckey.substring(8);
o.titleCRC = i2b2.h.getXNodeVal(pi[i2],'item_key');
o.patient_id = ckey.substring(13);
o.result_instance_id = o.PRS_id ;
o.id = ckey;
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('PR',o);
po.items.push(sdxDataNode);
} else {
//Get the modfier if it exists
// if (i2b2.h.getXNodeVal(pi[i2],'constrain_by_modifier') != null)
// {
// po.modifier_key = i2b2.h.getXNodeVal(pi[i2],'constrain_by_modifier/modifier_key');
// po.applied_path = i2b2.h.getXNodeVal(pi[i2],'constrain_by_modifier/applied_path');
// }
// WE MUST QUERY THE ONT CELL TO BE ABLE TO DISPLAY THE TREE STRUCTURE CORRECTLY
var o = new Object;
o.level = i2b2.h.getXNodeVal(pi[i2],'hlevel');
o.name = i2b2.h.getXNodeVal(pi[i2],'item_name');
o.tooltip = i2b2.h.getXNodeVal(pi[i2],'tooltip');
// nw096 - If string starts with path \\, lookup path in Ontology cell
if(o.name.slice(0, 2) == '\\\\'){
var results = i2b2.ONT.ajax.GetTermInfo("ONT", {ont_max_records:'max="1"', ont_synonym_records:'false', ont_hidden_records: 'false', concept_key_value: o.name}).parse();
if(results.model.length > 0){
o.name = results.model[0].origData.name;
o.tooltip = results.model[0].origData.tooltip;
}
}
o.key = i2b2.h.getXNodeVal(pi[i2],'item_key');
o.synonym_cd = i2b2.h.getXNodeVal(pi[i2],'item_is_synonym');
o.hasChildren = i2b2.h.getXNodeVal(pi[i2],'item_icon');
//o.xmlOrig = c;
// Lab Values processing
var lvd = i2b2.h.XPath(pi[i2], 'descendant::constrain_by_value');
if ((lvd.length>0) && (i2b2.h.XPath(pi[i2], 'descendant::constrain_by_modifier').length == 0)){
lvd = lvd[0];
o.LabValues = i2b2.CRC.view.modLabvaluesCtlr.processLabValuesForQryLoad(lvd);
}
// sdx encapsulate
var sdxDataNode = i2b2.sdx.Master.EncapsulateData('CONCPT',o);
if (o.LabValues) {
// We do want 2 copies of the Lab Values: one is original from server while the other one is for user manipulation
sdxDataNode.LabValues = o.LabValues;
}
if (itm.dateFrom) {
sdxDataNode.dateFrom = itm.dateFrom;
}
if (itm.dateTo) {
sdxDataNode.dateTo = itm.dateTo;
}
//o.xmlOrig = c;
if (i2b2.h.XPath(pi[i2], 'descendant::constrain_by_modifier').length > 0) {
//if (i2b2.h.getXNodeVal(pi[i2],'constrain_by_modifier') != null) {
sdxDataNode.origData.parent = {};
sdxDataNode.origData.parent.key = o.key;
//sdxDataNode.origData.parent.LabValues = o.LabValues;
sdxDataNode.origData.parent.hasChildren = o.hasChildren;
sdxDataNode.origData.parent.level = o.level;
sdxDataNode.origData.parent.name = o.name;
sdxDataNode.origData.key = i2b2.h.getXNodeVal(pi[i2],'constrain_by_modifier/modifier_key');
sdxDataNode.origData.applied_path = i2b2.h.getXNodeVal(pi[i2],'constrain_by_modifier/applied_path');
sdxDataNode.origData.name = i2b2.h.getXNodeVal(pi[i2],'constrain_by_modifier/modifier_name');
sdxDataNode.origData.isModifier = true;
this.hasModifier = true;
// Lab Values processing
var lvd = i2b2.h.XPath(pi[i2], 'descendant::constrain_by_modifier/constrain_by_value');
if (lvd.length>0){
lvd = lvd[0];
o.ModValues = i2b2.CRC.view.modLabvaluesCtlr.processModValuesForQryLoad(lvd);
}
if (o.ModValues) {
// We do want 2 copies of the Lab Values: one is original from server while the other one is for user manipulation
sdxDataNode.ModValues = o.ModValues;
}
//}
}
po.items.push(sdxDataNode);
// } else {
// console.error("CRC's ONT Handler could not get term details about '"+ckey+"'!");
// }
}
}
if(allDateFromsAreSame && allDateTosAreSame){
if(typeof allDateTos !== "undefined"){
po.dateTo = allDateTos;
}
if(typeof allDateFroms !== "undefined"){
po.dateFrom = allDateFroms;
}
}
dObj.panels[po.panel_num] = po;
}
// reindex the panels index (panel [1,3,5] should be [0,1,2])
dObj.panels = dObj.panels.compact();
i2b2.CRC.model.queryCurrent.panels[j] = dObj.panels;
}
// populate the panels yuiTrees
try {
var qpc = i2b2.CRC.ctrlr.QT.panelControllers[0];
var dm = i2b2.CRC.model.queryCurrent;
for (var k=0; k 0 )
count++;
if (count > 1)
break;
}
if (count < 2)
{
return { isValidated: false,
errorMainMsg: "You cannot run a temporal query with only one Obsevation defined.",
errorSubMsg: ""};
}
}
return { isValidated: true };
};
// ================================================================================================== //
this.doQueryRun = function() {
// function to build and run query
if (i2b2.CRC.ctrlr.currentQueryStatus != false && i2b2.CRC.ctrlr.currentQueryStatus.isQueryRunning()) {
i2b2.CRC.ctrlr.deleteCurrentQuery.cancelled = true;
i2b2.CRC.ctrlr.currentQueryStatus.cancelQuery();
i2b2.CRC.ctrlr.currentQueryStatus = false;
//alert('A query is already running.\n Please wait until the currently running query has finished.');
return void(0);
}
// tdw9 1707c: allow panels to be empty if submitting from new temporal query UI
if (i2b2.CRC.model.queryCurrent.panels[i2b2.CRC.ctrlr.QT.temporalGroup].length < 1 && // check to see if current set of classic UI panels is empty
!(i2b2.CRC.view.QT.isShowingTemporalQueryUI && !i2b2.CRC.view.QT.isShowingClassicTemporalQueryUI))
{
alert('You must enter at least one concept to run a query.');
return void(0);
}
if (i2b2.CRC.model.queryCurrent.panels[i2b2.CRC.ctrlr.QT.temporalGroup][0].items.length < 1)
{
alert('You must enter at least one concept to run a query.');
return void(0);
}
// tdw9 1707c: validate temporal query if we are in temporal mode
if (i2b2.CRC.view.QT.isShowingTemporalQueryUI)
{
var validationResult = this.validateTemporalQuery();
if ( !validationResult.isValidated )
{
i2b2.CRC.view.QT.showDialog("Cannot Run Query", validationResult.errorMainMsg, validationResult.errorSubMsg);
return void(0);
}
}
// make sure a shrine topic has been selected
if (i2b2.PM.model.shrine_domain) {
var topicSELECT = $('queryTopicSelect');
if (topicSELECT.selectedIndex == null || topicSELECT.selectedIndex == 0) {
alert('You must select a Topic to run a SHRINE query.');
return void(0);
}
var topicid = topicSELECT.options[topicSELECT.selectedIndex].value;
}
// callback for dialog submission
var handleSubmit = function() {
// submit value(s)
if(this.submit()) {
// run the query
//if(jQuery("input:checkbox[name=queryType]:checked").length > 0){ // WEBCLIENT-170
var t = $('dialogQryRun');
var queryNameInput = t.select('INPUT.inputQueryName')[0];
var options = {};
var t2 = t.select('INPUT.chkQueryType');
for (var i=0;i";
}
// generate the result_output_list (for 1.3 backend)
var result_output = "";
/*
var i=0;
if (options.chk_PRS) {
i++;
result_output += ' ';
}
if (options.chk_ENS) {
i++;
result_output += ' ';
}
if (options.chk_PRC) {
i++;
result_output += ' ';
}
*/
for(var name in options)
{
if (name) {
i++;
result_output += ' \n';
}
}
params.psm_result_output = ''+result_output+' \n';
// create query object
$('runBoxText').innerHTML = "Cancel Query";
i2b2.CRC.ctrlr.currentQueryStatus = new i2b2.CRC.ctrlr.QueryStatus($('infoQueryStatusText'));
i2b2.CRC.ctrlr.currentQueryStatus.startQuery(inQueryName, params);
}
// ================================================================================================== //
this._queryRunningTime = function() {
if (i2b2.CRC.ctrlr.QT.queryIsRunning) {
var d = new Date();
var t = Math.floor((d.getTime() - queryStartTime)/100)/10;
var el = $('numSeconds');
if (el) {
var s = t.toString();
if (s.indexOf('.') < 0) {
s += '.0';
}
el.innerHTML = s;
window.setTimeout('i2b2.CRC.ctrlr.QT._queryRunningTime()',100);
}
}
}
// ================================================================================================== //
this._queryPromptRun = function(handleSubmit) {
if (!i2b2.CRC.view.dialogQryRun) {
var handleCancel = function() {
this.cancel();
};
var loopBackSubmit = function() {
i2b2.CRC.view.dialogQryRun.submitterFunction();
};
var handlePreview = function() {
var queryNameInput = $('dialogQryRun').select('INPUT.inputQueryName')[0];
if(!queryNameInput)
queryNameInput.value = "No Query Name is currently provided";
i2b2.CRC.ctrlr.QT.doPrintQueryNew(true,queryNameInput.value,true);
};
i2b2.CRC.view.dialogQryRun = new YAHOO.widget.SimpleDialog("dialogQryRun", {
width: "400px",
fixedcenter: true,
constraintoviewport: true,
modal: true,
zindex: 700,
buttons: [{
text: "OK",
handler: loopBackSubmit,
isDefault: true
}, {
text: "Cancel",
handler: handleCancel
}]
});
$('dialogQryRun').show();
i2b2.CRC.view.dialogQryRun.validate = function(){
// now process the form data
var msgError = '';
var queryNameInput = $('dialogQryRun').select('INPUT.inputQueryName')[0];
if (!queryNameInput || queryNameInput.value.blank()) {
alert('Please enter a name for this query.');
return false;
}
if(jQuery("input:checkbox[name=queryType]:checked").length == 0){ // WEBCLIENT-170
alert('You must select one query result type to run.');
return false;
}
return true;
};
i2b2.CRC.view.dialogQryRun.render(document.body);
}
// manage the event handler for submit
delete i2b2.CRC.view.dialogQryRun.submitterFunction;
i2b2.CRC.view.dialogQryRun.submitterFunction = handleSubmit;
// display the dialoge
i2b2.CRC.view.dialogQryRun.center();
i2b2.CRC.view.dialogQryRun.show();
}
// ================================================================================================== //
this._queryPromptName = function(handleSubmit) {
if (!i2b2.CRC.view.dialogQmName) {
var handleCancel = function() {
this.cancel();
};
var loopBackSubmit = function() {
i2b2.CRC.view.dialogQmName.submitterFunction();
};
i2b2.CRC.view.dialogQmName = new YAHOO.widget.SimpleDialog("dialogQmName", {
width: "400px",
fixedcenter: true,
constraintoviewport: true,
modal: true,
zindex: 700,
buttons: [{
text: "OK",
handler: loopBackSubmit,
isDefault: true
}, {
text: "Cancel",
handler: handleCancel
}]
});
$('dialogQmName').show();
i2b2.CRC.view.dialogQmName.validate = function(){
// now process the form data
var msgError = '';
var queryNameInput = $('inputQueryName');
if (!queryNameInput || queryNameInput.value.blank()) {
alert('Please enter a name for this query.');
return false;
}
if(jQuery("input:checkbox[name=queryType]:checked").length == 0){ // WEBCLIENT-170
alert('You must select one query result type to run.');
return false;
}
return true;
};
i2b2.CRC.view.dialogQmName.render(document.body);
}
// manage the event handler for submit
delete i2b2.CRC.view.dialogQmName.submitterFunction;
i2b2.CRC.view.dialogQmName.submitterFunction = handleSubmit;
// display the dialoge
i2b2.CRC.view.dialogQmName.center();
i2b2.CRC.view.dialogQmName.show();
}
// tdw9 1707c: method to copy simple temporal query model to the classic one and load it to UI
this.copySimpleQueryToClassic = function()
{
// load simple model to the classic UI. Parse in-UI content and put equivalent data into the classic model
i2b2.CRC.view.QT.deleteEmptyEvents(); // delete any empty events
var events = jQuery(".temporalEvent");
var classicUIEventCount = i2b2.CRC.model.queryCurrent.panels.length - 1; // the first one ([0]) is Population
// create a mapping of Event names
var eventNameMapping = {};
var eventCounter = 1;
// tell each event to put its content into the classic model and perform rendering
for ( var i = 0; i < events.length; i++ )
{
var targetIndex = i+1;
var tqEvent = jQuery(events[i]).data(i2b2.CRC.view.QT.TQryEvent.eventKey);
tqEvent.copyToClassicUI(classicUIEventCount, targetIndex);
eventNameMapping[tqEvent.name] = "Event " + eventCounter;
eventCounter++;
}
// populate temporal relationships into the classic model
for ( var i = 0; i < i2b2.CRC.view.QT.temporalRelationships.length; i++ )
i2b2.CRC.view.QT.temporalRelationships[i].populateClassicUI(i, eventNameMapping);
// redraw panel count
i2b2.CRC.ctrlr.QT._redrawPanelCount();
// scroll to show the first panel
i2b2.CRC.ctrlr.QT.doScrollFirst();
}
// refactoring: considers the main query panels as a subquery, as well as each 'event' of the temporal query.
// the main query panels are all in i2b2.CRC.mode.queryCurrent.panels[0]
this.getSubqueryXML = function( isTemporal, subQueryIndex, auto_query_name_len )
{
var s = "";
var ip = subQueryIndex;
//for (var ip = 0; ip < i2b2.CRC.model.queryCurrent.panels.length; ip++)
//{
panel_list = i2b2.CRC.model.queryCurrent.panels[ip]; //i2b2.CRC.ctrlr.QT.temporalGroup];
panel_cnt = panel_list.length;
var auto_query_name = '';
if (isTemporal && ip > 0)
{
//if equal to one than add subquery_contraint
if (ip == 1)
{
for (var tb = 0; tb <= this.tenporalBuilders; tb++)
{
s += '\t\n';
s += '\t\t\n';
s += '\t\t\t' + $('instancevent1[' + tb + ']').options[$('instancevent1[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\t' + $('preloc1[' + tb + ']').options[$('preloc1[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\t' + $('instanceopf1[' + tb + ']').options[$('instanceopf1[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t \n';
s += '\t\t' + $('postloc[' + tb + ']').options[$('postloc[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\n';
s += '\t\t\t' + $('instancevent2[' + tb + ']').options[$('instancevent2[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\t' + $('preloc2[' + tb + ']').options[$('preloc2[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\t' + $('instanceopf2[' + tb + ']').options[$('instanceopf2[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t \n';
if ($('bytime1[' + tb + ']').checked)
{
s += '\t\t\n';
s += '\t\t\t' + $('byspan1[' + tb + ']').options[$('byspan1[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\t' + $('bytimevalue1[' + tb + ']').value + ' \n';
s += '\t\t\t' + $('bytimeunit1[' + tb + ']').options[$('bytimeunit1[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t \n';
}
if ($('bytime2[' + tb + ']').checked)
{
s += '\t\t\n';
s += '\t\t\t' + $('byspan2[' + tb + ']').options[$('byspan2[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\t' + $('bytimevalue2[' + tb + ']').value + ' \n';
s += '\t\t\t' + $('bytimeunit2[' + tb + ']').options[$('bytimeunit2[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t \n';
}
s += '\t \n';
}
}
if (panel_list[0].items.length == 0)
return s;
s += '\n ';
s += 'Event ' + ip + ' \n';
s += 'EVENT \n';
s += 'Event ' + ip + ' \n';
s += 'SAMEINSTANCENUM \n';
s += '0 \n';
}
for (var p = 0; p < panel_cnt; p++)
{
if (panel_list[p].items.length > 0) {
s += '\t\n';
s += '\t\t' + (p + 1) + ' \n';
// date range constraints
//if (panel_list[p].dateFrom) {
// s += '\t\t'+panel_list[p].dateFrom.Year+'-'+padNumber(panel_list[p].dateFrom.Month,2)+'-'+padNumber(panel_list[p].dateFrom.Day,2)+'T00:00:00.000-05:00 \n';
//}
//if (panel_list[p].dateTo) {
// s += '\t\t'+panel_list[p].dateTo.Year+'-'+padNumber(panel_list[p].dateTo.Month,2)+'-'+padNumber(panel_list[p].dateTo.Day,2)+'T00:00:00.000-05:00 \n';
//}
s += "\t\t" + panel_list[p].relevance + " \n";
// Exclude constraint (invert flag)
if (panel_list[p].exclude) {
s += '\t\t1 \n';
} else {
s += '\t\t0 \n';
}
// Panel Timing
s += '\t\t' + panel_list[p].timing + ' \n';
// Occurs constraint
s += '\t\t' + ((panel_list[p].occurs * 1) + 1) + ' \n';
// Concepts
for (i = 0; i < panel_list[p].items.length; i++) { // BUG FIX: WEBCLIENT-153 (Added i2b2.h.Escape() to all names/tooltips)
var sdxData = panel_list[p].items[i];
if (sdxData.sdxInfo.sdxType =="WRKF")
break;
s += '\t\t- \n';
if (panel_list[p].items[i].dateFrom || panel_list[p].items[i].dateTo) { // BUG FIX: WEBCLIENT-136
s += '\t\t\t
\n';
if (panel_list[p].items[i].dateFrom) {
s += '\t\t\t\t' + panel_list[p].items[i].dateFrom.Year + '-' + padNumber(panel_list[p].items[i].dateFrom.Month, 2) + '-' + padNumber(panel_list[p].items[i].dateFrom.Day, 2) + 'T00:00:00.000-05:00 \n';
}
if (panel_list[p].items[i].dateTo) {
s += '\t\t\t\t' + panel_list[p].items[i].dateTo.Year + '-' + padNumber(panel_list[p].items[i].dateTo.Month, 2) + '-' + padNumber(panel_list[p].items[i].dateTo.Day, 2) + 'T00:00:00.000-05:00 \n';
}
s += '\t\t\t \n';
}
switch (sdxData.sdxInfo.sdxType) {
case "QM":
if (sdxData.origData.id.startsWith("masterid")) // BUG FIX: WEBCLIENT-149
s += '\t\t\t' + sdxData.origData.id + ' \n';
else
s += '\t\t\tmasterid:' + sdxData.origData.id + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.origData.title) + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.origData.name) + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
break;
case "PRS":
s += '\t\t\tpatient_set_coll_id:' + sdxData.sdxInfo.sdxKeyValue + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.sdxInfo.sdxDisplayName) + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.sdxInfo.sdxDisplayName) + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
break;
case "ENS":
s += '\t\t\tpatient_set_enc_id:' + sdxData.sdxInfo.sdxKeyValue + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.sdxInfo.sdxDisplayName) + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.sdxInfo.sdxDisplayName) + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
break;
case "PR":
s += '\t\t\tPATIENT:HIVE:' + sdxData.sdxInfo.sdxKeyValue + ' \n';
s += '\t\t\t' + sdxData.sdxInfo.sdxDisplayName + ' \n';
s += '\t\t\t' + sdxData.sdxInfo.sdxDisplayName + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
break;
default:
if (sdxData.origData.isModifier) {
var modParent = sdxData.origData.parent;
var level = sdxData.origData.level;
var key = sdxData.origData.parent.key;
var name = (sdxData.origData.parent.name != null ? i2b2.h.Escape(sdxData.origData.parent.name) : i2b2.h.Escape(sdxData.origData.name));
var tooltip = sdxData.origData.tooltip;
var itemicon = sdxData.origData.hasChildren;
while (modParent != null) {
if (modParent.isModifier) {
modParent = modParent.parent;
} else {
level = modParent.level;
key = modParent.key;
name = modParent.name;
tooltip = modParent.tooltip;
itemicon = modParent.hasChildren;
break;
}
}
s += '\t\t\t' + level + ' \n';
s += '\t\t\t' + key + ' \n';
s += '\t\t\t' + i2b2.h.Escape(name) + ' \n';
// (sdxData.origData.newName != null ? sdxData.origData.newName : sdxData.origData.name) + '\n';
s += '\t\t\t' + i2b2.h.Escape(tooltip) + ' \n';
s += '\t\t\t' + itemicon + ' \n';
s += '\t\t\tENC \n';
s += '\t\t\t\t\n';
s += '\t\t\t\t\t' + sdxData.origData.name + ' \n';
s += '\t\t\t\t\t' + sdxData.origData.applied_path + ' \n';
s += '\t\t\t\t\t' + sdxData.origData.key + ' \n';
if (sdxData.ModValues) {
s += this.getValues(sdxData.ModValues);
}
s += '\t\t\t\t \n';
} else {
sdxData.origData.key = (sdxData.origData.key).replace(/' + sdxData.origData.level + '\n';
//s += '\t\t\t' + (sdxData.origData.newName != null ? i2b2.h.Escape(sdxData.origData.newName) : i2b2.h.Escape(sdxData.origData.name)) + ' \n';
s += '\t\t\t' + (sdxData.origData.name != null ? i2b2.h.Escape(sdxData.origData.name) : i2b2.h.Escape(sdxData.origData.newName)) + ' \n';
s += '\t\t\t' + sdxData.origData.key + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.origData.tooltip) + ' \n'; // BUG FIX: WEBCLIENT-135 (Escape tooltip)
s += '\t\t\tENC \n';
s += '\t\t\t' + sdxData.origData.hasChildren + ' \n';
}
try {
var t = i2b2.h.XPath(sdxData.origData.xmlOrig, 'descendant::synonym_cd/text()');
t = (t[0].nodeValue == "Y");
} catch (e) {
var t = "false";
}
s += '\t\t\t' + t + ' \n';
if (sdxData.LabValues) {
//s += '\t\t\t\n';
s += this.getValues(sdxData.LabValues);
}
break;
}
//TODO add contraint to the item in the future
/*
s += '\t\t\t\n';
if (panel_list[p].dateFrom) {
s += '\t\t\t\t'+panel_list[p].dateFrom.Year+'-'+padNumber(panel_list[p].dateFrom.Month,2)+'-'+padNumber(panel_list[p].dateFrom.Day,2)+'Z \n';
}
if (panel_list[p].dateTo) {
s += '\t\t\t\t'+panel_list[p].dateTo.Year+'-'+padNumber(panel_list[p].dateTo.Month,2)+'-'+padNumber(panel_list[p].dateTo.Day,2)+'Z \n';
}
s += '\t\t\t \n';
*/
s += '\t\t \n';
if (i == 0) {
if (undefined != sdxData.origData.name) {
auto_query_name += sdxData.origData.name.substring(0, auto_query_name_len);
} else if (undefined != sdxData.origData.title) {
auto_query_name += sdxData.origData.title.substring(0, auto_query_name_len);
} else {
auto_query_name += "new query";
}
if (p < panel_cnt - 1) { auto_query_name += '-'; }
}
}
s += '\t \n';
}
}
if (isTemporal && ip > 0)
s += ' \n ';
return s;
};
// ================================================================================================== //
// CREATING XML for the query users have built. ======================================================//
// ================================================================================================== //
// Main entry to generating query XML. Decides which XML-generation subroutine to run based on UI states //
this._getQueryXML = function(queryName)
{
if (i2b2.CRC.view.QT.isShowingTemporalQueryUI && !i2b2.CRC.view.QT.isShowingClassicTemporalQueryUI)
return this._getSimpleTemporalQueryXML( queryName );
else
return this._getOtherQueryXML( queryName );
}
// tdw9 1707c: method to create XML from SIMPLE temporal query UI
this.makeQueryXMLFromTemporalQueryUI = function( queryName )
{
var xml = "";
// add population XML
var panel_list = i2b2.CRC.model.queryCurrent.panels[0]; //i2b2.CRC.ctrlr.QT.temporalGroup];
var panel_cnt = panel_list.length;
var auto_query_name_len = 15;
var auto_query_name = '';
if (this.queryTiming == "TEMPORAL") {
isTemporal = true;
}
if (panel_cnt > 0) {
auto_query_name_len = Math.floor(15/panel_cnt);
if (auto_query_name_len < 1) {auto_query_name_len = 1;}
}
xml += this.getSubqueryXML(true, 0, auto_query_name_len); // build the population part of the query
// add temporal XML
var events = jQuery(".temporalEvent");
for ( var i = 0; i < i2b2.CRC.view.QT.temporalRelationships.length; i++ )
xml = xml + i2b2.CRC.view.QT.temporalRelationships[i].makeXML();
for ( var i = 0; i < events.length; i++ )
xml = xml + jQuery(events[i]).data("event").makeXML();
return xml;
};
// go through each event and grab the first concept's name, cutDown to size, and concatanate
this.makeAutoQueryNameForTemporalQueryUI = function()
{
var autoQueryName = "";
var auto_query_name_len = 15;
var events = jQuery(".temporalEvent");
var populationPanels = i2b2.CRC.model.queryCurrent.panels[0];
var nameParts = Math.max(1,populationPanels.length);
auto_query_name_len = Math.floor(15/nameParts);
if (auto_query_name_len < 1) {auto_query_name_len = 1;}
// build the population portion of the query name
for (var i = 0; i < populationPanels.length; i++ )
{
var sdxData = populationPanels[i].items[0];
if (populationPanels[i].items.length > 0) {
if (undefined != sdxData.origData.name)
autoQueryName += sdxData.origData.name.substring(0,auto_query_name_len);
else if (undefined != sdxData.origData.title)
autoQueryName += sdxData.origData.title.substring(0,auto_query_name_len);
else
autoQueryName += "new query";
if ( i < populationPanels.length-1)
autoQueryName += "-";
}
}
// build the temporal event portion of the query name
for ( var i = 0; i < events.length; i++ )
{
var sdxData = jQuery(events[i]).data("event").panels[0].items[0];
if (undefined != sdxData.origData.name)
autoQueryName += sdxData.origData.name.substring(0,auto_query_name_len);
else if (undefined != sdxData.origData.title)
autoQueryName += sdxData.origData.title.substring(0,auto_query_name_len);
else
autoQueryName += "new query";
}
return autoQueryName;
};
// SIMPLE TEMPORAL QUERY //
// tdw9 1707c: 1. clear UI of empty events and 2.invoke method to create XML based on new temporal query UI
this._getSimpleTemporalQueryXML = function(queryName)
{
i2b2.CRC.view.QT.deleteEmptyEvents();
var xml = "\n" +
"\t(t) " + queryName + " \n" +
"\tANY \n" +
"\t0 \n";
if (i2b2.PM.model.shrine_domain)
xml += '\t1 \n';
xml += this.makeQueryXMLFromTemporalQueryUI( queryName );
xml += " \n";
this.queryMsg = {};
this.queryMsg.queryAutoName = this.makeAutoQueryNameForTemporalQueryUI();
if (undefined === queryName)
this.queryMsg.queryName = this.queryNameDefault;
else
this.queryMsg.queryName = queryName;
this.queryMsg.queryXML = xml;
return (this.queryMsg);
};
// tdw9 1707c: ALL OTHER QUERIES //
this._getOtherQueryXML = function(queryName)
{
//var returnError = {};
var i;
var isTemporal = false;
var el;
var concept;
var panel_list = i2b2.CRC.model.queryCurrent.panels[0]; //i2b2.CRC.ctrlr.QT.temporalGroup];
var panel_cnt = panel_list.length;
var auto_query_name_len = 15;
var auto_query_name = '';
if (this.queryTiming == "TEMPORAL") {
isTemporal = true;
}
if (panel_cnt > 0) {
auto_query_name_len = Math.floor(15/panel_cnt);
if (auto_query_name_len < 1) {auto_query_name_len = 1;}
}
// build Query XML
var s = '\n';
if (isTemporal)
{
queryName = '(t) ' + queryName;
}
s += '\t' + i2b2.h.Escape(queryName) + ' \n';
if (this.queryTiming == "SAMEVISIT")
{
s += '\tSAMEVISIT \n';
} else if (this.queryTiming == "ANY") {
s += '\tANY \n';
} else if (this.queryTiming == "TEMPORAL") {
s += '\tANY \n';
} else {
s += '\tSAMEINSTANCENUM \n';
}
s += '\t0 \n';
if (i2b2.PM.model.shrine_domain) { s += '\t1 \n'; }
for (var ip = 0; ip < i2b2.CRC.model.queryCurrent.panels.length; ip++)
{
panel_list = i2b2.CRC.model.queryCurrent.panels[ip]; //i2b2.CRC.ctrlr.QT.temporalGroup];
panel_cnt = panel_list.length;
if (isTemporal && ip > 0)
{
//if equal to one then add subquery_contraint
if (ip == 1)
{
for (var tb=0; tb <= this.tenporalBuilders; tb++) {
s += '\t\n';
s += '\t\t\n';
s += '\t\t\t' + $('instancevent1[' + tb + ']').options[$('instancevent1[' + tb + ']').selectedIndex].text + ' \n';
s += '\t\t\t' + $('preloc1[' + tb + ']').options[$('preloc1[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\t' + $('instanceopf1[' + tb + ']').options[$('instanceopf1[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t \n';
s += '\t\t' + $('postloc[' + tb + ']').options[$('postloc[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\n';
s += '\t\t\t' + $('instancevent2[' + tb + ']').options[$('instancevent2[' + tb + ']').selectedIndex].text + ' \n';
s += '\t\t\t' + $('preloc2[' + tb + ']').options[$('preloc2[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\t' + $('instanceopf2[' + tb + ']').options[$('instanceopf2[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t \n';
if ( $('bytime1[' + tb + ']').checked)
{
s += '\t\t\n';
s += '\t\t\t' + $('byspan1[' + tb + ']').options[$('byspan1[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\t' + $('bytimevalue1[' + tb + ']').value + ' \n';
s += '\t\t\t' + $('bytimeunit1[' + tb + ']').options[$('bytimeunit1[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t \n';
}
if ( $('bytime2[' + tb + ']').checked)
{
s += '\t\t\n';
s += '\t\t\t' + $('byspan2[' + tb + ']').options[$('byspan2[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t\t' + $('bytimevalue2[' + tb + ']').value + ' \n';
s += '\t\t\t' + $('bytimeunit2[' + tb + ']').options[$('bytimeunit2[' + tb + ']').selectedIndex].value + ' \n';
s += '\t\t \n';
}
s += '\t \n';
}
}
if (panel_list[0].items.length == 0)
break;
s += '\n ';
s += 'Event '+ ip +' \n';
s += 'EVENT \n';
s += 'Event '+ ip +' \n';
s += 'SAMEINSTANCENUM \n';
s += '0 \n';
}
for (var p = 0; p < panel_cnt; p++) {
if ( panel_list[p].items.length> 0) {
s += '\t\n';
s += '\t\t' + (p+1) + ' \n';
// date range constraints
//if (panel_list[p].dateFrom) {
// s += '\t\t'+panel_list[p].dateFrom.Year+'-'+padNumber(panel_list[p].dateFrom.Month,2)+'-'+padNumber(panel_list[p].dateFrom.Day,2)+'T00:00:00.000-05:00 \n';
//}
//if (panel_list[p].dateTo) {
// s += '\t\t'+panel_list[p].dateTo.Year+'-'+padNumber(panel_list[p].dateTo.Month,2)+'-'+padNumber(panel_list[p].dateTo.Day,2)+'T00:00:00.000-05:00 \n';
//}
s += "\t\t" + panel_list[p].relevance + " \n";
// Exclude constraint (invert flag)
if (panel_list[p].exclude) {
s += '\t\t1 \n';
} else {
s += '\t\t0 \n';
}
// Panel Timing
s += '\t\t' + panel_list[p].timing + ' \n';
// Occurs constraint
s += '\t\t'+((panel_list[p].occurs*1)+1)+' \n';
// Concepts
for (i=0; i < panel_list[p].items.length; i++) { // BUG FIX: WEBCLIENT-153 (Added i2b2.h.Escape() to all names/tooltips)
var sdxData = panel_list[p].items[i];
if (sdxData.origData.parent == undefined || sdxData.origData.parent.encapType == undefined || sdxData.origData.parent.encapType != "FOLDER") {
s += '\t\t- \n';
if(panel_list[p].items[i].dateFrom || panel_list[p].items[i].dateTo){ // BUG FIX: WEBCLIENT-136
s += '\t\t\t
\n';
if (panel_list[p].items[i].dateFrom) {
s += '\t\t\t\t'+panel_list[p].items[i].dateFrom.Year+'-'+padNumber(panel_list[p].items[i].dateFrom.Month,2)+'-'+padNumber(panel_list[p].items[i].dateFrom.Day,2)+'T00:00:00.000-05:00 \n';
}
if (panel_list[p].items[i].dateTo) {
s += '\t\t\t\t'+panel_list[p].items[i].dateTo.Year+'-'+padNumber(panel_list[p].items[i].dateTo.Month,2)+'-'+padNumber(panel_list[p].items[i].dateTo.Day,2)+'T00:00:00.000-05:00 \n';
}
s += '\t\t\t \n';
}
switch(sdxData.sdxInfo.sdxType) {
case "QM":
if(sdxData.origData.id.startsWith("masterid")) // BUG FIX: WEBCLIENT-149
s += '\t\t\t' + sdxData.origData.id + ' \n';
else
s += '\t\t\tmasterid:' + sdxData.origData.id + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.origData.title) + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.origData.name) + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
break;
case "PRS":
s += '\t\t\tpatient_set_coll_id:' + sdxData.sdxInfo.sdxKeyValue + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.sdxInfo.sdxDisplayName) + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.sdxInfo.sdxDisplayName) + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
break;
case "PR":
s += '\t\t\tPATIENT:HIVE:' + sdxData.sdxInfo.sdxKeyValue + ' \n';
s += '\t\t\t' + sdxData.sdxInfo.sdxDisplayName + ' \n';
s += '\t\t\t' + sdxData.sdxInfo.sdxDisplayName + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
break;
case "WRKF_OLD":
var varInput = {
parent_key_value: sdxData.sdxInfo.sdxKeyValue,
result_wait_time: 180
};
var results = i2b2.WORK.ajax.getChildren("WORK:Workplace", varInput );
var nlst = i2b2.h.XPath(results.refXML, "//folder[name and work_xml and share_id and index and visual_attributes]");
for (var i = 0; i < nlst.length; i++) {
if (i != 0)
{
s += '\t\t \n';
if (i != nlst.length)
s += '\t\t- \n';
}
if (i2b2.h.getXNodeVal(nlst[i], "work_xml_i2b2_type") == 'CONCEPT') {
var work_xml= i2b2.h.XPath(nlst[i], "work_xml/descendant::concept/..");
for (var j=0; j < work_xml.length; j++) {
if (i2b2.h.getXNodeVal(work_xml[j], "level") != "undefined") {
s += '\t\t\t
' + i2b2.h.getXNodeVal(work_xml[j], "level") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "name") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "key") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "tooltip") + ' \n';
s += '\t\t\tENC \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "visualattributes") + ' \n';
try {
var t = i2b2.h.XPath(work_xml[j],'descendant::synonym_cd/text()');
t = (t[0].nodeValue=="Y");
} catch(e) {
var t = "false";
}
s += '\t\t\t'+t+' \n';
}
}
} else if (i2b2.h.getXNodeVal(nlst[i], "work_xml_i2b2_type") == 'PATIENT') {
var work_xml= i2b2.h.XPath(nlst[i], "work_xml/descendant::patient/..");
for (var j=0; j < work_xml.length; j++) {
if (i2b2.h.getXNodeVal(work_xml[j], "patient_id") != "undefined") {
s += '\t\t\tPATIENT:HIVE:' + i2b2.h.getXNodeVal(work_xml[j], "patient_id") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "patient_id") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "patient_id") + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
}
}
} else if (i2b2.h.getXNodeVal(nlst[i], "work_xml_i2b2_type") == 'PREV_QUERY') {
var work_xml= i2b2.h.XPath(nlst[i], "work_xml");
for (var j=0; j < work_xml.length; j++) {
if (i2b2.h.getXNodeVal(work_xml[j], "query_master_id") != "undefined") {
s += '\t\t\tmasterid:' + i2b2.h.getXNodeVal(work_xml[j], "query_master_id") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "name") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "name") + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
}
}
} else if (i2b2.h.getXNodeVal(nlst[i], "work_xml_i2b2_type") == 'PATIENT_COLL') {
var work_xml= i2b2.h.XPath(nlst[i], "work_xml");
for (var j=0; j < work_xml.length; j++) {
if (i2b2.h.getXNodeVal(work_xml[j], "result_instance_id") != "undefined") {
s += '\t\t\tpatient_set_col_id:' + i2b2.h.getXNodeVal(work_xml[j], "result_instance_id") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "description") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "description") + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
}
}
} else if (i2b2.h.getXNodeVal(nlst[i], "work_xml_i2b2_type") == 'ENCOUNTER_COLL') {
var work_xml= i2b2.h.XPath(nlst[i], "work_xml");
for (var j=0; j < work_xml.length; j++) {
if (i2b2.h.getXNodeVal(work_xml[j], "result_instance_id") != "undefined") {
s += '\t\t\tencounter_set_col_id:' + i2b2.h.getXNodeVal(work_xml[j], "result_instance_id") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "description") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "description") + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
}
}
}
}
break;
case "ENS":
s += '\t\t\tpatient_set_enc_id:' + sdxData.sdxInfo.sdxKeyValue + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.sdxInfo.sdxDisplayName) + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.sdxInfo.sdxDisplayName) + ' \n';
s += '\t\t\tfalse \n';
s += '\t\t\t0 \n';
break;
default:
if (sdxData.origData.isModifier) {
var modParent = sdxData.origData.parent;
var level = sdxData.origData.level;
var key = sdxData.origData.parent.key;
var name = (sdxData.origData.parent.name != null ? i2b2.h.Escape(sdxData.origData.parent.name) : i2b2.h.Escape(sdxData.origData.name)) ;
var tooltip = sdxData.origData.tooltip;
var itemicon = sdxData.origData.hasChildren;
while (modParent != null)
{
if (modParent.isModifier)
{
modParent = modParent.parent;
} else {
level = modParent.level;
key = modParent.key;
name = modParent.name;
tooltip = modParent.tooltip;
itemicon = modParent.hasChildren;
break;
}
}
s += '\t\t\t' + level + ' \n';
s += '\t\t\t' + i2b2.h.Escape(key) + ' \n';
s += '\t\t\t' + i2b2.h.Escape(name) + ' \n';
// (sdxData.origData.newName != null ? sdxData.origData.newName : sdxData.origData.name) + '\n';
s += '\t\t\t' + i2b2.h.Escape(tooltip) + ' \n';
s += '\t\t\t' + itemicon + ' \n';
s += '\t\t\tENC \n';
s += '\t\t\t\t\n';
s += '\t\t\t\t\t' + sdxData.origData.name + ' \n';
s += '\t\t\t\t\t' + sdxData.origData.applied_path + ' \n';
s += '\t\t\t\t\t' + sdxData.origData.key + ' \n';
if (sdxData.ModValues)
{
s += this.getValues( sdxData.ModValues);
}
s += '\t\t\t\t \n';
} else {
s += '\t\t\t' + sdxData.origData.level + ' \n';
//s += '\t\t\t' + (sdxData.origData.newName != null ? i2b2.h.Escape(sdxData.origData.newName) : i2b2.h.Escape(sdxData.origData.name)) + ' \n';
s += '\t\t\t' + (sdxData.origData.name != null ? i2b2.h.Escape(sdxData.origData.name) : i2b2.h.Escape(sdxData.origData.newName)) + ' \n';
s += '\t\t\t' + i2b2.h.Escape(sdxData.origData.key) + ' \n'; // BUG FIX: WEBCLIENT-227
s += '\t\t\t' + i2b2.h.Escape(sdxData.origData.tooltip) + ' \n'; // BUG FIX: WEBCLIENT-135 (Escape tooltip)
s += '\t\t\tENC \n';
s += '\t\t\t' + sdxData.origData.hasChildren + ' \n';
}
try {
var t = i2b2.h.XPath(sdxData.origData.xmlOrig,'descendant::synonym_cd/text()');
t = (t[0].nodeValue=="Y");
} catch(e) {
var t = "false";
}
s += '\t\t\t'+t+' \n';
if (sdxData.LabValues) {
//s += '\t\t\t\n';
s += this.getValues( sdxData.LabValues);
}
break;
}
//TODO add contraint to the item in the future
/*
s += '\t\t\t\n';
if (panel_list[p].dateFrom) {
s += '\t\t\t\t'+panel_list[p].dateFrom.Year+'-'+padNumber(panel_list[p].dateFrom.Month,2)+'-'+padNumber(panel_list[p].dateFrom.Day,2)+'Z \n';
}
if (panel_list[p].dateTo) {
s += '\t\t\t\t'+panel_list[p].dateTo.Year+'-'+padNumber(panel_list[p].dateTo.Month,2)+'-'+padNumber(panel_list[p].dateTo.Day,2)+'Z \n';
}
s += '\t\t\t \n';
*/
s += '\t\t \n';
if (i==0) {
if (undefined != sdxData.origData.name) {
auto_query_name += sdxData.origData.name.substring(0,auto_query_name_len);
} else if (undefined != sdxData.origData.title) {
auto_query_name += sdxData.origData.title.substring(0,auto_query_name_len);
} else {
auto_query_name += "new query";
}
if (p < panel_cnt-1) {auto_query_name += '-';}
}
}
}
s += '\t \n';
}
}
if (isTemporal && ip > 0)
{
s += ' \n ';
}
if (isTemporal == false)
{
break;
}
}
s += ' \n';
this.queryMsg = {};
this.queryMsg.queryAutoName = auto_query_name;
if (undefined===queryName) {
this.queryMsg.queryName = this.queryNameDefault;
} else {
this.queryMsg.queryName = queryName;
}
this.queryMsg.queryXML = s;
return(this.queryMsg);
};
// ================================================================================================== //
// END routines for generating query XML ============================================================ //
// ================================================================================================== //
this.getValues = function(lvd) {
var s = '\t\t\t\n';
//var lvd = sdxData.LabValues;
switch(lvd.MatchBy) {
case "FLAG":
s += '\t\t\t\tFLAG \n';
s += '\t\t\t\tEQ \n';
s += '\t\t\t\t'+i2b2.h.Escape(lvd.ValueFlag)+' \n';
break;
case "VALUE":
if (lvd.GeneralValueType=="ENUM") {
var sEnum = [];
for (var i2=0;i2TEXT\n';
s += '\t\t\t\t'+sEnum+' \n';
s += '\t\t\t\tIN \n';
} else if ((lvd.GeneralValueType=="STRING") || (lvd.GeneralValueType=="TEXT")){
s += '\t\t\t\tTEXT \n';
s += '\t\t\t\t'+lvd.StringOp+' \n';
s += '\t\t\t\t \n';
} else if (lvd.GeneralValueType=="LARGESTRING") {
if (lvd.DbOp) {
s += '\t\t\t\tCONTAINS[database] \n';
} else {
s += '\t\t\t\tCONTAINS \n';
}
s += '\t\t\t\tLARGETEXT \n';
s += '\t\t\t\t \n';
} else {
s += '\t\t\t\t'+lvd.GeneralValueType+' \n';
s += '\t\t\t\t'+lvd.UnitsCtrl+' \n';
s += '\t\t\t\t'+lvd.NumericOp+' \n';
if (lvd.NumericOp == 'BETWEEN') {
s += '\t\t\t\t'+i2b2.h.Escape(lvd.ValueLow)+' and '+i2b2.h.Escape(lvd.ValueHigh)+' \n';
} else {
s += '\t\t\t\t'+i2b2.h.Escape(lvd.Value)+' \n';
}
}
break;
case "":
break;
}
s += '\t\t\t \n';
return s;
}
this.getWorkplaceFolder = function(folder_id) {
var s = '';
var scopedCallback = new i2b2_scopedCallback();
scopedCallback.scope = i2b2.WORK;
scopedCallback.callback = function(results){
i2b2.WORK.view.main.queryResponse = results.msgResponse;
i2b2.WORK.view.main.queryRequest = results.msgRequest;
// var cl_yuiCallback = onCompleteCallback;
var nlst = i2b2.h.XPath(results.refXML, "//folder[name and work_xml and share_id and index and visual_attributes]");
for (var i = 0; i < nlst.length; i++) {
var work_xml= i2b2.h.XPath(nlst[i], "work_xml/descendant::concept/..");//[0].childNodes;
if (i != 0)
{
s += '\t\t\n';
if (i != nlst.length)
s += '\t\t- \n';
}
if (i2b2.h.getXNodeVal(nlst[i], "work_xml_i2b2_type") == 'CONCEPT') {
for (var j=0; j < work_xml.length; j++) {
if (i2b2.h.getXNodeVal(work_xml[j], "level") != "undefined") {
s += '\t\t\t
' + i2b2.h.getXNodeVal(work_xml[j], "level") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "name") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "key") + ' \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "tooltip") + ' \n';
s += '\t\t\tENC \n';
s += '\t\t\t' + i2b2.h.getXNodeVal(work_xml[j], "visualattributes") + ' \n';
try {
var t = i2b2.h.XPath(work_xml[j],'descendant::synonym_cd/text()');
t = (t[0].nodeValue=="Y");
} catch(e) {
var t = "false";
}
s += '\t\t\t'+t+' \n';
}
}
}
// var tmpNode = i2b2.WORK.view.main._generateTvNode(nodeData.name, nodeData, cl_tvParentNode);
}
return s;
};
var varInput = {
parent_key_value: folder_id,
result_wait_time: 180
};
i2b2.WORK.ajax.getChildren("WORK:Workplace", varInput, scopedCallback);
//return s;
}
// ================================================================================================== //
this.panelAdd = function(yuiTree) {
// this function is used to create a new panel, it initializes the data structure in the
if (!i2b2.CRC.model.queryCurrent.panels) {
i2b2.CRC.model.queryCurrent.panels = [];
i2b2.CRC.model.queryCurrent.panels[0] = new Array();
i2b2.CRC.model.queryCurrent.panels[1] = new Array();
i2b2.CRC.model.queryCurrent.panels[2] = new Array();
// i2b2.CRC.model.queryCurrent.panels = new Array(new Array());
}
var dm = i2b2.CRC.model.queryCurrent;
var pi = dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup].length;
if (pi == undefined)
{
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup] = new Array();
pi = 0;
}
var tTiming = i2b2.CRC.ctrlr.QT.queryTiming;
if ((tTiming == "TEMPORAL") && (i2b2.CRC.ctrlr.QT.temporalGroup > 0))
tTiming = "SAMEINSTANCENUM";
if ((tTiming == "TEMPORAL") && (i2b2.CRC.ctrlr.QT.temporalGroup == 0))
tTiming = "ANY";
// setup the data model for this panel
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi] = {};
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].dateTo = false;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].dateFrom = false;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].exclude = false;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].occurs = '0';
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].relevance = '100';
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].timing = tTiming; // i2b2.CRC.ctrlr.QT.queryTiming; //'ANY';
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].items = [];
// create a treeview root node and connect it to the treeview controller
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].tvRootNode = new YAHOO.widget.RootNode(this.yuiTree);
yuiTree.root = dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].tvRootNode;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].tvRootNode.tree = yuiTree;
yuiTree.setDynamicLoad(i2b2.CRC.ctrlr.QT._loadTreeDataForNode,1);
if (dm.panels.length == 1)
{
var tTiming = i2b2.CRC.ctrlr.QT.queryTiming;
if (i2b2.CRC.ctrlr.QT.queryTiming == "TEMPORAL")
tTiming = "ANY";
i2b2.CRC.ctrlr.QT.temporalGroup = 1;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup] = {};
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi] = {};
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].dateTo = false;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].dateFrom = false;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].exclude = false;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].occurs = '0';
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].relevance = '100';
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].timing = tTiming; //i2b2.CRC.ctrlr.QT.queryTiming; //'ANY';
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].items = [];
// create a treeview root node and connect it to the treeview controller
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].tvRootNode = new YAHOO.widget.RootNode(this.yuiTree);
yuiTree.root = dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].tvRootNode;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].tvRootNode.tree = yuiTree;
yuiTree.setDynamicLoad(i2b2.CRC.ctrlr.QT._loadTreeDataForNode,1);
i2b2.CRC.ctrlr.QT.temporalGroup = 2;
if (i2b2.CRC.ctrlr.QT.queryTiming == "TEMPORAL")
tTiming = "SAMEINSTANCENUM";
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup] = {};
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi] = {};
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].dateTo = false;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].dateFrom = false;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].exclude = false;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].occurs = '0';
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].relevance = '100';
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].timing = tTiming; //i2b2.CRC.ctrlr.QT.queryTiming; //'ANY';
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].items = [];
// create a treeview root node and connect it to the treeview controller
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].tvRootNode = new YAHOO.widget.RootNode(this.yuiTree);
yuiTree.root = dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].tvRootNode;
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi].tvRootNode.tree = yuiTree;
yuiTree.setDynamicLoad(i2b2.CRC.ctrlr.QT._loadTreeDataForNode,1);
i2b2.CRC.ctrlr.QT.temporalGroup = 0;
}
// update the count on the GUI
this._redrawPanelCount();
// return a reference to the new panel object
this.doSetQueryName.call(this,'');
return dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup][pi];
}
// ================================================================================================== //
this._loadTreeDataForNode = function(node, onCompleteCallback) {
i2b2.sdx.Master.LoadChildrenFromTreeview(node, onCompleteCallback);
}
// ================================================================================================== //
this.ToggleNode = function(divTarg, divTreeID) {
// get the i2b2 data from the yuiTree node
var tvTree = YAHOO.widget.TreeView.findTreeByChildDiv(divTarg); // this is a custom extention found in "hive_helpers.js"
var tvNode = tvTree.getNodeByProperty('nodeid', divTarg.id);
tvNode.toggle();
}
// ================================================================================================== //
this.panelDelete = function(index) {
// alter the data model's panel elements
var dm = i2b2.CRC.model.queryCurrent;
if(index <0 || index>=dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup].length) { return false;}
dm.panels[i2b2.CRC.ctrlr.QT.temporalGroup].splice(index,1);
// redraw the panels
this.doShowFrom(this.panelControllers[0].panelCurrentIndex);
// BUG FIX: force the panels to fully reattach the yuiRootNode to the controllers
for (var i=0; i 0) {
if (index_offset+i <= i2b2.CRC.model.queryCurrent.panels[i2b2.CRC.ctrlr.QT.temporalGroup].length) {
$('queryBalloonAnd'+(i)).style.display = 'block';
} else {
$('queryBalloonAnd'+(i)).style.display = 'none';
}
}
}
this._redrawScrollBtns();
}
// ================================================================================================== //
this._redrawAllPanels = function() {
$('infoQueryStatusText').innerHTML = "";
for (var i=0; i<3; i++) {
this.panelControllers[i].doRedraw();
if (i > 0) {
if (this.panelControllers[i].panelCurrentIndex-1 < i2b2.CRC.model.queryCurrent.panels[i2b2.CRC.ctrlr.QT.temporalGroup].length) {
$('queryBalloonAnd'+(i)).style.display = 'block';
} else {
$('queryBalloonAnd'+(i)).style.display = 'none';
}
}
}
}
// ================================================================================================== //
this._redrawPanelCount = function() {
var c = i2b2.CRC.model.queryCurrent.panels[i2b2.CRC.ctrlr.QT.temporalGroup].length;
if (c == 1) {
var s = '1 Group';
} else {
var s = c + ' Groups';
}
$('groupCount').innerHTML = s;
}
// ================================================================================================== //
this.laodQueryStatus = function( queryMasterId, queryName) {
var QRS = {};
var newHTML = "";
var qi_id = "";
$('infoQueryStatusText').innerHTML = "";
var scopedCallbackQI = new i2b2_scopedCallback();
scopedCallbackQI.scope = this;
scopedCallbackQI.callback = function(results) {
if (results.error) {
alert(results.errorMsg);
return;
} else {
// find our query instance
var qi_list = results.refXML.getElementsByTagName('query_instance');
var l = qi_list.length;
for (var i=0; i";
start_date = new Date(start_date.substring(0,4), start_date.substring(5,7)-1, start_date.substring(8,10), start_date.substring(11,13), start_date.substring(14,16),start_date.substring(17,19),start_date.substring(20,23));
}
var end_date = i2b2.h.XPath(temp, 'descendant-or-self::end_date')[0].firstChild.nodeValue;
var endDateElem = "";
if (!Object.isUndefined(end_date)) {
//alert(sDate.substring(0,4) + ":" + sDate.substring(5,7) + ":" + sDate.substring(8,10));
endDateElem = " "; // Query Report BG
end_date = new Date(end_date.substring(0,4), end_date.substring(5,7)-1, end_date.substring(8,10), end_date.substring(11,13),end_date.substring(14,16), end_date.substring(17,19), end_date.substring(20,23));
}
$('infoQueryStatusText').innerHTML = 'Finished Query: "'+queryName+'"
';
$('infoQueryStatusText').innerHTML += '
['+ (Math.floor((end_date - start_date)/100))/10 +' secs]
'+ startDateElem + endDateElem;
// $('infoQueryStatusText').innerHTML += 'Finished Query: "'+queryName+'"
Compute Time: ' + (Math.floor((end_date - start_date)/100))/10 + ' secs
';
i2b2.CRC.ajax.getQueryResultInstanceList_fromQueryInstanceId("CRC:QueryTool", {qi_key_value: qi_id}, scopedCallbackQRS);
}
}
}
// this is a private function that is used by all QueryStatus object instances to check their status
// this is mostly used for display for previous queries when they are dragged over
// callback processor to check the Query Instance
var scopedCallbackQRSI = new i2b2_scopedCallback();
scopedCallbackQRSI.scope = this;
scopedCallbackQRSI.callback = function(results) {
//var sCompiledResultsTest = ""; // snm0 - this is the text for the graph display
if (results.error) {
alert(results.errorMsg);
return;
} else {
// find our query instance
var ri_list = results.refXML.getElementsByTagName('query_result_instance');
var l = ri_list.length;
for (var i=0; i
" + description + " ";
i2b2.CRC.ctrlr.QT.sCompiledResultsTest += description + '\n'; //snm0
}
var crc_xml = results.refXML.getElementsByTagName('crc_xml_result');
l = crc_xml.length;
for (var i=0; i" + params[i2].getAttribute("column") + ": " + value + "