1 | <%@ page |
---|
2 | pageEncoding="UTF-8" |
---|
3 | session="false" |
---|
4 | import="net.sf.basedb.core.Application" |
---|
5 | import="net.sf.basedb.core.User" |
---|
6 | import="net.sf.basedb.core.DbControl" |
---|
7 | import="net.sf.basedb.core.SessionControl" |
---|
8 | import="net.sf.basedb.clients.web.Base" |
---|
9 | import="net.sf.basedb.clients.web.util.HTML" |
---|
10 | import="net.sf.basedb.util.Values" |
---|
11 | %> |
---|
12 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
13 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
14 | <% |
---|
15 | final SessionControl sc = Base.getExistingSessionControl(request, true); |
---|
16 | final String ID = sc.getId(); |
---|
17 | final float scale = Base.getScale(sc); |
---|
18 | DbControl dc = null; |
---|
19 | try |
---|
20 | { |
---|
21 | dc = sc.newDbControl(); |
---|
22 | final User user = User.getById(dc, sc.getLoggedInUserId()); |
---|
23 | %> |
---|
24 | <base:page type="default" > |
---|
25 | <base:head scripts="ajax.js" styles="path.css"> |
---|
26 | <link rel="stylesheet" type="text/css" href="reggie.css"> |
---|
27 | <script language="JavaScript" src="reggie.js" type="text/javascript" charset="UTF-8"></script> |
---|
28 | |
---|
29 | <script language="JavaScript"> |
---|
30 | |
---|
31 | var debug = false; |
---|
32 | var currentStep = 1; |
---|
33 | var caseIsValid = false; |
---|
34 | var consentDateIsValid = false; |
---|
35 | |
---|
36 | var consentToId = { "Yes": "consent.yes", "No" : "consent.no", "Not asked": "consent.notAsked" }; |
---|
37 | |
---|
38 | var caseInfo = null; |
---|
39 | |
---|
40 | function init() |
---|
41 | { |
---|
42 | var frm = document.forms['reggie']; |
---|
43 | frm.caseName.focus(); |
---|
44 | } |
---|
45 | |
---|
46 | function step1IsValid() |
---|
47 | { |
---|
48 | var frm = document.forms['reggie']; |
---|
49 | var caseName = frm.caseName.value; |
---|
50 | if (caseName == '') |
---|
51 | { |
---|
52 | setInputStatus('case', 'Missing', 'invalid'); |
---|
53 | caseIsValid = false; |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | setInputStatus('case', '', 'valid'); |
---|
58 | caseIsValid = true; |
---|
59 | } |
---|
60 | return caseIsValid; |
---|
61 | } |
---|
62 | |
---|
63 | function step2IsValid() |
---|
64 | { |
---|
65 | return consentDateIsValid; |
---|
66 | } |
---|
67 | |
---|
68 | function goNext(manual) |
---|
69 | { |
---|
70 | setInnerHTML('gonext.message', ''); |
---|
71 | if (currentStep == 1) |
---|
72 | { |
---|
73 | if (step1IsValid()) gotoStep2(); |
---|
74 | } |
---|
75 | else if (currentStep == 2) |
---|
76 | { |
---|
77 | if (step2IsValid()) gotoStep3(); |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | function gotoStep2() |
---|
83 | { |
---|
84 | // Check entered case and pnr with AJAX |
---|
85 | var frm = document.forms['reggie']; |
---|
86 | |
---|
87 | frm.caseName.disabled = true; |
---|
88 | currentStep = 2; |
---|
89 | |
---|
90 | var caseName = frm.caseName.value; |
---|
91 | var request = Ajax.getXmlHttpRequest(); |
---|
92 | var url = 'ConsentForm.servlet?ID=<%=ID%>&cmd=GetCaseInfo'; |
---|
93 | url += '&caseName=' + caseName; |
---|
94 | request.open("GET", url, false); |
---|
95 | request.send(null); |
---|
96 | |
---|
97 | if (debug) Main.debug(request.responseText); |
---|
98 | var response = JSON.parse(request.responseText); |
---|
99 | if (response.status != 'ok') |
---|
100 | { |
---|
101 | setFatalError(response.message); |
---|
102 | return false; |
---|
103 | } |
---|
104 | |
---|
105 | Main.hide('gonext'); |
---|
106 | Main.show('consentSection'); |
---|
107 | |
---|
108 | // Get case information from the AJAX response |
---|
109 | caseInfo = response.caseInfo; |
---|
110 | |
---|
111 | if (caseInfo.consentDate) |
---|
112 | { |
---|
113 | frm.consentDate.value = caseInfo.consentDate; |
---|
114 | } |
---|
115 | frm.consentDate.focus(); |
---|
116 | |
---|
117 | |
---|
118 | // caseInfo.consent = 'No'; |
---|
119 | // caseInfo.id = 999; |
---|
120 | // caseInfo.specimen = [ 1 ]; |
---|
121 | |
---|
122 | if (caseInfo.consent) |
---|
123 | { |
---|
124 | // A consent has already been registered for this case |
---|
125 | // We do not support updating this |
---|
126 | enableConsentOption(consentToId[caseInfo.consent], true); |
---|
127 | setInputStatus('consent', '"' + caseInfo.consent + '" has already been registered for this case. It is not possible to change with this wizard.', ''); |
---|
128 | Main.show('gorestart'); |
---|
129 | frm.consentDate.disabled = true; |
---|
130 | } |
---|
131 | else if (caseInfo.id) |
---|
132 | { |
---|
133 | // There is an existing case already registered |
---|
134 | // This wizard will only allow 'Yes' option on the consent form |
---|
135 | enableConsentOption('consent.yes', true); |
---|
136 | setInputStatus('consent', 'This case already exists.', 'valid'); |
---|
137 | Main.showInline('morehelp.yes'); |
---|
138 | Main.show('gocancel'); |
---|
139 | Main.show('goregister'); |
---|
140 | } |
---|
141 | else if (caseInfo.specimen && caseInfo.specimen.length > 0) |
---|
142 | { |
---|
143 | // There is no existing case but there are specimen related to it |
---|
144 | // This wizard can't be used until the "Personal registration wizard" |
---|
145 | // has been completed for this case |
---|
146 | setInputStatus('consent', 'Specimen tubes for this case already exists.', 'invalid'); |
---|
147 | Main.showInline('morehelp.specimen'); |
---|
148 | Main.show('gorestart'); |
---|
149 | frm.consentDate.disabled = true; |
---|
150 | } |
---|
151 | else |
---|
152 | { |
---|
153 | // We have no information about this case |
---|
154 | // The wizard will only allow 'No' and 'Not asked' option on the consent form |
---|
155 | enableConsentOption('consent.no', true); |
---|
156 | enableConsentOption('consent.notAsked'); |
---|
157 | Main.showInline('morehelp.no'); |
---|
158 | Main.show('gocancel'); |
---|
159 | Main.show('goregister'); |
---|
160 | } |
---|
161 | |
---|
162 | } |
---|
163 | |
---|
164 | function goRegister() |
---|
165 | { |
---|
166 | if (!step2IsValid()) return; |
---|
167 | |
---|
168 | var frm = document.forms['reggie']; |
---|
169 | frm.otherReasonIfNotAsked.disabled = true; |
---|
170 | frm.consentDate.disabled = true; |
---|
171 | for (var i = 0; i < frm.consent.length; i++) |
---|
172 | { |
---|
173 | frm.consent[i].disabled = true; |
---|
174 | } |
---|
175 | for (var i = 0; i < frm.reasonIfNotAsked.length; i++) |
---|
176 | { |
---|
177 | frm.reasonIfNotAsked[i].disabled = true; |
---|
178 | } |
---|
179 | |
---|
180 | Main.hide('goregister'); |
---|
181 | Main.hide('gocancel'); |
---|
182 | |
---|
183 | caseInfo.consentDate = frm.consentDate.value; |
---|
184 | caseInfo.consent = Forms.getCheckedRadio(frm.consent).value; |
---|
185 | if (caseInfo.consent == 'Not asked') |
---|
186 | { |
---|
187 | var reasonIfNotAsked = ''; |
---|
188 | for (var i = 0; i < frm.reasonIfNotAsked.length; i++) |
---|
189 | { |
---|
190 | var option = frm.reasonIfNotAsked[i]; |
---|
191 | if (option.checked) |
---|
192 | { |
---|
193 | if (option.id == 'notAsked.other') |
---|
194 | { |
---|
195 | reasonIfNotAsked += frm.otherReasonIfNotAsked.value; |
---|
196 | } |
---|
197 | else |
---|
198 | { |
---|
199 | var label = document.getElementById(option.id + '.label'); |
---|
200 | reasonIfNotAsked += label.innerHTML + '\n'; |
---|
201 | } |
---|
202 | } |
---|
203 | } |
---|
204 | caseInfo.reasonIfNotAsked = reasonIfNotAsked; |
---|
205 | } |
---|
206 | |
---|
207 | var submitInfo = new Object(); |
---|
208 | submitInfo.caseInfo = caseInfo; |
---|
209 | |
---|
210 | if (debug) Main.debug(JSON.stringify(submitInfo)); |
---|
211 | var request = Ajax.getXmlHttpRequest(); |
---|
212 | var url = 'ConsentForm.servlet?ID=<%=ID%>&cmd=RegisterConsent'; |
---|
213 | request.open("POST", url, false); |
---|
214 | request.setRequestHeader("Content-Type", "application/json"); |
---|
215 | request.send(JSON.stringify(submitInfo)); |
---|
216 | |
---|
217 | if (debug) Main.debug(request.responseText); |
---|
218 | |
---|
219 | var response = JSON.parse(request.responseText); |
---|
220 | if (response.status != 'ok') |
---|
221 | { |
---|
222 | setFatalError(response.message); |
---|
223 | return false; |
---|
224 | } |
---|
225 | |
---|
226 | var msg = '<ul>'; |
---|
227 | for (var i = 0; i < response.messages.length; i++) |
---|
228 | { |
---|
229 | msg += '<li>' + response.messages[i]; |
---|
230 | } |
---|
231 | msg += '</ul>'; |
---|
232 | setInnerHTML('done', msg); |
---|
233 | Main.show('done'); |
---|
234 | Main.show('gorestart'); |
---|
235 | } |
---|
236 | |
---|
237 | function enableConsentOption(optionId, checkIt) |
---|
238 | { |
---|
239 | var option = document.getElementById(optionId); // The radio button |
---|
240 | option.disabled = false; |
---|
241 | if (checkIt) option.checked = true; |
---|
242 | var label = document.getElementById(optionId + '.label'); // The label |
---|
243 | Main.removeClass(label, 'disabled'); |
---|
244 | } |
---|
245 | |
---|
246 | function consentDateOnChange() |
---|
247 | { |
---|
248 | var frm = document.forms['reggie']; |
---|
249 | consentDateIsValid = false; |
---|
250 | setInputStatus('consentDate', '', ''); |
---|
251 | |
---|
252 | var consentDate = frm.consentDate.value; |
---|
253 | |
---|
254 | if (consentDate == '') |
---|
255 | { |
---|
256 | setInputStatus('consentDate', 'Missing', 'warning'); |
---|
257 | } |
---|
258 | else |
---|
259 | { |
---|
260 | // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits. |
---|
261 | consentDate = autoFillDate(consentDate); |
---|
262 | frm.consentDate.value = consentDate; |
---|
263 | |
---|
264 | if (!Dates.isDate(consentDate, 'yyyyMMdd')) |
---|
265 | { |
---|
266 | setInputStatus('consentDate', 'Not a valid date', 'invalid'); |
---|
267 | return; |
---|
268 | } |
---|
269 | setInputStatus('consentDate', '', 'valid'); |
---|
270 | } |
---|
271 | |
---|
272 | consentDateIsValid = true; |
---|
273 | } |
---|
274 | |
---|
275 | |
---|
276 | function consentOnChange() |
---|
277 | { |
---|
278 | // If "Not asked" is selected we must enable the second question |
---|
279 | var isAsked = !document.getElementById('consent.notAsked').checked; |
---|
280 | |
---|
281 | var frm = document.forms['reggie']; |
---|
282 | var reasonIfNotAsked = frm.reasonIfNotAsked; |
---|
283 | for (var i = 0; i < reasonIfNotAsked.length; i++) |
---|
284 | { |
---|
285 | reasonIfNotAsked[i].disabled = isAsked; |
---|
286 | var label = document.getElementById(reasonIfNotAsked[i].id + '.label'); |
---|
287 | Main.addOrRemoveClass(label, 'disabled', isAsked); |
---|
288 | } |
---|
289 | frm.otherReasonIfNotAsked.disabled = isAsked; |
---|
290 | |
---|
291 | } |
---|
292 | |
---|
293 | </script> |
---|
294 | <style> |
---|
295 | .disabled |
---|
296 | { |
---|
297 | color: #999999; |
---|
298 | font-style: italic; |
---|
299 | } |
---|
300 | </style> |
---|
301 | </base:head> |
---|
302 | <base:body onload="init()"> |
---|
303 | |
---|
304 | <p:path style="margin-top: 20px; margin-bottom: 10px;"> |
---|
305 | <p:pathelement title="Reggie" href="<%="index.jsp?ID="+ID%>" /> |
---|
306 | <p:pathelement title="Consent form registration" /> |
---|
307 | </p:path> |
---|
308 | |
---|
309 | <% |
---|
310 | if (sc.getActiveProjectId() == 0) |
---|
311 | { |
---|
312 | %> |
---|
313 | <base:note type="warning" style="width: 800px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;"> |
---|
314 | No project has been selected. You may proceed with the registration but |
---|
315 | created items will not be shared. |
---|
316 | </base:note> |
---|
317 | <% |
---|
318 | } |
---|
319 | %> |
---|
320 | |
---|
321 | <form name="reggie" onsubmit="return false;"> |
---|
322 | |
---|
323 | <!-- 1. Case + Personal number --> |
---|
324 | <table border="0" cellspacing="0" cellpadding="0" class="stepform"> |
---|
325 | <tr> |
---|
326 | <td rowspan="3" class="stepno">1</td> |
---|
327 | <td class="steptitle">Enter Case Name</td> |
---|
328 | </tr> |
---|
329 | <tr> |
---|
330 | <td class="stepfields"> |
---|
331 | <table border="0" cellspacing="0" cellpadding="0" width="100%"> |
---|
332 | <tr> |
---|
333 | <td class="prompt">Case name</td> |
---|
334 | <td class="input"><input type="text" name="caseName" |
---|
335 | size="18" maxlength="12" onkeypress="doOnTabOrEnter(event, goNext)"></td> |
---|
336 | <td class="status" id="case.status"></td> |
---|
337 | <td class="help"><span id="case.message" class="message" style="display: none;"></span>The case (barcode) associated with the case.</td> |
---|
338 | </tr> |
---|
339 | </table> |
---|
340 | </td> |
---|
341 | </tr> |
---|
342 | </table> |
---|
343 | |
---|
344 | <!-- 2. Consent section --> |
---|
345 | <div id="consentSection" style="display: none;"> |
---|
346 | <p> |
---|
347 | <table border="0" cellspacing="0" cellpadding="0" class="stepform"> |
---|
348 | <tr> |
---|
349 | <td rowspan="2" class="stepno">2</td> |
---|
350 | <td class="steptitle">Consent form</td> |
---|
351 | </tr> |
---|
352 | <tr> |
---|
353 | <td class="stepfields"> |
---|
354 | <table border="0" cellspacing="0" cellpadding="0" width="100%"> |
---|
355 | <tr valign="top"> |
---|
356 | <td class="prompt">Date</td> |
---|
357 | <td class="input" style="padding-left: 0px;"> |
---|
358 | <input type="text" name="consentDate" value="" size="12" maxlength="10" |
---|
359 | onblur="consentDateOnChange()"> |
---|
360 | </td> |
---|
361 | <td class="status" id="consentDate.status"></td> |
---|
362 | <td class="help"> |
---|
363 | <span id="consentDate.message" class="message" style="display: none;"></span>(YYYYMMDD or MMDD) |
---|
364 | </td> |
---|
365 | </tr> |
---|
366 | <tr valign="top"> |
---|
367 | <td class="prompt">Consent</td> |
---|
368 | <td class="input" style="padding-left: 0px;"> |
---|
369 | <input id="consent.no" type="radio" name="consent" value="No" disabled onchange="consentOnChange()"> |
---|
370 | <label id="consent.no.label" for="consent.no" class="disabled">No</label><br> |
---|
371 | <input id="consent.yes" type="radio" name="consent" value="Yes" disabled onchange="consentOnChange()"> |
---|
372 | <label id="consent.yes.label" for="consent.yes" class="disabled">Yes</label><br> |
---|
373 | <input id="consent.notAsked" type="radio" name="consent" value="Not asked" disabled onchange="consentOnChange()"> |
---|
374 | <label id="consent.notAsked.label" for="consent.notAsked" class="disabled">Not asked</label> |
---|
375 | </td> |
---|
376 | <td class="status" id="consent.status"></td> |
---|
377 | <td class="help" rowspan="2"> |
---|
378 | <span id="consent.message" class="message" style="display: none;"></span> |
---|
379 | <span id="morehelp.yes" style="display: none;"> |
---|
380 | <b>Yes</b> is the only option supported by this wizard. The other alternatives |
---|
381 | may require manual deletion of already registered information. |
---|
382 | </span> |
---|
383 | <span id="morehelp.specimen" style="display: none;"> |
---|
384 | The <b>Personal information registration</b> wizard must be completed before a |
---|
385 | <b>Yes</b> can be registered. The other alternatives may require manual |
---|
386 | deletion of already registered information. |
---|
387 | </span> |
---|
388 | <span id="morehelp.no" style="display: none;"> |
---|
389 | The <b>Personal information registration</b> wizard must be completed for |
---|
390 | this case before a <b>Yes</b> can be registered. |
---|
391 | </span> |
---|
392 | </td> |
---|
393 | </tr> |
---|
394 | <tr valign="top"> |
---|
395 | <td class="subprompt">Reason if not asked</td> |
---|
396 | <td class="input"> |
---|
397 | <table border="0" cellpadding="0" cellspacing="0"> |
---|
398 | <tr valign="baseline"> |
---|
399 | <td><img src="../../images/joust/joinbottom.gif"></td> |
---|
400 | <td><input id="notAsked.forgot" type="checkbox" name="reasonIfNotAsked" disabled></td> |
---|
401 | <td><label id="notAsked.forgot.label" for="notAsked.forgot" class="disabled">Forgot to ask the patient</label></td> |
---|
402 | </tr> |
---|
403 | |
---|
404 | <tr valign="baseline"> |
---|
405 | <td></td> |
---|
406 | <td><input id="notAsked.language" type="checkbox" name="reasonIfNotAsked" disabled></td> |
---|
407 | <td><label id="notAsked.language.label" for="notAsked.language" class="disabled">Language problems</label></td> |
---|
408 | </tr> |
---|
409 | |
---|
410 | <tr valign="baseline"> |
---|
411 | <td></td> |
---|
412 | <td><input id="notAsked.condition" type="checkbox" name="reasonIfNotAsked" disabled></td> |
---|
413 | <td><label id="notAsked.condition.label" for="notAsked.condition" class="disabled">Patient can't decide due to physical and/or mental condition</label></td> |
---|
414 | </tr> |
---|
415 | |
---|
416 | <tr valign="baseline"> |
---|
417 | <td></td> |
---|
418 | <td><input id="notAsked.other" type="checkbox" name="reasonIfNotAsked" disabled></td> |
---|
419 | <td><label id="notAsked.other.label" for="notAsked.other" class="disabled">Other:</label></td> |
---|
420 | </tr> |
---|
421 | |
---|
422 | <tr valign="baseline"> |
---|
423 | <td></td> |
---|
424 | <td colspan="2"> |
---|
425 | <textarea name="otherReasonIfNotAsked" rows="3" cols="30" disabled |
---|
426 | onfocus="document.forms['reggie'].reasonIfNotAsked[3].checked = true"></textarea> |
---|
427 | </td> |
---|
428 | </tr> |
---|
429 | </table> |
---|
430 | |
---|
431 | </td> |
---|
432 | <td class="status" id="notAsked.status"></td> |
---|
433 | </tr> |
---|
434 | </table> |
---|
435 | </td> |
---|
436 | </tr> |
---|
437 | </table> |
---|
438 | </div> |
---|
439 | |
---|
440 | <div class="error" id="errorMessage" style="display: none; width: 800px; margin-left: 20px; margin-bottom: 0px;"></div> |
---|
441 | |
---|
442 | <div id="done" class="success" style="display: none; width: 800px; margin-left: 20px; margin-top: 20px;"></div> |
---|
443 | |
---|
444 | <table style="margin-left: 20px; margin-top: 10px;" class="navigation"> |
---|
445 | <tr> |
---|
446 | <td><base:button id="gocancel" title="Cancel" onclick="goRestart(false)" style="display: none;"/></td> |
---|
447 | <td><base:button id="gonext" title="Next" image="gonext.gif" onclick="goNext(true)"/></td> |
---|
448 | <td><base:button id="goregister" title="Register" image="gonext.gif" onclick="goRegister()" style="display: none;"/></td> |
---|
449 | <td><base:button id="gorestart" title="Restart" image="goback.gif" onclick="goRestart(true)" style="display: none;"/></td> |
---|
450 | <td id="gonext.message" class="message"></td> |
---|
451 | </tr> |
---|
452 | </table> |
---|
453 | </form> |
---|
454 | |
---|
455 | </base:body> |
---|
456 | </base:page> |
---|
457 | <% |
---|
458 | } |
---|
459 | finally |
---|
460 | { |
---|
461 | if (dc != null) dc.close(); |
---|
462 | } |
---|
463 | %> |
---|