← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8289: fixed (apply search by phone number function in Mobile (Light) )

 

------------------------------------------------------------
revno: 8289
committer: Homg Em <em.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-09-27 17:11:02 +0700
message:
  fixed (apply search by phone number function in Mobile (Light) )
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java
  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/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/ValidatePatientAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties


--
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-api/src/main/java/org/hisp/dhis/patient/PatientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2012-09-27 08:00:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2012-09-27 10:11:02 +0000
@@ -215,4 +215,6 @@
     
     Grid getScheduledEventsReport( List<String> searchKeys, OrganisationUnit orgunit, I18n i18n );
 
+    Collection<Patient> getPatientsByPhone( String phoneNumber, Integer min, Integer max );
+
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2012-09-27 08:00:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2012-09-27 10:11:02 +0000
@@ -50,32 +50,36 @@
     Collection<Patient> getByBirthDate( Date birthDate );
 
     Collection<Patient> getByNames( String name, Integer min, Integer max );
-    
-    Collection<Patient> get( String firstName, String middleName, String lastName, Date birthdate, String gender );    
-    
+
+    Collection<Patient> get( String firstName, String middleName, String lastName, Date birthdate, String gender );
+
     Collection<Patient> getByOrgUnit( OrganisationUnit organisationUnit, Integer min, Integer max );
-    
-    Collection<Patient> getByOrgUnitProgram( OrganisationUnit organisationUnit, Program program, Integer min, Integer max );
-    
+
+    Collection<Patient> getByOrgUnitProgram( OrganisationUnit organisationUnit, Program program, Integer min,
+        Integer max );
+
     Collection<Patient> getRepresentatives( Patient patient );
-    
-    int countListPatientByOrgunit(OrganisationUnit organisationUnit);
-    
+
+    int countListPatientByOrgunit( OrganisationUnit organisationUnit );
+
     int countGetPatientsByName( String name );
-    
+
     int countGetPatientsByOrgUnitProgram( OrganisationUnit organisationUnit, Program program );
 
     void removeErollmentPrograms( Program program );
-    
+
     Collection<Patient> search( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max );
-    
+
     int countSearch( List<String> searchKeys, OrganisationUnit orgunit );
-    
-    Collection<String> getPatientPhoneNumbers( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max );
+
+    Collection<String> getPatientPhoneNumbers( List<String> searchKeys, OrganisationUnit orgunit, Integer min,
+        Integer max );
 
     Collection<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min,
         Integer max );
-    
+
     Grid getPatientEventReport( Grid grid, List<String> searchKeys, OrganisationUnit orgunit );
+    
+    Collection<Patient> getByPhoneNumber( String phoneNumber, Integer min, Integer max);
 
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2012-09-27 08:00:40 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2012-09-27 10:11:02 +0000
@@ -256,6 +256,7 @@
         Set<Patient> patients = new HashSet<Patient>();
         patients.addAll( patientIdentifierService.getPatientsByIdentifier( searchText, 0, Integer.MAX_VALUE ) );
         patients.addAll( getPatientsByNames( searchText, 0, Integer.MAX_VALUE ) );
+        patients.addAll( getPatientsByPhone( searchText, 0, Integer.MAX_VALUE ) );
 
         // if an orgunit has been selected, filter out every patient that has a
         // different ou
@@ -548,8 +549,15 @@
         return patientStore.getProgramStageInstances( searchKeys, orgunit, min, max );
     }
 
+    @Override
+    public Collection<Patient> getPatientsByPhone( String phoneNumber, Integer min, Integer max )
+    {
+        return patientStore.getByPhoneNumber( phoneNumber, min, max );
+    }
+
     public Grid getScheduledEventsReport( List<String> searchKeys, OrganisationUnit orgunit, I18n i18n )
     {
+
         String startDate = "";
         String endDate = "";
         for ( String searchKey : searchKeys )
@@ -568,7 +576,7 @@
         {
             grid.setSubtitle( i18n.getString( "from" ) + " " + startDate + " " + i18n.getString( "to" ) + endDate );
         }
-        
+
         grid.addHeader( new GridHeader( "patientid", true, true ) );
         grid.addHeader( new GridHeader( i18n.getString( "first_name" ), false, true ) );
         grid.addHeader( new GridHeader( i18n.getString( "middle_name" ), false, true ) );
@@ -581,6 +589,7 @@
         grid.addHeader( new GridHeader( i18n.getString( "due_date" ), false, true ) );
 
         return patientStore.getPatientEventReport( grid, searchKeys, orgunit );
+
     }
 
 }

=== 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-09-27 09:35:24 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-09-27 10:11:02 +0000
@@ -137,6 +137,7 @@
     @SuppressWarnings( "unchecked" )
     @Override
     public Collection<Patient> get( String firstName, String middleName, String lastName, Date birthdate, String gender )
