← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8443: [mobile] fix activity plan

 

------------------------------------------------------------
revno: 8443
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Tue 2012-10-09 11:45:29 +0700
message:
  [mobile] fix activity plan
modified:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/main.vm


--
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-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2012-10-03 03:46:16 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2012-10-09 04:45:29 +0000
@@ -37,7 +37,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.api.mobile.ActivityReportingService;
@@ -59,6 +58,7 @@
 import org.hisp.dhis.patient.PatientIdentifierService;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientMobileSetting;
+import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
@@ -88,7 +88,9 @@
 
     private ProgramStageInstanceService programStageInstanceService;
 
-//    private ActivityPlanService activityPlanService;
+    // private ActivityPlanService activityPlanService;
+
+    private PatientService patientService;
 
     private PatientAttributeValueService patientAttValueService;
 
@@ -111,30 +113,38 @@
     @Override
     public ActivityPlan getCurrentActivityPlan( OrganisationUnit unit, String localeString )
     {
-        long time = System.currentTimeMillis();
+        Calendar cal = Calendar.getInstance();
+        cal.add( Calendar.DATE, 30 );
+
+        long upperBound = cal.getTime().getTime();
+
+        cal.add( Calendar.DATE, -60 );
+        long lowerBound = cal.getTime().getTime();
 
         List<Activity> items = new ArrayList<Activity>();
+        Collection<Patient> patients = patientService.getPatients( unit, null, null );
+
+        for ( Patient patient : patients )
+        {
+            for ( ProgramStageInstance programStageInstance : programStageInstanceService.getProgramStageInstances(
+                patient, false ) )
+            {
+                if ( programStageInstance.getDueDate().getTime() >= lowerBound
+                    && programStageInstance.getDueDate().getTime() <= upperBound )
+                {
+                    items.add( getActivity( programStageInstance, false ) );
+                }
+            }
+        }
 
         this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy( true ) );
 
-//        Collection<org.hisp.dhis.activityplan.Activity> activities = activityPlanService
-//            .getCurrentActivitiesByProvider( unit );
-//
-//        for ( org.hisp.dhis.activityplan.Activity activity : activities )
-//        {
-//            items.add( getActivity( activity.getTask(), activity.getDueDate().getTime() < time ) );
-//        }
-//
-//        if ( items.isEmpty() )
-//        {
-//            return null;
-//        }
-//
-//        Collections.sort( items, activityComparator );
+        if ( items.isEmpty() )
+        {
+            return null;
+        }
 
-        if ( DEBUG )
-            log.debug( "Found " + items.size() + " current activities in " + (System.currentTimeMillis() - time)
-                + " ms." );
+        Collections.sort( items, activityComparator );
 
         return new ActivityPlan( items );
     }
@@ -142,30 +152,27 @@
     @Override
     public ActivityPlan getAllActivityPlan( OrganisationUnit unit, String localeString )
     {
-//        long time = System.currentTimeMillis();
 
         List<Activity> items = new ArrayList<Activity>();
+        Collection<Patient> patients = patientService.getPatients( unit, null, null );
+
+        for ( Patient patient : patients )
+        {
+            for ( ProgramStageInstance programStageInstance : programStageInstanceService.getProgramStageInstances(
+                patient, false ) )
+            {
+                items.add( getActivity( programStageInstance, false ) );
+            }
+        }
 
         this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy( true ) );
 
-//        Collection<org.hisp.dhis.activityplan.Activity> activities = activityPlanService.getActivitiesByProvider( unit );
-//
-//        for ( org.hisp.dhis.activityplan.Activity activity : activities )
-//        {
-//            if ( activity.getDueDate() != null )
-//            {
-//                items.add( getActivity( activity.getTask(), activity.getDueDate().getTime() < time ) );
-//            }
-//
-//        }
-
         if ( items.isEmpty() )
         {
             return null;
         }
 
         Collections.sort( items, activityComparator );
-
         return new ActivityPlan( items );
     }
 
@@ -294,7 +301,7 @@
         activity.setDueDate( instance.getDueDate() );
         activity.setTask( getTask( instance ) );
         activity.setLate( late );
-        activity.setExpireDate( DateUtils.getDateAfterAddition( instance.getDueDate(), 0) );
+        activity.setExpireDate( DateUtils.getDateAfterAddition( instance.getDueDate(), 0 ) );
 
         return activity;
     }
@@ -499,10 +506,11 @@
         this.patientMobileSettingService = patientMobileSettingService;
     }
 
-//    public void setActivityPlanService( org.hisp.dhis.activityplan.ActivityPlanService activityPlanService )
-//    {
-//        this.activityPlanService = activityPlanService;
-//    }
+    // public void setActivityPlanService(
+    // org.hisp.dhis.activityplan.ActivityPlanService activityPlanService )
+    // {
+    // this.activityPlanService = activityPlanService;
+    // }
 
     public PatientMobileSetting getSetting()
     {
@@ -535,4 +543,10 @@
         this.patientIdentifierService = patientIdentifierService;
     }
 
+    @Required
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml	2012-09-14 05:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml	2012-10-09 04:45:29 +0000
@@ -24,6 +24,7 @@
     <property name="dataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
     <property name="patientMobileSettingService" ref="org.hisp.dhis.mobile.service.PatientMobileSettingService" />
     <property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
+	<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
   </bean>
 
   <bean id="org.hisp.dhis.mobile.api.IProgramService" class="org.hisp.dhis.mobile.service.DefaultProgramService">

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventFormAction.java	2012-10-03 07:43:08 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventFormAction.java	2012-10-09 04:45:29 +0000
@@ -34,8 +34,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
-
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientService;

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java	2012-10-03 07:43:08 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java	2012-10-09 04:45:29 +0000
@@ -34,9 +34,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-
 import javax.servlet.http.HttpServletRequest;
-
 import org.apache.struts2.ServletActionContext;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
@@ -58,7 +56,6 @@
 import org.hisp.dhis.program.ProgramStageInstanceService;
 import org.hisp.dhis.util.ContextUtils;
 import org.hisp.dhis.util.SessionUtils;
-
 import com.opensymphony.xwork2.Action;
 import com.opensymphony.xwork2.ActionContext;
 

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/main.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/main.vm	2012-09-21 14:54:46 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/main.vm	2012-10-09 04:45:29 +0000
@@ -11,7 +11,7 @@
 <div id="wrap">
 
 <div id="header">
-	<img src="../dhis-web-commons/security/logo_mobile.jpg" alt="DHIS2" width="47" height="20">
+	<img src="../dhis-web-commons/security/logo_mobile.png" alt="DHIS2" width="64" height="20">
 </div>
 
 <div id="content" align="center" style="text-align: left;">