← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3653: Merging 2.1 ReportModule: Improved CSReview, Aggregation, IndicatorReports and MetaDataReports

 

------------------------------------------------------------
revno: 3653
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-05-18 17:26:37 +0530
message:
  Merging 2.1 ReportModule: Improved CSReview,Aggregation,IndicatorReports and MetaDataReports
modified:
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java
  local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserResultAction.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/csreview/action/GenerateCSReviewReportResultAction.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/EDReportFormAction.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/EDReportResultAction.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/meta/action/GenerateMetaDataReportResultAction.java
  local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/edReportForm.vm
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/reports.js
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.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 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java	2011-04-29 13:45:23 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java	2011-05-18 11:56:37 +0000
@@ -34,6 +34,7 @@
 import java.util.Map;
 
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
@@ -133,4 +134,13 @@
     Map<String, String> getResultDataValueFromAggregateTable( Integer orgunitId, String dataElmentIdsByComma, String periodIdsByComma );
     
     Map<String, String> getAggDataFromDataValueTable( String orgUnitIdsByComma, String dataElmentIdsByComma, String periodsByComma );
+    
+    String getDataelementIds( List<Report_inDesign> reportDesignList );
+    
+    String getAggVal( String expression, Map<String, String> aggDeMap );
+
+    Map<String, List<String>> getIndicatorDataValueFromAggregateTable( Integer orgunitId, String indicatorIdsByComma, Integer periodId );
+    
+    double getIndividualIndicatorValue( Indicator indicator, OrganisationUnit orgunit, Date startDate, Date endDate );
+
 }

=== modified file 'local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java'
--- local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java	2011-04-29 13:45:23 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java	2011-05-18 11:56:37 +0000
@@ -1239,7 +1239,7 @@
 {
     int deFlag1 = 0;
     int deFlag2 = 0;
-		
+                
     try
     {
         Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
@@ -1803,6 +1803,7 @@
         }
     }
     
+    
     public Map<String, String> getAggDataFromDataValueTable( String orgUnitIdsByComma, String dataElmentIdsByComma, String periodIdsByComma )
     {
         Map<String, String> aggDeMap = new HashMap<String, String>();
@@ -1833,7 +1834,7 @@
             throw new RuntimeException( "Illegal DataElement id", e );
         }
     }
-
+    
     public String getResultDataValueFromAggregateTable( String formula, String periodIdsByComma, Integer orgunitId )
     {
         try
@@ -2024,4 +2025,180 @@
         
         return ""+recordCount;
     }
+    
+    public String getDataelementIds( List<Report_inDesign> reportDesignList )
+    {
+        String dataElmentIdsByComma = "-1";
+        for( Report_inDesign report_inDesign : reportDesignList )
+        {
+            String formula = report_inDesign.getExpression();
+            try
+            {
+                Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
+
+                Matcher matcher = pattern.matcher( formula );
+                StringBuffer buffer = new StringBuffer();
+
+                while ( matcher.find() )
+                {
+                    String replaceString = matcher.group();
+
+                    replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
+                    replaceString = replaceString.substring( 0, replaceString.indexOf( '.' ) );
+
+                    int dataElementId = Integer.parseInt( replaceString );
+                    dataElmentIdsByComma += "," + dataElementId;
+                    replaceString = "";
+                    matcher.appendReplacement( buffer, replaceString );
+                }
+            }
+            catch( Exception e )
+            {
+                
+            }
+        }
+        
+        return dataElmentIdsByComma;
+    }
+
+    public String getAggVal( String expression, Map<String, String> aggDeMap )
+    {
+        try
+        {
+            Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
+
+            Matcher matcher = pattern.matcher( expression );
+            StringBuffer buffer = new StringBuffer();
+
+            String resultValue = "";
+
+            while ( matcher.find() )
+            {
+                String replaceString = matcher.group();
+
+                replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
+
+                replaceString = aggDeMap.get( replaceString );
+                
+                if( replaceString == null )
+                {
+                    replaceString = "0";
+                }
+                
+                matcher.appendReplacement( buffer, replaceString );
+
+                resultValue = replaceString;
+            }
+
+            matcher.appendTail( buffer );
+            
+            double d = 0.0;
+            try
+            {
+                d = MathUtils.calculateExpression( buffer.toString() );
+            }
+            catch ( Exception e )
+            {
+                d = 0.0;
+                resultValue = "";
+            }
+            
+            resultValue = "" + (double) d;
+
+            return resultValue;
+        }
+        catch ( NumberFormatException ex )
+        {
+            throw new RuntimeException( "Illegal DataElement id", ex );
+        }
+    }
+    
+    public Map<String, List<String>> getIndicatorDataValueFromAggregateTable( Integer orgunitId, String indicatorIdsByComma, Integer periodId )
+    {
+        Map<String, List<String>> aggIndicatorMap = new HashMap<String, List<String>>();
+        try
+        {
+            String query = "SELECT indicatorid, numeratorvalue, denominatorvalue FROM aggregatedindicatorvalue " +
+                           " WHERE indicatorid IN (" + indicatorIdsByComma + " ) AND "+
+                           " organisationunitid = "+ orgunitId +" AND "+
+                           " periodid = " + periodId;
+
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            
+            while ( rs.next() )
+            {                
+                Integer indicatorId = rs.getInt( 1 );
+                Double aggregatedIndicatorValue = rs.getDouble( 2 );
+                Double aggNumeratorValue = rs.getDouble( 3 );
+                Double aggDenominatorValue = rs.getDouble( 4 );
+                
+                List<String> tempList = new ArrayList<String>();          
+                if( aggregatedIndicatorValue != null )
+                {
+                    tempList.add( ""+aggregatedIndicatorValue );
+                    tempList.add( ""+aggNumeratorValue );
+                    tempList.add( ""+aggDenominatorValue );
+                    
+                    aggIndicatorMap.put( ""+indicatorId, tempList );
+                }
+            }
+            
+            return aggIndicatorMap;
+        }
+        catch( Exception e )
+        {
+            throw new RuntimeException( "Illegal DataElement id", e );
+        }
+    }
+
+    public double getIndividualIndicatorValue( Indicator indicator, OrganisationUnit orgunit, Date startDate, Date endDate ) 
+    {
+        String numeratorExp = indicator.getNumerator();
+        String denominatorExp = indicator.getDenominator();
+        int indicatorFactor = indicator.getIndicatorType().getFactor();
+        String reportModelTB = "";
+        String numeratorVal = getIndividualResultDataValue( numeratorExp, startDate, endDate, orgunit, reportModelTB  );
+        String denominatorVal = getIndividualResultDataValue( denominatorExp, startDate, endDate, orgunit, reportModelTB );
+    
+        double numeratorValue;
+        try
+        {
+            numeratorValue = Double.parseDouble( numeratorVal );
+        } 
+        catch ( Exception e )
+        {
+            numeratorValue = 0.0;
+        }
+    
+        double denominatorValue;
+        try
+        {
+            denominatorValue = Double.parseDouble( denominatorVal );
+        } 
+        catch ( Exception e )
+        {
+            denominatorValue = 1.0;
+        }
+    
+        double aggregatedValue;
+        try
+        {
+            if( denominatorValue == 0 )
+            {
+                aggregatedValue = 0.0;
+            }
+            else
+            {
+                aggregatedValue = ( numeratorValue / denominatorValue ) * indicatorFactor;
+            }
+        } 
+        catch ( Exception e )
+        {
+            System.out.println( "Exception while calculating Indicator value for Indicaotr " + indicator.getName() );
+            aggregatedValue = 0.0;
+        }
+        
+        return aggregatedValue;
+    }
+
 }

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserResultAction.java	2011-04-15 11:39:32 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserResultAction.java	2011-05-18 11:56:37 +0000
@@ -1,6 +1,7 @@
 package org.hisp.dhis.reports.aggregation.action;
 
 import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
