dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12211
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3706: Fix bug: Visitplans are shown with completed-programStageIsntance as "true".
------------------------------------------------------------
revno: 3706
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-05-23 13:10:58 +0700
message:
Fix bug: Visitplans are shown with completed-programStageIsntance as "true".
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/activityplan/ActivityPlanStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/jdbc/
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/jdbc/JdbcActivityPlanStore.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/activityplan/ActivityPlanService.java
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/patient/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java
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/webapp/dhis-web-caseentry/javascript/report.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.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-api/src/main/java/org/hisp/dhis/activityplan/ActivityPlanService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/activityplan/ActivityPlanService.java 2011-03-22 04:36:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/activityplan/ActivityPlanService.java 2011-05-23 06:10:58 +0000
@@ -20,6 +20,8 @@
String ID = ActivityPlanService.class.getName();
Collection<Activity> getActivitiesByProvider( OrganisationUnit organisationUnit );
+
+ Collection<Activity> getActivitiesByProvider( OrganisationUnit organisationUnit, int min, int max );
Collection<Activity> getActivitiesByProvider( OrganisationUnit organisationUnit, Collection<Program> programs );
@@ -34,5 +36,7 @@
Collection<Activity> getActivitiesWithInDate( Date startDate, Date endDate );
Collection<Activity> getCurrentActivitiesByProvider( OrganisationUnit organisationUnit );
+
+ int countActivitiesByProvider ( OrganisationUnit organisationUnit );
}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/activityplan/ActivityPlanStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/activityplan/ActivityPlanStore.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/activityplan/ActivityPlanStore.java 2011-05-23 06:10:58 +0000
@@ -0,0 +1,19 @@
+/**
+ *
+ */
+package org.hisp.dhis.activityplan;
+
+import java.util.Collection;
+
+/**
+ * @author abyotag_adm
+ *
+ */
+public interface ActivityPlanStore
+{
+ String ID = ActivityPlanStore.class.getName();
+
+ Collection<Integer> getActivitiesByProvider( Integer orgunitId, int max, int min );
+
+ int countActivitiesByProvider ( Integer orgunitId );
+}
=== 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-04-28 07:10:33 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/DefaultActivityPlanService.java 2011-05-23 06:10:58 +0000
@@ -61,6 +61,13 @@
// Dependencies
// -------------------------------------------------------------------------
+ private ActivityPlanStore activityPlanStore;
+
+ public void setActivityPlanStore( ActivityPlanStore activityPlanStore )
+ {
+ this.activityPlanStore = activityPlanStore;
+ }
+
private ProgramService programService;
public void setProgramService( ProgramService programService )
@@ -103,37 +110,6 @@
public Collection<Activity> getCurrentActivitiesByProvider( OrganisationUnit organisationUnit )
{
- // long time = PeriodType.createCalendarInstance().getTime().getTime();
- //
- // List<Activity> items = new ArrayList<Activity>();
- //
- // Calendar expiredDate = Calendar.getInstance();
- //
- // Collection<ProgramStageInstance> programStageInstances =
- // programStageInstanceService.get( organisationUnit,
- // null, null, false );
- //
- // for ( ProgramStageInstance programStageInstance :
- // programStageInstances )
- // {
- // expiredDate.setTime( DateUtils.getDateAfterAddition(
- // programStageInstance.getDueDate(),
- // programStageInstance.getProgramInstance().getProgram().getMaxDaysAllowedInputData()
- // ) );
- // // TODO compare with date.before
- // if ( programStageInstance.getDueDate().getTime() <= time &&
- // expiredDate.getTimeInMillis() > time )
- // {
- // Activity activity = new Activity();
- // activity.setBeneficiary(
- // programStageInstance.getProgramInstance().getPatient() );
- // activity.setTask( programStageInstance );
- // activity.setDueDate( programStageInstance.getDueDate() );
- // items.add( activity );
- // }
- // }
- // return items;
-
long time = PeriodType.createCalendarInstance().getTime().getTime();
List<Activity> items = new ArrayList<Activity>();
@@ -308,6 +284,31 @@
}
+
+ public Collection<Activity> getActivitiesByProvider( OrganisationUnit organisationUnit, int min, int max )
+ {
+ Collection<Integer> programStageInstanceIds = activityPlanStore.getActivitiesByProvider ( organisationUnit.getId(), min, max);
+
+ Collection<Activity> activities = new ArrayList<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;
+ }
+
+ public int countActivitiesByProvider ( OrganisationUnit organisationUnit )
+ {
+ return activityPlanStore.countActivitiesByProvider( organisationUnit.getId() );
+ }
+
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
=== added directory 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/jdbc'
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/jdbc/JdbcActivityPlanStore.java 2011-05-23 06:10:58 +0000
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.activityplan.jdbc;
+
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.amplecode.quick.StatementHolder;
+import org.amplecode.quick.StatementManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.activityplan.ActivityPlanStore;
+import org.hisp.dhis.jdbc.StatementBuilder;
+import org.hisp.dhis.patient.startup.TableAlteror;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ JdbcActivityPlanStore.java May 22, 2011 7:52:03 PM $
+ *
+ */
+public class JdbcActivityPlanStore
+ implements ActivityPlanStore
+{
+ private static final Log log = LogFactory.getLog( TableAlteror.class );
+
+ // -------------------------------------------------------------------------
+ // Dependency
+ // -------------------------------------------------------------------------
+
+ private StatementManager statementManager;
+
+ private StatementBuilder statementBuilder;
+
+ // -------------------------------------------------------------------------
+ // Setters
+ // -------------------------------------------------------------------------
+
+ public void setStatementManager( StatementManager statementManager )
+ {
+ this.statementManager = statementManager;
+ }
+
+ public void setStatementBuilder( StatementBuilder statementBuilder )
+ {
+ this.statementBuilder = statementBuilder;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation Methods
+ // -------------------------------------------------------------------------
+
+ @Override
+ public Collection<Integer> getActivitiesByProvider( Integer orgunitId, int min, int max )
+ {
+ StatementHolder holder = statementManager.getHolder();
+
+ Collection<Integer> programStageInstanceIds = new HashSet<Integer>();
+ try
+ {
+ Statement statement = holder.getStatement();
+
+ String sql = statementBuilder.getActivityPlan( orgunitId, min, max );
+
+ ResultSet resultSet = statement.executeQuery( sql );
+
+ while ( resultSet.next() )
+ {
+ programStageInstanceIds.add( resultSet.getInt( 1 ) );
+ }
+
+ return programStageInstanceIds;
+
+ }
+ catch ( Exception ex )
+ {
+ log.debug( ex );
+
+ return null;
+ }
+ finally
+ {
+ holder.close();
+ }
+ }
+
+ @Override
+ public int countActivitiesByProvider( Integer orgunitId )
+ {
+ StatementHolder holder = statementManager.getHolder();
+
+ try
+ {
+ Statement statement = holder.getStatement();
+
+ String sql = "SELECT count(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 + " 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 " +
+ "ON ps1.programstageid=psi1.programstageid " +
+ "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";
+
+ ResultSet resultSet = statement.executeQuery( sql );
+ if(resultSet.next())
+ {
+ return resultSet.getInt( 1 );
+ }
+
+ return 0;
+ }
+ catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ return 0;
+ }
+ finally
+ {
+ holder.close();
+ }
+ }
+
+}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2011-05-02 14:48:05 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2011-05-23 06:10:58 +0000
@@ -29,6 +29,8 @@
import java.sql.ResultSet;
import java.sql.Statement;
+import java.util.Collection;
+import java.util.HashSet;
import org.amplecode.quick.StatementHolder;
import org.amplecode.quick.StatementManager;
@@ -101,9 +103,11 @@
executeSql( "UPDATE dataset SET mobile = false WHERE mobile is null" );
executeSql( "UPDATE dataset SET version = 1 WHERE version is null" );
-
+
updateSingleProgramValidation();
+ updateStageInProgram();
+
}
// -------------------------------------------------------------------------
@@ -147,16 +151,15 @@
private void updateSingleProgramValidation()
{
StatementHolder holder = statementManager.getHolder();
-
+
int optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo().getId();
-
+
try
{
Statement statement = holder.getStatement();
- ResultSet isUpdated = statement
- .executeQuery( "SELECT * FROM INFORMATION_SCHEMA.COLUMNS " +
- "WHERE TABLE_NAME = 'programstage_dataelement_validation'" );
+ ResultSet isUpdated = statement.executeQuery( "SELECT * FROM INFORMATION_SCHEMA.COLUMNS "
+ + "WHERE TABLE_NAME = 'programstage_dataelement_validation'" );
if ( isUpdated.next() )
{
@@ -166,29 +169,35 @@
int max = rsCount.getInt( 1 ) + 1;
ResultSet resultSet = statement
- .executeQuery( "SELECT pdv.description, pdv.leftprogramstageid, pdv.leftdataelementid, "+
- "pdv.rightprogramstageid, pdv.rightdataelementid, " +
- "pdv.operator, ps.programid "+
- "FROM programstage_dataelement_validation pdv "+
- "INNER JOIN programstage_dataelements pd "+
- "ON (pdv.leftprogramstageid=pd.dataelementid AND "+
- "pdv.leftdataelementid=pd.programstageid) "+
- "INNER JOIN programstage ps "+
- "ON pd.programstageid=ps.programstageid" );
+ .executeQuery( "SELECT pdv.description, pdv.leftprogramstageid, pdv.leftdataelementid, "
+ + "pdv.rightprogramstageid, pdv.rightdataelementid, " + "pdv.operator, ps.programid "
+ + "FROM programstage_dataelement_validation pdv " + "INNER JOIN programstage_dataelements pd "
+ + "ON (pdv.leftprogramstageid=pd.dataelementid AND "
+ + "pdv.leftdataelementid=pd.programstageid) " + "INNER JOIN programstage ps "
+ + "ON pd.programstageid=ps.programstageid" );
while ( resultSet.next() )
{
max++;
- String leftSide = "[" + resultSet.getString( 2 ) + "." + resultSet.getString( 3 ) + "." + optionCombo + "]";
- String rightSide = "[" + resultSet.getString( 4 ) + "." + resultSet.getString( 5 ) + "." + optionCombo + "]";
- String operator = resultSet.getInt( 6 ) > 0 ? ">" : ( resultSet.getInt( 6 ) < 0 ) ? "<" : "==";
-
+ String leftSide = "[" + resultSet.getString( 2 ) + "." + resultSet.getString( 3 ) + "."
+ + optionCombo + "]";
+ String rightSide = "[" + resultSet.getString( 4 ) + "." + resultSet.getString( 5 ) + "."
+ + optionCombo + "]";
+ String operator = resultSet.getInt( 6 ) > 0 ? ">" : (resultSet.getInt( 6 ) < 0) ? "<" : "==";
+
String fomular = leftSide + operator + rightSide;
-
- executeSql( "INSERT INTO programvalidation (programvalidationid, description,leftSide, rightSide, programid )" +
- "VALUES ( " + max + ",'" + resultSet.getString( 1 ) + "', '" + fomular + "', '1==1', " + resultSet.getInt( 7 ) + ")" );
+
+ executeSql( "INSERT INTO programvalidation (programvalidationid, description,leftSide, rightSide, programid )"
+ + "VALUES ( "
+ + max
+ + ",'"
+ + resultSet.getString( 1 )
+ + "', '"
+ + fomular
+ + "', '1==1', "
+ + resultSet.getInt( 7 ) + ")" );
}
-
+
executeSql( "DROP TABLE programstage_dataelement_validation" );
}
}
@@ -202,6 +211,75 @@
}
}
+ private void updateStageInProgram()
+ {
+ StatementHolder holder = statementManager.getHolder();
+
+ try
+ {
+ Statement statement = holder.getStatement();
+
+ Collection<Integer> programIds = getPrograms();
+
+ for ( Integer programId : programIds )
+ {
+ ResultSet resultSet = statement.executeQuery( "SELECT programstageid "
+ + "FROM programstage WHERE programid = " + programId );
+
+ int index = 1;
+ while ( resultSet.next() )
+ {
+ executeSql( "UPDATE programstage SET stageinprogram = " + index + " WHERE programstageid = "
+ + resultSet.getInt( 1 ) );
+ index++;
+ }
+ }
+ }
+ catch ( Exception ex )
+ {
+ log.debug( ex );
+ }
+ finally
+ {
+ holder.close();
+ }
+ }
+
+ private Collection<Integer> getPrograms()
+ {
+ Collection<Integer> result = new HashSet<Integer>();
+
+ StatementHolder holder = statementManager.getHolder();
+
+ try
+ {
+ Statement statement = holder.getStatement();
+
+ ResultSet rsMax = statement.executeQuery( "SELECT max(stageinprogram), programid "
+ + "FROM programstage GROUP BY programid" );
+
+ while ( rsMax.next() )
+ {
+ if ( rsMax.getInt( 1 ) == 0 )
+ {
+ result.add( rsMax.getInt( 2 ) );
+ }
+ }
+
+ return result;
+ }
+ catch ( Exception ex )
+ {
+ log.debug( ex );
+
+ return null;
+ }
+ finally
+ {
+ holder.close();
+ }
+ }
+
private int executeSql( String sql )
{
try
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2011-04-29 07:41:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2011-05-23 06:10:58 +0000
@@ -15,6 +15,12 @@
<property name="sessionFactory" ref="sessionFactory" />
</bean>
+ <bean id="org.hisp.dhis.activityplan.jdbc.JdbcActivityPlanStore"
+ class="org.hisp.dhis.activityplan.jdbc.JdbcActivityPlanStore">
+ <property name="statementManager" ref="statementManager" />
+ <property name="statementBuilder" ref="statementBuilder"/>
+ </bean>
+
<bean id="org.hisp.dhis.relationship.RelationshipStore"
class="org.hisp.dhis.relationship.hibernate.HibernateRelationshipStore">
<property name="clazz" value="org.hisp.dhis.relationship.Relationship" />
@@ -144,6 +150,8 @@
ref="org.hisp.dhis.program.ProgramInstanceService" />
<property name="programService"
ref="org.hisp.dhis.program.ProgramService" />
+ <property name="activityPlanStore"
+ ref="org.hisp.dhis.activityplan.jdbc.JdbcActivityPlanStore" />
</bean>
<bean id="org.hisp.dhis.caseaggregation.CaseAggregationConditionService"
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java 2011-04-07 08:21:36 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java 2011-05-23 06:10:58 +0000
@@ -149,4 +149,5 @@
String queryRawDataElementsForOrgUnitBetweenPeriods( Integer orgUnitId, List<Integer> betweenPeriodIds);
+ String getActivityPlan( int orgunitId, int min, int max );
}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java 2011-04-07 08:21:36 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java 2011-05-23 06:10:58 +0000
@@ -392,5 +392,30 @@
}
return sqlsb.toString();
}
-
+
+ public String getActivityPlan( int orgunitId, int min, int max )
+ {
+ return "SELECT 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 + " 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 " +
+ "ON ps1.programstageid=psi1.programstageid " +
+ "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 " +
+ "LIMIT " + max + " OFFSET " + min;
+ }
}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java 2011-04-07 08:21:36 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java 2011-05-23 06:10:58 +0000
@@ -397,6 +397,30 @@
}
return sqlsb.toString();
}
-
-
+
+ public String getActivityPlan( int orgunitId, int min, int max )
+ {
+ return "SELECT 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 + " 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 " +
+ "ON ps1.programstageid=psi1.programstageid " +
+ "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 " +
+ "LIMIT " + max + " OFFSET " + min;
+ }
}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java 2011-05-02 18:40:36 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java 2011-05-23 06:10:58 +0000
@@ -396,4 +396,30 @@
}
return sqlsb.toString();
}
+
+ public String getActivityPlan( int orgunitId, int min, int max )
+ {
+ return "SELECT 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 + " 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 " +
+ "ON ps1.programstageid=psi1.programstageid " +
+ "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 " +
+ "LIMIT " + min + " ," + max;
+ }
}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java 2011-04-07 08:21:36 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java 2011-05-23 06:10:58 +0000
@@ -394,4 +394,30 @@
}
return sqlsb.toString();
}
+
+ public String getActivityPlan( int orgunitId, int min, int max )
+ {
+ return "SELECT 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 + " 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 " +
+ "ON ps1.programstageid=psi1.programstageid " +
+ "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 " +
+ "LIMIT " + max + " OFFSET " + min;
+ }
}
=== 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-12 07:02:28 +0000
+++ 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
@@ -151,6 +151,13 @@
return activities;
}
+ private Integer total;
+
+ public Integer getTotal()
+ {
+ return total;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -164,7 +171,12 @@
organisationUnit = selectionManager.getSelectedOrganisationUnit();
- activities = activityPlanService.getActivitiesByProvider( organisationUnit );
+ total = activityPlanService.countActivitiesByProvider( organisationUnit );
+
+ this.paging = createPaging( total );
+
+ activities = new ArrayList<Activity>( activityPlanService.getActivitiesByProvider( organisationUnit, paging
+ .getStartPos(), paging.getPageSize() ) );
for ( Activity activity : activities )
{
@@ -186,11 +198,6 @@
{
Collection<Patient> patientsToBeVisited = visitsByPatients.keySet();
- this.paging = this.createPaging( patientsToBeVisited.size() );
-
- patientsToBeVisited = this.getBlockElement( new ArrayList<Patient>( patientsToBeVisited ), paging
- .getStartPos(), paging.getEndPos() );
-
// -------------------------------------------------------------
// Get all the attributes of the patients to be visited (in case
// users want to make sorting based on attributes
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js 2011-05-12 09:40:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js 2011-05-23 06:10:58 +0000
@@ -25,6 +25,7 @@
{
var type = messageElement.getAttribute( 'type' );
var message = messageElement.firstChild.nodeValue;
+ hideById( 'contentDiv' );
if ( type == 'success' )
{
@@ -48,7 +49,7 @@
{
'startDate': getFieldValue( 'startDate' ),
'&endDate': getFieldValue( 'endDate' )
- }, function() { unLockScreen(); });
+ }, function() { unLockScreen();hideById( 'message' );showById( 'contentDiv' );});
}
function viewRecords( programStageInstanceId )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java 2011-03-31 01:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java 2011-05-23 06:10:58 +0000
@@ -144,9 +144,11 @@
Program program = programService.getProgram( id );
- programStage.setProgram( program );
programStage.setName( name );
programStage.setDescription( description );
+ programStage.setStageInProgram( program.getProgramStages().size() + 1 );
+ programStage.setProgram( program );
+
minDaysFromStart = (minDaysFromStart == null) ? 0 : minDaysFromStart;
programStage.setMinDaysFromStart( minDaysFromStart );