← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6011: Added tracking ACS, CVD report and remove request object from NRHM Report

 

------------------------------------------------------------
revno: 6011
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-02-17 12:39:28 +0530
message:
  Added tracking ACS,CVD report and remove request object from NRHM Report
added:
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_ACS.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_Action.java
modified:
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportResultAction.java
  local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-reports-national/src/main/resources/struts.xml
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/chart.js
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/dataCompleteness.js
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/dataSetReport.js
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/datasetLockReport.js
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/document.js
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/grading.js
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/lists.js
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/report.js
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/reportParams.js
  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/table.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 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportResultAction.java	2012-02-02 09:56:51 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportResultAction.java	2012-02-17 07:09:28 +0000
@@ -196,6 +196,7 @@
         
         Date eDate = format.parseDate( endDate );
 
+        System.out.println("Start Date" + sDate + "-----"  + "End Date: " + eDate );
         generateReport( selProgram, orgUnitList, sDate, eDate );
 
         System.out.println("NBITS Report_" + selOrgUnit.getName() + "_" + selProgram.getName() + "_EndTime: " + new Date() );
@@ -269,6 +270,10 @@
             }
             
             sheet0.mergeCells( colCount, rowCount-1, colCount, rowCount );
+            sheet0.addCell( new Label( colCount, rowCount-1, "Benificiary ID", getCellFormat1() ) );
+            colCount++;
+            
+            sheet0.mergeCells( colCount, rowCount-1, colCount, rowCount );
             sheet0.addCell( new Label( colCount, rowCount-1, "Benificiary Name", getCellFormat1() ) );
             colCount++;
             sheet0.mergeCells( colCount, rowCount-1, colCount, rowCount );
@@ -283,6 +288,10 @@
             sheet0.mergeCells( colCount, rowCount-1, colCount, rowCount );
             sheet0.addCell( new Label( colCount, rowCount-1, "Blood Group", getCellFormat1() ) );
             colCount++;
+            sheet0.mergeCells( colCount, rowCount-1, colCount, rowCount );
+            sheet0.addCell( new Label( colCount, rowCount-1, "Registration Date", getCellFormat1() ) );
+            colCount++;
+            
             
             for( PatientAttribute patientAttribute : patientAttributes )
             {
@@ -311,19 +320,36 @@
 
                 for( DataElement dataElement : dataElementList )
                 {
-                    sheet0.addCell( new Label( colCount, rowCount, dataElement.getName(), getCellFormat1() ) );
+                    sheet0.addCell( new Label( colCount, rowCount, dataElement.getName() + "--" + dataElement.getType() , getCellFormat1() ) );
                     colCount++;
+                    
                 }
             }
             rowCount++;
             
             for( OrganisationUnit orgUnit : orgUnitList )
             {
-                query = "SELECT patient.patientid, programinstance.programinstanceid,programinstance.dateofincident,programinstance.enrollmentdate FROM programinstance INNER JOIN patient " +
-                                " ON programinstance.patientid = patient.patientid " +
-                                " WHERE patient.organisationunitid = "+ orgUnit.getId() +
-                                " AND programinstance.programid = "+ selProgram.getId() +
-                                " AND enddate IS NULL";
+                
+               
+                
+                if( sDate != null && eDate != null)
+                {
+                    query = "SELECT patient.patientid, programinstance.programinstanceid,programinstance.dateofincident,programinstance.enrollmentdate FROM programinstance INNER JOIN patient " +
+                            " ON programinstance.patientid = patient.patientid " +
+                            " WHERE patient.organisationunitid = "+ orgUnit.getId() +
+                            " AND programinstance.programid = "+ selProgram.getId() +
+                            " AND patient.registrationdate >= '"+startDate+"'" +
+                            " AND patient.registrationdate <= '"+endDate+"' "+
+                            " AND enddate IS NULL";
+                }
+                else
+                {
+                    query = "SELECT patient.patientid, programinstance.programinstanceid,programinstance.dateofincident,programinstance.enrollmentdate FROM programinstance INNER JOIN patient " +
+                            " ON programinstance.patientid = patient.patientid " +
+                            " WHERE patient.organisationunitid = "+ orgUnit.getId() +
+                            " AND programinstance.programid = "+ selProgram.getId() +
+                            " AND enddate IS NULL";
+                }
 
                 SqlRowSet sqlResultSet = jdbcTemplate.queryForRowSet( query );
                 if ( sqlResultSet != null )
@@ -384,6 +410,9 @@
                         }
                         
                         //Patient Properties
+                        
+                        sheet0.addCell( new Label( colCount, rowCount, patient.getId().toString(), getCellFormat2() ) );
+                        colCount++;
                         sheet0.addCell( new Label( colCount, rowCount, patient.getFullName(), getCellFormat2() ) );
                         colCount++;
                         sheet0.addCell( new Label( colCount, rowCount, patient.getTextGender(), getCellFormat2() ) );
@@ -394,6 +423,8 @@
                         colCount++;
                         sheet0.addCell( new Label( colCount, rowCount, patient.getBloodGroup(), getCellFormat2() ) );
                         colCount++;
+                        sheet0.addCell( new Label( colCount, rowCount, simpleDateFormat.format( patient.getRegistrationDate() ), getCellFormat2() ) );
+                        colCount++;
 
                         //Patient Attribute Values
                         for( PatientAttribute patientAttribute : patientAttributes )
@@ -483,9 +514,20 @@
                                                 " AND organisationunitid = " + orgUnit.getId(); 
 
                                 SqlRowSet sqlResultSet3 = jdbcTemplate.queryForRowSet( query );
