← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3271: Limit activities sent to mobile: Only activities which is started (current date > due date) and e...

 

------------------------------------------------------------
revno: 3271
committer: Tran Ng Minh Luan <Luan@MinhLuan-PC>
branch nick: dhis2
timestamp: Mon 2011-04-04 16:23:22 +0700
message:
  Limit activities sent to mobile: Only activities which is started (current date > due date) and expired date (due Date + maxAllowedInputDays) is not exceeded.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/DefaultActivityPlanService.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/activityplan/DefaultActivityPlanService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/DefaultActivityPlanService.java	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/DefaultActivityPlanService.java	2011-04-04 09:23:22 +0000
@@ -102,8 +102,12 @@
 
     public Collection<Activity> getCurrentActivitiesByProvider( OrganisationUnit organisationUnit )
     {
-        long time = System.currentTimeMillis();
-
+        Date today = new Date();
+        today.setHours( 0 );
+        today.setMinutes( 0 );
+        today.setSeconds( 0 );
+        long time = today.getTime();
+        
         List<Activity> items = new ArrayList<Activity>();
 
         List<ProgramInstance> programInstances = new ArrayList<ProgramInstance>();
@@ -115,32 +119,23 @@
             programInstances.addAll( programInstanceService.getProgramInstances( program, organisationUnit ) );
         }
 
-        Calendar expiredDate = Calendar.getInstance();
-
+        Calendar expiredDate = Calendar.getInstance(); 
+        
         for ( ProgramInstance programInstance : programInstances )
         {
             Set<ProgramStageInstance> programStageInstances = programInstance.getProgramStageInstances();
-            Inner: for ( ProgramStageInstance programStageInstance : programStageInstances )
+                for ( ProgramStageInstance programStageInstance : programStageInstances )
             {
                 if(!programStageInstance.isCompleted()){
-                    expiredDate.setTime( DateUtils.getDateAfterAddition( programStageInstance.getDueDate(),
-                        programStageInstance.getProgramInstance().getProgram().getMaxDaysAllowedInputData() ) );
-                    if ( programStageInstance.getDueDate().getTime() < time && expiredDate.getTimeInMillis() > time )
-                    {
-                        Activity activity = new Activity();
-                        activity.setBeneficiary( programInstance.getPatient() );
-                        activity.setTask( programStageInstance );
-                        activity.setDueDate( programStageInstance.getDueDate() );
-                        items.add( activity );
-                    }
-                    if ( programStageInstance.getDueDate().getTime() > time && expiredDate.getTimeInMillis() > time )
-                    {
-                        Activity activity = new Activity();
-                        activity.setBeneficiary( programInstance.getPatient() );
-                        activity.setTask( programStageInstance );
-                        activity.setDueDate( programStageInstance.getDueDate() );
-                        items.add( activity );
-                        break Inner;
+                    expiredDate.setTime( DateUtils.getDateAfterAddition( programStageInstance.getDueDate(), programStageInstance.getProgramInstance().getProgram().getMaxDaysAllowedInputData() ) );
+                    
+                    if ( programStageInstance.getDueDate().getTime() <= time && expiredDate.getTimeInMillis() > time )
+                    {
+                        Activity activity = new Activity();
+                        activity.setBeneficiary( programInstance.getPatient() );
+                        activity.setTask( programStageInstance );
+                        activity.setDueDate( programStageInstance.getDueDate() );
+                        items.add( activity );
                     }
                 }
             }