Changeset 1513
- Timestamp:
- Jan 19, 2012, 1:56:41 PM (11 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/consentform.jsp
r1369 r1513 135 135 enableConsentOption('consent.yes', true); 136 136 setInputStatus('consent', 'This case already exists.', 'valid'); 137 Main.showInline('morehelp.yes ');137 Main.showInline('morehelp.yesonly'); 138 138 Main.show('gocancel'); 139 139 Main.show('goregister'); … … 142 142 { 143 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 case146 setInputStatus('consent', 'Specimen tubes for this case already exists.', ' invalid');147 Main.showInline('morehelp. specimen');148 Main.show('go restart');149 frm.consentDate.disabled = true;144 // This wizard will only allow 'Yes' option on the consent form 145 enableConsentOption('consent.yes', true); 146 setInputStatus('consent', 'Specimen tubes for this case already exists.', 'valid'); 147 Main.showInline('morehelp.yesonly'); 148 Main.show('gocancel'); 149 Main.show('goregister'); 150 150 } 151 151 else 152 152 { 153 // We have no information about this case 154 // The wizard will only allow 'No' and 'Not asked' option on the consent form 153 // We have no information about this case -- but allow a consent to be registered in any case 155 154 enableConsentOption('consent.no', true); 156 155 enableConsentOption('consent.notAsked'); 157 Main.showInline('morehelp.no'); 156 enableConsentOption('consent.yes'); 157 Main.showInline('morehelp.any'); 158 158 Main.show('gocancel'); 159 159 Main.show('goregister'); … … 377 377 <td class="help" rowspan="2"> 378 378 <span id="consent.message" class="message" style="display: none;"></span> 379 <span id="morehelp.yes " style="display: none;">379 <span id="morehelp.yesonly" style="display: none;"> 380 380 <b>Yes</b> is the only option supported by this wizard. The other alternatives 381 381 may require manual deletion of already registered information. 382 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. 383 <span id="morehelp.any" style="display: none;"> 384 There is currently no information about this case. 391 385 </span> 392 386 </td> -
extensions/net.sf.basedb.reggie/trunk/resources/persinfo.jsp
r1367 r1513 473 473 currentStep = 3; 474 474 475 var updateMode = caseInfo.id ;475 var updateMode = caseInfo.id && caseInfo.patient; 476 476 477 477 // Generate list of specimen tubes … … 614 614 if (!updateMode || cc.id == caseInfo.id) 615 615 { 616 cases += '<input type="radio" name="laterality" value="' + cc.id + '" ';616 cases += '<input type="radio" name="laterality" value="' + cc.id + '" id="laterality'+cc.id+'"'; 617 617 if (cc.laterality == thisCaseLaterality) cases += ' checked'; 618 cases += ' onclick="lateralityOnChange()"> ';618 cases += ' onclick="lateralityOnChange()"><label for="laterality' + cc.id + '">'; 619 619 if (cc.laterality) 620 620 { … … 629 629 cases += ' [merge with ' + cc.name + ']'; 630 630 } 631 cases += '< br>';631 cases += '</label><br>'; 632 632 } 633 633 } … … 637 637 if (!hasLeftCase) 638 638 { 639 cases += '<input type="radio" name="laterality" value="LEFT" ';639 cases += '<input type="radio" name="laterality" value="LEFT" id="lateralityLeft"'; 640 640 if (thisCaseLaterality == 'LEFT') cases += ' checked'; 641 cases += ' onclick="lateralityOnChange()"> LEFT';642 if (!updateMode) cases += ' [<i>new case</i>] ';641 cases += ' onclick="lateralityOnChange()"><label for="lateralityLeft">LEFT'; 642 if (!updateMode) cases += ' [<i>new case</i>]</label>'; 643 643 cases += '<br>'; 644 644 } 645 645 if (!hasRightCase) 646 646 { 647 cases += '<input type="radio" name="laterality" value="RIGHT" ';647 cases += '<input type="radio" name="laterality" value="RIGHT" id="lateralityRight"'; 648 648 if (thisCaseLaterality == 'RIGHT') cases += ' checked'; 649 cases += ' onclick="lateralityOnChange()"> RIGHT';650 if (!updateMode) cases += ' [<i>new case</i>] ';649 cases += ' onclick="lateralityOnChange()"><label for="lateralityRight">RIGHT'; 650 if (!updateMode) cases += ' [<i>new case</i>]</label>'; 651 651 cases += '<br>'; 652 652 } 653 653 if (!updateMode && !hasLeftCase && !hasRightCase) 654 654 { 655 cases += '<input type="radio" name="laterality" value="" ';655 cases += '<input type="radio" name="laterality" value="" id="lateralityUnknown"'; 656 656 if (thisCaseLaterality == null) cases += ' checked'; 657 cases += ' onclick="lateralityOnChange()">< i>unknown laterality</i> [<i>new case</i>]<br>';657 cases += ' onclick="lateralityOnChange()"><label for="lateralityUnknown"><i>unknown laterality</i> [<i>new case</i>]</label><br>'; 658 658 } 659 659 } … … 723 723 frm.rnaLaterTime.disabled = true; 724 724 725 var updateMode = caseInfo.id ;725 var updateMode = caseInfo.id && caseInfo.patient; 726 726 var submitInfo = new Object(); 727 727 submitInfo.patientInfo = patientInfo; … … 921 921 <td class="prompt" id="laterality.prompt">Laterality</td> 922 922 <td class="input" id="laterality.input"> 923 <input type="radio" name="laterality" value="LEFT" onclick="lateralityOnChange()">LEFT<br>924 <input type="radio" name="laterality" value="RIGHT" onclick="lateralityOnChange()">RIGHT<br>925 <input type="radio" name="laterality" value="" checked onclick="lateralityOnChange()"><i>unknown</i>923 <input type="radio" name="laterality" value="LEFT" id="lateralityLeft" onclick="lateralityOnChange()"><label for="lateralityLeft">LEFT</label><br> 924 <input type="radio" name="laterality" value="RIGHT" id="lateralityRight" onclick="lateralityOnChange()"><label for="lateralityRight">RIGHT</label><br> 925 <input type="radio" name="laterality" value="" checked id="lateralityUnknown" onclick="lateralityOnChange()"><i><label for="lateralityUnknown">unknown</label></i> 926 926 </td> 927 927 <td class="status" id="laterality.status"></td> -
extensions/net.sf.basedb.reggie/trunk/resources/specimentube.jsp
r1499 r1513 948 948 <td class="prompt" id="laterality.prompt">Laterality</td> 949 949 <td class="input" id="laterality.input"> 950 <input type="radio" name="laterality" value="LEFT" onclick="lateralityOnChange()">LEFT<br>951 <input type="radio" name="laterality" value="RIGHT" onclick="lateralityOnChange()">RIGHT<br>952 <input type="radio" name="laterality" value="" checked onclick="lateralityOnChange()"><i>unknown</i>950 <input type="radio" name="laterality" value="LEFT" id="lateralityLeft" onclick="lateralityOnChange()"><label for="lateralityLeft">LEFT</label><br> 951 <input type="radio" name="laterality" value="RIGHT" id="lateralityRight" onclick="lateralityOnChange()"><label for="lateralityRight">RIGHT</label><br> 952 <input type="radio" name="laterality" value="" id="lateralityUnknown" checked onclick="lateralityOnChange()"><i><label for="lateralityUnknown">unknown</label></i> 953 953 </td> 954 954 <td class="status" id="laterality.status"></td> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java
r1512 r1513 387 387 } 388 388 389 /** 390 Copy annotation values between two items. 391 392 @param from The item to copy from. If this item is not annotated with 393 the given annotation type, nothing is copied 394 @param to The item to copy to. If this item already has been annotated with 395 the given annotation type, the 'force' paremter decides if the annotation is 396 overwritten or not 397 @param at The annotation type to copy 398 @param force TRUE to overwrite existing annotations, FALSE to not 399 @return TRUE if this method copied annotations, FALSE if not 400 @since 2.2 401 */ 402 public static boolean copyAnnotationValues(Annotatable from, Annotatable to, AnnotationType at, boolean force) 403 { 404 List<?> annotations = getAnnotationValues(from, at); 405 if (annotations == null || annotations.size() == 0) return false; 406 407 if (!force) 408 { 409 // We need to check if the 'to' item already has the annotation 410 if (to.isAnnotated() && to.getAnnotationSet().hasAnnotation(at)) return false; 411 } 412 413 // Copy the values 414 to.getAnnotationSet().getAnnotation(at).setValues(annotations); 415 return true; 416 } 389 417 390 418 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java
r1504 r1513 20 20 import net.sf.basedb.core.BioSource; 21 21 import net.sf.basedb.core.DbControl; 22 import net.sf.basedb.core.InvalidDataException;23 22 import net.sf.basedb.core.Item; 24 23 import net.sf.basedb.core.Sample; … … 82 81 if (theCase != null) 83 82 { 83 // Check that the registration is not prohibited 84 84 theCase.verifyConsent(dc, null); 85 86 // Load the patient associated with the case87 Patient patient = Patient.findByCase(dc, theCase);88 if (patient == null)89 {90 throw new InvalidDataException("The case (" + caseName + ") was found but it is not associated " +91 "with any patient. This wizard can't be used until that is corrected.");92 }93 85 94 86 // Load specimen tubes for the case 95 87 specimenTubes = SpecimenTube.findByCase(dc, theCase, true); 88 if (specimenTubes.size() == 0) 89 { 90 // No specimen tubes are linked with the case -- see if we can find some unlinked 91 specimenTubes = SpecimenTube.findByCaseName(dc, caseName); 92 } 96 93 97 94 // Continue to load some more info (annotations, etc...) … … 100 97 theCase.loadAnnotations(dc, "pad", Reggie.ANNOTATION_PAD_CASE, null); 101 98 theCase.loadAnnotations(dc, "reasonIfNoSpecimen", Reggie.ANNOTATION_REASON_IF_NO_SPECIMEN, null); 102 103 // ... patient annotations 104 patient.loadDefaultAnnotations(dc); 105 99 106 100 // Wrap what we have so far up into JSON objects 107 101 jsonCase = theCase.asJSONObject(); 108 jsonCase.put("patient", patient.asJSONObject()); 102 103 // Load the patient associated with the case 104 Patient patient = Patient.findByCase(dc, theCase); 105 // The patient can be null if (for example) we have only registered consent=yes so far 106 if (patient != null) 107 { 108 patient.loadDefaultAnnotations(dc); 109 jsonCase.put("patient", patient.asJSONObject()); 110 } 109 111 } 110 112 else … … 245 247 246 248 dc = sc.newDbControl(); 247 Number patientId = (Number)jsonPat.get("id"); 248 BioSource patient = null; 249 250 if (patientId != null) 251 { 252 patient = BioSource.getById(dc, patientId.intValue()); 253 } 254 else 255 { 256 // Create new patient 257 patient = BioSource.getNew(dc); 258 patient.setItemSubtype(Subtype.PATIENT.load(dc)); 259 patient.setName((String)jsonPat.get("name")); 260 String pnr = (String)jsonPat.get("personalNumber"); 261 String dateOfBirth = (String)jsonPat.get("dateOfBirth"); 262 String gender = (String)jsonPat.get("gender"); 263 264 AnnotationType personalNumberType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_PERSONAL_NUMBER, true); 265 AnnotationType familyNameType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_FAMILY_NAME, true); 266 AnnotationType allFirstNamesType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_ALL_FIRST_NAMES, true); 267 AnnotationType genderType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_GENDER, true); 268 AnnotationType dateOfBirthType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_DATE_OF_BIRTH, true); 269 270 AnnotationSet as = patient.getAnnotationSet(); 271 as.getAnnotation(personalNumberType).setValue(pnr); 272 as.getAnnotation(familyNameType).setValue((String)jsonPat.get("familyName")); 273 as.getAnnotation(allFirstNamesType).setValue((String)jsonPat.get("allFirstNames")); 274 if (gender != null) as.getAnnotation(genderType).setValue(gender); 275 if (dateOfBirth != null) 276 { 277 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); 278 df.setLenient(false); 279 as.getAnnotation(dateOfBirthType).setValue(df.parse(dateOfBirth)); 280 } 281 if (gender == null || dateOfBirth == null) 282 { 283 patient.setDescription("This patient was recorded with a non-standard PersonalNumber. " + 284 "DateOfBirth and Gender annotations could not be automatically generated."); 285 } 286 dc.saveItem(patient); 287 288 jsonMessages.add("Patient '" + patient.getName() + "' created successfully."); 289 } 249 BioSource patient = getOrCreatePatient(dc, jsonPat, jsonMessages); 250 251 // If we already have a case with id it is probably due to an already registered consent=yes 252 Number preCaseId = (Number)jsonCase.get("id"); 290 253 291 254 // Get laterality … … 304 267 // Load the real laterality from the case 305 268 laterality = (String)Reggie.getAnnotationValue(theCase, lateralityType); 269 270 if (preCaseId != null) 271 { 272 // Remove the pre-registered case but copy consent information first 273 AnnotationType consentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT, true); 274 AnnotationType consentDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT_DATE, true); 275 276 Sample preCase = Sample.getById(dc, preCaseId.intValue()); 277 Reggie.copyAnnotationValues(preCase, theCase, consentType, false); 278 Reggie.copyAnnotationValues(preCase, theCase, consentDateType, false); 279 dc.deleteItem(preCase); 280 } 281 306 282 jsonMessages.add("Case '" + originalCaseName + "' merged with case '" + theCase.getName() + "' successfully."); 307 283 } 308 284 else 309 285 { 310 // Register a new case 311 theCase = Sample.getNew(dc); 286 if (preCaseId != null) 287 { 288 // Load existing case 289 theCase = Sample.getById(dc, preCaseId.intValue()); 290 } 291 else 292 { 293 // Register a new case 294 theCase = Sample.getNew(dc); 295 dc.saveItem(theCase); 296 } 312 297 theCase.setItemSubtype(Subtype.CASE.load(dc)); 313 298 theCase.setName(originalCaseName); … … 317 302 } 318 303 theCase.getCreationEvent().setSource(patient); 319 dc.saveItem(theCase);320 304 jsonMessages.add("Case '" + originalCaseName + "' created successfully."); 321 305 } … … 368 352 JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader()); 369 353 JSONObject jsonCase = (JSONObject)jsonReq.get("caseInfo"); 370 371 354 dc = sc.newDbControl(); 355 372 356 Number caseId = (Number)jsonCase.get("id"); 373 357 Sample theCase = Sample.getById(dc, caseId.intValue()); … … 461 445 } 462 446 447 @SuppressWarnings("unchecked") 448 private BioSource getOrCreatePatient(DbControl dc, JSONObject jsonPat, JSONArray jsonMessages) 449 throws Exception 450 { 451 Number patientId = (Number)jsonPat.get("id"); 452 BioSource patient = null; 453 454 if (patientId != null) 455 { 456 patient = BioSource.getById(dc, patientId.intValue()); 457 } 458 else 459 { 460 // Create new patient 461 patient = BioSource.getNew(dc); 462 patient.setItemSubtype(Subtype.PATIENT.load(dc)); 463 patient.setName((String)jsonPat.get("name")); 464 String pnr = (String)jsonPat.get("personalNumber"); 465 String dateOfBirth = (String)jsonPat.get("dateOfBirth"); 466 String gender = (String)jsonPat.get("gender"); 467 468 AnnotationType personalNumberType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_PERSONAL_NUMBER, true); 469 AnnotationType familyNameType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_FAMILY_NAME, true); 470 AnnotationType allFirstNamesType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_ALL_FIRST_NAMES, true); 471 AnnotationType genderType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_GENDER, true); 472 AnnotationType dateOfBirthType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_DATE_OF_BIRTH, true); 473 474 AnnotationSet as = patient.getAnnotationSet(); 475 as.getAnnotation(personalNumberType).setValue(pnr); 476 as.getAnnotation(familyNameType).setValue((String)jsonPat.get("familyName")); 477 as.getAnnotation(allFirstNamesType).setValue((String)jsonPat.get("allFirstNames")); 478 if (gender != null) as.getAnnotation(genderType).setValue(gender); 479 if (dateOfBirth != null) 480 { 481 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); 482 df.setLenient(false); 483 as.getAnnotation(dateOfBirthType).setValue(df.parse(dateOfBirth)); 484 } 485 if (gender == null || dateOfBirth == null) 486 { 487 patient.setDescription("This patient was recorded with a non-standard PersonalNumber. " + 488 "DateOfBirth and Gender annotations could not be automatically generated."); 489 } 490 dc.saveItem(patient); 491 492 jsonMessages.add("Patient '" + patient.getName() + "' created successfully."); 493 } 494 return patient; 495 496 } 463 497 464 498 -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SpecimenTubeServlet.java
r1463 r1513 69 69 70 70 String caseName = req.getParameter("caseName"); 71 Case theCase = Case.findByName(dc, caseName); 71 Case theCase = Case.findByName(dc, caseName); 72 72 73 if (theCase != null) 73 74 { 74 throw new InvalidDataException("The case (" + caseName + ") already exists in BASE. " +75 "This wizard cannot be used to update tubes that already been connected to a case.");75 // Verify that consent has been given 76 theCase.verifyConsent(dc, null); 76 77 } 77 78 … … 79 80 if (specimenTubes.size() > 0) 80 81 { 81 throw new InvalidDataException("There are already specimen tubes in this case."); 82 } 83 84 JSONObject jsonCase = null; 85 if (theCase == null) 86 { 87 jsonCase = new JSONObject(); 88 jsonCase.put("name", caseName); 89 } 82 throw new InvalidDataException(specimenTubes.size() + 83 " specimen tubes have already been registered for this case. This wizard can't be used for updating."); 84 } 85 86 JSONObject jsonCase = new JSONObject(); 87 jsonCase.put("name", caseName); 90 88 json.put("caseInfo", jsonCase); 91 89 }
Note: See TracChangeset
for help on using the changeset viewer.