+import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
 
 import java.io.BufferedInputStream;
 import java.io.File;
@@ -12,8 +13,10 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 import jxl.CellType;
@@ -144,14 +147,7 @@
     {
         this.endDate = endDate;
     }
-/*
-    private String aggCB;
 
-    public void setAggCB( String aggCB )
-    {
-        this.aggCB = aggCB;
-    }
-*/
     private String periodTypeId;
 
     public void setPeriodTypeId( String periodTypeId )
@@ -159,6 +155,13 @@
         this.periodTypeId = periodTypeId;
     }
 
+    private String aggData;
+    
+    public void setAggData( String aggData )
+    {
+        this.aggData = aggData;
+    }
+
     private String reportModelTB;
 
     private List<OrganisationUnit> orgUnitList;
@@ -177,18 +180,10 @@
 
     private Integer monthCount;
     
-    private String aggData;
-    
-    public void setAggData( String aggData )
-    {
-        this.aggData = aggData;
-    }
-    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
-    public String execute()
-        throws Exception
+    public String execute() throws Exception
     {
         statementManager.initialise();
         
@@ -238,8 +233,11 @@
         System.out.println( orgUnitList.get( 0 ).getName()+ " : " + selReportObj.getName()+" : Report Generation Start Time is : " + new Date() );
  
         sDate = format.parseDate( startDate );
-
         eDate = format.parseDate( endDate );
+        
+        List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriods( sDate, eDate ) );
+        Collection<Integer> periodIds = new ArrayList<Integer>( getIdentifiers(Period.class, periodList ) );
+        String periodIdsByComma = getCommaDelimitedString( periodIds );
 
         Calendar tempStartDate = Calendar.getInstance();
         Calendar tempEndDate = Calendar.getInstance();
@@ -252,15 +250,33 @@
 
         // Getting DataValues
         List<Report_inDesign> reportDesignList = reportService.getReportDesign( deCodesXMLFileName );
+        String dataElmentIdsByComma = reportService.getDataelementIds( reportDesignList );
+        
         int orgUnitCount = 0;
-
         Iterator<OrganisationUnit> it = orgUnitList.iterator();
         while ( it.hasNext() )
         {
             OrganisationUnit currentOrgUnit = (OrganisationUnit) it.next();
 
+            Map<String, String> aggDeMap = new HashMap<String, String>();
+            if( aggData.equalsIgnoreCase( USEEXISTINGAGGDATA ) )
+            {
+                aggDeMap.putAll( reportService.getResultDataValueFromAggregateTable( currentOrgUnit.getId(), dataElmentIdsByComma, periodIdsByComma ) );
+            }
+            else if( aggData.equalsIgnoreCase( GENERATEAGGDATA ) )
+            {
+                List<OrganisationUnit> childOrgUnitTree = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( currentOrgUnit.getId() ) );
+                List<Integer> childOrgUnitTreeIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, childOrgUnitTree ) );
+                String childOrgUnitsByComma = getCommaDelimitedString( childOrgUnitTreeIds );
+
+                aggDeMap.putAll( reportService.getAggDataFromDataValueTable( childOrgUnitsByComma, dataElmentIdsByComma, periodIdsByComma ) );
+            }
+            else if( aggData.equalsIgnoreCase( USECAPTUREDDATA ) )
+            {
+                aggDeMap.putAll( reportService.getAggDataFromDataValueTable( ""+currentOrgUnit.getId(), dataElmentIdsByComma, periodIdsByComma ) );
+            }
+            
             int count1 = 0;
-
             Iterator<Report_inDesign> reportDesignIterator = reportDesignList.iterator();
             while ( reportDesignIterator.hasNext() )
             {
@@ -655,17 +671,18 @@
                     {
                         if( aggData.equalsIgnoreCase( USECAPTUREDDATA ) )
                         {
-                            tempStr = reportService.getIndividualResultDataValue(deCodeString, sDate, eDate, currentOrgUnit, reportModelTB );
+                            tempStr = reportService.getAggVal( deCodeString, aggDeMap );
+                            //tempStr = reportService.getIndividualResultDataValue(deCodeString, sDate, eDate, currentOrgUnit, reportModelTB );
                         } 
                         else if( aggData.equalsIgnoreCase( GENERATEAGGDATA ) )
                         {
-                            tempStr = reportService.getResultDataValue( deCodeString, sDate, eDate, currentOrgUnit, reportModelTB );
+                            tempStr = reportService.getAggVal( deCodeString, aggDeMap );
+                            //tempStr = reportService.getResultDataValue( deCodeString, sDate, eDate, currentOrgUnit, reportModelTB );
                         }
                         else if( aggData.equalsIgnoreCase( USEEXISTINGAGGDATA ) )
                         {
-                            List<Period> periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates( sDate, eDate ) );
-                            Collection<Integer> periodIds = new ArrayList<Integer>( getIdentifiers(Period.class, periodList ) );
-                            tempStr = reportService.getResultDataValueFromAggregateTable( deCodeString, periodIds, currentOrgUnit, reportModelTB );
+                            tempStr = reportService.getAggVal( deCodeString, aggDeMap );
+                            //tempStr = reportService.getResultDataValueFromAggregateTable( deCodeString, periodIds, currentOrgUnit, reportModelTB );
                         }
                     }
                     else

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/csreview/action/GenerateCSReviewReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/csreview/action/GenerateCSReviewReportResultAction.java	2011-04-29 13:45:23 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/csreview/action/GenerateCSReviewReportResultAction.java	2011-05-18 11:56:37 +0000
@@ -238,7 +238,7 @@
 
         // Getting DeCodes
         List<Report_inDesign> reportDesignList = reportService.getReportDesign( deCodesXMLFileName );
-        String dataElmentIdsByComma = getDataelementIds( reportDesignList );
+        String dataElmentIdsByComma = reportService.getDataelementIds( reportDesignList );
         //List<String> deCodesList = getDECodes( deCodesXMLFileName );
 
         // Getting Exel Template

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/EDReportFormAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/EDReportFormAction.java	2010-08-28 10:15:38 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/EDReportFormAction.java	2011-05-18 11:56:37 +0000
@@ -7,6 +7,9 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.indicator.comparator.IndicatorGroupNameComparator;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -28,7 +31,13 @@
     {
         this.periodService = periodService;
     }
