' + qriObj.description + ' "' +self.QM.name+ '"
';
//if there was an error display it.
if((qriObj.statusName == "ERROR") || (qriObj.statusName == "UNAVAILABLE")){
+ // placeholder
var errorObj = {
shortDescription: "Desination site was unable to translate SHRINE query term to local ontology.",
stackTrace: "Error mapping query terms from" +
" network to local forms. request:" +
"RunQueryRequest(I2B2_PROJECT_NAME,180000 milliseconds,"+
"AuthenticationInfo(*****,****,Credential(******,false)),"+
"QUERY_ID,None,Set(PATIENT_COUNT_XML)," +
"QueryDefinition(QUERY_NAME,Some(" +
"Term(\\PROJECT\\AND\\CONCEPT\\PATH\\OF\\UNMAPPED\\TERM),"+
"Some(ANY),None,None,None,List())))",
longDescription:
'The site responding to the query does not understand how to map the SHRINE query term it was given to its own local i2b2 term.)',
wikiUrl:
'https://open.med.harvard.edu/wiki/display/SHRINETEAM/Error+Types+for+Improved+Error+Messaging'
};
errorObjects.push(errorObj);
- self.dispDIV.innerHTML += "
" + errorObj.shortDescription + "";
+ self.dispDIV.innerHTML += " -
" + errorObj.shortDescription + "";
continue;
}
else if((qriObj.statusName == "PROCESSING")){
self.dispDIV.innerHTML += " -
Still Processing Request";
continue;
}
else if(["COMPLETED","FINISHED"].indexOf(qriObj.statusName) < 0){
self.dispDIV.innerHTML += " -
Results not available";
continue;
}
self.dispDIV.innerHTML += "
"
+ "Patient Count"
+ ": "
+ getObfuscatedResult(qriObj.setSize, 10)
+ "
";
//grab breakdown data.
brdNodeList = i2b2.h.XPath(qriNode, 'descendant-or-self::breakdown_data/column');
for(brdIdx = 0; brdIdx < brdNodeList.length; brdIdx ++){
//init brd vars.
brdNode = brdNodeList[brdIdx];
brdObj = parseBreakdown(brdNode);
if(brdObj.parentResultType !== breakdownType){
breakdownType = brdObj.parentResultType;
self.dispDIV.innerHTML += "
"
+ getBreakdownTitle(brdObj.parentResultType)
+ ":
";
self.dispDIV.innerHTML += "
";
}
self.dispDIV.innerHTML += "
"
+ brdObj.name
+ ": "
+ getObfuscatedResult(brdObj.value, 10)
+ "
";
}
}
createErrorDialogue(self.dispDIV, errorObjects);
i2b2.CRC.ctrlr.history.Refresh();
}
/**
* Scope for error dialog.
*/
function createErrorDialogue (container, errorObjects) {
// -- no errors abandon ship! -- //
if(errorObjects.length < 1) {
return;
}
var anchors, btnExpand, btnContract, errObjects = errorObjects, errorData;
//this sets up the events.
anchors = container.getElementsByClassName('query-error-anchor');
if(anchors.length == 0) {
return;
}
addAnchorEvents();
function expandErrorDetailDiv (ev) {
btnExpand.style.display = 'none';
btnContract.style.display = 'inline';
document.getElementById('errorDetailDiv').style.height = '200px';
- $('errorDetailDiv').innerHTML = '
' +errorData.shortDescription + '
' +
- errorData.longDescription + '
' +
- errorData.stackTrace + '
Click here for more information.';
+ $('errorDetailDiv').innerHTML = 'Name:
' +errorData.shortDescription + '
' +
+ 'Description:
' + errorData.longDescription + '
' +
+ 'Technical Details:
' + errorData.stackTrace + '
' +
+ '';
}
function retractErrorDetailDiv (ev) {
btnExpand.style.display = 'inline';
btnContract.style.display = 'none';
document.getElementById('errorDetailDiv').style.height = '80px';
- $('errorDetailDiv').innerHTML = '' +errorData.shortDescription + '
' +
- errorData.longDescription + '
'
+ $('errorDetailDiv').innerHTML = 'Name:
' +errorData.shortDescription + '
' +
+ 'Description:
' + errorData.longDescription + '
'
}
function onClick(event) {
event.preventDefault();
errorData = event.currentTarget.__errorData__;
btnExpand = document.getElementById('btnExpandErrorDetail');
btnContract = document.getElementById('btnContractErrorDetail');
// -- add event listeners for expand and contract as well --//
btnExpand.addEventListener('click', expandErrorDetailDiv, false);
btnContract.addEventListener('click', retractErrorDetailDiv, false);
showErrorDetail(errorData);
}
function showErrorDetail(detailObj) {
var handleCancel = function() {
this.cancel();
removeAllEvents();
retractErrorDetailDiv();
};
var dialogErrorDetail = new YAHOO.widget.SimpleDialog("dialogErrorDetail", {
width: "820px",
fixedcenter: true,
constraintoviewport: true,
modal: true,
zindex: 700,
buttons: [ {
text: "Done",
handler: handleCancel,
isDefault: true
}]
});
dialogErrorDetail._doClose = function (e) {
e.preventDefault();
this.cancel();
removeAllEvents();
retractErrorDetailDiv();
}
$('dialogErrorDetail').show();
dialogErrorDetail.validate = function(){
return true;
};
dialogErrorDetail.render(document.body);
// / display the dialoge
dialogErrorDetail.center();
dialogErrorDetail.show();
- $('errorDetailDiv').innerHTML = '' + errorData.shortDescription + '';
+ $('errorDetailDiv').innerHTML = 'Name:
' + errorData.shortDescription + '
';
}
function addAnchorEvents () {
var el, length = anchors.length;
// -- will need to iterate over these once they are created and add event listeners.
for(var i = 0; i < length; i ++) {
var el = anchors[i];
el.__errorData__ = errorObjects[i];
el.addEventListener('click', onClick, false);
}
}
function removeAllEvents () {
btnExpand.removeEventListener('click', expandErrorDetailDiv);
btnContract.removeEventListener('click', retractErrorDetailDiv);
}
}
/**
*
* @param qriNode
* @returns {{qiStatusName: string, qiStatusDescription: string, qiSetSize: string, qiDescription: string, qiResultName: string, qiResultDescription: string}}
*/
function parseQueryResultInstance(qriNode){
var qriObj = {
statusName: grabXmlNodeData(qriNode, 'descendant-or-self::query_status_type/name'),
statusDescription: grabXmlNodeData(qriNode, 'descendant-or-self::query_status_type/description'),
description: grabXmlNodeData(qriNode, 'descendant-or-self::description')
};
if(qriObj.statusName == "ERROR"){
return qriObj;
}
qriObj.setSize = grabXmlNodeData(qriNode, 'descendant-or-self::set_size');
qriObj.resultName = grabXmlNodeData(qriNode, 'descendant-or-self::query_result_type/name');
qriObj.resultDescription = grabXmlNodeData(qriNode, 'descendant-or-self::query_result_type/description');
//if is obfuscated.
/*if (i2b2.PM.model.isObfuscated) {
qriObj.setSize = (+qriObj.setSize < 4)? "<3" : qriObj.setSize + "+-3";
}*/
return qriObj;
}
/**
*
* @param brdNode
*/
function parseBreakdown(brdNode){
var brdObj = {
name: grabXmlNodeData(brdNode, 'name'),
value: grabXmlNodeData(brdNode, 'value'),
parentResultType: grabXmlNodeData(brdNode, 'parent::breakdown_data/resultType')
}
return brdObj;
}
/**
* Return breakdown title based on breakdown type.
* @param breakdownType
* @returns {*}
*/
function getBreakdownTitle(breakdownType) {
return {
'PATIENT_AGE_COUNT_XML': 'Patient Age Count Breakdown',
'PATIENT_GENDER_COUNT_XML': 'Patient Gender Count Breakdown',
'PATIENT_RACE_COUNT_XML': 'Patient Race Count Breakdown',
'PATIENT_VITALSTATUS_COUNT_XML':'Patient Vital Status Count Breakdown'
}[breakdownType];
};
/**
* Method for hiding the precise value of a query below a certain result.
* @param resultCount - the number of results from a query.
* @param obfuscationSetting - do not reveal this number of results
*/
function getObfuscatedResult(resultCount, obfuscationSetting) {
var resultTitle = " - ",
name = " patients",
offsetText = " +-3",
isException = i2b2.PM.model.isObfuscated === false;
//default to 10.
obfuscationSetting = (arguments.length > 1) ? arguments[1] : 10;
//if user role is an exception. return result.
if (isException) {
return resultTitle += resultCount + name;
}
resultTitle += ((resultCount >= obfuscationSetting)?
resultCount + offsetText + name: obfuscationSetting + name + " or fewer");
return resultTitle;
}
/**
* Grab data for node, return empty string if none.
* @param node
* @param xPathString
* @returns {string}
*/
function grabXmlNodeData(node, xPathString){
return (i2b2.h.XPath(node, xPathString).length)? i2b2.h.XPath(node, xPathString)[0].firstChild.nodeValue : '';
}
// switch to status tab
i2b2.CRC.view.status.showDisplay();
// timer and display refresh stuff
private_startTime = new Date();
private_refreshInterrupt = setInterval("i2b2.CRC.ctrlr.currentQueryStatus.refreshStatus()", 100);
// AJAX call
i2b2.CRC.ajax.runQueryInstance_fromQueryDefinition("CRC:QueryTool", this.params, this.callbackQueryDef);
}
return {
name: "",
polling_interval: 1000,
QM: {id:false, status:""},
QI: {id:false, status:""},
QRS:{},
displayDIV: false,
running: false,
started: false,
startQuery: function(queryName, ajaxParams) {
this.name = queryName;
this.params = ajaxParams;
private_startQuery.call(this);
},
cancelQuery: function() {
private_cancelQuery();
},
isQueryRunning: function() {
return private_singleton_isRunning;
},
refreshStatus: function() {
private_refresh_status();
}
};
}();
i2b2.CRC.ctrlr.currentQueryStatus = false;