← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10702: Add new formula to calculate number of children orgunits completed all program-stage-instance.

 

------------------------------------------------------------
revno: 10702
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-04-28 15:54:29 +0700
message:
  Add new formula to calculate number of children orgunits completed all program-stage-instance.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionManager.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.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/javascript/viewDataEntryForm.js


--
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/caseaggregation/CaseAggregationCondition.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java	2013-04-03 15:46:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java	2013-04-28 08:54:29 +0000
@@ -46,7 +46,7 @@
     public static final String SEPARATOR_OBJECT = ":";
 
     public static final String AGGRERATION_COUNT = "COUNT";
-
+    
     public static final String AGGRERATION_SUM = "times";
     
     public static final String AGGRERATION_SUM_VALUE = "sum";
@@ -79,9 +79,17 @@
     
     public static String OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY = "PC";
     
+    public static String OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE = "PSIC";
+    
     public static String OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE = "dateOfIncident";
     public static String OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE = "enrollmentDate";
 
+    public static final String regExp = "\\[(" + OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE + "|" + OBJECT_PATIENT + "|" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE + "|"
+    + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY + "|"
+    + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PATIENT_PROPERTY + "|"
+    + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9@#\\- ]+[" + SEPARATOR_ID + "[a-zA-Z0-9]*]*)"
+    + "\\]";
+
     // -------------------------------------------------------------------------
     // Fields
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java	2013-04-04 18:06:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java	2013-04-28 08:54:29 +0000
@@ -81,4 +81,5 @@
     
     void aggregate( List<CaseAggregateSchedule> caseAggregateSchedules, String taskStrategy );
     
+    boolean hasOrgunitProgramStageCompleted( String expresstion );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionManager.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionManager.java	2013-04-17 07:58:14 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionManager.java	2013-04-28 08:54:29 +0000
@@ -86,4 +86,5 @@
     String parseExpressionToSql( String aggregationExpression, String operator, Integer deSumId,
         Integer orgunitId, String startDate, String endDate );
 
+    boolean hasOrgunitProgramStageCompleted( String expresstion );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java	2013-04-17 07:58:14 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java	2013-04-28 08:54:29 +0000
@@ -30,13 +30,9 @@
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.AGGRERATION_SUM;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_PROPERTY;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_DATAELEMENT;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_PROPERTY;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_OBJECT;
 import static org.hisp.dhis.i18n.I18nUtils.i18n;
@@ -80,12 +76,6 @@
 public class DefaultCaseAggregationConditionService
     implements CaseAggregationConditionService
 {
-    private final String regExp = "\\[(" + OBJECT_PATIENT + "|" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE + "|"
-        + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY + "|"
-        + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PATIENT_PROPERTY + "|"
-        + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9@#\\- ]+[" + SEPARATOR_ID + "[a-zA-Z0-9]*]*)"
-        + "\\]";
-
     private final String INVALID_CONDITION = "Invalid condition";
 
     private final String TOTAL_OF_PATIENTS_REGISTERED = "Total of patient registration";
@@ -361,7 +351,7 @@
     {
         StringBuffer description = new StringBuffer();
 
-        Pattern patternCondition = Pattern.compile( regExp );
+        Pattern patternCondition = Pattern.compile( CaseAggregationCondition.regExp );
 
         Matcher matcher = patternCondition.matcher( condition );
 
@@ -573,6 +563,11 @@
         ConcurrentUtils.waitForCompletion( futures );
     }
 
+    public boolean hasOrgunitProgramStageCompleted( String expresstion )
+    {
+        return aggregationConditionManager.hasOrgunitProgramStageCompleted( expresstion );
+    }
+
     // -------------------------------------------------------------------------
     // Support Methods
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java	2013-04-17 07:58:14 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java	2013-04-28 08:54:29 +0000
@@ -37,6 +37,7 @@
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_DATAELEMENT;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_PROPERTY;
+import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OPERATOR_AND;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_OBJECT;
@@ -80,12 +81,6 @@
 public class JdbcCaseAggregationConditionManager
     implements CaseAggregationConditionManager
 {
-    private final String regExp = "\\[(" + OBJECT_PATIENT + "|" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE + "|"
-        + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY + "|"
-        + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PATIENT_PROPERTY + "|"
-        + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9@#\\- ]+[" + SEPARATOR_ID + "[a-zA-Z0-9]*]*)"
-        + "\\]";
-
     private final String IS_NULL = "is null";
 
     private final String PROPERTY_AGE = "age";
@@ -182,8 +177,17 @@
             || operator.equals( CaseAggregationCondition.AGGRERATION_SUM ) )
         {
             String sql = parseExpressionToSql( caseExpression, operator, deSumId, orgunitId, startDate, endDate );
-            Collection<Integer> ids = this.executeSQL( sql );
-            return (ids == null) ? null : ids.size() + 0.0;
+
+            if ( hasOrgunitProgramStageCompleted( caseExpression ) )
+            {
+                Collection<Integer> ids = this.executeSQL( sql );
+                return (ids == null) ? null : ids.iterator().next() + 0.0;
+            }
+            else
+            {
+                Collection<Integer> ids = this.executeSQL( sql );
+                return (ids == null) ? null : ids.size() + 0.0;
+            }
         }
 
         String sql = "SELECT " + operator + "( cast( pdv.value as DOUBLE PRECISION ) ) ";
@@ -243,6 +247,8 @@
         sql = getSQL( operator, subSQL, operators ).replace( IN_CONDITION_START_SIGN, "(" ).replaceAll(
             IN_CONDITION_END_SIGN, ")" );
 
+        sql.replaceAll( "COMBINE", " " );
+
         return sql;
     }
 