+    
+    private IndicatorService indicatorService ;
 
+    public void setIndicatorService( IndicatorService indicatorService )
+    {
+        this.indicatorService = indicatorService;
+    }
     // -------------------------------------------------------------------------
     // Getter & Setter
     // -------------------------------------------------------------------------
@@ -46,7 +55,14 @@
     {
         return simpleDateFormat;
     }
-
+    
+    private List<IndicatorGroup> indicatorGroups;
+    
+    public List<IndicatorGroup> getIndicatorGroups()
+    {
+        return indicatorGroups;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -54,6 +70,11 @@
     public String execute()
         throws Exception
     {
+        //Indicator Group
+        indicatorGroups = new ArrayList<IndicatorGroup>( indicatorService.getAllIndicatorGroups()) ;
+        Collections.sort( indicatorGroups, new IndicatorGroupNameComparator() );
+        
+        //period information
         periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( new MonthlyPeriodType() ) );
 
         Iterator<Period> periodIterator = periods.iterator();

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/EDReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/EDReportResultAction.java	2011-04-15 11:39:32 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/EDReportResultAction.java	2011-05-18 11:56:37 +0000
@@ -1,14 +1,22 @@
 package org.hisp.dhis.reports.ed.action;
 
+import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
+import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
+
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -31,11 +39,11 @@
 import org.hisp.dhis.indicator.IndicatorGroup;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitShortNameComparator;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.reports.ReportService;
+import org.hisp.dhis.user.CurrentUserService;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -48,6 +56,14 @@
 public class EDReportResultAction
     implements Action
 {
+    
+    private final String GENERATEAGGDATA = "generateaggdata";
+
+    private final String USEEXISTINGAGGDATA = "useexistingaggdata";
+
+    private final String USECAPTUREDDATA = "usecaptureddata";
+    
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -65,13 +81,6 @@
         this.periodService = periodService;
     }
 
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
     private IndicatorService indicatorService;
 
     public void setIndicatorService( IndicatorService indicatorService )
@@ -92,6 +101,13 @@
     {
         this.reportService = reportService;
     }
+    
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }    
 
     // -------------------------------------------------------------------------
     // Getter & Setter
@@ -124,8 +140,23 @@
         this.selectedEndPeriodId = selectedEndPeriodId;
     }
 
+    private Integer indicatorGroupId;
+    
+    public void setIndicatorGroupId( Integer indicatorGroupId )
+    {
+        this.indicatorGroupId = indicatorGroupId;
+    }
+
     private String raFolderName;
-
+    
+    private String aggData;
+    
+    public void setAggData( String aggData )
+    {
+        this.aggData = aggData;
+    }
+    
+    private List<OrganisationUnit> orgUnitList;
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -134,37 +165,20 @@
         throws Exception
     {
         statementManager.initialise();
-
+        
+        orgUnitList = new ArrayList<OrganisationUnit>();
         raFolderName = reportService.getRAFolderName();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MMM-yy" );
 
-        List<Integer> headerInfo = getInfoFromXMLForEDReport();
-
-        String outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator
-            + "output" + File.separator + UUID.randomUUID().toString() + ".xls";
+        String outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + "output" + File.separator + UUID.randomUUID().toString() + ".xls";
 
         WritableWorkbook outputReportWorkbook = Workbook.createWorkbook( new File( outputReportPath ) );
         WritableSheet sheet0 = outputReportWorkbook.createSheet( "EDReport", 0 );
-
-        if ( headerInfo == null || headerInfo.size() == 0 )
-        {
-            System.out.println( "There is problem with report xml file, please check" );
-            sheet0.addCell( new Label( 2, 2, "There is problem with report xml file, please check", getCellFormat2() ) );
-            outputReportWorkbook.write();
-            outputReportWorkbook.close();
-
-            fileName = "EDReport.xls";
-            File outputReportFile = new File( outputReportPath );
-            inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
-
-            outputReportFile.deleteOnExit();
-            statementManager.destroy();
-            return SUCCESS;
-        }
-
+        
+        // Period Info
         Period selectedStartPeriod = periodService.getPeriod( selectedStartPeriodId );
         Period selectedEndPeriod = periodService.getPeriod( selectedEndPeriodId );
-
+        
         if ( selectedStartPeriod == null || selectedEndPeriod == null )
         {
             System.out.println( "There is no period with that id" );
@@ -172,7 +186,7 @@
             outputReportWorkbook.write();
             outputReportWorkbook.close();
 
-            fileName = "EDReport.xls";
+            fileName = "IndicatorReport.xls";
             File outputReportFile = new File( outputReportPath );
             inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
 
@@ -181,17 +195,34 @@
             return SUCCESS;
         }
 
-        // HardCoded with Bihar State OrgUnitId - 7
-        OrganisationUnit selectedOrgUnit = organisationUnitService.getOrganisationUnit( headerInfo.get( 0 ) );
+        List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriods( selectedStartPeriod.getStartDate(), selectedEndPeriod.getEndDate() ) );
+        Collection<Integer> periodIds = new ArrayList<Integer>( getIdentifiers(Period.class, periodList ) );
+        String periodIdsByComma = getCommaDelimitedString( periodIds );
 
-        if ( selectedOrgUnit == null )
-        {
-            System.out.println( "There is no orgunit with that id" );
-            sheet0.addCell( new Label( 2, 2, "There is no orgunit with that id", getCellFormat2() ) );
+        
+        List<OrganisationUnit> curUserRootOrgUnitList = new ArrayList<OrganisationUnit>( currentUserService.getCurrentUser().getOrganisationUnits() );
+        String orgUnitName = "";
+        
+        if ( curUserRootOrgUnitList != null && curUserRootOrgUnitList.size() > 0 )
+        {
+            for ( OrganisationUnit orgUnit : curUserRootOrgUnitList )
+            {
+                orgUnitName += orgUnit.getName() + ", ";
+                List<OrganisationUnit> childList = new ArrayList<OrganisationUnit>( orgUnit.getChildren() );
+                Collections.sort( childList, new OrganisationUnitShortNameComparator() );
+                orgUnitList.addAll( childList );
+                orgUnitList.add( orgUnit );
+            }
+        }
+      
+        if ( curUserRootOrgUnitList == null || curUserRootOrgUnitList.size() == 0 )
+        {
+            System.out.println( "There is no orgunit with that User" );
+            sheet0.addCell( new Label( 2, 2, "There is no orgunit with that User", getCellFormat2() ) );
             outputReportWorkbook.write();
             outputReportWorkbook.close();
 
-            fileName = "EDReport.xls";
+            fileName = "IndicatorReport.xls";
             File outputReportFile = new File( outputReportPath );
             inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
 
@@ -201,13 +232,8 @@
             return SUCCESS;
         }
 
-        List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>( selectedOrgUnit.getChildren() );
-        Collections.sort( orgUnitList, new OrganisationUnitShortNameComparator() );
-        orgUnitList.add( selectedOrgUnit );
-
-        // HardCoded with ED IndicatorGroup - 12
-        IndicatorGroup selectedIndicatorGroup = indicatorService.getIndicatorGroup( headerInfo.get( 1 ) );
-
+        IndicatorGroup selectedIndicatorGroup = indicatorService.getIndicatorGroup( indicatorGroupId );
+        
         if ( selectedIndicatorGroup == null )
         {
             System.out.println( "There is no IndicatorGroup with that id" );
@@ -215,7 +241,7 @@
             outputReportWorkbook.write();
             outputReportWorkbook.close();
 
-            fileName = "EDReport.xls";
+            fileName = "IndicatorReport.xls";
             File outputReportFile = new File( outputReportPath );
             inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
 
@@ -226,7 +252,8 @@
         }
 
         List<Indicator> indicators = new ArrayList<Indicator>( selectedIndicatorGroup.getMembers() );
-
+        String dataElmentIdsByComma = getDataelementIds( indicators );
+        
         int rowCount = 4;
         int colCount = 0;
 
@@ -243,12 +270,10 @@
             sheet0.addCell( new Label( colCount++, rowCount + 1, "Numerator", getCellFormat1() ) );
             sheet0.addCell( new Label( colCount++, rowCount + 1, "Denominator", getCellFormat1() ) );
             sheet0.addCell( new Label( colCount++, rowCount + 1, "Indicator", getCellFormat1() ) );
-
-            // colCount += 3;
         }
 
         // Printing Main Header Info
