← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7553: Remove unused method

 

------------------------------------------------------------
revno: 7553
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-07-10 14:16:10 +0700
message:
  Remove unused method
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/java/org/hisp/dhis/caseentry/action/patient/GetPatientsByNameAction.java


--
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-10 06:49:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-07-10 07:16:10 +0000
@@ -106,9 +106,16 @@
     }
 
     @Override
-    public Collection<Patient> getByNames( String name, Integer min, Integer max )
+    public Collection<Patient> getByNames( String fullName, Integer min, Integer max )
     {
-        String sql = statementBuilder.getPatientsByFullName( name, min, max );
+        fullName = fullName.toLowerCase();
+        String sql = "SELECT patientid FROM patient " + "where lower( " + statementBuilder.getPatientFullName() + ") "
+            + "like '%" + fullName + "%' ";
+
+        if ( min != null && max != null )
+        {
+            sql += statementBuilder.limitRecord( min, max );
+        }
 
         StatementHolder holder = statementManager.getHolder();
 
@@ -198,32 +205,13 @@
     }
 
     @Override
-    public int countGetPatientsByName( String name )
+    public int countGetPatientsByName( String fullName )
     {
-        String sql = statementBuilder.countPatientsByFullName( name );
-        StatementHolder holder = statementManager.getHolder();
-
-        try
-        {
-            Statement statement = holder.getStatement();
-
-            ResultSet resultSet = statement.executeQuery( sql );
-
-            if ( resultSet.next() )
-            {
-                return resultSet.getInt( 1 );
-            }
-        }
-        catch ( Exception ex )
-        {
-            ex.printStackTrace();
-        }
-        finally
-        {
-            holder.close();
-        }
-
-        return 0;
+        fullName = fullName.toLowerCase();
+        String sql = "SELECT count(*) FROM patient where lower( " + statementBuilder.getPatientFullName() + ") "
+            + "like '%" + fullName + "%' ";
+        
+        return jdbcTemplate.queryForInt( sql );
     }
 
     @Override
@@ -305,12 +293,15 @@
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
-    
-    private String searchPatientSql( boolean count, List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max )
+
+    private String searchPatientSql( boolean count, List<String> searchKeys, OrganisationUnit orgunit, Integer min,
+        Integer max )
     {
         String selector = count ? "count(*) " : "* ";
 
-        String sql = "select " + selector + " from ( select distinct p.patientid, p.firstname, p.middlename, p.lastname, p.gender, p.phonenumber, p.birthdate, p.deathdate,";
+        String sql = "select "
+            + selector
+            + " from ( select distinct p.patientid, p.firstname, p.middlename, p.lastname, p.gender, p.phonenumber, p.birthdate, p.deathdate,";
         String patientWhere = "";
         String patientOperator = " where ";
         String otherWhere = "";
@@ -334,7 +325,8 @@
             }
             else if ( keys[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) )
             {
-                patientWhere = operator + "( ( lower( " + statementBuilder.getPatientFullName() + " ) like '%" + id + "%' ) or lower(pi.identifier)='" + id + "') ";
+                patientWhere = operator + "( ( lower( " + statementBuilder.getPatientFullName() + " ) like '%" + id
+                    + "%' ) or lower(pi.identifier)='" + id + "') ";
                 patientOperator = " and ";
                 hasIdentifier = true;
             }
@@ -361,12 +353,12 @@
         {
             sql += " left join patientidentifier pi on p.patientid=pi.patientid ";
         }
-        
-        if( orgunit != null )
+
+        if ( orgunit != null )
         {
-            patientWhere += " and p.organisationunitid = " +  orgunit.getId();
+            patientWhere += " and p.organisationunitid = " + orgunit.getId();
         }
-        
+
         sql += patientWhere + " order by p.patientid desc ";
         sql += " ) as searchresult";
         sql += otherWhere;

=== 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-07-10 06:49:04 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2012-07-10 07:16:10 +0000
@@ -154,12 +154,6 @@
     
     String deleteOldestOverlappingPatientArchiveData();
     
-    String getPatientsByFullName( String fullName );
-    
-    String getPatientsByFullName( String fullName, int min, int max );
-    
-    String countPatientsByFullName( String fullName );
-
     String queryDataElementStructureForOrgUnit();
 
     String queryRawDataElementsForOrgUnitBetweenPeriods( Integer orgUnitId, List<Integer> betweenPeriodIds);

=== 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-07-10 06:49:04 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java	2012-07-10 07:16:10 +0000
@@ -261,24 +261,6 @@
             + "AND a.timestamp<=d.timestamp;";
     }
 
