← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2200: Add a method to get PatientDataValue list into Aggregation Engine function.

 

------------------------------------------------------------
revno: 2200
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-11-29 09:04:22 +0700
message:
  Add a method to get PatientDataValue list into Aggregation Engine function.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueStore.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/patientdatavalue/DefaultPatientDataValueService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/hibernate/HibernatePatientDataValueStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/GetDataSetPeriodsAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationMenu.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.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/CaseAggregationConditionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java	2010-11-25 22:22:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java	2010-11-29 02:04:22 +0000
@@ -32,6 +32,7 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.period.Period;
 
 /**
@@ -55,4 +56,6 @@
 
     
     double parseConditition( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit, Period period );
+        
+    Collection<PatientDataValue> getPatientDataValues( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit, Period period );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java	2010-11-25 22:22:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java	2010-11-29 02:04:22 +0000
@@ -1,13 +1,13 @@
 package org.hisp.dhis.patientdatavalue;
 
+import java.io.Serializable;
+import java.util.Date;
+
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.ProgramStageInstance;
 
-import java.io.Serializable;
-import java.util.Date;
-
 /**
  * @author Abyot Asalefew Gizaw
  * @version $Id$

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueService.java	2009-10-28 19:47:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueService.java	2010-11-29 02:04:22 +0000
@@ -28,10 +28,12 @@
 package org.hisp.dhis.patientdatavalue;
 
 import java.util.Collection;
+import java.util.Date;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.program.ProgramStageInstance;
 
 /**
@@ -87,6 +89,8 @@
     Collection<PatientDataValue> getPatientDataValues( ProgramStageInstance programStageInstance, boolean providedByAnotherFacility );
     
     Collection<PatientDataValue> getPatientDataValues( DataElement dataElement, boolean providedByAnotherFacility );
+    
+    Collection<PatientDataValue> getPatientDataValues( Patient patient, Collection<DataElement> dataElements, Date date, java.util.Date date2 );
 
     Collection<PatientDataValue> getAllPatientDataValues();
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueStore.java	2009-10-28 19:47:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueStore.java	2010-11-29 02:04:22 +0000
@@ -28,11 +28,13 @@
 package org.hisp.dhis.patientdatavalue;
 
 import java.util.Collection;
+import java.util.Date;
 
 import org.hisp.dhis.common.GenericStore;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.program.ProgramStageInstance;
 
 /**
@@ -84,5 +86,8 @@
     Collection<PatientDataValue> get( ProgramStageInstance programStageInstance, boolean providedByAnotherFacility );
 
     Collection<PatientDataValue> get( DataElement dataElement, boolean providedByAnotherFacility );
+    
+    Collection<PatientDataValue> get( Patient patient, Collection<DataElement> dataElements, Date startDate, Date endDate );
+
 
 }
\ No newline at end of file

=== 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	2010-11-25 22:22:10 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java	2010-11-29 02:04:22 +0000
@@ -37,16 +37,21 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.patientdatavalue.PatientDataValue;
+import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.system.util.DateUtils;
-import org.hisp.dhis.system.util.MathUtils;
 import org.nfunk.jep.JEP;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -67,6 +72,12 @@
 
     private CaseAggregationConditionStore aggregationConditionStore;
 
+    private DataElementService dataElementService;
+
+    private PatientService patientService;
+
+    private PatientDataValueService dataValueService;
+
     // -------------------------------------------------------------------------
     // Getters && Setters
     // -------------------------------------------------------------------------
@@ -76,6 +87,11 @@
         this.aggregationConditionStore = aggregationConditionStore;
     }
 
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation Method
     // -------------------------------------------------------------------------
@@ -86,6 +102,16 @@
         return aggregationConditionStore.save( caseAggregationCondition );
     }
 
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
+    public void setDataValueService( PatientDataValueService dataValueService )
+    {
+        this.dataValueService = dataValueService;
+    }
+
     @Override
     public void deleteCaseAggregationCondition( CaseAggregationCondition caseAggregationCondition )
     {
@@ -122,6 +148,45 @@
     public double parseConditition( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit,
         Period period )
     {
+        String sql = createSQL( aggregationCondition, orgunit, period );
+
+        Collection<Integer> patientIds = aggregationConditionStore.executeSQL( sql );
+
+        return calValue( patientIds, aggregationCondition.getOperator() );
+    }
+
+    @Override
+    public Collection<PatientDataValue> getPatientDataValues( CaseAggregationCondition aggregationCondition,
+        OrganisationUnit orgunit, Period period )
+    {
+        Collection<PatientDataValue> result = new HashSet<PatientDataValue>();
+
+        String sql = createSQL( aggregationCondition, orgunit, period );
+        
+        Collection<DataElement> dataElements = getDataElementsInExpression( aggregationCondition
+            .getAggregationExpression() );
+
+        Collection<Integer> patientIds = aggregationConditionStore.executeSQL( sql );
+
+        for ( Integer patientId : patientIds )
+        {
+            Patient patient = patientService.getPatient( patientId );
+
+            Collection<PatientDataValue> dataValues = dataValueService.getPatientDataValues( patient, dataElements,
+                period.getStartDate(), period.getEndDate() );
+
+            result.addAll( dataValues );
+        }
+        
+        return result;
+    }
+
+    // -------------------------------------------------------------------------
+    // Support Methods
+    // -------------------------------------------------------------------------
+
+    private String createSQL( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit, Period period )
+    {
         int orgunitId = orgunit.getId();
         String startDate = DateUtils.getMediumDateString( period.getStartDate() );
         String endDate = DateUtils.getMediumDateString( period.getEndDate() );
@@ -212,8 +277,8 @@
                 {
                     Collection<Integer> patientIds = aggregationConditionStore.executeSQL( condition );
                     value = calValue( patientIds, AGGRERATION_SUM );
-                        
-                    subExp = subExp.replace(  "~", value + "" );
+
+                    subExp = subExp.replace( "~", value + "" );
                 }
 
                 condition = expression[i].replace( match, condition ).replaceAll( "[\\[\\]]", "" );
@@ -222,11 +287,11 @@
             if ( expression[i].contains( "+" ) )
             {
                 final JEP parser = new JEP();
-                
+
                 parser.parseExpression( subExp );
-                
-                String _subExp = (  parser.getValue() == 1.0 ) ? " AND 1 = 1 " : " AND 0 = 1 ";
-                
+
+                String _subExp = (parser.getValue() == 1.0) ? " AND 1 = 1 " : " AND 0 = 1 ";
+
                 int noPlus = expression[i].split( "\\+" ).length - 1;
                 List<String> subOperators = new ArrayList<String>();
                 for ( int j = 0; j < noPlus; j++ )
@@ -240,16 +305,41 @@
             conditions.add( condition );
         }
 
-        String sqlResult = getSQL( conditions, operators );
-        
-        Collection<Integer> patientIds = aggregationConditionStore.executeSQL( sqlResult );
-
-        return calValue( patientIds, aggregationCondition.getOperator() );
-    }
-
-    // -------------------------------------------------------------------------
-    // Support Methods
-    // -------------------------------------------------------------------------
+        return getSQL( conditions, operators );
+
+    }
+
+    private Collection<DataElement> getDataElementsInExpression( String aggregationExpression )
+    {
+        String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "[0-9]+" + SEPARATOR_ID
+            + "[0-9]+" + SEPARATOR_ID + "[0-9]+" + "\\]";
+
+        Collection<DataElement> dataElements = new HashSet<DataElement>();
+
+        // ---------------------------------------------------------------------
+        // parse expressions
+        // ---------------------------------------------------------------------
+
+        Pattern pattern = Pattern.compile( regExp );
+
+        Matcher matcher = pattern.matcher( aggregationExpression );
+
+        while ( matcher.find() )
+        {
+            String match = matcher.group();
+            match = match.replaceAll( "[\\[\\]]", "" );
+
+            String[] info = match.split( SEPARATOR_OBJECT );
+            String[] ids = info[1].split( SEPARATOR_ID );
+
+            int dataElementId = Integer.parseInt( ids[1] );
+            DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+            dataElements.add( dataElement );
+        }
+
+        return dataElements;
+    }
 
     private String getCondititionForDataElement( int programStageId, int dataElementId, int optionComboId,
         int orgunitId, String startDate, String endDate )
@@ -339,13 +429,12 @@
 //
 //        // aggregationCondition.setAggregationExpression(
 //        // "( [DE:1.1.1] + [DE:1.1.1] + [DE:1.1.1] > 0 " );
-//        aggregationCondition
-//            .setAggregationExpression( " [DE:15.116.1]  +  [DE:16.117.1] > 0" );
+//        aggregationCondition.setAggregationExpression( " [DE:15.1.1]  +  [DE:16.2.1] > 0" );
 //        // );
 //
 //        DefaultCaseAggregationConditionService service = new DefaultCaseAggregationConditionService();
 //
-//        service.parseConditition( aggregationCondition, null, null );
+//        service.getDataElementsInExpression( aggregationCondition.getAggregationExpression() );
 //    }
 
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/DefaultPatientDataValueService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/DefaultPatientDataValueService.java	2010-11-25 22:22:10 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/DefaultPatientDataValueService.java	2010-11-29 02:04:22 +0000
@@ -28,10 +28,12 @@
 package org.hisp.dhis.patientdatavalue;
 
 import java.util.Collection;
+import java.util.Date;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -185,4 +187,10 @@
         return patientDataValueStore.get( dataElement, providedByAnotherFacility );
     }
 
+    public Collection<PatientDataValue> getPatientDataValues( Patient patient, Collection<DataElement> dataElements,
+        Date startDate, Date endDate )
+    {
+        return patientDataValueStore.get( patient, dataElements, startDate, endDate );
+    }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/hibernate/HibernatePatientDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/hibernate/HibernatePatientDataValueStore.java	2010-10-22 06:43:14 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/hibernate/HibernatePatientDataValueStore.java	2010-11-29 02:04:22 +0000
@@ -28,6 +28,7 @@
 package org.hisp.dhis.patientdatavalue.hibernate;
 
 import java.util.Collection;
+import java.util.Date;
 
 import org.hibernate.Query;
 import org.hibernate.criterion.Restrictions;
@@ -35,6 +36,7 @@
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.hibernate.HibernateGenericStore;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.patientdatavalue.PatientDataValueStore;
 import org.hisp.dhis.program.ProgramStageInstance;
@@ -117,7 +119,7 @@
     {
         return getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) ).list();
     }
-    
+
     @SuppressWarnings( "unchecked" )
     public Collection<PatientDataValue> get( OrganisationUnit organisationUnit,
         ProgramStageInstance programStageInstance )
@@ -125,7 +127,7 @@
         return getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ),
             Restrictions.eq( "programStageInstance", programStageInstance ) ).list();
     }
-    
+
     @SuppressWarnings( "unchecked" )
     public Collection<PatientDataValue> get( OrganisationUnit organisationUnit,
         Collection<ProgramStageInstance> programStageInstances )
@@ -147,17 +149,16 @@
     {
         return getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ),
             Restrictions.eq( "optionCombo", optionCombo ) ).list();
-    }    
+    }
 
     @SuppressWarnings( "unchecked" )
     public Collection<PatientDataValue> get( boolean providedByAnotherFacility )
     {
         return getCriteria( Restrictions.eq( "providedByAnotherFacility", providedByAnotherFacility ) ).list();
     }
-    
+
     @SuppressWarnings( "unchecked" )
-    public Collection<PatientDataValue> get( OrganisationUnit organisationUnit,
-        boolean providedByAnotherFacility )
+    public Collection<PatientDataValue> get( OrganisationUnit organisationUnit, boolean providedByAnotherFacility )
     {
         return getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ),
             Restrictions.eq( "providedByAnotherFacility", providedByAnotherFacility ) ).list();
@@ -177,4 +178,16 @@
         return getCriteria( Restrictions.eq( "dataElement", dataElement ),
             Restrictions.eq( "providedByAnotherFacility", providedByAnotherFacility ) ).list();
     }
+
+    @SuppressWarnings( "unchecked" )
+    public Collection<PatientDataValue> get( Patient patient, Collection<DataElement> dataElements, Date startDate,
+        Date endDate )
+    {
+        String hql = "From PatientDataValue pdv where pdv.dataElement in ( :dataElements ) "
+            + "AND pdv.programStageInstance.programInstance.patient = :patient "
+            + "AND pdv.programStageInstance.executionDate >= :startDate AND pdv.programStageInstance.executionDate <= :endDate ";
+
+        return getQuery( hql ).setParameterList( "dataElements", dataElements ).setEntity( "patient", patient )
+            .setDate( "startDate", startDate ).setDate( "endDate", endDate ).list();
+    }
 }

=== 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	2010-11-25 22:22:10 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2010-11-29 02:04:22 +0000
@@ -146,7 +146,10 @@
 	
 	<bean id="org.hisp.dhis.caseaggregation.CaseAggregationConditionService"
     class="org.hisp.dhis.caseaggregation.DefaultCaseAggregationConditionService">
-    	<property name="aggregationConditionStore" ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionStore" />     	
+    	<property name="aggregationConditionStore" ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionStore" />
+    	<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />     	
+        <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />     	
+        <property name="dataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />     	     	
     </bean>
     
     <bean id="org.hisp.dhis.program.ProgramStageDataElementService"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/GetDataSetPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/GetDataSetPeriodsAction.java	2010-11-25 22:22:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/GetDataSetPeriodsAction.java	2010-11-29 02:04:22 +0000
@@ -49,7 +49,7 @@
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-    
+
     private PeriodService periodService;
 
     public void setPeriodService( PeriodService periodService )
@@ -68,11 +68,11 @@
     // Input & output
     // -------------------------------------------------------------------------
 
-    private Integer id;
+    private Integer selectedDataSets;
 
-    public void setId( Integer id )
+    public void setSelectedDataSets( Integer selectedDataSets )
     {
-        this.id = id;
+        this.selectedDataSets = selectedDataSets;
     }
 
     private List<Period> periods;
@@ -92,9 +92,9 @@
     private SimpleDateFormat simpleDateFormat1;
 
     private SimpleDateFormat simpleDateFormat2;
-	
-	private PeriodType periodType;
-            
+
+    private PeriodType periodType;
+
     public PeriodType getPeriodType()
     {
         return periodType;
@@ -103,29 +103,29 @@
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
-    
+
     public String execute()
         throws Exception
     {
         periodNameList = new ArrayList<String>();
-        DataSet dSet;
-        dSet = dataSetService.getDataSet( id );
+
+        DataSet dSet = dataSetService.getDataSet( selectedDataSets );
         periodType = dSet.getPeriodType();
 
         periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( periodType ) );
 
         Iterator<Period> periodIterator = periods.iterator();
-        while( periodIterator.hasNext() )
+        while ( periodIterator.hasNext() )
         {
             Period p1 = periodIterator.next();
-            
+
             if ( p1.getStartDate().compareTo( new Date() ) > 0 )
             {
-                periodIterator.remove( );
+                periodIterator.remove();
             }
-            
+
         }
-        
+
         Collections.sort( periods, new PeriodComparator() );
 
         if ( periodType.getName().equalsIgnoreCase( "monthly" ) )
@@ -133,8 +133,8 @@
             simpleDateFormat1 = new SimpleDateFormat( "MMM-yyyy" );
             for ( Period p1 : periods )
             {
-                //if ( p1.getStartDate().compareTo( new Date() ) <= 0 )
-                    periodNameList.add( simpleDateFormat1.format( p1.getStartDate() ) );
+                // if ( p1.getStartDate().compareTo( new Date() ) <= 0 )
+                periodNameList.add( simpleDateFormat1.format( p1.getStartDate() ) );
 
             }
 
@@ -146,7 +146,7 @@
 
             for ( Period p1 : periods )
             {
-                //if ( p1.getStartDate().compareTo( new Date() ) <= 0 )
+                // if ( p1.getStartDate().compareTo( new Date() ) <= 0 )
                 {
                     String tempPeriodName = simpleDateFormat1.format( p1.getStartDate() ) + " - "
                         + simpleDateFormat2.format( p1.getEndDate() );
@@ -167,7 +167,7 @@
             int year;
             for ( Period p1 : periods )
             {
-                //if ( p1.getStartDate().compareTo( new Date() ) <= 0 )
+                // if ( p1.getStartDate().compareTo( new Date() ) <= 0 )
                 {
                     year = Integer.parseInt( simpleDateFormat1.format( p1.getStartDate() ) ) + 1;
                     periodNameList.add( simpleDateFormat1.format( p1.getStartDate() ) + "-" + year );
@@ -179,7 +179,7 @@
             simpleDateFormat1 = new SimpleDateFormat( "yyyy-mm-dd" );
             for ( Period p1 : periods )
             {
-                //if ( p1.getStartDate().compareTo( new Date() ) <= 0 )
+                // if ( p1.getStartDate().compareTo( new Date() ) <= 0 )
                 {
                     String tempPeriodName = simpleDateFormat1.format( p1.getStartDate() ) + " - "
                         + simpleDateFormat1.format( p1.getEndDate() );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationMenu.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationMenu.vm	2010-07-04 23:55:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationMenu.vm	2010-11-29 02:04:22 +0000
@@ -3,23 +3,3 @@
 <ul>
     <li><a href="caseAggregationForm.action">$i18n.getString( "case_aggregation" )</a></li>     
 </ul>
-
-<br>
-#parse( "/dhis-web-commons/ouwt/orgunittree.vm" )
-
-<script type="text/javascript">
-
-function orgUnitHasBeenSelected( orgUnitIds )
-{    
-	if(orgUnitIds == null || orgUnitIds == "" )
-	{
-		return;
-	}
-
-	if(orgUnitIds != null)
-		getOrgUDetails(orgUnitIds);	
-}
-
-selection.setListenerFunction( orgUnitHasBeenSelected );
-
-</script>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js	2010-07-06 09:34:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js	2010-11-29 02:04:22 +0000
@@ -18,14 +18,18 @@
 {
   var dataSetList = document.getElementById("selectedDataSets");
   var dataSetId = dataSetList.options[ dataSetList.selectedIndex].value;
-
-  
-    var url = "getDataSetPeriods.action?id=" + dataSetId;
+  
+  if(dataSetId == '0')
+  {
+	return;
+  }
+  
+	var url = "getDataSetPeriods.action?selectedDataSets=" + dataSetId;
     
     var request = new Request();
-      request.setResponseTypeXML( 'period' );
-      request.setCallbackSuccess( getdSetPeriodsReceived );
-      request.send( url ); 
+    request.setResponseTypeXML( 'period' );
+    request.setCallbackSuccess( getdSetPeriodsReceived );
+    request.send( url ); 
 }