-        String mainHeaderInfo = "Key Indicator Analysis - " + selectedOrgUnit.getName() + " From : "
+        String mainHeaderInfo = "Indicator Group Name - " + selectedIndicatorGroup.getName() +  " ,OrgUnit Name is "+ orgUnitName + " From : "
             + simpleDateFormat.format( selectedStartPeriod.getStartDate() ) + " To : "
             + simpleDateFormat.format( selectedEndPeriod.getStartDate() );
         sheet0.mergeCells( 0, 1, colCount - 1, 1 );
@@ -259,7 +284,12 @@
         for ( OrganisationUnit ou : orgUnitList )
         {
             colCount = 0;
-
+            Map<String, String> aggDeMap = new HashMap<String, String>();
+            if( aggData.equalsIgnoreCase( USEEXISTINGAGGDATA ) )
+            {
+                aggDeMap.putAll( reportService.getResultDataValueFromAggregateTable( ou.getId(), dataElmentIdsByComma, periodIdsByComma ) );
+            }
+            
             if ( slno != orgUnitList.size() )
             {
                 sheet0.addCell( new Number( colCount++, rowCount, slno, getCellFormat2() ) );
@@ -272,12 +302,78 @@
 
             for ( Indicator indicator : indicators )
             {
-                Double numValue = aggregationService.getAggregatedNumeratorValue( indicator, selectedStartPeriod
-                    .getStartDate(), selectedEndPeriod.getEndDate(), ou );
-                Double denValue = aggregationService.getAggregatedDenominatorValue( indicator, selectedStartPeriod
-                    .getStartDate(), selectedEndPeriod.getEndDate(), ou );
-                Double indValue = aggregationService.getAggregatedIndicatorValue( indicator, selectedStartPeriod
-                    .getStartDate(), selectedEndPeriod.getEndDate(), ou );
+                Double numValue = 0.0;
+                Double denValue = 0.0;
+                Double indValue = 0.0;
+                
+                if( aggData.equalsIgnoreCase( GENERATEAGGDATA ) )
+                {
+                     numValue = aggregationService.getAggregatedNumeratorValue( indicator, selectedStartPeriod.getStartDate(), selectedEndPeriod.getEndDate(), ou );
+                     denValue = aggregationService.getAggregatedDenominatorValue( indicator, selectedStartPeriod.getStartDate(), selectedEndPeriod.getEndDate(), ou );
+                     indValue = aggregationService.getAggregatedIndicatorValue( indicator, selectedStartPeriod.getStartDate(), selectedEndPeriod.getEndDate(), ou );
+                }
+                else if ( aggData.equalsIgnoreCase( USECAPTUREDDATA ) )
+                {
+                    indValue = reportService.getIndividualIndicatorValue( indicator, ou, selectedStartPeriod.getStartDate(), selectedEndPeriod.getEndDate() );
+                    
+                    String tempStr = reportService.getIndividualResultDataValue( indicator.getNumerator(), selectedStartPeriod.getStartDate(), selectedEndPeriod.getEndDate(), ou, "" );
+                   
+                     try
+                     {
+                         numValue = Double.parseDouble( tempStr );
+                     }
+                     catch ( Exception e )
+                     {
+                         numValue = 0.0;
+                     }
+
+                     tempStr = reportService.getIndividualResultDataValue( indicator.getDenominator(), selectedStartPeriod.getStartDate(), selectedEndPeriod.getEndDate(), ou, "" );
+
+                     try
+                     {
+                         denValue = Double.parseDouble( tempStr );
+                     }
+                     catch ( Exception e )
+                     {
+                         denValue = 0.0;
+                     }
+                }
+                else if ( aggData.equalsIgnoreCase( USEEXISTINGAGGDATA ) )
+                {
+                    try
+                    {
+                        numValue = Double.parseDouble( reportService.getAggVal( indicator.getNumerator(), aggDeMap ) );
+                    }
+                    catch( Exception e )
+                    {
+                        numValue = 0.0;
+                    }
+                    
+                    try
+                    {
+                        denValue = Double.parseDouble( reportService.getAggVal( indicator.getDenominator(), aggDeMap ) );    
+                    }
+                    catch( Exception e )
+                    {
+                        denValue = 0.0;
+                    }
+
+                    try
+                    {
+                        if( denValue != 0.0 )
+                        {
+                                indValue = ( numValue / denValue ) * indicator.getIndicatorType().getFactor();
+                        }
+                        else
+                        {
+                                indValue = 0.0;
+                        }
+                    }
+                    catch( Exception e )
+                    {
+                        indValue = 0.0;
+                    }
+                }
 
                 if ( indValue == null )
                     indValue = 0.0;
@@ -333,9 +429,15 @@
         outputReportWorkbook.write();
         outputReportWorkbook.close();
 
-        fileName = "EDReport_" + simpleDateFormat.format( selectedStartPeriod.getStartDate() ) + "_"
-            + simpleDateFormat.format( selectedEndPeriod.getStartDate() ) + ".xls";
+        
+        fileName = "IndicatorReport_" + orgUnitName + "_" + simpleDateFormat.format( selectedStartPeriod.getStartDate() ) + "_" + simpleDateFormat.format( selectedEndPeriod.getStartDate() ) + ".xls";
+        fileName = fileName.replaceAll( " ", "" );
+        fileName = fileName.replaceAll( ",", "_" );
+        
         File outputReportFile = new File( outputReportPath );
+        
+        System.out.println( fileName );
+        
         inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
 
         outputReportFile.deleteOnExit();
@@ -447,5 +549,40 @@
 
         return wCellformat;
     }
+    
+    public String getDataelementIds( List<Indicator> indicatorList )
+    {
+        String dataElmentIdsByComma = "-1";
+        for( Indicator indicator : indicatorList )
+        {
+            String formula = indicator.getNumerator() + " + " + indicator.getDenominator();
+            try
+            {
+                Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
+
+                Matcher matcher = pattern.matcher( formula );
+                StringBuffer buffer = new StringBuffer();
+
+                while ( matcher.find() )
+                {
+                    String replaceString = matcher.group();
+
+                    replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
+                    replaceString = replaceString.substring( 0, replaceString.indexOf( '.' ) );
+
+                    int dataElementId = Integer.parseInt( replaceString );
+                    dataElmentIdsByComma += "," + dataElementId;
+                    replaceString = "";
+                    matcher.appendReplacement( buffer, replaceString );
+                }
+            }
+            catch( Exception e )
+            {
+                
+            }
+        }
+        
+        return dataElmentIdsByComma;
+    }
 
 }

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/meta/action/GenerateMetaDataReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/meta/action/GenerateMetaDataReportResultAction.java	2011-04-15 11:53:12 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/meta/action/GenerateMetaDataReportResultAction.java	2011-05-18 11:56:37 +0000
@@ -456,6 +456,10 @@
                 sheet0.addCell( new Label( colStart + 6, rowStart, "DataElementShortName", getCellFormat1() ) );
                 sheet0.addCell( new Label( colStart + 7, rowStart, "DataElementType", getCellFormat1() ) );
                 sheet0.addCell( new Label( colStart + 8, rowStart, "DataElementUrl", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 9, rowStart, "DomainType", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 10, rowStart, "NumberType", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 11, rowStart, "PeriodType", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 12, rowStart, "LastUpdated", getCellFormat1() ) );
             }
         }
 
