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"]; // Query A: // -panel 1: // cutaneous_melanoma // -panel 2: // braf_gene // -panel 3: // protein_600 var queryA = [ [cutaneous_melanoma], [braf_gene], [protein_600] ]; // Query B: // -panel 1: // cutaneous_melanoma // -panel 2: // braf_gene // -panel 3: // pten_gene, cdkn2a_gene, map2k1_gene, mpa2k2 var queryB = [ [cutaneous_melanoma], [braf_gene], [pten_gene, cdkn2a_gene, map2k1_gene, mpa2k2] ]; i2b2.MedCo.test.ctrlr = { // time the action started startTime: null, // whether the query has been encrypted encrypted: false, encrypting: false, // pointer to the interval object so to stop it timeinterval: null, encrypt: function(){ if (this.doing){ alert("Already doing something.") return } this.doing = true; // start timer var dothis = function(){ document.getElementById("MedCo-EncryptCurr").innerHTML = i2b2.MedCo.ctrlr.background.remaining; }; this.startTimer("MedCo-EncryptTime", i2b2.MedCo.ctrlr.background.done, dothis); 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++){ i2b2.MedCo.ctrlr.background.toBeEncrypted(panel[j]) tot += panel[j].length } } document.getElementById("MedCo-EncryptTot").innerHTML = tot; }, 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 query = this.getQuery(); // callback processor to run the query from definition this.MedCocallback = new i2b2_scopedCallback(); this.MedCocallback.scope = this; this.MedCocallback.callback = function(results) { // // "results" 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] // stop the timer and the gif i2b2.MedCo.QT.timer.stop(); try{ if (results.error) { alert(results.errorMsg); return; } else { // extract and show the patient counts i2b2.MedCo.QT.query.showResponse(results); } } catch(e){ alert("Error when extracting the results of the query: " + e.message) } }; this.MedCoparams = {}; this.MedCoparams.psm_query_definition = i2b2.MedCo.QT.query.buildQueryDefinition("MedCo_query"); this.MedCoparams.psm_result_output = "\n\n"; i2b2.CRC.ajax.runQueryInstance_fromQueryDefinition("PLUGIN:MedCo", this.MedCoparams, this.MedCocallback); }, getQuery: function(){ var query = null; switch(document.getElementById('MedCo-QueryType').value) { case "A": query = queryA; break; case "B": query = queryB; break; default: alert("Query type not recognized.") return } return query }, getNumQueries: function(){ return parseInt(document.getElementById('MedCo-NumQueries').value) }, queryChanged: function(){ this.encrypted = false; }, startTimer: function(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.stopTimer(); this.startTime = new Date().getTime(); this.timeinterval = setInterval(function(){i2b2.MedCo.test.ctrlr.updateTimer(label, stop, dothis)}, 100); }, updateTimer: function(label, stop, dothis){ dothis(); var now = new Date().getTime(); document.getElementById(label).innerHTML = ((now-this.startTime)/1000).toFixed(2); if (stop()){ this.stopTimer() } }, stopTimer: function(){ clearInterval(this.timeinterval); this.timeinterval = null; this.doing = false; } };