Changeset 1307
- Timestamp:
- Mar 4, 2011, 11:33:52 AM (12 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/persinfo.jsp
r1306 r1307 179 179 180 180 var laterality = selectedLaterality.value; 181 if (laterality != 'LEFT' && laterality != 'RIGHT')181 if (laterality.match(/\d+/)) 182 182 { 183 183 // It is the ID of an existing case … … 192 192 } 193 193 } 194 195 if (!laterality) return; 196 197 // No specimen tubes 194 else if (laterality == '') 195 { 196 laterality = null; 197 } 198 199 // No specimen tubes? 198 200 if (!caseInfo.specimen || caseInfo.specimen.length == 0) return; 201 199 202 for (var i = 0; i < caseInfo.specimen.length; i++) 200 203 { 201 204 var specimen = caseInfo.specimen[i]; 202 if (specimen.laterality && specimen.laterality != laterality) 203 { 204 setInputStatus('laterality', 'Not same laterality as specimen tubes', 'warning'); 205 if (specimen.laterality != laterality) 206 { 207 if (specimen.laterality == null) 208 { 209 setInputStatus('laterality', 'Specimen tubes are updated to: ' + laterality, 'valid') 210 } 211 else 212 { 213 setInputStatus('laterality', 'Not same laterality as specimen tubes', 'warning'); 214 } 205 215 return; 206 216 } … … 294 304 295 305 // Generate list of specimen tubes 296 var thisCaseLaterality; 306 var hasLeftSpecimen = false; 307 var hasRightSpecimen = false; 308 var hasUnknownSpecimen = false; 309 var thisCaseLaterality = null; 297 310 if (caseInfo.specimen && caseInfo.specimen.length > 0) 298 311 { … … 302 315 { 303 316 var specimen = caseInfo.specimen[i]; 304 specimenTubes += specimen.name 317 specimenTubes += specimen.name; 305 318 if (specimen.laterality) 306 319 { 307 320 specimenTubes += ' ('+specimen.laterality + ')'; 308 321 Forms.checkRadio(frm.laterality, specimen.laterality); 309 310 if (thisCaseLaterality && thisCaseLaterality != specimen.laterality) 311 { 312 setInputStatus('specimenTubes', 'Specimen tubes with different laterality', 'warning'); 313 } 322 if (specimen.laterality == 'LEFT') hasLeftSpecimen = true; 323 if (specimen.laterality == 'RIGHT') hasRightSpecimen = true; 314 324 thisCaseLaterality = specimen.laterality; 315 325 } 316 326 else 317 327 { 328 hasUnknownSpecimen = true; 318 329 specimenTubes += ' (<i>unknown laterality</i>)'; 319 330 } … … 321 332 } 322 333 setInnerHTML('specimenTubes', specimenTubes); 323 } 324 325 334 335 // Check that all specimen tubes have the same laterality 336 var numLateralities = 0; 337 if (hasLeftSpecimen) numLateralities++; 338 if (hasRightSpecimen) numLateralities++; 339 if (hasUnknownSpecimen) numLateralities++; 340 if (numLateralities > 1) 341 { 342 setInputStatus('specimenTubes', 'Specimen tubes with different laterality', 'warning'); 343 thisCaseLaterality = null; 344 } 345 } 346 326 347 Main.show('caseSection'); 327 348 … … 329 350 var hasLeftCase = false; 330 351 var hasRightCase = false; 352 var hasUnknownCase = false; 331 353 if (patientInfo.cases && patientInfo.cases.length > 0) 332 354 { … … 338 360 if (cc.laterality == 'LEFT') 339 361 { 340 if (hasLeftCase) setInputStatus('laterality', 'Two cases with LEFT', 'warning');362 if (hasLeftCase) setInputStatus('laterality', 'Two cases with laterality=LEFT', 'warning'); 341 363 hasLeftCase = true; 342 364 } 343 if (cc.laterality == 'RIGHT')344 { 345 if (hasRightCase) setInputStatus('laterality', 'Two cases with RIGHT', 'warning');365 else if (cc.laterality == 'RIGHT') 366 { 367 if (hasRightCase) setInputStatus('laterality', 'Two cases with laterality=RIGHT', 'warning'); 346 368 hasRightCase = true; 369 } 370 else 371 { 372 hasUnknownCase = true; 347 373 } 348 374 if (cc.laterality == thisCaseLaterality) cases += ' checked'; … … 372 398 cases += ' onclick="lateralityOnChange()"><i>new case</i> (RIGHT)<br>'; 373 399 } 400 cases += '<input type="radio" name="laterality" value=""'; 401 if (thisCaseLaterality == null) cases += ' checked'; 402 cases += ' onclick="lateralityOnChange()"><i>new case</i> (<i>unknown laterality</i>)<br>'; 374 403 } 375 404 … … 727 756 <td class="prompt" id="laterality.prompt">Laterality</td> 728 757 <td class="input" id="laterality.input"> 729 <input type="radio" name="laterality" value="LEFT" onclick="lateralityOnChange()">LEFT 730 <input type="radio" name="laterality" value="RIGHT" onclick="lateralityOnChange()">RIGHT 758 <input type="radio" name="laterality" value="LEFT" onclick="lateralityOnChange()">LEFT<br> 759 <input type="radio" name="laterality" value="RIGHT" onclick="lateralityOnChange()">RIGHT<br> 760 <input type="radio" name="laterality" value="" checked onclick="lateralityOnChange()"><i>unknown</i> 731 761 </td> 732 762 <td class="status" id="laterality.status"></td> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java
r1302 r1307 178 178 return as.getAnnotation(at).getValues().get(0); 179 179 } 180 181 /** 182 Set a (single) annotation value on an item. 183 */ 184 public static void setAnnotationValue(Annotatable item, AnnotationType at, Object value) 185 { 186 item.getAnnotationSet().getAnnotation(at).setValue(value); 187 } 188 180 189 181 190 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java
r1290 r1307 252 252 } 253 253 254 String laterality = (String)jsonCase.get("laterality"); 255 254 // Get laterality 255 String laterality = Values.getStringOrNull((String)jsonCase.get("laterality")); 256 AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 257 258 // Load/create case 256 259 String originalCaseName = (String)jsonCase.get("name"); 260 // If merging with an existing case the 'laterality' value holds the id 261 int caseId = Values.getInt(laterality); 257 262 Sample theCase = null; 258 if ("LEFT".equals(laterality) || "RIGHT".equals(laterality)) 263 if (caseId > 0) 264 { 265 // Merge with existing case 266 theCase = Sample.getById(dc, caseId); 267 laterality = (String)Reggie.getAnnotationValue(theCase, lateralityType); 268 jsonMessages.add("Case '" + originalCaseName + "' merged with case '" + theCase.getName() + "' successfully."); 269 } 270 else 259 271 { 260 272 // Register a new case 261 273 theCase = Sample.getNew(dc); 262 274 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")); 275 if (laterality != null) 276 { 277 Reggie.setAnnotationValue(theCase, lateralityType, laterality); 278 } 266 279 theCase.setBioSource(patient); 267 280 dc.saveItem(theCase); 268 281 jsonMessages.add("Case '" + originalCaseName + "' created successfully."); 269 }270 else271 {272 // Merge with existing case273 theCase = Sample.getById(dc, Values.getInt(laterality));274 jsonMessages.add("Case '" + originalCaseName + "' merged with case '" + theCase.getName() + "' successfully.");275 282 } 276 283 … … 282 289 AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true); 283 290 AnnotationType padCaseType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD_CASE, true); 284 List padCase = new ArrayList(caseAnnotations.getAnnotation(padCaseType).getValues()); 291 List padCase = new ArrayList(); 292 if (caseAnnotations.hasAnnotation(padCaseType)) 293 { 294 padCase.addAll(caseAnnotations.getAnnotation(padCaseType).getValues()); 295 } 285 296 for (int i = 0; i < jsonSpecimen.size(); ++i) 286 297 { … … 293 304 String pad = (String)Reggie.getAnnotationValue(specimen, padType); 294 305 if (pad != null && !padCase.contains(pad)) padCase.add(pad); 306 // Set laterality on the specimen tube if it is missing 307 if (laterality != null) 308 { 309 String specimenLaterality = (String)Reggie.getAnnotationValue(specimen, lateralityType); 310 if (specimenLaterality == null) 311 { 312 Reggie.setAnnotationValue(specimen, lateralityType, laterality); 313 jsonMessages.add("Updated laterality on '" + specimen.getName() + "' to " + laterality + "."); 314 } 315 } 316 295 317 } 296 318 if (padCase.size() > 0) caseAnnotations.getAnnotation(padCaseType).setValues(padCase); 297 jsonMessages.add(jsonSpecimen.size() + " specimen tube slinked with case '" + theCase.getName() + "' successfully.");319 jsonMessages.add(jsonSpecimen.size() + " specimen tube(s) linked with case '" + theCase.getName() + "' successfully."); 298 320 } 299 321 else
Note: See TracChangeset
for help on using the changeset viewer.