=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/DefaultActivityPlanService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/DefaultActivityPlanService.java 2011-05-23 06:10:58 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/DefaultActivityPlanService.java 2011-09-28 07:00:14 +0000 @@ -371,7 +371,6 @@ for ( ProgramInstance programInstance : programInstances ) { - Program program = programInstance.getProgram(); ProgramStage nextStage = program.getProgramStageByStage( visitsByProgramInstances.get( programInstance === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/jdbc/JdbcActivityPlanStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/jdbc/JdbcActivityPlanStore.java 2011-05-23 06:10:58 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/jdbc/JdbcActivityPlanStore.java 2011-09-28 07:00:14 +0000 @@ -138,8 +138,7 @@ "INNER JOIN program_organisationunits po1 " + "ON po1.programid=pi1.programid " + "WHERE pi1.completed = FALSE " + - "AND po1.organisationunitid = " + orgunitId + " AND psi1.completed = FALSE ) " + - "ORDER BY ps.stageinprogram"; + "AND po1.organisationunitid = " + orgunitId + " AND psi1.completed = FALSE ) "; ResultSet resultSet = statement.executeQuery( sql ); if(resultSet.next()) === 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 2011-08-01 18:58:07 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2011-09-28 07:00:14 +0000 @@ -330,7 +330,7 @@ @Override public Collection sortPatientsByAttribute( Collection patients, PatientAttribute patientAttribute ) { - List patientsSortedByAttribute = new ArrayList(); +// List patientsSortedByAttribute = new ArrayList(); Collection sortedPatients = new ArrayList(); @@ -341,14 +341,15 @@ Collection patientAttributeValues = patientAttributeValueService .getPatientAttributeValues( patients ); - + if ( patientAttributeValues != null ) - { + { for ( PatientAttributeValue patientAttributeValue : patientAttributeValues ) { if ( patientAttribute == patientAttributeValue.getPatientAttribute() ) { - patientsSortedByAttribute.add( patientAttributeValue ); + sortedPatients.add( patientAttributeValue.getPatient() ); + patients.remove( patientAttributeValue.getPatient() ); } } } @@ -357,16 +358,9 @@ // Make sure all patients are in the sorted list - because all // patients might not have the sorting attribute/value // --------------------------------------------------------------------- - - for( PatientAttributeValue patientAttributeValue : patientsSortedByAttribute ) - { - sortedPatients.add( patientAttributeValue.getPatient() ); - } - - patients.removeAll( patientsSortedByAttribute ); - + sortedPatients.addAll( patients ); - + return sortedPatients; } @@ -469,7 +463,7 @@ { return patientStore.countGetPatientsByOrgUnitProgram( organisationUnit, program ); } - + @Override public Object getObjectValue( String property, String value, I18nFormat format ) { === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/visitplan/SearchVisitPlanAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/visitplan/SearchVisitPlanAction.java 2011-05-23 06:10:58 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/visitplan/SearchVisitPlanAction.java 2011-09-28 07:00:14 +0000 @@ -213,10 +213,7 @@ if ( sortingAttributeId != null ) { sortingAttribute = patientAttributeService.getPatientAttribute( sortingAttributeId ); - } - - if ( sortingAttribute != null ) - { + sortedPatients = patientService.sortPatientsByAttribute( patientsToBeVisited, sortingAttribute ); } else