Changeset 1290
- Timestamp:
- Feb 21, 2011, 2:29:46 PM (13 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/persinfo.jsp
r1289 r1290 51 51 if (caseName == '') 52 52 { 53 setInputStatus('case', 'Missing', false);53 setInputStatus('case', 'Missing', 'invalid'); 54 54 return; 55 55 } 56 setInputStatus('case', '', true);56 setInputStatus('case', '', 'valid'); 57 57 caseIsValid = true; 58 58 } … … 66 66 if (pnr.length < 12) 67 67 { 68 setInputStatus('pnr', 'Too short', false);68 setInputStatus('pnr', 'Too short', 'invalid'); 69 69 return; 70 70 } … … 72 72 if (!Dates.isDate(pnr.substring(0, 8), 'yyyyMMdd')) 73 73 { 74 setInputStatus('pnr', 'Not a valid date', false);74 setInputStatus('pnr', 'Not a valid date', 'invalid'); 75 75 return; 76 76 } … … 91 91 if (control != parseInt(pnr.substr(11, 1))) 92 92 { 93 setInputStatus('pnr', 'Invalid control digit', false);93 setInputStatus('pnr', 'Invalid control digit', 'invalid'); 94 94 return; 95 95 } 96 96 97 setInputStatus('pnr', '', true);97 setInputStatus('pnr', '', 'valid'); 98 98 pnrIsValid = true; 99 99 100 if (caseIsValid) gotoStep2(); 101 } 102 103 function allFirstNamesOnKeyPress(event) 100 //if (caseIsValid) gotoStep2(); 101 } 102 103 function lateralityOnChange() 104 { 105 // Check selected laterality against specimen tubes 106 var frm = document.forms['reggie']; 107 var selectedLaterality = Forms.getCheckedRadio(frm.laterality); 108 109 // No laterality/case selected 110 if (selectedLaterality == null) return; 111 112 var laterality = selectedLaterality.value; 113 if (laterality != 'LEFT' && laterality != 'RIGHT') 114 { 115 // It is the ID of an existing case 116 for (var i = 0; i < patientInfo.cases.length; i++) 117 { 118 var cse = patientInfo.cases[i]; 119 if (cse.id == laterality) 120 { 121 laterality = cse.laterality; 122 break; 123 } 124 } 125 } 126 127 if (!laterality) return; 128 129 // No specimen tubes 130 if (!caseInfo.specimen || caseInfo.specimen.length == 0) return; 131 132 for (var i = 0; i < caseInfo.specimen.length; i++) 133 { 134 var specimen = caseInfo.specimen[i]; 135 if (specimen.laterality && specimen.laterality != laterality) 136 { 137 setInputStatus('laterality', 'Not same laterality as specimen tubes', 'warning'); 138 return; 139 } 140 } 141 setInputStatus('laterality', '', 'valid'); 142 } 143 144 function goNextOnTab(event) 104 145 { 105 146 if (event.keyCode == 9) setTimeout('goNext()', 200); … … 153 194 setInnerHTML('existing.dateOfBirth', patientInfo.dateOfBirth); 154 195 setInnerHTML('existing.gender', patientInfo.gender); 155 196 gotoStep3(); 156 197 } 157 198 } … … 161 202 // Check entered case and pnr with AJAX 162 203 var frm = document.forms['reggie']; 163 if (frm.patientCode) 204 205 if (!patientInfo.id) 164 206 { 165 207 var formOk = true; … … 167 209 if (frm.allFirstNames.value == '') 168 210 { 169 setInputStatus('allFirstNames', 'Missing', false);211 setInputStatus('allFirstNames', 'Missing', 'invalid'); 170 212 frm.allFirstNames.focus(); 171 213 formOk = false; … … 173 215 else 174 216 { 175 setInputStatus('allFirstNames', '', true);217 setInputStatus('allFirstNames', '', 'valid'); 176 218 } 177 219 178 220 if (frm.familyName.value == '') 179 221 { 180 setInputStatus('familyName', 'Missing', false);222 setInputStatus('familyName', 'Missing', 'invalid'); 181 223 frm.familyName.focus(); 182 224 formOk = false; … … 184 226 else 185 227 { 186 setInputStatus('familyName', '', true);228 setInputStatus('familyName', '', 'valid'); 187 229 } 188 230 … … 190 232 if (frm.patientCode.value == '') 191 233 { 192 setInputStatus('patientCode', 'Missing', false);234 setInputStatus('patientCode', 'Missing', 'invalid'); 193 235 frm.patientCode.focus(); 194 236 formOk = false; … … 196 238 else 197 239 { 198 setInputStatus('patientCode', '', true);240 setInputStatus('patientCode', '', 'valid'); 199 241 } 200 242 if (!formOk) return; … … 211 253 } 212 254 213 if (!patientInfo.cases || patientInfo.cases.length == 0) 214 { 215 Main.show('newCaseSection'); 216 } 217 255 // Generate list of specimen tubes 256 var thisCaseLaterality; 218 257 if (caseInfo.specimen && caseInfo.specimen.length > 0) 219 258 { … … 228 267 specimenTubes += ' ('+specimen.laterality + ')'; 229 268 Forms.checkRadio(frm.laterality, specimen.laterality); 269 270 if (thisCaseLaterality && thisCaseLaterality != specimen.laterality) 271 { 272 setInputStatus('specimenTubes', 'Specimen tubes with different laterality', 'warning'); 273 } 274 thisCaseLaterality = specimen.laterality; 230 275 } 231 276 specimenTubes += '<br>'; … … 233 278 setInnerHTML('specimenTubes', specimenTubes); 234 279 } 235 280 281 282 Main.show('caseSection'); 283 284 // Existing cases for this patient 285 var hasLeftCase = false; 286 var hasRightCase = false; 287 if (patientInfo.cases && patientInfo.cases.length > 0) 288 { 289 var cases = ''; 290 for (var i = 0; i < patientInfo.cases.length; i++) 291 { 292 var cc = patientInfo.cases[i]; 293 cases += '<input type="radio" name="laterality" value="' + cc.id + '"'; 294 if (cc.laterality == 'LEFT') 295 { 296 if (hasLeftCase) setInputStatus('laterality', 'Two cases with LEFT', 'warning'); 297 hasLeftCase = true; 298 } 299 if (cc.laterality == 'RIGHT') 300 { 301 if (hasRightCase) setInputStatus('laterality', 'Two cases with RIGHT', 'warning'); 302 hasRightCase = true; 303 } 304 if (cc.laterality == thisCaseLaterality) cases += ' checked'; 305 cases += ' onclick="lateralityOnChange()">'; 306 cases += cc.name + ' (' + cc.laterality + ')<br>'; 307 } 308 309 if (!hasLeftCase) 310 { 311 cases += '<input type="radio" name="laterality" value="LEFT" '; 312 if (thisCaseLaterality == 'LEFT') cases += ' checked'; 313 cases += ' onclick="lateralityOnChange()"><i>new case</i> (LEFT)<br>'; 314 } 315 if (!hasRightCase) 316 { 317 cases += '<input type="radio" name="laterality" value="RIGHT"'; 318 if (thisCaseLaterality == 'RIGHT') cases += ' checked'; 319 cases += ' onclick="lateralityOnChange()"><i>new case</i> (RIGHT)<br>'; 320 } 321 322 if (hasLeftCase && hasRightCase) 323 { 324 setInnerHTML('laterality.prompt', 'Merge with case'); 325 } 326 else 327 { 328 setInnerHTML('laterality.prompt', 'Merge/create new case'); 329 } 330 331 setInnerHTML('laterality.input', cases); 332 } 333 lateralityOnChange(); 334 236 335 Main.hide('gonext'); 237 336 Main.show('gocreate'); … … 240 339 function goCreate() 241 340 { 341 Main.hide('gocreate'); 242 342 var frm = document.forms['reggie']; 243 343 … … 248 348 submitInfo.patientInfo = patientInfo; 249 349 submitInfo.caseInfo = caseInfo; 250 //alert(JSON.stringify(submitInfo));251 350 252 351 var request = Ajax.getXmlHttpRequest(); … … 257 356 258 357 setInnerHTML('debug', request.responseText); 358 359 var response = JSON.parse(request.responseText); 360 if (response.status != 'ok') 361 { 362 setFatalError(response.message); 363 return false; 364 } 365 366 var msg = '<ul>'; 367 for (var i = 0; i < response.messages.length; i++) 368 { 369 msg += '<li>' + response.messages[i]; 370 } 371 msg += '</ul>'; 372 setInnerHTML('done', msg); 373 Main.show('done'); 374 Main.show('gorestart'); 375 259 376 } 260 377 … … 267 384 } 268 385 269 function setInputStatus(prefix, message, isValid)386 function setInputStatus(prefix, message, clazz) 270 387 { 271 388 var tag = document.getElementById(prefix + '.status'); 272 Main.addClass(tag, isValid ? 'isvalid' : 'invalid'); 273 Main.removeClass(tag, isValid ? 'invalid' : 'isvalid'); 389 tag.className = 'status ' + clazz; 274 390 275 391 setInnerHTML(prefix + '.message', message); … … 381 497 content: url('../../images/error.gif'); 382 498 } 383 .status.isvalid:before 499 .status.warning:before 500 { 501 content: url('../../images/warning.gif'); 502 } 503 .status.valid:before 384 504 { 385 505 content: url('../../images/ok.gif'); 386 506 } 387 507 .success ul 508 { 509 list-style-image: url('../../images/ok.gif'); 510 } 388 511 </style> 389 512 </base:head> … … 407 530 <table border="0" cellspacing="0" cellpadding="0" width="100%"> 408 531 <tr valign="top"> 409 <td class="prompt">Case Name</td>532 <td class="prompt">Case name</td> 410 533 <td class="input"><input type="text" name="caseName" 411 534 size="18" maxlength="12" onblur="caseNameOnChange()"></td> … … 414 537 </tr> 415 538 <tr> 416 <td class="prompt">Personal Number</td>539 <td class="prompt">Personal number</td> 417 540 <td class="input"><input type="text" name="personalNumber" 418 size="18" maxlength="12" onkeyup="personalNumberOnChange()" ></td>541 size="18" maxlength="12" onkeyup="personalNumberOnChange()" onkeypress="goNextOnTab(event)"></td> 419 542 <td class="status" id="pnr.status"></td> 420 543 <td class="help"><span id="pnr.message" class="message" style="display: none;"></span>(YYYYMMDDZZZZ)</td> … … 452 575 <td class="prompt">All first names</td> 453 576 <td class="input"><input type="text" name="allFirstNames" 454 size="35" maxlength="255" onkeypress=" allFirstNamesOnKeyPress(event)"></td>577 size="35" maxlength="255" onkeypress="goNextOnTab(event)"></td> 455 578 <td class="status" id="allFirstNames.status"></td> 456 579 <td class="help"><span id="allFirstNames.message" class="message" style="display: none;"></span>Type all names, see FamilyName comment on valid characters.</td> … … 522 645 523 646 524 <!-- 3. New case registration -->525 <div id=" newCaseSection" style="display: none;">647 <!-- 3. Case registration --> 648 <div id="caseSection" style="display: none;"> 526 649 <p> 527 650 <table border="0" cellspacing="0" cellpadding="0" class="stepform"> 528 651 <tr> 529 652 <td rowspan="2" class="stepno">3</td> 530 <td class="steptitle"> New case: Enter information</td>653 <td class="steptitle">About this case</td> 531 654 </tr> 532 655 <tr> 533 656 <td class="stepfields"> 534 657 <table border="0" cellspacing="0" cellpadding="0" width="100%"> 535 <tr >536 <td class="prompt" >Laterality</td>537 <td class="input" >538 <input type="radio" name="laterality" value="LEFT" >LEFT539 <input type="radio" name="laterality" value="RIGHT" >RIGHT658 <tr valign="top"> 659 <td class="prompt" id="laterality.prompt">Laterality</td> 660 <td class="input" id="laterality.input"> 661 <input type="radio" name="laterality" value="LEFT" onclick="lateralityOnChange()">LEFT 662 <input type="radio" name="laterality" value="RIGHT" onclick="lateralityOnChange()">RIGHT 540 663 </td> 541 <td class="status" ></td>542 <td class="help">< /td>664 <td class="status" id="laterality.status"></td> 665 <td class="help"><span id="laterality.message" class="message" style="display: none;"></span></td> 543 666 </tr> 544 667 <tr valign="top"> 545 668 <td class="prompt">Specimen tubes</td> 546 <td class="input" id="specimenTubes">not found</td> 547 <td class="status"></td> 548 <td class="help">The specimen tube(s) associated with this case.</td> 549 </tr> 550 669 <td class="input" id="specimenTubes"><i>not found</i></td> 670 <td class="status" id="specimenTubes.status"></td> 671 <td class="help"><span id="specimenTubes.message" class="message" style="display: none;"></span>The specimen tube(s) associated with this case.</td> 672 </tr> 551 673 <tr id="reasonIfNoSpecimenSection" valign="top"> 552 674 <td class="prompt">Reason if no specimen</td> … … 562 684 563 685 <div class="error" id="errorMessage" style="display: none; width: 800px; margin-left: 20px; margin-bottom: 0px;"></div> 686 687 <div id="done" class="success" style="display: none; width: 800px; margin-left: 20px; margin-top: 20px;"></div> 564 688 565 689 <table style="margin-left: 20px; margin-top: 10px;"> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java
r1289 r1290 35 35 import net.sf.basedb.reggie.Reggie; 36 36 import net.sf.basedb.util.MD5; 37 import net.sf.basedb.util.Values; 37 38 import net.sf.basedb.util.error.ThrowableUtil; 38 39 import net.sf.basedb.util.formatter.DateFormatter; … … 204 205 JSONObject json = new JSONObject(); 205 206 json.put("status", "ok"); 207 208 JSONArray jsonMessages = new JSONArray(); 206 209 207 210 final SessionControl sc = Application.getSessionControl(ID, req.getRemoteAddr()); … … 245 248 as.getAnnotation(dateOfBirthType).setValue(df.parseString(pnr.substring(0, 8))); 246 249 dc.saveItem(patient); 247 } 248 249 // Create new case 250 Sample cse = Sample.getNew(dc); 251 cse.setName((String)jsonCase.get("name")); 252 AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 253 AnnotationSet as = cse.getAnnotationSet(); 254 as.getAnnotation(lateralityType).setValue((String)jsonCase.get("laterality")); 255 cse.setBioSource(patient); 256 dc.saveItem(cse); 250 251 jsonMessages.add("Patient '" + patient.getName() + "' created successfully."); 252 } 253 254 String laterality = (String)jsonCase.get("laterality"); 255 256 String originalCaseName = (String)jsonCase.get("name"); 257 Sample theCase = null; 258 if ("LEFT".equals(laterality) || "RIGHT".equals(laterality)) 259 { 260 // Register a new case 261 theCase = Sample.getNew(dc); 262 theCase.setName(originalCaseName); 263 AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 264 AnnotationSet as = theCase.getAnnotationSet(); 265 as.getAnnotation(lateralityType).setValue((String)jsonCase.get("laterality")); 266 theCase.setBioSource(patient); 267 dc.saveItem(theCase); 268 jsonMessages.add("Case '" + originalCaseName + "' created successfully."); 269 } 270 else 271 { 272 // Merge with existing case 273 theCase = Sample.getById(dc, Values.getInt(laterality)); 274 jsonMessages.add("Case '" + originalCaseName + "' merged with case '" + theCase.getName() + "' successfully."); 275 } 257 276 258 277 // Link the case with specimen 278 AnnotationSet caseAnnotations = theCase.getAnnotationSet(); 259 279 JSONArray jsonSpecimen = (JSONArray)jsonCase.get("specimen"); 260 280 if (jsonSpecimen != null && jsonSpecimen.size() > 0) … … 262 282 AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true); 263 283 AnnotationType padCaseType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD_CASE, true); 264 List padCase = new ArrayList( as.getAnnotation(padCaseType).getValues());284 List padCase = new ArrayList(caseAnnotations.getAnnotation(padCaseType).getValues()); 265 285 for (int i = 0; i < jsonSpecimen.size(); ++i) 266 286 { 267 287 JSONObject jsonSpec = (JSONObject)jsonSpecimen.get(i); 268 288 Sample specimen = Sample.getById(dc, ((Long)jsonSpec.get("id")).intValue()); 289 // Set specimen to 'pooled' and link with case 269 290 specimen.setPooled(true); 270 specimen.getCreationEvent().addSource(cse, null); 291 specimen.getCreationEvent().addSource(theCase, null); 292 // Copy PAD annotation on specimen to PADcase annotation on case 271 293 String pad = (String)Reggie.getAnnotationValue(specimen, padType); 272 294 if (pad != null && !padCase.contains(pad)) padCase.add(pad); 273 295 } 274 as.getAnnotation(padCaseType).setValues(padCase); 296 if (padCase.size() > 0) caseAnnotations.getAnnotation(padCaseType).setValues(padCase); 297 jsonMessages.add(jsonSpecimen.size() + " specimen tubes linked with case '" + theCase.getName() + "' successfully."); 275 298 } 276 299 else 277 300 { 278 301 AnnotationType reasonIfNoSpecimenType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_REASON_IF_NO_SPECIMEN, true); 279 Annotation reasonIfNoSpecimen = as.getAnnotation(reasonIfNoSpecimenType);302 Annotation reasonIfNoSpecimen = caseAnnotations.getAnnotation(reasonIfNoSpecimenType); 280 303 List values = new ArrayList(reasonIfNoSpecimen.getValues()); 281 values.add("[" + cse.getName()+ "] " + jsonCase.get("reasonIfNoSpecimen"));304 values.add("[" + originalCaseName + "] " + jsonCase.get("reasonIfNoSpecimen")); 282 305 reasonIfNoSpecimen.setValues(values); 283 306 } 284 307 285 308 dc.commit(); 309 json.put("messages", jsonMessages); 286 310 287 311 }
Note: See TracChangeset
for help on using the changeset viewer.