-    public String getPatientsByFullName( String fullName )
-    {
-        return "SELECT patientid FROM patient " + "where lower( firstname || ' ' || middleName || ' ' || lastname) "
-            + "like lower('%" + fullName + "%') ";
-    }
-
-    public String getPatientsByFullName( String fullName, int min, int max )
-    {
-        return "SELECT patientid FROM patient " + "where lower( firstname || ' ' || middleName || ' ' || lastname) "
-            + "like lower('%" + fullName + "%') " + "limit " + max + " OFFSET " + min;
-    }
-
-    public String countPatientsByFullName( String fullName )
-    {
-        return "SELECT count(patientid) FROM patient "
-            + "where lower( firstname || ' ' || middleName || ' ' || lastname) " + "like lower('%" + fullName + "%')";
-    }
-
     public String queryDataElementStructureForOrgUnit()
     {
         StringBuffer sb = new StringBuffer();

=== 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-07-10 06:49:04 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2012-07-10 07:16:10 +0000
@@ -278,28 +278,6 @@
                 "AND a.timestamp<=d.timestamp;";
     }
     
-    public String getPatientsByFullName( String fullName )
-    {
-        return "SELECT patientid FROM patient " +
-                "where lower( firstname || ' ' || middleName || ' ' || lastname) " +
-                "like lower('%" + fullName + "%') ";
-    }
-    
-    public String getPatientsByFullName( String fullName, int min, int max )
-    {
-        return "SELECT patientid FROM patient " +
-                "where lower( firstname || ' ' || middleName || ' ' || lastname) " +
-                "like lower('%" + fullName + "%') " +
-                "limit " + max + " OFFSET " + min;
-    }
-    
-    public String countPatientsByFullName( String fullName )
-    {
-        return "SELECT count(patientid) FROM patient " +
-            "where lower( firstname || ' ' || middleName || ' ' || lastname) " +
-            "like lower('%" + fullName + "%')";
-    }
-    
     public String queryDataElementStructureForOrgUnit()
     {
         StringBuffer sqlsb = new StringBuffer();

=== 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-07-10 06:49:04 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2012-07-10 07:16:10 +0000
@@ -276,28 +276,6 @@
             "AND a.timestamp<=d.timestamp;";
     }
 
-    public String getPatientsByFullName( String fullName )
-    {
-        return "SELECT patientid FROM patient " +
-            "where lower(concat( firstname, \" \",middleName , \" \" , lastname) ) " +
-            "like lower('%" + fullName + "%') ";
-    }
-   
-    public String getPatientsByFullName( String fullName, int min, int max )
-    {
-        return "SELECT patientid FROM patient " +
-            "where lower(concat( firstname, \" \",middleName , \" \" , lastname) ) " +
-            "like lower('%" + fullName + "%') " +
-            "limit " + min + " ," + max;
-    }
-   
-    public String countPatientsByFullName( String fullName )
-    {
-        return "SELECT count(patientid) FROM patient " +
-            "where lower(concat( firstname, \" \",middleName , \" \" , lastname) ) " +
-            "like lower('%" + fullName + "%')";
-    }
-
     public String queryDataElementStructureForOrgUnit()
     {
         StringBuffer sqlsb = new StringBuffer();

=== 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-07-10 06:49:04 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2012-07-10 07:16:10 +0000
@@ -273,28 +273,6 @@
                 "AND a.timestamp<=d.timestamp;";
     }
     
-    public String getPatientsByFullName( String fullName )
-    {
-        return "SELECT patientid FROM patient " +
-                "where lower( firstname || ' ' || middleName || ' ' || lastname ) " +
-                "like lower('%" + fullName + "%') ";
-    }
-    
-    public String getPatientsByFullName( String fullName, int min, int max )
-    {
-        return "SELECT patientid FROM patient " +
-                "where lower( firstname || ' ' || middleName || ' ' || lastname) " +
-                "like lower('%" + fullName + "%') " +
-                "limit " + max + " OFFSET " + min;
-    }
-    
-    public String countPatientsByFullName( String fullName )
-    {
-        return "SELECT count(patientid) FROM patient " +
-               "where lower( firstname || ' ' || middleName || ' ' || lastname) " +
-               "like lower('%" + fullName + "%') ";
-    }
-
     public String queryDataElementStructureForOrgUnit()
     {
            StringBuffer sqlsb = new StringBuffer();

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientsByNameAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientsByNameAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientsByNameAction.java	2012-07-10 07:16:10 +0000
@@ -87,30 +87,7 @@
     public String execute()
     {
         fullName = fullName.trim();
-
-        int startIndex = fullName.indexOf( ' ' );
-        int endIndex = fullName.lastIndexOf( ' ' );
-
-        String firstName = fullName.toString();
-        String middleName = "";
-        String lastName = "";
-
-        if ( fullName.indexOf( ' ' ) != -1 )
-        {
-            firstName = fullName.substring( 0, startIndex );
-            if ( startIndex == endIndex )
-            {
-                middleName = "";
-                lastName = fullName.substring( startIndex + 1, fullName.length() );
-            }
-            else
-            {
-                middleName = fullName.substring( startIndex + 1, endIndex );
-                lastName = fullName.substring( endIndex + 1, fullName.length() );
-            }
-        }
-
-        String fullName = (firstName + " " + middleName + " " + lastName).trim();
+        
         total = patientService.countGetPatientsByName( fullName );
         this.paging = createPaging( total );