← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9565: minor fixed

 

------------------------------------------------------------
revno: 9565
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-01-21 15:13:02 +0700
message:
  minor fixed
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-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.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


--
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-10-02 06:23:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2013-01-21 08:13:02 +0000
@@ -217,4 +217,5 @@
 
     Collection<Patient> getPatientsByPhone( String phoneNumber, Integer min, Integer max );
     
+    Collection<Patient> getPatientByFullname( String fullName );
 }

=== 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-10-02 06:23:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2013-01-21 08:13:02 +0000
@@ -82,4 +82,6 @@
     
     Collection<Patient> getByPhoneNumber( String phoneNumber, Integer min, Integer max);
     
+    Collection<Patient> getByFullName( String fullName );
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-01-17 09:23:01 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-01-21 08:13:02 +0000
@@ -603,8 +603,8 @@
                 lastName = fullName.substring( endIndex + 1, fullName.length() );
             }
         }
-        List<Patient> patients = (List<Patient>) this.patientService.getPatientsByNames( firstName + middleName
-            + lastName, 0, 1 );
+        List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( firstName + middleName
+            + lastName);
 
         if ( patients.size() > 1 )
         {

=== 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-11-01 05:46:26 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2013-01-21 08:13:02 +0000
@@ -592,4 +592,10 @@
 
     }
 
+    @Override
+    public Collection<Patient> getPatientByFullname( String fullName )
+    {
+        return patientStore.getByFullName( fullName );
+    }
+
 }

=== 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	2013-01-14 06:36:46 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-01-21 08:13:02 +0000
@@ -108,7 +108,7 @@
 
         fullName = fullName.toLowerCase();
         String sql = "SELECT patientid FROM patient " + "where lower( " + statementBuilder.getPatientFullName() + ") "
-            + "='" + fullName + "'";
+            + "like '%" + fullName + "%'";
 
         if ( min != null && max != null )
         {
@@ -567,5 +567,33 @@
 
         return query.list();
     }
+
+    @Override
+    public Collection<Patient> getByFullName( String fullName )
+    {
+        List<Patient> patients = new ArrayList<Patient>();
+
+        fullName = fullName.toLowerCase();
+        String sql = "SELECT patientid FROM patient " + "where lower( " + statementBuilder.getPatientFullName() + ") "
+            + "='" + fullName + "'";
+
+        try
+        {
+            patients = jdbcTemplate.query( sql, new RowMapper<Patient>()
+            {
+                public Patient mapRow( ResultSet rs, int rowNum )
+                    throws SQLException
+                {
+                    return get( rs.getInt( 1 ) );
+                }
+            } );
+        }
+        catch ( Exception ex )
+        {
+            ex.printStackTrace();
+        }
+
+        return patients;
+    }
     
 }