+                                
                                 if ( sqlResultSet3 != null && sqlResultSet3.next() )
                                 {
                                     String value = sqlResultSet3.getString( 1 );
+                                    
+                                    if( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_BOOL) )
+                                    {
+                                        if( value.equalsIgnoreCase("false") )
+                                            value = "No";
+                                        else
+                                            value = "Yes";
+                                    }
+
+                                    
                                     if( value != null && !value.trim().equalsIgnoreCase("") )
                                     {
                                         sheet0.addCell( new Label( colCount, rowCount, value, getCellFormat2() ) );

=== added file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_ACS.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_ACS.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_ACS.java	2012-02-17 07:09:28 +0000
@@ -0,0 +1,945 @@
+package org.hisp.dhis.reports.portal.action;
+
+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.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import jxl.Workbook;
+import jxl.format.Alignment;
+import jxl.format.Border;
+import jxl.format.BorderLineStyle;
+import jxl.format.VerticalAlignment;
+import jxl.write.Label;
+import jxl.write.Number;
+import jxl.write.WritableCellFormat;
+import jxl.write.WritableSheet;
+import jxl.write.WritableWorkbook;
+
+import org.hisp.dhis.config.Configuration_IN;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientIdentifier;
+import org.hisp.dhis.patient.PatientIdentifierService;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.patientdatavalue.PatientDataValue;
+import org.hisp.dhis.patientdatavalue.PatientDataValueService;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.reports.util.ReportService;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import com.opensymphony.xwork2.Action;
+
+public class PortalReportsResult_ACS implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ReportService reportService;
+
+    public void setReportService( ReportService reportService )
+    {
+        this.reportService = reportService;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private PatientService patientService;
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+    
+    private PatientIdentifierService patientIdentifierService;
+
+    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
+    {
+        this.patientIdentifierService = patientIdentifierService;
+    }
+
+    private ProgramStageInstanceService programStageInstanceService;
+
+    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+    {
+        this.programStageInstanceService = programStageInstanceService;
+    }
+
+    private PatientDataValueService patientDataValueService;
+
+    public void setPatientDataValueService( PatientDataValueService patientDataValueService )
+    {
+        this.patientDataValueService = patientDataValueService;
+    }
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private DataElementCategoryService dataElementCategoryOptionComboService;
+
+    public void setDataElementCategoryOptionComboService(
+            DataElementCategoryService dataElementCategoryOptionComboService )
+    {
+        this.dataElementCategoryOptionComboService = dataElementCategoryOptionComboService;
+    }
+    
+    private JdbcTemplate jdbcTemplate;
+
+    public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+    {
+        this.jdbcTemplate = jdbcTemplate;
+    }
+    
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+    // -------------------------------------------------------------------------
+    // Properties
+    // -------------------------------------------------------------------------
+
+    private InputStream inputStream;
+
+    public InputStream getInputStream()
+    {
+        return inputStream;
+    }
+    private String fileName;
+
+    public String getFileName()
+    {
+        return fileName;
+    }
+
+    private String reportFileNameTB;
+
+    public void setReportFileNameTB( String reportFileNameTB )
+    {
+        this.reportFileNameTB = reportFileNameTB;
+    }
+    
+    private String reportLevelTB;
+
+    public void setReportLevelTB( String reportLevelTB )
+    {
+        this.reportLevelTB = reportLevelTB;
+    }
+    private String reportList;
+
+    public void setReportList( String reportList )
+    {
+        this.reportList = reportList;
+    }
+    private int ouIDTB;
+
+    public void setOuIDTB( int ouIDTB )
+    {
+        this.ouIDTB = ouIDTB;
+    }
+    private String startDate;
+
+    public void setStartDate( String startDate )
+    {
+        this.startDate = startDate;
+    }
+    private String endDate;
+
+    public void setEndDate( String endDate )
+    {
+        this.endDate = endDate;
+    }
+
+    private String inputTemplatePath;
+    private String outputReportPath;
+    private String raFolderName;
+    private List<String> serviceType;
+    private List<String> deCodeType;
+    private List<Integer> sheetList;
+    private List<Integer> rowList;
+    private List<Integer> colList;
+    private List<Integer> progList;
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+            throws Exception 
+    {
+        deCodeType = new ArrayList<String>();
+        serviceType = new ArrayList<String>();
+        sheetList = new ArrayList<Integer>();
+        rowList = new ArrayList<Integer>();
+        colList = new ArrayList<Integer>();
+        progList = new ArrayList<Integer>();
+
+        raFolderName = reportService.getRAFolderName();
+        
+        inputTemplatePath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + "template" + File.separator + reportFileNameTB;
+        outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator +  Configuration_IN.DEFAULT_TEMPFOLDER;
+        File newdir = new File( outputReportPath );
+        if( !newdir.exists() )
+        {
+            newdir.mkdirs();
+        }
+        outputReportPath += File.separator + UUID.randomUUID().toString() + ".xls";
+        
+        System.out.println( "Report Generation Start Time is : \t" + new Date() );
+        
+        
+        // query for CVD Report
+        
+        if( reportLevelTB.trim().equalsIgnoreCase( "1" ) )
+        {
+            generateCVDReport();
+        }
+        
+        //String queryCVD = "SELECT  programstageinstanceid, programstageid,executiondate FROM programstageinstance WHERE programstageid IN ("+ reportLevelTB +")AND executiondate between '"+startDate+"' AND '"+endDate+"' ";
+        
+        else
+        {
+            generateReport();
+        }
+        
+        System.out.println( "Report Generation End Time is : \t" + new Date() );
+        
+        return SUCCESS;
+    }
+    
+    public void generateReport() throws Exception
+    {
+        Workbook templateWorkbook = Workbook.getWorkbook( new File( inputTemplatePath ) );
+        WritableWorkbook outputReportWorkbook = Workbook.createWorkbook( new File( outputReportPath ), templateWorkbook );
+        
+        // Cell formatting
+        WritableCellFormat wCellformat = new WritableCellFormat();
+        wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+        wCellformat.setAlignment( Alignment.CENTRE );
+        wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE );
+        wCellformat.setWrap( false );
+
+        WritableCellFormat deWCellformat = new WritableCellFormat();
+        deWCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+        deWCellformat.setAlignment( Alignment.CENTRE );
+        deWCellformat.setVerticalAlignment( VerticalAlignment.JUSTIFY );
+        deWCellformat.setWrap( true );
+
+        //WritableSheet sheet = outputReportWorkbook.getSheet( 0 );
+        
+        // OrgUnit Related Info
+        OrganisationUnit selectedOrgUnit = new OrganisationUnit();
+        selectedOrgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
+        
+        //System.out.println( "Report Level TB : " + reportLevelTB );
+        
+        // Getting Programs
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+        int rowCount = 0;
+        String deCodesXMLFileName = reportList + "DECodes.xml";
+        List<String> deCodesList = getDECodes( deCodesXMLFileName );
+        String[] programIds = reportLevelTB.split( "," );
+        
+        String query = "SELECT patient.patientid, patient.firstname, patient.gender, patient.birthdate, programstageinstanceid, executiondate,patient.middlename,patient.lastname,patient.registrationdate FROM programstageinstance " +
+                                        " INNER JOIN programinstance ON programinstance.programinstanceid = programstageinstance.programinstanceid " +
+                                        " INNER JOIN patient on programinstance.patientid = patient.patientid " +
+                                        " WHERE programinstance.programid IN ("+ reportLevelTB +") " +
+                                        " AND executiondate >= '"+startDate+"'" +
+                                        " AND executiondate <= '"+endDate+"' "+
+                                        " AND patient.organisationunitid = "+ ouIDTB +" ORDER BY executiondate" ;
+        
+       //System.out.println( query );
+        
+        SqlRowSet sqlResultSet1 = jdbcTemplate.queryForRowSet( query );
+        if ( sqlResultSet1 != null )
+        {
+            int rowNo = 0;
+            sqlResultSet1.beforeFirst();
+            while ( sqlResultSet1.next() )
+            {
+                int patientId = sqlResultSet1.getInt( 1 );
+                String temppatientId = sqlResultSet1.getString( 1 );
+                String patientName = sqlResultSet1.getString( 2 );
+                String patientMiddleName = sqlResultSet1.getString( 7 );
+                String patientLastName = sqlResultSet1.getString( 8 );
+                String patinetGender = sqlResultSet1.getString( 3 );
+                Date patientBirthDate = sqlResultSet1.getDate( 4 );
+                int programStageInstanceId = sqlResultSet1.getInt( 5 );
+                Date executionDate = sqlResultSet1.getDate( 6 );
+                Date registrationDate = sqlResultSet1.getDate( 9 );
+                
+                Patient patient = patientService.getPatient( patientId );
+                List<PatientIdentifier> patientIdentifiers = new ArrayList<PatientIdentifier>( patientIdentifierService.getPatientIdentifiers( patient ) );
+                ProgramStageInstance prgStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
+                int count1 = 0;
+                Iterator<String> deCodeIterator = deCodesList.iterator();
+                while( deCodeIterator.hasNext() )
+                {
+                    String deCode = deCodeIterator.next();
+                    int tempColNo = colList.get( count1 );
+                    int sheetNo = sheetList.get( count1 );
+                    String tempStr = "";
+                    String sType = serviceType.get( count1 );
+                    int tempRowNo = rowList.get( count1 );
+                    
+                    if( sType.equalsIgnoreCase("slno") )
+                    {
+                        tempStr = "" + rowNo;
+                    }
+                    else if( deCode.equalsIgnoreCase("PATIENTID") )
+                    {
+                        tempStr = temppatientId;
+                    }
+                    else if( deCode.equalsIgnoreCase("PATIENTNAME") )
+                    {
+                        tempStr = patientName + " " + patientMiddleName + " " + patientLastName;
+                    }
+                    else if( deCode.equalsIgnoreCase("AGE") )
+                    {
+                        tempStr = getAge( patientBirthDate );
+                    }
+                    else if( deCode.equalsIgnoreCase("DOB") )
+                    {
+                        tempStr = simpleDateFormat.format( patientBirthDate );
+                    }
+                    else if( deCode.equalsIgnoreCase("GENDER") )
+                    {
+                        tempStr = patinetGender;
+                    }
+                    else if( deCode.equalsIgnoreCase("HOSPITALNAME") )
+                    {
+                        tempStr = selectedOrgUnit.getName();
+                    }
+                    
+                    else if( deCode.equalsIgnoreCase("REGDATE") )
+                    {
+                        tempStr = simpleDateFormat.format( registrationDate );
+                    }
+                    
+                    else if( sType.equalsIgnoreCase("dataelement") )
+                    {
+                        DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) );
+                        PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit );
+                        if( patientDV != null && patientDV.getValue() != null )
+                        {
+                                tempStr = patientDV.getValue();
+                        }
+                    }
+                    else if( sType.equalsIgnoreCase("dataelement-dd") )
+                    {
+                        DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) );
+                        PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit );
+                        if( patientDV != null && patientDV.getValue() != null )
+                        {
+                                Integer optionComboId = Integer.parseInt( patientDV.getValue() );
+                                DataElementCategoryOptionCombo deCOC = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboId );
+                                tempStr = deCOC.getName();
+                        }
+                    }
+                    else if( sType.equalsIgnoreCase("dataelement-b") )
+                    {
+                        DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) );
+                        PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit );
+                        if( patientDV != null && patientDV.getValue() != null )
+                        {
+                                if( patientDV.getValue().equalsIgnoreCase("false") )
+                                        tempStr = "no";
+                                else
+                                        tempStr = "yes";
+                        }
+                    }
+
+                    else if( sType.equalsIgnoreCase("reasonfordelay") )
+                    {
+                        
+                        String[] tempDe = deCode.split( ":" );
+                        String dealy = tempDe[0];
+                        String reason = tempDe[1];
+                        
+                        //System.out.println( " dealy : " + dealy + " ,reason: " + reason );
+                        
+                        DataElement deDealy = dataElementService.getDataElement( Integer.parseInt( dealy ) );
+                        PatientDataValue patientDelayDV = patientDataValueService.getPatientDataValue( prgStageInstance, deDealy, selectedOrgUnit );
+                        if( patientDelayDV != null && patientDelayDV.getValue() != null )
+                        {
+                            if( patientDelayDV.getValue().equalsIgnoreCase("true") )
+                            {
+                                DataElement deReason = dataElementService.getDataElement( Integer.parseInt( reason ) );
+                                PatientDataValue patientReasonDV = patientDataValueService.getPatientDataValue( prgStageInstance, deReason, selectedOrgUnit );
+                                if( patientReasonDV != null && patientReasonDV.getValue() != null )
+                                {
+                                        Integer optionComboId = Integer.parseInt( patientReasonDV.getValue() );
+                                        DataElementCategoryOptionCombo deCOC = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboId );
+                                        tempStr = deCOC.getName();
+                                        //System.out.println( " Reason -- : -- " + tempStr );
+                                }
+                            }
+                            else
+                            {
+                                tempStr = "";
+                            }
+                        }
+                    }
+                    else if( sType.equalsIgnoreCase("BMI") )
+                    {
+                        String[] tempDe = deCode.split( ":" );
+                        String weightDE = "";
+                        String heightDE = "";
+                        String tempStrWeight = "";
+                        String tempStrHeight = "";
+                        for ( int i = 0 ; i < tempDe.length ; i++ )
+                        {
+                            weightDE = tempDe[0];
+                            heightDE = tempDe[1];
+                            //System.out.println( " weight -- : -- " + weightDE );
+                            //System.out.println( " height -- : -- " + heightDE );
+                        }
+                        
+                        DataElement deWeight = dataElementService.getDataElement( Integer.parseInt( weightDE ) );
+                        PatientDataValue patientWeightDV = patientDataValueService.getPatientDataValue( prgStageInstance, deWeight, selectedOrgUnit );
+                        if( patientWeightDV != null && patientWeightDV.getValue() != null )
+                        {
+                            tempStrWeight = patientWeightDV.getValue();
+                        }
+                        
+                        DataElement deHeight = dataElementService.getDataElement( Integer.parseInt( heightDE ) );
+                        PatientDataValue patientHeightDV = patientDataValueService.getPatientDataValue( prgStageInstance, deHeight, selectedOrgUnit );
+                        if( patientHeightDV != null && patientHeightDV.getValue() != null )
+                        {
+                            tempStrHeight = patientHeightDV.getValue();
+                        }
+                        
+                        if (  tempStrWeight != null && !tempStrWeight.trim().equalsIgnoreCase( "" ) &&  tempStrHeight != null && !tempStrHeight.trim().equalsIgnoreCase( "" )  )
+                        {
+                            //System.out.println( " Weight : " + tempStrWeight + " ,Height: " + tempStrHeight );
+                            
+                            double w = Double.parseDouble( tempStrWeight );
+                            double h = Double.parseDouble( tempStrHeight );
+                            
+                            //Integer w = Integer.parseInt( weight );
+                            //Integer h = Integer.parseInt( height );
+                            double tempBMI = w/(h*h);
+                            
+                            String bmi = Double.toString( tempBMI );
+                            
+                            tempStr = bmi;
+                        }
+                        else
+                        {
+                            tempStr = "";
+                            
+                        }
+
+                        
+                        //tempStr = getBMI( weight, height);
+                    }
+                    
+                    // Code for Hospital STAY
+                    
+                    else if( sType.equalsIgnoreCase("hstay") )
+                    {
+                        String[] tempDe = deCode.split( ":" );
+                        String startDE = "";
+                        String endDE = "";
+                        String tempStartDate = "";
+                        String tempEndDate = "";
+                        for ( int i = 0 ; i < tempDe.length ; i++ )
+                        {
+                            startDE = tempDe[0];
+                            endDE = tempDe[1];
+                        }
+                        
+                        DataElement deStart = dataElementService.getDataElement( Integer.parseInt( startDE ) );
+                        PatientDataValue patientStartDV = patientDataValueService.getPatientDataValue( prgStageInstance, deStart, selectedOrgUnit );
+                        if( patientStartDV != null && patientStartDV.getValue() != null )
+                        {
+                            tempStartDate = patientStartDV.getValue();
+                        }
+                        
+                        DataElement deEnd = dataElementService.getDataElement( Integer.parseInt( endDE ) );
+                        PatientDataValue patientEndDV = patientDataValueService.getPatientDataValue( prgStageInstance, deEnd, selectedOrgUnit );
+                        if( patientEndDV != null && patientEndDV.getValue() != null )
+                        {
+                            tempEndDate = patientEndDV.getValue();
+                        }
+                        
+                        if (  tempStartDate != null && !tempStartDate.trim().equalsIgnoreCase( "" ) &&  tempEndDate != null && !tempEndDate.trim().equalsIgnoreCase( "" )  )
+                        {
+                            //System.out.println( " Start Date : " + tempStartDate + " ,End Date: " + tempEndDate );
+                            
+                            
+                            //simpleDateFormat.format( registrationDate );
+                            
+                            //Date startDate = simpleDateFormat.format( tempStartDate );
+                            
+                            Date sDate = format.parseDate( tempStartDate );
+                            Date eDate = format.parseDate( tempEndDate );
+                            
+                            //String tempFromDate = simpleDateFormat.format( sDate );
+                            //String tempToDate = simpleDateFormat.format( eDate );
+                            
+                            
+                            Calendar tempSDate = Calendar.getInstance();
+                            Calendar tempEDate = Calendar.getInstance();
+
+                            tempSDate.setTime( sDate );
+                            tempEDate.setTime( eDate );
+                            
+                            int age = tempEDate.get( Calendar.DATE ) - tempSDate.get( Calendar.DATE );
+                            
+                            tempStr = "" + age ;
+                        }
+                        else
+                        {
+                            tempStr = "";
+                            
+                        }
+                        //System.out.println( " Hospital Stay  : " + tempStr );
+                        
+                        //tempStr = getBMI( weight, height);
+                    }
+                    
+                    
+                    // Code for Date and time 
+                    
+                    else if( sType.equalsIgnoreCase("datetime") )
+                    {
+                        String[] tempDe = deCode.split( ":" );
+                        String pdate = "";
+                        String pTime = "";
+                        String tempPDate = "";
+                        String tempPTime = "";
+                        for ( int i = 0 ; i < tempDe.length ; i++ )
+                        {
+                            pdate = tempDe[0];
+                            pTime = tempDe[1];
+                        }
+                        
+                        DataElement dePDate = dataElementService.getDataElement( Integer.parseInt( pdate ) );
+                        PatientDataValue patientPdateDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePDate, selectedOrgUnit );
+                        if( patientPdateDV != null && patientPdateDV.getValue() != null )
+                        {
+                            tempPDate = patientPdateDV.getValue();
+                        }
+                        
+                        DataElement dePTime = dataElementService.getDataElement( Integer.parseInt( pTime ) );
+                        PatientDataValue patientPTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePTime, selectedOrgUnit );
+                        if( patientPTimeDV != null && patientPTimeDV.getValue() != null )
+                        {
+                            tempPTime = patientPTimeDV.getValue();
+                        }
+                        
+                        if (  tempPDate != null && !tempPDate.trim().equalsIgnoreCase( "" ) &&  tempPTime != null && !tempPTime.trim().equalsIgnoreCase( "" )  )
+                        {
+                            //System.out.println( " Start Date : " + tempPDate + " ,End Date: " + tempPTime );
+                                                        
+                            tempStr = tempPDate + "," + tempPTime ;
+                        }
+                        else
+                        {
+                            tempStr = "";
+                            
+                        }
+                        //System.out.println( " Date and Time is   : " + tempStr );
+                        
+                        //tempStr = getBMI( weight, height);
+                    }
+                    
+                    // Code for Date and time Diffrence
+                    
+                    else if( sType.equalsIgnoreCase("datetimediff") )
+                    {
+                        String[] tempDe = deCode.split( ":" );
+                        String acsDate = "";
+                        String acsTime = "";
+                        String preDate = "";
+                        String preTime = "";
+                        String tempAcsDate = "";
+                        String tempAcsTime = "";
+                        String tempPreDate = "";
+                        String tempPreTime = "";
+                        for ( int i = 0 ; i < tempDe.length ; i++ )
+                        {
+                            acsDate = tempDe[0];
+                            acsTime = tempDe[1];
+                            preDate = tempDe[2];
+                            preTime = tempDe[3];
+                            
+                        }
+                        
+                        DataElement deAcsDate = dataElementService.getDataElement( Integer.parseInt( acsDate ) );
+                        PatientDataValue patientAcsdateDV = patientDataValueService.getPatientDataValue( prgStageInstance, deAcsDate, selectedOrgUnit );
+                        if( patientAcsdateDV != null && patientAcsdateDV.getValue() != null )
+                        {
+                            tempAcsDate = patientAcsdateDV.getValue();
+                        }
+                        
+                        
+                        DataElement deAcsTime = dataElementService.getDataElement( Integer.parseInt( acsTime ) );
+                        PatientDataValue patientAcsTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, deAcsTime, selectedOrgUnit );
+                        if( patientAcsTimeDV != null && patientAcsTimeDV.getValue() != null )
+                        {
+                            tempAcsTime = patientAcsTimeDV.getValue();
+                        }
+                        
+                        DataElement dePreDate = dataElementService.getDataElement( Integer.parseInt( preDate ) );
+                        PatientDataValue patientPredateDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePreDate, selectedOrgUnit );
+                        if( patientPredateDV != null && patientPredateDV.getValue() != null )
+                        {
+                            tempPreDate = patientPredateDV.getValue();
+                        }
+                        
+                        
+                        
+                        DataElement dePreTime = dataElementService.getDataElement( Integer.parseInt( preTime ) );
+                        PatientDataValue patientPreTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePreTime, selectedOrgUnit );
+                        if( patientPreTimeDV != null && patientPreTimeDV.getValue() != null )
+                        {
+                            tempPreTime = patientPreTimeDV.getValue();
+                        }
+                        
+                        
+                        if (  tempAcsDate != null && !tempAcsDate.trim().equalsIgnoreCase( "" ) &&  tempAcsTime != null && !tempAcsTime.trim().equalsIgnoreCase( "" ) && tempPreDate != null && !tempPreDate.trim().equalsIgnoreCase( "" ) &&  tempPreTime != null && !tempPreTime.trim().equalsIgnoreCase( "" ) )
+                        {
+                            //System.out.println( " Acs Date : " + tempAcsDate + " ,Acs Time: " + tempAcsTime +  " Pre Date : " + tempPreDate + " ,Acs Time: " + tempPreTime );
+                                                        
+                            Date sDate = format.parseDate( tempAcsDate );
+                            Date eDate = format.parseDate( tempPreDate );
+                            
+                            //String tempFromDate = simpleDateFormat.format( sDate );
+                            //String tempToDate = simpleDateFormat.format( eDate );
+                            
+                            
+                            Calendar tempSDate = Calendar.getInstance();
+                            Calendar tempEDate = Calendar.getInstance();
+                            
+                            tempSDate.setTime( sDate );
+                            tempEDate.setTime( eDate );
+
+                            
+                            long millisecondsStart = tempSDate.getTimeInMillis();
+                            long millisecondsEnd = tempEDate.getTimeInMillis();
+                            long tempDiffinSecond = millisecondsEnd - millisecondsStart;
+                            
+                            
+                            
+                            String[] tempACSTIME = tempAcsTime.split( ":" );
+                            String[] tempPRETIME = tempPreTime.split( ":" );
+                            
+                            String tempACSHour = tempACSTIME[0];
+                            String tempACSMin = tempACSTIME[1];
+                            
+                            String tempPREHour = tempPRETIME[0];
+                            String tempPREMin = tempPRETIME[1];
+                            
+                            long diffInSecond = (Long.parseLong( tempPREHour)*3600 + Long.parseLong(tempPREMin)*60) - (Long.parseLong( tempACSHour)*3600 + Long.parseLong(tempACSMin)*60);
+                            
+                            long finalDiffInMilisecond = tempDiffinSecond + diffInSecond*1000;
+                            
+                            
+                            long daysDifference = finalDiffInMilisecond/1000/60/60/24;
+                            finalDiffInMilisecond -= daysDifference*1000*60*60*24;
+                     
+                            long hoursDifference = finalDiffInMilisecond/1000/60/60;
+                            finalDiffInMilisecond -= hoursDifference*1000*60*60;
+                     
+                            long minutesDifference = finalDiffInMilisecond/1000/60;
+                            finalDiffInMilisecond -= minutesDifference*1000*60;
+                     
+                            long secondsDifference = finalDiffInMilisecond/1000;
+                            
+                            String tm_lapsed = Long.toString( daysDifference ) + ":" + Long.toString( hoursDifference ) + ":" + Long.toString( minutesDifference );
+                            
+                            tempStr = tm_lapsed;
+                        }
+                        else
+                        {
+                            tempStr = "";
+                            
+                        }
+                        //System.out.println( " Total diff in time   : " + tempStr );
+                        
+                        //tempStr = getBMI( weight, height);
+                    }
+
+                    //System.out.println( sType + " : " + deCode + " : " + tempStr );
+                    //System.out.println( sType + " : " + tempStr );
+                    tempRowNo =  rowNo+1;  
+                    WritableSheet sheet = outputReportWorkbook.getSheet( sheetNo );
+                    try
+                    {
+                        //double tempDouble = Double.parseDouble( tempStr );
+                        sheet.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStr ), wCellformat ) );
+                    }
+                    catch( Exception e )
+                    {
+                        sheet.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
+                    }
+                    
+                    count1++;
+                }
+                
+                rowNo++;
+            }
+        }
+
+        outputReportWorkbook.write();
+        outputReportWorkbook.close();
+        fileName = reportFileNameTB.replace( ".xls", "" );
+        fileName += "_" + selectedOrgUnit.getShortName() + ".xls";
+        File outputReportFile = new File( outputReportPath );
+        inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
+        outputReportFile.deleteOnExit();
+    }
+    
+
+    public void generateCVDReport() throws Exception
+    {
+        Workbook templateWorkbook = Workbook.getWorkbook( new File( inputTemplatePath ) );
+        WritableWorkbook outputReportWorkbook = Workbook.createWorkbook( new File( outputReportPath ), templateWorkbook );
+        
+        // Cell formatting
+        WritableCellFormat wCellformat = new WritableCellFormat();
+        wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+        wCellformat.setAlignment( Alignment.CENTRE );
+        wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE );
+        wCellformat.setWrap( false );
+
+        WritableCellFormat deWCellformat = new WritableCellFormat();
+        deWCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+        deWCellformat.setAlignment( Alignment.CENTRE );
+        deWCellformat.setVerticalAlignment( VerticalAlignment.JUSTIFY );
+        deWCellformat.setWrap( true );
+
+        //WritableSheet sheet = outputReportWorkbook.getSheet( 0 );
+        
+        // OrgUnit Related Info
+        OrganisationUnit selectedOrgUnit = new OrganisationUnit();
+        selectedOrgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
+        
+        //System.out.println( "Report Level TB : " + reportLevelTB );
+        
+        // Getting Programs
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+        int rowCount = 0;
+        String deCodesXMLFileName = reportList + "DECodes.xml";
+        List<String> deCodesList = getDECodes( deCodesXMLFileName );
+        String[] programIds = reportLevelTB.split( "," );
+        
+        String queryCVD = "SELECT  programstageinstanceid,programstageid,executiondate FROM programstageinstance WHERE programstageid IN ("+ reportLevelTB +")AND executiondate between '"+startDate+"' AND '"+endDate+"' ";
+        
+        //System.out.println( queryCVD );
+        
+        SqlRowSet sqlResultSetCVD = jdbcTemplate.queryForRowSet( queryCVD );
+        if ( sqlResultSetCVD != null )
+        {
+            int rowNo = 1;
+            sqlResultSetCVD.beforeFirst();
+            while ( sqlResultSetCVD.next() )
+            {
+                int cvdProgramStageInstanceId = sqlResultSetCVD.getInt( 1 );
+                Date executionDate = sqlResultSetCVD.getDate( 3 );
+                ProgramStageInstance prgStageInstance = programStageInstanceService.getProgramStageInstance( cvdProgramStageInstanceId );
+                int count1 = 0;
+                Iterator<String> deCodeIterator = deCodesList.iterator();
+                while( deCodeIterator.hasNext() )
+                {
+                    String deCode = deCodeIterator.next();
+                    int tempColNo = colList.get( count1 );
+                    int sheetNo = sheetList.get( count1 );
+                    String tempStr = "";
+                    String sType = serviceType.get( count1 );
+                    int tempRowNo = rowList.get( count1 );
+                    
+                    if( sType.equalsIgnoreCase("slno") )
+                    {
+                        tempStr = "" + rowNo;
+                    }
+                    else if( deCode.equalsIgnoreCase("EXECUTIONDATE") )
+                    {
+                        tempStr = simpleDateFormat.format( executionDate );
+                    }
+
+                    
+                    else if( sType.equalsIgnoreCase("dataelement") )
+                    {
+                        DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) );
+                        PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit );
+                        if( patientDV != null && patientDV.getValue() != null )
+                        {
+                                tempStr = patientDV.getValue();
+                        }
+                    }
+                    else if( sType.equalsIgnoreCase("dataelement-dd") )
+                    {
+                        DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) );
+                        PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit );
+                        if( patientDV != null && patientDV.getValue() != null )
+                        {
+                                Integer optionComboId = Integer.parseInt( patientDV.getValue() );
+                                DataElementCategoryOptionCombo deCOC = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboId );
+                                tempStr = deCOC.getName();
+                        }
+                    }
+                    else if( sType.equalsIgnoreCase("dataelement-b") )
+                    {
+                        DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) );
+                        PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit );
+                        if( patientDV != null && patientDV.getValue() != null )
+                        {
+                                if( patientDV.getValue().equalsIgnoreCase("false") )
+                                        tempStr = "no";
+                                else
+                                        tempStr = "yes";
+                        }
+                    }
+
+                    //System.out.println( sType + " : " + deCode + " : " + tempStr );
+                    //System.out.println( sType + " : " + tempStr );
+                    tempRowNo =  rowNo+1;  
+                    WritableSheet sheet = outputReportWorkbook.getSheet( sheetNo );
+                    try
+                    {
+                        //double tempDouble = Double.parseDouble( tempStr );
+                        sheet.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStr ), wCellformat ) );
+                    }
+                    catch( Exception e )
+                    {
+                        sheet.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
+                    }
+                    
+                    count1++;
+                }
+                
+                rowNo++;
+            }
+        }
+
+        outputReportWorkbook.write();
+        outputReportWorkbook.close();
+        fileName = reportFileNameTB.replace( ".xls", "" );
+        fileName += "_" + selectedOrgUnit.getShortName() + ".xls";
+        File outputReportFile = new File( outputReportPath );
+        inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
+        outputReportFile.deleteOnExit();
+    }
+
+    
+    
+    public String getAge( Date birthDate )
+    {
+        if ( birthDate == null )
+        {
+            return "0";
+        }
+
+        Calendar birthCalendar = Calendar.getInstance();
+        birthCalendar.setTime( birthDate );
+
+        Calendar todayCalendar = Calendar.getInstance();
+
+        int age = todayCalendar.get( Calendar.YEAR ) - birthCalendar.get( Calendar.YEAR );
+
+        if ( todayCalendar.get( Calendar.MONTH ) < birthCalendar.get( Calendar.MONTH ) )
+        {
+            age--;
+        }
+        else if ( todayCalendar.get( Calendar.MONTH ) == birthCalendar.get( Calendar.MONTH )
+            && todayCalendar.get( Calendar.DAY_OF_MONTH ) < birthCalendar.get( Calendar.DAY_OF_MONTH ) )
+        {
+            age--;
+        }
+
+        if ( age < 1 )
+        {
+            return "( < 1 yr )";
+        }
+        else
+        {
+            return "( " + age + " yr )";
+        }
+    }
+    
+    public List<String> getDECodes( String fileName )
+    {
+        List<String> deCodes = new ArrayList<String>();
+        String path = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + fileName;
+
+        try 
+        {
+            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+            Document doc = docBuilder.parse( new File( path ) );
+            if ( doc == null )
+            {
+                return null;
+            }
+
+            NodeList listOfDECodes = doc.getElementsByTagName( "de-code" );
+            int totalDEcodes = listOfDECodes.getLength();
+
+            for ( int s = 0; s < totalDEcodes; s++ )
+            {
+                Element deCodeElement = ( Element ) listOfDECodes.item( s );
+                NodeList textDECodeList = deCodeElement.getChildNodes();
+                deCodes.add( ( ( Node ) textDECodeList.item( 0 ) ).getNodeValue().trim() );
+                serviceType.add( deCodeElement.getAttribute( "stype" ) );
+                deCodeType.add( deCodeElement.getAttribute( "type" ) );
+                sheetList.add( new Integer( deCodeElement.getAttribute( "sheetno" ) ) );
+                rowList.add( new Integer( deCodeElement.getAttribute( "rowno" ) ) );
+                colList.add( new Integer( deCodeElement.getAttribute( "colno" ) ) );
+                progList.add( new Integer( deCodeElement.getAttribute( "progno" ) ) );
+            }// end of for loop with s var
+
+        }// try block end
+        catch ( SAXParseException err )
+        {
+        } 
+        catch ( SAXException e )
+        {
+            Exception x = e.getException();
+            ( ( x == null ) ? e : x ).printStackTrace();
+        } 
+        catch ( Throwable t )
+        {
+            t.printStackTrace();
+        }
+
+        return deCodes;
+    }
+}