@@ -483,7 +487,50 @@
                     sheet0.addCell( new Label( colStart + 6, rowStart, dataElement.getShortName(), wCellformat ) );
                     sheet0.addCell( new Label( colStart + 7, rowStart, dataElement.getType(), wCellformat ) );
                     sheet0.addCell( new Label( colStart + 8, rowStart, dataElement.getUrl(), wCellformat ) );
+                    
+                    String domainType = new String();
+                    if ( dataElement.getDomainType() != null )
+                    {
+                        domainType = dataElement.getDomainType();
+                    }
+                    else
+                    {
+                        domainType = "";
+                    }
+                    sheet0.addCell( new Label( colStart + 9, rowStart, domainType, wCellformat ) );
+                    
+                    String numberType = new String();
+                    if ( dataElement.getNumberType() != null )
+                    {
+                        numberType = dataElement.getNumberType();
+                    }
+                    else
+                    {
+                        numberType = "";
+                    }
+                    sheet0.addCell( new Label( colStart + 10, rowStart, numberType, wCellformat ) );
 
+                    String periodType = new String();
+                    if ( dataElement.getPeriodType() != null )
+                    {
+                        periodType = dataElement.getPeriodType().getName();
+                    }
+                    else
+                    {
+                        periodType = "";
+                    }
+                    sheet0.addCell( new Label( colStart + 11, rowStart, periodType, wCellformat ) );
+                    
+                    String lastUpdate = new String();
+                    if ( dataElement.getLastUpdated() != null )
+                    {
+                        lastUpdate = dataElement.getLastUpdated().toString();
+                    }
+                    else
+                    {
+                        lastUpdate = "";
+                    }
+                    sheet0.addCell( new Label( colStart + 12, rowStart, lastUpdate, wCellformat ) );
                 }
             }
 
@@ -491,7 +538,7 @@
 
             rowStart++;
         }
-
+        
         outputReportWorkbook.write();
         outputReportWorkbook.close();
 
@@ -545,6 +592,10 @@
                 sheet0.addCell( new Label( colStart + 6, rowStart, "DataElementShortName", getCellFormat1() ) );
                 sheet0.addCell( new Label( colStart + 7, rowStart, "DataElementType", getCellFormat1() ) );
                 sheet0.addCell( new Label( colStart + 8, rowStart, "DataElementUrl", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 9, rowStart, "DomainType", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 10, rowStart, "NumberType", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 11, rowStart, "PeriodType", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 12, rowStart, "LastUpdated", getCellFormat1() ) );
             }
         }
 
@@ -566,7 +617,7 @@
 
             if ( incID.equalsIgnoreCase( PRINT ) )
             {
-                sheet0.mergeCells( colStart + 1, rowStart, colStart + 8, rowStart );
+                sheet0.mergeCells( colStart + 1, rowStart, colStart + 12, rowStart );
             }
 
             rowStart++;
@@ -596,6 +647,50 @@
                         sheet0.addCell( new Label( colStart + 6, rowStart, dataElement.getShortName(), wCellformat ) );
                         sheet0.addCell( new Label( colStart + 7, rowStart, dataElement.getType(), wCellformat ) );
                         sheet0.addCell( new Label( colStart + 8, rowStart, dataElement.getUrl(), wCellformat ) );
+                        
+                        String domainType = new String();
+                        if ( dataElement.getDomainType() != null )
+                        {
+                            domainType = dataElement.getDomainType();
+                        }
+                        else
+                        {
+                            domainType = "";
+                        }
+                        sheet0.addCell( new Label( colStart + 9, rowStart, domainType, wCellformat ) );
+                        
+                        String numberType = new String();
+                        if ( dataElement.getNumberType() != null )
+                        {
+                            numberType = dataElement.getNumberType();
+                        }
+                        else
+                        {
+                            numberType = "";
+                        }
+                        sheet0.addCell( new Label( colStart + 10, rowStart, numberType, wCellformat ) );
+
+                        String periodType = new String();
+                        if ( dataElement.getPeriodType() != null )
+                        {
+                            periodType = dataElement.getPeriodType().getName();
+                        }
+                        else
+                        {
+                            periodType = "";
+                        }
+                        sheet0.addCell( new Label( colStart + 11, rowStart, periodType, wCellformat ) );
+                        
+                        String lastUpdate = new String();
+                        if ( dataElement.getLastUpdated() != null )
+                        {
+                            lastUpdate = dataElement.getLastUpdated().toString();
+                        }
+                        else
+                        {
+                            lastUpdate = "";
+                        }
+                        sheet0.addCell( new Label( colStart + 12, rowStart, lastUpdate, wCellformat ) );
                     }
                 }
 
@@ -656,6 +751,11 @@
                 sheet0.addCell( new Label( colStart + 6, rowStart, "organisationUnitCode", getCellFormat1() ) );
                 sheet0.addCell( new Label( colStart + 7, rowStart, "organisationUnitUrl", getCellFormat1() ) );
                 sheet0.addCell( new Label( colStart + 8, rowStart, "Last Updated", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 9, rowStart, "Contact Person", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 10, rowStart, "Phone Number", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 11, rowStart, "Email", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 12, rowStart, "Comment", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 13, rowStart, "Coordinates", getCellFormat1() ) );
             }
         }
 
@@ -677,7 +777,7 @@
 
             if ( incID.equalsIgnoreCase( PRINT ) )
             {
-                sheet0.mergeCells( colStart + 1, rowStart, colStart + 8, rowStart );
+                sheet0.mergeCells( colStart + 1, rowStart, colStart + 13, rowStart );
             }
 
             rowStart++;
