Changeset 2144
- Timestamp:
- Nov 19, 2013, 10:13:28 AM (10 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/reports/case_summary.jsp
r2134 r2144 74 74 var debug = false; 75 75 var ID = '<%=ID%>'; 76 var caseName= ''; 76 77 77 78 var TRUNCATE_SIZE = [-1, 30, 20, 15]; … … 296 297 if (frm.caseName) frm.caseName.focus(); 297 298 298 varcaseName = '<%=HTML.javaScriptEncode(caseName)%>';299 caseName = '<%=HTML.javaScriptEncode(caseName)%>'; 299 300 var isAdmin = <%=isAdmin ? "true" : "false"%>; 300 301 var isPatientCurator = <%=isPatientCurator ? "true" : "false"%>; … … 303 304 url += '&caseName=<%=HTML.urlEncode(caseName)%>'; 304 305 var request = Ajax.getXmlHttpRequest(); 305 request.open("GET", url, false); 306 request.open("GET", url, false); 306 307 request.send(null); 307 308 … … 324 325 if (caseInfo) 325 326 { 327 // Use returned case name, as it may have been found from personal number 328 caseName = caseInfo.name; 329 // Update header text to use the potentially changed case name 330 if (document.getElementById('path-case-summary') != null) 331 { 332 document.getElementById('path-case-summary').innerHTML = 'Case summary - ' + escape(caseName); 333 } 334 if (document.getElementById('path-case-summary-popup') != null) 335 { 336 document.getElementById('path-case-summary-popup').innerHTML = 'Case summary - ' + escape(caseName); 337 } 326 338 consentOk = !caseInfo.consent || caseInfo.consent == 'Yes'; 327 339 addColumn('case.name', makeLink('SAMPLE', caseInfo)); … … 802 814 var printNote = '<b>Note!</b> For better printing set page orientation to <i>portrait</i>.<br>'; 803 815 printNote += ' You may have to <i>scale down</i> to fit everything on the width of the page.'; 804 openPrintWindow('<%=ID%>', 'all-content', 'Case summary - <%=HTML.encodeTags(caseName)%>', 'portrait', printNote, '../', 'case_summary.css');816 openPrintWindow('<%=ID%>', 'all-content', 'Case summary - ' + escape(caseName), 'portrait', printNote, '../', 'case_summary.css'); 805 817 } 806 818 … … 873 885 { 874 886 %> 875 <h1 >Case summary - <%= HTML.encodeTags(caseName)%></h1>887 <h1 id="path-case-summary-popup">Case summary - <%= HTML.encodeTags(caseName)%></h1> 876 888 <% 877 889 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Case.java
r1907 r2144 102 102 /** 103 103 Find all cases linked with a patient. A patient can have 0, 1 or 2 104 cases. If more than two are found an exception is thrown. 104 cases. If more than two are found an exception is thrown. 105 The cases are sorted in ascending order after case name. 105 106 */ 106 107 public static List<Case> findByPatient(DbControl dc, Patient patient) -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/CaseSummaryServlet.java
r2134 r2144 5 5 import java.util.List; 6 6 import java.util.Set; 7 import java.util.regex.Matcher; 8 import java.util.regex.Pattern; 7 9 8 10 import javax.servlet.ServletException; … … 26 28 import net.sf.basedb.core.MeasuredBioMaterial; 27 29 import net.sf.basedb.core.Permission; 30 import net.sf.basedb.core.PermissionDeniedException; 28 31 import net.sf.basedb.core.Sample; 29 32 import net.sf.basedb.core.SessionControl; … … 90 93 91 94 String caseName = req.getParameter("caseName"); 95 // Check if input 'caseName' is valid, or is personal number 96 boolean validCaseName = caseNameIsValid(caseName, true); 97 Patient patient = null; 98 Case theCase = null; 99 List<Case> caseList = null; 100 if (!validCaseName) 101 { 102 // Input 'caseName' may be personal number 103 String potentialPnr = caseName; 104 // Find cases by personal number if user has permission to do so 105 try 106 { 107 patient = Patient.findByPersonalNumber(dc, potentialPnr); 108 } 109 catch (PermissionDeniedException e) 110 {} 111 if (patient != null) 112 { 113 caseList = Case.findByPatient(dc, patient); 114 if (caseList != null && caseList.size() > 0) 115 { 116 // Use lowest case name (a patient can have at most 2 cases) 117 theCase = (Case) caseList.get(0); 118 } 119 if (theCase != null) 120 { 121 // Use case name found from personal number 122 caseName = theCase.getName(); 123 } 124 } 125 } 126 92 127 JSONArray jsonSections = new JSONArray(); 93 128 json.put("sections", jsonSections); … … 101 136 102 137 // Load case (null if not found) and patient 103 Case theCase = Case.findByName(dc, caseName); 104 Patient patient = null; 138 if (theCase == null) 139 { 140 theCase = Case.findByName(dc, caseName); 141 } 105 142 if (theCase != null) 106 143 { … … 108 145 jsonSections.add(loadSectionInfo(sc, "case")); 109 146 json.put("caseInfo", theCase.asJSONObject()); 110 patient = Patient.findByCase(dc, theCase); 147 if (patient == null) 148 { 149 patient = Patient.findByCase(dc, theCase); 150 } 111 151 } 112 152 … … 346 386 json.writeJSONString(resp.getWriter()); 347 387 } 388 } 389 390 /* 391 Verify that the 'case' name is a 7-digit value + optional 'C' suffix. 392 393 @param caseName String Input case name to check. 394 @param allowSuffix boolean Flag indicating if optional 'C' suffix is allowed. 395 @return boolean True if potential case name (not necessarily in database), false otherwise. 396 */ 397 private boolean caseNameIsValid(String caseName, boolean allowSuffix) 398 { 399 boolean isValid = false; 400 if (caseName != null) 401 { 402 String regex = allowSuffix ? "^\\d{7}C?$" : "^\\d{7}$"; 403 Pattern pattern = Pattern.compile(regex); 404 Matcher matcher = pattern.matcher(caseName); 405 isValid = matcher.matches(); 406 } 407 return isValid; 348 408 } 349 409
Note: See TracChangeset
for help on using the changeset viewer.