4785 |
27 Apr 18 |
olle |
var Consent = function() |
4785 |
27 Apr 18 |
olle |
2 |
{ |
4785 |
27 Apr 18 |
olle |
var consent = {}; |
4785 |
27 Apr 18 |
olle |
var consentToId = { "Yes": "consent.yes", "No" : "consent.no", "Not asked": "consent.notAsked" }; |
4785 |
27 Apr 18 |
olle |
var patientInfo; |
4785 |
27 Apr 18 |
olle |
var debug = 0; |
4785 |
27 Apr 18 |
olle |
7 |
|
4785 |
27 Apr 18 |
olle |
var sampleItemPrefix = ''; |
4785 |
27 Apr 18 |
olle |
var sampleItemNumDigits = 5; |
4785 |
27 Apr 18 |
olle |
10 |
|
4785 |
27 Apr 18 |
olle |
consent.initPage = function() |
4785 |
27 Apr 18 |
olle |
12 |
{ |
4785 |
27 Apr 18 |
olle |
13 |
|
4785 |
27 Apr 18 |
olle |
// Step 1 |
4785 |
27 Apr 18 |
olle |
Events.addEventHandler('step-1', 'wizard-validate', consent.validateStep1); |
4785 |
27 Apr 18 |
olle |
Events.addEventHandler('caseName', 'keypress', Wizard.goNextOnTabOrEnter); |
4785 |
27 Apr 18 |
olle |
17 |
|
4785 |
27 Apr 18 |
olle |
// Step 2 |
4785 |
27 Apr 18 |
olle |
Events.addEventHandler('step-2', 'wizard-initialize', consent.initializeStep2); |
4785 |
27 Apr 18 |
olle |
Events.addEventHandler('step-2', 'wizard-validate', consent.validateStep2); |
4785 |
27 Apr 18 |
olle |
Events.addEventHandler('consentDate', 'blur', Wizard.validateDate); |
4785 |
27 Apr 18 |
olle |
22 |
|
4785 |
27 Apr 18 |
olle |
Events.addEventHandler('consent.yes', 'change', consent.consentOnChange); |
4785 |
27 Apr 18 |
olle |
Events.addEventHandler('consent.no', 'change', consent.consentOnChange); |
4785 |
27 Apr 18 |
olle |
Events.addEventHandler('consent.notAsked', 'change', consent.consentOnChange); |
4785 |
27 Apr 18 |
olle |
Events.addEventHandler('otherReasonIfNotAsked', 'focus', consent.onOtherReasonFocus); |
4785 |
27 Apr 18 |
olle |
27 |
|
4785 |
27 Apr 18 |
olle |
// Navigation |
4785 |
27 Apr 18 |
olle |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
4785 |
27 Apr 18 |
olle |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
4785 |
27 Apr 18 |
olle |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
4785 |
27 Apr 18 |
olle |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
4785 |
27 Apr 18 |
olle |
33 |
|
4785 |
27 Apr 18 |
olle |
// Final registration |
4785 |
27 Apr 18 |
olle |
Events.addEventHandler('wizard', 'wizard-submit', consent.submit); |
4785 |
27 Apr 18 |
olle |
36 |
|
4785 |
27 Apr 18 |
olle |
// Load permissions |
4785 |
27 Apr 18 |
olle |
consent.initPermissions(); |
4785 |
27 Apr 18 |
olle |
// Load configuration |
4785 |
27 Apr 18 |
olle |
consent.loadConfiguration(); |
4785 |
27 Apr 18 |
olle |
41 |
|
4785 |
27 Apr 18 |
olle |
//Doc.show('step-1'); |
4785 |
27 Apr 18 |
olle |
//Doc.show('gonext'); |
4785 |
27 Apr 18 |
olle |
44 |
} |
4785 |
27 Apr 18 |
olle |
45 |
|
4785 |
27 Apr 18 |
olle |
consent.initPermissions = function() |
4785 |
27 Apr 18 |
olle |
47 |
{ |
4785 |
27 Apr 18 |
olle |
// Get permission information |
4785 |
27 Apr 18 |
olle |
var url = '../Install.servlet?ID='+App.getSessionId(); |
4785 |
27 Apr 18 |
olle |
url += '&cmd=GetPermissions'; |
4785 |
27 Apr 18 |
olle |
var request = Ajax.getXmlHttpRequest(); |
4785 |
27 Apr 18 |
olle |
request.open("GET", url, true); |
4785 |
27 Apr 18 |
olle |
Ajax.setReadyStateHandler(request, consent.onPermissionsLoaded, consent.onPermissionsLoaded); |
4785 |
27 Apr 18 |
olle |
request.send(null); |
4785 |
27 Apr 18 |
olle |
55 |
} |
4785 |
27 Apr 18 |
olle |
56 |
|
4785 |
27 Apr 18 |
olle |
// Callback when permission information is ready |
4785 |
27 Apr 18 |
olle |
consent.onPermissionsLoaded = function(request) |
4785 |
27 Apr 18 |
olle |
59 |
{ |
4785 |
27 Apr 18 |
olle |
if (debug) App.debug(Strings.encodeTags(request.responseText)); |
4785 |
27 Apr 18 |
olle |
var response; |
4785 |
27 Apr 18 |
olle |
var error = false; |
4785 |
27 Apr 18 |
olle |
try |
4785 |
27 Apr 18 |
olle |
64 |
{ |
4785 |
27 Apr 18 |
olle |
response = JSON.parse(request.responseText); |
4785 |
27 Apr 18 |
olle |
if (response.status != 'ok') |
4785 |
27 Apr 18 |
olle |
67 |
{ |
4785 |
27 Apr 18 |
olle |
error = response.message || response.stacktrace || 'Unexpected error'; |
4785 |
27 Apr 18 |
olle |
69 |
} |
4785 |
27 Apr 18 |
olle |
70 |
} |
4785 |
27 Apr 18 |
olle |
catch (ex) |
4785 |
27 Apr 18 |
olle |
72 |
{ |
4785 |
27 Apr 18 |
olle |
error = ex; |
4785 |
27 Apr 18 |
olle |
74 |
} |
4785 |
27 Apr 18 |
olle |
75 |
|
4785 |
27 Apr 18 |
olle |
if (error) |
4785 |
27 Apr 18 |
olle |
77 |
{ |
4785 |
27 Apr 18 |
olle |
alert(error); |
4785 |
27 Apr 18 |
olle |
return; |
4785 |
27 Apr 18 |
olle |
80 |
} |
4785 |
27 Apr 18 |
olle |
81 |
|
4785 |
27 Apr 18 |
olle |
myPermissions = response.permissions; |
4785 |
27 Apr 18 |
olle |
//var isAdmin = myPermissions['Administrator'] == 1; |
4785 |
27 Apr 18 |
olle |
//var noProjectIsActive = !App.getActiveProjectId(); |
4785 |
27 Apr 18 |
olle |
85 |
} |
4785 |
27 Apr 18 |
olle |
86 |
|
4785 |
27 Apr 18 |
olle |
consent.loadConfiguration = function() |
4785 |
27 Apr 18 |
olle |
88 |
{ |
4785 |
27 Apr 18 |
olle |
var url = '../Session.servlet?ID='+App.getSessionId(); |
4785 |
27 Apr 18 |
olle |
url += '&cmd=GetConfiguration' |
4785 |
27 Apr 18 |
olle |
var request = Ajax.getXmlHttpRequest(); |
4785 |
27 Apr 18 |
olle |
request.open("GET", url, true); |
4785 |
27 Apr 18 |
olle |
Ajax.setReadyStateHandler(request, consent.onConfiguration, consent.onConfiguration); |
4785 |
27 Apr 18 |
olle |
request.send(null); |
4785 |
27 Apr 18 |
olle |
95 |
} |
4785 |
27 Apr 18 |
olle |
96 |
|
4785 |
27 Apr 18 |
olle |
consent.onConfiguration = function(request) |
4785 |
27 Apr 18 |
olle |
98 |
{ |
4785 |
27 Apr 18 |
olle |
var frm = document.forms['meludi']; |
4785 |
27 Apr 18 |
olle |
100 |
|
4785 |
27 Apr 18 |
olle |
if (debug) |
4785 |
27 Apr 18 |
olle |
102 |
{ |
4785 |
27 Apr 18 |
olle |
App.debug(Strings.encodeTags(request.responseText)); |
4785 |
27 Apr 18 |
olle |
104 |
} |
4785 |
27 Apr 18 |
olle |
105 |
|
4785 |
27 Apr 18 |
olle |
var response; |
4785 |
27 Apr 18 |
olle |
var error = false; |
4785 |
27 Apr 18 |
olle |
try |
4785 |
27 Apr 18 |
olle |
109 |
{ |
4785 |
27 Apr 18 |
olle |
response = JSON.parse(request.responseText); |
4785 |
27 Apr 18 |
olle |
if (response.status != 'ok') |
4785 |
27 Apr 18 |
olle |
112 |
{ |
4785 |
27 Apr 18 |
olle |
error = response.message || response.stacktrace || 'Unexpected error'; |
4785 |
27 Apr 18 |
olle |
114 |
} |
4785 |
27 Apr 18 |
olle |
115 |
} |
4785 |
27 Apr 18 |
olle |
catch (ex) |
4785 |
27 Apr 18 |
olle |
117 |
{ |
4785 |
27 Apr 18 |
olle |
error = ex; |
4785 |
27 Apr 18 |
olle |
119 |
} |
4785 |
27 Apr 18 |
olle |
if (error) App.debug(error); |
4785 |
27 Apr 18 |
olle |
121 |
|
4785 |
27 Apr 18 |
olle |
// Get configuration result |
4785 |
27 Apr 18 |
olle |
var conf = response.configuration; |
4785 |
27 Apr 18 |
olle |
// Check for uses site prefix flag |
4785 |
27 Apr 18 |
olle |
usesSitePrefix = conf.usesSitePrefix; |
4785 |
27 Apr 18 |
olle |
126 |
/* |
4785 |
27 Apr 18 |
olle |
// Check for project focus default |
4785 |
27 Apr 18 |
olle |
var projectFocusDefault = conf.projectFocusDefault; |
4785 |
27 Apr 18 |
olle |
if (projectFocusDefault != null) |
4785 |
27 Apr 18 |
olle |
130 |
{ |
4785 |
27 Apr 18 |
olle |
frm.projectFocus.value = projectFocusDefault; |
4785 |
27 Apr 18 |
olle |
consent.projectFocusOnChange(); |
4785 |
27 Apr 18 |
olle |
133 |
} |
4785 |
27 Apr 18 |
olle |
// Check for specimen type default |
4785 |
27 Apr 18 |
olle |
var specimenTypeDefault = conf.specimenTypeDefault; |
4785 |
27 Apr 18 |
olle |
if (specimenTypeDefault != null) |
4785 |
27 Apr 18 |
olle |
137 |
{ |
4785 |
27 Apr 18 |
olle |
frm.specimenType.value = specimenTypeDefault; |
4785 |
27 Apr 18 |
olle |
139 |
} |
4785 |
27 Apr 18 |
olle |
// Check for specimen input type default |
4785 |
27 Apr 18 |
olle |
var specimenInputTypeDefault = conf.specimenInputTypeDefault; |
4785 |
27 Apr 18 |
olle |
if (specimenInputTypeDefault != null) |
4785 |
27 Apr 18 |
olle |
143 |
{ |
4785 |
27 Apr 18 |
olle |
frm.specimenInputType.value = specimenInputTypeDefault; |
4785 |
27 Apr 18 |
olle |
145 |
} |
4785 |
27 Apr 18 |
olle |
// Check for extracts from first specimen only default |
4785 |
27 Apr 18 |
olle |
var extractsFromFirstSpecimenOnlyDefault = conf.extractsFromFirstSpecimenOnlyDefault; |
4785 |
27 Apr 18 |
olle |
if (extractsFromFirstSpecimenOnlyDefault != null) |
4785 |
27 Apr 18 |
olle |
149 |
{ |
4785 |
27 Apr 18 |
olle |
frm.extractsFromFirstSpecimenOnlyCB.checked = extractsFromFirstSpecimenOnlyDefault; |
4785 |
27 Apr 18 |
olle |
151 |
} |
4785 |
27 Apr 18 |
olle |
152 |
*/ |
4785 |
27 Apr 18 |
olle |
153 |
|
4785 |
27 Apr 18 |
olle |
// Continue with initializing info for case |
4785 |
27 Apr 18 |
olle |
var url = '../LabelGeneration.servlet?ID='+App.getSessionId(); |
4785 |
27 Apr 18 |
olle |
url += '&cmd=CountCases'; |
4785 |
27 Apr 18 |
olle |
Wizard.showLoadingAnimation('Loading cases...'); |
4785 |
27 Apr 18 |
olle |
Wizard.asyncJsonRequest(url, consent.caseInfoLoadedStep1); |
4785 |
27 Apr 18 |
olle |
159 |
} |
4785 |
27 Apr 18 |
olle |
160 |
|
4785 |
27 Apr 18 |
olle |
consent.caseInfoLoadedStep1 = function(response) |
4785 |
27 Apr 18 |
olle |
162 |
{ |
4785 |
27 Apr 18 |
olle |
var frm = document.forms['meludi']; |
4785 |
27 Apr 18 |
olle |
164 |
|
4785 |
27 Apr 18 |
olle |
// Disable PAD/CL input field if not Administrator or PatientCurator |
4785 |
27 Apr 18 |
olle |
var isAdmin = myPermissions['Administrator'] == 1; |
4785 |
27 Apr 18 |
olle |
var isPatCur = myPermissions['PatientCurator'] == 1; |
4785 |
27 Apr 18 |
olle |
if (!isAdmin && !isPatCur) |
4785 |
27 Apr 18 |
olle |
169 |
{ |
4785 |
27 Apr 18 |
olle |
frm.pad.disabled = true; |
4785 |
27 Apr 18 |
olle |
171 |
} |
4785 |
27 Apr 18 |
olle |
172 |
|
4785 |
27 Apr 18 |
olle |
sampleItemPrefix = response.sampleItemPrefix; |
4785 |
27 Apr 18 |
olle |
sampleItemNumDigits = response.sampleItemNumDigits; |
4785 |
27 Apr 18 |
olle |
var nofCases = response.count; |
4785 |
27 Apr 18 |
olle |
if (nofCases == null) |
4785 |
27 Apr 18 |
olle |
177 |
{ |
4785 |
27 Apr 18 |
olle |
nofCases = 0; |
4785 |
27 Apr 18 |
olle |
179 |
} |
4785 |
27 Apr 18 |
olle |
var startNum = nofCases + 1; |
4785 |
27 Apr 18 |
olle |
// Pad number with leading zeros to get right number of digits |
4785 |
27 Apr 18 |
olle |
startNum = String('0000000000' + startNum).slice(-sampleItemNumDigits); |
4785 |
27 Apr 18 |
olle |
var startCase = sampleItemPrefix + startNum; |
4785 |
27 Apr 18 |
olle |
if (usesSitePrefix != null && usesSitePrefix) |
4785 |
27 Apr 18 |
olle |
185 |
{ |
4785 |
27 Apr 18 |
olle |
startCase = ''; |
4785 |
27 Apr 18 |
olle |
187 |
} |
4785 |
27 Apr 18 |
olle |
frm.caseName.value = startCase; |
4785 |
27 Apr 18 |
olle |
Doc.element('caseNameText').innerHTML = 'The case name (barcode) associated with this specimen tube ("' + sampleItemPrefix + '" + ' + sampleItemNumDigits + ' digits).'; |
4785 |
27 Apr 18 |
olle |
190 |
|
4785 |
27 Apr 18 |
olle |
Doc.show('step-1'); |
4785 |
27 Apr 18 |
olle |
Doc.show('gonext'); |
4785 |
27 Apr 18 |
olle |
193 |
} |
4785 |
27 Apr 18 |
olle |
194 |
|
4785 |
27 Apr 18 |
olle |
195 |
/** |
4785 |
27 Apr 18 |
olle |
Check that the case number is valid. |
4785 |
27 Apr 18 |
olle |
197 |
*/ |
4785 |
27 Apr 18 |
olle |
consent.validateStep1 = function(event) |
4785 |
27 Apr 18 |
olle |
199 |
{ |
4785 |
27 Apr 18 |
olle |
var frm = document.forms['meludi']; |
4785 |
27 Apr 18 |
olle |
201 |
|
4785 |
27 Apr 18 |
olle |
var caseName = frm.caseName.value; |
4785 |
27 Apr 18 |
olle |
var caseIsValid = false; |
4785 |
27 Apr 18 |
olle |
Wizard.setInputStatus('caseName'); |
4785 |
27 Apr 18 |
olle |
if (caseName == '') |
4785 |
27 Apr 18 |
olle |
206 |
{ |
4785 |
27 Apr 18 |
olle |
Wizard.setInputStatus('caseName', 'invalid', 'Missing'); |
4785 |
27 Apr 18 |
olle |
frm.caseName.focus(); |
4785 |
27 Apr 18 |
olle |
209 |
} |
4785 |
27 Apr 18 |
olle |
else if (!Meludi.isValidCaseName2(caseName, sampleItemPrefix, sampleItemNumDigits)) |
4785 |
27 Apr 18 |
olle |
211 |
{ |
4785 |
27 Apr 18 |
olle |
Wizard.setInputStatus('caseName', 'invalid', 'Only name = "' + sampleItemPrefix + '" + ' + sampleItemNumDigits + ' digits is allowed.'); |
4785 |
27 Apr 18 |
olle |
frm.caseName.focus(); |
4785 |
27 Apr 18 |
olle |
214 |
} |
4785 |
27 Apr 18 |
olle |
else |
4785 |
27 Apr 18 |
olle |
216 |
{ |
4785 |
27 Apr 18 |
olle |
Wizard.setInputStatus('caseName', 'valid'); |
4785 |
27 Apr 18 |
olle |
caseIsValid = true; |
4785 |
27 Apr 18 |
olle |
219 |
} |
4785 |
27 Apr 18 |
olle |
220 |
|
4785 |
27 Apr 18 |
olle |
// If not valid, we prevent the wizard from moving to the next step |
4785 |
27 Apr 18 |
olle |
if (!caseIsValid) event.preventDefault(); |
4785 |
27 Apr 18 |
olle |
223 |
} |
4785 |
27 Apr 18 |
olle |
224 |
|
4785 |
27 Apr 18 |
olle |
225 |
|
4785 |
27 Apr 18 |
olle |
// Check that the date is valid |
4785 |
27 Apr 18 |
olle |
consent.validateStep2 = function(event) |
4785 |
27 Apr 18 |
olle |
228 |
{ |
4785 |
27 Apr 18 |
olle |
var consentDateIsValid = Wizard.isValid('consentDate'); |
4785 |
27 Apr 18 |
olle |
if (!consentDateIsValid) event.preventDefault(); |
4785 |
27 Apr 18 |
olle |
231 |
} |
4785 |
27 Apr 18 |
olle |
232 |
|
4785 |
27 Apr 18 |
olle |
233 |
/** |
4785 |
27 Apr 18 |
olle |
Load information about the given case. |
4785 |
27 Apr 18 |
olle |
235 |
*/ |
4785 |
27 Apr 18 |
olle |
consent.initializeStep2 = function(event) |
4785 |
27 Apr 18 |
olle |
237 |
{ |
4785 |
27 Apr 18 |
olle |
var frm = document.forms['meludi']; |
4785 |
27 Apr 18 |
olle |
var caseName = frm.caseName.value; |
4785 |
27 Apr 18 |
olle |
240 |
|
4785 |
27 Apr 18 |
olle |
var url = '../ConsentForm.servlet?ID='+App.getSessionId(); |
4785 |
27 Apr 18 |
olle |
url += '&cmd=GetCaseInfo'; |
4785 |
27 Apr 18 |
olle |
url += '&caseName=' + encodeURIComponent(caseName); |
4785 |
27 Apr 18 |
olle |
alert("consentform.js::initializeStep2(): url = " + url); |
4785 |
27 Apr 18 |
olle |
245 |
|
4785 |
27 Apr 18 |
olle |
Wizard.showLoadingAnimation('Loading case information...'); |
4785 |
27 Apr 18 |
olle |
Wizard.asyncJsonRequest(url, consent.caseInfoLoaded); |
4785 |
27 Apr 18 |
olle |
248 |
} |
4785 |
27 Apr 18 |
olle |
249 |
|
4785 |
27 Apr 18 |
olle |
250 |
/** |
4785 |
27 Apr 18 |
olle |
Initalize the second step based on the information we have about the case. |
4785 |
27 Apr 18 |
olle |
252 |
*/ |
4785 |
27 Apr 18 |
olle |
consent.caseInfoLoaded = function(response) |
4785 |
27 Apr 18 |
olle |
254 |
{ |
4785 |
27 Apr 18 |
olle |
var frm = document.forms['meludi']; |
4785 |
27 Apr 18 |
olle |
var caseName = frm.caseName.value; |
4785 |
27 Apr 18 |
olle |
patientInfo = response.patientInfo; |
4785 |
27 Apr 18 |
olle |
var caseInfo = response.caseInfo; |
4785 |
27 Apr 18 |
olle |
var specimenInfo = response.specimenInfo; |
4785 |
27 Apr 18 |
olle |
alert("consentform.js::caseInfoLoaded(): patientInfo = " + JSON.stringify(patientInfo)); |
4785 |
27 Apr 18 |
olle |
alert("consentform.js::caseInfoLoaded(): caseInfo = " + JSON.stringify(caseInfo)); |
4785 |
27 Apr 18 |
olle |
alert("consentform.js::caseInfoLoaded(): specimenInfo = " + JSON.stringify(specimenInfo)); |
4785 |
27 Apr 18 |
olle |
263 |
|
4785 |
27 Apr 18 |
olle |
sampleItemPrefix = response.sampleItemPrefix; |
4785 |
27 Apr 18 |
olle |
sampleItemNumDigits = response.sampleItemNumDigits; |
4785 |
27 Apr 18 |
olle |
266 |
|
4785 |
27 Apr 18 |
olle |
if (patientInfo) |
4785 |
27 Apr 18 |
olle |
268 |
{ |
4785 |
27 Apr 18 |
olle |
var moreCasesHtml = ''; |
4785 |
27 Apr 18 |
olle |
var numMissing = 0; |
4785 |
27 Apr 18 |
olle |
271 |
|
4785 |
27 Apr 18 |
olle |
if (patientInfo.allCases) |
4785 |
27 Apr 18 |
olle |
273 |
{ |
4785 |
27 Apr 18 |
olle |
for (var i = 0; i < patientInfo.allCases.length; i++) |
4785 |
27 Apr 18 |
olle |
275 |
{ |
4785 |
27 Apr 18 |
olle |
var c = patientInfo.allCases[i]; |
4785 |
27 Apr 18 |
olle |
//var laterality = c.laterality ? ' ('+c.laterality+')' : ''; |
4785 |
27 Apr 18 |
olle |
var checked = ''; |
4785 |
27 Apr 18 |
olle |
if (!c.consent) |
4785 |
27 Apr 18 |
olle |
280 |
{ |
4785 |
27 Apr 18 |
olle |
checked = 'checked'; |
4785 |
27 Apr 18 |
olle |
numMissing++; |
4785 |
27 Apr 18 |
olle |
283 |
} |
4785 |
27 Apr 18 |
olle |
284 |
|
4785 |
27 Apr 18 |
olle |
if (c.name == caseName && c.consentDate) |
4785 |
27 Apr 18 |
olle |
286 |
{ |
4785 |
27 Apr 18 |
olle |
frm.consentDate.value = c.consentDate; |
4785 |
27 Apr 18 |
olle |
288 |
} |
4785 |
27 Apr 18 |
olle |
moreCasesHtml += '<input type="checkbox" name="case.'+c.id+'" id="case.'+c.id+'" ' + checked +'>'; |
4785 |
27 Apr 18 |
olle |
//moreCasesHtml += '<label for="case.'+c.id+'">Case: ' + Strings.encodeTags(c.name + laterality) + '</label><br>'; |
4785 |
27 Apr 18 |
olle |
291 |
} |
4785 |
27 Apr 18 |
olle |
292 |
} |
4785 |
27 Apr 18 |
olle |
293 |
|
4785 |
27 Apr 18 |
olle |
294 |
|
4785 |
27 Apr 18 |
olle |
295 |
/* |
4785 |
27 Apr 18 |
olle |
if (patientInfo.allBlood) |
4785 |
27 Apr 18 |
olle |
297 |
{ |
4785 |
27 Apr 18 |
olle |
for (var i = 0; i < patientInfo.allBlood.length; i++) |
4785 |
27 Apr 18 |
olle |
299 |
{ |
4785 |
27 Apr 18 |
olle |
var c = patientInfo.allBlood[i]; |
4785 |
27 Apr 18 |
olle |
var checked = ''; |
4785 |
27 Apr 18 |
olle |
if (!c.consent) |
4785 |
27 Apr 18 |
olle |
303 |
{ |
4785 |
27 Apr 18 |
olle |
checked = 'checked'; |
4785 |
27 Apr 18 |
olle |
numMissing++; |
4785 |
27 Apr 18 |
olle |
306 |
} |
4785 |
27 Apr 18 |
olle |
if (c.name.indexOf(caseName) == 0 && c.consentDate) |
4785 |
27 Apr 18 |
olle |
308 |
{ |
4785 |
27 Apr 18 |
olle |
frm.consentDate.value = c.consentDate; |
4785 |
27 Apr 18 |
olle |
310 |
} |
4785 |
27 Apr 18 |
olle |
moreCasesHtml += '<input type="checkbox" name="blood.'+ c.id + '" id="blood.'+c.id+'" ' + checked +'>'; |
4785 |
27 Apr 18 |
olle |
moreCasesHtml += '<label for="blood.'+c.id+'">Blood: ' + Strings.encodeTags(c.name) + '</label><br>'; |
4785 |
27 Apr 18 |
olle |
313 |
} |
4785 |
27 Apr 18 |
olle |
314 |
} |
4785 |
27 Apr 18 |
olle |
315 |
*/ |
4785 |
27 Apr 18 |
olle |
316 |
|
4785 |
27 Apr 18 |
olle |
consent.enableConsentOption('consent.yes', true); |
4785 |
27 Apr 18 |
olle |
Doc.element('moreCases').innerHTML = moreCasesHtml; |
4785 |
27 Apr 18 |
olle |
Doc.show('moreCasesSection'); |
4785 |
27 Apr 18 |
olle |
320 |
|
4785 |
27 Apr 18 |
olle |
if (numMissing > 0) |
4785 |
27 Apr 18 |
olle |
322 |
{ |
4785 |
27 Apr 18 |
olle |
Wizard.setInputStatus('consent', 'valid', 'This patient already exists and has at least one case or blood sample with missing consent.'); |
4785 |
27 Apr 18 |
olle |
324 |
} |
4785 |
27 Apr 18 |
olle |
else |
4785 |
27 Apr 18 |
olle |
326 |
{ |
4785 |
27 Apr 18 |
olle |
Wizard.setInputStatus('consent', 'valid', '"Yes" has already been registered for all case and blood samples for this patient.'); |
4785 |
27 Apr 18 |
olle |
328 |
} |
4785 |
27 Apr 18 |
olle |
Doc.show('morehelp.multiple', 'inline'); |
4785 |
27 Apr 18 |
olle |
Doc.show('morehelp.yesonly', 'inline'); |
4785 |
27 Apr 18 |
olle |
Doc.show('gocancel'); |
4785 |
27 Apr 18 |
olle |
Doc.show('goregister'); |
4785 |
27 Apr 18 |
olle |
333 |
|
4785 |
27 Apr 18 |
olle |
334 |
} |
4785 |
27 Apr 18 |
olle |
else if (caseInfo) |
4785 |
27 Apr 18 |
olle |
336 |
{ |
4785 |
27 Apr 18 |
olle |
if (caseInfo.consent) |
4785 |
27 Apr 18 |
olle |
338 |
{ |
4785 |
27 Apr 18 |
olle |
// A consent has already been registered for this case |
4785 |
27 Apr 18 |
olle |
// We do not support updating this |
4785 |
27 Apr 18 |
olle |
consent.enableConsentOption(consentToId[caseInfo.consent], true); |
4785 |
27 Apr 18 |
olle |
Wizard.setInputStatus('consent', '', '"' + caseInfo.consent + '" has already been registered for this case. It is not possible to change with this wizard.'); |
4785 |
27 Apr 18 |
olle |
if (caseInfo.consentDate) |
4785 |
27 Apr 18 |
olle |
344 |
{ |
4785 |
27 Apr 18 |
olle |
frm.consentDate.value = caseInfo.consentDate; |
4785 |
27 Apr 18 |
olle |
frm.consentDate.disabled = true; |
4785 |
27 Apr 18 |
olle |
347 |
} |
4785 |
27 Apr 18 |
olle |
Doc.show('gorestart'); |
4785 |
27 Apr 18 |
olle |
349 |
} |
4785 |
27 Apr 18 |
olle |
else |
4785 |
27 Apr 18 |
olle |
351 |
{ |
4785 |
27 Apr 18 |
olle |
consent.enableConsentOption('consent.no', true); |
4785 |
27 Apr 18 |
olle |
consent.enableConsentOption('consent.notAsked'); |
4785 |
27 Apr 18 |
olle |
consent.enableConsentOption('consent.yes'); |
4785 |
27 Apr 18 |
olle |
if (caseInfo.consentDate) |
4785 |
27 Apr 18 |
olle |
356 |
{ |
4785 |
27 Apr 18 |
olle |
frm.consentDate.value = caseInfo.consentDate; |
4785 |
27 Apr 18 |
olle |
frm.consentDate.disabled = true; |
4785 |
27 Apr 18 |
olle |
359 |
} |
4785 |
27 Apr 18 |
olle |
Doc.show('morehelp.any', 'inline'); |
4785 |
27 Apr 18 |
olle |
Doc.show('gocancel'); |
4785 |
27 Apr 18 |
olle |
Doc.show('goregister'); |
4785 |
27 Apr 18 |
olle |
363 |
} |
4785 |
27 Apr 18 |
olle |
364 |
} |
4785 |
27 Apr 18 |
olle |
else if (specimenInfo) |
4785 |
27 Apr 18 |
olle |
366 |
{ |
4785 |
27 Apr 18 |
olle |
// There is no existing case but there are specimen related to it |
4785 |
27 Apr 18 |
olle |
// This wizard will only allow 'Yes' option on the consent form |
4785 |
27 Apr 18 |
olle |
consent.enableConsentOption('consent.yes', true); |
4785 |
27 Apr 18 |
olle |
Wizard.setInputStatus('consent', 'valid', 'Specimen tubes for this case already exists.'); |
4785 |
27 Apr 18 |
olle |
Doc.show('morehelp.yesonly', 'inline'); |
4785 |
27 Apr 18 |
olle |
Doc.show('gocancel'); |
4785 |
27 Apr 18 |
olle |
Doc.show('goregister'); |
4785 |
27 Apr 18 |
olle |
374 |
} |
4785 |
27 Apr 18 |
olle |
else |
4785 |
27 Apr 18 |
olle |
376 |
{ |
4785 |
27 Apr 18 |
olle |
// We have no information about this case -- but allow a consent to be registered in any case |
4785 |
27 Apr 18 |
olle |
consent.enableConsentOption('consent.no', true); |
4785 |
27 Apr 18 |
olle |
consent.enableConsentOption('consent.notAsked'); |
4785 |
27 Apr 18 |
olle |
consent.enableConsentOption('consent.yes'); |
4785 |
27 Apr 18 |
olle |
Doc.show('morehelp.any', 'inline'); |
4785 |
27 Apr 18 |
olle |
Doc.show('gocancel'); |
4785 |
27 Apr 18 |
olle |
Doc.show('goregister'); |
4785 |
27 Apr 18 |
olle |
384 |
} |
4785 |
27 Apr 18 |
olle |
385 |
|
4785 |
27 Apr 18 |
olle |
Wizard.setCurrentStep(2); |
4785 |
27 Apr 18 |
olle |
if (!frm.consentDate.disabled) frm.consentDate.focus(); |
4785 |
27 Apr 18 |
olle |
388 |
|
4785 |
27 Apr 18 |
olle |
389 |
} |
4785 |
27 Apr 18 |
olle |
390 |
|
4785 |
27 Apr 18 |
olle |
391 |
|
4785 |
27 Apr 18 |
olle |
consent.submit = function() |
4785 |
27 Apr 18 |
olle |
393 |
{ |
4785 |
27 Apr 18 |
olle |
394 |
|
4785 |
27 Apr 18 |
olle |
var frm = document.forms['meludi']; |
4785 |
27 Apr 18 |
olle |
396 |
|
4785 |
27 Apr 18 |
olle |
var consentInfo = {}; |
4785 |
27 Apr 18 |
olle |
consentInfo.caseName = frm.caseName.value; |
4785 |
27 Apr 18 |
olle |
consentInfo.consentDate = frm.consentDate.value; |
4785 |
27 Apr 18 |
olle |
consentInfo.consent = Forms.getCheckedRadio(frm.consent).value; |
4785 |
27 Apr 18 |
olle |
if (consentInfo.consent == 'Not asked') |
4785 |
27 Apr 18 |
olle |
402 |
{ |
4785 |
27 Apr 18 |
olle |
var reasonIfNotAsked = ''; |
4785 |
27 Apr 18 |
olle |
for (var i = 0; i < frm.reasonIfNotAsked.length; i++) |
4785 |
27 Apr 18 |
olle |
405 |
{ |
4785 |
27 Apr 18 |
olle |
var option = frm.reasonIfNotAsked[i]; |
4785 |
27 Apr 18 |
olle |
if (option.checked) |
4785 |
27 Apr 18 |
olle |
408 |
{ |
4785 |
27 Apr 18 |
olle |
if (option.id == 'notAsked.other') |
4785 |
27 Apr 18 |
olle |
410 |
{ |
4785 |
27 Apr 18 |
olle |
reasonIfNotAsked += frm.otherReasonIfNotAsked.value; |
4785 |
27 Apr 18 |
olle |
412 |
} |
4785 |
27 Apr 18 |
olle |
else |
4785 |
27 Apr 18 |
olle |
414 |
{ |
4785 |
27 Apr 18 |
olle |
var label = Doc.element(option.id + '.label'); |
4785 |
27 Apr 18 |
olle |
reasonIfNotAsked += label.innerHTML + '\n'; |
4785 |
27 Apr 18 |
olle |
417 |
} |
4785 |
27 Apr 18 |
olle |
418 |
} |
4785 |
27 Apr 18 |
olle |
419 |
} |
4785 |
27 Apr 18 |
olle |
consentInfo.reasonIfNotAsked = reasonIfNotAsked; |
4785 |
27 Apr 18 |
olle |
421 |
} |
4785 |
27 Apr 18 |
olle |
422 |
|
4785 |
27 Apr 18 |
olle |
if (patientInfo) |
4785 |
27 Apr 18 |
olle |
424 |
{ |
4785 |
27 Apr 18 |
olle |
var selectedSamples = []; |
4785 |
27 Apr 18 |
olle |
if (patientInfo.allCases) |
4785 |
27 Apr 18 |
olle |
427 |
{ |
4785 |
27 Apr 18 |
olle |
for (var i = 0; i < patientInfo.allCases.length; i++) |
4785 |
27 Apr 18 |
olle |
429 |
{ |
4785 |
27 Apr 18 |
olle |
var c = patientInfo.allCases[i]; |
4785 |
27 Apr 18 |
olle |
var chk = frm['case.'+c.id]; |
4785 |
27 Apr 18 |
olle |
if (chk.checked) selectedSamples.push(c.id); |
4785 |
27 Apr 18 |
olle |
433 |
} |
4785 |
27 Apr 18 |
olle |
434 |
} |
4785 |
27 Apr 18 |
olle |
435 |
|
4785 |
27 Apr 18 |
olle |
if (patientInfo.allBlood) |
4785 |
27 Apr 18 |
olle |
437 |
{ |
4785 |
27 Apr 18 |
olle |
for (var i = 0; i < patientInfo.allBlood.length; i++) |
4785 |
27 Apr 18 |
olle |
439 |
{ |
4785 |
27 Apr 18 |
olle |
var c = patientInfo.allBlood[i]; |
4785 |
27 Apr 18 |
olle |
var chk = frm['blood.'+c.id]; |
4785 |
27 Apr 18 |
olle |
if (chk.checked) selectedSamples.push(c.id); |
4785 |
27 Apr 18 |
olle |
443 |
} |
4785 |
27 Apr 18 |
olle |
444 |
} |
4785 |
27 Apr 18 |
olle |
consentInfo.selectedSamples = selectedSamples; |
4785 |
27 Apr 18 |
olle |
446 |
} |
4785 |
27 Apr 18 |
olle |
447 |
|
4785 |
27 Apr 18 |
olle |
var submitInfo = {}; |
4785 |
27 Apr 18 |
olle |
submitInfo.consentInfo = consentInfo; |
4785 |
27 Apr 18 |
olle |
450 |
|
4785 |
27 Apr 18 |
olle |
var url = '../ConsentForm.servlet?ID=' + App.getSessionId(); |
4785 |
27 Apr 18 |
olle |
url += '&cmd=RegisterConsent'; |
4785 |
27 Apr 18 |
olle |
453 |
|
4785 |
27 Apr 18 |
olle |
Wizard.showLoadingAnimation('Registering consent information...'); |
4785 |
27 Apr 18 |
olle |
Wizard.asyncJsonRequest(url, consent.submissionResults, 'POST', JSON.stringify(submitInfo)); |
4785 |
27 Apr 18 |
olle |
456 |
} |
4785 |
27 Apr 18 |
olle |
457 |
|
4785 |
27 Apr 18 |
olle |
458 |
|
4785 |
27 Apr 18 |
olle |
consent.submissionResults = function(response) |
4785 |
27 Apr 18 |
olle |
460 |
{ |
4785 |
27 Apr 18 |
olle |
Wizard.showFinalMessage(response.messages); |
4785 |
27 Apr 18 |
olle |
Doc.show('gorestart'); |
4785 |
27 Apr 18 |
olle |
463 |
} |
4785 |
27 Apr 18 |
olle |
464 |
|
4785 |
27 Apr 18 |
olle |
consent.enableConsentOption = function(option, checkIt) |
4785 |
27 Apr 18 |
olle |
466 |
{ |
4785 |
27 Apr 18 |
olle |
option = Doc.element(option); // The radio button |
4785 |
27 Apr 18 |
olle |
option.disabled = false; |
4785 |
27 Apr 18 |
olle |
if (checkIt) option.checked = true; |
4785 |
27 Apr 18 |
olle |
470 |
|
4785 |
27 Apr 18 |
olle |
var label = Doc.element(option.id + '.label'); // The label |
4785 |
27 Apr 18 |
olle |
Doc.removeClass(label, 'disabled'); |
4785 |
27 Apr 18 |
olle |
473 |
} |
4785 |
27 Apr 18 |
olle |
474 |
|
4785 |
27 Apr 18 |
olle |
475 |
|
4785 |
27 Apr 18 |
olle |
476 |
|
4785 |
27 Apr 18 |
olle |
consent.consentOnChange = function() |
4785 |
27 Apr 18 |
olle |
478 |
{ |
4785 |
27 Apr 18 |
olle |
// If "Not asked" is selected we must enable the second question |
4785 |
27 Apr 18 |
olle |
var isAsked = !Doc.element('consent.notAsked').checked; |
4785 |
27 Apr 18 |
olle |
481 |
|
4785 |
27 Apr 18 |
olle |
var frm = document.forms['meludi']; |
4785 |
27 Apr 18 |
olle |
var reasonIfNotAsked = frm.reasonIfNotAsked; |
4785 |
27 Apr 18 |
olle |
for (var i = 0; i < reasonIfNotAsked.length; i++) |
4785 |
27 Apr 18 |
olle |
485 |
{ |
4785 |
27 Apr 18 |
olle |
reasonIfNotAsked[i].disabled = isAsked; |
4785 |
27 Apr 18 |
olle |
Doc.addOrRemoveClass(reasonIfNotAsked[i].id + '.label', 'disabled', isAsked); |
4785 |
27 Apr 18 |
olle |
488 |
} |
4785 |
27 Apr 18 |
olle |
frm.otherReasonIfNotAsked.disabled = isAsked; |
4785 |
27 Apr 18 |
olle |
490 |
} |
4785 |
27 Apr 18 |
olle |
491 |
|
4785 |
27 Apr 18 |
olle |
consent.onOtherReasonFocus = function() |
4785 |
27 Apr 18 |
olle |
493 |
{ |
4785 |
27 Apr 18 |
olle |
Doc.element('notAsked.other').checked = true; |
4785 |
27 Apr 18 |
olle |
495 |
} |
4785 |
27 Apr 18 |
olle |
496 |
|
4785 |
27 Apr 18 |
olle |
return consent; |
4785 |
27 Apr 18 |
olle |
498 |
}(); |
4785 |
27 Apr 18 |
olle |
499 |
|
4785 |
27 Apr 18 |
olle |
Doc.onLoad(Consent.initPage); |
4785 |
27 Apr 18 |
olle |
501 |
|