@@ -748,6 +848,62 @@
                             lastUpdate = "";
                         }
                         sheet0.addCell( new Label( colStart + 8, rowStart, lastUpdate, wCellformat ) );
+                        
+                        String contactPerson = new String();
+                        if ( organisationUnit.getContactPerson() != null )
+                        {
+                            contactPerson = organisationUnit.getContactPerson();
+                        }
+                        else
+                        {
+                            contactPerson = "";
+                        }
+                        sheet0.addCell( new Label( colStart + 9, rowStart, contactPerson, wCellformat ) );
+
+                        String phoneNumber = new String();
+                        if( organisationUnit.getPhoneNumber() != null )
+                        {
+                            phoneNumber = organisationUnit.getPhoneNumber();
+                        }
+                        else
+                        {
+                            phoneNumber = "";
+                        }
+                        sheet0.addCell( new Label( colStart + 10, rowStart, phoneNumber, wCellformat ) );
+                        
+                        String email = new String();
+                        if( organisationUnit.getEmail() != null )
+                        {
+                            email = organisationUnit.getEmail();
+                        }
+                        else
+                        {
+                            email = "";
+                        }
+                        sheet0.addCell( new Label( colStart + 11, rowStart, email, wCellformat ) );
+                        
+                        String comment = new String();
+                        if( organisationUnit.getComment() != null )
+                        {
+                            comment = organisationUnit.getComment();
+                        }
+                        else
+                        {
+                            comment = "";
+                        }
+                        sheet0.addCell( new Label( colStart + 12, rowStart, comment, wCellformat ) );
+                        
+                        String coordinates =  new String();
+                        if( organisationUnit.getCoordinates() != null )
+                        {
+                            coordinates = organisationUnit.getCoordinates();
+                        }
+                        else
+                        {
+                            coordinates = "";
+                        }
+                        sheet0.addCell( new Label( colStart + 13, rowStart, coordinates, wCellformat ) );
+                        
                     }
                     else
                     {
@@ -902,6 +1058,8 @@
                 sheet0.addCell( new Label( colStart + 9, rowStart, "Contact Person", getCellFormat1() ) );
                 sheet0.addCell( new Label( colStart + 10, rowStart, "Phone Number", getCellFormat1() ) );
                 sheet0.addCell( new Label( colStart + 11, rowStart, "Email", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 12, rowStart, "Comment", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 13, rowStart, "Coordinates", getCellFormat1() ) );
             }
             else if ( incID.equalsIgnoreCase( SOURCE ) )
             {
@@ -1014,6 +1172,28 @@
                         email = "";
                     }
                     sheet0.addCell( new Label( colStart + 11, rowStart, email, wCellformat ) );
+                    
+                    String comment = new String();
+                    if( ou.getComment() != null )
+                    {
+                        comment = ou.getComment();
+                    }
+                    else
+                    {
+                        comment = "";
+                    }
+                    sheet0.addCell( new Label( colStart + 12, rowStart, comment, wCellformat ) );
+                    
+                    String coordinates =  new String();
+                    if( ou.getCoordinates() != null )
+                    {
+                        coordinates = ou.getCoordinates();
+                    }
+                    else
+                    {
+                        coordinates = "";
+                    }
+                    sheet0.addCell( new Label( colStart + 13, rowStart, coordinates, wCellformat ) );
                 }
                 else if ( incID.equalsIgnoreCase( SOURCE ) )
                 {
@@ -1342,8 +1522,7 @@
                     sheet0.addCell( new Label( colStart + 2, rowStart, dataSet.getShortName(), wCellformat ) );
                     sheet0.addCell( new Label( colStart + 3, rowStart, dataSet.getCode(), wCellformat ) );
                     sheet0.addCell( new Label( colStart + 4, rowStart, dataSet.getAlternativeName(), wCellformat ) );
-                    sheet0
-                        .addCell( new Label( colStart + 5, rowStart, dataSet.getPeriodType().getName(), wCellformat ) );
+                    sheet0.addCell( new Label( colStart + 5, rowStart, dataSet.getPeriodType().getName(), wCellformat ) );
                 }
             }
 
@@ -1405,8 +1584,8 @@
                 sheet0.addCell( new Label( colStart + 5, rowStart, "ValidationRuleType", getCellFormat1() ) );
                 sheet0.addCell( new Label( colStart + 6, rowStart, "ValidationRuleLeftSideDescription",
                     getCellFormat1() ) );
-                sheet0.addCell( new Label( colStart + 7, rowStart, "ValidationRuleRightSideDescription",
-                    getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 7, rowStart, "ValidationRuleRightSideDescription", getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 8, rowStart, "ValidationRulePeriodType", getCellFormat1() ) );
             }
         }
 
@@ -1435,6 +1614,17 @@
                         wCellformat ) );
                     sheet0.addCell( new Label( colStart + 7, rowStart, validationRule.getRightSide().getDescription(),
                         wCellformat ) );
+                    
+                    String periodType = new String();
+                    if ( validationRule.getPeriodType() != null )
+                    {
+                        periodType = validationRule.getPeriodType().getName();
+                    }
+                    else
+                    {
+                        periodType = "";
+                    }
+                    sheet0.addCell( new Label( colStart + 8, rowStart, periodType, wCellformat ) );
                 }
             }
 
@@ -1497,6 +1687,7 @@
                     getCellFormat1() ) );
                 sheet0.addCell( new Label( colStart + 7, rowStart, "ValidationRuleRightSideDescription",
                     getCellFormat1() ) );
+                sheet0.addCell( new Label( colStart + 8, rowStart, "ValidationRulePeriodType", getCellFormat1() ) );
             }
         }
 
@@ -1518,7 +1709,7 @@
 
             if ( incID.equalsIgnoreCase( PRINT ) )
             {
-                sheet0.mergeCells( colStart + 1, rowStart, colStart + 7, rowStart );
+                sheet0.mergeCells( colStart + 1, rowStart, colStart + 8, rowStart );
             }
 
             rowStart++;
@@ -1547,6 +1738,16 @@
                             .getDescription(), wCellformat ) );
                         sheet0.addCell( new Label( colStart + 7, rowStart, validationRule.getRightSide()
                             .getDescription(), wCellformat ) );
+                        String periodType = new String();
+                        if ( validationRule.getPeriodType() != null )
+                        {
+                            periodType = validationRule.getPeriodType().getName();
+                        }
+                        else
+                        {
+                            periodType = "";
+                        }
+                        sheet0.addCell( new Label( colStart + 8, rowStart, periodType, wCellformat ) );
                     }
                 }
 

=== modified file 'local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml	2011-04-29 13:45:23 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml	2011-05-18 11:56:37 +0000
@@ -173,9 +173,8 @@
         class="org.hisp.dhis.reports.ed.action.EDReportFormAction"
         scope="prototype">
         
-        <property name="periodService">
-            <ref bean="org.hisp.dhis.period.PeriodService"/>
-        </property>
+        <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+        <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
     </bean>
     
     <bean id="org.hisp.dhis.reports.ed.action.EDReportResultAction"
