Changeset 1519
- Timestamp:
- Jan 23, 2012, 1:39:05 PM (11 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/consentform.jsp
r1514 r1519 37 37 38 38 var caseInfo = null; 39 var bloodInfo = null; 39 40 40 41 function init() … … 115 116 // Get case information from the AJAX response 116 117 caseInfo = response.caseInfo; 117 118 bloodInfo = response.bloodInfo; 119 118 120 if (caseInfo.consentDate) 119 121 { 120 122 frm.consentDate.value = caseInfo.consentDate; 121 123 } 124 else if (bloodInfo.consentDate) 125 { 126 frm.consentDate.value = bloodInfo.consentDate; 127 } 122 128 frm.consentDate.focus(); 123 124 125 // caseInfo.consent = 'No';126 // caseInfo.id = 999;127 // caseInfo.specimen = [ 1 ];128 129 129 if (caseInfo.consent )130 if (caseInfo.consent || bloodInfo.consent) 130 131 { 131 132 // A consent has already been registered for this case … … 136 137 frm.consentDate.disabled = true; 137 138 } 138 else if (caseInfo.id )139 else if (caseInfo.id || bloodInfo.id) 139 140 { 140 141 // There is an existing case already registered … … 214 215 var submitInfo = new Object(); 215 216 submitInfo.caseInfo = caseInfo; 217 submitInfo.bloodInfo = bloodInfo; 216 218 217 219 if (debug) Main.debug(JSON.stringify(submitInfo)); -
extensions/net.sf.basedb.reggie/trunk/resources/persinfo.jsp
r1514 r1519 41 41 var patientInfo = null; 42 42 var caseInfo = null; 43 var bloodInfo = null; 43 44 44 45 function init() … … 404 405 // Get biosource information from the AJAX response 405 406 caseInfo = response.caseInfo; 407 bloodInfo = response.bloodInfo; 406 408 407 409 if (caseInfo && caseInfo.patient) … … 410 412 gotoStep2(); 411 413 } 412 414 else if (bloodInfo && bloodInfo.patient) 415 { 416 frm.personalNumber.value = bloodInfo.patient.personalNumber; 417 gotoStep2(); 418 } 413 419 } 414 420 -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/ConsentFormServlet.java
r1504 r1519 25 25 import net.sf.basedb.reggie.converter.DateToStringConverter; 26 26 import net.sf.basedb.reggie.converter.StringToDateConverter; 27 import net.sf.basedb.reggie.dao.Blood; 27 28 import net.sf.basedb.reggie.dao.Case; 28 29 import net.sf.basedb.reggie.dao.Patient; … … 70 71 dc = sc.newDbControl(); 71 72 72 // Find a case by name73 // Find a case + blood by name 73 74 String caseName = req.getParameter("caseName"); 74 75 Case theCase = Case.findByName(dc, caseName); 76 Blood blood = Blood.findByCaseName(dc, caseName); 77 75 78 List<SpecimenTube> specimenTubes = null; 76 79 JSONObject jsonCase = null; 80 JSONObject jsonBlood = null; 77 81 78 82 if (theCase != null) … … 105 109 jsonCase.put("specimen", jsonTubes); 106 110 } 107 108 // This is what we send back to the browser109 111 json.put("caseInfo", jsonCase); 112 113 // Load blood information for the same case 114 if (blood != null) 115 { 116 blood.loadAnnotations(dc, "consent", Reggie.ANNOTATION_CONSENT, null); 117 DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd")); 118 blood.loadAnnotations(dc, "consentDate", Reggie.ANNOTATION_CONSENT_DATE, dateConverter); 119 120 // Wrap it up into JSON objects 121 jsonBlood = blood.asJSONObject(); 122 } 123 124 json.put("bloodInfo", jsonBlood); 110 125 111 126 } … … 149 164 JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader()); 150 165 JSONObject jsonCase = (JSONObject)jsonReq.get("caseInfo"); 166 JSONObject jsonBlood = (JSONObject)jsonReq.get("bloodInfo"); 151 167 152 168 dc = sc.newDbControl(); 153 169 154 170 Number caseId = (Number)jsonCase.get("id"); 171 Number bloodId = (Number)jsonBlood.get("id"); 155 172 String consent = Values.getStringOrNull((String)jsonCase.get("consent")); 156 173 StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd")); … … 194 211 if (consentDate != null) Reggie.setAnnotationValue(theCase, consentDateType, consentDate); 195 212 213 // Blood if available 214 if (bloodId != null) 215 { 216 Sample blood = Sample.getById(dc, bloodId.intValue()); 217 jsonMessages.add("Consent for blood '" + blood.getName() + "' set to: " + consent); 218 Reggie.setAnnotationValue(blood, consentType, consent); 219 if (consentDate != null) Reggie.setAnnotationValue(blood, consentDateType, consentDate); 220 } 221 196 222 dc.commit(); 197 223 json.put("messages", jsonMessages); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java
r1518 r1519 77 77 String caseName = req.getParameter("caseName"); 78 78 Case theCase = Case.findByName(dc, caseName); 79 Patient patient = null; 79 Blood blood = Blood.findByCaseName(dc, caseName); 80 80 81 List<SpecimenTube> specimenTubes = null; 81 82 JSONObject jsonCase = null; 83 JSONObject jsonBlood = null; 82 84 83 85 if (theCase != null) … … 104 106 105 107 // Load the patient associated with the case 106 patient = Patient.findByCase(dc, theCase); 108 Patient patient = Patient.findByCase(dc, theCase); 109 // The patient can be null if (for example) we have only registered consent=yes so far 110 if (patient != null) 111 { 112 patient.loadDefaultAnnotations(dc); 113 jsonCase.put("patient", patient.asJSONObject()); 114 } 107 115 } 108 116 else … … 112 120 jsonCase = new JSONObject(); 113 121 jsonCase.put("name", caseName); 114 115 // Also check for a blood sample so that we can get patient information 116 Blood blood = Blood.findByCaseName(dc, caseName); 117 if (blood != null) patient = Patient.findByBlood(dc, blood); 118 } 119 120 // The patient can be null if (for example) we have only registered consent=yes so far 121 if (patient != null) 122 { 123 patient.loadDefaultAnnotations(dc); 124 jsonCase.put("patient", patient.asJSONObject()); 122 } 123 124 if (blood != null) 125 { 126 // Check that the registration is not prohibited 127 blood.verifyConsent(dc, null); 128 129 // Wrap what we have so far up into JSON objects 130 jsonBlood = blood.asJSONObject(); 131 132 // Load patient information 133 Patient patient = Patient.findByBlood(dc, blood); 134 if (patient != null) 135 { 136 patient.loadDefaultAnnotations(dc); 137 jsonBlood.put("patient", patient.asJSONObject()); 138 } 125 139 } 126 140 … … 147 161 // This is what we send back to the browser 148 162 json.put("caseInfo", jsonCase); 163 json.put("bloodInfo", jsonBlood); 149 164 150 165 }
Note: See TracChangeset
for help on using the changeset viewer.