=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientsByNameAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientsByNameAction.java 2011-01-20 02:12:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientsByNameAction.java 2011-01-21 09:18:56 +0000 @@ -80,7 +80,29 @@ public String execute() { - patients = new ArrayList( patientService.getPatients( fullName ) ); + int startIndex = fullName.indexOf( ' ' ); + int endIndex = fullName.lastIndexOf( ' ' ); + + String firstName = fullName.toString(); + String middleName = ""; + String lastName = ""; + + if( startIndex != -1 ) + { + firstName = fullName.substring( 0, startIndex ); + if ( startIndex == endIndex ) + { + middleName = ""; + lastName = fullName.substring( startIndex, fullName.length() ); + } + else + { + middleName = fullName.substring( startIndex + 1, endIndex ); + lastName = fullName.substring( endIndex, fullName.length() ); + } + } + + patients = new ArrayList( patientService.getPatients( firstName + " " + middleName + " " + lastName ) ); return SUCCESS; }