← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4695: Error thrown when searching patients by identifier or name.

 

------------------------------------------------------------
revno: 4695
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-09-27 13:46:37 +0700
message:
  Error thrown when searching patients by identifier or name.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.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/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java	2011-09-21 08:33:55 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java	2011-09-27 06:46:37 +0000
@@ -155,7 +155,7 @@
     public Collection<Patient> searchPatients( List<Integer> patientAttributeIds, List<String> searchTexts, int min,
         int max )
     {
-        String hql = "SELECT DISTINCT pav.patient FROM PatientAttributeValue as pav WHERE pav.patient in ";
+        String hql = "SELECT DISTINCT p FROM Patient as p WHERE p in ";
         String end = "";
 
         int index = 0;
@@ -168,7 +168,7 @@
             index++;
         }
 
-        hql += " ORDER BY pav.value ASC";
+        hql += " ORDER BY p.id ASC";
 
         Query query = getQuery( hql + end ).setFirstResult( min ).setMaxResults( max );
 
@@ -177,7 +177,7 @@
 
     public int countSearchPatients( List<Integer> patientAttributeIds, List<String> searchTexts )
     {
-        String hql = "SELECT COUNT( DISTINCT pav.patient ) FROM PatientAttributeValue as pav WHERE pav.patient in ";
+        String hql = "SELECT COUNT( DISTINCT p ) FROM Patient as p WHERE p in ";
         String end = "";
 
         int index = 0;
@@ -236,7 +236,7 @@
 
             hql += " ( SELECT p" + index + " FROM Patient as p" + index + " JOIN p" + index
                 + ".identifiers as identifier" + index + " " + "WHERE lower(identifier" + index
-                + ".identifier)=lower(" + searchText + ") " + "OR (lower(p" + index
+                + ".identifier)=lower('" + searchText + "') " + "OR (lower(p" + index
                 + ".firstName) LIKE lower('%" + firstName + "%') " + "AND lower(p" + index + ".middleName) = lower('"
                 + middleName + "') " + "AND lower(p" + index + ".lastName) LIKE lower('%" + lastName + "%')) ";