← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7837: Don't search patients which full-name has two words.

 

------------------------------------------------------------
revno: 7837
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-08-02 17:32:32 +0700
message:
  Don't search patients which full-name has two words.
modified:
  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-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-08-01 08:49:36 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-08-02 10:32:32 +0000
@@ -318,7 +318,16 @@
             else if ( keys[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) )
             {
                 patientWhere = patientOperator + "( ( lower( " + statementBuilder.getPatientFullName() + " ) like '%" + id
-                    + "%' ) or lower(pi.identifier)='" + id + "') ";
+                    + "%' ) or lower(pi.identifier)='" + id + "' ";
+                
+                String[] keyValues = id.split( " " );
+                if( keyValues.length==2)
+                {
+                    String otherId = keyValues[0] + "  " + keyValues[1]; 
+                    patientWhere += " or lower( " + statementBuilder.getPatientFullName() + " ) like '%" + otherId
+                        + "%'  ";
+                }
+                patientWhere += ")"; 
                 patientOperator = " and ";
                 hasIdentifier = true;
             }