@@ -260,14 +266,10 @@
         String sql = "select caseaggregationconditionid, aggregationdataelementid, optioncomboid, "
             + " cagg.aggregationexpression as caseexpression, cagg.\"operator\" as caseoperator, cagg.desum as desumid "
             + "     from caseaggregationcondition cagg inner join datasetmembers dm "
-            + "             on cagg.aggregationdataelementid=dm.dataelementid "
-            + "     inner join dataset ds "
-            + "             on ds.datasetid = dm.datasetid "
-            + "     inner join periodtype pt "
-            + "             on pt.periodtypeid=ds.periodtypeid "
-            + "     inner join dataelement de "
-            + "             on de.dataelementid=dm.dataelementid "
-            + "     where ds.datasetid = "
+            + "             on cagg.aggregationdataelementid=dm.dataelementid " + "     inner join dataset ds "
+            + "             on ds.datasetid = dm.datasetid " + "     inner join periodtype pt "
+            + "             on pt.periodtypeid=ds.periodtypeid " + "     inner join dataelement de "
+            + "             on de.dataelementid=dm.dataelementid " + "     where ds.datasetid = "
             + dataSet.getDataSetId();
 
         SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );
@@ -286,18 +288,23 @@
                 String caseOperator = rs.getString( "caseoperator" );
                 int deSumId = rs.getInt( "desumid" );
 
