2602 |
27 Aug 14 |
nicklas |
var Blood = function() |
2602 |
27 Aug 14 |
nicklas |
2 |
{ |
2602 |
27 Aug 14 |
nicklas |
var blood = {}; |
2656 |
11 Sep 14 |
nicklas |
var debug = 0; |
2602 |
27 Aug 14 |
nicklas |
5 |
|
2602 |
27 Aug 14 |
nicklas |
var patientInfo = null; |
2602 |
27 Aug 14 |
nicklas |
var bloodInfo = null; |
2602 |
27 Aug 14 |
nicklas |
var siteInfo = null; |
2602 |
27 Aug 14 |
nicklas |
var consentInfo = null; |
2602 |
27 Aug 14 |
nicklas |
10 |
|
2602 |
27 Aug 14 |
nicklas |
var caseIsValid = false; |
6510 |
03 Dec 21 |
nicklas |
var pnrIsTested = false; |
2602 |
27 Aug 14 |
nicklas |
var pnrIsValid = false; |
2602 |
27 Aug 14 |
nicklas |
var pnrIsAcceptable = false; |
2602 |
27 Aug 14 |
nicklas |
15 |
|
2602 |
27 Aug 14 |
nicklas |
var samplingDateIsValid = true; |
2602 |
27 Aug 14 |
nicklas |
var freezerDateIsValid = true; |
2602 |
27 Aug 14 |
nicklas |
18 |
|
2602 |
27 Aug 14 |
nicklas |
blood.initPage = function() |
2602 |
27 Aug 14 |
nicklas |
20 |
{ |
2602 |
27 Aug 14 |
nicklas |
// Step 1 |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', blood.validateStep1); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('caseName', 'keypress', Wizard.focusOnEnter); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('caseName', 'blur', blood.caseNameOnChange); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('personalNumber', 'keyup', blood.personalNumberOnChange); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('personalNumber', 'keypress', Wizard.goNextOnTabOrEnter); |
2602 |
27 Aug 14 |
nicklas |
27 |
|
2602 |
27 Aug 14 |
nicklas |
// Step 2 |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', blood.initializeStep2); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', blood.validateStep2); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('familyName', 'blur', blood.nameOnChange); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('allFirstNames', 'blur', blood.nameOnChange); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('allFirstNames', 'keypress', Wizard.goNextOnTabOrEnter); |
2602 |
27 Aug 14 |
nicklas |
34 |
|
2602 |
27 Aug 14 |
nicklas |
// Step 3 |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('step-3', 'wizard-initialize', blood.initializeStep3); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('step-3', 'wizard-validate', blood.validateStep3); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('samplingDate', 'blur', blood.samplingDateTimeOnChange); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('samplingTime', 'blur', blood.samplingDateTimeOnChange); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('freezerDate', 'blur', blood.freezerDateTimeOnChange); |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('freezerTime', 'blur', blood.freezerDateTimeOnChange); |
2602 |
27 Aug 14 |
nicklas |
42 |
|
2602 |
27 Aug 14 |
nicklas |
// Navigation |
2602 |
27 Aug 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2602 |
27 Aug 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2602 |
27 Aug 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2602 |
27 Aug 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2602 |
27 Aug 14 |
nicklas |
Buttons.addClickHandler('goupdate', Wizard.goRegister); |
2602 |
27 Aug 14 |
nicklas |
49 |
|
2602 |
27 Aug 14 |
nicklas |
// Final registration |
2602 |
27 Aug 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', blood.submit); |
2602 |
27 Aug 14 |
nicklas |
52 |
|
2602 |
27 Aug 14 |
nicklas |
Doc.show('step-1'); |
2602 |
27 Aug 14 |
nicklas |
Doc.show('gonext'); |
2602 |
27 Aug 14 |
nicklas |
55 |
} |
2602 |
27 Aug 14 |
nicklas |
56 |
|
2602 |
27 Aug 14 |
nicklas |
blood.caseNameOnChange = function() |
2602 |
27 Aug 14 |
nicklas |
58 |
{ |
2602 |
27 Aug 14 |
nicklas |
var frm = document.forms['reggie']; |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('caseName'); |
2602 |
27 Aug 14 |
nicklas |
var caseName = frm.caseName.value.toUpperCase(); |
2602 |
27 Aug 14 |
nicklas |
caseIsValid = false; |
2602 |
27 Aug 14 |
nicklas |
if (caseName == '') |
2602 |
27 Aug 14 |
nicklas |
64 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('caseName', 'invalid', 'Missing'); |
2602 |
27 Aug 14 |
nicklas |
frm.caseName.focus(); |
2602 |
27 Aug 14 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
68 |
} |
6277 |
03 Jun 21 |
nicklas |
if (!Reggie.checkValidCaseName(caseName, 'K?', 'C?')) // Allow 'K'-prefix and/or 'C' suffix to be used |
2602 |
27 Aug 14 |
nicklas |
70 |
{ |
6277 |
03 Jun 21 |
nicklas |
Wizard.setInputStatus('caseName', 'invalid', 'Expected 7-digits + optional \'K\' prefix or \'C\' suffix.'); |
2602 |
27 Aug 14 |
nicklas |
frm.caseName.focus(); |
2602 |
27 Aug 14 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
74 |
} |
2602 |
27 Aug 14 |
nicklas |
75 |
|
2602 |
27 Aug 14 |
nicklas |
frm.caseName.value = caseName; |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('caseName', 'valid'); |
2602 |
27 Aug 14 |
nicklas |
caseIsValid = true; |
2602 |
27 Aug 14 |
nicklas |
79 |
|
2602 |
27 Aug 14 |
nicklas |
var url = '../BloodRegistration.servlet?ID='+App.getSessionId(); |
2602 |
27 Aug 14 |
nicklas |
url += '&cmd=GetBloodInfo&caseName=' + encodeURIComponent(caseName); |
2602 |
27 Aug 14 |
nicklas |
Wizard.showLoadingAnimation('Loading information about case...'); |
2602 |
27 Aug 14 |
nicklas |
Wizard.asyncJsonRequest(url, blood.onBloodInfoLoaded); |
2602 |
27 Aug 14 |
nicklas |
84 |
} |
2602 |
27 Aug 14 |
nicklas |
85 |
|
2602 |
27 Aug 14 |
nicklas |
86 |
|
2602 |
27 Aug 14 |
nicklas |
blood.onBloodInfoLoaded = function(response) |
2602 |
27 Aug 14 |
nicklas |
88 |
{ |
2602 |
27 Aug 14 |
nicklas |
var frm = document.forms['reggie']; |
2602 |
27 Aug 14 |
nicklas |
90 |
|
2602 |
27 Aug 14 |
nicklas |
// Get biosource information from the AJAX response |
2602 |
27 Aug 14 |
nicklas |
bloodInfo = response.bloodInfo; |
2602 |
27 Aug 14 |
nicklas |
patientInfo = response.patientInfo; |
2602 |
27 Aug 14 |
nicklas |
consentInfo = response.consentInfo; |
2602 |
27 Aug 14 |
nicklas |
siteInfo = response.siteInfo; |
2602 |
27 Aug 14 |
nicklas |
96 |
|
2602 |
27 Aug 14 |
nicklas |
if (patientInfo) |
2602 |
27 Aug 14 |
nicklas |
98 |
{ |
2602 |
27 Aug 14 |
nicklas |
frm.personalNumber.value = patientInfo.personalNumber; |
2602 |
27 Aug 14 |
nicklas |
blood.personalNumberOnChange(); |
6510 |
03 Dec 21 |
nicklas |
pnrIsValid = true; |
2602 |
27 Aug 14 |
nicklas |
Wizard.goNext(false); |
2602 |
27 Aug 14 |
nicklas |
103 |
} |
2602 |
27 Aug 14 |
nicklas |
104 |
|
2602 |
27 Aug 14 |
nicklas |
105 |
} |
2602 |
27 Aug 14 |
nicklas |
106 |
|
2602 |
27 Aug 14 |
nicklas |
blood.personalNumberOnChange = function() |
2602 |
27 Aug 14 |
nicklas |
108 |
{ |
2602 |
27 Aug 14 |
nicklas |
var frm = document.forms['reggie']; |
2602 |
27 Aug 14 |
nicklas |
var pnr = frm.personalNumber.value; |
6510 |
03 Dec 21 |
nicklas |
111 |
|
2602 |
27 Aug 14 |
nicklas |
pnrIsValid = false; |
6510 |
03 Dec 21 |
nicklas |
pnrIsAcceptable = false; |
6510 |
03 Dec 21 |
nicklas |
pnrIsTested = true; |
6510 |
03 Dec 21 |
nicklas |
115 |
|
6510 |
03 Dec 21 |
nicklas |
var pnrLen = pnr.length; |
6510 |
03 Dec 21 |
nicklas |
if (pnrLen == 0) |
6510 |
03 Dec 21 |
nicklas |
118 |
{ |
6510 |
03 Dec 21 |
nicklas |
Wizard.setInputStatus('personalNumber', 'invalid', 'A personal number is required'); |
6510 |
03 Dec 21 |
nicklas |
return; |
6510 |
03 Dec 21 |
nicklas |
121 |
} |
6510 |
03 Dec 21 |
nicklas |
122 |
|
2602 |
27 Aug 14 |
nicklas |
pnrIsAcceptable = true; |
2602 |
27 Aug 14 |
nicklas |
if (pnrLen != 12 && pnrLen != 10) |
2602 |
27 Aug 14 |
nicklas |
125 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('personalNumber', 'warning', pnrLen < 12 ? 'Too short' : 'Too long'); |
2602 |
27 Aug 14 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
128 |
} |
2602 |
27 Aug 14 |
nicklas |
129 |
|
2602 |
27 Aug 14 |
nicklas |
if (!pnr.match(/^\d+$/)) |
2602 |
27 Aug 14 |
nicklas |
131 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('personalNumber', 'warning', 'Non-standard personal number'); |
2602 |
27 Aug 14 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
134 |
} |
2602 |
27 Aug 14 |
nicklas |
135 |
|
2602 |
27 Aug 14 |
nicklas |
var datePart = pnr.substring(0, pnrLen - 4); // Remove last four digits |
2602 |
27 Aug 14 |
nicklas |
var dateFormat = pnrLen == 10 ? 'yyMMdd' : 'yyyyMMdd'; |
2602 |
27 Aug 14 |
nicklas |
var isValidDate = Dates.isDate(datePart, dateFormat); |
2602 |
27 Aug 14 |
nicklas |
if (!isValidDate) |
2602 |
27 Aug 14 |
nicklas |
140 |
{ |
2602 |
27 Aug 14 |
nicklas |
var dayInMonth = parseInt(datePart.substring(-2), 10); // Last two characters |
2602 |
27 Aug 14 |
nicklas |
if (dayInMonth > 60) |
2602 |
27 Aug 14 |
nicklas |
143 |
{ |
2602 |
27 Aug 14 |
nicklas |
// 'Samordningsnummer' has day-in-month + 60; check this |
2602 |
27 Aug 14 |
nicklas |
dayInMonth -= 60; |
2602 |
27 Aug 14 |
nicklas |
var tmpPnr = pnr.substring(0, pnrLen - 6); // First 4 or 6 digits is year+month |
2602 |
27 Aug 14 |
nicklas |
if (dayInMonth < 10) tmpPnr += '0'; |
2602 |
27 Aug 14 |
nicklas |
tmpPnr += dayInMonth; |
2602 |
27 Aug 14 |
nicklas |
isValidDate = Dates.isDate(tmpPnr, dateFormat); |
2602 |
27 Aug 14 |
nicklas |
150 |
} |
2602 |
27 Aug 14 |
nicklas |
151 |
} |
2602 |
27 Aug 14 |
nicklas |
if (!isValidDate) |
2602 |
27 Aug 14 |
nicklas |
153 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('personalNumber', 'warning', 'Not a valid date'); |
2602 |
27 Aug 14 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
156 |
} |
2602 |
27 Aug 14 |
nicklas |
157 |
|
2602 |
27 Aug 14 |
nicklas |
if (!Reggie.personalNumberControlDigitCheck(pnr.substr(pnrLen == 10 ? 0 : 2))) |
2602 |
27 Aug 14 |
nicklas |
159 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('personalNumber', 'warning', 'Invalid control digit'); |
2602 |
27 Aug 14 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
162 |
} |
2602 |
27 Aug 14 |
nicklas |
163 |
|
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('personalNumber', 'valid'); |
2602 |
27 Aug 14 |
nicklas |
pnrIsValid = true; |
2602 |
27 Aug 14 |
nicklas |
Wizard.hideGoNextConfirmation(); |
2602 |
27 Aug 14 |
nicklas |
167 |
} |
2602 |
27 Aug 14 |
nicklas |
168 |
|
2602 |
27 Aug 14 |
nicklas |
blood.validateStep1 = function(event) |
2602 |
27 Aug 14 |
nicklas |
170 |
{ |
6510 |
03 Dec 21 |
nicklas |
if (!pnrIsTested) persinfo.personalNumberOnChange(); |
6510 |
03 Dec 21 |
nicklas |
if (!caseIsValid || !pnrIsValid) |
2602 |
27 Aug 14 |
nicklas |
173 |
{ |
6510 |
03 Dec 21 |
nicklas |
if (!pnrIsAcceptable) |
2602 |
27 Aug 14 |
nicklas |
175 |
{ |
2602 |
27 Aug 14 |
nicklas |
event.preventDefault(); |
6510 |
03 Dec 21 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
178 |
} |
6510 |
03 Dec 21 |
nicklas |
var frm = document.forms['reggie']; |
6510 |
03 Dec 21 |
nicklas |
if (!frm.verifyGoNext) |
6510 |
03 Dec 21 |
nicklas |
181 |
{ |
6510 |
03 Dec 21 |
nicklas |
frm.personalNumber.focus(); |
6510 |
03 Dec 21 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Check to verify registration of non-standard personal number.'); |
6510 |
03 Dec 21 |
nicklas |
event.preventDefault(); |
6510 |
03 Dec 21 |
nicklas |
185 |
} |
2602 |
27 Aug 14 |
nicklas |
186 |
} |
2602 |
27 Aug 14 |
nicklas |
187 |
} |
2602 |
27 Aug 14 |
nicklas |
188 |
|
6824 |
30 Aug 22 |
nicklas |
blood.initializeStep2 = function() |
2602 |
27 Aug 14 |
nicklas |
190 |
{ |
2602 |
27 Aug 14 |
nicklas |
if (!patientInfo) |
2602 |
27 Aug 14 |
nicklas |
192 |
{ |
2602 |
27 Aug 14 |
nicklas |
var frm = document.forms['reggie']; |
2602 |
27 Aug 14 |
nicklas |
var pnr = frm.personalNumber.value; |
2602 |
27 Aug 14 |
nicklas |
if (pnr.length == 10 && pnrIsValid) |
2602 |
27 Aug 14 |
nicklas |
196 |
{ |
2602 |
27 Aug 14 |
nicklas |
var year = Reggie.fullYear(parseInt(pnr.substr(0, 2), 10)); |
2602 |
27 Aug 14 |
nicklas |
pnr = year + pnr.substr(2); |
2602 |
27 Aug 14 |
nicklas |
199 |
} |
2602 |
27 Aug 14 |
nicklas |
200 |
|
2602 |
27 Aug 14 |
nicklas |
var url = '../PersonalRegistration.servlet?ID='+App.getSessionId(); |
2602 |
27 Aug 14 |
nicklas |
url += '&cmd=GetPatientInfo'; |
2602 |
27 Aug 14 |
nicklas |
url += '&personalNumber=' + encodeURIComponent(pnr); |
2602 |
27 Aug 14 |
nicklas |
url += '&pnrIsValid=' + pnrIsValid; |
2602 |
27 Aug 14 |
nicklas |
205 |
|
2602 |
27 Aug 14 |
nicklas |
Wizard.showLoadingAnimation('Loading patient information...'); |
2602 |
27 Aug 14 |
nicklas |
Wizard.asyncJsonRequest(url, blood.patientInfoLoaded); |
2602 |
27 Aug 14 |
nicklas |
208 |
} |
2602 |
27 Aug 14 |
nicklas |
else |
2602 |
27 Aug 14 |
nicklas |
210 |
{ |
2602 |
27 Aug 14 |
nicklas |
blood.patientInfoLoaded(); |
2602 |
27 Aug 14 |
nicklas |
212 |
} |
2602 |
27 Aug 14 |
nicklas |
213 |
} |
2602 |
27 Aug 14 |
nicklas |
214 |
|
2602 |
27 Aug 14 |
nicklas |
blood.patientInfoLoaded = function(response) |
2602 |
27 Aug 14 |
nicklas |
216 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setCurrentStep(2); |
2602 |
27 Aug 14 |
nicklas |
if (response) patientInfo = response.patientInfo; |
2602 |
27 Aug 14 |
nicklas |
var frm = document.forms['reggie']; |
2602 |
27 Aug 14 |
nicklas |
220 |
|
2602 |
27 Aug 14 |
nicklas |
if (!patientInfo.id) |
2602 |
27 Aug 14 |
nicklas |
222 |
{ |
2602 |
27 Aug 14 |
nicklas |
Doc.show('new-patient'); |
2602 |
27 Aug 14 |
nicklas |
frm.patientCode.value = patientInfo.name; |
2602 |
27 Aug 14 |
nicklas |
Doc.element('new.dateOfBirth').innerHTML = patientInfo.dateOfBirth ? patientInfo.dateOfBirth : "---"; |
2602 |
27 Aug 14 |
nicklas |
Doc.element('new.gender').innerHTML = patientInfo.gender ? patientInfo.gender : "---"; |
2602 |
27 Aug 14 |
nicklas |
frm.familyName.focus(); |
2602 |
27 Aug 14 |
nicklas |
if (!pnrIsValid) |
2602 |
27 Aug 14 |
nicklas |
229 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('gender', 'warning', 'Gender and DateOfBirth can\'t be automatically generated for non-standard Personal number'); |
2602 |
27 Aug 14 |
nicklas |
231 |
} |
2602 |
27 Aug 14 |
nicklas |
Doc.show('gonext'); |
2602 |
27 Aug 14 |
nicklas |
Doc.show('gocancel'); |
2602 |
27 Aug 14 |
nicklas |
234 |
} |
2602 |
27 Aug 14 |
nicklas |
else |
2602 |
27 Aug 14 |
nicklas |
236 |
{ |
2602 |
27 Aug 14 |
nicklas |
Doc.show('existing-patient'); |
2602 |
27 Aug 14 |
nicklas |
Doc.element('step-2-title').innerHTML = 'Existing patient: Verify names'; |
2602 |
27 Aug 14 |
nicklas |
Doc.element('existing.patientCode').innerHTML = Strings.encodeTags(patientInfo.name); |
2602 |
27 Aug 14 |
nicklas |
Doc.element('existing.familyName').innerHTML = Strings.encodeTags(patientInfo.familyName); |
2602 |
27 Aug 14 |
nicklas |
Doc.element('existing.allFirstNames').innerHTML = Strings.encodeTags(patientInfo.allFirstNames); |
2602 |
27 Aug 14 |
nicklas |
if (patientInfo.dateOfBirth) Doc.element('existing.dateOfBirth').innerHTML = Strings.encodeTags(patientInfo.dateOfBirth); |
2602 |
27 Aug 14 |
nicklas |
if (patientInfo.gender) Doc.element('existing.gender').innerHTML = Strings.encodeTags(patientInfo.gender); |
2602 |
27 Aug 14 |
nicklas |
Wizard.goNext(true); |
2602 |
27 Aug 14 |
nicklas |
245 |
} |
2602 |
27 Aug 14 |
nicklas |
246 |
} |
2602 |
27 Aug 14 |
nicklas |
247 |
|
2602 |
27 Aug 14 |
nicklas |
blood.validateStep2 = function(event) |
2602 |
27 Aug 14 |
nicklas |
249 |
{ |
2602 |
27 Aug 14 |
nicklas |
var valid = true; |
2602 |
27 Aug 14 |
nicklas |
var acceptable = true; |
2602 |
27 Aug 14 |
nicklas |
var frm = document.forms['reggie']; |
2602 |
27 Aug 14 |
nicklas |
253 |
|
2602 |
27 Aug 14 |
nicklas |
// New patient only |
2602 |
27 Aug 14 |
nicklas |
if (!patientInfo.id) |
2602 |
27 Aug 14 |
nicklas |
256 |
{ |
2602 |
27 Aug 14 |
nicklas |
// Validate 'New patient' form |
2602 |
27 Aug 14 |
nicklas |
if (frm.allFirstNames.value == '') |
2602 |
27 Aug 14 |
nicklas |
259 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('allFirstNames', 'warning', 'Missing'); |
2602 |
27 Aug 14 |
nicklas |
valid = false; |
2602 |
27 Aug 14 |
nicklas |
262 |
} |
2602 |
27 Aug 14 |
nicklas |
else |
2602 |
27 Aug 14 |
nicklas |
264 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('allFirstNames', 'valid'); |
2602 |
27 Aug 14 |
nicklas |
266 |
} |
2602 |
27 Aug 14 |
nicklas |
267 |
|
2602 |
27 Aug 14 |
nicklas |
if (frm.familyName.value == '') |
2602 |
27 Aug 14 |
nicklas |
269 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('familyName', 'warning', 'Missing'); |
2602 |
27 Aug 14 |
nicklas |
valid = false; |
2602 |
27 Aug 14 |
nicklas |
272 |
} |
2602 |
27 Aug 14 |
nicklas |
else |
2602 |
27 Aug 14 |
nicklas |
274 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('familyName', 'valid'); |
2602 |
27 Aug 14 |
nicklas |
276 |
} |
2602 |
27 Aug 14 |
nicklas |
if (frm.patientCode.value == '') |
2602 |
27 Aug 14 |
nicklas |
278 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('patientCode', 'invalid', 'Missing'); |
2602 |
27 Aug 14 |
nicklas |
frm.patientCode.focus(); |
2602 |
27 Aug 14 |
nicklas |
valid = false; |
2602 |
27 Aug 14 |
nicklas |
acceptable = false; |
2602 |
27 Aug 14 |
nicklas |
283 |
} |
2602 |
27 Aug 14 |
nicklas |
else |
2602 |
27 Aug 14 |
nicklas |
285 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('patientCode', 'valid'); |
2613 |
29 Aug 14 |
nicklas |
patientInfo.name = frm.patientCode.value; |
2602 |
27 Aug 14 |
nicklas |
288 |
} |
2602 |
27 Aug 14 |
nicklas |
289 |
|
2602 |
27 Aug 14 |
nicklas |
if (event.detail.auto) |
2602 |
27 Aug 14 |
nicklas |
291 |
{ |
2602 |
27 Aug 14 |
nicklas |
if (!valid) |
2602 |
27 Aug 14 |
nicklas |
293 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Check to verify registration with missing name(s).'); |
2602 |
27 Aug 14 |
nicklas |
event.preventDefault(); |
2602 |
27 Aug 14 |
nicklas |
296 |
} |
2602 |
27 Aug 14 |
nicklas |
297 |
} |
2602 |
27 Aug 14 |
nicklas |
else |
2602 |
27 Aug 14 |
nicklas |
299 |
{ |
2602 |
27 Aug 14 |
nicklas |
if (!acceptable) event.preventDefault(); |
2602 |
27 Aug 14 |
nicklas |
301 |
} |
2602 |
27 Aug 14 |
nicklas |
302 |
} |
2602 |
27 Aug 14 |
nicklas |
303 |
} |
2602 |
27 Aug 14 |
nicklas |
304 |
|
2602 |
27 Aug 14 |
nicklas |
blood.nameOnChange = function(event) |
2602 |
27 Aug 14 |
nicklas |
306 |
{ |
2602 |
27 Aug 14 |
nicklas |
var field = event.target; |
2617 |
01 Sep 14 |
nicklas |
patientInfo[field.name] = field.value; |
2602 |
27 Aug 14 |
nicklas |
if (field.value == '') |
2602 |
27 Aug 14 |
nicklas |
310 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus(field, 'warning', 'Missing'); |
2602 |
27 Aug 14 |
nicklas |
312 |
} |
2602 |
27 Aug 14 |
nicklas |
else |
2602 |
27 Aug 14 |
nicklas |
314 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus(field, 'valid'); |
2602 |
27 Aug 14 |
nicklas |
Wizard.hideGoNextConfirmation(); |
2602 |
27 Aug 14 |
nicklas |
317 |
} |
2602 |
27 Aug 14 |
nicklas |
318 |
} |
2602 |
27 Aug 14 |
nicklas |
319 |
|
2602 |
27 Aug 14 |
nicklas |
320 |
|
6824 |
30 Aug 22 |
nicklas |
blood.initializeStep3 = function() |
2602 |
27 Aug 14 |
nicklas |
322 |
{ |
2602 |
27 Aug 14 |
nicklas |
var updateMode = bloodInfo.id; |
2602 |
27 Aug 14 |
nicklas |
var frm = document.forms['reggie']; |
2602 |
27 Aug 14 |
nicklas |
325 |
|
2602 |
27 Aug 14 |
nicklas |
if (updateMode) |
2602 |
27 Aug 14 |
nicklas |
327 |
{ |
2602 |
27 Aug 14 |
nicklas |
Doc.element('step-3-title').innerHTML = 'Update blood \''+Strings.encodeTags(bloodInfo.name)+'\''; |
2602 |
27 Aug 14 |
nicklas |
if (bloodInfo.samplingDate != null) |
2602 |
27 Aug 14 |
nicklas |
330 |
{ |
2602 |
27 Aug 14 |
nicklas |
frm.samplingDate.value = bloodInfo.samplingDate.substring(0, 8); |
2602 |
27 Aug 14 |
nicklas |
frm.samplingTime.value = bloodInfo.samplingDate.substring(9, 13); |
2602 |
27 Aug 14 |
nicklas |
blood.samplingDateTimeOnChange(); |
2602 |
27 Aug 14 |
nicklas |
334 |
} |
2602 |
27 Aug 14 |
nicklas |
if (bloodInfo.freezerDate != null) |
2602 |
27 Aug 14 |
nicklas |
336 |
{ |
2602 |
27 Aug 14 |
nicklas |
frm.freezerDate.value = bloodInfo.freezerDate.substring(0, 8); |
2602 |
27 Aug 14 |
nicklas |
frm.freezerTime.value = bloodInfo.freezerDate.substring(9, 13); |
2602 |
27 Aug 14 |
nicklas |
blood.freezerDateTimeOnChange(); |
2602 |
27 Aug 14 |
nicklas |
340 |
} |
2602 |
27 Aug 14 |
nicklas |
frm.serum.checked = bloodInfo.serum == 'Yes'; |
2602 |
27 Aug 14 |
nicklas |
if (bloodInfo.bloodSample) |
2602 |
27 Aug 14 |
nicklas |
343 |
{ |
2602 |
27 Aug 14 |
nicklas |
Forms.selectListOption(frm.bloodSample, bloodInfo.bloodSample); |
2602 |
27 Aug 14 |
nicklas |
345 |
} |
2602 |
27 Aug 14 |
nicklas |
if (bloodInfo.otherPathNote) |
2602 |
27 Aug 14 |
nicklas |
347 |
{ |
2602 |
27 Aug 14 |
nicklas |
frm.otherPathNote.value = bloodInfo.otherPathNote; |
2602 |
27 Aug 14 |
nicklas |
349 |
} |
2602 |
27 Aug 14 |
nicklas |
350 |
} |
2602 |
27 Aug 14 |
nicklas |
else |
2602 |
27 Aug 14 |
nicklas |
352 |
{ |
2602 |
27 Aug 14 |
nicklas |
// Select 'PreNeo' if case name has 'C' suffix |
2602 |
27 Aug 14 |
nicklas |
var caseName = frm.caseName.value; |
6277 |
03 Jun 21 |
nicklas |
var cLength = caseName.length; |
6277 |
03 Jun 21 |
nicklas |
if (cLength > 7 && caseName.substr(cLength-1, 1) == 'C') |
2602 |
27 Aug 14 |
nicklas |
357 |
{ |
2602 |
27 Aug 14 |
nicklas |
Forms.selectListOption(frm.bloodSample, 'PreNeo'); |
2602 |
27 Aug 14 |
nicklas |
359 |
} |
2602 |
27 Aug 14 |
nicklas |
if (consentInfo && consentInfo.consent) |
2602 |
27 Aug 14 |
nicklas |
361 |
{ |
2602 |
27 Aug 14 |
nicklas |
frm.copyConsent.value = consentInfo.id; |
2602 |
27 Aug 14 |
nicklas |
var html = "From '" + Strings.encodeTags(consentInfo.name) + "' (" + consentInfo.consent; |
2602 |
27 Aug 14 |
nicklas |
if (consentInfo.consentDate) html += '; ' + consentInfo.consentDate; |
2602 |
27 Aug 14 |
nicklas |
html += ')'; |
2602 |
27 Aug 14 |
nicklas |
Doc.element('copyConsent.text').innerHTML = html; |
2602 |
27 Aug 14 |
nicklas |
Doc.show("copyConsentSection"); |
2602 |
27 Aug 14 |
nicklas |
368 |
} |
2602 |
27 Aug 14 |
nicklas |
369 |
} |
2602 |
27 Aug 14 |
nicklas |
370 |
|
6610 |
25 Feb 22 |
nicklas |
// Plasm/serum check box should not be selected |
6610 |
25 Feb 22 |
nicklas |
frm.serum.checked = siteInfo && siteInfo.usePlasmaSerum; |
2602 |
27 Aug 14 |
nicklas |
373 |
|
2602 |
27 Aug 14 |
nicklas |
if (updateMode) |
2602 |
27 Aug 14 |
nicklas |
375 |
{ |
2602 |
27 Aug 14 |
nicklas |
Doc.show('goupdate'); |
2602 |
27 Aug 14 |
nicklas |
377 |
} |
2602 |
27 Aug 14 |
nicklas |
else |
2602 |
27 Aug 14 |
nicklas |
379 |
{ |
2602 |
27 Aug 14 |
nicklas |
Doc.show('goregister'); |
2602 |
27 Aug 14 |
nicklas |
381 |
} |
2602 |
27 Aug 14 |
nicklas |
Doc.show('gocancel'); |
2602 |
27 Aug 14 |
nicklas |
383 |
|
2602 |
27 Aug 14 |
nicklas |
Wizard.setCurrentStep(3); |
2602 |
27 Aug 14 |
nicklas |
frm.samplingDate.focus(); |
2602 |
27 Aug 14 |
nicklas |
386 |
} |
2602 |
27 Aug 14 |
nicklas |
387 |
|
2602 |
27 Aug 14 |
nicklas |
blood.validateStep3 = function(event) |
2602 |
27 Aug 14 |
nicklas |
389 |
{ |
2602 |
27 Aug 14 |
nicklas |
if (!samplingDateIsValid || !freezerDateIsValid) |
2602 |
27 Aug 14 |
nicklas |
391 |
{ |
2602 |
27 Aug 14 |
nicklas |
event.preventDefault(); |
2602 |
27 Aug 14 |
nicklas |
393 |
} |
2602 |
27 Aug 14 |
nicklas |
394 |
} |
2602 |
27 Aug 14 |
nicklas |
395 |
|
2602 |
27 Aug 14 |
nicklas |
blood.samplingDateTimeOnChange = function() |
2602 |
27 Aug 14 |
nicklas |
397 |
{ |
2602 |
27 Aug 14 |
nicklas |
var frm = document.forms['reggie']; |
2602 |
27 Aug 14 |
nicklas |
samplingDateIsValid = false; |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('samplingDate'); |
2602 |
27 Aug 14 |
nicklas |
401 |
|
2602 |
27 Aug 14 |
nicklas |
var samplingDate = frm.samplingDate.value; |
2602 |
27 Aug 14 |
nicklas |
var samplingTime = frm.samplingTime.value; |
2602 |
27 Aug 14 |
nicklas |
404 |
|
2602 |
27 Aug 14 |
nicklas |
var isUppsala = siteInfo && siteInfo.prefix == '88'; |
2602 |
27 Aug 14 |
nicklas |
406 |
|
2602 |
27 Aug 14 |
nicklas |
if (samplingDate != '' || samplingTime != '') |
2602 |
27 Aug 14 |
nicklas |
408 |
{ |
2602 |
27 Aug 14 |
nicklas |
// Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits. |
2602 |
27 Aug 14 |
nicklas |
samplingDate = Reggie.autoFillDate(samplingDate, true); |
2602 |
27 Aug 14 |
nicklas |
frm.samplingDate.value = samplingDate; |
2602 |
27 Aug 14 |
nicklas |
412 |
|
2602 |
27 Aug 14 |
nicklas |
samplingTime = Reggie.autoFillTime(samplingTime); |
2602 |
27 Aug 14 |
nicklas |
// Set sampling time to 0000 for Uppsala since it is not known |
2602 |
27 Aug 14 |
nicklas |
if (!samplingTime && isUppsala) samplingTime = '0000'; |
2602 |
27 Aug 14 |
nicklas |
frm.samplingTime.value = samplingTime; |
2602 |
27 Aug 14 |
nicklas |
417 |
|
2602 |
27 Aug 14 |
nicklas |
if (!Dates.isDate(samplingDate, 'yyyyMMdd')) |
2602 |
27 Aug 14 |
nicklas |
419 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('samplingDate', 'invalid', 'Not a valid date'); |
2602 |
27 Aug 14 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
422 |
} |
2602 |
27 Aug 14 |
nicklas |
423 |
|
2602 |
27 Aug 14 |
nicklas |
// Automatically fill in freezer date except for Uppsala since it is not known |
2602 |
27 Aug 14 |
nicklas |
if (frm.freezerDate.value == '' && !isUppsala) |
2602 |
27 Aug 14 |
nicklas |
426 |
{ |
2602 |
27 Aug 14 |
nicklas |
frm.freezerDate.value = samplingDate; |
2602 |
27 Aug 14 |
nicklas |
428 |
} |
2602 |
27 Aug 14 |
nicklas |
429 |
|
2602 |
27 Aug 14 |
nicklas |
if (!Dates.isDate(samplingDate + ' ' + samplingTime, 'yyyyMMdd HHmm')) |
2602 |
27 Aug 14 |
nicklas |
431 |
{ |
2602 |
27 Aug 14 |
nicklas |
if (samplingDate != '') |
2602 |
27 Aug 14 |
nicklas |
433 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('samplingDate', 'invalid', 'Not a valid time'); |
2602 |
27 Aug 14 |
nicklas |
435 |
} |
2602 |
27 Aug 14 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
437 |
} |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('samplingDate', 'valid'); |
2602 |
27 Aug 14 |
nicklas |
439 |
} |
2602 |
27 Aug 14 |
nicklas |
samplingDateIsValid = true; |
2602 |
27 Aug 14 |
nicklas |
441 |
} |
2602 |
27 Aug 14 |
nicklas |
442 |
|
2602 |
27 Aug 14 |
nicklas |
blood.freezerDateTimeOnChange = function() |
2602 |
27 Aug 14 |
nicklas |
444 |
{ |
2602 |
27 Aug 14 |
nicklas |
var frm = document.forms['reggie']; |
2602 |
27 Aug 14 |
nicklas |
freezerDateIsValid = false; |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('freezerDate'); |
2602 |
27 Aug 14 |
nicklas |
448 |
|
2602 |
27 Aug 14 |
nicklas |
var freezerDate = frm.freezerDate.value; |
2602 |
27 Aug 14 |
nicklas |
var freezerTime = frm.freezerTime.value; |
2602 |
27 Aug 14 |
nicklas |
var freezerTimestamp; |
2602 |
27 Aug 14 |
nicklas |
452 |
|
2602 |
27 Aug 14 |
nicklas |
if (freezerDate != '' || freezerTime != '') |
2602 |
27 Aug 14 |
nicklas |
454 |
{ |
2602 |
27 Aug 14 |
nicklas |
// Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits. |
2602 |
27 Aug 14 |
nicklas |
freezerDate = Reggie.autoFillDate(freezerDate, true); |
2602 |
27 Aug 14 |
nicklas |
frm.freezerDate.value = freezerDate; |
2602 |
27 Aug 14 |
nicklas |
458 |
|
2602 |
27 Aug 14 |
nicklas |
freezerTime = Reggie.autoFillTime(freezerTime); |
2602 |
27 Aug 14 |
nicklas |
frm.freezerTime.value = freezerTime; |
2602 |
27 Aug 14 |
nicklas |
461 |
|
2602 |
27 Aug 14 |
nicklas |
if (!Dates.isDate(freezerDate, 'yyyyMMdd')) |
2602 |
27 Aug 14 |
nicklas |
463 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('freezerDate', 'invalid', 'Not a valid date'); |
2602 |
27 Aug 14 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
466 |
} |
2602 |
27 Aug 14 |
nicklas |
freezerTimestamp = Dates.parseString(freezerDate + ' ' + freezerTime, 'yyyyMMdd HHmm'); |
2602 |
27 Aug 14 |
nicklas |
if (freezerTimestamp == null) |
2602 |
27 Aug 14 |
nicklas |
469 |
{ |
2602 |
27 Aug 14 |
nicklas |
if (freezerDate != '') |
2602 |
27 Aug 14 |
nicklas |
471 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('freezerDate', 'invalid', 'Not a valid time'); |
2602 |
27 Aug 14 |
nicklas |
473 |
} |
2602 |
27 Aug 14 |
nicklas |
return; |
2602 |
27 Aug 14 |
nicklas |
475 |
} |
2602 |
27 Aug 14 |
nicklas |
476 |
|
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('freezerDate', 'valid'); |
2602 |
27 Aug 14 |
nicklas |
478 |
} |
2602 |
27 Aug 14 |
nicklas |
479 |
|
2602 |
27 Aug 14 |
nicklas |
freezerDateIsValid = true; |
2602 |
27 Aug 14 |
nicklas |
481 |
|
2602 |
27 Aug 14 |
nicklas |
if (samplingDateIsValid && freezerTimestamp) |
2602 |
27 Aug 14 |
nicklas |
483 |
{ |
2602 |
27 Aug 14 |
nicklas |
var samplingTimestamp = Dates.parseString(frm.samplingDate.value + ' ' + frm.samplingTime.value, 'yyyyMMdd Hmm'); |
2602 |
27 Aug 14 |
nicklas |
if (samplingTimestamp && samplingTimestamp.getDate() != freezerTimestamp.getDate()) |
2602 |
27 Aug 14 |
nicklas |
486 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.setInputStatus('freezerDate', 'warning', 'Sampling and freezer dates are different'); |
2602 |
27 Aug 14 |
nicklas |
488 |
} |
2602 |
27 Aug 14 |
nicklas |
489 |
} |
2602 |
27 Aug 14 |
nicklas |
490 |
} |
2602 |
27 Aug 14 |
nicklas |
491 |
|
2602 |
27 Aug 14 |
nicklas |
blood.submit = function() |
2602 |
27 Aug 14 |
nicklas |
493 |
{ |
2602 |
27 Aug 14 |
nicklas |
var frm = document.forms['reggie']; |
2602 |
27 Aug 14 |
nicklas |
495 |
|
2602 |
27 Aug 14 |
nicklas |
bloodInfo.samplingDate = Strings.trim(frm.samplingDate.value + ' ' + frm.samplingTime.value); |
2602 |
27 Aug 14 |
nicklas |
bloodInfo.freezerDate = Strings.trim(frm.freezerDate.value + ' ' + frm.freezerTime.value); |
2602 |
27 Aug 14 |
nicklas |
bloodInfo.serum = frm.serum.checked ? "Yes" : "No"; |
2602 |
27 Aug 14 |
nicklas |
bloodInfo.bloodSample = frm.bloodSample.value; |
2602 |
27 Aug 14 |
nicklas |
bloodInfo.otherPathNote = frm.otherPathNote.value; |
2602 |
27 Aug 14 |
nicklas |
if (frm.copyConsent.checked && frm.copyConsent.value) |
2602 |
27 Aug 14 |
nicklas |
502 |
{ |
2602 |
27 Aug 14 |
nicklas |
bloodInfo.copyConsent = parseInt(frm.copyConsent.value, 10); |
2602 |
27 Aug 14 |
nicklas |
504 |
} |
2602 |
27 Aug 14 |
nicklas |
505 |
|
2602 |
27 Aug 14 |
nicklas |
var updateMode = bloodInfo.id; |
2602 |
27 Aug 14 |
nicklas |
var submitInfo = {}; |
2602 |
27 Aug 14 |
nicklas |
submitInfo.patientInfo = patientInfo; |
2602 |
27 Aug 14 |
nicklas |
submitInfo.bloodInfo = bloodInfo; |
2602 |
27 Aug 14 |
nicklas |
510 |
|
2602 |
27 Aug 14 |
nicklas |
var url = '../BloodRegistration.servlet?ID='+App.getSessionId(); |
2602 |
27 Aug 14 |
nicklas |
url += '&cmd=' + (updateMode ? 'UpdateBlood' : 'CreateBlood'); |
2602 |
27 Aug 14 |
nicklas |
513 |
|
2602 |
27 Aug 14 |
nicklas |
Wizard.showLoadingAnimation('Registering blood information...'); |
2602 |
27 Aug 14 |
nicklas |
Wizard.asyncJsonRequest(url, blood.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2602 |
27 Aug 14 |
nicklas |
516 |
|
2602 |
27 Aug 14 |
nicklas |
517 |
} |
2602 |
27 Aug 14 |
nicklas |
518 |
|
2602 |
27 Aug 14 |
nicklas |
blood.submissionResults = function(response) |
2602 |
27 Aug 14 |
nicklas |
520 |
{ |
2602 |
27 Aug 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2602 |
27 Aug 14 |
nicklas |
Doc.show('gorestart'); |
2602 |
27 Aug 14 |
nicklas |
523 |
} |
2602 |
27 Aug 14 |
nicklas |
524 |
|
2602 |
27 Aug 14 |
nicklas |
525 |
|
2602 |
27 Aug 14 |
nicklas |
return blood; |
2602 |
27 Aug 14 |
nicklas |
527 |
}(); |
2602 |
27 Aug 14 |
nicklas |
528 |
|
2602 |
27 Aug 14 |
nicklas |
Doc.onLoad(Blood.initPage); |
2602 |
27 Aug 14 |
nicklas |
530 |
|