2677 |
17 Sep 14 |
nicklas |
var SpecimenTubeReg = function() |
2677 |
17 Sep 14 |
nicklas |
2 |
{ |
2677 |
17 Sep 14 |
nicklas |
var streg = {}; |
2702 |
26 Sep 14 |
nicklas |
var debug = 0; |
2677 |
17 Sep 14 |
nicklas |
5 |
|
2677 |
17 Sep 14 |
nicklas |
var caseInfo; |
5345 |
02 Apr 19 |
nicklas |
var siteInfo; |
5333 |
28 Mar 19 |
nicklas |
var freeWells; |
5333 |
28 Mar 19 |
nicklas |
var freePausedWells; |
2677 |
17 Sep 14 |
nicklas |
10 |
|
2677 |
17 Sep 14 |
nicklas |
var nofTubesIsValid = false; |
2677 |
17 Sep 14 |
nicklas |
var samplingDateIsValid = true; |
2677 |
17 Sep 14 |
nicklas |
var rnaLaterDateIsValid = true; |
2677 |
17 Sep 14 |
nicklas |
var lateralityIsValid = true; |
2677 |
17 Sep 14 |
nicklas |
var biopsyTypeIsValid = true; |
2677 |
17 Sep 14 |
nicklas |
16 |
|
2677 |
17 Sep 14 |
nicklas |
var wellIsValid = []; |
2677 |
17 Sep 14 |
nicklas |
18 |
|
2677 |
17 Sep 14 |
nicklas |
var restartTimer; |
2677 |
17 Sep 14 |
nicklas |
var restartAt; |
2677 |
17 Sep 14 |
nicklas |
21 |
|
2677 |
17 Sep 14 |
nicklas |
// Page initialization |
2677 |
17 Sep 14 |
nicklas |
streg.initPage = function() |
2677 |
17 Sep 14 |
nicklas |
24 |
{ |
2677 |
17 Sep 14 |
nicklas |
// Step 1 |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', streg.validateStep1); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('caseName', 'keypress', Wizard.goNextOnTabOrEnter); |
2677 |
17 Sep 14 |
nicklas |
28 |
|
2677 |
17 Sep 14 |
nicklas |
// Step 2 |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', streg.initializeStep2); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', streg.validateStep2); |
2842 |
20 Oct 14 |
nicklas |
Events.addEventHandler('nofTubes', 'keypress', Events.integerOnly); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('nofTubes', 'blur', streg.nofTubesOnChange); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('arrivalDate', 'blur', Wizard.validateDate); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('samplingDate', 'blur', streg.samplingDateOnChange); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('samplingTime', 'blur', streg.samplingDateOnChange); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('rnaLaterDate', 'blur', streg.rnaLaterDateOnChange); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('rnaLaterTime', 'blur', streg.rnaLaterDateOnChange); |
2677 |
17 Sep 14 |
nicklas |
39 |
|
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('lateralityLEFT', 'click', streg.lateralityOnChange); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('lateralityRIGHT', 'click', streg.lateralityOnChange); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('lateralityU', 'click', streg.lateralityOnChange); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('biopsyType', 'change', streg.biopsyTypeOnChange); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('otherPathNote', 'keypress', Wizard.goNextOnTab); |
2677 |
17 Sep 14 |
nicklas |
45 |
|
2677 |
17 Sep 14 |
nicklas |
// Step 3 |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('step-3', 'wizard-initialize', streg.initializeStep3); |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('step-3', 'wizard-validate', streg.validateStep3); |
2677 |
17 Sep 14 |
nicklas |
49 |
|
2677 |
17 Sep 14 |
nicklas |
// Navigation |
2677 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2677 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2677 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2677 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2677 |
17 Sep 14 |
nicklas |
Buttons.addClickHandler('gostop', streg.stopAutoRestart); |
2677 |
17 Sep 14 |
nicklas |
56 |
|
2677 |
17 Sep 14 |
nicklas |
// Final registration |
2677 |
17 Sep 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', streg.submit); |
2677 |
17 Sep 14 |
nicklas |
59 |
|
2677 |
17 Sep 14 |
nicklas |
Doc.show('step-1'); |
2677 |
17 Sep 14 |
nicklas |
Doc.show('gonext'); |
4546 |
29 Jun 17 |
nicklas |
62 |
|
4546 |
29 Jun 17 |
nicklas |
// Load counters for storage box check |
4546 |
29 Jun 17 |
nicklas |
var url = '../Session.servlet?ID='+App.getSessionId(); |
4546 |
29 Jun 17 |
nicklas |
url += '&cmd=GetCounters' |
4546 |
29 Jun 17 |
nicklas |
Wizard.asyncJsonRequest(url, streg.countersLoaded); |
2677 |
17 Sep 14 |
nicklas |
67 |
} |
2677 |
17 Sep 14 |
nicklas |
68 |
|
4546 |
29 Jun 17 |
nicklas |
streg.countersLoaded = function(response) |
4546 |
29 Jun 17 |
nicklas |
70 |
{ |
4546 |
29 Jun 17 |
nicklas |
if (response.counts) |
4546 |
29 Jun 17 |
nicklas |
72 |
{ |
4546 |
29 Jun 17 |
nicklas |
var emptyBoxes = response.counts['empty-storage-boxes']; |
4546 |
29 Jun 17 |
nicklas |
if (emptyBoxes < 2) |
4546 |
29 Jun 17 |
nicklas |
75 |
{ |
4546 |
29 Jun 17 |
nicklas |
Wizard.showGoNextConfirmation(false, '<span class="moreboxes">There is only ' + emptyBoxes + ' empty storage box. Create more boxes with the <i>Storage box creation wizard</i>.</span>'); |
4546 |
29 Jun 17 |
nicklas |
77 |
} |
4546 |
29 Jun 17 |
nicklas |
78 |
} |
4546 |
29 Jun 17 |
nicklas |
79 |
} |
4546 |
29 Jun 17 |
nicklas |
80 |
|
2677 |
17 Sep 14 |
nicklas |
streg.validateStep1 = function(event) |
2677 |
17 Sep 14 |
nicklas |
82 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
84 |
|
5276 |
05 Feb 19 |
nicklas |
var caseName = frm.caseName.value.toUpperCase(); |
2677 |
17 Sep 14 |
nicklas |
var caseIsValid = false; |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('caseName'); |
2677 |
17 Sep 14 |
nicklas |
if (caseName == '') |
2677 |
17 Sep 14 |
nicklas |
89 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('caseName', 'invalid', 'Missing'); |
2677 |
17 Sep 14 |
nicklas |
frm.caseName.focus(); |
2677 |
17 Sep 14 |
nicklas |
92 |
} |
2840 |
20 Oct 14 |
nicklas |
else if (!Reggie.isValidCaseName(caseName, true)) // Allow C/D suffix to be used |
2677 |
17 Sep 14 |
nicklas |
94 |
{ |
2840 |
20 Oct 14 |
nicklas |
Wizard.setInputStatus('caseName', 'invalid', 'Only 7-digits name + optional \'C\' or \'D\' is allowed.'); |
2677 |
17 Sep 14 |
nicklas |
frm.caseName.focus(); |
2677 |
17 Sep 14 |
nicklas |
97 |
} |
2677 |
17 Sep 14 |
nicklas |
else |
2677 |
17 Sep 14 |
nicklas |
99 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('caseName', 'valid'); |
5276 |
05 Feb 19 |
nicklas |
frm.caseName.value = caseName; |
2677 |
17 Sep 14 |
nicklas |
caseIsValid = true; |
2677 |
17 Sep 14 |
nicklas |
103 |
} |
2677 |
17 Sep 14 |
nicklas |
104 |
|
2677 |
17 Sep 14 |
nicklas |
// If not valid, we prevent the wizard from moving to the next step |
2677 |
17 Sep 14 |
nicklas |
if (!caseIsValid) event.preventDefault(); |
2677 |
17 Sep 14 |
nicklas |
107 |
} |
2677 |
17 Sep 14 |
nicklas |
108 |
|
2677 |
17 Sep 14 |
nicklas |
streg.initializeStep2 = function() |
2677 |
17 Sep 14 |
nicklas |
110 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
var caseName = frm.caseName.value; |
2677 |
17 Sep 14 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
2677 |
17 Sep 14 |
nicklas |
url += '&cmd=GetCaseInfo'; |
2677 |
17 Sep 14 |
nicklas |
url += '&caseName=' + encodeURIComponent(caseName); |
2677 |
17 Sep 14 |
nicklas |
116 |
|
2677 |
17 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Loading information about case...'); |
2677 |
17 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, streg.caseInfoLoaded); |
2677 |
17 Sep 14 |
nicklas |
119 |
} |
2677 |
17 Sep 14 |
nicklas |
120 |
|
2677 |
17 Sep 14 |
nicklas |
121 |
|
2677 |
17 Sep 14 |
nicklas |
streg.caseInfoLoaded = function(response) |
2677 |
17 Sep 14 |
nicklas |
123 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
caseInfo = response.caseInfo; |
5345 |
02 Apr 19 |
nicklas |
siteInfo = response.siteInfo; |
2677 |
17 Sep 14 |
nicklas |
127 |
|
2677 |
17 Sep 14 |
nicklas |
Wizard.setCurrentStep(2); |
2677 |
17 Sep 14 |
nicklas |
Doc.show('gocancel'); |
2677 |
17 Sep 14 |
nicklas |
Doc.show('gonext'); |
2677 |
17 Sep 14 |
nicklas |
131 |
|
2677 |
17 Sep 14 |
nicklas |
frm.arrivalDate.value = Dates.formatDate(new Date(), 'yyyyMMdd'); |
2677 |
17 Sep 14 |
nicklas |
133 |
|
2677 |
17 Sep 14 |
nicklas |
frm.nofTubes.focus(); |
2677 |
17 Sep 14 |
nicklas |
frm.nofTubes.setSelectionRange(0,1); |
2677 |
17 Sep 14 |
nicklas |
136 |
|
2677 |
17 Sep 14 |
nicklas |
// Select 'Laterality' if we have that information since before |
2677 |
17 Sep 14 |
nicklas |
if (caseInfo.laterality) |
2677 |
17 Sep 14 |
nicklas |
139 |
{ |
2677 |
17 Sep 14 |
nicklas |
Forms.checkRadio(frm.laterality, caseInfo.laterality); |
2677 |
17 Sep 14 |
nicklas |
streg.lateralityOnChange(); |
2677 |
17 Sep 14 |
nicklas |
142 |
|
2677 |
17 Sep 14 |
nicklas |
if (caseInfo.laterality == 'LEFT') Doc.hide('lateralityRight'); |
2677 |
17 Sep 14 |
nicklas |
if (caseInfo.laterality == 'RIGHT') Doc.hide('lateralityLeft'); |
2677 |
17 Sep 14 |
nicklas |
Doc.hide('lateralityUnknown'); |
2677 |
17 Sep 14 |
nicklas |
Doc.element('lateralityFromCase').innerHTML = '(From existing case: ' + Strings.encodeTags(caseInfo.name) + ')'; |
2677 |
17 Sep 14 |
nicklas |
Doc.show('lateralityFromCase'); |
2677 |
17 Sep 14 |
nicklas |
148 |
} |
2677 |
17 Sep 14 |
nicklas |
149 |
|
2677 |
17 Sep 14 |
nicklas |
150 |
|
2677 |
17 Sep 14 |
nicklas |
var caseName = frm.caseName.value; |
2840 |
20 Oct 14 |
nicklas |
if (caseName.length > 7) |
2677 |
17 Sep 14 |
nicklas |
153 |
{ |
2840 |
20 Oct 14 |
nicklas |
var suffix = caseName.substring(7, 8); |
2840 |
20 Oct 14 |
nicklas |
if (suffix == 'C') |
2840 |
20 Oct 14 |
nicklas |
156 |
{ |
2840 |
20 Oct 14 |
nicklas |
// Select 'SpecimenCoreBiopsy' if case name has 'C' suffix |
2840 |
20 Oct 14 |
nicklas |
Forms.selectListOption(frm.biopsyType, 'SpecimenCoreBiopsy'); |
2840 |
20 Oct 14 |
nicklas |
159 |
} |
2840 |
20 Oct 14 |
nicklas |
else if (suffix == 'D') |
2840 |
20 Oct 14 |
nicklas |
161 |
{ |
2840 |
20 Oct 14 |
nicklas |
// Select 'SpecimenCoreBiopsy2nd' if case name has 'D' suffix |
2840 |
20 Oct 14 |
nicklas |
Forms.selectListOption(frm.biopsyType, 'SpecimenCoreBiopsy2nd'); |
2840 |
20 Oct 14 |
nicklas |
164 |
} |
2677 |
17 Sep 14 |
nicklas |
streg.biopsyTypeOnChange(); |
2677 |
17 Sep 14 |
nicklas |
166 |
} |
2677 |
17 Sep 14 |
nicklas |
167 |
} |
2677 |
17 Sep 14 |
nicklas |
168 |
|
2677 |
17 Sep 14 |
nicklas |
streg.nofTubesOnChange = function() |
2677 |
17 Sep 14 |
nicklas |
170 |
{ |
2677 |
17 Sep 14 |
nicklas |
nofTubesIsValid = false; |
2677 |
17 Sep 14 |
nicklas |
172 |
|
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
var nofTubes = frm.nofTubes.value; |
2677 |
17 Sep 14 |
nicklas |
175 |
|
2677 |
17 Sep 14 |
nicklas |
if (nofTubes == '') |
2677 |
17 Sep 14 |
nicklas |
177 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('nofTubes', 'invalid', 'Missing'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
180 |
} |
2677 |
17 Sep 14 |
nicklas |
if (parseInt(nofTubes) < 1) |
2677 |
17 Sep 14 |
nicklas |
182 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('nofTubes', 'invalid', 'Must be at least 1'); |
4516 |
01 Jun 17 |
nicklas |
return; |
4516 |
01 Jun 17 |
nicklas |
185 |
} |
4516 |
01 Jun 17 |
nicklas |
if (parseInt(nofTubes) > 9) |
4516 |
01 Jun 17 |
nicklas |
187 |
{ |
4516 |
01 Jun 17 |
nicklas |
Wizard.setInputStatus('nofTubes', 'invalid', 'Must not be greater than 9'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
190 |
} |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('nofTubes', 'valid'); |
2677 |
17 Sep 14 |
nicklas |
nofTubesIsValid = true; |
2677 |
17 Sep 14 |
nicklas |
193 |
} |
2677 |
17 Sep 14 |
nicklas |
194 |
|
2677 |
17 Sep 14 |
nicklas |
195 |
|
2677 |
17 Sep 14 |
nicklas |
streg.samplingDateOnChange = function() |
2677 |
17 Sep 14 |
nicklas |
197 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
199 |
|
2677 |
17 Sep 14 |
nicklas |
samplingDateIsValid = false; |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('samplingDate'); |
2677 |
17 Sep 14 |
nicklas |
202 |
|
2677 |
17 Sep 14 |
nicklas |
var samplingDate = frm.samplingDate.value; |
2677 |
17 Sep 14 |
nicklas |
var samplingTime = frm.samplingTime.value; |
2677 |
17 Sep 14 |
nicklas |
205 |
|
2677 |
17 Sep 14 |
nicklas |
if (samplingDate != '' || samplingTime != '') |
2677 |
17 Sep 14 |
nicklas |
207 |
{ |
2677 |
17 Sep 14 |
nicklas |
// Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits. |
2677 |
17 Sep 14 |
nicklas |
samplingDate = Reggie.autoFillDate(samplingDate); |
2677 |
17 Sep 14 |
nicklas |
frm.samplingDate.value = samplingDate; |
2677 |
17 Sep 14 |
nicklas |
211 |
|
2677 |
17 Sep 14 |
nicklas |
samplingTime = Reggie.autoFillTime(samplingTime); |
2677 |
17 Sep 14 |
nicklas |
frm.samplingTime.value = samplingTime; |
2677 |
17 Sep 14 |
nicklas |
214 |
|
2677 |
17 Sep 14 |
nicklas |
var d = Dates.parseString(samplingDate, 'yyyyMMdd'); |
2677 |
17 Sep 14 |
nicklas |
if (d == null) |
2677 |
17 Sep 14 |
nicklas |
217 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('samplingDate', 'invalid', 'Not a valid date'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
220 |
} |
2677 |
17 Sep 14 |
nicklas |
221 |
|
2677 |
17 Sep 14 |
nicklas |
var today = new Date(); |
2677 |
17 Sep 14 |
nicklas |
if (d.getTime() > today.getTime()) |
2677 |
17 Sep 14 |
nicklas |
224 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('samplingDate', 'invalid', 'Future date is not valid'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
227 |
} |
2677 |
17 Sep 14 |
nicklas |
if (frm.rnaLaterDate.value == '') frm.rnaLaterDate.value = samplingDate; |
2677 |
17 Sep 14 |
nicklas |
229 |
|
2677 |
17 Sep 14 |
nicklas |
if (!Dates.isDate(samplingDate + ' ' + samplingTime, 'yyyyMMdd HHmm')) |
2677 |
17 Sep 14 |
nicklas |
231 |
{ |
2677 |
17 Sep 14 |
nicklas |
if (samplingDate != '') |
2677 |
17 Sep 14 |
nicklas |
233 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('samplingDate', 'invalid', 'Not a valid time (if time unknown, also leave date field blank)'); |
2677 |
17 Sep 14 |
nicklas |
235 |
} |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
237 |
} |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('samplingDate', 'valid'); |
2677 |
17 Sep 14 |
nicklas |
239 |
} |
2677 |
17 Sep 14 |
nicklas |
samplingDateIsValid = true; |
2677 |
17 Sep 14 |
nicklas |
streg.rnaLaterDateOnChange(); |
2677 |
17 Sep 14 |
nicklas |
242 |
} |
2677 |
17 Sep 14 |
nicklas |
243 |
|
2677 |
17 Sep 14 |
nicklas |
244 |
|
2677 |
17 Sep 14 |
nicklas |
streg.rnaLaterDateOnChange = function() |
2677 |
17 Sep 14 |
nicklas |
246 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
248 |
|
2677 |
17 Sep 14 |
nicklas |
rnaLaterDateIsValid = false; |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('rnaLaterDate'); |
4996 |
03 Oct 18 |
nicklas |
Wizard.hideGoNextConfirmation(); |
2677 |
17 Sep 14 |
nicklas |
252 |
|
2677 |
17 Sep 14 |
nicklas |
var rnaLaterDate = frm.rnaLaterDate.value; |
2677 |
17 Sep 14 |
nicklas |
var rnaLaterTime = frm.rnaLaterTime.value; |
2677 |
17 Sep 14 |
nicklas |
255 |
|
2677 |
17 Sep 14 |
nicklas |
if (rnaLaterDate != '' || rnaLaterTime != '') |
2677 |
17 Sep 14 |
nicklas |
257 |
{ |
2677 |
17 Sep 14 |
nicklas |
// Auto-fill the date if it's not given in yyyyMMdd |
2677 |
17 Sep 14 |
nicklas |
rnaLaterDate = Reggie.autoFillDate(rnaLaterDate); |
2677 |
17 Sep 14 |
nicklas |
frm.rnaLaterDate.value = rnaLaterDate; |
2677 |
17 Sep 14 |
nicklas |
261 |
|
2677 |
17 Sep 14 |
nicklas |
rnaLaterTime = Reggie.autoFillTime(rnaLaterTime); |
2677 |
17 Sep 14 |
nicklas |
frm.rnaLaterTime.value = rnaLaterTime; |
2677 |
17 Sep 14 |
nicklas |
264 |
|
2677 |
17 Sep 14 |
nicklas |
var d = Dates.parseString(rnaLaterDate, 'yyyyMMdd'); |
2677 |
17 Sep 14 |
nicklas |
if (d == null) |
2677 |
17 Sep 14 |
nicklas |
267 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('rnaLaterDate', 'invalid', 'Not a valid date'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
270 |
} |
2677 |
17 Sep 14 |
nicklas |
var today = new Date(); |
2677 |
17 Sep 14 |
nicklas |
if (d.getTime() > today.getTime()) |
2677 |
17 Sep 14 |
nicklas |
273 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('rnaLaterDate', 'invalid', 'Future date is not valid'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
276 |
} |
2677 |
17 Sep 14 |
nicklas |
277 |
|
2677 |
17 Sep 14 |
nicklas |
var rnaLaterTimestamp = Dates.parseString(rnaLaterDate + ' ' + rnaLaterTime, 'yyyyMMdd HHmm'); |
2677 |
17 Sep 14 |
nicklas |
if (rnaLaterTimestamp == null) |
2677 |
17 Sep 14 |
nicklas |
280 |
{ |
2677 |
17 Sep 14 |
nicklas |
if (rnaLaterDate != '') |
2677 |
17 Sep 14 |
nicklas |
282 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('rnaLaterDate', 'invalid', 'Not a valid time (if time unknown, also leave date field blank)'); |
2677 |
17 Sep 14 |
nicklas |
284 |
} |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
286 |
} |
4996 |
03 Oct 18 |
nicklas |
// The date is valid, but we should also compare it to the sampling date |
4996 |
03 Oct 18 |
nicklas |
Wizard.setInputStatus('rnaLaterDate', 'valid'); |
2677 |
17 Sep 14 |
nicklas |
if (samplingDateIsValid && rnaLaterTimestamp) |
2677 |
17 Sep 14 |
nicklas |
290 |
{ |
4996 |
03 Oct 18 |
nicklas |
var samplingTimestamp = Dates.parseString(frm.samplingDate.value + ' ' + frm.samplingTime.value, 'yyyyMMdd Hmm'); |
4996 |
03 Oct 18 |
nicklas |
var samplingDate = Dates.parseString(frm.samplingDate.value + ' 0000', 'yyyyMMdd Hmm'); // NOTE! Need to specify minutes otherwise we get the current time of day |
4996 |
03 Oct 18 |
nicklas |
293 |
|
2677 |
17 Sep 14 |
nicklas |
if (samplingTimestamp) |
2677 |
17 Sep 14 |
nicklas |
295 |
{ |
4996 |
03 Oct 18 |
nicklas |
var timeToRNALaterInMinutes = (rnaLaterTimestamp.getTime() - samplingTimestamp.getTime()) / (1000 * 60); |
4996 |
03 Oct 18 |
nicklas |
if (timeToRNALaterInMinutes < 0) |
2677 |
17 Sep 14 |
nicklas |
298 |
{ |
4996 |
03 Oct 18 |
nicklas |
Wizard.setInputStatus('rnaLaterDate', 'invalid', 'RNA later time must be later than Sampling time'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
301 |
} |
4996 |
03 Oct 18 |
nicklas |
302 |
|
4996 |
03 Oct 18 |
nicklas |
var daysToRnaLater = (rnaLaterTimestamp.getTime() - samplingDate.getTime()) / (1000 * 3600 * 24); |
4996 |
03 Oct 18 |
nicklas |
if (daysToRnaLater >= 2) |
2677 |
17 Sep 14 |
nicklas |
305 |
{ |
4996 |
03 Oct 18 |
nicklas |
Wizard.setInputStatus('rnaLaterDate', 'invalid', 'Sampling and RNA later dates differ by more than 1 day'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
308 |
} |
4996 |
03 Oct 18 |
nicklas |
else if (daysToRnaLater >= 1) |
4996 |
03 Oct 18 |
nicklas |
310 |
{ |
4996 |
03 Oct 18 |
nicklas |
Wizard.setInputStatus('rnaLaterDate', 'warning', 'Sampling and RNA later dates are different'); |
4996 |
03 Oct 18 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Verify that Sampling and RNA later dates are different'); |
4996 |
03 Oct 18 |
nicklas |
313 |
} |
2677 |
17 Sep 14 |
nicklas |
314 |
} |
2677 |
17 Sep 14 |
nicklas |
315 |
} |
2677 |
17 Sep 14 |
nicklas |
316 |
} |
2677 |
17 Sep 14 |
nicklas |
317 |
|
2677 |
17 Sep 14 |
nicklas |
rnaLaterDateIsValid = true; |
2677 |
17 Sep 14 |
nicklas |
319 |
} |
2677 |
17 Sep 14 |
nicklas |
320 |
|
2677 |
17 Sep 14 |
nicklas |
321 |
|
2677 |
17 Sep 14 |
nicklas |
streg.lateralityOnChange = function() |
2677 |
17 Sep 14 |
nicklas |
323 |
{ |
2677 |
17 Sep 14 |
nicklas |
lateralityIsValid = false; |
2677 |
17 Sep 14 |
nicklas |
325 |
|
2677 |
17 Sep 14 |
nicklas |
// Check selected laterality against specimen tubes |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
var selectedLaterality = Forms.getCheckedRadio(frm.laterality); |
2677 |
17 Sep 14 |
nicklas |
329 |
|
2677 |
17 Sep 14 |
nicklas |
// No laterality/case selected |
2677 |
17 Sep 14 |
nicklas |
if (selectedLaterality == null) |
2677 |
17 Sep 14 |
nicklas |
332 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('laterality', 'invalid', 'Not selected'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
335 |
} |
2677 |
17 Sep 14 |
nicklas |
336 |
|
2677 |
17 Sep 14 |
nicklas |
lateralityIsValid = true; |
2677 |
17 Sep 14 |
nicklas |
338 |
|
2677 |
17 Sep 14 |
nicklas |
if (caseInfo.laterality && caseInfo.laterality != selectedLaterality.value) |
2677 |
17 Sep 14 |
nicklas |
340 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('laterality', 'warning', 'Not same laterality as existing case/specimen'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
343 |
} |
2677 |
17 Sep 14 |
nicklas |
344 |
|
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('laterality', 'valid'); |
2677 |
17 Sep 14 |
nicklas |
346 |
} |
2677 |
17 Sep 14 |
nicklas |
347 |
|
2677 |
17 Sep 14 |
nicklas |
streg.biopsyTypeOnChange = function() |
2677 |
17 Sep 14 |
nicklas |
349 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
var selectedBiopsyType = frm.biopsyType.value; |
2677 |
17 Sep 14 |
nicklas |
biopsyTypeIsValid = false; |
2677 |
17 Sep 14 |
nicklas |
353 |
|
2677 |
17 Sep 14 |
nicklas |
// Check 'SpecimenCoreBiopsy' if case name has 'C' suffix |
2677 |
17 Sep 14 |
nicklas |
var caseName = frm.caseName.value; |
2840 |
20 Oct 14 |
nicklas |
var suffix = caseName.length > 7 ? caseName.substring(7, 8) : null; |
2840 |
20 Oct 14 |
nicklas |
if (suffix == 'C' && selectedBiopsyType != 'SpecimenCoreBiopsy') |
2677 |
17 Sep 14 |
nicklas |
358 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('biopsyType', 'invalid', 'Case name with \'C\' suffix is always SpecimenCoreBiopsy'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
361 |
} |
2840 |
20 Oct 14 |
nicklas |
if (suffix == 'D' && selectedBiopsyType != 'SpecimenCoreBiopsy2nd') |
2840 |
20 Oct 14 |
nicklas |
363 |
{ |
2840 |
20 Oct 14 |
nicklas |
Wizard.setInputStatus('biopsyType', 'invalid', 'Case name with \'D\' suffix is always SpecimenCoreBiopsy2nd'); |
2840 |
20 Oct 14 |
nicklas |
return; |
2840 |
20 Oct 14 |
nicklas |
366 |
} |
2677 |
17 Sep 14 |
nicklas |
367 |
|
2677 |
17 Sep 14 |
nicklas |
biopsyTypeIsValid = true; |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('biopsyType', 'valid'); |
2677 |
17 Sep 14 |
nicklas |
370 |
} |
2677 |
17 Sep 14 |
nicklas |
371 |
|
2677 |
17 Sep 14 |
nicklas |
372 |
|
2677 |
17 Sep 14 |
nicklas |
streg.validateStep2 = function(event) |
2677 |
17 Sep 14 |
nicklas |
374 |
{ |
2677 |
17 Sep 14 |
nicklas |
var valid = true; |
2677 |
17 Sep 14 |
nicklas |
376 |
|
2677 |
17 Sep 14 |
nicklas |
valid &= nofTubesIsValid; |
2677 |
17 Sep 14 |
nicklas |
valid &= Wizard.isValid('arrivalDate'); |
2677 |
17 Sep 14 |
nicklas |
valid &= samplingDateIsValid; |
2677 |
17 Sep 14 |
nicklas |
valid &= rnaLaterDateIsValid; |
2677 |
17 Sep 14 |
nicklas |
valid &= lateralityIsValid; |
2677 |
17 Sep 14 |
nicklas |
valid &= biopsyTypeIsValid; |
2677 |
17 Sep 14 |
nicklas |
383 |
|
2677 |
17 Sep 14 |
nicklas |
if (!valid) event.preventDefault(); |
2677 |
17 Sep 14 |
nicklas |
385 |
} |
2677 |
17 Sep 14 |
nicklas |
386 |
|
2677 |
17 Sep 14 |
nicklas |
streg.initializeStep3 = function() |
2677 |
17 Sep 14 |
nicklas |
388 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
var nofTubes = parseInt(frm.nofTubes.value); |
2677 |
17 Sep 14 |
nicklas |
if (nofTubes > 2) Doc.addClass('step-2', 'auto-hide'); |
2677 |
17 Sep 14 |
nicklas |
392 |
|
2677 |
17 Sep 14 |
nicklas |
var html = ''; |
2677 |
17 Sep 14 |
nicklas |
for (var i=0; i < nofTubes; i++) |
2677 |
17 Sep 14 |
nicklas |
395 |
{ |
5345 |
02 Apr 19 |
nicklas |
var defaultPaused = siteInfo && siteInfo.paused; |
5333 |
28 Mar 19 |
nicklas |
397 |
|
2801 |
13 Oct 14 |
nicklas |
var tubeNo = i+caseInfo.specimenFirstIndex; |
5333 |
28 Mar 19 |
nicklas |
html += '<tbody id="specimenSection.'+i+'"' + (defaultPaused ? 'class="pause-specimen"' : '')+'>'; |
2677 |
17 Sep 14 |
nicklas |
html += '<tr class="section-header">'; |
2801 |
13 Oct 14 |
nicklas |
html += '<td colspan="4">Specimen Tube '+Strings.encodeTags(caseInfo.originalName)+'.'+tubeNo+'</td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '</tr>'; |
2677 |
17 Sep 14 |
nicklas |
403 |
|
3602 |
16 Nov 15 |
nicklas |
html += '<tr>'; |
3602 |
16 Nov 15 |
nicklas |
html += '<td class="subprompt yellow-tag"><label for="yellowLabel.'+i+'">Yellow label</label></td>'; |
3602 |
16 Nov 15 |
nicklas |
html += '<td class="input">'; |
3602 |
16 Nov 15 |
nicklas |
html += '<input type="checkbox" name="yellowLabel.'+i+'" id="yellowLabel.'+i+'"></td>'; |
3602 |
16 Nov 15 |
nicklas |
html += '<td class="status"></td>'; |
3602 |
16 Nov 15 |
nicklas |
html += '<td class="help"></td>'; |
3602 |
16 Nov 15 |
nicklas |
html += '</tr>'; |
3602 |
16 Nov 15 |
nicklas |
411 |
|
2801 |
13 Oct 14 |
nicklas |
html += '<tr>' |
2801 |
13 Oct 14 |
nicklas |
html += '<td class="subprompt">Specimen type</td>'; |
2801 |
13 Oct 14 |
nicklas |
html += '<td class="input">'; |
2801 |
13 Oct 14 |
nicklas |
html += '<select name="specimenType.'+i+'" id="specimenType.'+i+'">'; |
2801 |
13 Oct 14 |
nicklas |
html += '<option selected value="">unknown'; |
2801 |
13 Oct 14 |
nicklas |
html += '<option value="Primary">Primary'; |
2801 |
13 Oct 14 |
nicklas |
html += '<option value="LymphnodeRegional">LymphnodeRegional'; |
2801 |
13 Oct 14 |
nicklas |
html += '<option value="MetastasisDistant">MetastasisDistant'; |
2801 |
13 Oct 14 |
nicklas |
html += '<option value="RecurrenceLocal">RecurrenceLocal'; |
2801 |
13 Oct 14 |
nicklas |
html += '<option value="RecurrenceRegional">RecurrenceRegional'; |
2801 |
13 Oct 14 |
nicklas |
html += '<option value="Normal">Normal'; |
2801 |
13 Oct 14 |
nicklas |
html += '<option value="Uncertain">Uncertain'; |
2801 |
13 Oct 14 |
nicklas |
html += '</select>'; |
2801 |
13 Oct 14 |
nicklas |
html += '</td>'; |
2801 |
13 Oct 14 |
nicklas |
html += '<td class="status" id="specimenType.'+i+'.status"></td>'; |
2801 |
13 Oct 14 |
nicklas |
html += '<td class="help"><span id="specimenType.'+i+'.message" class="message"></span></td>'; |
2801 |
13 Oct 14 |
nicklas |
html += '</tr>'; |
2801 |
13 Oct 14 |
nicklas |
429 |
|
2677 |
17 Sep 14 |
nicklas |
html += '<tr>'; |
5333 |
28 Mar 19 |
nicklas |
html += '<td class="subprompt">Sample processing</td>'; |
5333 |
28 Mar 19 |
nicklas |
html += '<td class="input">'; |
5333 |
28 Mar 19 |
nicklas |
html += '<label><input type="radio" name="processing.'+i+'" value="1" id="continue.'+i+'" '+(defaultPaused?'':'checked')+'>Continue</label>'; |
5333 |
28 Mar 19 |
nicklas |
html += '<label><input type="radio" name="processing.'+i+'" value="0" id="pause.'+i+'" '+(defaultPaused?'checked':'')+'>Pause</label>'; |
5333 |
28 Mar 19 |
nicklas |
html += '</td>'; |
5333 |
28 Mar 19 |
nicklas |
html += '<td class="status"></td>'; |
5333 |
28 Mar 19 |
nicklas |
html += '<td class="help">Select if the specimen should be partitioned and extracted or if it should be paused until later.</td>'; |
5333 |
28 Mar 19 |
nicklas |
html += '</tr>'; |
5333 |
28 Mar 19 |
nicklas |
439 |
|
5333 |
28 Mar 19 |
nicklas |
html += '<tr class="storage-box">'; |
2677 |
17 Sep 14 |
nicklas |
html += '<td class="subprompt">Box</td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '<td class="input">'; |
2677 |
17 Sep 14 |
nicklas |
html += '<input type="text" name="box.'+i+'" id="box.'+i+'" style="width: 12em;" maxlength="12"></td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '<td class="status" id="box.'+i+'.status"></td>'; |
5333 |
28 Mar 19 |
nicklas |
html += '<td class="help"><span id="box.'+i+'.message" class="message"></span>Box-number where the specimen tube should be stored.</td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '</tr>'; |
2677 |
17 Sep 14 |
nicklas |
447 |
|
5333 |
28 Mar 19 |
nicklas |
html += '<tr class="storage-box">'; |
2677 |
17 Sep 14 |
nicklas |
html += '<td class="subprompt">Row</td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '<td class="input">'; |
2677 |
17 Sep 14 |
nicklas |
html += '<input type="text" name="row.'+i+'" id="row.'+i+'" style="text-transform:uppercase; width: 3em;" maxlength="2">'; |
2677 |
17 Sep 14 |
nicklas |
html += ' Column<input type="text" name="column.'+i+'" id="column.'+i+'" style="width: 3em;" maxlength="2">'; |
2677 |
17 Sep 14 |
nicklas |
html += '</td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '<td class="status" id="position.'+i+'.status"></td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '<td class="help"><span id="position.'+i+'.message" class="message"></span></td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '</tr>'; |
2677 |
17 Sep 14 |
nicklas |
457 |
|
2677 |
17 Sep 14 |
nicklas |
html += '<tr class="align-top">'; |
2677 |
17 Sep 14 |
nicklas |
html += '<td class="subprompt">Operator delivery comment</td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '<td class="input"><textarea rows="3" name="comment.'+i+'" id="comment.'+i+'"></textarea></td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '<td class="status" id="comment.'+i+'.status"></td>'; |
2801 |
13 Oct 14 |
nicklas |
html += '<td class="help"><span id="comment.'+i+'.message" class="message"></span>In this field, enter information specific for specimen tube ' +tubeNo+'.</td>'; |
2677 |
17 Sep 14 |
nicklas |
html += '</tr>'; |
3602 |
16 Nov 15 |
nicklas |
464 |
|
3602 |
16 Nov 15 |
nicklas |
html += '</tbody>'; |
2677 |
17 Sep 14 |
nicklas |
466 |
} |
2677 |
17 Sep 14 |
nicklas |
Doc.element('specimen-tubes').innerHTML = html; |
2677 |
17 Sep 14 |
nicklas |
468 |
|
5333 |
28 Mar 19 |
nicklas |
for (var i = 0; i < nofTubes; i++) |
5333 |
28 Mar 19 |
nicklas |
470 |
{ |
5333 |
28 Mar 19 |
nicklas |
// Move focus to next field |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('specimenType.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'box.'+i }); |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('box.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'row.'+i }); |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('row.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'column.'+i }); |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('column.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'comment.'+i }); |
5333 |
28 Mar 19 |
nicklas |
476 |
|
5333 |
28 Mar 19 |
nicklas |
// Form validation |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('column.'+i, 'keypress', Events.integerOnly); |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('box.'+i, 'change', streg.wellOnChange, { 'index': i }); |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('row.'+i, 'change', streg.wellOnChange, { 'index': i }); |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('column.'+i, 'change', streg.wellOnChange, { 'index': i }); |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('box.'+i, 'keyup', streg.boxOnKeyUp); |
5333 |
28 Mar 19 |
nicklas |
483 |
|
5333 |
28 Mar 19 |
nicklas |
// Yellow label + pause |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('yellowLabel.'+i, 'change', streg.yellowLabelOnChange, { 'index': i }); |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('continue.'+i, 'change', streg.processingOnChange, { 'index': i }); |
5333 |
28 Mar 19 |
nicklas |
Events.addEventHandler('pause.'+i, 'change', streg.processingOnChange, { 'index': i }); |
5333 |
28 Mar 19 |
nicklas |
488 |
} |
5333 |
28 Mar 19 |
nicklas |
489 |
|
2677 |
17 Sep 14 |
nicklas |
Wizard.setCurrentStep(3); |
2677 |
17 Sep 14 |
nicklas |
Doc.show('goregister'); |
2677 |
17 Sep 14 |
nicklas |
Doc.show('gocancel'); |
2801 |
13 Oct 14 |
nicklas |
frm['specimenType.0'].focus(); |
2677 |
17 Sep 14 |
nicklas |
494 |
|
2677 |
17 Sep 14 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
5335 |
28 Mar 19 |
nicklas |
url += '&cmd=FindStoragePositions&includePausePositions=1'; |
2677 |
17 Sep 14 |
nicklas |
url += '&nofTubes='+frm.nofTubes.value; |
2677 |
17 Sep 14 |
nicklas |
498 |
|
2677 |
17 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Looking for empty box positions...'); |
2677 |
17 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, streg.storagePositionsLoaded); |
2677 |
17 Sep 14 |
nicklas |
501 |
} |
2677 |
17 Sep 14 |
nicklas |
502 |
|
2677 |
17 Sep 14 |
nicklas |
streg.storagePositionsLoaded = function(response) |
2677 |
17 Sep 14 |
nicklas |
504 |
{ |
5333 |
28 Mar 19 |
nicklas |
freeWells = response.wells; |
5333 |
28 Mar 19 |
nicklas |
freePausedWells = response.pausedWells; |
5333 |
28 Mar 19 |
nicklas |
streg.setDefaultStoragePositions(); |
5333 |
28 Mar 19 |
nicklas |
508 |
} |
5333 |
28 Mar 19 |
nicklas |
509 |
|
5333 |
28 Mar 19 |
nicklas |
streg.setDefaultStoragePositions = function() |
5333 |
28 Mar 19 |
nicklas |
511 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
var nofTubes = parseInt(frm.nofTubes.value); |
5333 |
28 Mar 19 |
nicklas |
514 |
|
5333 |
28 Mar 19 |
nicklas |
var wellNo = 0; |
5333 |
28 Mar 19 |
nicklas |
var pausedWellNo = 0; |
5333 |
28 Mar 19 |
nicklas |
for (var tubeNo = 0; tubeNo < nofTubes; tubeNo++) |
2677 |
17 Sep 14 |
nicklas |
518 |
{ |
5333 |
28 Mar 19 |
nicklas |
var well = Doc.element('pause.'+tubeNo).checked ? freePausedWells[pausedWellNo++] : freeWells[wellNo++]; |
5333 |
28 Mar 19 |
nicklas |
frm['box.'+tubeNo].value = well.bioPlate.name; |
5333 |
28 Mar 19 |
nicklas |
frm['row.'+tubeNo].value = Reggie.wellToAlpha(well.row); |
5333 |
28 Mar 19 |
nicklas |
frm['column.'+tubeNo].value = well.column+1; |
5333 |
28 Mar 19 |
nicklas |
wellIsValid[tubeNo] = true; |
5333 |
28 Mar 19 |
nicklas |
Wizard.setInputStatus('position.'+tubeNo, 'valid'); |
5333 |
28 Mar 19 |
nicklas |
Wizard.setInputStatus('box.'+tubeNo, 'valid'); |
2677 |
17 Sep 14 |
nicklas |
526 |
} |
2677 |
17 Sep 14 |
nicklas |
527 |
} |
2677 |
17 Sep 14 |
nicklas |
528 |
|
3602 |
16 Nov 15 |
nicklas |
// Update class on specimen section |
3602 |
16 Nov 15 |
nicklas |
streg.yellowLabelOnChange = function(event) |
3602 |
16 Nov 15 |
nicklas |
531 |
{ |
3602 |
16 Nov 15 |
nicklas |
var index = Data.int(event.currentTarget, 'index'); |
3602 |
16 Nov 15 |
nicklas |
Doc.addOrRemoveClass('specimenSection.'+index, 'yellow-label', event.currentTarget.checked); |
3602 |
16 Nov 15 |
nicklas |
534 |
} |
3602 |
16 Nov 15 |
nicklas |
535 |
|
5333 |
28 Mar 19 |
nicklas |
streg.processingOnChange = function(event) |
5333 |
28 Mar 19 |
nicklas |
537 |
{ |
5333 |
28 Mar 19 |
nicklas |
var index = Data.int(event.currentTarget, 'index'); |
5333 |
28 Mar 19 |
nicklas |
Doc.addOrRemoveClass('specimenSection.'+index, 'pause-specimen', Doc.element('pause.'+index).checked); |
5333 |
28 Mar 19 |
nicklas |
streg.setDefaultStoragePositions(); |
5333 |
28 Mar 19 |
nicklas |
541 |
} |
5333 |
28 Mar 19 |
nicklas |
542 |
|
2677 |
17 Sep 14 |
nicklas |
streg.boxOnKeyUp = function(event) |
2677 |
17 Sep 14 |
nicklas |
544 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
546 |
|
2677 |
17 Sep 14 |
nicklas |
var index = Data.int(event.currentTarget, 'index'); |
2677 |
17 Sep 14 |
nicklas |
548 |
|
2677 |
17 Sep 14 |
nicklas |
var box = frm['box.'+index].value; |
5333 |
28 Mar 19 |
nicklas |
var paused = Doc.element('pause.'+index).checked; |
5333 |
28 Mar 19 |
nicklas |
var prefix = paused ? 'PSp' : 'Sp'; |
5333 |
28 Mar 19 |
nicklas |
if (box.indexOf(prefix) != 0) |
2677 |
17 Sep 14 |
nicklas |
553 |
{ |
5333 |
28 Mar 19 |
nicklas |
frm['box.'+index].value = prefix+box; |
2677 |
17 Sep 14 |
nicklas |
555 |
} |
2677 |
17 Sep 14 |
nicklas |
556 |
} |
2677 |
17 Sep 14 |
nicklas |
557 |
|
2677 |
17 Sep 14 |
nicklas |
558 |
|
2677 |
17 Sep 14 |
nicklas |
streg.wellOnChange = function(event) |
2677 |
17 Sep 14 |
nicklas |
560 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
var target = event.currentTarget; |
2677 |
17 Sep 14 |
nicklas |
563 |
|
2677 |
17 Sep 14 |
nicklas |
var index = Data.int(target, 'index'); |
2677 |
17 Sep 14 |
nicklas |
var box = frm['box.'+index].value; |
2677 |
17 Sep 14 |
nicklas |
var row = frm['row.'+index].value; |
2677 |
17 Sep 14 |
nicklas |
var column = frm['column.'+index].value; |
5333 |
28 Mar 19 |
nicklas |
var paused = Doc.element('pause.'+index).checked; |
2677 |
17 Sep 14 |
nicklas |
569 |
|
2677 |
17 Sep 14 |
nicklas |
wellIsValid[index] = false; |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('box.'+index); |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('position.'+index); |
2677 |
17 Sep 14 |
nicklas |
573 |
|
2677 |
17 Sep 14 |
nicklas |
if (box == '') |
2677 |
17 Sep 14 |
nicklas |
575 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('box.'+index, 'invalid', 'Missing box'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
578 |
} |
2677 |
17 Sep 14 |
nicklas |
579 |
|
2677 |
17 Sep 14 |
nicklas |
if (row == '') |
2677 |
17 Sep 14 |
nicklas |
581 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('position.'+index, 'invalid', 'Missing row'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
584 |
} |
2677 |
17 Sep 14 |
nicklas |
585 |
|
2677 |
17 Sep 14 |
nicklas |
if (column == '') |
2677 |
17 Sep 14 |
nicklas |
587 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('position.'+index, 'invalid', 'Missing column'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
590 |
} |
2677 |
17 Sep 14 |
nicklas |
591 |
|
2677 |
17 Sep 14 |
nicklas |
// Check for duplicates |
2677 |
17 Sep 14 |
nicklas |
var nofTubes = parseInt(frm.nofTubes.value); |
2677 |
17 Sep 14 |
nicklas |
for (var i=0; i < nofTubes; i++) |
2677 |
17 Sep 14 |
nicklas |
595 |
{ |
2677 |
17 Sep 14 |
nicklas |
if (i != index) |
2677 |
17 Sep 14 |
nicklas |
597 |
{ |
2677 |
17 Sep 14 |
nicklas |
if (box == frm.elements['box.'+i].value && row == frm['row.'+i].value && column == frm['column.'+i].value) |
2677 |
17 Sep 14 |
nicklas |
599 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('position.'+index, 'invalid', 'The position is already used once in this wizard'); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
602 |
} |
2677 |
17 Sep 14 |
nicklas |
603 |
} |
2677 |
17 Sep 14 |
nicklas |
604 |
} |
2677 |
17 Sep 14 |
nicklas |
605 |
|
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('position.'+index, 'checking', 'Checking...'); |
2677 |
17 Sep 14 |
nicklas |
607 |
|
2677 |
17 Sep 14 |
nicklas |
// Seems to be ok -- check if used by another sample |
2677 |
17 Sep 14 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
2677 |
17 Sep 14 |
nicklas |
url += '&cmd=ValidateWell'; |
2677 |
17 Sep 14 |
nicklas |
url += '&box=' + encodeURIComponent(box); |
2677 |
17 Sep 14 |
nicklas |
url += '&row=' + encodeURIComponent(row); |
2677 |
17 Sep 14 |
nicklas |
url += '&column=' + encodeURIComponent(column); |
5333 |
28 Mar 19 |
nicklas |
url += '&paused='+(paused ? 1 : 0) |
2677 |
17 Sep 14 |
nicklas |
615 |
|
2677 |
17 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, function(response) { streg.onBoxValidated(response, index) } ); |
2677 |
17 Sep 14 |
nicklas |
617 |
} |
2677 |
17 Sep 14 |
nicklas |
618 |
|
2677 |
17 Sep 14 |
nicklas |
streg.onBoxValidated = function(response, index) |
2677 |
17 Sep 14 |
nicklas |
620 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('position.'+index); |
2677 |
17 Sep 14 |
nicklas |
if (response.message) |
2677 |
17 Sep 14 |
nicklas |
623 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus(response.box ? 'box.'+index : 'position.'+index, 'invalid', Strings.encodeTags(response.message)); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
626 |
} |
2677 |
17 Sep 14 |
nicklas |
627 |
|
2677 |
17 Sep 14 |
nicklas |
wellIsValid[index] = true; |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('box.'+index, 'valid'); |
2677 |
17 Sep 14 |
nicklas |
Wizard.setInputStatus('position.'+index, 'valid'); |
2677 |
17 Sep 14 |
nicklas |
631 |
} |
2677 |
17 Sep 14 |
nicklas |
632 |
|
2677 |
17 Sep 14 |
nicklas |
633 |
|
2677 |
17 Sep 14 |
nicklas |
streg.validateStep3 = function(event) |
2677 |
17 Sep 14 |
nicklas |
635 |
{ |
2677 |
17 Sep 14 |
nicklas |
var valid = false; |
2677 |
17 Sep 14 |
nicklas |
637 |
|
2677 |
17 Sep 14 |
nicklas |
for (var i = 0; i < wellIsValid.length; i++) |
2677 |
17 Sep 14 |
nicklas |
639 |
{ |
2677 |
17 Sep 14 |
nicklas |
if (!wellIsValid[i]) |
2677 |
17 Sep 14 |
nicklas |
641 |
{ |
2677 |
17 Sep 14 |
nicklas |
event.preventDefault(); |
2677 |
17 Sep 14 |
nicklas |
return; |
2677 |
17 Sep 14 |
nicklas |
644 |
} |
2677 |
17 Sep 14 |
nicklas |
645 |
} |
2677 |
17 Sep 14 |
nicklas |
646 |
} |
2677 |
17 Sep 14 |
nicklas |
647 |
|
2677 |
17 Sep 14 |
nicklas |
648 |
|
2677 |
17 Sep 14 |
nicklas |
streg.submit = function() |
2677 |
17 Sep 14 |
nicklas |
650 |
{ |
2677 |
17 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2677 |
17 Sep 14 |
nicklas |
652 |
|
2677 |
17 Sep 14 |
nicklas |
caseInfo.laterality = Forms.getCheckedRadio(frm.laterality).value; |
2677 |
17 Sep 14 |
nicklas |
caseInfo.samplingDate = Strings.trim(frm.samplingDate.value + ' ' + frm.samplingTime.value); |
2677 |
17 Sep 14 |
nicklas |
caseInfo.rnaLaterDate = Strings.trim(frm.rnaLaterDate.value + ' ' + frm.rnaLaterTime.value); |
2677 |
17 Sep 14 |
nicklas |
caseInfo.otherPathNote = frm.otherPathNote.value; |
2677 |
17 Sep 14 |
nicklas |
caseInfo.arrivalDate = Strings.trim(frm.arrivalDate.value); |
2677 |
17 Sep 14 |
nicklas |
658 |
|
2677 |
17 Sep 14 |
nicklas |
var nofTubes = parseInt(frm.nofTubes.value); |
2677 |
17 Sep 14 |
nicklas |
caseInfo.specimen = []; |
2677 |
17 Sep 14 |
nicklas |
for (var i = 0; i < nofTubes; i++) |
2677 |
17 Sep 14 |
nicklas |
662 |
{ |
2677 |
17 Sep 14 |
nicklas |
var specimenTube ={}; |
2677 |
17 Sep 14 |
nicklas |
specimenTube.name = caseInfo.originalName+'.'+(i+caseInfo.specimenFirstIndex); |
5333 |
28 Mar 19 |
nicklas |
specimenTube.paused = Doc.element('pause.'+i).checked; |
2677 |
17 Sep 14 |
nicklas |
666 |
|
2677 |
17 Sep 14 |
nicklas |
specimenTube.box = frm['box.'+i].value; |
2677 |
17 Sep 14 |
nicklas |
specimenTube.row = frm['row.'+i].value; |
2677 |
17 Sep 14 |
nicklas |
specimenTube.column = frm['column.'+i].value; |
2677 |
17 Sep 14 |
nicklas |
specimenTube.comment = frm['comment.'+i].value; |
2801 |
13 Oct 14 |
nicklas |
specimenTube.specimenType = frm['specimenType.'+i].value; |
3602 |
16 Nov 15 |
nicklas |
specimenTube.yellowLabel = frm['yellowLabel.'+i].checked; |
2677 |
17 Sep 14 |
nicklas |
specimenTube.biopsyType = frm.biopsyType.value; |
2677 |
17 Sep 14 |
nicklas |
caseInfo.specimen[i] = specimenTube; |
2677 |
17 Sep 14 |
nicklas |
675 |
} |
2677 |
17 Sep 14 |
nicklas |
676 |
|
2677 |
17 Sep 14 |
nicklas |
var submitInfo = {}; |
2677 |
17 Sep 14 |
nicklas |
submitInfo.caseInfo = caseInfo; |
2677 |
17 Sep 14 |
nicklas |
679 |
|
2677 |
17 Sep 14 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
2677 |
17 Sep 14 |
nicklas |
url += '&cmd=CreateSpecimenTubes'; |
2677 |
17 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2677 |
17 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, streg.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2677 |
17 Sep 14 |
nicklas |
684 |
} |
2677 |
17 Sep 14 |
nicklas |
685 |
|
2677 |
17 Sep 14 |
nicklas |
streg.submissionResults = function(response) |
2677 |
17 Sep 14 |
nicklas |
687 |
{ |
2677 |
17 Sep 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2677 |
17 Sep 14 |
nicklas |
Doc.show('gostop'); |
2677 |
17 Sep 14 |
nicklas |
Doc.show('gonext-message'); |
5333 |
28 Mar 19 |
nicklas |
restartAt = (new Date()).getTime() + 4000; |
2677 |
17 Sep 14 |
nicklas |
restartTimer = setInterval(streg.countDownToRestart, 200); |
2677 |
17 Sep 14 |
nicklas |
693 |
} |
2677 |
17 Sep 14 |
nicklas |
694 |
|
2677 |
17 Sep 14 |
nicklas |
streg.countDownToRestart = function() |
2677 |
17 Sep 14 |
nicklas |
696 |
{ |
2677 |
17 Sep 14 |
nicklas |
var time = restartAt - (new Date()).getTime(); |
2677 |
17 Sep 14 |
nicklas |
if (time < 0) |
2677 |
17 Sep 14 |
nicklas |
699 |
{ |
5333 |
28 Mar 19 |
nicklas |
clearTimeout(restartTimer); |
2677 |
17 Sep 14 |
nicklas |
Wizard.restartWizard(); |
2677 |
17 Sep 14 |
nicklas |
702 |
} |
2677 |
17 Sep 14 |
nicklas |
else |
2677 |
17 Sep 14 |
nicklas |
704 |
{ |
2677 |
17 Sep 14 |
nicklas |
Doc.element('gonext-message').innerHTML = '<i>Wizard will restart automatically in ' + Math.ceil(time/1000) + ' seconds...</i>'; |
2677 |
17 Sep 14 |
nicklas |
706 |
} |
2677 |
17 Sep 14 |
nicklas |
707 |
} |
2677 |
17 Sep 14 |
nicklas |
708 |
|
2677 |
17 Sep 14 |
nicklas |
streg.stopAutoRestart = function() |
2677 |
17 Sep 14 |
nicklas |
710 |
{ |
2677 |
17 Sep 14 |
nicklas |
clearTimeout(restartTimer); |
2677 |
17 Sep 14 |
nicklas |
Doc.hide('gonext-message'); |
2677 |
17 Sep 14 |
nicklas |
Doc.hide('gostop'); |
5333 |
28 Mar 19 |
nicklas |
Doc.show('gorestart'); |
2677 |
17 Sep 14 |
nicklas |
715 |
} |
2677 |
17 Sep 14 |
nicklas |
716 |
|
2677 |
17 Sep 14 |
nicklas |
717 |
|
2677 |
17 Sep 14 |
nicklas |
return streg; |
2677 |
17 Sep 14 |
nicklas |
719 |
}(); |
2677 |
17 Sep 14 |
nicklas |
720 |
|
2677 |
17 Sep 14 |
nicklas |
Doc.onLoad(SpecimenTubeReg.initPage); |
2677 |
17 Sep 14 |
nicklas |
722 |
|