← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7334: Error when loading visit plans.

 

------------------------------------------------------------
revno: 7334
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-20 15:57:27 +0700
message:
  Error when loading visit plans.
modified:
  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/jdbc/JdbcActivityPlanStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.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	2012-06-15 04:30:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/DefaultActivityPlanService.java	2012-06-20 08:57:27 +0000
@@ -289,19 +289,22 @@
 
     public Collection<Activity> getActivitiesByProvider( OrganisationUnit organisationUnit, int min, int max )
     {
-        Collection<Integer> programStageInstanceIds = activityPlanStore.getActivitiesByProvider(
-            organisationUnit.getId(), min, max );
+        Collection<Integer> programStageInstanceIds = activityPlanStore.getActivitiesByProvider( organisationUnit
+            .getId(), min, max );
 
         Collection<Activity> activities = new ArrayList<Activity>();
 
-        for ( Integer id : programStageInstanceIds )
+        if ( programStageInstanceIds != null )
         {
-            ProgramStageInstance instance = programStageInstanceService.getProgramStageInstance( id );
-            Activity activity = new Activity();
-            activity.setBeneficiary( instance.getProgramInstance().getPatient() );
-            activity.setTask( instance );
-            activity.setDueDate( instance.getDueDate() );
-            activities.add( activity );
+            for ( Integer id : programStageInstanceIds )
+            {
+                ProgramStageInstance instance = programStageInstanceService.getProgramStageInstance( id );
+                Activity activity = new Activity();
+                activity.setBeneficiary( instance.getProgramInstance().getPatient() );
+                activity.setTask( instance );
+                activity.setDueDate( instance.getDueDate() );
+                activities.add( activity );
+            }
         }
 
         return activities;

=== 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	2012-03-19 07:56:03 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/jdbc/JdbcActivityPlanStore.java	2012-06-20 08:57:27 +0000
@@ -86,14 +86,12 @@
         {
             Statement statement = holder.getStatement();
 
-            // String sql = statementBuilder.getActivityPlan( orgunitId, min,
-            // max );
-            String sql = "SELECT psi.programstageinstanceid " + "FROM programstageinstance psi "
+            String sql = "SELECT distinct psi.programstageinstanceid " + "FROM programstageinstance psi "
                 + "INNER JOIN programinstance pi " + "ON pi.programinstanceid = psi.programinstanceid "
                 + "INNER JOIN programstage ps " + "ON ps.programstageid=psi.programstageid "
                 + "INNER JOIN program_organisationunits po " + "ON po.programid=pi.programid "
                 + "INNER JOIN program pg " + "ON po.programid=pg.programid " + "WHERE pi.completed = FALSE  "
-                + "AND pg.singleEvent=FALSE " + "AND po.organisationunitid = " + orgunitId
+                + "AND pg.type=1 " + "AND po.organisationunitid = " + orgunitId
                 + " AND psi.completed = FALSE " + "AND ps.stageinprogram in ( SELECT min(ps1.stageinprogram) "
                 + "FROM programstageinstance psi1 " + "INNER JOIN programinstance pi1 "
                 + "ON pi1.programinstanceid = psi1.programinstanceid " + "INNER JOIN programstage ps1 "
@@ -133,11 +131,12 @@
         {
             Statement statement = holder.getStatement();
 
-            String sql = "SELECT count(psi.programstageinstanceid) " + "FROM programstageinstance psi "
+            String sql = "SELECT count(distinct psi.programstageinstanceid) " + "FROM programstageinstance psi "
                 + "INNER JOIN programinstance pi " + "ON pi.programinstanceid = psi.programinstanceid "
                 + "INNER JOIN programstage ps " + "ON ps.programstageid=psi.programstageid "
                 + "INNER JOIN program_organisationunits po " + "ON po.programid=pi.programid "
-                + "WHERE pi.completed = FALSE  " + "AND po.organisationunitid = " + orgunitId
+                + "INNER JOIN program pg " + "ON po.programid=pg.programid " + "WHERE pi.completed = FALSE  "
+                + "AND pg.type=1 " + "AND po.organisationunitid = " + orgunitId
                 + " AND psi.completed = FALSE " + "AND ps.stageinprogram in ( SELECT min(ps1.stageinprogram) "
                 + "FROM programstageinstance psi1 " + "INNER JOIN programinstance pi1 "
                 + "ON pi1.programinstanceid = psi1.programinstanceid " + "INNER JOIN programstage ps1 "

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java	2012-05-23 15:02:50 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java	2012-06-20 08:57:27 +0000
@@ -128,19 +128,4 @@
         return programStore.get( type, orgunit );
     }
 
-//    public Collection<Program> getPrograms( boolean singleEvent )
-//    {
-//        return programStore.get( singleEvent );
-//    }
-//
-//    public Collection<Program> getPrograms( boolean singleEvent, boolean anonymous )
-//    {
-//        return programStore.get( singleEvent, anonymous );
-//    }
-//    
-//    public Collection<Program> getPrograms( boolean singleEvent, boolean anonymous, OrganisationUnit orgunit )
-//    {
-//        return programStore.get( singleEvent, anonymous, orgunit );
-//    }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java	2012-05-23 15:02:50 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java	2012-06-20 08:57:27 +0000
@@ -58,32 +58,4 @@
         return getCriteria( Restrictions.eq( "type", type ) ).createAlias( "organisationUnits", "orgunit" ).add(
             Restrictions.eq( "orgunit.id", orgunit.getId() ) ).list();
     }
-
-    // @SuppressWarnings( "unchecked" )
-    // @Override
-    // public Collection<Program> get( boolean singleEvent )
-    // {
-    // return getCriteria( Restrictions.eq( "singleEvent", singleEvent
-    // )).list();
-    // }
-    //
-    // @SuppressWarnings( "unchecked" )
-    // @Override
-    // public Collection<Program> get( boolean singleEvent, boolean anonymous )
-    // {
-    // return getCriteria( Restrictions.eq( "singleEvent", singleEvent ),
-    // Restrictions.eq( "anonymous", anonymous ) ).list();
-    // }
-    //
-    // @SuppressWarnings( "unchecked" )
-    // @Override
-    // public Collection<Program> get( boolean singleEvent, boolean anonymous,
-    // OrganisationUnit orgunit )
-    // {
-    // return getCriteria( Restrictions.eq( "singleEvent", singleEvent ),
-    // Restrictions.eq( "anonymous", anonymous ) ).createAlias(
-    // "organisationUnits", "orgunit" ).add(
-    // Restrictions.eq( "orgunit.id", orgunit.getId() ) ).list();
-    // }
-
 }