← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8293: Error when to search persons by program.

 

------------------------------------------------------------
revno: 8293
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-09-27 20:45:15 +0700
message:
  Error when to search persons by program.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/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-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 13:00:26 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-09-27 13:45:15 +0000
@@ -516,7 +516,7 @@
         {
             sql += "(select organisationunitid from patient where patientid=p.patientid and organisationunitid = "
                 + orgunit.getId() + " ) as orgunitid,";
-            otherWhere += otherWhere + operator + "orgunitid=" + orgunit.getId();
+            otherWhere += operator + "orgunitid=" + orgunit.getId();
         }
 
         sql = sql.substring( 0, sql.length() - 1 ) + " "; // Removing last comma
@@ -528,7 +528,7 @@
             sql = sql + subSQL + from + " inner join programinstance pgi on " + " (pgi.patientid=p.patientid) "
                 + " inner join programstageinstance psi on " + " (psi.programinstanceid=pgi.programinstanceid) "
                 + " inner join programstage pgs on (pgs.programstageid=psi.programstageid) ";
-            if( isPriorityEvent )
+            if ( isPriorityEvent )
             {
                 sql += " inner join patientattributevalue pav on p.patientid=pav.patientid ";
             }
@@ -558,41 +558,20 @@
         
         return sql;
     }
+
+    @SuppressWarnings( "unchecked" )
     @Override
     public Collection<Patient> getByPhoneNumber( String phoneNumber, Integer min, Integer max )
     {
-
-        List<Patient> patients = new ArrayList<Patient>();
-
-        String sql = "select patientid from patient where phoneNumber like '%" + phoneNumber + "%'";
-
+        String hql = "select p from Patient p where p.phoneNumber like '%" + phoneNumber + "%'";
+        Query query = getQuery( hql );
+        
         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;
-
+            query.setFirstResult( min ).setMaxResults( max );
+        }
+
+        return query.list();
     }
-
-
-
+    
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-09-27 10:20:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-09-27 13:45:15 +0000
@@ -235,7 +235,7 @@
 rightSide=Right side
 in_range_due_date_plus_or_minus=In range due date +/-
 activity_planning=Visit Schedule
-intro_activity_planning=Visit Schedule provide the user at a facility or in an area with a list of upcoming visits. to better plan for daily/weekly activities
+intro_activity_planning=Visit Schedule provides for the user at a facility or in an area a list of upcoming visits to better plan for daily/weekly activities.
 back_to_main_menu=Back to main menu
 of=of
 show_all_items=Show all items