Changeset 1523
- Timestamp:
- Jan 24, 2012, 3:34:18 PM (11 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
r1519 r1523 30 30 <script language="JavaScript"> 31 31 32 var debug = false;32 var debug = true; 33 33 var currentStep = 1; 34 34 var pnrIsValid = false; … … 43 43 var bloodInfo = null; 44 44 45 var copyConsentEnabled = false; 46 45 47 function init() 46 48 { … … 248 250 setInputStatus('laterality', updateMode && numCases > 1 ? 'NOTE! Some alternatives may be missing if there is another case for the patient.' : '', 'valid'); 249 251 lateralityIsValid = true; 250 252 251 253 var laterality = selectedLaterality.value; 252 254 if (laterality.match(/\d+/)) … … 267 269 laterality = null; 268 270 } 271 272 // If the selected laterality/case is not the same as the other case with consent enable the copy consent option 273 Main.showHide('copyConsentSection', copyConsentEnabled && selectedLaterality.value != frm.copyConsent.value); 269 274 270 275 // No specimen tubes? … … 672 677 cases += ' onclick="lateralityOnChange()"><label for="lateralityUnknown"><i>unknown laterality</i> [<i>new case</i>]</label><br>'; 673 678 } 679 680 if (!updateMode && patientInfo.cases[0].consent) 681 { 682 var c = patientInfo.cases[0]; 683 var html = "From case '" + c.name; 684 html += "' (" + c.consent; 685 if (c.consentDate) html += '; ' + c.consentDate; 686 html += ')'; 687 setInnerHTML('copyConsent.text', html); 688 frm.copyConsent.value = patientInfo.cases[0].id; 689 copyConsentEnabled = true; 690 } 691 674 692 } 675 693 … … 697 715 setInnerHTML('laterality.input', cases); 698 716 } 717 718 // Check the blood registration for consent information 719 if (!copyConsentEnabled && bloodInfo && bloodInfo.consent) 720 { 721 var html = "From blood '" + bloodInfo.name; 722 html += "' (" + bloodInfo.consent; 723 if (bloodInfo.consentDate) html += '; ' + bloodInfo.consentDate; 724 html += ')'; 725 setInnerHTML('copyConsent.text', html); 726 frm.copyConsent.value = bloodInfo.id; 727 copyConsentEnabled = true; 728 } 729 730 699 731 lateralityOnChange(); 700 732 … … 726 758 caseInfo.samplingDate = Main.trimString(frm.samplingDate.value + ' ' + frm.samplingTime.value); 727 759 caseInfo.rnaLaterDate = Main.trimString(frm.rnaLaterDate.value + ' ' + frm.rnaLaterTime.value); 760 if (frm.copyConsent.checked && frm.copyConsent.value) 761 { 762 caseInfo.copyConsent = parseInt(frm.copyConsent.value); 763 } 728 764 729 765 for (var i = 0; i < frm.laterality.length; i++) … … 737 773 frm.rnaLaterDate.disabled = true; 738 774 frm.rnaLaterTime.disabled = true; 775 frm.copyConsent.disabled = true; 739 776 740 777 var updateMode = caseInfo.id && caseInfo.patient; … … 744 781 745 782 if (debug) Main.debug(JSON.stringify(submitInfo)); 746 783 747 784 var request = Ajax.getXmlHttpRequest(); 748 785 var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd='; … … 943 980 <td class="help"><span id="laterality.message" class="message" style="display: none;"></span></td> 944 981 </tr> 982 <tr id="copyConsentSection" style="display: none;"> 983 <td class="prompt">Copy consent?</td> 984 <td class="input"> 985 <input type="checkbox" name="copyConsent" id="copyConsent" value="" checked> 986 <label for="copyConsent"><span id="copyConsent.text"></span></label> 987 </td> 988 <td class="status" id="copyConsent.status"></td> 989 <td class="help"></td> 990 </tr> 945 991 <tr id="padSection" valign="top"> 946 992 <td class="prompt">PAD</td> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java
r1519 r1523 41 41 42 42 private static final long serialVersionUID = 8770173686061080429L; 43 43 private final DateToStringConverter dateTimeConverter; 44 private final DateToStringConverter dateConverter; 45 44 46 public PersonalRegistrationServlet() 45 {} 47 { 48 dateTimeConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd HHmm")); 49 dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd")); 50 } 46 51 47 52 @SuppressWarnings("unchecked") … … 126 131 // Check that the registration is not prohibited 127 132 blood.verifyConsent(dc, null); 128 133 blood.loadAnnotations(dc, "consent", Reggie.ANNOTATION_CONSENT, null); 134 blood.loadAnnotations(dc, "consentDate", Reggie.ANNOTATION_CONSENT_DATE, dateConverter); 135 129 136 // Wrap what we have so far up into JSON objects 130 137 jsonBlood = blood.asJSONObject(); … … 147 154 AnnotationType samplingDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SAMPLING_DATETIME, true); 148 155 AnnotationType rnaLaterDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true); 149 DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd HHmm"));150 156 for (SpecimenTube tube : specimenTubes) 151 157 { 152 158 tube.loadAnnotations("pad", padType, null); 153 159 tube.loadAnnotations("laterality", lateralityType, null); 154 tube.loadAnnotations("samplingDate", samplingDateType, date Converter);155 tube.loadAnnotations("rnaLaterDate", rnaLaterDateType, date Converter);160 tube.loadAnnotations("samplingDate", samplingDateType, dateTimeConverter); 161 tube.loadAnnotations("rnaLaterDate", rnaLaterDateType, dateTimeConverter); 156 162 jsonTubes.add(tube.asJSONObject()); 157 163 } … … 199 205 { 200 206 c.loadAnnotations("laterality", lateralityType, null); 207 c.loadAnnotations(dc, "consent", Reggie.ANNOTATION_CONSENT, null); 208 c.loadAnnotations(dc, "consentDate", Reggie.ANNOTATION_CONSENT_DATE, dateConverter); 201 209 jsonCases.add(c.asJSONObject()); 202 210 } … … 293 301 { 294 302 // Remove the pre-registered case but copy consent information first 295 AnnotationType consentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT, true);296 AnnotationType consentDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT_DATE, true);297 298 303 Sample preCase = Sample.getById(dc, preCaseId.intValue()); 299 Reggie.copyAnnotationValues(preCase, theCase, consentType, false); 300 Reggie.copyAnnotationValues(preCase, theCase, consentDateType, false); 304 copyConsentAnnotations(dc, preCase, theCase); 301 305 dc.deleteItem(preCase); 302 306 } … … 324 328 } 325 329 theCase.getCreationEvent().setSource(patient); 330 331 Number copyConsentId = (Number)jsonCase.get("copyConsent"); 332 if (copyConsentId != null) 333 { 334 Sample consentCase = Sample.getById(dc, copyConsentId.intValue()); 335 copyConsentAnnotations(dc, consentCase, theCase); 336 } 337 326 338 jsonMessages.add("Case '" + originalCaseName + "' created successfully."); 327 339 } … … 518 530 } 519 531 520 532 private void copyConsentAnnotations(DbControl dc, Sample from, Sample to) 533 { 534 AnnotationType consentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT, true); 535 AnnotationType consentDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT_DATE, true); 536 537 Reggie.copyAnnotationValues(from, to, consentType, false); 538 Reggie.copyAnnotationValues(from, to, consentDateType, false); 539 } 521 540 }
Note: See TracChangeset
for help on using the changeset viewer.