Changeset 1326
- Timestamp:
- Mar 29, 2011, 2:55:33 PM (13 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/persinfo.jsp
r1319 r1326 139 139 setInputStatus('case', '', 'valid'); 140 140 caseIsValid = true; 141 142 getCaseInfo(); 141 143 } 142 144 … … 208 210 { 209 211 lateralityIsValid = false; 212 var updateMode = caseInfo.id; 210 213 211 214 // Check selected laterality against specimen tubes … … 219 222 return; 220 223 } 221 setInputStatus('laterality', '', 'valid'); 224 225 var numCases = patientInfo.cases ? patientInfo.cases.length : 0; 226 setInputStatus('laterality', updateMode && numCases > 1 ? 'NOTE! Some alternatives may be missing if there is another case for the patient.' : '', 'valid'); 222 227 lateralityIsValid = true; 223 228 … … 249 254 if (specimen.laterality != laterality) 250 255 { 251 if (specimen.laterality == null )256 if (specimen.laterality == null || updateMode) 252 257 { 253 258 setInputStatus('laterality', 'Specimen tubes are updated to: ' + laterality, 'valid') … … 260 265 } 261 266 } 267 262 268 } 263 269 … … 292 298 if (event.keyCode == 13) setTimeout("document.forms['reggie']."+inputField+".focus()", 200); 293 299 return true; 300 } 301 302 function getCaseInfo() 303 { 304 // Check entered case and pnr with AJAX 305 var frm = document.forms['reggie']; 306 var caseName = frm.caseName.value; 307 var request = Ajax.getXmlHttpRequest(); 308 var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd=GetCaseInfo'; 309 url += '&caseName=' + caseName; 310 request.open("GET", url, false); 311 request.send(null); 312 313 setInnerHTML('debug', request.responseText); 314 var response = JSON.parse(request.responseText); 315 if (response.status != 'ok') 316 { 317 setFatalError(response.message); 318 return false; 319 } 320 321 // Get biosource information from the AJAX response 322 caseInfo = response.caseInfo; 323 324 if (caseInfo && caseInfo.patient) 325 { 326 frm.personalNumber.value = caseInfo.patient.personalNumber; 327 gotoStep2(); 328 } 329 294 330 } 295 331 … … 303 339 304 340 var pnr = frm.personalNumber.value; 305 var caseName = frm.caseName.value;306 341 var request = Ajax.getXmlHttpRequest(); 307 var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd= CheckPersonalNumberAndCaseName';342 var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd=GetPatientInfo'; 308 343 url += '&personalNumber=' + pnr; 309 344 url += '&pnrIsValid=' + pnrIsValid; 310 url += '&caseName=' + caseName;311 345 request.open("GET", url, false); 312 346 request.send(null); 313 347 314 //setInnerHTML('debug', request.responseText);348 setInnerHTML('debug', request.responseText); 315 349 316 350 var response = JSON.parse(request.responseText); … … 321 355 } 322 356 357 // Get patient information from the AJAX response 358 patientInfo = response.patientInfo; 359 323 360 Main.show('gocancel'); 324 325 // Get biosource information from the AJAX response326 patientInfo = response.patientInfo;327 caseInfo = response.caseInfo;328 361 329 362 if (!patientInfo.id) … … 366 399 currentStep = 3; 367 400 401 var updateMode = caseInfo.id; 402 368 403 // Generate list of specimen tubes 369 404 var hasLeftSpecimen = false; 370 405 var hasRightSpecimen = false; 371 406 var hasUnknownSpecimen = false; 372 var thisCaseLaterality = null; 407 var thisCaseLaterality = caseInfo.laterality; 408 var thisCasePAD = null; 373 409 var hasPAD = false; 374 410 if (caseInfo.specimen && caseInfo.specimen.length > 0) … … 380 416 var specimen = caseInfo.specimen[i]; 381 417 specimenTubes += specimen.name; 382 if (specimen.pad) hasPAD = true; 418 if (specimen.pad) 419 { 420 hasPAD = true; 421 thisCasePAD = specimen.pad; 422 } 383 423 if (specimen.laterality) 384 424 { … … 410 450 } 411 451 412 Main.showHide('padSection', !hasPAD); 452 frm.pad.value = thisCasePAD; 453 Main.showHide('padSection', !hasPAD || updateMode); 413 454 414 455 Main.show('caseSection'); … … 424 465 { 425 466 var cc = patientInfo.cases[i]; 426 cases += '<input type="radio" name="laterality" value="' + cc.id + '"';427 467 if (cc.laterality == 'LEFT') 428 468 { 429 if (hasLeftCase ) setInputStatus('laterality', 'Two cases with laterality=LEFT', 'warning');469 if (hasLeftCase && !updateMode) setInputStatus('laterality', 'Two cases with laterality=LEFT', 'warning'); 430 470 hasLeftCase = true; 431 471 } 432 472 else if (cc.laterality == 'RIGHT') 433 473 { 434 if (hasRightCase ) setInputStatus('laterality', 'Two cases with laterality=RIGHT', 'warning');474 if (hasRightCase && !updateMode) setInputStatus('laterality', 'Two cases with laterality=RIGHT', 'warning'); 435 475 hasRightCase = true; 436 476 } … … 439 479 hasUnknownCase = true; 440 480 } 441 if (cc.laterality == thisCaseLaterality) cases += ' checked'; 442 cases += ' onclick="lateralityOnChange()">' + cc.name; 443 if (cc.laterality) 444 { 445 cases += ' (' + cc.laterality + ')<br>'; 446 } 447 else 448 { 449 cases += ' (<i>unknown laterality</i>)<br>'; 481 if (!updateMode || cc.id == caseInfo.id) 482 { 483 cases += '<input type="radio" name="laterality" value="' + cc.id + '"'; 484 if (cc.laterality == thisCaseLaterality) cases += ' checked'; 485 cases += ' onclick="lateralityOnChange()">'; 486 if (cc.laterality) 487 { 488 cases += cc.laterality; 489 } 490 else 491 { 492 cases += '<i>unknown laterality</i>'; 493 } 494 if (!updateMode) 495 { 496 cases += ' [merge with ' + cc.name + ']'; 497 } 498 cases += '<br>'; 450 499 } 451 500 } 452 501 453 if (patientInfo.cases.length == 1 )502 if (patientInfo.cases.length == 1 || updateMode) 454 503 { 455 504 if (!hasLeftCase) … … 457 506 cases += '<input type="radio" name="laterality" value="LEFT" '; 458 507 if (thisCaseLaterality == 'LEFT') cases += ' checked'; 459 cases += ' onclick="lateralityOnChange()"><i>new case</i> (LEFT)<br>'; 508 cases += ' onclick="lateralityOnChange()">LEFT'; 509 if (!updateMode) cases += ' [<i>new case</i>]'; 510 cases += '<br>'; 460 511 } 461 512 if (!hasRightCase) … … 463 514 cases += '<input type="radio" name="laterality" value="RIGHT"'; 464 515 if (thisCaseLaterality == 'RIGHT') cases += ' checked'; 465 cases += ' onclick="lateralityOnChange()"><i>new case</i> (RIGHT)<br>'; 466 } 467 cases += '<input type="radio" name="laterality" value=""'; 468 if (thisCaseLaterality == null) cases += ' checked'; 469 cases += ' onclick="lateralityOnChange()"><i>new case</i> (<i>unknown laterality</i>)<br>'; 516 cases += ' onclick="lateralityOnChange()">RIGHT'; 517 if (!updateMode) cases += ' [<i>new case</i>]'; 518 cases += '<br>'; 519 } 520 if (!updateMode && !hasLeftCase && !hasRightCase) 521 { 522 cases += '<input type="radio" name="laterality" value=""'; 523 if (thisCaseLaterality == null) cases += ' checked'; 524 cases += ' onclick="lateralityOnChange()"><i>unknown laterality</i> [<i>new case</i>]<br>'; 525 } 470 526 } 471 527 472 if (patientInfo.cases.length == 2) 473 { 474 setInnerHTML('laterality.prompt', 'Merge with case'); 475 } 476 else 477 { 478 setInnerHTML('laterality.prompt', 'Merge/create new case'); 528 if (updateMode) 529 { 530 if (caseInfo.merged) 531 { 532 setInnerHTML('step3.title', 'Update case \''+caseInfo.originalName+'\' (which is merged with case \'' + caseInfo.name + '\')'); 533 } 534 else 535 { 536 setInnerHTML('step3.title', 'Update case \''+caseInfo.name+'\''); 537 } 538 539 } 540 else if (patientInfo.cases.length == 2) 541 { 542 setInnerHTML('step3.title', 'Merge with existing case'); 543 } 544 else if (patientInfo.cases.length > 0) 545 { 546 setInnerHTML('step3.title', 'Create new case or merge with existing case'); 479 547 } 480 548 … … 484 552 485 553 Main.hide('gonext'); 486 Main.show('gocreate'); 554 if (updateMode) 555 { 556 Main.show('goupdate'); 557 } 558 else 559 { 560 Main.show('gocreate'); 561 } 487 562 488 563 if (!hasPAD && lateralityIsValid) frm.pad.focus(); … … 495 570 Main.hide('gocreate'); 496 571 Main.hide('gocancel'); 572 Main.hide('goupdate'); 497 573 var frm = document.forms['reggie']; 498 574 … … 508 584 frm.pad.disabled = true; 509 585 586 var updateMode = caseInfo.id; 510 587 var submitInfo = new Object(); 511 588 submitInfo.patientInfo = patientInfo; … … 515 592 516 593 var request = Ajax.getXmlHttpRequest(); 517 var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd=Create'; 594 var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd='; 595 url += updateMode ? 'UpdateCase' : 'CreateCase'; 518 596 request.open("POST", url, false); 519 597 request.setRequestHeader("Content-Type", "application/json"); 520 598 request.send(JSON.stringify(submitInfo)); 521 599 522 //setInnerHTML('debug', request.responseText);600 setInnerHTML('debug', request.responseText); 523 601 524 602 var response = JSON.parse(request.responseText); … … 572 650 Main.hide('gocancel'); 573 651 Main.show('gorestart'); 652 var frm = document.forms['reggie']; 653 for (var i = 0; i < frm.elements.length; i++) 654 { 655 frm.elements[i].disabled = true; 656 } 657 574 658 } 575 659 … … 831 915 <tr> 832 916 <td rowspan="2" class="stepno">3</td> 833 <td class="steptitle" >About thiscase</td>917 <td class="steptitle" id="step3.title">Create new case</td> 834 918 </tr> 835 919 <tr> … … 859 943 onblur="padOnChange()"></td> 860 944 <td class="status" id="pad.status"></td> 861 <td class="help"><span id="pad.message" class="message" style="display: none;"></span>PAD should be entered when no specimen tubes have been registered </td>945 <td class="help"><span id="pad.message" class="message" style="display: none;"></span>PAD should be entered when no specimen tubes have been registered.</td> 862 946 </tr> 863 947 <tr id="reasonIfNoSpecimenSection" valign="top"> … … 882 966 <td><base:button id="gonext" title="Next" image="gonext.gif" onclick="goNext(true)"/></td> 883 967 <td><base:button id="gocreate" title="Create" image="gonext.gif" onclick="goCreate()" style="display: none;"/></td> 968 <td><base:button id="goupdate" title="Update" image="gonext.gif" onclick="goCreate()" style="display: none;"/></td> 884 969 <td><base:button id="gorestart" title="Restart" image="goback.gif" onclick="goRestart(true)" style="display: none;"/></td> 885 970 <td id="gonext.message" class="message"></td> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java
r1325 r1326 1 1 package net.sf.basedb.reggie; 2 2 3 import java.util.Collections; 3 4 import java.util.List; 4 5 … … 198 199 } 199 200 200 201 /** 202 Get an array annotation value from an item. Returns an empty list if 203 there are no annotations of the given type. 204 @since 1.2 205 */ 206 public static List<?> getAnnotationValues(Annotatable item, AnnotationType at) 207 { 208 if (!item.isAnnotated()) return Collections.emptyList(); 209 AnnotationSet as = item.getAnnotationSet(); 210 if (!as.hasAnnotation(at)) return Collections.emptyList(); 211 return as.getAnnotation(at).getValues(); 212 } 213 214 215 201 216 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java
r1319 r1326 4 4 import java.text.SimpleDateFormat; 5 5 import java.util.ArrayList; 6 import java.util.Date;7 6 import java.util.List; 8 7 … … 28 27 import net.sf.basedb.core.Sample; 29 28 import net.sf.basedb.core.SessionControl; 30 import net.sf.basedb.core.Type;31 import net.sf.basedb.core.query.Annotations;32 29 import net.sf.basedb.core.query.Expressions; 33 30 import net.sf.basedb.core.query.Hql; … … 35 32 import net.sf.basedb.core.query.Restrictions; 36 33 import net.sf.basedb.reggie.Reggie; 34 import net.sf.basedb.reggie.dao.Case; 35 import net.sf.basedb.reggie.dao.Patient; 36 import net.sf.basedb.reggie.dao.SpecimenTube; 37 37 import net.sf.basedb.util.MD5; 38 38 import net.sf.basedb.util.Values; … … 67 67 try 68 68 { 69 if (" CheckPersonalNumberAndCaseName".equals(cmd))69 if ("GetCaseInfo".equals(cmd)) 70 70 { 71 /* 72 Load information about a single case when given the case name/barcode 73 If a case is found we will load annotations, the patient it is associated with 74 and specimen tubes for the case. If no case is found we check to see 75 if there are any specimen tubes that have the case name as prefix and 76 load information about them. 77 */ 71 78 dc = sc.newDbControl(); 72 AnnotationType pnrType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_PERSONAL_NUMBER, true); 73 AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 74 AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true); 75 79 80 // Find a case by name 81 String caseName = req.getParameter("caseName"); 82 Case theCase = Case.findByName(dc, caseName); 83 List<SpecimenTube> specimenTubes = null; 84 JSONObject jsonCase = null; 85 86 if (theCase != null) 87 { 88 // Load the patient associated with the case 89 Patient patient = Patient.findByCase(dc, theCase); 90 if (patient == null) 91 { 92 throw new InvalidDataException("The case (" + caseName + ") was found but it is not associated " + 93 "with any patient. This wizard can't be used until that is corrected."); 94 } 95 96 // Load specimen tubes for the case 97 specimenTubes = SpecimenTube.findByCase(dc, theCase, true); 98 99 // Continue to load some more info (annotations, etc...) 100 // ... case annotations 101 theCase.loadAnnotations(dc, "laterality", Reggie.ANNOTATION_LATERALITY); 102 theCase.loadAnnotations(dc, "pad", Reggie.ANNOTATION_PAD_CASE); 103 theCase.loadAnnotations(dc, "reasonIfNoSpecimen", Reggie.ANNOTATION_REASON_IF_NO_SPECIMEN); 104 105 // ... patient annotations 106 patient.loadDefaultAnnotations(dc); 107 108 // Wrap what we have so far up into JSON objects 109 jsonCase = theCase.asJSONObject(); 110 jsonCase.put("patient", patient.asJSONObject()); 111 } 112 else 113 { 114 // Could not find the registered case -- see if we can find any specimen tubes 115 specimenTubes = SpecimenTube.findByCaseName(dc, caseName); 116 jsonCase = new JSONObject(); 117 jsonCase.put("name", caseName); 118 } 119 120 // Load specimen tube annotations 121 JSONArray jsonTubes = new JSONArray(); 122 if (specimenTubes.size() > 0) 123 { 124 AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true); 125 AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 126 for (SpecimenTube tube : specimenTubes) 127 { 128 tube.loadAnnotations("pad", padType); 129 tube.loadAnnotations("laterality", lateralityType); 130 jsonTubes.add(tube.asJSONObject()); 131 } 132 } 133 jsonCase.put("specimen", jsonTubes); 134 135 // This is what we send back to the browser 136 json.put("caseInfo", jsonCase); 137 138 } 139 140 else if ("GetPatientInfo".equals(cmd)) 141 { 142 /* 143 Load information about a single patient when given a personal number 144 If a patient is found we will load annotations and the cases associated 145 with it. If no patient is found, we populate a new object with some 146 information (eg. birth date and gender) from the information we have. 147 */ 148 dc = sc.newDbControl(); 149 150 // Request parameters 76 151 String pnr = req.getParameter("personalNumber"); 77 String caseName = req.getParameter("caseName");78 152 boolean pnrIsValid = Values.getBoolean(req.getParameter("pnrIsValid")); 79 80 // Find patient information given the personal number 81 ItemQuery<BioSource> patientQuery = BioSource.getQuery(); 82 patientQuery.restrict(Annotations.eq(null, pnrType, pnr, false)); 83 List<BioSource> patients = patientQuery.list(dc); 84 JSONObject jsonPat = new JSONObject(); 85 jsonPat.put("personalNumber", pnr); 86 87 if (patients.size() > 1) 88 { 89 throw new InvalidDataException( 90 "More than one patient with the given personal number was found. " + 91 "This wizard can't be used for registration until that is corrected."); 92 93 } 94 95 if (patients.size() == 1) 96 { 97 AnnotationType familyNameType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_FAMILY_NAME, true); 98 AnnotationType allFirstNamesType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_ALL_FIRST_NAMES, true); 99 AnnotationType genderType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_GENDER, true); 100 AnnotationType dateOfBirthType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_DATE_OF_BIRTH, true); 101 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); 102 BioSource bs = patients.get(0); 103 jsonPat.put("id", bs.getId()); 104 jsonPat.put("name", bs.getName()); 105 jsonPat.put("familyName", Reggie.getAnnotationValue(bs, familyNameType)); 106 jsonPat.put("allFirstNames", Reggie.getAnnotationValue(bs, allFirstNamesType)); 107 jsonPat.put("gender", Reggie.getAnnotationValue(bs, genderType)); 108 jsonPat.put("dateOfBirth", df.format((Date)Reggie.getAnnotationValue(bs, dateOfBirthType))); 109 110 // Find existing cases for the patient 111 ItemQuery<Sample> caseQuery = bs.getSamples(); 112 caseQuery.include(Include.ALL); 153 154 // Find a patient by personalNumber 155 Patient patient = Patient.findByPersonalNumber(dc, pnr); 156 JSONObject jsonPat = null; 157 158 if (patient != null) 159 { 160 // Load patient annotations 161 patient.loadDefaultAnnotations(dc); 162 163 // Load cases associated with this patient 164 List<Case> cases = Case.findByPatient(dc, patient); 165 166 // Load case annotations 113 167 JSONArray jsonCases = new JSONArray(); 114 for (Sample s : caseQuery.list(dc)) 115 { 116 JSONObject jsonCase = new JSONObject(); 117 jsonCase.put("id", s.getId()); 118 jsonCase.put("name", s.getName()); 119 jsonCase.put("laterality", Reggie.getAnnotationValue(s, lateralityType)); 120 jsonCases.add(jsonCase); 121 } 168 if (cases.size() > 0) 169 { 170 AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 171 for (Case c : cases) 172 { 173 c.loadAnnotations("laterality", lateralityType); 174 jsonCases.add(c.asJSONObject()); 175 } 176 } 177 178 jsonPat = patient.asJSONObject(); 122 179 jsonPat.put("cases", jsonCases); 180 123 181 } 124 182 else 125 183 { 126 // Try to find the highest existing patient number127 patientQuery = BioSource.getQuery();184 // No patient was found -- try to find the highest existing patient number 185 ItemQuery<BioSource> patientQuery = BioSource.getQuery(); 128 186 patientQuery.restrict(Restrictions.like(Hql.property("name"), Expressions.string("PAT%"))); 129 187 patientQuery.order(Orders.desc(Hql.property("name"))); 130 188 patientQuery.setMaxResults(1); 131 189 patientQuery.include(Include.ALL); 132 patients = patientQuery.list(dc); 133 190 List<BioSource> patients = patientQuery.list(dc); 191 jsonPat = new JSONObject(); 192 jsonPat.put("personalNumber", pnr); 134 193 if (patients.size() == 0) 135 194 { … … 150 209 jsonPat.put("gender", Integer.parseInt(pnr.substring(10,11)) % 2 == 0 ? "F" : "M"); 151 210 } 152 153 } 154 155 // Check for existing case 156 ItemQuery<Sample> caseQuery = Sample.getQuery(); 157 caseQuery.restrict(Restrictions.eq(Hql.property("name"), Expressions.parameter("name", caseName, Type.STRING))); 158 List<Sample> cases = caseQuery.list(dc); 159 JSONObject jsonCase = new JSONObject(); 160 if (cases.size() >= 1) 161 { 162 throw new InvalidDataException( 163 "At least one case with the given case name already exists. " + 164 "This wizard can't be used for registration until that is corrected."); 165 } 166 jsonCase.put("name", caseName); 167 168 // Find specimen information 169 ItemQuery<Sample> specimenQuery = Sample.getQuery(); 170 specimenQuery.restrict(Restrictions.like(Hql.property("name"), Expressions.parameter("name", caseName + ".%", Type.STRING))); 171 172 JSONArray jsonSpecimens = new JSONArray(); 173 for (Sample specimen : specimenQuery.list(dc)) 174 { 175 JSONObject jsonSpecimen = new JSONObject(); 176 jsonSpecimen.put("id", specimen.getId()); 177 jsonSpecimen.put("name", specimen.getName()); 178 jsonSpecimen.put("laterality", Reggie.getAnnotationValue(specimen, lateralityType)); 179 jsonSpecimen.put("pad", Reggie.getAnnotationValue(specimen, padType)); 180 jsonSpecimens.add(jsonSpecimen); 181 } 182 jsonCase.put("specimen", jsonSpecimens); 183 211 } 212 184 213 json.put("patientInfo", jsonPat); 185 json.put("caseInfo", jsonCase);186 214 } 187 215 } … … 222 250 try 223 251 { 224 if ("Create ".equals(cmd))252 if ("CreateCase".equals(cmd)) 225 253 { 226 254 JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader()); 227 228 255 JSONObject jsonPat = (JSONObject)jsonReq.get("patientInfo"); 229 256 JSONObject jsonCase = (JSONObject)jsonReq.get("caseInfo"); … … 322 349 { 323 350 JSONObject jsonSpec = (JSONObject)jsonSpecimen.get(i); 324 Sample specimen = Sample.getById(dc, (( Long)jsonSpec.get("id")).intValue());351 Sample specimen = Sample.getById(dc, ((Number)jsonSpec.get("id")).intValue()); 325 352 // Set specimen to 'pooled' and link with case 326 353 specimen.setPooled(true); … … 360 387 361 388 } 389 390 else if ("UpdateCase".equals(cmd)) 391 { 392 JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader()); 393 JSONObject jsonCase = (JSONObject)jsonReq.get("caseInfo"); 394 395 dc = sc.newDbControl(); 396 Number caseId = (Number)jsonCase.get("id"); 397 398 Sample theCase = Sample.getById(dc, caseId.intValue()); 399 400 // Get laterality 401 String laterality = Values.getStringOrNull((String)jsonCase.get("laterality")); 402 // If the 'laterality' value is a number, then it hasn't changed 403 if (Values.getInt(laterality) == 0) 404 { 405 AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 406 Reggie.setAnnotationValue(theCase, lateralityType, laterality); 407 int numSpecimen = 0; 408 for (Sample specimen : theCase.getChildSamples().list(dc)) 409 { 410 Reggie.setAnnotationValue(specimen, lateralityType, laterality); 411 numSpecimen++; 412 } 413 jsonMessages.add("Updated case '" + theCase.getName() + "' and " +numSpecimen + 414 " specimen tube(s) to laterality="+laterality); 415 } 416 417 dc.commit(); 418 json.put("messages", jsonMessages); 419 } 420 362 421 } 363 422 catch (Throwable t)
Note: See TracChangeset
for help on using the changeset viewer.