=== added file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_Action.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_Action.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_Action.java	2012-02-17 07:09:28 +0000
@@ -0,0 +1,578 @@
+package org.hisp.dhis.reports.portal.action;
+
+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.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import jxl.Workbook;
+import jxl.format.Alignment;
+import jxl.format.Border;
+import jxl.format.BorderLineStyle;
+import jxl.format.VerticalAlignment;
+import jxl.write.Label;
+import jxl.write.Number;
+import jxl.write.WritableCellFormat;
+import jxl.write.WritableSheet;
+import jxl.write.WritableWorkbook;
+
+import org.hisp.dhis.config.Configuration_IN;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientIdentifier;
+import org.hisp.dhis.patient.PatientIdentifierService;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.patientdatavalue.PatientDataValue;
+import org.hisp.dhis.patientdatavalue.PatientDataValueService;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.reports.util.ReportService;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import com.opensymphony.xwork2.Action;
+
+public class PortalReportsResult_Action implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ReportService reportService;
+
+    public void setReportService( ReportService reportService )
+    {
+        this.reportService = reportService;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private PatientService patientService;
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+    
+    private PatientIdentifierService patientIdentifierService;
+
+    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
+    {
+        this.patientIdentifierService = patientIdentifierService;
+    }
+
+    private ProgramStageInstanceService programStageInstanceService;
+
+    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+    {
+        this.programStageInstanceService = programStageInstanceService;
+    }
+
+    private PatientDataValueService patientDataValueService;
+
+    public void setPatientDataValueService( PatientDataValueService patientDataValueService )
+    {
+        this.patientDataValueService = patientDataValueService;
+    }
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private DataElementCategoryService dataElementCategoryOptionComboService;
+
+    public void setDataElementCategoryOptionComboService(
+            DataElementCategoryService dataElementCategoryOptionComboService )
+    {
+        this.dataElementCategoryOptionComboService = dataElementCategoryOptionComboService;
+    }
+    
+    private JdbcTemplate jdbcTemplate;
+
+    public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+    {
+        this.jdbcTemplate = jdbcTemplate;
+    }
+
+    // -------------------------------------------------------------------------
+    // Properties
+    // -------------------------------------------------------------------------
+
+    private InputStream inputStream;
+
+    public InputStream getInputStream()
+    {
+        return inputStream;
+    }
+    private String fileName;
+
+    public String getFileName()
+    {
+        return fileName;
+    }
+
+    private String reportFileNameTB;
+
+    public void setReportFileNameTB( String reportFileNameTB )
+    {
+        this.reportFileNameTB = reportFileNameTB;
+    }
+    
+    private String reportLevelTB;
+
+    public void setReportLevelTB( String reportLevelTB )
+    {
+        this.reportLevelTB = reportLevelTB;
+    }
+    private String reportList;
+
+    public void setReportList( String reportList )
+    {
+        this.reportList = reportList;
+    }
+    private int ouIDTB;
+
+    public void setOuIDTB( int ouIDTB )
+    {
+        this.ouIDTB = ouIDTB;
+    }
+    private String startDate;
+
+    public void setStartDate( String startDate )
+    {
+        this.startDate = startDate;
+    }
+    private String endDate;
+
+    public void setEndDate( String endDate )
+    {
+        this.endDate = endDate;
+    }
+
+    private String inputTemplatePath;
+    private String outputReportPath;
+    private String raFolderName;
+    private List<String> serviceType;
+    private List<String> deCodeType;
+    private List<Integer> sheetList;
+    private List<Integer> rowList;
+    private List<Integer> colList;
+    private List<Integer> progList;
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+            throws Exception 
+    {
+        deCodeType = new ArrayList<String>();
+        serviceType = new ArrayList<String>();
+        sheetList = new ArrayList<Integer>();
+        rowList = new ArrayList<Integer>();
+        colList = new ArrayList<Integer>();
+        progList = new ArrayList<Integer>();
+
+    	raFolderName = reportService.getRAFolderName();
+    	
+        inputTemplatePath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + "template" + File.separator + reportFileNameTB;
+        outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator +  Configuration_IN.DEFAULT_TEMPFOLDER;
+        File newdir = new File( outputReportPath );
+        if( !newdir.exists() )
+        {
+            newdir.mkdirs();
+        }
+        outputReportPath += File.separator + UUID.randomUUID().toString() + ".xls";
+
+        generateReport();
+        
+        return SUCCESS;
+    }
+    
+    public void generateReport() throws Exception
+    {
+        Workbook templateWorkbook = Workbook.getWorkbook( new File( inputTemplatePath ) );
+        WritableWorkbook outputReportWorkbook = Workbook.createWorkbook( new File( outputReportPath ), templateWorkbook );
+        
+        // Cell formatting
+        WritableCellFormat wCellformat = new WritableCellFormat();
+        wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+        wCellformat.setAlignment( Alignment.CENTRE );
+        wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE );
+        wCellformat.setWrap( true );
+
+        WritableCellFormat deWCellformat = new WritableCellFormat();
+        deWCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+        deWCellformat.setAlignment( Alignment.CENTRE );
+        deWCellformat.setVerticalAlignment( VerticalAlignment.JUSTIFY );
+        deWCellformat.setWrap( true );
+
+        //WritableSheet sheet = outputReportWorkbook.getSheet( 0 );
+        
+        // OrgUnit Related Info
+        OrganisationUnit selectedOrgUnit = new OrganisationUnit();
+        selectedOrgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
+        
+        // Getting Programs
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+        int rowCount = 0;
+        String deCodesXMLFileName = reportList + "DECodes.xml";
+        List<String> deCodesList = getDECodes( deCodesXMLFileName );
+        String[] programIds = reportLevelTB.split( "," );
+        
+        String query = "SELECT patient.patientid, patient.firstname, patient.gender, patient.birthdate, programstageinstanceid, executiondate FROM programstageinstance " +
+        				" INNER JOIN programinstance ON programinstance.programinstanceid = programstageinstance.programinstanceid " +
+        				" INNER JOIN patient on programinstance.patientid = patient.patientid " +
+        				" WHERE programinstance.programid IN ("+ reportLevelTB +") " +
+        				" AND executiondate >= '"+startDate+"'" +
+        				" AND executiondate <= '"+endDate+"' "+
+        				" AND patient.organisationunitid = "+ ouIDTB +" ORDER BY executiondate" ;
+        
+        //System.out.println( query );
+        
+        SqlRowSet sqlResultSet1 = jdbcTemplate.queryForRowSet( query );
+        if ( sqlResultSet1 != null )
+        {
+            int rowNo = 1;
+            sqlResultSet1.beforeFirst();
+            while ( sqlResultSet1.next() )
+            {
+            	int patientId = sqlResultSet1.getInt( 1 );
+            	String patientName = sqlResultSet1.getString( 2 );
+            	String patinetGender = sqlResultSet1.getString( 3 );
+            	Date patientBirthDate = sqlResultSet1.getDate( 4 );
+                int programStageInstanceId = sqlResultSet1.getInt( 5 );
+                Date executionDate = sqlResultSet1.getDate( 6 );
+                
+                Patient patient = patientService.getPatient( patientId );
+                List<PatientIdentifier> patientIdentifiers = new ArrayList<PatientIdentifier>( patientIdentifierService.getPatientIdentifiers( patient ) );
+                ProgramStageInstance prgStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
+                int count1 = 0;
+                Iterator<String> deCodeIterator = deCodesList.iterator();
+                while( deCodeIterator.hasNext() )
+                {
+                	String deCode = deCodeIterator.next();
+                	int tempColNo = colList.get( count1 );
+                    int sheetNo = sheetList.get( count1 );
+                    String tempStr = "";
+                    String sType = serviceType.get( count1 );
+                    int tempRowNo = rowList.get( count1 );
+                    
+                    if( sType.equalsIgnoreCase("slno") )
+                    {
+                    	tempStr = "" + rowNo;
+                    }
+                    else if( sType.equalsIgnoreCase("executiondate") )
+                    {
+                    	tempStr = simpleDateFormat.format( executionDate );
+                    }
+                    else if( deCode.equalsIgnoreCase("GENDER") )
+                    {
+                    	tempStr = patinetGender;
+                    }
+                    else if( deCode.equalsIgnoreCase("AGE") )
+                    {
+                    	tempStr = getAge( patientBirthDate );
+                    }
+                    else if( sType.equalsIgnoreCase("PI-PART0") )
+                    {
+                    	//System.out.println( "Inside pipart0" );
+                    	tempStr = " ";
+                    	for( PatientIdentifier patientIdentifier : patientIdentifiers )
+                    	{
+                    		//System.out.println( patientIdentifier.getId() + " : " + deCode );
+                    		if( patientIdentifier.getIdentifierType() != null && patientIdentifier.getIdentifierType().getId() == Integer.parseInt(deCode) )
+                    		{
+                    			try
+                    			{
+                    				tempStr = patientIdentifier.getIdentifier().split("-")[0];
+                    			}
+                    			catch( Exception e )
+                    			{
+                    			}
+                    			break;
+                    		}
+                    	}
+                    }
+                    else if( sType.equalsIgnoreCase("PI-PART1") )
+                    {
+                    	tempStr = " ";
+                    	for( PatientIdentifier patientIdentifier : patientIdentifiers )
+                    	{
+                    		if( patientIdentifier.getIdentifierType() != null && patientIdentifier.getIdentifierType().getId() == Integer.parseInt(deCode) )
+                    		{
+                    			try
+                    			{
+                    				tempStr = patientIdentifier.getIdentifier().split("-")[1];
+                    			}
+                    			catch( Exception e )
+                    			{
+                    			}
+                    			break;
+                    		}
+                    	}
+                    }
+                    else if( sType.equalsIgnoreCase("PI-PART2") )
+                    {
+                    	tempStr = " ";
+                    	for( PatientIdentifier patientIdentifier : patientIdentifiers )
+                    	{
+                    		if( patientIdentifier.getIdentifierType() != null && patientIdentifier.getIdentifierType().getId() == Integer.parseInt(deCode) )
+                    		{
+                    			try
+                    			{
+                    				tempStr = patientIdentifier.getIdentifier().split("-")[2];
+                    			}
+                    			catch( Exception e )
+                    			{
+                    			}
+                    			break;
+                    		}
+                    	}
+                    }
+                    else if( sType.equalsIgnoreCase("PI-PART3") )
+                    {
+                    	tempStr = " ";
+                    	for( PatientIdentifier patientIdentifier : patientIdentifiers )
+                    	{
+                    		if( patientIdentifier.getIdentifierType() != null && patientIdentifier.getIdentifierType().getId() == Integer.parseInt(deCode) )
+                    		{
+                    			try
+                    			{
+                    				tempStr = patientIdentifier.getIdentifier().split("-")[3];
+                    			}
+                    			catch( Exception e )
+                    			{
+                    			}
+                    			break;
+                    		}
+                    	}
+                    }
+                    else if( sType.equalsIgnoreCase("PI-PART4") )
+                    {
+                    	tempStr = " ";
+                    	for( PatientIdentifier patientIdentifier : patientIdentifiers )
+                    	{
+                    		if( patientIdentifier.getIdentifierType() != null && patientIdentifier.getIdentifierType().getId() == Integer.parseInt(deCode) )
+                    		{
+                    			try
+                    			{
+                    				tempStr = patientIdentifier.getIdentifier().split("-")[4];
+                    			}
+                    			catch( Exception e )
+                    			{
+                    			}
+                    			break;
+                    		}
+                    	}
+                    }
+                    else if( sType.equalsIgnoreCase("PI-PART5") )
+                    {
+                    	tempStr = " ";
+                    	for( PatientIdentifier patientIdentifier : patientIdentifiers )
+                    	{
+                    		if( patientIdentifier.getIdentifierType() != null && patientIdentifier.getIdentifierType().getId() == Integer.parseInt(deCode) )
+                    		{
+                    			try
+                    			{
+                    				tempStr = patientIdentifier.getIdentifier().split("-")[5];
+                    			}
+                    			catch( Exception e )
+                    			{
+                    			}
+                    			break;
+                    		}
+                    	}
+                    }
+                    else if( sType.equalsIgnoreCase("PI-PART6") )
+                    {
+                    	tempStr = " ";
+                    	for( PatientIdentifier patientIdentifier : patientIdentifiers )
+                    	{
+                    		if( patientIdentifier.getIdentifierType() != null && patientIdentifier.getIdentifierType().getId() == Integer.parseInt(deCode) )
+                    		{
+                    			try
+                    			{
+                    				tempStr = patientIdentifier.getIdentifier().split("-")[6];
+                    			}
+                    			catch( Exception e )
+                    			{
+                    			}
+                    			break;
+                    		}
+                    	}
+                    }
+                    else if( sType.equalsIgnoreCase("dataelement") )
+                    {
+                        DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) );
+                        PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit );
+                        if( patientDV != null && patientDV.getValue() != null )
+                        {
+                        	tempStr = patientDV.getValue();
+                        }
+                    }
+                    else if( sType.equalsIgnoreCase("dataelement-dd") )
+                    {
+                        DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) );
+                        PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit );
+                        if( patientDV != null && patientDV.getValue() != null )
+                        {
+                        	Integer optionComboId = Integer.parseInt( patientDV.getValue() );
+                        	DataElementCategoryOptionCombo deCOC = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboId );
+                        	tempStr = deCOC.getName();
+                        }
+                    }
+                    else if( sType.equalsIgnoreCase("dataelement-b") )
+                    {
+                        DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) );
+                        PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit );
+                        if( patientDV != null && patientDV.getValue() != null )
+                        {
+                        	if( patientDV.getValue().equalsIgnoreCase("false") )
+                        		tempStr = "N";
+                        	else
+                        		tempStr = "Y";
+                        }
+                    }
+
+                    //System.out.println( sType + " : " + tempStr );
+                    	
+                    WritableSheet sheet = outputReportWorkbook.getSheet( sheetNo );
+                    try
+                    {
+                    	double tempDouble = Double.parseDouble( tempStr );
+                    	sheet.addCell( new Number( tempColNo, tempRowNo+rowNo, tempDouble ) );
+                    }
+                    catch( Exception e )
+                    {
+                    	sheet.addCell( new Label( tempColNo, tempRowNo+rowNo, tempStr ) );
+                    }
+                    
+                    count1++;
+                }
+                
+                rowNo++;
+            }
+        }
+
+        outputReportWorkbook.write();
+        outputReportWorkbook.close();
+        fileName = reportFileNameTB.replace( ".xls", "" );
+        fileName += "_" + selectedOrgUnit.getShortName() + ".xls";
+        File outputReportFile = new File( outputReportPath );
+        inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
+        outputReportFile.deleteOnExit();
+    }
+    
+    
+    public String getAge( Date birthDate )
+    {
+        if ( birthDate == null )
+        {
+            return "0";
+        }
+
+        Calendar birthCalendar = Calendar.getInstance();
+        birthCalendar.setTime( birthDate );
+
+        Calendar todayCalendar = Calendar.getInstance();
+
+        int age = todayCalendar.get( Calendar.YEAR ) - birthCalendar.get( Calendar.YEAR );
+
+        if ( todayCalendar.get( Calendar.MONTH ) < birthCalendar.get( Calendar.MONTH ) )
+        {
+            age--;
+        }
+        else if ( todayCalendar.get( Calendar.MONTH ) == birthCalendar.get( Calendar.MONTH )
+            && todayCalendar.get( Calendar.DAY_OF_MONTH ) < birthCalendar.get( Calendar.DAY_OF_MONTH ) )
+        {
+            age--;
+        }
+
+        if ( age < 1 )
+        {
+            return "( < 1 yr )";
+        }
+        else
+        {
+            return "( " + age + " yr )";
+        }
+    }
+    
+    public List<String> getDECodes( String fileName )
+    {
+        List<String> deCodes = new ArrayList<String>();
+        String path = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + fileName;
+
+        try 
+        {
+            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+            Document doc = docBuilder.parse( new File( path ) );
+            if ( doc == null )
+            {
+                return null;
+            }
+
+            NodeList listOfDECodes = doc.getElementsByTagName( "de-code" );
+            int totalDEcodes = listOfDECodes.getLength();
+
+            for ( int s = 0; s < totalDEcodes; s++ )
+            {
+                Element deCodeElement = ( Element ) listOfDECodes.item( s );
+                NodeList textDECodeList = deCodeElement.getChildNodes();
+                deCodes.add( ( ( Node ) textDECodeList.item( 0 ) ).getNodeValue().trim() );
+                serviceType.add( deCodeElement.getAttribute( "stype" ) );
+                deCodeType.add( deCodeElement.getAttribute( "type" ) );
+                sheetList.add( new Integer( deCodeElement.getAttribute( "sheetno" ) ) );
+                rowList.add( new Integer( deCodeElement.getAttribute( "rowno" ) ) );
+                colList.add( new Integer( deCodeElement.getAttribute( "colno" ) ) );
+                progList.add( new Integer( deCodeElement.getAttribute( "progno" ) ) );
+            }// end of for loop with s var
+
+        }// try block end
+        catch ( SAXParseException err )
+        {
+        } 
+        catch ( SAXException e )
+        {
+            Exception x = e.getException();
+            ( ( x == null ) ? e : x ).printStackTrace();
+        } 
+        catch ( Throwable t )
+        {
+            t.printStackTrace();
+        }
+
+        return deCodes;
+    }
+}

