← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20889: minor fix

 

------------------------------------------------------------
revno: 20889
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-10-29 10:16:11 +0700
message:
  minor fix
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.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-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2015-10-23 03:41:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2015-10-29 03:16:11 +0000
@@ -516,18 +516,21 @@
     @Override
     public boolean canAutoCompleteProgramInstanceStatus( ProgramInstance programInstance )
     {
-        Set<ProgramStageInstance> stageInstances = programInstance.getProgramStageInstances();
+        Set<ProgramStageInstance> programStageInstances = new HashSet<>( programInstance.getProgramStageInstances() );
+        Set<ProgramStage> programStages = new HashSet<>();
 
-        for ( ProgramStageInstance stageInstance : stageInstances )
+        for ( ProgramStageInstance programStageInstance : programStageInstances )
         {
-            if ( (!stageInstance.isCompleted() && stageInstance.getStatus() != EventStatus.SKIPPED)
-                || stageInstance.getProgramStage().getRepeatable() )
+            if ( (!programStageInstance.isCompleted() && programStageInstance.getStatus() != EventStatus.SKIPPED)
+                || programStageInstance.getProgramStage().getRepeatable() )
             {
                 return false;
             }
+
+            programStages.add( programStageInstance.getProgramStage() );
         }
 
-        return true;
+        return programStages.size() != programInstance.getProgram().getProgramStages().size();
     }
 
     @Override