← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7552: Add function to search a part of fullname.

 

------------------------------------------------------------
revno: 7552
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-07-10 13:49:04 +0700
message:
  Add function to search a part of fullname.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/search.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-07-06 09:59:36 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-07-10 06:49:04 +0000
@@ -277,7 +277,7 @@
 
             ResultSet resultSet = statement.executeQuery( sql );
 
-            if ( resultSet.next() )
+            while ( resultSet.next() )
             {
                 int patientId = resultSet.getInt( 1 );
                 patients.add( get( patientId ) );
@@ -334,24 +334,7 @@
             }
             else if ( keys[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) )
             {
-                int startIndex = id.indexOf( ' ' );
-                int endIndex = id.lastIndexOf( ' ' );
-                String firstName = id.substring( 0, startIndex );
-                String middleName = "";
-                String lastName = "";
-                
-                if ( startIndex == endIndex )
-                {
-                    middleName = "";
-                    lastName = id.substring( startIndex + 1, id.length() );
-                }
-                else
-                {
-                    middleName = id.substring( startIndex + 1, endIndex );
-                    lastName = id.substring( endIndex + 1, id.length() );
-                }
-                
-                patientWhere = operator + "( ( lower(p.firstname)='" + firstName + "' and lower(p.middlename)='" + middleName + "' and lower(p.lastname)='" + lastName + "' ) or lower(pi.identifier)='" + id + "') ";
+                patientWhere = operator + "( ( lower( " + statementBuilder.getPatientFullName() + " ) like '%" + id + "%' ) or lower(pi.identifier)='" + id + "') ";
                 patientOperator = " and ";
                 hasIdentifier = true;
             }
@@ -392,7 +375,7 @@
         {
             sql += statementBuilder.limitRecord( min, max );
         }
-        
+
         return sql;
     }
 

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2012-03-19 07:56:03 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2012-07-10 06:49:04 +0000
@@ -167,4 +167,6 @@
     String limitRecord( int min, int max );
     
     String getAddDate( String dateField, int days );
+    
+    String getPatientFullName();
 }

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java	2012-03-19 07:56:03 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java	2012-07-10 06:49:04 +0000
@@ -323,4 +323,9 @@
     {
         return "DATEADD('DAY'," + days + "," + dateField + ")";
     }
+    
+    public String getPatientFullName()
+    {
+        return  "concat( firstname, \" \",middleName , \" \" , lastname)";
+    }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2012-03-19 07:56:03 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2012-07-10 06:49:04 +0000
@@ -344,4 +344,9 @@
     {
         return "DATEADD('DAY'," + days + "," + dateField + ")";
     }
+    
+    public String getPatientFullName()
+    {
+        return  "concat( firstname, \" \",middleName , \" \" , lastname)";
+    }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2012-03-19 07:56:03 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2012-07-10 06:49:04 +0000
@@ -341,4 +341,9 @@
     {
         return "ADDDATE(" + dateField + "," + days + ")";
     }
+    
+    public String getPatientFullName()
+    {
+        return  "concat( firstname, \" \",middleName , \" \" , lastname)";
+    }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2012-05-17 16:47:13 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2012-07-10 06:49:04 +0000
@@ -276,7 +276,7 @@
     public String getPatientsByFullName( String fullName )
     {
         return "SELECT patientid FROM patient " +
-                "where lower( firstname || ' ' || middleName || ' ' || lastname) " +
+                "where lower( firstname || ' ' || middleName || ' ' || lastname ) " +
                 "like lower('%" + fullName + "%') ";
     }
     
@@ -339,4 +339,9 @@
     {
         return "(" + dateField + "+" + days + ")";
     }
+    
+    public String getPatientFullName()
+    {
+        return  "firstname || ' ' || middleName || ' ' || lastname";
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css	2012-06-01 04:31:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css	2012-07-10 06:49:04 +0000
@@ -765,4 +765,3 @@
     background-image: url(../images/equals.png) !important;
 }
 
-

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js	2012-06-28 04:07:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js	2012-07-10 06:49:04 +0000
@@ -60,7 +60,7 @@
 	
 	if ( key==13 )// Enter
 	{
-		validateSearch();
+		validateAdvancedSearch();
 	}
 }
 
@@ -70,12 +70,6 @@
 		return window.event.keyCode;
 	 return (e)? e.which : null;
 }
- 
-function validateSearch()
-{
-	$.postUTF8( 'validateSearch.action',{ searchText:getFieldValue( 'searchText' )}
-		, searchValidationCompleted	);
-}
 
 function searchValidationCompleted( messageElement )
 {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/search.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/search.vm	2011-03-24 17:27:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/search.vm	2012-07-10 06:49:04 +0000
@@ -16,7 +16,7 @@
 
 <hr style="clear:both">
 
-<form id="searchForm" name="searchForm" action="searchPatient.action" method="post" onsubmit="return validateSearch()">
+<form id="searchForm" name="searchForm" action="searchPatient.action" method="post" onsubmit="return validateAdvancedSearch();">
 <table> 
     <tr>           
         <td>