@@ -183,20 +182,12 @@
         scope="prototype">
         
         <property name="statementManager" ref="statementManager"/>
-        <property name="periodService">
-            <ref bean="org.hisp.dhis.period.PeriodService"/>
-        </property>
-        <property name="organisationUnitService">
-            <ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
-        </property>
-        <property name="indicatorService">
-            <ref bean="org.hisp.dhis.indicator.IndicatorService"/>
-        </property>
-        <property name="aggregationService">
-            <ref bean="org.hisp.dhis.aggregation.AggregationService"/>
-        </property>
-        <property name="reportService" ref="org.hisp.dhis.reports.ReportService">
-        </property>
+        <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+        <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
+        <property name="aggregationService" ref="org.hisp.dhis.aggregation.AggregationService" />
+        <property name="reportService" ref="org.hisp.dhis.reports.ReportService" />
+        <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+        
     </bean>
     
     <!-- Auto Reports -->
@@ -1175,6 +1166,7 @@
         <property name="relationshipTypeService">
             <ref bean="org.hisp.dhis.relationship.RelationshipTypeService"/>
         </property>
+        <property name="jdbcTemplate" ref="jdbcTemplate"/>
     </bean>
     
     <!-- NBITS : BenificiaryInfo Report -->
@@ -1311,6 +1303,5 @@
         <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
         <property name="jdbcTemplate" ref="jdbcTemplate"/>
     </bean>
-
     
 </beans>

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/edReportForm.vm'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/edReportForm.vm	2010-06-04 11:50:05 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/edReportForm.vm	2011-05-18 11:56:37 +0000
@@ -1,46 +1,62 @@
 
-<h1>ED Report Analyser</h1>
-<hr />  
-<br />
+<h3>Indicator Report Analyser</h3>
+<hr /><br />
 
-<form id="reportForm" name="reportForm" action="generateEDReport.action" method="post" onsubmit="return formValidationsForEDReport()" target="_blank">        
-    <table align="center" style=" border-collapse: collapse; margin-top: 0;" cellpadding="0" cellspacing="0" width="730" border=0>                      
+<form id="reportForm" name="reportForm" action="generateEDReport.action" method="post" onsubmit="return formValidationsForEDReport()" target="_blank">
+    <table align="center" style=" border-collapse: collapse; margin-top: 0;" cellpadding="0" cellspacing="0" width="70%" border=0>
         <tr>
             <td class="NormalB">
-                From Date : <br />
+                1.$i18n.getString( "indicator_group" ) :<br />
+                <select id="indicatorGroupId" name="indicatorGroupId" style="width:200px">
+                    <option value="ALL">[ Select IndicatorGroup / All ]</option>
+                    #foreach ( $group in $indicatorGroups )
+                    <option value="$group.id" title="$group.name">$group.name</option>
+                    #end
+                </select>
+            </td>
+            <td class="NormalB">
+                3.From Date : <br />
                 <select id="selectedStartPeriodId" name="selectedStartPeriodId" style="width:200px">
                     #foreach ( $mperiod in $periods )
                         <option value="$mperiod.id">$simpleDateFormat.format( $mperiod.startDate )</option>
                     #end
                 </select>
             </td>
-         </tr>   
-        <tr>
-            <td>&nbsp;</td>
-        </tr>
-        <tr>
-            <td>&nbsp;</td>
-        </tr>
-        <tr>
-            <td class="NormalB">
-                To Date : <br />
+        </tr>
+        <tr>
+            <td>&nbsp;</td><td>&nbsp;</td>
+        </tr>
+        <tr>
+            <td>&nbsp;</td><td>&nbsp;</td>
+        </tr>
+        <tr>
+            <td class="NormalB">
+                2.$i18n.getString( "generated_data_type" ) :<br />
+                <select id="aggData" name="aggData" style="width:200px">
+                    <option value="generateaggdata">$i18n.getString( "generate_agg_data" )</option>
+                    <option value="useexistingaggdata">$i18n.getString( "use_existing_agg_data" )</option>
+                    <option value="usecaptureddata">$i18n.getString( "use_captured_data" )</option>
+                </select>
+            </td>
+            <td class="NormalB">
+                4.To Date : <br />
                 <select id="selectedEndPeriodId" name="selectedEndPeriodId" style="width:200px">
                     #foreach ( $mperiod in $periods )
                         <option value="$mperiod.id">$simpleDateFormat.format( $mperiod.startDate )</option>
                     #end
                 </select>
             </td>
-         </tr>   
-        <tr>
-            <td>&nbsp;</td>
-        </tr>
-        <tr>
-            <td>&nbsp;</td>
-        </tr>
-         <tr>   
+        </tr>
+        <tr>
+            <td>&nbsp;</td><td>&nbsp;</td>
+        </tr>
+        <tr>
+            <td>&nbsp;</td><td>&nbsp;</td>
+        </tr>
+        <tr>   
             <td class="NormalB">
-                <input type="submit" name="generate" value='Generate Report'/>
+                <input type="submit" name="generate" value='Generate Report' style="width:200px" />
             </td>
-         </tr>   
-      </table>  
- </form>     
\ No newline at end of file
+        </tr>
+    </table>  
+ </form>
\ No newline at end of file

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/reports.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/reports.js	2011-04-15 11:40:14 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/reports.js	2011-05-18 11:56:37 +0000
@@ -517,22 +517,27 @@
 
 
 //-----------------------------------------------------------------------------