+
     {
         Criteria crit = getCriteria();
         Conjunction con = Restrictions.conjunction();
@@ -152,7 +153,6 @@
 
         con.add( Restrictions.eq( "gender", gender ) );
         con.add( Restrictions.eq( "birthDate", birthdate ) );
-
         crit.add( con );
 
         crit.addOrder( Order.asc( "firstName" ) );
@@ -326,7 +326,7 @@
 
         return jdbcTemplate.queryForInt( sql );
     }
-    
+
     @Override
     public Grid getPatientEventReport( Grid grid, List<String> searchKeys, OrganisationUnit orgunit )
     {
@@ -339,7 +339,7 @@
         SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
 
         GridUtils.addRows( grid, rowSet );
-        
+
         return grid;
     }
 
@@ -558,4 +558,42 @@
         
         return sql;
     }
+    @Override
+    public Collection<Patient> getByPhoneNumber( String phoneNumber, Integer min, Integer max )
+    {
+
+        List<Patient> patients = new ArrayList<Patient>();
+
+        String sql = "select patientid from patient " + "where lower( " + statementBuilder.getPatientsByPhone() + ") "
+            + "like '%" + phoneNumber + "%'";
+
+        if ( min != null && max != null )
+        {
+            sql += statementBuilder.limitRecord( min, max );
+        }
+        try
+        {
+            patients = jdbcTemplate.query( sql, new RowMapper<Patient>()
+            {
+
+                @Override
+                public Patient mapRow( ResultSet rs, int rowNum )
+                    throws SQLException
+                {
+
+                    return get( rs.getInt( 1 ) );
+                }
+
+            } );
+        }
+        catch ( Exception ex )
+        {
+            ex.printStackTrace();
+        }
+        return patients;
+
+    }
+
+
+
 }

=== 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-09-27 06:54:00 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2012-09-27 10:11:02 +0000
@@ -163,4 +163,6 @@
     String getAddDate( String dateField, int days );
     
     String getPatientFullName();
+    
+    String getPatientsByPhone();
 }

=== 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-09-27 06:54:00 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2012-09-27 10:11:02 +0000
@@ -326,4 +326,10 @@
     {
         return  "concat( firstname, \" \",middleName , \" \" , lastname)";
     }
+
+    @Override
+    public String getPatientsByPhone()
+    {
+        return "phoneNumber";
+    }
 }

=== 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-09-27 06:54:00 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2012-09-27 10:11:02 +0000
@@ -322,4 +322,7 @@
     {
         return  "concat( firstname, \" \",middleName , \" \" , lastname)";
     }
+    public String getPatientsByPhone(){
+        return "phoneNumber";
+    }
 }

=== 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-09-27 06:54:00 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2012-09-27 10:11:02 +0000
@@ -321,4 +321,8 @@
     {
         return  "firstname || ' ' || middleName || ' ' || lastname";
     }
+    
+    public String getPatientsByPhone(){
+        return "phoneNumber";
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java	2012-09-27 06:54:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java	2012-09-27 10:11:02 +0000
@@ -136,14 +136,14 @@
         {
             Patient patient = new Patient();
             patient.setBirthDateFromAge( age.intValue(), ageType );
-            
-            if( patient.getIntegerValueOfAge() > 100 )
+
+            if ( patient.getIntegerValueOfAge() > 100 )
             {
                 message = i18n.getString( "age_of_patient_must_be_less_or_equals_to_100" );
                 return INPUT;
             }
         }
-        
+
         if ( dobType != null && (dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED) )
         {
             birthDate = birthDate.trim();
@@ -189,8 +189,9 @@
         if ( !checkedDuplicate )
         {
             patients = patientService.getPatients( firstName, middleName, lastName, format.parseDate( birthDate ),
-                gender );
-            
+
+            gender );
+
             if ( patients != null && patients.size() > 0 )
             {
                 message = i18n.getString( "patient_duplicate" );
@@ -212,7 +213,7 @@
                         }
                     }
                 }
-                
+
                 if ( flagDuplicate )
                 {
                     return PATIENT_DUPLICATE;
@@ -265,11 +266,11 @@
                 if ( !underAge || (underAge && !idType.isRelated()) )
                 {
                     value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + idType.getId() );
-                    
+
                     if ( StringUtils.isNotBlank( value ) )
                     {
                         PatientIdentifier identifier = patientIdentifierService.get( idType, value );
-                        
+
                         if ( identifier != null
                             && (id == null || identifier.getPatient().getId().intValue() != id.intValue()) )
                         {

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2012-09-27 06:54:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2012-09-27 10:11:02 +0000
@@ -83,7 +83,7 @@
 tracking=Tracking
 find_beneficiary=Find Person
 activity_plan=Activity Plan
-search_by_name_or_id=Search By Name or ID
+search_by_name_or_id=Search By Name or ID or Phone Number
 select_orgunit=Select Organisation Unit
 all_orgunit=All Organisation Unit
 tracking_menu=Tracking Menu