=== 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	2012-02-02 09:56:51 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml	2012-02-17 07:09:28 +0000
@@ -1340,6 +1340,33 @@
         </property>
         
     </bean>
+    <bean id="org.hisp.dhis.reports.portal.action.PortalReportsResult_Action"
+        class="org.hisp.dhis.reports.portal.action.PortalReportsResult_Action"
+        scope="prototype">
+        <property name="reportService" ref="org.hisp.dhis.reports.util.ReportService" />
+        <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+        <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+        <property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
+        <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+        <property name="patientDataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="dataElementCategoryOptionComboService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+        <property name="jdbcTemplate" ref="jdbcTemplate"/>        
+    </bean>
+
+    <bean id="org.hisp.dhis.reports.portal.action.PortalReportsResult_ACS"
+        class="org.hisp.dhis.reports.portal.action.PortalReportsResult_ACS"
+        scope="prototype">
+        <property name="reportService" ref="org.hisp.dhis.reports.util.ReportService" />
+        <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+        <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+        <property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
+        <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+        <property name="patientDataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="dataElementCategoryOptionComboService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+        <property name="jdbcTemplate" ref="jdbcTemplate"/>        
+    </bean>	
 
     <!-- NBITS Reports -->
     <bean id="org.hisp.dhis.reports.nbits.action.NBITSReportFormAction"

