diff --git a/shrine-webclient/src/main/html/js-i2b2/cells/plugins/MedCo/MedCo_tests.js b/shrine-webclient/src/main/html/js-i2b2/cells/plugins/MedCo/MedCo_tests.js
index ad3c45c1c..70b440547 100644
--- a/shrine-webclient/src/main/html/js-i2b2/cells/plugins/MedCo/MedCo_tests.js
+++ b/shrine-webclient/src/main/html/js-i2b2/cells/plugins/MedCo/MedCo_tests.js
@@ -1,276 +1,281 @@
i2b2.MedCo.test = {}
// questions: always select all zygosity options?
var cutaneous_melanoma = ["2"];
// (25 variants):
var braf_gene = ["-7054948997223410688", "-7054948998062267136", "-7054968999892742144", "-7054948999337337856", "-7054948997064022784", "-7054953138544961536", "-7054948997064020736", "-7054923607457132544", "-7054904773018905600", "-7054898625779855360", "-7054948987408734208", "-7054923379857424384", "-7054917142457610240", "-7054861692282335232", "-7054948050082458624", "-7054922546600210432", "-7054949048695910400", "-7054923381098933248", "-7054861517262417920", "-7054918645662608384", "-7054905185268658176", "-7054904954414166016", "-7054898626853597184", "-7054904932905773056", "-7054861823278837760"];
// (58 variants)
var protein_600 = ["-8933802084025738584", "-6486664075878068224", "-5631356589790194688", "-3744382902155078656", "-4243330163464466432", "-8390864270639754240", "-2861998644146466816", "-8933794510723345408", "-2275778788769918976", "-3744380364936704000", "-4847903122799977472", "-3744370070973837312", "-6486663046126103552", "-2862005101596240896", "-8933793458456358912", "-3731886507003209728", "-4243326752186690560", "-3684888714590289920", "-6600247701843995648", "-5707938912580661248", "-6600348525161082880", "-4243327620843826176", "-5707936738253467648", "-3744381594337537024", "-8390871813676067840", "-6486638321073122304", "-8718336899686591488", "-8161767032237320192", "-8718388095730315264", "-6600348471507544064", "-4847902555864297472", "-8718385496201359360", "-3744381715771026432", "-8390900435338128384", "-4243331029974117376", "-8718385510160003072", "-5707941003155992576", "-5707940965541473280", "-3744377054557105152", "-8390878215358377984", "-8161775324644764672", "-8161760075430494208", "-8933792699320889344", "-8933788672755493888", "-8718360110998468096", "-5707941120160295936", "-6600276494231006208", "-8933788638429310976", "-6486653465127809024", "-3744380416476311552", "-3729075172548795136", "-6600294904608320512", "-8933788867136319488", "-5707939282988035072", "-3744381760767524864", "-2275781595497491456", "-8933793225454383104", "-4243329794097277952"];
// (14 variants)
var pten_gene = ["-6244734599302213632", "-6244835122005142528", "-6244734615609652992", "-6244731379150482432", "-6244761261385445376", "-6244761331212216320", "-6244803225329855488", "-6244761257090477056", "-6244761165822422016", "-6244761148709661696", "-6244761290443582464", "-6244734719527742464", "-6244803244478955520", "-6244731450050998272"];
// (22 variants)
var cdkn2a_gene = ["-6605707269956960256", "-6605707340823916544", "-6605707363372498944", "-6605707399913269248", "-6605707450345581568", "-6605707366560164864", "-6605707493295259648", "-6605707451419324416", "-6605707339750174720", "-6605707347467692032", "-6605707487054123520", "-6605707304132149248", "-6605703514008055808", "-6605707366560165888", "-6605707438500867072", "-6605707503026037760", "-6605703519225765120", "-6605707607111888896", "-6605707340672917504", "-6605703519376764928", "-6605707351594886144", "-6605707619996790784"];
// (9 variants)
var map2k1_gene = ["-4828214681296432128", "-4828266596713621504", "-4828266483970731008", "-4828258079793473536", "-4828266501150601216", "-4828266502224342016", "-4828257969198066688", "-4828266574613577728", "-4828218249340513280"];
// (7 variants)
var mpa2k2 = ["-3742593253707344896", "-3742593391179853824", "-3742595392634613760", "-3742581279372079104", "-3742593229011282944", "-3742591331743035392", "-3742581136564416512"];
// simple test query
var queryTest = [
[{"sensitive": true, "values": cutaneous_melanoma}]
]
// Query A:
// -panel 1:
// cutaneous_melanoma
// -panel 2:
// braf_gene
// -panel 3:
// protein_600
var queryA = [
[{"sensitive": true, "values": cutaneous_melanoma}],
[{"sensitive": true, "values": braf_gene}],
[{"sensitive": true, "values": protein_600}]
];
// Query B:
// -panel 1:
// cutaneous_melanoma
// -panel 2:
// braf_gene
// -panel 3:
// pten_gene, cdkn2a_gene, map2k1_gene, mpa2k2
var queryB = [
[{"sensitive": true, "values": cutaneous_melanoma}],
[{"sensitive": true, "values": braf_gene}],
[{"sensitive": true, "values": pten_gene},
{"sensitive": true, "values": cdkn2a_gene},
{"sensitive": true, "values": map2k1_gene},
{"sensitive": true, "values": mpa2k2}]
];
i2b2.MedCo.test.ctrlr = {
// time the action started
startTime: null,
// whether the query has been encrypted
encrypted: false,
// whether it is already doing something (encrypting or sending the queries)
doing: false,
// pointer to the interval object so to stop it
timeinterval: null,
// response of the query
response: null,
encrypt: function(){
if (this.doing){
alert("Already doing something.")
return
}
this.doing = true;
var startTime = new Date().getTime();
var query = this.getQuery();
// clear encryption cache and start encryption
i2b2.MedCo.ctrlr.background.encryptionCache = {};
var tot = 0;
for (var i = 0; i < query.length; i++){
var panel=query[i];
for (var j = 0; j < panel.length; j++){
if (panel[j].sensitive) {
i2b2.MedCo.ctrlr.background.toBeEncrypted(panel[j].values)
tot += panel[j].values.length
}
}
}
document.getElementById("MedCoTest-EncryptTot").innerHTML = tot;
document.getElementById("MedCoTest-EncryptCurr").innerHTML = 0;
// start timer
var dothis = function(){
document.getElementById("MedCoTest-EncryptCurr").innerHTML = tot - i2b2.MedCo.ctrlr.background.remainingToEncrypt;
};
var done = function(){
if (i2b2.MedCo.ctrlr.background.encryptionDone()){
i2b2.MedCo.test.ctrlr.encrypted = true;
return true
}
return false
};
this.startTimer(startTime, "MedCoTest-EncryptTime", done, dothis);
},
send: function(){
if (this.doing){
alert("Already doing something.")
return
}
// check the query has been encrypted
if (!this.encrypted){
alert("First encrypt the query.")
return
}
this.doing = true;
var startTime = new Date().getTime();
// get query
var query = this.getQuery();
// clear panels and put in their model the parameters
i2b2.MedCo.QT.ctrlr.clear();
for (var i = 0; i < query.length; i++){
var panel=query[i];
for (var j = 0; j < panel.length; j++){
i2b2.MedCo.QT.panels[i].model.content.push(panel[j])
}
}
var numQueries = this.getNumQueries();
var remaining = numQueries;
- for (var i = 0; i < numQueries; i++) {
+ function sendQuery() {
this.MedCoparams = {};
this.MedCoparams.psm_query_definition = i2b2.MedCo.QT.query.buildQueryDefinition("MedCo_query");
this.MedCoparams.psm_result_output = "\n\n";
// callback processor to run the query from definition
this.MedCocallback = new i2b2_scopedCallback();
this.MedCocallback.scope = this;
this.MedCocallback.callback = function (results) {
- // todo decrypt result? keep the time for each query?
+ // todo keep the time for each query?
remaining -= 1
// extract the server times
try{
if (results.error) {
alert(results.errorMsg);
return;
} else {
this.response = results;
}
} catch(e){
alert("Error when extracting the results of the query: " + e.message)
}
};
-
i2b2.CRC.ajax.runQueryInstance_fromQueryDefinition("PLUGIN:MedCo", this.MedCoparams, this.MedCocallback);
}
+
+ for (var i = 0; i < numQueries; i++) {
+ sendQuery();
+
+ }
+
// clear panels
i2b2.MedCo.QT.ctrlr.clear();
// show tot response count
document.getElementById("MedCoTest-QueryTot").innerHTML = numQueries;
// start timer
var dothis = function(){
document.getElementById("MedCoTest-QueryCurr").innerHTML = numQueries - remaining;
};
var done = function(){
return remaining<=0;
};
this.startTimer(startTime, "MedCoTest-QueryTime", done, dothis);
},
decrypt: function(){
if (this.doing){
alert("Already doing something.")
return
}
if (!this.response){
alert("No response to be decrypted.")
return
}
this.doing = true;
// clear decryption cache and start decryption
i2b2.MedCo.ctrlr.background.decryptionCache = {};
var startTime = new Date().getTime();
i2b2.MedCo.QT.query.showResponse(this.response, "MedCoTest-QueryResult");
// show number of patient counts to be decrypted and start timer
var tot = this.response.refXML.getElementsByTagName('query_result_instance').length;
document.getElementById("MedCoTest-DecryptTot").innerHTML = tot;
document.getElementById("MedCoTest-DecryptCurr").innerHTML = 0;
var dothis = function(){
document.getElementById("MedCoTest-DecryptCurr").innerHTML = tot - i2b2.MedCo.ctrlr.background.remainingToDecrypt;
};
this.startTimer(startTime, "MedCoTest-DecryptTime", i2b2.MedCo.ctrlr.background.decryptionDone, dothis);
},
getQuery: function(){
switch(document.getElementById('MedCoTest-QueryType').value) {
case "A":
return queryA;
break;
case "B":
return queryB;
break;
case "T":
return queryTest;
default:
alert("Query type not recognized.")
return
}
},
getNumQueries: function(){
return parseInt(document.getElementById('MedCoTest-NumQueries').value)
},
queryChanged: function(){
this.encrypted = false;
switch(document.getElementById('MedCoTest-QueryType').value){
case "A":
document.getElementById("MedCoTest-QueryDescr").innerHTML = "Cutaneous Melanoma AND braf AND protein -\\600";
break;
case "B":
document.getElementById("MedCoTest-QueryDescr").innerHTML = "Cutaneous Melanoma AND braf AND (pten OR cdkn2a OR map2k1 OR mpa2k2)";
break;
case "T":
document.getElementById("MedCoTest-QueryDescr").innerHTML = "Cutaneous Melanoma";
break;
}
},
startTimer: function(startTime, label, stop, dothis){
// label: id of the html object in which write the time
// stop: function which returns a boolean (true if the action has been completed => stop the timer)
// dothis: if given this function is while updating the timer
this.clearTimer();
this.startTime = startTime;
this.timeinterval = setInterval(function(){i2b2.MedCo.test.ctrlr.updateTimer(label, stop, dothis)}, 100);
},
updateTimer: function(label, stop, dothis){
if (dothis instanceof Function) {
dothis();
}
var now = new Date().getTime();
document.getElementById(label).innerHTML = ((now-this.startTime)/1000).toFixed(2);
if (stop()){
this.stopTimer()
}
},
clearTimer: function(){
this.startTime = null;
clearInterval(this.timeinterval);
this.timeinterval = null;
},
stopTimer: function(){
this.clearTimer();
this.doing = false;
}
};
\ No newline at end of file