-// FormValidations for ED Report
+//FormValidations for ED Report
 //-----------------------------------------------------------------------------
 function formValidationsForEDReport()
 {
 		
-    var startPeriodObj = document.getElementById('selectedStartPeriodId');
-    var endPeriodObj = document.getElementById('selectedEndPeriodId');
+	var startPeriodObj = document.getElementById('selectedStartPeriodId');
+	var endPeriodObj = document.getElementById('selectedEndPeriodId');
+	var indicatorGroupObj = document.getElementById('indicatorGroupId');
 	
-    sDateTxt = startPeriodObj.options[startPeriodObj.selectedIndex].text;
-    sDate = formatDate(new Date(getDateFromFormat(sDateTxt,"MMM-y")),"yyyy-MM-dd");
-    eDateTxt = endPeriodObj.options[endPeriodObj.selectedIndex].text;
-    eDate = formatDate(new Date(getDateFromFormat(eDateTxt,"MMM-y")),"yyyy-MM-dd");
-        
-    if(sDate > eDate) {
-        alert("Starting Date is Greater");return false;
-    }
-
-    return true;
+	sDateTxt = startPeriodObj.options[startPeriodObj.selectedIndex].text;
+	sDate = formatDate(new Date(getDateFromFormat(sDateTxt,"MMM-y")),"yyyy-MM-dd");
+	eDateTxt = endPeriodObj.options[endPeriodObj.selectedIndex].text;
+	eDate = formatDate(new Date(getDateFromFormat(eDateTxt,"MMM-y")),"yyyy-MM-dd");
+ 
+	if(sDate > eDate) 
+	{
+		alert( "Starting Date is Greater" );return false;
+	}
+	else if( indicatorGroupObj.options[indicatorGroupObj.selectedIndex].value == "ALL" )
+	{
+		alert( "Please Select Indicator Group" );return false;
+	}
+	return true;
 } // formValidations Function End

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm	2011-04-15 11:40:14 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm	2011-05-18 11:56:37 +0000
@@ -1,85 +1,85 @@
-<h2>Report Analyser</h2>
-
-#if( $auth.hasAccess( "dhis-web-reports", "reportManagement") )
-    <ul>
-        <li>Report Management</li>
-        <ul>
-            <li><a href = "reportManagement.action">Report Management</a></li>
-        </ul>
-    </ul>
-#end
-
-#if( $auth.hasAccess( "dhis-web-reports", "upwardReportAnalyser") )
-    <ul>
-        <li>Report Analysis</li>
-        <ul>
-            #if( $auth.hasAccess( "dhis-web-reports", "upwardReportAnalyser") )
-                <li><a href = "upwardReportAnalyser.action">GOI Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "edReportForm") )
-                <li><a href = "edReportForm.action">ED Report</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "routineReportAnalyser") )
-                <li><a href = "routineReportAnalyser.action">Routine Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "feedbackReportAnalyser") )
-                <li><a href = "feedbackReportAnalyser.action">Feedback Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "aggregationReportAnalyser") )
-                <li><a href = "aggregationReportAnalyser.action">Aggregation Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "linelistingReportAnalyser") )
-                <li><a href = "linelistingReportAnalyser.action">Linelisting Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "periodWiseprogressReportAnalyser") )
-                <li><a href = "periodWiseprogressReportAnalyser.action">Periodwise Progress Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "ouWiseProgressReportAnalyser") )
-                <li><a href = "ouWiseProgressReportAnalyser.action">Orgunitwise Progress Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "metaDataReportAnalyser") )
-                <li><a href = "metaDataReportAnalyser.action">Meta Data Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "dataSetLockReportAnalyser") )
-                <li><a href = "dataSetLockReportAnalyser.action">DataSet Lock Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "quarterlyPhysicalReport") )
-                <li><a href = "quarterlyPhysicalReport.action ">Quarterly Physical Output Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "mobileReportAnalyser") )
-                <li><a href = "mobileReportAnalyser.action">Mobile Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "csReviewReportForm") )
-                <li><a href = "csReviewReportForm.action">CS Review Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "populateUsers") )
-                <li><a href = "populateUsers.action">Populate Users</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "autoReportAnalyser") )
-                <li><a href = "autoReportAnalyser.action">Bulk Reports</a></li>
-            #end
-            <li><a href = "populateMultipleUsers.action">Populate Users From Excel</a></li>
-            <!--<li><a href = "advancedReportAnalyser.action">Advanced Reports</a></li>-->  
-        </ul>
-    </ul>
-#end
-
-#if( $auth.hasAccess( "dhis-web-reports", "benificiaryInfoReportsAnalyser") )
-    <ul>
-        <li>NameBased Reports</li>
-        <ul>
-            #if( $auth.hasAccess( "dhis-web-reports", "benificiaryInfoReportsAnalyser") )
-                <li><a href = "benificiaryInfoReportsAnalyser.action">NBITS Benificiary Info</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "activePlanReportsAnalyser") )
-                <li><a href = "activePlanReportsAnalyser.action">NBITS ActivityPlan</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "portalReportsAnalyser") )
-                <li><a href = "portalReportsAnalyser.action">NBITS Portal Reports</a></li>
-            #end
-            #if( $auth.hasAccess( "dhis-web-reports", "nbitsReportsAnalyser") )
-                <li><a href = "nbitsReportsAnalyser.action">NBITS Reports</a></li>
-            #end
-        </ul>
-    </ul>
+<h2>Report Analyser</h2>
+
+#if( $auth.hasAccess( "dhis-web-reports", "reportManagement") )
+    <ul>
+        <li>Report Management</li>
+        <ul>
+            <li><a href = "reportManagement.action">Report Management</a></li>
+        </ul>
+    </ul>
+#end
+
+#if( $auth.hasAccess( "dhis-web-reports", "upwardReportAnalyser") )
+    <ul>
+        <li>Report Analysis</li>
+        <ul>
+            #if( $auth.hasAccess( "dhis-web-reports", "upwardReportAnalyser") )
+                <li><a href = "upwardReportAnalyser.action">GOI Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "edReportForm") )
+                <li><a href = "edReportForm.action">Indicator Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "routineReportAnalyser") )
+                <li><a href = "routineReportAnalyser.action">Routine Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "feedbackReportAnalyser") )
+                <li><a href = "feedbackReportAnalyser.action">Feedback Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "aggregationReportAnalyser") )
+                <li><a href = "aggregationReportAnalyser.action">Aggregation Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "linelistingReportAnalyser") )
+                <li><a href = "linelistingReportAnalyser.action">Linelisting Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "periodWiseprogressReportAnalyser") )
+                <li><a href = "periodWiseprogressReportAnalyser.action">Periodwise Progress Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "ouWiseProgressReportAnalyser") )
+                <li><a href = "ouWiseProgressReportAnalyser.action">Orgunitwise Progress Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "metaDataReportAnalyser") )
+                <li><a href = "metaDataReportAnalyser.action">Meta Data Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "dataSetLockReportAnalyser") )
+                <li><a href = "dataSetLockReportAnalyser.action">DataSet Lock Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "quarterlyPhysicalReport") )
+                <li><a href = "quarterlyPhysicalReport.action ">Quarterly Physical Output Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "mobileReportAnalyser") )
+                <li><a href = "mobileReportAnalyser.action">Mobile Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "csReviewReportForm") )
+                <li><a href = "csReviewReportForm.action">CS Review Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "populateUsers") )
+                <li><a href = "populateUsers.action">Populate Users</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "autoReportAnalyser") )
+                <li><a href = "autoReportAnalyser.action">Bulk Reports</a></li>
+            #end
+            <li><a href = "populateMultipleUsers.action">Populate Users From Excel</a></li>
+            <!--<li><a href = "advancedReportAnalyser.action">Advanced Reports</a></li>-->  
+        </ul>
+    </ul>
+#end
+
+#if( $auth.hasAccess( "dhis-web-reports", "benificiaryInfoReportsAnalyser") )
+    <ul>
+        <li>NameBased Reports</li>
+        <ul>
+            #if( $auth.hasAccess( "dhis-web-reports", "benificiaryInfoReportsAnalyser") )
+                <li><a href = "benificiaryInfoReportsAnalyser.action">NBITS Benificiary Info</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "activePlanReportsAnalyser") )
+                <li><a href = "activePlanReportsAnalyser.action">NBITS ActivityPlan</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "portalReportsAnalyser") )
+                <li><a href = "portalReportsAnalyser.action">NBITS Portal Reports</a></li>
+            #end
+            #if( $auth.hasAccess( "dhis-web-reports", "nbitsReportsAnalyser") )
+                <li><a href = "nbitsReportsAnalyser.action">NBITS Reports</a></li>
+            #end
+        </ul>
+    </ul>
 #end
\ No newline at end of file