extensions/net.sf.basedb.meludi/trunk/resources/personal/ffpe_section_registration_alt_rec.js

Code
Comments
Other
Rev Date Author Line
5060 29 Oct 18 olle 1 var Istat = function()
5060 29 Oct 18 olle 2 {
5060 29 Oct 18 olle 3   var istat = {};
5060 29 Oct 18 olle 4   var debug = 0;
5060 29 Oct 18 olle 5   
5060 29 Oct 18 olle 6   var refVariantDefault = 'kit1_standard';
5060 29 Oct 18 olle 7
5114 20 Nov 18 olle 8   // Well validation variable for input specimen, DNA, RNA
5114 20 Nov 18 olle 9   var wellIsValid = [];
5114 20 Nov 18 olle 10   // Well validation variables for extracts from specimen
5114 20 Nov 18 olle 11   var dnaWellIsValid = [];
5114 20 Nov 18 olle 12   var rnaWellIsValid = [];
5114 20 Nov 18 olle 13   
5060 29 Oct 18 olle 14   // Page initialization
5060 29 Oct 18 olle 15   istat.initPage = function()
5060 29 Oct 18 olle 16   {
5060 29 Oct 18 olle 17     // Step 1
5060 29 Oct 18 olle 18     Events.addEventHandler('step-1', 'wizard-validate', istat.validateStep1);
5060 29 Oct 18 olle 19     Events.addEventHandler('extractSourceItems', 'change', istat.sourceItemsOnChange);
5060 29 Oct 18 olle 20
5060 29 Oct 18 olle 21     // Step 2
5060 29 Oct 18 olle 22     Events.addEventHandler('step-2', 'wizard-initialize', istat.initializeStep2);
5060 29 Oct 18 olle 23     Events.addEventHandler('step-2', 'wizard-validate', istat.validateStep2);
5060 29 Oct 18 olle 24
5060 29 Oct 18 olle 25     // Navigation
5060 29 Oct 18 olle 26     Buttons.addClickHandler('gocancel', Wizard.cancelWizard);
5060 29 Oct 18 olle 27     Buttons.addClickHandler('gorestart', Wizard.restartWizard);
5060 29 Oct 18 olle 28     Buttons.addClickHandler('gonext', Wizard.goNextOnClick);
5060 29 Oct 18 olle 29     Buttons.addClickHandler('goregister', Wizard.goRegister);
5060 29 Oct 18 olle 30     
5060 29 Oct 18 olle 31     // Final registration
5060 29 Oct 18 olle 32     Events.addEventHandler('wizard', 'wizard-submit', istat.submit);
5060 29 Oct 18 olle 33
5060 29 Oct 18 olle 34     // Get FFPE block items
5060 29 Oct 18 olle 35     var url = '../Extraction.servlet?ID='+App.getSessionId();
5061 30 Oct 18 olle 36     url += '&cmd=GetFfpeBlocksUnusedForSection';    
5060 29 Oct 18 olle 37     Wizard.showLoadingAnimation('Loading unprocessed items...');
5060 29 Oct 18 olle 38     Wizard.asyncJsonRequest(url, istat.initializeStep1);
5060 29 Oct 18 olle 39   }
5060 29 Oct 18 olle 40   
5060 29 Oct 18 olle 41   istat.initializeStep1 = function(response)
5060 29 Oct 18 olle 42   {
5060 29 Oct 18 olle 43     var frm = document.forms['meludi'];
5060 29 Oct 18 olle 44     var items = response.items;
5060 29 Oct 18 olle 45     
5060 29 Oct 18 olle 46     var sourceItemList = frm.extractSourceItems;
5060 29 Oct 18 olle 47     if (items.length)
5060 29 Oct 18 olle 48     {
5060 29 Oct 18 olle 49       var numItems = items.length;
5060 29 Oct 18 olle 50       for (var i=0; i < items.length; i++)
5060 29 Oct 18 olle 51       {
5060 29 Oct 18 olle 52         var item = items[i];
5060 29 Oct 18 olle 53         var name = (i+1) + ': ' + Strings.encodeTags(item.name);
5060 29 Oct 18 olle 54         if (item.pad)
5060 29 Oct 18 olle 55         {
5060 29 Oct 18 olle 56           name += ' -- (PAD: ' + Strings.encodeTags(item.pad + ')');
5060 29 Oct 18 olle 57         }
5060 29 Oct 18 olle 58         var selected = i < 8;
5060 29 Oct 18 olle 59         var option = new Option(name, item.id, selected, selected);
5060 29 Oct 18 olle 60         option.item = item;
5060 29 Oct 18 olle 61         if (item.yellowLabel)
5060 29 Oct 18 olle 62         {
5060 29 Oct 18 olle 63           option.className = 'yellow';
5060 29 Oct 18 olle 64         }
5060 29 Oct 18 olle 65         sourceItemList.options[sourceItemList.length] = option;
5060 29 Oct 18 olle 66       }
5060 29 Oct 18 olle 67       istat.sourceItemsOnChange();
5060 29 Oct 18 olle 68     }
5060 29 Oct 18 olle 69     else
5060 29 Oct 18 olle 70     {
5060 29 Oct 18 olle 71       Wizard.setFatalError('No sectioned FFPE block items available.');
5060 29 Oct 18 olle 72       return;
5060 29 Oct 18 olle 73     }
5060 29 Oct 18 olle 74
5060 29 Oct 18 olle 75     Wizard.setCurrentStep(1);
5060 29 Oct 18 olle 76     Doc.show('step-1');
5060 29 Oct 18 olle 77     Doc.show('gonext');
5060 29 Oct 18 olle 78   }
5060 29 Oct 18 olle 79
5060 29 Oct 18 olle 80   istat.sourceItemsOnChange = function()
5060 29 Oct 18 olle 81   {
5060 29 Oct 18 olle 82     sourceItemListIsValid = false;
5060 29 Oct 18 olle 83     Wizard.setInputStatus('extractSourceItems');
5060 29 Oct 18 olle 84     
5060 29 Oct 18 olle 85     var frm = document.forms['meludi'];
5060 29 Oct 18 olle 86     var sourceItemList = frm.extractSourceItems;
5060 29 Oct 18 olle 87     
5060 29 Oct 18 olle 88     var numSelected = 0;
5060 29 Oct 18 olle 89     for (var i = 0; i < sourceItemList.length; i++)
5060 29 Oct 18 olle 90     {
5060 29 Oct 18 olle 91       if (sourceItemList[i].selected) numSelected++;
5060 29 Oct 18 olle 92     }
5060 29 Oct 18 olle 93
5060 29 Oct 18 olle 94     if (numSelected < 1)
5060 29 Oct 18 olle 95     {
5060 29 Oct 18 olle 96       Wizard.setInputStatus('extractSourceItems', 'invalid', 'Must select a number of FFPE block items.');
5060 29 Oct 18 olle 97       return;
5060 29 Oct 18 olle 98     }
5060 29 Oct 18 olle 99     
5060 29 Oct 18 olle 100     sourceItemListIsValid = true;
5060 29 Oct 18 olle 101     Wizard.setInputStatus('extractSourceItems', 'valid');
5060 29 Oct 18 olle 102   }
5060 29 Oct 18 olle 103
5060 29 Oct 18 olle 104   istat.validateStep1 = function(event)
5060 29 Oct 18 olle 105   {
5060 29 Oct 18 olle 106     if (!sourceItemListIsValid)
5060 29 Oct 18 olle 107     {
5060 29 Oct 18 olle 108       event.preventDefault();
5060 29 Oct 18 olle 109     }
5060 29 Oct 18 olle 110     var valid = true;
5060 29 Oct 18 olle 111   }
5060 29 Oct 18 olle 112
5060 29 Oct 18 olle 113   istat.initializeStep2 = function()
5060 29 Oct 18 olle 114   {
5060 29 Oct 18 olle 115     var frm = document.forms['meludi'];
5060 29 Oct 18 olle 116     var ffpeBlockList = istat.getSelectedItemsList();
5060 29 Oct 18 olle 117
5060 29 Oct 18 olle 118     Doc.addClass('extractSourceItems', 'disabled');
5060 29 Oct 18 olle 119
5060 29 Oct 18 olle 120     var nofBlocks = ffpeBlockList.length;
5114 20 Nov 18 olle 121         
5060 29 Oct 18 olle 122     var html = '';
5060 29 Oct 18 olle 123
5060 29 Oct 18 olle 124 /*
5060 29 Oct 18 olle 125     // Add buttons for adding standard comments for all FFPE blocks
5060 29 Oct 18 olle 126     html += '<tr class="section-header">';
5060 29 Oct 18 olle 127     html += '<td colspan="4">Standard comments</td>';
5060 29 Oct 18 olle 128     html += '</tr>';
5060 29 Oct 18 olle 129
5060 29 Oct 18 olle 130     html += '<tr class="align-top">';
5060 29 Oct 18 olle 131     html += '<td class="subprompt"></td>';
5060 29 Oct 18 olle 132     html += '<td><div class="button basicbutton interactable" id="addCarvedOutComment" style="font-weight: normal;">Add &quot;Utkarvad&quot; (Carved out)</div></td>';
5060 29 Oct 18 olle 133     html += '<td class="status" id="addCarvedOutComment.status"></td>';
5060 29 Oct 18 olle 134     html += '<td class="help"><span id="addCarvedOutComment.message" class="message"></span>Click button to add standard comment for all items.</td>';    
5060 29 Oct 18 olle 135     html += '</tr>';
5060 29 Oct 18 olle 136
5060 29 Oct 18 olle 137     html += '<tr class="align-top">';
5060 29 Oct 18 olle 138     html += '<td class="subprompt"></td>';
5060 29 Oct 18 olle 139     html += '<td><div class="button basicbutton interactable" id="addMnbComment" style="font-weight: normal;">Add &quot;MNB&quot; (Medium needle biopsy)</div></td>';
5060 29 Oct 18 olle 140     html += '<td class="status" id="addMnbComment.status"></td>';
5060 29 Oct 18 olle 141     html += '<td class="help"><span id="addMnbComment.message" class="message"></span>Click button to add standard comment for all items.</td>';    
5060 29 Oct 18 olle 142     html += '</tr>';
5060 29 Oct 18 olle 143 */
5060 29 Oct 18 olle 144
5060 29 Oct 18 olle 145     for (var i=0; i < nofBlocks; i++)
5060 29 Oct 18 olle 146     {
5126 21 Nov 18 olle 147       var ffpeBlockName = ffpeBlockList[i].name;
5126 21 Nov 18 olle 148       var ffpeSectionName = ffpeBlockName + '.s';
5060 29 Oct 18 olle 149       var pad = ffpeBlockList[i].pad;
5114 20 Nov 18 olle 150       var materialNumber = ffpeBlockList[i].materialNumber;
5060 29 Oct 18 olle 151       var yellowLabelCheck = '';
5060 29 Oct 18 olle 152       if (ffpeBlockList[i].yellowLabel == 'yellow')
5060 29 Oct 18 olle 153       {
5060 29 Oct 18 olle 154         yellowLabelCheck = 'checked';
5060 29 Oct 18 olle 155       }
5060 29 Oct 18 olle 156       var operatorDeliveryComment = ffpeBlockList[i].operatorDeliveryComment;
5060 29 Oct 18 olle 157 //alert("ffpe_section_registration_alt_rec.js::initializeStep2(): i = " + i + " ffpeSectionName = " + ffpeSectionName + " pad = " + pad + " yellowLabelCheck = " + yellowLabelCheck);
5060 29 Oct 18 olle 158       //var tubeIdentifier = 'TubeId' + blockName + i;
5060 29 Oct 18 olle 159       var tubeIdentifier = ffpeSectionName;
5060 29 Oct 18 olle 160
5060 29 Oct 18 olle 161       html += '<tr class="section-header">';
5060 29 Oct 18 olle 162       html += '<td colspan="4">FFPE section '+ffpeSectionName+'</td>';
5060 29 Oct 18 olle 163       html += '</tr>';
5060 29 Oct 18 olle 164
5060 29 Oct 18 olle 165       var padMsg = 'PAD number for '+ffpeSectionName+'.';
5114 20 Nov 18 olle 166       var materialNumberMsg = 'Material number (FFPE block number) for '+ffpeSectionName+'.';
5060 29 Oct 18 olle 167       var yellowLabelMsg = 'Assigned yellow label for '+ffpeSectionName+' (selected for processing).';
5060 29 Oct 18 olle 168       var nofSectionsMsg = 'Number of sections for '+ffpeSectionName+'.';
5832 21 Feb 20 olle 169       //var pctViabTumourCellsMsg = '% Viable tumour cells for '+ffpeSectionName+'.';
5060 29 Oct 18 olle 170       var opDelCmtMsg = 'In this field, enter information specific for for '+ffpeSectionName+'.';
5060 29 Oct 18 olle 171       var disabledAttribute = '';
5060 29 Oct 18 olle 172
5060 29 Oct 18 olle 173       // PAD number (info only)
5060 29 Oct 18 olle 174       html += '<tr>';
5060 29 Oct 18 olle 175       html += '<td class="subprompt">PAD</td>';
5060 29 Oct 18 olle 176       html += '<td>'+pad+'</td>';
5060 29 Oct 18 olle 177       html += '<td class="status" id="pad.'+i+'.status"></td>';
5060 29 Oct 18 olle 178       html += '<td class="help"><span id="pad.'+i+'.message" class="message"></span>'+padMsg+'<span id="pad.'+i+'.message" class="message"></span></td>';
5060 29 Oct 18 olle 179       html += '</tr>';
5060 29 Oct 18 olle 180
5114 20 Nov 18 olle 181       // Material number (info only)
5114 20 Nov 18 olle 182       html += '<tr>';
5114 20 Nov 18 olle 183       html += '<td class="subprompt">Material number</td>';
5114 20 Nov 18 olle 184       html += '<td>'+materialNumber+'</td>';
5114 20 Nov 18 olle 185       html += '<td class="status" id="materialNumber.'+i+'.status"></td>';
5114 20 Nov 18 olle 186       html += '<td class="help"><span id="materialNumber.'+i+'.message" class="message"></span>'+materialNumberMsg+'<span id="pad.'+i+'.message" class="message"></span></td>';
5114 20 Nov 18 olle 187       html += '</tr>';
5114 20 Nov 18 olle 188
5060 29 Oct 18 olle 189       // Yellow label check box (info only)
5060 29 Oct 18 olle 190       html += '<tr>';
5060 29 Oct 18 olle 191       html += '<td class="subprompt">Selected for processing</td>';
5060 29 Oct 18 olle 192       html += '<td class="input">';
5060 29 Oct 18 olle 193       html += '<label id="yellowLabel.'+i+'"><input type="checkbox" name="yellowLabel.'+i+'" id="yellowLabel.'+i+'" '+yellowLabelCheck+' '+disabledAttribute+' disabled>Yellow label</label>';
5060 29 Oct 18 olle 194       html += '</td>';
5060 29 Oct 18 olle 195       html += '<td class="status" id="yellowLabel.'+i+'.status"></td>';
5060 29 Oct 18 olle 196       html += '<td class="help"><span id="yellowLabel.'+i+'.message" class="message"></span>'+yellowLabelMsg+'<span id="yellowLabel.'+i+'.message" class="message"></span></td>';
5060 29 Oct 18 olle 197       html += '</tr>';
5060 29 Oct 18 olle 198
5114 20 Nov 18 olle 199       var tubeContentTypeNameInternal = 'FFPE section';
5114 20 Nov 18 olle 200       var tubeContentType = 'FFPE section';
5114 20 Nov 18 olle 201       var tubeContentTypeName = 'Specimen';
5114 20 Nov 18 olle 202       var tubeName = ffpeSectionName;
5114 20 Nov 18 olle 203       var extractsFromFirstSpecimenOnly = false;
5114 20 Nov 18 olle 204
5114 20 Nov 18 olle 205       var boxMsg = 'No storage space allocated for specimen; all amount expected to be used.';
5137 22 Nov 18 olle 206       var dnaBoxMsg = 'Box-number and position where the DNA extract will be placed.';
5137 22 Nov 18 olle 207       var rnaBoxMsg = 'Box-number and position where the RNA extract will be placed.';
5137 22 Nov 18 olle 208       var heGlassFBoxMsg = 'Box-number and position where the H&E glass "F" will be placed.';
5137 22 Nov 18 olle 209       var heGlassEBoxMsg = 'Box-number and position where the H&E glass "E" will be placed.';
5114 20 Nov 18 olle 210       var disabledAttribute = '';
5832 21 Feb 20 olle 211       //var pctTumourCellsFMsg = '% Tumour cells for '+ffpeSectionName+'.F.'
5832 21 Feb 20 olle 212       //var pctTumourCellsEMsg = '% Tumour cells for '+ffpeSectionName+'.E.'
5114 20 Nov 18 olle 213
5114 20 Nov 18 olle 214 /*
5060 29 Oct 18 olle 215       html += '<tr>';
5114 20 Nov 18 olle 216       html += '<td class="subprompt">'+tubeContentTypeName+'&nbsp;'+tubeName+'&nbsp;&nbsp;&nbsp;'+'Box</td>';
5060 29 Oct 18 olle 217       html += '<td class="input">';
5114 20 Nov 18 olle 218       html += '<input type="text" name="box.'+i+'" id="box.'+i+'" style="width: 12em;" maxlength="12"'+disabledAttribute+'>';
5114 20 Nov 18 olle 219       html += '&nbsp;Row<input type="text" name="row.'+i+'" id="row.'+i+'" style="text-transform:uppercase; width: 3em;" maxlength="2"'+disabledAttribute+'>';
5114 20 Nov 18 olle 220       html += '&nbsp;Column<input type="text" name="column.'+i+'" id="column.'+i+'" style="width: 3em;" maxlength="2"'+disabledAttribute+'>';
5060 29 Oct 18 olle 221       html += '</td>';
5114 20 Nov 18 olle 222       html += '<td class="status" id="box.'+i+'.status"></td>';
5114 20 Nov 18 olle 223       html += '<td class="help"><span id="box.'+i+'.message" class="message"></span>'+boxMsg+'<span id="position.'+i+'.message" class="message"></span></td>';
5060 29 Oct 18 olle 224       html += '</tr>';
5114 20 Nov 18 olle 225 */
5060 29 Oct 18 olle 226
5114 20 Nov 18 olle 227       disabledAttribute = '';
5114 20 Nov 18 olle 228       if (i == 0 || !extractsFromFirstSpecimenOnly)
5114 20 Nov 18 olle 229       {
5114 20 Nov 18 olle 230         html += '<tr>';
5114 20 Nov 18 olle 231         html += '<td class="subprompt">DNA extract'+'&nbsp;'+tubeName+'.d&nbsp;&nbsp;&nbsp;'+'Box</td>';
5114 20 Nov 18 olle 232         html += '<td class="input">';
5114 20 Nov 18 olle 233         html += '<input type="text" name="dnaBox.'+i+'" id="dnaBox.'+i+'" style="width: 12em;" maxlength="12"'+disabledAttribute+'>';
5114 20 Nov 18 olle 234         html += '&nbsp;Row<input type="text" name="dnaRow.'+i+'" id="dnaRow.'+i+'" style="text-transform:uppercase; width: 3em;" maxlength="2"'+disabledAttribute+'>';
5114 20 Nov 18 olle 235         html += '&nbsp;Column<input type="text" name="dnaColumn.'+i+'" id="dnaColumn.'+i+'" style="width: 3em;" maxlength="2"'+disabledAttribute+'>';
5114 20 Nov 18 olle 236         html += '</td>';
5114 20 Nov 18 olle 237         html += '<td class="status" id="dnaBox.'+i+'.status"></td>';
5114 20 Nov 18 olle 238         html += '<td class="help"><span id="dnaBox.'+i+'.message" class="message"></span>'+dnaBoxMsg+'<span id="dnaPosition.'+i+'.message" class="message"></span></td>';
5114 20 Nov 18 olle 239         html += '</tr>';
5114 20 Nov 18 olle 240
5114 20 Nov 18 olle 241         html += '<tr>';
5114 20 Nov 18 olle 242         html += '<td class="subprompt">RNA extract'+'&nbsp;'+tubeName+'.r&nbsp;&nbsp;&nbsp;'+'Box</td>';
5114 20 Nov 18 olle 243         html += '<td class="input">';
5114 20 Nov 18 olle 244         html += '<input type="text" name="rnaBox.'+i+'" id="rnaBox.'+i+'" style="width: 12em;" maxlength="12"'+disabledAttribute+'>';
5114 20 Nov 18 olle 245         html += '&nbsp;Row<input type="text" name="rnaRow.'+i+'" id="rnaRow.'+i+'" style="text-transform:uppercase; width: 3em;" maxlength="2"'+disabledAttribute+'>';
5114 20 Nov 18 olle 246         html += '&nbsp;Column<input type="text" name="rnaColumn.'+i+'" id="rnaColumn.'+i+'" style="width: 3em;" maxlength="2"'+disabledAttribute+'>';
5114 20 Nov 18 olle 247         html += '</td>';
5114 20 Nov 18 olle 248         html += '<td class="status" id="rnaBox.'+i+'.status"></td>';
5114 20 Nov 18 olle 249         html += '<td class="help"><span id="rnaBox.'+i+'.message" class="message"></span>'+rnaBoxMsg+'<span id="rnaPosition.'+i+'.message" class="message"></span></td>';
5114 20 Nov 18 olle 250         html += '</tr>';
5114 20 Nov 18 olle 251       }
5114 20 Nov 18 olle 252
5114 20 Nov 18 olle 253       // Number of sections
5060 29 Oct 18 olle 254       html += '<tr>';
5114 20 Nov 18 olle 255       html += '<td class="subprompt">Number of sections</td>';
5060 29 Oct 18 olle 256       html += '<td class="input">';
5214 09 Jan 19 olle 257       //html += '<input type="text" name="nofSections.'+i+'" id="nofSections.'+i+'" style="width: 3em;" maxlength="2" value="1" '+disabledAttribute+'>';
5214 09 Jan 19 olle 258       html += '<input type="text" name="nofSections.'+i+'" id="nofSections.'+i+'" style="width: 3em;" maxlength="2" value="" '+disabledAttribute+'>';
5060 29 Oct 18 olle 259       html += '</td>';
5114 20 Nov 18 olle 260       html += '<td class="status" id="nofSections.'+i+'.status"></td>';
5114 20 Nov 18 olle 261       html += '<td class="help"><span id="nofSections.'+i+'.message" class="message"></span>'+nofSectionsMsg+'<span id="nofSections.'+i+'.message" class="message"></span></td>';
5060 29 Oct 18 olle 262       html += '</tr>';
5060 29 Oct 18 olle 263
5060 29 Oct 18 olle 264       // Operator delivery comment
5060 29 Oct 18 olle 265       html += '<tr class="align-top">';
5060 29 Oct 18 olle 266       html += '<td class="subprompt">Operator delivery comment</td>';
5060 29 Oct 18 olle 267       html += '<td class="input"><textarea rows="3" name="comment.'+i+'" id="comment.'+i+'">'+operatorDeliveryComment+'</textarea></td>';
5060 29 Oct 18 olle 268       html += '<td class="status" id="comment.'+i+'.status"></td>';
5060 29 Oct 18 olle 269       html += '<td class="help"><span id="comment.'+i+'.message" class="message"></span>'+opDelCmtMsg+'</td>';    
5060 29 Oct 18 olle 270       html += '</tr>';
5114 20 Nov 18 olle 271
5114 20 Nov 18 olle 272       // H&E glass "Front"
5114 20 Nov 18 olle 273       html += '<tr>';
5126 21 Nov 18 olle 274       html += '<td class="subprompt">H&E glass'+'&nbsp;'+ffpeBlockName+'.F&nbsp;&nbsp;&nbsp;'+'Box</td>';
5114 20 Nov 18 olle 275       html += '<td class="input">';
5114 20 Nov 18 olle 276       html += '<input type="text" name="heGlassFBox.'+i+'" id="heGlassFBox.'+i+'" style="width: 12em;" maxlength="12"'+disabledAttribute+'>';
5114 20 Nov 18 olle 277       //html += '&nbsp;Tray<input type="text" name="heGlassFTray.'+i+'" id="heGlassFTray.'+i+'" style="text-transform:uppercase; width: 3em;" maxlength="2"'+disabledAttribute+'>';
5114 20 Nov 18 olle 278       html += '&nbsp;Position<input type="text" name="heGlassFPosition.'+i+'" id="heGlassFPosition.'+i+'" style="width: 3em;" maxlength="2"'+disabledAttribute+'>';
5114 20 Nov 18 olle 279       html += '</td>';
5114 20 Nov 18 olle 280       html += '<td class="status" id="heGlassFBox.'+i+'.status"></td>';
5114 20 Nov 18 olle 281       html += '<td class="help"><span id="heGlassFBox.'+i+'.message" class="message"></span>'+heGlassFBoxMsg+'<span id="heGlassFPosition.'+i+'.message" class="message"></span></td>';
5114 20 Nov 18 olle 282       html += '</tr>';
5114 20 Nov 18 olle 283
5832 21 Feb 20 olle 284 /*
5114 20 Nov 18 olle 285       // H&E glass "Front" percentage of tumor cells 
5114 20 Nov 18 olle 286       html += '<tr>';
5114 20 Nov 18 olle 287       html += '<td class="subprompt">% Tumour cells</td>';
5114 20 Nov 18 olle 288       html += '<td class="input">';
5114 20 Nov 18 olle 289       html += '<input type="text" name="pctTumourCellsF.'+i+'" id="pctTumourCellsF.'+i+'" style="width: 3em;" maxlength="3"'+disabledAttribute+'>';
5114 20 Nov 18 olle 290       html += '</td>';
5114 20 Nov 18 olle 291       html += '<td class="status" id="pctTumourCellsF.'+i+'.status"></td>';
5114 20 Nov 18 olle 292       html += '<td class="help"><span id="pctTumourCellsF.'+i+'.message" class="message"></span>'+pctTumourCellsFMsg+'<span id="pctTumourCellsF.'+i+'.message" class="message"></span></td>';
5114 20 Nov 18 olle 293       html += '</tr>';
5832 21 Feb 20 olle 294 */
5114 20 Nov 18 olle 295
5114 20 Nov 18 olle 296       // H&E glass "End"
5114 20 Nov 18 olle 297       html += '<tr>';
5126 21 Nov 18 olle 298       html += '<td class="subprompt">H&E glass'+'&nbsp;'+ffpeBlockName+'.E&nbsp;&nbsp;&nbsp;'+'Box</td>';
5114 20 Nov 18 olle 299       html += '<td class="input">';
5114 20 Nov 18 olle 300       html += '<input type="text" name="heGlassEBox.'+i+'" id="heGlassEBox.'+i+'" style="width: 12em;" maxlength="12"'+disabledAttribute+'>';
5114 20 Nov 18 olle 301       //html += '&nbsp;Tray<input type="text" name="heGlassETray.'+i+'" id="heGlassETray.'+i+'" style="text-transform:uppercase; width: 3em;" maxlength="2"'+disabledAttribute+'>';
5114 20 Nov 18 olle 302       html += '&nbsp;Position<input type="text" name="heGlassEPosition.'+i+'" id="heGlassEPosition.'+i+'" style="width: 3em;" maxlength="2"'+disabledAttribute+'>';
5114 20 Nov 18 olle 303       html += '</td>';
5114 20 Nov 18 olle 304       html += '<td class="status" id="heGlassEBox.'+i+'.status"></td>';
5114 20 Nov 18 olle 305       html += '<td class="help"><span id="heGlassEBox.'+i+'.message" class="message"></span>'+heGlassEBoxMsg+'<span id="heGlassEPosition.'+i+'.message" class="message"></span></td>';
5114 20 Nov 18 olle 306       html += '</tr>';
5114 20 Nov 18 olle 307
5832 21 Feb 20 olle 308 /*
5114 20 Nov 18 olle 309       // H&E glass "End" percentage of tumor cells 
5114 20 Nov 18 olle 310       html += '<tr>';
5114 20 Nov 18 olle 311       html += '<td class="subprompt">% Tumour cells</td>';
5114 20 Nov 18 olle 312       html += '<td class="input">';
5114 20 Nov 18 olle 313       html += '<input type="text" name="pctTumourCellsE.'+i+'" id="pctTumourCellsE.'+i+'" style="width: 3em;" maxlength="3"'+disabledAttribute+'>';
5114 20 Nov 18 olle 314       html += '</td>';
5114 20 Nov 18 olle 315       html += '<td class="status" id="pctTumourCellsE.'+i+'.status"></td>';
5114 20 Nov 18 olle 316       html += '<td class="help"><span id="pctTumourCellsE.'+i+'.message" class="message"></span>'+pctTumourCellsEMsg+'<span id="pctTumourCellsE.'+i+'.message" class="message"></span></td>';
5114 20 Nov 18 olle 317       html += '</tr>';
5832 21 Feb 20 olle 318 */
5060 29 Oct 18 olle 319     }
5060 29 Oct 18 olle 320     Doc.element('ffpe-sections').innerHTML = html;
5060 29 Oct 18 olle 321
5060 29 Oct 18 olle 322 /*
5060 29 Oct 18 olle 323     // Add click handlers for buttons for adding standard comments for all specimens/RNA/DNA
5060 29 Oct 18 olle 324     var addCarvedOutCommentGeneralButton = Doc.element('addCarvedOutComment');
5060 29 Oct 18 olle 325     Buttons.addClickHandler(addCarvedOutCommentGeneralButton, istat.addCommentGeneral, {'nofBlocks': nofBlocks, 'text-field': 'comment.', 'text': 'Utkarvad.'});
5060 29 Oct 18 olle 326     var addMnbCommentGeneralButton = Doc.element('addMnbComment');
5060 29 Oct 18 olle 327     Buttons.addClickHandler(addMnbCommentGeneralButton, istat.addCommentGeneral, {'nofBlocks': nofBlocks, 'text-field': 'comment.', 'text': 'MNB.'});
5060 29 Oct 18 olle 328 */
5060 29 Oct 18 olle 329
5060 29 Oct 18 olle 330     Doc.hide('gonext');
5060 29 Oct 18 olle 331     Doc.show('goregister');
5060 29 Oct 18 olle 332     Doc.show('gocancel');
5060 29 Oct 18 olle 333
5114 20 Nov 18 olle 334     //frm['nofSections.0'].focus();
5114 20 Nov 18 olle 335     Wizard.setCurrentStep(2);
5060 29 Oct 18 olle 336     Doc.show('step-2');
5114 20 Nov 18 olle 337
5114 20 Nov 18 olle 338     var storageBoxSuffix = '_sp';
5114 20 Nov 18 olle 339     
5114 20 Nov 18 olle 340     //var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId();
5114 20 Nov 18 olle 341     var url = '../BaseLineRegistration.servlet?ID='+App.getSessionId();
5114 20 Nov 18 olle 342     url += '&cmd=FindStoragePositions';  
5114 20 Nov 18 olle 343     //url += '&nofTubes='+frm.nofTubes.value;
5114 20 Nov 18 olle 344     url += '&nofTubes='+nofBlocks;
5114 20 Nov 18 olle 345     url += '&storageBoxSuffix='+storageBoxSuffix;
5114 20 Nov 18 olle 346     url += '&extractsFromFirstSpecimenOnly='+extractsFromFirstSpecimenOnly;
5114 20 Nov 18 olle 347     
5114 20 Nov 18 olle 348     Wizard.showLoadingAnimation('Looking for empty box positions...');
5114 20 Nov 18 olle 349     Wizard.asyncJsonRequest(url, istat.storagePositionsLoaded);
5060 29 Oct 18 olle 350   }
5060 29 Oct 18 olle 351
5060 29 Oct 18 olle 352   istat.addCommentGeneral = function(event)
5060 29 Oct 18 olle 353   {
5060 29 Oct 18 olle 354     var nofBlocks = Data.get(event.currentTarget, 'nofBlocks', event.currentTarget.id);
5060 29 Oct 18 olle 355     var textFieldBase = Data.get(event.currentTarget, 'text-field', event.currentTarget.id);
5060 29 Oct 18 olle 356     // Get standard comment text to add
5060 29 Oct 18 olle 357     var text = Data.get(event.currentTarget, 'text', event.currentTarget.id);
5060 29 Oct 18 olle 358     // Loop over comment fields to update
5060 29 Oct 18 olle 359     for (var i=0; i < nofBlocks; i++)
5060 29 Oct 18 olle 360     {
5060 29 Oct 18 olle 361       var textField = Doc.element(textFieldBase+i);
5060 29 Oct 18 olle 362       if (textField)
5060 29 Oct 18 olle 363       {
5060 29 Oct 18 olle 364         if (text && text != '')
5060 29 Oct 18 olle 365         {
5060 29 Oct 18 olle 366           // Check if current comment field already contains text
5060 29 Oct 18 olle 367           if (textField.value != '')
5060 29 Oct 18 olle 368           {
5060 29 Oct 18 olle 369             // Add space to text in current comment field
5060 29 Oct 18 olle 370             textField.value += ' ';
5060 29 Oct 18 olle 371           }
5060 29 Oct 18 olle 372           // Add standard comment text
5060 29 Oct 18 olle 373           textField.value += text;
5060 29 Oct 18 olle 374         }
5060 29 Oct 18 olle 375       }
5060 29 Oct 18 olle 376     }
5060 29 Oct 18 olle 377   }
5060 29 Oct 18 olle 378   
5114 20 Nov 18 olle 379   istat.storagePositionsLoaded = function(response)
5114 20 Nov 18 olle 380   {
5114 20 Nov 18 olle 381     var freeWells = response.wells;
5114 20 Nov 18 olle 382 //alert("ffpe_section_registration_alt_rec.js::storagePositionsLoaded(): freeWells = " + JSON.stringify(freeWells));
5114 20 Nov 18 olle 383     var ihc = response.ihc;
5114 20 Nov 18 olle 384     var heglass = response.heglass;
5114 20 Nov 18 olle 385 //alert("ffpe_section_registration_alt_rec.js::storagePositionsLoaded(): heglass = " + JSON.stringify(heglass));
5114 20 Nov 18 olle 386     var frm = document.forms['meludi'];
5114 20 Nov 18 olle 387     //var tubeContentType = frm.tubeContentType.value;
5114 20 Nov 18 olle 388     var tubeContentType = 'Specimen';
5114 20 Nov 18 olle 389     //var nofTubes = parseInt(frm.nofTubes.value);
5114 20 Nov 18 olle 390     // Free wells are found for both DNA and RNA for each specimen tube
5114 20 Nov 18 olle 391     var nofTubes = freeWells.length/2;
5114 20 Nov 18 olle 392     //var extractsFromFirstSpecimenOnly = frm.extractsFromFirstSpecimenOnlyCB.checked;
5114 20 Nov 18 olle 393     var extractsFromFirstSpecimenOnly = false;
5114 20 Nov 18 olle 394
5114 20 Nov 18 olle 395     // No storage space is allocated for first specimen,
5114 20 Nov 18 olle 396     // since all amount is expected to be used for analysis.
5114 20 Nov 18 olle 397     // Specimen tube with i == 0 is therefore skipped.
5114 20 Nov 18 olle 398     if (tubeContentType == 'Specimen')
5114 20 Nov 18 olle 399     {
5114 20 Nov 18 olle 400       for (var i = 0; i < nofTubes; i++)
5114 20 Nov 18 olle 401       {
5114 20 Nov 18 olle 402         //wellIndex = 3*i;
5114 20 Nov 18 olle 403         wellIndex = 2*i;
5114 20 Nov 18 olle 404         var specWell = null;
5114 20 Nov 18 olle 405 /*
5114 20 Nov 18 olle 406         if (i > 0)
5114 20 Nov 18 olle 407         {
5114 20 Nov 18 olle 408           specWell = freeWells[wellIndex];
5114 20 Nov 18 olle 409           if (!specWell || specWell == '') 
5114 20 Nov 18 olle 410           {
5114 20 Nov 18 olle 411             Wizard.setInputStatus('box.'+i, 'invalid', 'Missing box');
5114 20 Nov 18 olle 412             return;
5114 20 Nov 18 olle 413           }
5114 20 Nov 18 olle 414         }
5114 20 Nov 18 olle 415 */
5114 20 Nov 18 olle 416         var dnaWell = null;
5114 20 Nov 18 olle 417         if (i == 0 || !extractsFromFirstSpecimenOnly)
5114 20 Nov 18 olle 418         {
5114 20 Nov 18 olle 419           //dnaWell = freeWells[wellIndex+1];
5114 20 Nov 18 olle 420           dnaWell = freeWells[wellIndex];
5114 20 Nov 18 olle 421 //alert("ffpe_section_registration_alt_rec.js::storagePositionsLoaded(): i = " + i + " wellIndex = " + wellIndex + " dnaWell = " + JSON.stringify(dnaWell));
5114 20 Nov 18 olle 422           if (!dnaWell || dnaWell == '') 
5114 20 Nov 18 olle 423           {
5114 20 Nov 18 olle 424             Wizard.setInputStatus('dnaBox.'+i, 'invalid', 'Missing box');
5114 20 Nov 18 olle 425             return;
5114 20 Nov 18 olle 426           }
5114 20 Nov 18 olle 427         }
5114 20 Nov 18 olle 428         var rnaWell = null;
5114 20 Nov 18 olle 429         if (i == 0 || !extractsFromFirstSpecimenOnly)
5114 20 Nov 18 olle 430         {
5114 20 Nov 18 olle 431           //rnaWell = freeWells[wellIndex+2];
5114 20 Nov 18 olle 432           rnaWell = freeWells[wellIndex+1];
5114 20 Nov 18 olle 433           if (!rnaWell || rnaWell == '') 
5114 20 Nov 18 olle 434           {
5114 20 Nov 18 olle 435             Wizard.setInputStatus('rnaBox.'+i, 'invalid', 'Missing box');
5114 20 Nov 18 olle 436             return;
5114 20 Nov 18 olle 437           }
5114 20 Nov 18 olle 438         }
5114 20 Nov 18 olle 439         var heGlassFBox = heglass[wellIndex];
5114 20 Nov 18 olle 440         var heGlassEBox = heglass[wellIndex+1];
5114 20 Nov 18 olle 441         
5114 20 Nov 18 olle 442         // Update form fields for storage plates
5114 20 Nov 18 olle 443 /*
5114 20 Nov 18 olle 444         if (specWell)
5114 20 Nov 18 olle 445         {
5114 20 Nov 18 olle 446           frm['box.'+i].value = specWell.bioPlate.name;
5114 20 Nov 18 olle 447           frm['row.'+i].value = Meludi.wellToAlpha(specWell.row);
5114 20 Nov 18 olle 448           frm['column.'+i].value = specWell.column+1;
5114 20 Nov 18 olle 449         }
5114 20 Nov 18 olle 450 */
5114 20 Nov 18 olle 451       
5114 20 Nov 18 olle 452         if (dnaWell)
5114 20 Nov 18 olle 453         {
5114 20 Nov 18 olle 454           frm['dnaBox.'+i].value = dnaWell.bioPlate.name;
5114 20 Nov 18 olle 455           frm['dnaRow.'+i].value = Meludi.wellToAlpha(dnaWell.row);
5114 20 Nov 18 olle 456           frm['dnaColumn.'+i].value = dnaWell.column+1;
5114 20 Nov 18 olle 457         }
5114 20 Nov 18 olle 458
5114 20 Nov 18 olle 459         if (rnaWell)
5114 20 Nov 18 olle 460         {
5114 20 Nov 18 olle 461           frm['rnaBox.'+i].value = rnaWell.bioPlate.name;
5114 20 Nov 18 olle 462           frm['rnaRow.'+i].value = Meludi.wellToAlpha(rnaWell.row);
5114 20 Nov 18 olle 463           frm['rnaColumn.'+i].value = rnaWell.column+1;
5114 20 Nov 18 olle 464         }
5114 20 Nov 18 olle 465
5114 20 Nov 18 olle 466         if (heGlassFBox)
5114 20 Nov 18 olle 467         {
5114 20 Nov 18 olle 468           frm['heGlassFBox.'+i].value = heGlassFBox.storageBox;
5114 20 Nov 18 olle 469           frm['heGlassFPosition.'+i].value = heGlassFBox.position;
5114 20 Nov 18 olle 470         }
5114 20 Nov 18 olle 471
5114 20 Nov 18 olle 472         if (heGlassEBox)
5114 20 Nov 18 olle 473         {
5114 20 Nov 18 olle 474           frm['heGlassEBox.'+i].value = heGlassEBox.storageBox;
5114 20 Nov 18 olle 475           frm['heGlassEPosition.'+i].value = heGlassEBox.position;
5114 20 Nov 18 olle 476         }
5114 20 Nov 18 olle 477
5114 20 Nov 18 olle 478         // Move focus to next field
5114 20 Nov 18 olle 479 /*
5114 20 Nov 18 olle 480         Events.addEventHandler('box.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'row.'+i });
5114 20 Nov 18 olle 481         Events.addEventHandler('row.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'column.'+i });
5114 20 Nov 18 olle 482         Events.addEventHandler('column.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'dnaBox.'+i });
5114 20 Nov 18 olle 483 */
5114 20 Nov 18 olle 484
5114 20 Nov 18 olle 485         Events.addEventHandler('dnaBox.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'dnaRow.'+i });
5114 20 Nov 18 olle 486         Events.addEventHandler('dnaRow.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'dnaColumn.'+i });
5114 20 Nov 18 olle 487         Events.addEventHandler('dnaColumn.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'rnaBox.'+i });
5114 20 Nov 18 olle 488
5114 20 Nov 18 olle 489         Events.addEventHandler('rnaBox.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'rnaRow.'+i });
5114 20 Nov 18 olle 490         Events.addEventHandler('rnaRow.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'rnaColumn.'+i });
5114 20 Nov 18 olle 491         Events.addEventHandler('rnaColumn.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'nofSections.'+i });
5114 20 Nov 18 olle 492
5114 20 Nov 18 olle 493         Events.addEventHandler('nofSections.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'comment.'+i });
5114 20 Nov 18 olle 494       
5114 20 Nov 18 olle 495         // Form validation
5114 20 Nov 18 olle 496 /*
5114 20 Nov 18 olle 497         Events.addEventHandler('column.'+i, 'keypress', Events.integerOnly);
5114 20 Nov 18 olle 498         Events.addEventHandler('box.'+i, 'change', istat.wellOnChange, { 'boxtype': 'Specimen', 'index': i });
5114 20 Nov 18 olle 499         Events.addEventHandler('row.'+i, 'change', istat.wellOnChange, { 'boxtype': 'Specimen', 'index': i });
5114 20 Nov 18 olle 500         Events.addEventHandler('column.'+i, 'change', istat.wellOnChange, { 'boxtype': 'Specimen', 'index': i });
5114 20 Nov 18 olle 501         Events.addEventHandler('box.'+i, 'keyup', istat.boxOnKeyUp, { 'boxtype': 'Specimen'});
5114 20 Nov 18 olle 502 */
5114 20 Nov 18 olle 503
5114 20 Nov 18 olle 504         Events.addEventHandler('dnaColumn.'+i, 'keypress', Events.integerOnly);
5114 20 Nov 18 olle 505         Events.addEventHandler('dnaBox.'+i, 'change', istat.wellOnChange, { 'boxtype': 'DNA', 'index': i });
5114 20 Nov 18 olle 506         Events.addEventHandler('dnaRow.'+i, 'change', istat.wellOnChange, { 'boxtype': 'DNA', 'index': i });
5114 20 Nov 18 olle 507         Events.addEventHandler('dnaColumn.'+i, 'change', istat.wellOnChange, { 'boxtype': 'DNA', 'index': i });
5114 20 Nov 18 olle 508         Events.addEventHandler('dnaBox.'+i, 'keyup', istat.boxOnKeyUp, { 'boxtype': 'DNA'});
5114 20 Nov 18 olle 509
5114 20 Nov 18 olle 510         Events.addEventHandler('rnaColumn.'+i, 'keypress', Events.integerOnly);
5114 20 Nov 18 olle 511         Events.addEventHandler('rnaBox.'+i, 'change', istat.wellOnChange, { 'boxtype': 'RNA', 'index': i });
5114 20 Nov 18 olle 512         Events.addEventHandler('rnaRow.'+i, 'change', istat.wellOnChange, { 'boxtype': 'RNA', 'index': i });
5114 20 Nov 18 olle 513         Events.addEventHandler('rnaColumn.'+i, 'change', istat.wellOnChange, { 'boxtype': 'RNA', 'index': i });
5114 20 Nov 18 olle 514         Events.addEventHandler('rnaBox.'+i, 'keyup', istat.boxOnKeyUp, { 'boxtype': 'RNA'});
5114 20 Nov 18 olle 515
5114 20 Nov 18 olle 516         Events.addEventHandler('nofSections.'+i, 'keypress', Events.integerOnly);
5114 20 Nov 18 olle 517         Events.addEventHandler('nofSections.'+i, 'change', istat.nofSectionsOnChange, { 'index': i });
5114 20 Nov 18 olle 518       
5114 20 Nov 18 olle 519         wellIsValid[i] = true;
5114 20 Nov 18 olle 520         dnaWellIsValid[i] = true;
5114 20 Nov 18 olle 521         rnaWellIsValid[i] = true;
5114 20 Nov 18 olle 522 /*
5114 20 Nov 18 olle 523         Wizard.setInputStatus('position.'+i, 'valid');
5114 20 Nov 18 olle 524 */
5114 20 Nov 18 olle 525 /*
5114 20 Nov 18 olle 526         Wizard.setInputStatus('box.'+i, 'valid');
5114 20 Nov 18 olle 527 */
5114 20 Nov 18 olle 528         if (i == 0 || !extractsFromFirstSpecimenOnly)
5114 20 Nov 18 olle 529         {
5114 20 Nov 18 olle 530           Wizard.setInputStatus('dnaBox.'+i, 'valid');
5114 20 Nov 18 olle 531           Wizard.setInputStatus('rnaBox.'+i, 'valid');
5114 20 Nov 18 olle 532         }
5114 20 Nov 18 olle 533         if (tubeContentType == 'Specimen')
5114 20 Nov 18 olle 534         {
5114 20 Nov 18 olle 535           Wizard.setInputStatus('nofSections.'+i, 'valid');
5114 20 Nov 18 olle 536         }
5114 20 Nov 18 olle 537       }
5114 20 Nov 18 olle 538     }
5114 20 Nov 18 olle 539     else if (tubeContentType == 'DNA' || tubeContentType == 'RNA' || tubeContentType == 'DNA_RNA')
5114 20 Nov 18 olle 540     {
5114 20 Nov 18 olle 541       for (var i = 0; i < nofTubes; i++)
5114 20 Nov 18 olle 542       {
5114 20 Nov 18 olle 543         var wellIndex = i;
5114 20 Nov 18 olle 544         var well = freeWells[wellIndex];
5114 20 Nov 18 olle 545         if (!well || well == '') 
5114 20 Nov 18 olle 546         {
5114 20 Nov 18 olle 547           Wizard.setInputStatus('box.'+i, 'invalid', 'Missing box');
5114 20 Nov 18 olle 548           return;
5114 20 Nov 18 olle 549         }
5114 20 Nov 18 olle 550         frm['box.'+i].value = well.bioPlate.name;
5114 20 Nov 18 olle 551         frm['row.'+i].value = Meludi.wellToAlpha(well.row);
5114 20 Nov 18 olle 552         frm['column.'+i].value = well.column+1;
5114 20 Nov 18 olle 553       
5114 20 Nov 18 olle 554         // Move focus to next field
5114 20 Nov 18 olle 555         Events.addEventHandler('box.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'row.'+i });
5114 20 Nov 18 olle 556         Events.addEventHandler('row.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'column.'+i });
5114 20 Nov 18 olle 557         Events.addEventHandler('column.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'nofSections.'+i });
5114 20 Nov 18 olle 558         Events.addEventHandler('nofSections.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'comment.'+i });
5114 20 Nov 18 olle 559       
5114 20 Nov 18 olle 560         // Form validation
5114 20 Nov 18 olle 561         Events.addEventHandler('column.'+i, 'keypress', Events.integerOnly);
5114 20 Nov 18 olle 562         Events.addEventHandler('box.'+i, 'change', istat.wellOnChange, { 'index': i });
5114 20 Nov 18 olle 563         Events.addEventHandler('row.'+i, 'change', istat.wellOnChange, { 'index': i });
5114 20 Nov 18 olle 564         Events.addEventHandler('column.'+i, 'change', istat.wellOnChange, { 'index': i });
5114 20 Nov 18 olle 565         Events.addEventHandler('box.'+i, 'keyup', istat.boxOnKeyUp);
5114 20 Nov 18 olle 566         Events.addEventHandler('nofSections.'+i, 'keypress', Events.integerOnly);
5114 20 Nov 18 olle 567         Events.addEventHandler('nofSections.'+i, 'change', istat.nofSectionsOnChange, { 'index': i });
5114 20 Nov 18 olle 568       
5114 20 Nov 18 olle 569         wellIsValid[i] = true;
5114 20 Nov 18 olle 570 /*
5114 20 Nov 18 olle 571         Wizard.setInputStatus('position.'+i, 'valid');
5114 20 Nov 18 olle 572 */
5114 20 Nov 18 olle 573         Wizard.setInputStatus('box.'+i, 'valid');
5114 20 Nov 18 olle 574         if (tubeContentType == 'Specimen')
5114 20 Nov 18 olle 575         {
5114 20 Nov 18 olle 576           Wizard.setInputStatus('nofSections.'+i, 'valid');
5114 20 Nov 18 olle 577         }
5114 20 Nov 18 olle 578       }
5114 20 Nov 18 olle 579     }
5114 20 Nov 18 olle 580   }
5114 20 Nov 18 olle 581
5114 20 Nov 18 olle 582   istat.boxOnKeyUp = function(event)
5114 20 Nov 18 olle 583   {
5114 20 Nov 18 olle 584     var frm = document.forms['meludi'];
5114 20 Nov 18 olle 585     var tubeContentType = frm.tubeContentType.value;
5114 20 Nov 18 olle 586     
5114 20 Nov 18 olle 587     var boxType = Data.get(event.currentTarget, 'boxtype');
5114 20 Nov 18 olle 588     var index = Data.int(event.currentTarget, 'index');
5114 20 Nov 18 olle 589
5114 20 Nov 18 olle 590     // Get box prefix, default is for input tubes
5114 20 Nov 18 olle 591     var boxPrefix = 'box.';
5114 20 Nov 18 olle 592     if (boxType && boxType == 'DNA')
5114 20 Nov 18 olle 593     {
5114 20 Nov 18 olle 594       boxPrefix = 'dnaBox.';
5114 20 Nov 18 olle 595     }
5114 20 Nov 18 olle 596     if (boxType && boxType == 'RNA')
5114 20 Nov 18 olle 597     {
5114 20 Nov 18 olle 598       boxPrefix = 'rnaBox.';
5114 20 Nov 18 olle 599     }
5114 20 Nov 18 olle 600
5114 20 Nov 18 olle 601     // Check box name
5114 20 Nov 18 olle 602     var boxIsValid = true;
5114 20 Nov 18 olle 603     var box = frm[boxPrefix+index].value;
5114 20 Nov 18 olle 604     Wizard.setInputStatus(boxPrefix+index);
5114 20 Nov 18 olle 605     // Check for prefix "ML_"
5114 20 Nov 18 olle 606     if (box.indexOf('ML_') != 0)
5114 20 Nov 18 olle 607     {
5114 20 Nov 18 olle 608       boxIsValid = false;
5114 20 Nov 18 olle 609     }
5114 20 Nov 18 olle 610     var suffix = '_sp';
5114 20 Nov 18 olle 611     if (tubeContentType == 'DNA' || (boxType && boxType == 'DNA'))
5114 20 Nov 18 olle 612     {
5114 20 Nov 18 olle 613       suffix = '_dna';
5114 20 Nov 18 olle 614     }
5114 20 Nov 18 olle 615     else if (tubeContentType == 'RNA' || (boxType && boxType == 'RNA'))
5114 20 Nov 18 olle 616     {
5114 20 Nov 18 olle 617       suffix = '_rna';
5114 20 Nov 18 olle 618     }
5114 20 Nov 18 olle 619     // Check for suffix
5114 20 Nov 18 olle 620     if (box.indexOf(suffix) != (box.length - suffix.length))
5114 20 Nov 18 olle 621     {
5114 20 Nov 18 olle 622       boxIsValid = false;
5114 20 Nov 18 olle 623     }
5114 20 Nov 18 olle 624     
5114 20 Nov 18 olle 625     if (!boxIsValid)
5114 20 Nov 18 olle 626     {
5114 20 Nov 18 olle 627       Wizard.setInputStatus(boxPrefix+index, 'invalid', 'Box name must start with "ML_" and end with "'+suffix+'"');
5114 20 Nov 18 olle 628       return;
5114 20 Nov 18 olle 629     }
5114 20 Nov 18 olle 630   }
5114 20 Nov 18 olle 631   
5114 20 Nov 18 olle 632   istat.wellOnChange = function(event)
5114 20 Nov 18 olle 633   {
5114 20 Nov 18 olle 634     var frm = document.forms['meludi'];
5114 20 Nov 18 olle 635     var target = event.currentTarget;
5114 20 Nov 18 olle 636
5114 20 Nov 18 olle 637     var boxType = Data.get(target, 'boxtype');
5114 20 Nov 18 olle 638     var index = Data.int(target, 'index');
5114 20 Nov 18 olle 639
5114 20 Nov 18 olle 640     // Get well position prefixes, default is for input tubes
5114 20 Nov 18 olle 641     var boxPrefix = 'box.';
5114 20 Nov 18 olle 642     var rowPrefix = 'row.';
5114 20 Nov 18 olle 643     var columnPrefix = 'column.';
5114 20 Nov 18 olle 644     if (boxType && boxType == 'DNA')
5114 20 Nov 18 olle 645     {
5114 20 Nov 18 olle 646       boxPrefix = 'dnaBox.';
5114 20 Nov 18 olle 647       rowPrefix = 'dnaRow.';
5114 20 Nov 18 olle 648       columnPrefix = 'dnaColumn.';
5114 20 Nov 18 olle 649     }
5114 20 Nov 18 olle 650     if (boxType && boxType == 'RNA')
5114 20 Nov 18 olle 651     {
5114 20 Nov 18 olle 652       boxPrefix = 'rnaBox.';
5114 20 Nov 18 olle 653       rowPrefix = 'rnaRow.';
5114 20 Nov 18 olle 654       columnPrefix = 'rnaColumn.';
5114 20 Nov 18 olle 655     }
5114 20 Nov 18 olle 656     var box = frm[boxPrefix+index].value;
5114 20 Nov 18 olle 657     var row = frm[rowPrefix+index].value;
5114 20 Nov 18 olle 658     var column = frm[columnPrefix+index].value;
5114 20 Nov 18 olle 659     
5114 20 Nov 18 olle 660     //wellIsValid[index] = true;
5114 20 Nov 18 olle 661     if (!boxType || boxType == 'Specimen')
5114 20 Nov 18 olle 662     {
5114 20 Nov 18 olle 663       wellIsValid[index] = false;
5114 20 Nov 18 olle 664     }
5114 20 Nov 18 olle 665     else if (boxType && boxType == 'DNA')
5114 20 Nov 18 olle 666     {
5114 20 Nov 18 olle 667       dnaWellIsValid[index] = false;
5114 20 Nov 18 olle 668     }
5114 20 Nov 18 olle 669     else if (boxType && boxType == 'RNA')
5114 20 Nov 18 olle 670     {
5114 20 Nov 18 olle 671       rnaWellIsValid[index] = false;
5114 20 Nov 18 olle 672     }
5114 20 Nov 18 olle 673     else
5114 20 Nov 18 olle 674     {
5114 20 Nov 18 olle 675       wellIsValid[index] = false;
5114 20 Nov 18 olle 676     }
5114 20 Nov 18 olle 677     Wizard.setInputStatus(boxPrefix+index);
5114 20 Nov 18 olle 678 /*
5114 20 Nov 18 olle 679     Wizard.setInputStatus('position.'+index);
5114 20 Nov 18 olle 680 */
5114 20 Nov 18 olle 681     
5114 20 Nov 18 olle 682     if (box == '') 
5114 20 Nov 18 olle 683     {
5114 20 Nov 18 olle 684       Wizard.setInputStatus(boxPrefix+index, 'invalid', 'Missing box');
5114 20 Nov 18 olle 685       return;
5114 20 Nov 18 olle 686     }
5114 20 Nov 18 olle 687
5114 20 Nov 18 olle 688     // Position errors are reported on box message line    
5114 20 Nov 18 olle 689     if (row == '')
5114 20 Nov 18 olle 690     {
5114 20 Nov 18 olle 691       Wizard.setInputStatus(boxPrefix+index, 'invalid', 'Missing row');
5114 20 Nov 18 olle 692       return;
5114 20 Nov 18 olle 693     }
5114 20 Nov 18 olle 694
5114 20 Nov 18 olle 695     if (column == '')
5114 20 Nov 18 olle 696     {
5114 20 Nov 18 olle 697       Wizard.setInputStatus(boxPrefix+index, 'invalid', 'Missing column');
5114 20 Nov 18 olle 698       return;
5114 20 Nov 18 olle 699     }
5114 20 Nov 18 olle 700     
5114 20 Nov 18 olle 701     // Check for duplicates
5114 20 Nov 18 olle 702     var nofTubes = parseInt(frm.nofTubes.value);
5114 20 Nov 18 olle 703     for (var i=0; i < nofTubes; i++)
5114 20 Nov 18 olle 704     {    
5114 20 Nov 18 olle 705       if (i != index)
5114 20 Nov 18 olle 706       {
5114 20 Nov 18 olle 707         if (box == frm.elements[boxPrefix+i].value && row == frm[rowPrefix+i].value && column == frm[columnPrefix+i].value)
5114 20 Nov 18 olle 708         {
5114 20 Nov 18 olle 709           Wizard.setInputStatus(boxPrefix+index, 'invalid', 'The position is already used once in this wizard');        
5114 20 Nov 18 olle 710           return;
5114 20 Nov 18 olle 711         }
5114 20 Nov 18 olle 712       }
5114 20 Nov 18 olle 713     }
5114 20 Nov 18 olle 714
5114 20 Nov 18 olle 715     //Wizard.setInputStatus('position.'+index, 'checking', 'Checking...');
5114 20 Nov 18 olle 716     Wizard.setInputStatus(boxPrefix+index, 'checking', 'Checking...');
5114 20 Nov 18 olle 717     
5114 20 Nov 18 olle 718     // Seems to be ok -- check if used by another sample
5114 20 Nov 18 olle 719     var request = Ajax.getXmlHttpRequest();
5114 20 Nov 18 olle 720     var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId();
5114 20 Nov 18 olle 721     url += '&cmd=ValidateWell';
5114 20 Nov 18 olle 722     url += '&box=' + encodeURIComponent(box);  
5114 20 Nov 18 olle 723     url += '&row=' + encodeURIComponent(row);
5114 20 Nov 18 olle 724     url += '&column=' + encodeURIComponent(column);
5114 20 Nov 18 olle 725     
5114 20 Nov 18 olle 726     Wizard.asyncJsonRequest(url, function(response) { istat.onBoxValidated(response, boxType, index) } );
5114 20 Nov 18 olle 727   }
5114 20 Nov 18 olle 728   
5114 20 Nov 18 olle 729   istat.onBoxValidated = function(response, boxType, index)
5114 20 Nov 18 olle 730   {
5114 20 Nov 18 olle 731     // Get well position prefixes, default is for input tubes
5114 20 Nov 18 olle 732     var boxPrefix = 'box.';
5114 20 Nov 18 olle 733     if (boxType && boxType == 'DNA')
5114 20 Nov 18 olle 734     {
5114 20 Nov 18 olle 735       boxPrefix = 'dnaBox.';
5114 20 Nov 18 olle 736     }
5114 20 Nov 18 olle 737     if (boxType && boxType == 'RNA')
5114 20 Nov 18 olle 738     {
5114 20 Nov 18 olle 739       boxPrefix = 'rnaBox.';
5114 20 Nov 18 olle 740     }
5114 20 Nov 18 olle 741
5114 20 Nov 18 olle 742     //Wizard.setInputStatus('position.'+index);
5114 20 Nov 18 olle 743     Wizard.setInputStatus(boxPrefix+index);
5114 20 Nov 18 olle 744     if (response.message)
5114 20 Nov 18 olle 745     {
5114 20 Nov 18 olle 746       //Wizard.setInputStatus(response.box ? 'box.'+index : 'position.'+index, 'invalid', Strings.encodeTags(response.message));
5114 20 Nov 18 olle 747       Wizard.setInputStatus(boxPrefix+index, 'invalid', Strings.encodeTags(response.message));
5114 20 Nov 18 olle 748       return;
5114 20 Nov 18 olle 749     }
5114 20 Nov 18 olle 750     
5114 20 Nov 18 olle 751     //wellIsValid[index] = true;
5114 20 Nov 18 olle 752     if (!boxType || boxType == 'Specimen')
5114 20 Nov 18 olle 753     {
5114 20 Nov 18 olle 754       wellIsValid[index] = true;
5114 20 Nov 18 olle 755     }
5114 20 Nov 18 olle 756     else if (boxType && boxType == 'DNA')
5114 20 Nov 18 olle 757     {
5114 20 Nov 18 olle 758       dnaWellIsValid[index] = true;
5114 20 Nov 18 olle 759     }
5114 20 Nov 18 olle 760     else if (boxType && boxType == 'RNA')
5114 20 Nov 18 olle 761     {
5114 20 Nov 18 olle 762       rnaWellIsValid[index] = true;
5114 20 Nov 18 olle 763     }
5114 20 Nov 18 olle 764     else
5114 20 Nov 18 olle 765     {
5114 20 Nov 18 olle 766       wellIsValid[index] = true;
5114 20 Nov 18 olle 767     }
5114 20 Nov 18 olle 768     Wizard.setInputStatus(boxPrefix+index, 'valid');
5114 20 Nov 18 olle 769 /*
5114 20 Nov 18 olle 770     Wizard.setInputStatus('position.'+index, 'valid');
5114 20 Nov 18 olle 771 */
5114 20 Nov 18 olle 772   }
5114 20 Nov 18 olle 773
5114 20 Nov 18 olle 774   
5114 20 Nov 18 olle 775   istat.nofSectionsOnChange = function(event)
5114 20 Nov 18 olle 776   {
5114 20 Nov 18 olle 777     var frm = document.forms['meludi'];
5114 20 Nov 18 olle 778     var target = event.currentTarget;
5114 20 Nov 18 olle 779
5114 20 Nov 18 olle 780     var index = Data.int(target, 'index');
5114 20 Nov 18 olle 781     var nofSections = frm['nofSections.'+index].value;
5114 20 Nov 18 olle 782
5114 20 Nov 18 olle 783     Wizard.setInputStatus('nofSections.'+index);
5114 20 Nov 18 olle 784
5114 20 Nov 18 olle 785     if (nofSections == '')
5114 20 Nov 18 olle 786     {
5114 20 Nov 18 olle 787       Wizard.setInputStatus('nofSections'+index, 'invalid', 'Missing');
5114 20 Nov 18 olle 788       return;
5114 20 Nov 18 olle 789     }
5114 20 Nov 18 olle 790     if (parseInt(nofSections) < 1)
5114 20 Nov 18 olle 791     {
5114 20 Nov 18 olle 792       Wizard.setInputStatus('nofSections'+index, 'invalid', 'Must be at least 1');
5114 20 Nov 18 olle 793       return;    
5114 20 Nov 18 olle 794     }
5114 20 Nov 18 olle 795     Wizard.setInputStatus('nofSections'+index, 'valid');
5114 20 Nov 18 olle 796   }
5114 20 Nov 18 olle 797
5060 29 Oct 18 olle 798   istat.validateStep2 = function(event)
5060 29 Oct 18 olle 799   {
5060 29 Oct 18 olle 800     var valid = true;
5060 29 Oct 18 olle 801     //var frm = document.forms['meludi'];
5060 29 Oct 18 olle 802
5060 29 Oct 18 olle 803 /*
5060 29 Oct 18 olle 804     // Check that all FFPE blocks have PAD numbers
5060 29 Oct 18 olle 805     var nofBlocks = ffpeBlockList.length;
5060 29 Oct 18 olle 806     for (var i = 0; i < nofBlocks; i++)
5060 29 Oct 18 olle 807     {
5060 29 Oct 18 olle 808       if (frm['pad.'+i].value == '')
5060 29 Oct 18 olle 809       {
5060 29 Oct 18 olle 810         Wizard.setInputStatus('pad.'+i, 'warning', 'Missing');
5060 29 Oct 18 olle 811         valid = false;
5060 29 Oct 18 olle 812       }
5060 29 Oct 18 olle 813     }
5060 29 Oct 18 olle 814 */
5060 29 Oct 18 olle 815     if (!valid)
5060 29 Oct 18 olle 816     {
5060 29 Oct 18 olle 817       event.preventDefault();
5060 29 Oct 18 olle 818     }
5060 29 Oct 18 olle 819   }
5060 29 Oct 18 olle 820
5060 29 Oct 18 olle 821   istat.submit = function()
5060 29 Oct 18 olle 822   {
5060 29 Oct 18 olle 823     var frm = document.forms['meludi'];
5060 29 Oct 18 olle 824     var ffpeBlockList = istat.getSelectedItemsList();
5060 29 Oct 18 olle 825     
5060 29 Oct 18 olle 826     var ffpeSectionInfo = {};
5060 29 Oct 18 olle 827     var nofBlocks = ffpeBlockList.length;
5060 29 Oct 18 olle 828     ffpeSectionInfo.ffpeSections = [];
5060 29 Oct 18 olle 829     for (var i = 0; i < nofBlocks; i++)
5060 29 Oct 18 olle 830     {
5060 29 Oct 18 olle 831       var ffpeSection ={};
5114 20 Nov 18 olle 832       ffpeSection.name = ffpeBlockList[i].name + '.s';
5060 29 Oct 18 olle 833       ffpeSection.blockName = ffpeBlockList[i].name;
5060 29 Oct 18 olle 834       //ffpeBlock.samplingDate = frm['samplingDate'].value;
5060 29 Oct 18 olle 835       //ffpeSection.arrivalDate = frm['arrivalDate'].value;
5060 29 Oct 18 olle 836       ffpeSection.pad = ffpeBlockList[i].pad;
5114 20 Nov 18 olle 837       ffpeSection.materialNumber = ffpeBlockList[i].materialNumber;
5060 29 Oct 18 olle 838       ffpeSection.yellowLabel = null;
5060 29 Oct 18 olle 839       var yellowLabelCB = false;
5060 29 Oct 18 olle 840       yellowLabelCB = frm['yellowLabel.'+i].checked;
5060 29 Oct 18 olle 841       if (yellowLabelCB)
5060 29 Oct 18 olle 842       {
5060 29 Oct 18 olle 843         ffpeSection.yellowLabel = 'yellow';
5060 29 Oct 18 olle 844       }
5060 29 Oct 18 olle 845       ffpeSection.nofSections = frm['nofSections.'+i].value;
5114 20 Nov 18 olle 846       //ffpeSection.viableTumourCellsPercent = frm['pctViabTumourCells.'+i].value;
5060 29 Oct 18 olle 847       ffpeSection.comment = frm['comment.'+i].value;
5060 29 Oct 18 olle 848       //ffpeBlock.operator = frm['operator'].value;
5114 20 Nov 18 olle 849       
5114 20 Nov 18 olle 850       ffpeSection.dnaBox = frm['dnaBox.'+i].value;
5114 20 Nov 18 olle 851       ffpeSection.dnaRow = frm['dnaRow.'+i].value;
5114 20 Nov 18 olle 852       ffpeSection.dnaColumn = frm['dnaColumn.'+i].value;
5114 20 Nov 18 olle 853       
5114 20 Nov 18 olle 854       ffpeSection.rnaBox = frm['rnaBox.'+i].value;
5114 20 Nov 18 olle 855       ffpeSection.rnaRow = frm['rnaRow.'+i].value;
5114 20 Nov 18 olle 856       ffpeSection.rnaColumn = frm['rnaColumn.'+i].value;
5114 20 Nov 18 olle 857
5114 20 Nov 18 olle 858       ffpeSection.heGlassFBox = frm['heGlassFBox.'+i].value;
5114 20 Nov 18 olle 859       ffpeSection.heGlassFPosition = frm['heGlassFPosition.'+i].value;
5832 21 Feb 20 olle 860       //ffpeSection.pctTumourCellsF = frm['pctTumourCellsF.'+i].value;
5114 20 Nov 18 olle 861
5114 20 Nov 18 olle 862       ffpeSection.heGlassEBox = frm['heGlassEBox.'+i].value;
5114 20 Nov 18 olle 863       ffpeSection.heGlassEPosition = frm['heGlassEPosition.'+i].value;
5832 21 Feb 20 olle 864       //ffpeSection.pctTumourCellsE = frm['pctTumourCellsE.'+i].value;
5114 20 Nov 18 olle 865       //
5060 29 Oct 18 olle 866       ffpeSectionInfo.ffpeSections[i] = ffpeSection;
5060 29 Oct 18 olle 867     }
5060 29 Oct 18 olle 868     var submitInfo = {};
5060 29 Oct 18 olle 869     submitInfo.ffpeSectionInfo = ffpeSectionInfo;
5060 29 Oct 18 olle 870
5060 29 Oct 18 olle 871     var url = '../BaseLineRegistration.servlet?ID='+App.getSessionId();
5060 29 Oct 18 olle 872     url += '&cmd=RegisterFFPESections';
5060 29 Oct 18 olle 873     Wizard.showLoadingAnimation('Registering FFPE section[s]...');
5060 29 Oct 18 olle 874     Wizard.asyncJsonRequest(url, istat.submissionResults, 'POST', JSON.stringify(submitInfo));
5060 29 Oct 18 olle 875   }
5060 29 Oct 18 olle 876   
5060 29 Oct 18 olle 877   istat.submissionResults = function(response)
5060 29 Oct 18 olle 878   {
5060 29 Oct 18 olle 879     Wizard.showFinalMessage(response.messages);
5060 29 Oct 18 olle 880     Doc.show('gorestart');
5060 29 Oct 18 olle 881   }
5060 29 Oct 18 olle 882
5060 29 Oct 18 olle 883   istat.getSelectedItemsList = function()
5060 29 Oct 18 olle 884   {
5060 29 Oct 18 olle 885     var frm = document.forms['meludi'];
5060 29 Oct 18 olle 886     
5060 29 Oct 18 olle 887     // Get number of selected extract source items
5060 29 Oct 18 olle 888     var numItems = 0;
5060 29 Oct 18 olle 889     var selItemsList = [];
5060 29 Oct 18 olle 890     for (var i = 0; i < frm.extractSourceItems.length; i++)
5060 29 Oct 18 olle 891     {
5060 29 Oct 18 olle 892       if (frm.extractSourceItems[i].selected)
5060 29 Oct 18 olle 893       {
5060 29 Oct 18 olle 894         if (frm.extractSourceItems[i].item != null)
5060 29 Oct 18 olle 895         {
5060 29 Oct 18 olle 896           selItemsList[numItems] = frm.extractSourceItems[i].item;
5060 29 Oct 18 olle 897           numItems++;
5060 29 Oct 18 olle 898         }
5060 29 Oct 18 olle 899       }
5060 29 Oct 18 olle 900     }
5060 29 Oct 18 olle 901     return selItemsList;
5060 29 Oct 18 olle 902   }
5060 29 Oct 18 olle 903
5060 29 Oct 18 olle 904   return istat;
5060 29 Oct 18 olle 905 }();
5060 29 Oct 18 olle 906
5060 29 Oct 18 olle 907 Doc.onLoad(Istat.initPage);
5060 29 Oct 18 olle 908