Changeset 1520
- Timestamp:
- Jan 23, 2012, 4:03:26 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/consentform.jsp
r1519 r1520 29 29 <script language="JavaScript"> 30 30 31 var debug = false;31 var debug = true; 32 32 var currentStep = 1; 33 33 var caseIsValid = false; … … 38 38 var caseInfo = null; 39 39 var bloodInfo = null; 40 var patientInfo = null; 40 41 41 42 function init() … … 117 118 caseInfo = response.caseInfo; 118 119 bloodInfo = response.bloodInfo; 120 patientInfo = response.patientInfo; 119 121 120 122 if (caseInfo.consentDate) … … 127 129 } 128 130 frm.consentDate.focus(); 131 132 if (patientInfo) 133 { 134 var html = ''; 135 if (patientInfo.allCases) 136 { 137 for (var i = 0; i < patientInfo.allCases.length; i++) 138 { 139 var c = patientInfo.allCases[i]; 140 html += '<input type="checkbox" name="case.'+c.id+'" id="case.'+c.id+'" checked><label for="'+c.id+'">Case: ' + c.name + '</label><br>'; 141 } 142 } 129 143 144 if (patientInfo.allBlood) 145 { 146 for (var i = 0; i < patientInfo.allBlood.length; i++) 147 { 148 var c = patientInfo.allBlood[i]; 149 html += '<input type="checkbox" name="blood.'+ c.id + '" id="case.'+c.id+'" checked><label for="'+c.id+'">Blood: ' + c.name + '</label><br>'; 150 } 151 } 152 153 document.getElementById('moreCases').innerHTML = html; 154 Main.show('moreCasesSection'); 155 } 156 130 157 if (caseInfo.consent || bloodInfo.consent) 131 158 { … … 213 240 } 214 241 242 if (patientInfo) 243 { 244 if (patientInfo.allCases) 245 { 246 var selectedCases = new Array(); 247 for (var i = 0; i < patientInfo.allCases.length; i++) 248 { 249 var c = patientInfo.allCases[i]; 250 if (frm['case.'+c.id].checked) selectedCases[selectedCases.length] = c.id; 251 } 252 caseInfo.selectedCases = selectedCases; 253 } 254 255 if (patientInfo.allBlood) 256 { 257 var selectedBlood = new Array(); 258 for (var i = 0; i < patientInfo.allBlood.length; i++) 259 { 260 var c = patientInfo.allBlood[i]; 261 if (frm['blood.'+c.id].checked) selectedBlood[selectedBlood.length] = c.id; 262 } 263 bloodInfo.selectedBlood = selectedBlood; 264 } 265 } 266 215 267 var submitInfo = new Object(); 216 268 submitInfo.caseInfo = caseInfo; 217 269 submitInfo.bloodInfo = bloodInfo; 218 270 219 271 if (debug) Main.debug(JSON.stringify(submitInfo)); 220 272 var request = Ajax.getXmlHttpRequest(); … … 380 432 <input id="consent.yes" type="radio" name="consent" value="Yes" disabled onchange="consentOnChange()"> 381 433 <label id="consent.yes.label" for="consent.yes" class="disabled">Yes</label><br> 434 <div id="moreCasesSection" style="display: none;"> 435 <table border="0" cellpadding="0" cellspacing="0"> 436 <tr valign="baseline"> 437 <td><img src="../../images/joust/joinbottom.gif"></td> 438 <td id="moreCases"></td> 439 </tr> 440 </table> 441 </div> 382 442 <input id="consent.notAsked" type="radio" name="consent" value="Not asked" disabled onchange="consentOnChange()"> 383 443 <label id="consent.notAsked.label" for="consent.notAsked" class="disabled">Not asked</label> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/ConsentFormServlet.java
r1519 r1520 75 75 Case theCase = Case.findByName(dc, caseName); 76 76 Blood blood = Blood.findByCaseName(dc, caseName); 77 Patient patient = null; 77 78 78 79 List<SpecimenTube> specimenTubes = null; … … 88 89 DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd")); 89 90 theCase.loadAnnotations(dc, "consentDate", Reggie.ANNOTATION_CONSENT_DATE, dateConverter); 90 91 92 // Get patient 93 patient = Patient.findByCase(dc, theCase); 94 91 95 // Wrap it up into JSON objects 92 96 jsonCase = theCase.asJSONObject(); … … 117 121 DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd")); 118 122 blood.loadAnnotations(dc, "consentDate", Reggie.ANNOTATION_CONSENT_DATE, dateConverter); 119 123 124 // Get patient 125 if (patient == null) patient = Patient.findByBlood(dc, blood); 126 120 127 // Wrap it up into JSON objects 121 128 jsonBlood = blood.asJSONObject(); 122 129 } 130 else 131 { 132 jsonBlood = new JSONObject(); 133 jsonBlood.put("name", caseName+".b"); 134 } 123 135 124 136 json.put("bloodInfo", jsonBlood); 137 138 if (patient != null) 139 { 140 JSONObject jsonPatient = patient.asJSONObject(); 141 142 // Load all cases for the patient 143 List<Case> allCases = Case.findByPatient(dc, patient); 144 JSONArray jsonAll = new JSONArray(); 145 if (allCases.size() > 0) 146 { 147 for (Case c : allCases) 148 { 149 jsonAll.add(c.asJSONObject()); 150 } 151 } 152 jsonPatient.put("allCases", jsonAll); 153 154 // Load all blood for the patient 155 List<Blood> allBlood = Blood.findByPatient(dc, patient); 156 jsonAll = new JSONArray(); 157 if (allBlood.size() > 0) 158 { 159 for (Blood b : allBlood) 160 { 161 jsonAll.add(b.asJSONObject()); 162 } 163 } 164 jsonPatient.put("allBlood", jsonAll); 165 json.put("patientInfo", jsonPatient); 166 } 125 167 126 168 } … … 198 240 jsonMessages.add("Patient '" + vPat.getName() + "' created."); 199 241 } 242 Reggie.setAnnotationValue(theCase, consentType, consent); 243 if (consentDate != null) Reggie.setAnnotationValue(theCase, consentDateType, consentDate); 200 244 201 245 dc.saveItem(theCase); … … 204 248 else 205 249 { 206 // Load existing case 207 theCase = Sample.getById(dc, caseId.intValue()); 208 jsonMessages.add("Consent for case '" + theCase.getName() + "' set to: " + consent); 209 } 210 Reggie.setAnnotationValue(theCase, consentType, consent); 211 if (consentDate != null) Reggie.setAnnotationValue(theCase, consentDateType, consentDate); 250 List<Number> selectedCases = (List<Number>)jsonCase.get("selectedCases"); 251 if (selectedCases != null) 252 { 253 for (Number n : selectedCases) 254 { 255 theCase = Sample.getById(dc, n.intValue()); 256 Reggie.setAnnotationValue(theCase, consentType, consent); 257 if (consentDate != null) Reggie.setAnnotationValue(theCase, consentDateType, consentDate); 258 jsonMessages.add("Consent for case '" + theCase.getName() + "' set to: " + consent); 259 } 260 } 261 else 262 { 263 // Load existing case 264 theCase = Sample.getById(dc, caseId.intValue()); 265 Reggie.setAnnotationValue(theCase, consentType, consent); 266 if (consentDate != null) Reggie.setAnnotationValue(theCase, consentDateType, consentDate); 267 jsonMessages.add("Consent for case '" + theCase.getName() + "' set to: " + consent); 268 } 269 } 212 270 213 271 // Blood if available 214 if (bloodId != null) 272 List<Number> selectedBlood = (List<Number>)jsonBlood.get("selectedBlood"); 273 if (selectedBlood != null) 274 { 275 for (Number n : selectedBlood) 276 { 277 Sample blood = Sample.getById(dc, n.intValue()); 278 jsonMessages.add("Consent for blood '" + blood.getName() + "' set to: " + consent); 279 Reggie.setAnnotationValue(blood, consentType, consent); 280 if (consentDate != null) Reggie.setAnnotationValue(blood, consentDateType, consentDate); 281 } 282 283 } 284 else if (bloodId != null) 215 285 { 216 286 Sample blood = Sample.getById(dc, bloodId.intValue());
Note: See TracChangeset
for help on using the changeset viewer.