=== modified file 'local/in/dhis-web-reports-national/src/main/resources/struts.xml'
--- local/in/dhis-web-reports-national/src/main/resources/struts.xml	2011-12-14 11:06:08 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/struts.xml	2012-02-17 07:09:28 +0000
@@ -846,6 +846,7 @@
             <param name="requiredAuthorities">F_REPORT_NBITS_PORTAL</param>
             <interceptor-ref name="organisationUnitTreeStack"/>
         </action>
+<!--
         <action name="generatePortalReport"
             class="org.hisp.dhis.reports.portal.action.PortalReportsResultAction">
             <result name="success" type="stream">
@@ -855,7 +856,29 @@
                 <param name="bufferSize">1024</param>
             </result>
         </action>
-
+-->	
+<!--	
+        <action name="generatePortalReport"
+            class="org.hisp.dhis.reports.portal.action.PortalReportsResult_Action">
+            <result name="success" type="stream">
+                <param name="contentType">application/vnd.ms-excel</param>
+                <param name="inputName">inputStream</param>
+                <param name="contentDisposition">filename="${fileName}"</param>
+                <param name="bufferSize">1024</param>
+            </result>
+        </action>
+-->	
+		
+        <action name="generatePortalReport"
+            class="org.hisp.dhis.reports.portal.action.PortalReportsResult_ACS">
+            <result name="success" type="stream">
+                <param name="contentType">application/vnd.ms-excel</param>
+                <param name="inputName">inputStream</param>
+                <param name="contentDisposition">filename="${fileName}"</param>
+                <param name="bufferSize">1024</param>
+            </result>
+        </action>
+		
         <!-- NBITS Reports -->
         <action name="nbitsReportsAnalyser"
             class="org.hisp.dhis.reports.nbits.action.NBITSReportFormAction">

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/chart.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/chart.js	2010-09-09 12:12:20 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/chart.js	2012-02-17 07:09:28 +0000
@@ -35,7 +35,8 @@
 
 function getChartStatus()
 {   
-    /* //var url = "getStatus.action";
+    
+	/* //var url = "getStatus.action";
     
     var request = new Request();
     request.setResponseTypeXML( "status" );
@@ -86,7 +87,7 @@
     
     if ( result )
     {
-        /* //window.location.href = "removeChart.action?id=" + chartId;
+    	/* //window.location.href = "removeChart.action?id=" + chartId;
         var request = new Request();
         var requestString = "removeChart.action";
         var params = "id=" + chartId;
@@ -111,7 +112,7 @@
 
 function showChartDetails( chartId )
 {
-    /* var request = new Request();
+	/* var request = new Request();
     request.setResponseTypeXML( 'chart' );
     request.setCallbackSuccess( chartReceived );
     //request.send( 'getChart.action?id=' + chartId );

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/dataCompleteness.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/dataCompleteness.js	2010-09-15 08:50:45 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/dataCompleteness.js	2012-02-17 07:09:28 +0000
@@ -224,7 +224,7 @@
     
     if ( periodTypeId != null )
     {       
-       /* // var url = "../dhis-web-commons-ajax/getPeriods.action?name=" + periodTypeId;
+    	/* // var url = "../dhis-web-commons-ajax/getPeriods.action?name=" + periodTypeId;
         
         var request = new Request();
         request.setResponseTypeXML( "period" );

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/dataSetReport.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/dataSetReport.js	2010-09-09 12:12:20 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/dataSetReport.js	2012-02-17 07:09:28 +0000
@@ -89,7 +89,7 @@
 
 function getDataSetReportStatus()
 {   
-    /* //var url = "getStatus.action";
+	/* //var url = "getStatus.action";
     
     var request = new Request();
     request.setResponseTypeXML( "status" );

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/datasetLockReport.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/datasetLockReport.js	2010-12-22 07:29:08 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/datasetLockReport.js	2012-02-17 07:09:28 +0000
@@ -41,10 +41,7 @@
            setFieldValue( "ouNameTB",json.organisationUnit.name );
      });
 }
-
-
-
-/*
+	/*
 		
 		$.post("getOrgUnitName.action",
 			{
@@ -67,8 +64,6 @@
     document.reportForm.ouNameTB.value = orgUnitname;
 }
 
-
-
 //function getAllPeriods() {
 	//var periodTypeList = document.getElementById("periodTypeId");
 //	var periodTypeId = periodTypeList.options[periodTypeList.selectedIndex].value;
@@ -157,7 +152,6 @@
 		return new DOMParser().parseFromString(xml, 'text/xml');
 	throw new Error('No XML parser available');
 }
-
 // functions for get all corresponding dataSets
 function getDataSets() {
 	var periodTypeList = document.getElementById("periodTypeId");

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/document.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/document.js	2010-09-09 12:12:20 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/document.js	2012-02-17 07:09:28 +0000
@@ -48,7 +48,7 @@
     
     if ( dialog )
     {
-        /* //window.location.href = "removeDocument.action?id=" + id;
+    	/* //window.location.href = "removeDocument.action?id=" + id;
         var request = new Request();
         var requestString = "removeDocument.action";
         var params = "id=" + id ;
@@ -72,7 +72,7 @@
     
     if ( dialog )
     {
-        /* var request = new Request(); 
+    	/* var request = new Request(); 
         //request.send( "addDocumentToDashboard.action?id=" + id );
         var requestString = "addDocumentToDashboard.action";
         var params = "id=" + id ;

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/grading.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/grading.js	2010-09-15 08:50:45 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/grading.js	2012-02-17 07:09:28 +0000
@@ -7,7 +7,7 @@
 	
     if ( orgUnitGroupSetId != null )
     {
-        /* //var url = "getOrgUnitGroups.action?orgUnitGroupSetId=" + orgUnitGroupSetId;
+    	/* //var url = "getOrgUnitGroups.action?orgUnitGroupSetId=" + orgUnitGroupSetId;
 		
         var request = new Request();
         request.setResponseTypeXML( 'orgunitgroup' );
@@ -71,7 +71,6 @@
     clearList(orgUnitList);
 }
 
-
 // Removes slected orgunits from the Organisation List
 function remOUFunction()
 {
@@ -98,7 +97,6 @@
         }
     }
 }
-
 // Grading Report Form Validations
 function formValidations()
 {			         

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/lists.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/lists.js	2010-09-15 08:50:45 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/lists.js	2012-02-17 07:09:28 +0000
@@ -50,7 +50,7 @@
         
         if ( listContains( selectedDataElements, id ) == false )
         {               
-            /* var option = document.createElement( "option" );
+        	/* var option = document.createElement( "option" );
             option.value = id;
             option.text = dataElementName;
             availableDataElements.add( option, null ); */
@@ -67,7 +67,7 @@
     
     if ( categoryComboId != null )
     {
-        /* //var url = "../dhis-web-commons-ajax/getDataElements.action?categoryComboId=" + categoryComboId + "&aggregate=true";
+    	/* //var url = "../dhis-web-commons-ajax/getDataElements.action?categoryComboId=" + categoryComboId + "&aggregate=true";
         
         var request = new Request();
         request.setResponseTypeXML( 'dataElement' );
@@ -161,7 +161,7 @@
         
         if ( listContains( selectedIndicators, id ) == false )
         {               
-            /* var option = document.createElement( "option" );
+        	/* var option = document.createElement( "option" );
             option.value = id;
             option.text = indicatorName;
             availableIndicators.add( option, null ); */
@@ -217,7 +217,7 @@
         
         if ( listContains( selectedOrganisationUnits, id ) == false )
         {                       
-            /* var option = document.createElement( "option" );
+        	/* var option = document.createElement( "option" );
             option.value = id;
             option.text = organisationUnitName;
             availableOrganisationUnits.add( option, null ); */
@@ -396,7 +396,7 @@
     
     if ( periodTypeId != null )
     {       
-        /* //var url = "../dhis-web-commons-ajax/getPeriods.action?name=" + periodTypeId;
+    	/* //var url = "../dhis-web-commons-ajax/getPeriods.action?name=" + periodTypeId;
         
         var request = new Request();
         request.setResponseTypeXML( 'period' );

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/report.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/report.js	2010-09-09 12:12:20 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/report.js	2012-02-17 07:09:28 +0000
@@ -7,7 +7,7 @@
     var params2;
     if ( document.getElementById( "reportingPeriod" ) != null )
     {
-        ///url += "&reportingPeriod=" + getListValue( "reportingPeriod" );
+    	//url += "&reportingPeriod=" + getListValue( "reportingPeriod" );
         
 		//params2 += "&reportingPeriod=" + getListValue( "reportingPeriod" );
 		
@@ -25,7 +25,7 @@
     
     if ( document.getElementById( "parentOrganisationUnitId" ) != null )
     {
-        ////url += "&parentOrganisationUnitId=" + getListValue( "parentOrganisationUnitId" );
+        //url += "&parentOrganisationUnitId=" + getListValue( "parentOrganisationUnitId" );
         //params2 += "&reportingPeriod=" + getListValue( "reportingPeriod" );
 		$.post("createTable.action",
 			{
@@ -41,7 +41,7 @@
     
     if ( document.getElementById( "organisationUnitId" ) != null )
     {
-        ////url += "&organisationUnitId=" + getListValue( "organisationUnitId" );
+        ///url += "&organisationUnitId=" + getListValue( "organisationUnitId" );
         //params2 += "&reportingPeriod=" + getListValue( "reportingPeriod" );
 		$.post("createTable.action",
 			{

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/reportParams.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/reportParams.js	2010-09-15 08:50:45 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/reportParams.js	2012-02-17 07:09:28 +0000
@@ -9,7 +9,7 @@
     
     if ( organisationUnitLevel != null )
     {
-       /* // var url = "../dhis-web-commons-ajax/getOrganisationUnits.action?level=" + organisationUnitLevel;
+    	/* // var url = "../dhis-web-commons-ajax/getOrganisationUnits.action?level=" + organisationUnitLevel;
         
         var request = new Request();
         request.setResponseTypeXML( 'organisationUnit' );

=== 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-05-18 11:56:37 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/reports.js	2012-02-17 07:09:28 +0000
@@ -58,7 +58,7 @@
 
 function getOUDetails(orgUnitIds)
 {
-    /* //var url = "getOrgUnitDetails.action?orgUnitId=" + orgUnitIds;
+	/* //var url = "getOrgUnitDetails.action?orgUnitId=" + orgUnitIds;
 	
     var request = new Request();
     request.setResponseTypeXML( 'orgunit' );
@@ -155,7 +155,8 @@
 		},'xml');
 
     }
-}// getDataElements end           
+}
+// getDataElements end           
 
 function getDataElementsReceived( xmlObject )
 {
@@ -246,6 +247,7 @@
     }
  
 }
+
 /*
 function getReports( ouId, reportListFileName )
 { 
@@ -270,7 +272,7 @@
     }
 }
 */
-// 23/08/2010
+
 
 function getReports( ouId, reportTypeName )
 { 
@@ -284,7 +286,7 @@
           
     if ( periodType != "NA" && ouId != null && ouId != "" )
     {
-       /*  var request = new Request();
+    	/*  var request = new Request();
         request.setResponseTypeXML( 'report' );
         request.setCallbackSuccess( getReportsReceived );
 

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/table.js'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/table.js	2010-09-09 12:12:20 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/table.js	2012-02-17 07:09:28 +0000
@@ -36,7 +36,7 @@
 	
 	if ( byId( "reportingPeriod" ) != null )
     {
-        ////url += "&reportingPeriod=" + getListValue( "reportingPeriod" );
+        //url += "&reportingPeriod=" + getListValue( "reportingPeriod" );
         //params += "&reportingPeriod=" + getListValue( "reportingPeriod" );
 		
 		$.post("createTable.action",
@@ -52,7 +52,7 @@
     
     if ( document.getElementById( "parentOrganisationUnitId" ) != null )
     {
-        ////url += "&parentOrganisationUnitId=" + getListValue( "parentOrganisationUnitId" );
+        //url += "&parentOrganisationUnitId=" + getListValue( "parentOrganisationUnitId" );
         //params += "&parentOrganisationUnitId=" + getListValue( "parentOrganisationUnitId" );
 		
 		$.post("createTable.action",
@@ -67,7 +67,7 @@
     
     if ( document.getElementById( "organisationUnitId" ) != null )
     {
-        ////url += "&organisationUnitId=" + getListValue( "organisationUnitId" );
+        //url += "&organisationUnitId=" + getListValue( "organisationUnitId" );
         //params += "&organisationUnitId=" + getListValue( "organisationUnitId" );
 		
 		$.post("createTable.action",
@@ -88,7 +88,7 @@
 
 function getTableStatus()
 {
-    /* //var url = "getStatus.action";
+	/* //var url = "getStatus.action";
     
     var request = new Request();
     request.setResponseTypeXML( 'status' );
@@ -218,7 +218,7 @@
     
     if ( result )
     {
-        /* //window.location.href = "removeTable.action?id=" + tableId;
+    	/* //window.location.href = "removeTable.action?id=" + tableId;
         var request = new Request();
         var requestString = "removeTable.action";
         var params = "id=" + tableId;
@@ -332,7 +332,7 @@
 
 function showTableDetails( tableId )
 {
-   /*  var request = new Request();
+	/*  var request = new Request();
     request.setResponseTypeXML( 'reportTable' );
     request.setCallbackSuccess( tableReceived );
     //request.send( 'getTable.action?id=' + tableId );