← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6293: (patient) Move SQL to get activity plan from statementBuilder to service-patient; minor fix for ...

 

------------------------------------------------------------
revno: 6293
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-03-19 14:56:03 +0700
message:
  (patient) Move SQL to get activity plan from statementBuilder  to service-patient; minor fix for case aggregate query builder module.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/jdbc/JdbcActivityPlanStore.java
  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-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.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-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	2011-09-28 07:00:14 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/activityplan/jdbc/JdbcActivityPlanStore.java	2012-03-19 07:56:03 +0000
@@ -57,7 +57,7 @@
     private StatementManager statementManager;
 
     private StatementBuilder statementBuilder;
-    
+
     // -------------------------------------------------------------------------
     // Setters
     // -------------------------------------------------------------------------
@@ -86,10 +86,24 @@
         {
             Statement statement = holder.getStatement();
 
-            String sql = statementBuilder.getActivityPlan( orgunitId, min, max );
-            
+            // String sql = statementBuilder.getActivityPlan( orgunitId, min,
+            // max );
+            String sql = "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 "
+                + "INNER JOIN program pg " + "ON po.programid=pg.programid " + "WHERE pi.completed = FALSE  "
+                + "AND pg.singleEvent=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 "
+                + statementBuilder.limitRecord( min, max );
+
             ResultSet resultSet = statement.executeQuery( sql );
-            
+
             while ( resultSet.next() )
             {
                 programStageInstanceIds.add( resultSet.getInt( 1 ) );
@@ -101,7 +115,7 @@
         catch ( Exception ex )
         {
             log.debug( ex );
-            
+
             return null;
         }
         finally
@@ -114,38 +128,29 @@
     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 ) ";
+            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 ) ";
 
             ResultSet resultSet = statement.executeQuery( sql );
-            if(resultSet.next())
+            if ( resultSet.next() )
             {
                 return resultSet.getInt( 1 );
             }
-                
+
             return 0;
         }
         catch ( Exception ex )

=== 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	2012-03-16 16:49:58 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2012-03-19 07:56:03 +0000
@@ -163,8 +163,6 @@
     String queryDataElementStructureForOrgUnit();
 
     String queryRawDataElementsForOrgUnitBetweenPeriods( Integer orgUnitId, List<Integer> betweenPeriodIds);
-
-    String getActivityPlan( int orgunitId, int min, int max );
     
     String limitRecord( 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	2012-03-16 16:49:58 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java	2012-03-19 07:56:03 +0000
@@ -313,36 +313,7 @@
         }
         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 " +
-                    "INNER JOIN program pg " +
-                        "ON po.programid=pg.programid " +
-                 "WHERE pi.completed = FALSE  " +
-                        "AND pg.singleEvent=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;
-    }
-
+          
     public String limitRecord( int min, int max )
     {
         return " 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	2012-03-16 16:49:58 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2012-03-19 07:56:03 +0000
@@ -335,35 +335,6 @@
         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 " +
-                    "INNER JOIN program pg " +
-                        "ON po.programid=pg.programid " +
-                 "WHERE pi.completed = FALSE  " +
-                        "AND pg.singleEvent=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;
-    }
-
     public String limitRecord( int min, int max )
     {
         return " 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	2012-03-16 16:49:58 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2012-03-19 07:56:03 +0000
@@ -332,35 +332,6 @@
         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 " +
-                    "INNER JOIN program pg " +
-                        "ON po.programid=pg.programid " +
-                 "WHERE pi.completed = FALSE  " +
-                        "AND pg.singleEvent=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;
-    }
-    
     public String limitRecord( int min, int max )
     {
         return " 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	2012-03-16 18:28:34 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2012-03-19 07:56:03 +0000
@@ -331,35 +331,6 @@
         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 " +
-                    "INNER JOIN program pg " +
-                        "ON po.programid=pg.programid " +
-                 "WHERE pi.completed = FALSE  " +
-                        "AND pg.singleEvent=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;
-    }
-    
     public String limitRecord( int min, int max )
     {
         return " LIMIT " + max + " OFFSET " + min;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2012-03-16 07:50:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2012-03-19 07:56:03 +0000
@@ -278,7 +278,7 @@
 		<td>
 			<input type="submit" value="$i18n.getString( 'add' )" style="width:10em"/>
 			<input type="button" value="$i18n.getString( 'test_condition' )" style="width:10em" onclick='testCaseAggregationCondition();'/>
-			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='caseAggregation.action?dataSetId=$dataSetId'" style="width:10em"/>
+			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='caseAggregation.action?dataSetId=$!dataSetId'" style="width:10em"/>
 		</td>
 	</tr>
 </table>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm	2012-03-16 07:58:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm	2012-03-19 07:56:03 +0000
@@ -22,7 +22,7 @@
 				<input type="text" onkeyup="filterValues( this.value , 1)" />
 			</td>
 			<td colspan="3" style="text-align:right">
-				<input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddCaseAggregationForm.action?dataSetId=$dataSetId'" >
+				<input type="button" value="$i18n.getString( 'add_new' )" onclick="showAddCaseAggregationForm();" >
 			</td>
 		</tr>
 		</table>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js	2012-03-16 08:57:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js	2012-03-19 07:56:03 +0000
@@ -89,7 +89,7 @@
 		return;  
 	}
 
-	$.getJSON( 'getProgramStages.action', { programId:programId }, getProgramStagesFomulaCompleted );
+	$.get( 'getProgramStages.action', { programId:programId }, getProgramStagesFomulaCompleted, 'xml' );
 }
 
 function getProgramStagesFomulaCompleted( programstageElement )
@@ -287,3 +287,8 @@
 			setInnerHTML('list', html );
 		} );
 }
+
+function showAddCaseAggregationForm()
+{
+	window.location.href='showAddCaseAggregationForm.action?dataSetId=' + getFieldValue( 'dataSetId' );
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2012-03-16 07:50:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2012-03-19 07:56:03 +0000
@@ -294,7 +294,7 @@
 		<td>
 			<input type="submit" value="$i18n.getString( 'update' )" style="width:10em">
 			<input type="button" value="$i18n.getString( 'test_condition' )" style="width:10em" onclick='testCaseAggregationCondition();'/>
-			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='caseAggregation.action?dataSetId=$dataSetId'" style="width:10em">
+			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='caseAggregation.action?dataSetId=$!dataSetId'" style="width:10em">
 		</td>
 	<tr>
 </table>