-                Collection<Integer> _orgunitIds = getServiceOrgunit(
-                    DateUtils.getMediumDateString( period.getStartDate() ),
-                    DateUtils.getMediumDateString( period.getEndDate() ) );
-
-                if ( orgunitIds == null )
-                {
-                    orgunitIds = new HashSet<Integer>();
-                    orgunitIds.addAll( _orgunitIds );
-                }
-                else
-                {
-                    orgunitIds.retainAll( _orgunitIds );
+                boolean flag = hasOrgunitProgramStageCompleted( caseExpression );
+
+                if ( !flag )
+                {
+                    Collection<Integer> _orgunitIds = getServiceOrgunit(
+                        DateUtils.getMediumDateString( period.getStartDate() ),
+                        DateUtils.getMediumDateString( period.getEndDate() ) );
+
+                    if ( orgunitIds == null )
+                    {
+                        orgunitIds = new HashSet<Integer>();
+                        orgunitIds.addAll( _orgunitIds );
+                    }
+                    else
+                    {
+                        orgunitIds.retainAll( _orgunitIds );
+                    }
                 }
 
                 // ---------------------------------------------------------------------
@@ -312,8 +319,7 @@
 
                     boolean hasValue = jdbcTemplate.queryForRowSet( dataValueSql ).next();
 
-                    Double resultValue = getAggregateValue( caseExpression, caseOperator, deSumId, orgunitId,
-                        period );
+                    Double resultValue = getAggregateValue( caseExpression, caseOperator, deSumId, orgunitId, period );
 
                     if ( resultValue != null && resultValue != 0 )
                     {
@@ -456,6 +462,10 @@
      */
     private String createSQL( String caseExpression, String operator, int orgunitId, String startDate, String endDate )
     {
+        Boolean orgunitCompletedProgramStage = false;
+
+        String sqlOrgunitCompleted = "";
+
         // ---------------------------------------------------------------------
         // get operators
         // ---------------------------------------------------------------------
@@ -471,13 +481,13 @@
             operators.add( matcherOperator.group() );
         }
 
-        String[] expression = caseExpression.split( "(AND|OR)" );
+        String[] expression = caseExpression.split( "(AND|OR|COMBINE)" );
 
         // ---------------------------------------------------------------------
         // parse expressions
         // ---------------------------------------------------------------------
 
-        Pattern patternCondition = Pattern.compile( regExp );
+        Pattern patternCondition = Pattern.compile( CaseAggregationCondition.regExp );
 
         List<String> conditions = new ArrayList<String>();
         double value = 0.0;
@@ -485,6 +495,7 @@
         for ( int i = 0; i < expression.length; i++ )
         {
             String subExp = expression[i];
+
             List<String> subConditions = new ArrayList<String>();
 
             Matcher matcherCondition = patternCondition.matcher( expression[i] );
@@ -494,6 +505,7 @@
             while ( matcherCondition.find() )
             {
                 String match = matcherCondition.group();
+
                 subExp = subExp.replace( match, "~" );
                 match = match.replaceAll( "[\\[\\]]", "" );
 
@@ -587,7 +599,12 @@
                 {
                     condition = getConditionForPatientProgramStageProperty( info[1], operator, startDate, endDate );
                 }
-
+                else if ( info[0].equalsIgnoreCase( OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE ) )
+                {
+                    sqlOrgunitCompleted += getConditionForOrgunitProgramStageCompleted( info[1], operator, orgunitId,
+                        startDate, endDate, orgunitCompletedProgramStage );
+                    orgunitCompletedProgramStage = true;
+                }
                 // -------------------------------------------------------------
                 // Replacing the operand with 1 in order to later be able to
                 // verify
@@ -623,7 +640,16 @@
                 condition = getSQL( operator, subConditions, subOperators ) + _subExp;
             }
 
-            conditions.add( condition );
+            condition = condition.trim();
+            if ( !condition.isEmpty() )
+            {
+                conditions.add( condition );
+            }
+        }
+
+        if ( !sqlOrgunitCompleted.isEmpty() )
+        {
+            conditions.add( sqlOrgunitCompleted );
         }
 
         return getSQL( operator, conditions, operators );
@@ -910,6 +936,39 @@
     }
 
     /**
+     * Return standard SQL to retrieve the number of children orgunits has all
+     * program-stage-instance completed and due-date. E.g [PSIC:1]
+     * 
+     * @flag True if there are many stages in the expression
+     * 
+     */
+    private String getConditionForOrgunitProgramStageCompleted( String programStageId, String operator, int orgunitId,
+        String startDate, String endDate, boolean flag )
+    {
+        String sql = "";
+        if ( !flag )
+        {
+            sql = "SELECT " + operator + "(distinct psi.organisationunitid) "
+                + "         FROM programstageinstance psi ";
+        }
+        else
+        {
+            sql = " AND psi.organisationunitid in ( SELECT psi.organisationunitid "
+                + "         FROM programstageinstance psi ";
+        }
+
+        sql += " JOIN organisationunit ou ON psi.organisationunitid=ou.organisationunitid " + " WHERE ou.parentid="
+            + orgunitId + " AND psi.completed=true AND psi.programstageid = " + programStageId + " AND "
+            + " psi.executiondate >= '" + startDate + "' AND psi.executiondate <= '" + endDate + "' ";
+
+        if ( flag )
+        {
+            sql += ")";
+        }
+        return sql;
+    }
+
+    /**
      * Return standard SQL by combining all sub-expressions of an aggregate
      * query builder formula.
      * 
@@ -974,4 +1033,25 @@
 
         return orgunitIds;
     }
+
+    public boolean hasOrgunitProgramStageCompleted( String expresstion )
+    {
+        Pattern pattern = Pattern.compile( CaseAggregationCondition.regExp );
+        Matcher matcher = pattern.matcher( expresstion );
+        while ( matcher.find() )
+        {
+            String match = matcher.group();
+
+            match = match.replaceAll( "[\\[\\]]", "" );
+
+            String[] info = match.split( SEPARATOR_OBJECT );
+
+            if ( info[0].equalsIgnoreCase( CaseAggregationCondition.OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java	2013-04-04 18:06:19 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java	2013-04-28 08:54:29 +0000
@@ -261,17 +261,22 @@
                 selectedOrgunit.getId() ) );
         }
 
-        orgunitIds.retainAll( programStageInstanceService.getOrganisationUnitIds( sDate, eDate ) );
-        
         // ---------------------------------------------------------------------
         // Aggregation
         // ---------------------------------------------------------------------
-
-        for ( Integer orgUnitId : orgunitIds )
+        for ( CaseAggregationCondition condition : aggregationConditions )
         {
-            OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
-            for ( CaseAggregationCondition condition : aggregationConditions )
-            {
+            boolean flag = aggregationConditionService.hasOrgunitProgramStageCompleted( condition.getAggregationExpression() );
+
+            if ( !flag )
+            {
+                orgunitIds.retainAll( programStageInstanceService.getOrganisationUnitIds( sDate, eDate ) );
+            }
+            
+            for ( Integer orgUnitId : orgunitIds )
+            {
+                OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+
                 DataElement dElement = condition.getAggregationDataElement();
                 DataElementCategoryOptionCombo optionCombo = condition.getOptionCombo();
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2013-04-26 14:46:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2013-04-28 08:54:29 +0000
@@ -389,4 +389,5 @@
 create_new_program_indicator = Create new program indicator
 update_program_indicator = Edit program indicator
 disable_registration_fields = Disable registration fields
-data_entry = Data entry
\ No newline at end of file
+data_entry = Data entry
+combine = Combine
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2013-04-17 07:58:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2013-04-28 08:54:29 +0000
@@ -889,6 +889,14 @@
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/caseAggregationList.vm</param>
 		</action>
+		
+		<action name="getProgramStages"
+			class="org.hisp.dhis.patient.action.programstage.GetProgramStageListAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonProgramStages.vm
+			</result>
+			<param name="onExceptionReturn">plainTextError</param>
+		</action>
 
 		<!-- Validation - PatientValidationCriteria -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.vm	2013-04-17 07:58:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.vm	2013-04-28 08:54:29 +0000
@@ -1,7 +1,9 @@
 <div id="tabs">
 	<ul>
 		<li><a href="#tab-1">$i18n.getString("dataelements")</a></li>
+		<li><a href="#tab-2">$i18n.getString("patient_attributes")</a></li>
 		<li><a href="#tab-3">$i18n.getString("program")</a></li>
+		<li><a href="#tab-4">$i18n.getString("orgunit")</a></li>
 	</ul>	
 	
 	<div id="tab-1">
@@ -82,6 +84,29 @@
 		</table>
 	</div>
 	
+	<div id="tab-4">
+		<table>
+			<tr>
+				<td><label>$i18n.getString('program')</label></td>
+			</tr>
+			<tr>
+				<td>
+					<select id="orgunitProgramId" name="orgunitProgramId" onchange='getProgramStages();' >
+						<option value=''>[$i18n.getString("please_select")]</option>
+						#foreach( $program in $programs )
+							<option value='$program.id'>$encoder.htmlEncode($program.name)</option>
+						#end
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td>
+					<select multiple id="orgunitProgramStageId" name="orgunitProgramStageId"  size="10" name="programStageProperty" ondblclick="insertInfo(this, true);" >
+					</select>
+				</td>
+			</tr>
+		</table>
+	</div>
 </div>
 
 <p></p>
@@ -106,6 +131,7 @@
 			&nbsp;&nbsp;&nbsp;
 			<input type='button' style="width:45px;" alt="$i18n.getString( 'and' )" onclick='insertOperator( "AND" );' value="AND" />
 			<input type='button' style="width:45px;" alt="$i18n.getString( 'or' )" onclick='insertOperator( "OR" );' value="OR" />
+			<input type='button' style="width:45px;" alt="$i18n.getString( 'combine' )" onclick='insertOperator( "COMBINE" );' value="COMBINE" />
 			&nbsp;&nbsp;&nbsp;
 			<input type='button' style="width:45px;" align="right" alt="$i18n.getString( 'clear' )" onclick="byId('aggregationCondition').value='';" value="$i18n.getString('clear')" />
 		</td>

=== 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	2013-03-20 14:22:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js	2013-04-28 08:54:29 +0000
@@ -179,6 +179,30 @@
 		});
 }
 
+function getProgramStages()
+{
+	var programId = getFieldValue( 'orgunitProgramId' );
+	if(programId=='') return;
+	
+	clearListById( 'orgunitProgramStageId' );
+	
+	jQuery.getJSON( 'getProgramStages.action',{ id:programId }
+		,function( json ) 
+		{
+			enable('programProperty');
+			var programstage = jQuery('#orgunitProgramStageId');
+			
+			for ( i in json.programStages ) 
+			{ 
+				var id = json.programStages[i].id;
+				var formularId = "[PSIC:" + id + "]";
+				var name = json.programStages[i].name;
+
+				programstage.append( "<option value='" + formularId + "' title='" + name + "'>" + name + "</option>" );
+			}
+		});
+}
+
 //------------------------------------------------------------------------------
 // Get DataElements of Program-Stage
 //------------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js	2013-04-05 07:46:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js	2013-04-28 08:54:29 +0000
@@ -364,3 +364,13 @@
 		setHeaderDelayMessage( i18n_save_success ); 
 	} );
 }
+
+function deleteRegistrationFormFromView()
+{
+	var result = window.confirm( i18n_confirm_delete + '\n\n' + name );
+	if ( result )
+	{
+		window.location.href = 'delRegistrationEntryFormAction.action?id=' + id;
+	}
+}
+