dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18739
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7927: CCEM iReport Modification
------------------------------------------------------------
revno: 7927
committer: Samta <samta-bajpayee@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-08-17 11:21:10 +0100
message:
CCEM iReport Modification
modified:
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java
local/in/dhis-web-coldchain/src/main/resources/struts.xml
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java 2012-08-01 08:04:18 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java 2012-08-17 10:21:10 +0000
@@ -95,6 +95,7 @@
protected Map param = new HashMap();
protected DynamicReport dr;
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -252,9 +253,8 @@
{
Connection con = jdbcTemplate.getDataSource().getConnection();
String fileName = null;
- String path = System.getenv("DHIS2_HOME") + File.separator + "ireports" + File.separator;
-
-
+ String path = System.getenv( "DHIS2_HOME" ) + File.separator + "ireports" + File.separator;
+
HashMap<String, Object> hash = new HashMap<String, Object>();
String orgUnitIdsByComma = ccemReportManager.getOrgunitIdsByComma( selOrgUnitList, orgunitGroupList );
@@ -262,8 +262,7 @@
Map<String, String> ccemSettingsMap = new HashMap<String, String>( ccemReportManager.getCCEMSettings() );
List<CCEMReportDesign> reportDesignList = new ArrayList<CCEMReportDesign>( ccemReportManager
.getCCEMReportDesign( ccemReport.getXmlTemplateName() ) );
-
-
+
String oName = null;
String oUnitGrpName = null;
oUnitGrpName = organisationUnitGroupService.getOrganisationUnitGroup( orgunitGroupList.get( 0 ) ).getName()
@@ -279,8 +278,7 @@
for ( int j = 1; j <= selOrgUnitList.size() - 1; j++ )
{
oName += "," + organisationUnitService.getOrganisationUnit( selOrgUnitList.get( j ) ).getName();
- System.out.println( "Group is: "
- + organisationUnitService.getOrganisationUnit( selOrgUnitList.get( j ) ) );
+ System.out.println( "Group is: " + organisationUnitService.getOrganisationUnit( selOrgUnitList.get( j ) ) );
}
hash.put( "orgunitGroup", oUnitGrpName );
hash.put( "selOrgUnit", oName );
@@ -297,12 +295,12 @@
CCEMReportDesign ccemReportDesign = reportDesignList.get( 0 );
String ccemCellContent = ccemSettingsMap.get( ccemReportDesign.getContent() );
Integer inventoryTypeId = Integer.parseInt( ccemCellContent.split( ":" )[0] );
- Integer catalogTypeAttributeId = Integer.parseInt( ccemCellContent.split( ":" )[1] );
+ Integer catalogTypeAttributeId = Integer.parseInt( ccemCellContent.split( ":" )[1] );
hash.put( "inventoryTypeId", inventoryTypeId );
- hash.put( "catalogTypeAttributeId", catalogTypeAttributeId );
+ hash.put( "catalogTypeAttributeId", catalogTypeAttributeId );
fileName = "Refrigerators_freezer_models_by_agegroup.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport( path + fileName );
- jasperPrint = JasperFillManager.fillReport( jasperReport, hash, con );
+ jasperPrint = JasperFillManager.fillReport( jasperReport, hash, con );
}
else if ( ccemReport.getReportType().equals( CCEMReport.CATALOGTYPE_ATTRIBUTE_VALUE_AGE_GROUP.trim() ) )
@@ -310,106 +308,110 @@
CCEMReportDesign ccemReportDesign = reportDesignList.get( 0 );
String ccemCellContent = ccemSettingsMap.get( ccemReportDesign.getContent() );
Integer inventoryTypeId = Integer.parseInt( ccemCellContent.split( ":" )[0] );
- Integer catalogTypeAttributeId = Integer.parseInt( ccemCellContent.split( ":" )[1] );
+ Integer catalogTypeAttributeId = Integer.parseInt( ccemCellContent.split( ":" )[1] );
hash.put( "inventoryTypeId", inventoryTypeId );
- hash.put( "catalogTypeAttributeId", catalogTypeAttributeId );
+ hash.put( "catalogTypeAttributeId", catalogTypeAttributeId );
int i = 0;
- Integer inventoryTypeAttributeId=3;
- for( CCEMReportDesign ccemReportDesign1 : reportDesignList )
+ Integer inventoryTypeAttributeId = 3;
+ for ( CCEMReportDesign ccemReportDesign1 : reportDesignList )
{
i++;
- if( i == 1 ) continue;
+ if ( i == 1 )
+ continue;
String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
- if( ccemCellContent1.split( ":" )[3].equalsIgnoreCase( "UNKNOWN" ))
+ if ( ccemCellContent1.split( ":" )[3].equalsIgnoreCase( "UNKNOWN" ) )
{
-
+
}
- else if( ccemCellContent1.split( ":" )[4].equalsIgnoreCase( "MORE" ) )
+ else if ( ccemCellContent1.split( ":" )[4].equalsIgnoreCase( "MORE" ) )
{
inventoryTypeId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
catalogTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
- inventoryTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[2] );
+ inventoryTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[2] );
}
else
{
inventoryTypeId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
catalogTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
- inventoryTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[2] );
+ inventoryTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[2] );
}
- }
- Map<String, Integer> catalogTypeAttributeValueMap1 = new HashMap<String, Integer>(
- ccemReportManager.getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId,
- catalogTypeAttributeId, inventoryTypeAttributeId, 0, 2 ) );
-
- Map<String, Integer> catalogTypeAttributeValueMap2 = new HashMap<String, Integer>(
- ccemReportManager.getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId,
- catalogTypeAttributeId, inventoryTypeAttributeId, 3, 5 ) );
-
- Map<String, Integer> catalogTypeAttributeValueMap3 = new HashMap<String, Integer>(
- ccemReportManager.getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId,
- catalogTypeAttributeId, inventoryTypeAttributeId, 6, 10 ) );
-
- Map<String, Integer> catalogTypeAttributeValueMap4 = new HashMap<String, Integer>( ccemReportManager.getCatalogTypeAttributeValueByAge( orgUnitIdsByComma,inventoryTypeId, catalogTypeAttributeId, 3, 11, -1 ) );
-
+ }
+ Map<String, Integer> catalogTypeAttributeValueMap1 = new HashMap<String, Integer>( ccemReportManager
+ .getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId, catalogTypeAttributeId,
+ inventoryTypeAttributeId, 0, 2 ) );
+
+ Map<String, Integer> catalogTypeAttributeValueMap2 = new HashMap<String, Integer>( ccemReportManager
+ .getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId, catalogTypeAttributeId,
+ inventoryTypeAttributeId, 3, 5 ) );
+
+ Map<String, Integer> catalogTypeAttributeValueMap3 = new HashMap<String, Integer>( ccemReportManager
+ .getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId, catalogTypeAttributeId,
+ inventoryTypeAttributeId, 6, 10 ) );
+
+ Map<String, Integer> catalogTypeAttributeValueMap4 = new HashMap<String, Integer>( ccemReportManager
+ .getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId, catalogTypeAttributeId, 3, 11,
+ -1 ) );
+
hash.put( "Value_0_2", catalogTypeAttributeValueMap1 );
- hash.put( "Value_3_5", catalogTypeAttributeValueMap2 );
+ hash.put( "Value_3_5", catalogTypeAttributeValueMap2 );
hash.put( "Value_6_10", catalogTypeAttributeValueMap3 );
- hash.put( "Value_11_MORE", catalogTypeAttributeValueMap4 );
-
+ hash.put( "Value_11_MORE", catalogTypeAttributeValueMap4 );
+
fileName = "CATALOGTYPE ATTRIBUTE VALUE AGE GROUP.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport( path + fileName );
jasperPrint = JasperFillManager.fillReport( jasperReport, hash, con );
}
- else if( ccemReport.getReportType().equals( CCEMReport.ORGUNITGROUP_DATAVALUE ) )
- {
+ else if ( ccemReport.getReportType().equals( CCEMReport.ORGUNITGROUP_DATAVALUE ) )
+ {
ccemReportOutput = new CCEMReportOutput();
List<String> tableHeadings = new ArrayList<String>();
List<List<String>> tableSubHeadings = new ArrayList<List<String>>();
List tableData = new ArrayList();
List<String> oneSubHeadingRow = new ArrayList<String>();
- List<String> content= new ArrayList<String>();
-
- FastReportBuilder frb = new FastReportBuilder();
+ List<String> content = new ArrayList<String>();
+
+ FastReportBuilder frb = new FastReportBuilder();
Integer periodId = 0;
Date date1 = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime( date1 );
- String periodStartDate = "";
- Map<String, Integer> subHeadingNumber= new HashMap<String, Integer>();
- if( periodRadio.equalsIgnoreCase( CCEMReport.CURRENT_YEAR ) )
+ String periodStartDate = "";
+ Map<String, Integer> subHeadingNumber = new HashMap<String, Integer>();
+ if ( periodRadio.equalsIgnoreCase( CCEMReport.CURRENT_YEAR ) )
{
periodStartDate = calendar.get( Calendar.YEAR ) + "-01-01";
}
- else if( periodRadio.equalsIgnoreCase( CCEMReport.LAST_YEAR ) )
+ else if ( periodRadio.equalsIgnoreCase( CCEMReport.LAST_YEAR ) )
{
- periodStartDate = (calendar.get( Calendar.YEAR )-1) + "-01-01";
+ periodStartDate = (calendar.get( Calendar.YEAR ) - 1) + "-01-01";
}
-
- periodId = ccemReportManager.getPeriodId( periodStartDate, ccemReport.getPeriodRequire() );
- tableHeadings.add( "Facility Type" );
- oneSubHeadingRow.add( " " );
- tableHeadings.add( "Total Facilities" );
- oneSubHeadingRow.add( " " );
+
+ periodId = ccemReportManager.getPeriodId( periodStartDate, ccemReport.getPeriodRequire() );
+ tableHeadings.add( "Facility Type" );
+ oneSubHeadingRow.add( " " );
+ tableHeadings.add( "Total Facilities" );
+ oneSubHeadingRow.add( " " );
String dataElementIdsByComma = "-1";
String optComboIdsByComma = "-1";
List<String> dataElementOptions = new ArrayList<String>();
-
- for( CCEMReportDesign ccemReportDesign1 : reportDesignList )
- {
+
+ for ( CCEMReportDesign ccemReportDesign1 : reportDesignList )
+ {
String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
Integer dataElementId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
Integer optComboId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
-
+
dataElementIdsByComma += "," + dataElementId;
- optComboIdsByComma += "," + optComboId;
- tableHeadings.add( ccemReportDesign1.getDisplayheading() );
- List<String> distinctDataElementValues = new ArrayList<String>( ccemReportManager.getDistinctDataElementValue( dataElementId, optComboId, periodId ) );
- int number=0;
- for( int i = 0; i < distinctDataElementValues.size(); i++ )
- {
- if( i != 0 )
+ optComboIdsByComma += "," + optComboId;
+ tableHeadings.add( ccemReportDesign1.getDisplayheading() );
+ List<String> distinctDataElementValues = new ArrayList<String>( ccemReportManager
+ .getDistinctDataElementValue( dataElementId, optComboId, periodId ) );
+ int number = 0;
+ for ( int i = 0; i < distinctDataElementValues.size(); i++ )
+ {
+ if ( i != 0 )
{
- tableHeadings.add( " " );
+ tableHeadings.add( " " );
}
oneSubHeadingRow.add( distinctDataElementValues.get( i ).split( ":" )[2] );
dataElementOptions.add( distinctDataElementValues.get( i ) );
@@ -417,114 +419,118 @@
}
subHeadingNumber.put( ccemReportDesign1.getDisplayheading(), number );
}
-
- tableSubHeadings.add( oneSubHeadingRow );
- int count=0;
-
- for(int i=0;i<=tableHeadings.size()-1;i++)
- {
- if(tableHeadings.get( i )==" " )
- {
+
+ tableSubHeadings.add( oneSubHeadingRow );
+ int count = 0;
+
+ for ( int i = 0; i <= tableHeadings.size() - 1; i++ )
+ {
+ if ( tableHeadings.get( i ) == " " )
+ {
}
else
{
- if(i==0 || i==1)
+ if ( i == 0 || i == 1 )
{
- frb.addColumn(tableHeadings.get( i ), tableHeadings.get( i ), String.class.getName(), 100,true);
+ frb.addColumn( tableHeadings.get( i ), tableHeadings.get( i ), String.class.getName(), 100,
+ true );
count++;
-
+
}
else
- {
+ {
}
}
}
- for(int j=0;j<=tableSubHeadings.size()-1;j++)
- {
- for(int k=0; k<=tableSubHeadings.get( j ).size()-1;k++)
+ for ( int j = 0; j <= tableSubHeadings.size() - 1; j++ )
+ {
+ for ( int k = 0; k <= tableSubHeadings.get( j ).size() - 1; k++ )
{
- if(tableSubHeadings.get( j ).get( k )==" ")
- {
+ if ( tableSubHeadings.get( j ).get( k ) == " " )
+ {
}
else
- {
- frb.addColumn(tableSubHeadings.get( j ).get( k ),
- tableSubHeadings.get( j ).get( k ), String.class.getName(), 50, true);
- content.add( tableSubHeadings.get( j ).get( k ) );
- count++;
+ {
+ frb.addColumn( tableSubHeadings.get( j ).get( k ), tableSubHeadings.get( j ).get( k ),
+ String.class.getName(), 50, true );
+ content.add( tableSubHeadings.get( j ).get( k ) );
+ count++;
}
- }
- }
- frb.setPrintColumnNames(true);
+ }
+ }
+ frb.setPrintColumnNames( true );
frb.setHeaderHeight( 100 );
- frb.setColumnsPerPage(1, count).setUseFullPageWidth(true);
-
- int start=2;
- for(int i=2;i<=tableHeadings.size()-1;i++)
- {
- if(tableHeadings.get( i )== " ")
- {
-
- }
- else
- {
- frb.setColspan(start, subHeadingNumber.get( tableHeadings.get( i ) ), tableHeadings.get( i ));
- start=start + subHeadingNumber.get( tableHeadings.get( i ) );
- }
- }
- frb.setTemplateFile( path+"ORGUNITGROUP_DATAVALUE.jrxml" );
- for( Integer orgUnitGroupId : orgunitGroupList )
- {
- Map numberOfData=new HashMap();
+ frb.setColumnsPerPage( 1, count ).setUseFullPageWidth( true );
+
+ int start = 2;
+ for ( int i = 2; i <= tableHeadings.size() - 1; i++ )
+ {
+ if ( tableHeadings.get( i ) == " " )
+ {
+
+ }
+ else
+ {
+ frb.setColspan( start, subHeadingNumber.get( tableHeadings.get( i ) ), tableHeadings.get( i ) );
+ start = start + subHeadingNumber.get( tableHeadings.get( i ) );
+ }
+ }
+ frb.setTemplateFile( path + "ORGUNITGROUP_DATAVALUE.jrxml" );
+ for ( Integer orgUnitGroupId : orgunitGroupList )
+ {
+ Map numberOfData = new HashMap();
List<Integer> orgUnitIds = ccemReportManager.getOrgunitIds( selOrgUnitList, orgUnitGroupId );
- if( orgUnitIds == null || orgUnitIds.size() <= 0 )
- {
-
+ if ( orgUnitIds == null || orgUnitIds.size() <= 0 )
+ {
+
}
- else
+ else
{
- OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
-
- String orgUnitIdsBycomma = getCommaDelimitedString( orgUnitIds );
- numberOfData.put( "Facility Type", orgUnitGroup.getName() );
- numberOfData.put( "Total Facilities", ""+orgUnitIds.size() );
- Map<String, Integer> dataValueCountMap2 = new HashMap<String, Integer>( ccemReportManager.getDataValueCountforDataElements( dataElementIdsByComma, optComboIdsByComma, periodId, orgUnitIdsBycomma ) );
- for(int i=0;i<=dataElementOptions.size()-1;i++)
- {
- Integer temp = dataValueCountMap2.get( dataElementOptions.get(i) );
- if( temp == null )
- {
- numberOfData.put( content.get( i ), "0" );
- }
- else
- {
- numberOfData.put( content.get( i ), temp+"" );
- }
- }
+ OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService
+ .getOrganisationUnitGroup( orgUnitGroupId );
+
+ String orgUnitIdsBycomma = getCommaDelimitedString( orgUnitIds );
+ numberOfData.put( "Facility Type", orgUnitGroup.getName() );
+ numberOfData.put( "Total Facilities", "" + orgUnitIds.size() );
+ Map<String, Integer> dataValueCountMap2 = new HashMap<String, Integer>( ccemReportManager
+ .getDataValueCountforDataElements( dataElementIdsByComma, optComboIdsByComma, periodId,
+ orgUnitIdsBycomma ) );
+ for ( int i = 0; i <= dataElementOptions.size() - 1; i++ )
+ {
+ Integer temp = dataValueCountMap2.get( dataElementOptions.get( i ) );
+ if ( temp == null )
+ {
+ numberOfData.put( content.get( i ), "0" );
+ }
+ else
+ {
+ numberOfData.put( content.get( i ), temp + "" );
+ }
+ }
tableData.add( numberOfData );
- }
+ }
}
-
- JRDataSource ds = new JRMapCollectionDataSource(tableData );
+
+ JRDataSource ds = new JRMapCollectionDataSource( tableData );
DynamicReport dynamicReport = frb.build();
dynamicReport.getOptions().getDefaultDetailStyle().setBackgroundColor( Color.BLUE );
- dynamicReport.getOptions().getDefaultHeaderStyle().setBorder(Border.THIN());
- dynamicReport.getOptions().getDefaultHeaderStyle().setHorizontalAlign(HorizontalAlign.CENTER );
- dynamicReport.getOptions().getDefaultDetailStyle().setBorder(Border.THIN());
- dynamicReport.getOptions().getDefaultDetailStyle().setHorizontalAlign(HorizontalAlign.CENTER );
- dynamicReport.getOptions().getDefaultDetailStyle().setVerticalAlign( VerticalAlign.MIDDLE );
+ dynamicReport.getOptions().getDefaultHeaderStyle().setBorder( Border.THIN() );
+ dynamicReport.getOptions().getDefaultHeaderStyle().setHorizontalAlign( HorizontalAlign.CENTER );
+ dynamicReport.getOptions().getDefaultDetailStyle().setBorder( Border.THIN() );
+ dynamicReport.getOptions().getDefaultDetailStyle().setHorizontalAlign( HorizontalAlign.CENTER );
+ dynamicReport.getOptions().getDefaultDetailStyle().setVerticalAlign( VerticalAlign.MIDDLE );
jr = DynamicJasperHelper.generateJasperReport( dynamicReport, new ClassicLayoutManager(), hash );
- jasperPrint = JasperFillManager.fillReport( jr, hash, ds );
+ jasperPrint = JasperFillManager.fillReport( jr, hash, ds );
}
-
- else if( ccemReport.getReportType().equals( CCEMReport.ORGUNIT_EQUIPMENT_ROUTINE_DATAVALUE ) )
+
+ else if ( ccemReport.getReportType().equals( CCEMReport.ORGUNIT_EQUIPMENT_ROUTINE_DATAVALUE ) )
{
ccemReportOutput = new CCEMReportOutput();
List<String> tableHeadings = new ArrayList<String>();
List<List<String>> tableSubHeadings = new ArrayList<List<String>>();
List<String> oneSubHeadingRow = new ArrayList<String>();
List tableData = new ArrayList();
- List<String> content= new ArrayList<String>();
+ List<String> content = new ArrayList<String>();
Date date2 = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime( date2 );
@@ -535,171 +541,176 @@
PeriodType periodType = periodService.getPeriodTypeByName( ccemReport.getPeriodRequire() );
Date sDate = null;
Date eDate = null;
- Map<String, Integer> subHeadingNumber= new HashMap<String, Integer>();
- int monthDays[] = {31,28,31,30,31,30,31,31,30,31,30,31};
-
+ Map<String, Integer> subHeadingNumber = new HashMap<String, Integer>();
+ int monthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
tableHeadings.add( "OrgUnit Hierarchy" );
oneSubHeadingRow.add( " " );
tableHeadings.add( "OrgUnit" );
oneSubHeadingRow.add( " " );
-
- if( periodRadio.equalsIgnoreCase( CCEMReport.CURRENT_YEAR ) )
+
+ if ( periodRadio.equalsIgnoreCase( CCEMReport.CURRENT_YEAR ) )
{
periodStartDate = calendar.get( Calendar.YEAR ) + "-01-01";
periodEndDate = calendar.get( Calendar.YEAR ) + "-12-31";
sDate = format.parseDate( periodStartDate );
eDate = format.parseDate( periodEndDate );
}
- else if( periodRadio.equalsIgnoreCase( CCEMReport.LAST_YEAR ) )
+ else if ( periodRadio.equalsIgnoreCase( CCEMReport.LAST_YEAR ) )
{
- periodStartDate = (calendar.get( Calendar.YEAR )-1) + "-01-01";
- periodEndDate = (calendar.get( Calendar.YEAR )-1) + "-12-31";
- sDate = format.parseDate( periodStartDate );
- eDate = format.parseDate( periodEndDate );
+ periodStartDate = (calendar.get( Calendar.YEAR ) - 1) + "-01-01";
+ periodEndDate = (calendar.get( Calendar.YEAR ) - 1) + "-12-31";
+ sDate = format.parseDate( periodStartDate );
+ eDate = format.parseDate( periodEndDate );
}
- else if( periodRadio.equalsIgnoreCase( CCEMReport.LAST_6_MONTHS ) )
+ else if ( periodRadio.equalsIgnoreCase( CCEMReport.LAST_6_MONTHS ) )
{
calendar.add( Calendar.MONTH, -1 );
calendar.set( Calendar.DATE, monthDays[calendar.get( Calendar.MONTH )] );
eDate = calendar.getTime();
-
+
calendar.add( Calendar.MONTH, -5 );
calendar.set( Calendar.DATE, 1 );
sDate = calendar.getTime();
}
- else if( periodRadio.equalsIgnoreCase( CCEMReport.LAST_3_MONTHS ) )
+ else if ( periodRadio.equalsIgnoreCase( CCEMReport.LAST_3_MONTHS ) )
{
calendar.add( Calendar.MONTH, -1 );
calendar.set( Calendar.DATE, monthDays[calendar.get( Calendar.MONTH )] );
eDate = calendar.getTime();
-
+
calendar.add( Calendar.MONTH, -2 );
calendar.set( Calendar.DATE, 1 );
sDate = calendar.getTime();
}
-
+
periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates( periodType, sDate, eDate ) );
- Collection<Integer> periodIds = new ArrayList<Integer>( getIdentifiers(Period.class, periodList ) );
+ Collection<Integer> periodIds = new ArrayList<Integer>( getIdentifiers( Period.class, periodList ) );
periodIdsByComma = getCommaDelimitedString( periodIds );
SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MMM-yy" );
-
-
+
String dataElementIdsByComma = "-1";
String optComboIdsByComma = "-1";
-
- for( CCEMReportDesign ccemReportDesign1 : reportDesignList )
+
+ for ( CCEMReportDesign ccemReportDesign1 : reportDesignList )
{
String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
Integer dataElementId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
Integer optComboId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
-
+
dataElementIdsByComma += "," + dataElementId;
optComboIdsByComma += "," + optComboId;
-
+
tableHeadings.add( ccemReportDesign1.getDisplayheading() );
int i = 0;
- for( Period period : periodList )
+ for ( Period period : periodList )
{
oneSubHeadingRow.add( simpleDateFormat.format( period.getStartDate() ) );
- if( i != 0 )
+ if ( i != 0 )
tableHeadings.add( " " );
i++;
}
subHeadingNumber.put( ccemReportDesign1.getDisplayheading(), i );
}
-
+
List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>();
List<OrganisationUnit> orgUnitGroupMembers = new ArrayList<OrganisationUnit>();
-
- for( Integer orgUnitGroupId : orgunitGroupList )
+
+ for ( Integer orgUnitGroupId : orgunitGroupList )
{
- OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
+ OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService
+ .getOrganisationUnitGroup( orgUnitGroupId );
orgUnitGroupMembers.addAll( orgUnitGroup.getMembers() );
}
-
- for( Integer orgUnitId : selOrgUnitList )
+
+ for ( Integer orgUnitId : selOrgUnitList )
{
orgUnitList.addAll( organisationUnitService.getOrganisationUnitWithChildren( orgUnitId ) );
}
-
+
orgUnitList.retainAll( orgUnitGroupMembers );
- Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers(OrganisationUnit.class, orgUnitList ) );
+ Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class,
+ orgUnitList ) );
orgUnitIdsByComma = getCommaDelimitedString( orgUnitIds );
-
- Map<String, Integer> equipmentDataValueMap = new HashMap<String, Integer>( ccemReportManager.getFacilityWiseEquipmentRoutineData( orgUnitIdsByComma, periodIdsByComma, dataElementIdsByComma, optComboIdsByComma ) );
-
+
+ Map<String, Integer> equipmentDataValueMap = new HashMap<String, Integer>( ccemReportManager
+ .getFacilityWiseEquipmentRoutineData( orgUnitIdsByComma, periodIdsByComma, dataElementIdsByComma,
+ optComboIdsByComma ) );
+
FastReportBuilder frb = new FastReportBuilder();
tableSubHeadings.add( oneSubHeadingRow );
-
- int count=0;
-
- for(int i=0;i<=tableHeadings.size()-1;i++)
- {
- if(tableHeadings.get( i )==" " )
- {
+
+ int count = 0;
+
+ for ( int i = 0; i <= tableHeadings.size() - 1; i++ )
+ {
+ if ( tableHeadings.get( i ) == " " )
+ {
}
else
{
- if(i==0 || i==1)
+ if ( i == 0 || i == 1 )
{
- content.add(tableHeadings.get( i ));
- frb.addColumn(tableHeadings.get( i ), tableHeadings.get( i ), String.class.getName(), 50,true);
+ content.add( tableHeadings.get( i ) );
+ frb
+ .addColumn( tableHeadings.get( i ), tableHeadings.get( i ), String.class.getName(), 50,
+ true );
count++;
-
+
}
else
- {
+ {
}
}
}
- for(int j=0;j<=tableSubHeadings.size()-1;j++)
- {
- int increment=0;
-
- for(int k=0; k<=tableSubHeadings.get( j ).size()-1;k++)
+ for ( int j = 0; j <= tableSubHeadings.size() - 1; j++ )
+ {
+ int increment = 0;
+
+ for ( int k = 0; k <= tableSubHeadings.get( j ).size() - 1; k++ )
{
-
- if(tableSubHeadings.get( j ).get( k )==" ")
- {
+
+ if ( tableSubHeadings.get( j ).get( k ) == " " )
+ {
}
else
- {
- if(tableSubHeadings.get( j ).get( k ).contains( tableSubHeadings.get( j ).get( k ) ))
+ {
+ if ( tableSubHeadings.get( j ).get( k ).contains( tableSubHeadings.get( j ).get( k ) ) )
{
increment++;
}
-
- frb.addColumn(tableSubHeadings.get( j ).get( k ),
- tableSubHeadings.get( j ).get( k )+ " "+ increment , String.class.getName(), 50, true);
- content.add( tableSubHeadings.get( j ).get( k )+ " "+increment );
- count++;
+
+ frb.addColumn( tableSubHeadings.get( j ).get( k ), tableSubHeadings.get( j ).get( k ) + " "
+ + increment, String.class.getName(), 50, true );
+ content.add( tableSubHeadings.get( j ).get( k ) + " " + increment );
+ count++;
}
- }
- }
- frb.setPrintColumnNames(true);
+ }
+ }
+ frb.setPrintColumnNames( true );
frb.setHeaderHeight( 100 );
- frb.setColumnsPerPage(1, count).setUseFullPageWidth(true);
-
- int start=2;
- for(int i=2;i<=tableHeadings.size()-1;i++)
- {
- if(tableHeadings.get( i )== " ")
- {
-
- }
- else
- {
- frb.setColspan(start, subHeadingNumber.get( tableHeadings.get( i ) ), tableHeadings.get( i ));
- start=start + subHeadingNumber.get( tableHeadings.get( i ) );
- }
- }
-
- for( OrganisationUnit orgUnit : orgUnitList )
- {
- Map<String, String> numberOfData=new HashMap<String, String>();
+ frb.setColumnsPerPage( 1, count ).setUseFullPageWidth( true );
+
+ int start = 2;
+ for ( int i = 2; i <= tableHeadings.size() - 1; i++ )
+ {
+ if ( tableHeadings.get( i ) == " " )
+ {
+
+ }
+ else
+ {
+ frb.setColspan( start, subHeadingNumber.get( tableHeadings.get( i ) ), tableHeadings.get( i ) );
+ start = start + subHeadingNumber.get( tableHeadings.get( i ) );
+ }
+ }
+
+ for ( OrganisationUnit orgUnit : orgUnitList )
+ {
+ Map<String, String> numberOfData = new HashMap<String, String>();
List<String> oneTableDataRow = new ArrayList<String>();
String orgUnitBranch = "";
- if( orgUnit.getParent() != null )
+ if ( orgUnit.getParent() != null )
{
orgUnitBranch = getOrgunitBranch( orgUnit.getParent() );
}
@@ -707,97 +718,222 @@
{
orgUnitBranch = " ";
}
-
+
numberOfData.put( content.get( 0 ), orgUnitBranch );
numberOfData.put( content.get( 1 ), orgUnit.getName() );
- int i=2;
- for( CCEMReportDesign ccemReportDesign1 : reportDesignList )
- {
+ int i = 2;
+ for ( CCEMReportDesign ccemReportDesign1 : reportDesignList )
+ {
String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
Integer dataElementId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
Integer optComboId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
-
- for(Period period : periodList)
- {
- Integer temp = equipmentDataValueMap.get( orgUnit.getId()+":"+dataElementId+":"+period.getId() );
- if( temp == null )
- {
- numberOfData.put(content.get( i ), " " );
+
+ for ( Period period : periodList )
+ {
+ Integer temp = equipmentDataValueMap.get( orgUnit.getId() + ":" + dataElementId + ":"
+ + period.getId() );
+ if ( temp == null )
+ {
+ numberOfData.put( content.get( i ), " " );
}
else
- {
- numberOfData.put(content.get( i ) , temp+"" );
+ {
+ numberOfData.put( content.get( i ), temp + "" );
}
- i++;
- }
-
- }
+ i++;
+ }
+
+ }
tableData.add( numberOfData );
}
- frb.setTemplateFile( path+"ORGUNIT_EQUIPMENT_ROUTINE_DATAVALUE.jrxml" );
- JRDataSource ds = new JRMapCollectionDataSource(tableData );
+ frb.setTemplateFile( path + "ORGUNIT_EQUIPMENT_ROUTINE_DATAVALUE.jrxml" );
+ JRDataSource ds = new JRMapCollectionDataSource( tableData );
DynamicReport dynamicReport = frb.build();
dynamicReport.getOptions().getDefaultDetailStyle().setBackgroundColor( Color.BLUE );
- dynamicReport.getOptions().getDefaultHeaderStyle().setBorder(Border.THIN());
- dynamicReport.getOptions().getDefaultHeaderStyle().setHorizontalAlign(HorizontalAlign.CENTER );
- dynamicReport.getOptions().getDefaultDetailStyle().setBorder(Border.THIN());
- dynamicReport.getOptions().getDefaultDetailStyle().setHorizontalAlign(HorizontalAlign.CENTER );
- dynamicReport.getOptions().getDefaultDetailStyle().setVerticalAlign( VerticalAlign.MIDDLE );
+ dynamicReport.getOptions().getDefaultHeaderStyle().setBorder( Border.THIN() );
+ dynamicReport.getOptions().getDefaultHeaderStyle().setHorizontalAlign( HorizontalAlign.CENTER );
+ dynamicReport.getOptions().getDefaultDetailStyle().setBorder( Border.THIN() );
+ dynamicReport.getOptions().getDefaultDetailStyle().setHorizontalAlign( HorizontalAlign.CENTER );
+ dynamicReport.getOptions().getDefaultDetailStyle().setVerticalAlign( VerticalAlign.MIDDLE );
jr = DynamicJasperHelper.generateJasperReport( dynamicReport, new ClassicLayoutManager(), hash );
jasperPrint = JasperFillManager.fillReport( jr, hash, ds );
}
- else if( ccemReport.getReportType().equals( CCEMReport.VACCINE_STORAGE_CAPACITY ) )
+ else if ( ccemReport.getReportType().equals( CCEMReport.VACCINE_STORAGE_CAPACITY ) )
{
+ ccemReportOutput = new CCEMReportOutput();
List<String> tableHeadings = new ArrayList<String>();
List<List<String>> tableSubHeadings = new ArrayList<List<String>>();
List<String> oneSubHeadingRow = new ArrayList<String>();
List tableData = new ArrayList();
-
+
List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>();
List<OrganisationUnit> orgUnitGroupMembers = new ArrayList<OrganisationUnit>();
+ List<String> content = new ArrayList<String>();
String orgUnitGroupIdsByComma = "-1";
-
+ Map<String, Integer> subHeadingNumber = new HashMap<String, Integer>();
Integer periodId = 0;
Date date2 = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime( date2 );
String periodStartDate = "";
-
+
periodStartDate = calendar.get( Calendar.YEAR ) + "-01-01";
-
+
periodId = ccemReportManager.getPeriodId( periodStartDate, "Yearly" );
-
- FastReportBuilder frb = new FastReportBuilder();
- frb.addColumn( "OrgUnit Hierarchy", "OrgUnit Hierarchy", String.class.getName(), 100,true );
- frb.addColumn( "OrgUnit", "OrgUnit", String.class.getName(), 100,true );
- frb.addColumn( "OrgUnit Code", "OrgUnit Code", String.class.getName(), 100,true );
- frb.setPrintColumnNames(true);
-
- frb.setColumnsPerPage(1, 10).setUseFullPageWidth(true);
- frb.setTemplateFile( path+"VACCINE_STORAGE_CAPACITY.jrxml" );
-
- String dataElementIdsByComma = "-1";
- String optComboIdsByComma = "-1";
-
- for( Integer orgUnitGroupId : orgunitGroupList )
- {
- OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
- orgUnitGroupMembers.addAll( orgUnitGroup.getMembers() );
- }
-
- for( Integer orgUnitId : selOrgUnitList )
+
+ FastReportBuilder frb = new FastReportBuilder();
+ frb.addColumn( "OrgUnit Hierarchy", "OrgUnit Hierarchy", String.class.getName(), 170, true );
+ frb.addColumn( "OrgUnit", "OrgUnit", String.class.getName(), 80, true );
+ frb.addColumn( "OrgUnit Code", "OrgUnit Code", String.class.getName(), 70, true );
+ frb.addColumn( "OrgUnit Type", "OrgUnit Type", String.class.getName(), 80, true );
+ frb.addColumn( "Actual", "Actual", String.class.getName(), 50, true );
+ frb.addColumn( "Required", "Required", String.class.getName(), 50, true );
+ frb.addColumn( "Difference", "Difference", String.class.getName(), 50, true );
+ frb.addColumn( ">30%", ">30%-1", String.class.getName(), 50, true );
+ frb.addColumn( "10-30%", "10-30%-1", String.class.getName(), 50, true );
+ frb.addColumn( "+/- 10%", "+/- 10%-1", String.class.getName(), 50, true );
+ frb.addColumn( "10-30%", "10-30%-2", String.class.getName(), 50, true );
+ frb.addColumn( ">30%", ">30%-2", String.class.getName(), 50, true );
+ frb.setColspan( 4, 3, "Net Storage" );
+ frb.setColspan( 7, 2, "Surplus" );
+ frb.setColspan( 9, 1, "Match" );
+ frb.setColspan( 10, 2, "Shortage" );
+
+ CCEMReportDesign ccemReportDesign1 = reportDesignList.get( 0 );
+ String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
+ if ( ccemCellContent1.equals( "ALL" ) )
+ {
+ for ( Integer orgUnitGroupId : orgunitGroupList )
+ {
+ OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService
+ .getOrganisationUnitGroup( orgUnitGroupId );
+ orgUnitGroupMembers.addAll( orgUnitGroup.getMembers() );
+ orgUnitGroupIdsByComma += "," + orgUnitGroupId;
+ }
+ }
+ else
+ {
+ String orgUnitGroupIds[] = ccemReportDesign1.getContent().split( "," );
+
+ for ( Integer orgUnitGroupId : orgunitGroupList )
+ {
+ int flag = 0;
+ for ( String ouGroupId : orgUnitGroupIds )
+ {
+ if ( Integer.parseInt( ouGroupId ) == orgUnitGroupId )
+ {
+ orgUnitGroupIdsByComma += "," + orgUnitGroupId;
+ flag = 1;
+ break;
+ }
+ }
+
+ if ( flag == 0 )
+ continue;
+
+ OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService
+ .getOrganisationUnitGroup( orgUnitGroupId );
+ orgUnitGroupMembers.addAll( orgUnitGroup.getMembers() );
+ }
+ }
+
+ for ( Integer orgUnitId : selOrgUnitList )
{
orgUnitList.addAll( organisationUnitService.getOrganisationUnitWithChildren( orgUnitId ) );
}
-
+
orgUnitList.retainAll( orgUnitGroupMembers );
- for( OrganisationUnit orgUnit : orgUnitList )
- {
- Map<String, String> numberOfData=new HashMap<String, String>();
- List<String> oneTableDataRow = new ArrayList<String>();
+ Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class,
+ orgUnitList ) );
+ orgUnitIdsByComma = getCommaDelimitedString( orgUnitIds );
+
+ // Calculations for Actual Column
+ ccemReportDesign1 = reportDesignList.get( 1 );
+ ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
+
+ String[] partsOfCellContent = ccemCellContent1.split( "-" );
+ Integer vscrActualInventoryTypeId = Integer.parseInt( partsOfCellContent[0].split( ":" )[0] );
+ Integer vscrActualInventoryTypeAttributeId = Integer.parseInt( partsOfCellContent[0].split( ":" )[1] );
+ Double factor = Double.parseDouble( partsOfCellContent[0].split( ":" )[2] );
+ ;
+
+ Map<Integer, Double> equipmentSumByInventoryTypeMap = new HashMap<Integer, Double>( ccemReportManager
+ .getSumOfEquipmentDatabyInventoryType( orgUnitIdsByComma, vscrActualInventoryTypeId,
+ vscrActualInventoryTypeAttributeId, factor ) );
+
+ String[] partsOfVSRActualCellContent = partsOfCellContent[1].split( ":" );
+ Integer vsrActualInventoryTypeId = Integer.parseInt( partsOfVSRActualCellContent[0] );
+ Integer vsrActualCatalogTypeAttributeId = Integer.parseInt( partsOfVSRActualCellContent[1] );
+ Integer vsrActualInventoryTypeAttributeId = Integer.parseInt( partsOfVSRActualCellContent[2] );
+ String vsrActualEquipmentValue = partsOfVSRActualCellContent[3];
+
+ Map<Integer, Double> catalogSumByEquipmentDataMap = new HashMap<Integer, Double>( ccemReportManager
+ .getCatalogDataSumByEquipmentData( orgUnitIdsByComma, vsrActualInventoryTypeId,
+ vsrActualCatalogTypeAttributeId, vsrActualInventoryTypeAttributeId, vsrActualEquipmentValue ) );
+
+ // Calculations for Required Column
+ ccemReportDesign1 = reportDesignList.get( 2 );
+ ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
+ partsOfCellContent = ccemCellContent1.split( "--" );
+
+ String[] catalogDataParts = partsOfCellContent[0].split( ":" );
+ Integer vsReqCatalogTypeId = Integer.parseInt( catalogDataParts[0] );
+ Integer vsReqStorageTempId = Integer.parseInt( catalogDataParts[1] );
+ String vsReqStorageTemp = catalogDataParts[2];
+ Integer vsReqNationalSupplyId = Integer.parseInt( catalogDataParts[3] );
+ String vsReqNationalSupply = catalogDataParts[4];
+ String vsReqCatalogAttribIds = catalogDataParts[5];
+
+ Integer vsReqPackedVol = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[0] );
+ Integer vsReqDiluentVol = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[1] );
+ Integer vsReqDoses = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[2] );
+ Integer vsReqTargetPopCat = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[3] );
+ Integer vsReqUsage = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[4] );
+ Integer vsReqWastage = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[5] );
+
+ List<Integer> catalogIdsForRequirement = new ArrayList<Integer>( ccemReportManager
+ .getCatalogIdsForRequirement( vsReqCatalogTypeId, vsReqStorageTempId, vsReqStorageTemp,
+ vsReqNationalSupplyId, vsReqNationalSupply ) );
+
+ Map<String, String> catalogDataForRequirement = new HashMap<String, String>( ccemReportManager
+ .getCatalogDataForRequirement( vsReqCatalogTypeId, vsReqStorageTempId, vsReqStorageTemp,
+ vsReqNationalSupplyId, vsReqNationalSupply, vsReqCatalogAttribIds ) );
+
+ Integer vsReqStaticDel = Integer.parseInt( partsOfCellContent[3].split( "," )[0] );
+ Integer vsReqOutReachDel = Integer.parseInt( partsOfCellContent[3].split( "," )[1] );
+
+ String catalogOption_DataelementIds = vsReqStaticDel + "," + vsReqOutReachDel;
+
+ String[] dataelementDataParts = partsOfCellContent[1].split( "," );
+ Map<String, Integer> catalogOption_DataelementMap = new HashMap<String, Integer>();
+
+ for ( String de_catalogOption : dataelementDataParts )
+ {
+ catalogOption_DataelementMap.put( de_catalogOption.split( ":" )[1], Integer.parseInt( de_catalogOption
+ .split( ":" )[0] ) );
+ catalogOption_DataelementIds += "," + Integer.parseInt( de_catalogOption.split( ":" )[0] );
+ }
+
+ Map<String, String> dataElementDataForRequirement = new HashMap<String, String>( ccemReportManager
+ .getDataElementDataForCatalogOptionsForRequirement( orgUnitIdsByComma, catalogOption_DataelementIds,
+ periodId ) );
+
+ String orgUnitGroupAttribIds = partsOfCellContent[2];
+ Integer vsReqSupplyInterval = Integer.parseInt( orgUnitGroupAttribIds.split( "," )[0] );
+ Integer vsReqReserveStock = Integer.parseInt( orgUnitGroupAttribIds.split( "," )[1] );
+
+ Map<String, String> orgUnitGroupAttribDataForRequirement = new HashMap<String, String>( ccemReportManager
+ .getOrgUnitGroupAttribDataForRequirement( orgUnitGroupIdsByComma, orgUnitGroupAttribIds ) );
+
+ Map<Integer, String> orgUnitGroupMap = new HashMap<Integer, String>( ccemReportManager
+ .getOrgunitAndOrgUnitGroupMap( orgUnitGroupIdsByComma, orgUnitIdsByComma ) );
+
+ for ( OrganisationUnit orgUnit : orgUnitList )
+ {
+ Map<String, String> numberOfData = new HashMap<String, String>();
String orgUnitBranch = "";
- if( orgUnit.getParent() != null )
+ if ( orgUnit.getParent() != null )
{
orgUnitBranch = getOrgunitBranch( orgUnit.getParent() );
}
@@ -805,31 +941,264 @@
{
orgUnitBranch = " ";
}
-
numberOfData.put( "OrgUnit Hierarchy", orgUnitBranch );
- numberOfData.put( "OrgUnit", orgUnit.getName()+"" );
- numberOfData.put( "OrgUnit Code", orgUnit.getCode()+"" );
+ numberOfData.put( "OrgUnit", orgUnit.getName() );
+ numberOfData.put( "OrgUnit Code", orgUnit.getCode() );
+ String orgUnitGroupName = orgUnitGroupMap.get( orgUnit.getId() );
+ if ( orgUnitGroupName == null )
+ {
+ numberOfData.put( "OrgUnit Type", " " );
+ }
+ else
+ {
+ numberOfData.put( "OrgUnit Type", orgUnitGroupName );
+ }
+
+ Double vsrActualValue = catalogSumByEquipmentDataMap.get( orgUnit.getId() );
+ if ( vsrActualValue == null )
+ vsrActualValue = 0.0;
+
+ Double vscrActualValue = equipmentSumByInventoryTypeMap.get( orgUnit.getId() );
+ if ( vscrActualValue == null )
+ vscrActualValue = 0.0;
+
+ Double vaccineActualValue = vsrActualValue + vscrActualValue;
+ vaccineActualValue = Math.round( vaccineActualValue * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 );
+ numberOfData.put( "Actual", vaccineActualValue + "" );
+
+ // Calculation for Requirement Column
+ String tempStr = null;
+ Double vaccineRequirement = 0.0;
+ for ( Integer catalogId : catalogIdsForRequirement )
+ {
+ Double vsReqUsageData = 0.0;
+ tempStr = catalogDataForRequirement.get( catalogId + ":" + vsReqUsage );
+ if ( tempStr != null )
+ {
+ try
+ {
+ vsReqUsageData = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ vsReqUsageData = 0.0;
+ }
+ }
+
+ Double vsReqTargetPopData = 0.0;
+ String vsReqTargetPopCatData = catalogDataForRequirement.get( catalogId + ":" + vsReqTargetPopCat );
+ if ( vsReqTargetPopCatData != null )
+ {
+ Integer deId = catalogOption_DataelementMap.get( vsReqTargetPopCatData );
+ tempStr = dataElementDataForRequirement.get( deId + ":" + periodId + ":" + orgUnit.getId() );
+ if ( tempStr != null )
+ {
+ try
+ {
+ vsReqTargetPopData = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ vsReqTargetPopData = 0.0;
+ }
+ }
+ }
+
+ Double vsReqDosesData = 0.0;
+ tempStr = catalogDataForRequirement.get( catalogId + ":" + vsReqDoses );
+ if ( tempStr != null )
+ {
+ try
+ {
+ vsReqDosesData = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ vsReqDosesData = 0.0;
+ }
+ }
+
+ Double vsReqPackedVolData = 0.0;
+ tempStr = catalogDataForRequirement.get( catalogId + ":" + vsReqPackedVol );
+ if ( tempStr != null )
+ {
+ try
+ {
+ vsReqPackedVolData = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ vsReqPackedVolData = 0.0;
+ }
+ }
+
+ String tempStr1 = dataElementDataForRequirement.get( vsReqStaticDel + ":" + periodId + ":"
+ + orgUnit.getId() );
+ String tempStr2 = dataElementDataForRequirement.get( vsReqOutReachDel + ":" + periodId + ":"
+ + orgUnit.getId() );
+ if ( (tempStr1 != null && tempStr1.equalsIgnoreCase( "true" ))
+ || (tempStr2 != null && tempStr2.equalsIgnoreCase( "true" )) )
+ {
+ Double vsReqDiluentVolData = 0.0;
+ tempStr = catalogDataForRequirement.get( catalogId + ":" + vsReqDiluentVol );
+ if ( tempStr != null )
+ {
+ try
+ {
+ vsReqDiluentVolData = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ vsReqDiluentVolData = 0.0;
+ }
+ }
+
+ vsReqPackedVolData += vsReqDiluentVolData;
+ }
+
+ Double vsReqWastageData = 0.0;
+ tempStr = catalogDataForRequirement.get( catalogId + ":" + vsReqWastage );
+ if ( tempStr != null )
+ {
+ try
+ {
+ vsReqWastageData = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ vsReqWastageData = 0.0;
+ }
+ }
+
+ Double vsReqSupplyIntervalData = 0.0;
+ tempStr = orgUnitGroupAttribDataForRequirement.get( orgUnit.getId() + ":" + vsReqSupplyInterval );
+ if ( tempStr != null )
+ {
+ try
+ {
+ vsReqSupplyIntervalData = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ vsReqSupplyIntervalData = 0.0;
+ }
+ }
+
+ Double vsReqReserveStockData = 0.0;
+ tempStr = orgUnitGroupAttribDataForRequirement.get( orgUnit.getId() + ":" + vsReqReserveStock );
+ if ( tempStr != null )
+ {
+ try
+ {
+ vsReqReserveStockData = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ vsReqReserveStockData = 0.0;
+ }
+ }
+
+ // Formula for calculating Requirement for individual
+ // vaccine
+ Double individualVaccineRequirement = 0.0;
+ try
+ {
+ individualVaccineRequirement = ((vsReqUsageData * vsReqTargetPopData) / 100) * vsReqDosesData
+ * vsReqPackedVolData * (1 / (1 - (vsReqWastageData / 100)))
+ * (((vsReqSupplyIntervalData + vsReqReserveStockData) / 52) / 1000);
+ }
+ catch ( Exception e )
+ {
+ System.out.println( "Exception while calculating individualVaccineRequirement" );
+ individualVaccineRequirement = 0.0;
+ }
+
+ // System.out.println( vsReqUsageData
+ // +":"+vsReqTargetPopData +":"+vsReqDosesData
+ // +":"+vsReqPackedVolData +":"+ vsReqWastageData +":"+
+ // vsReqSupplyIntervalData +":"+ vsReqReserveStockData );
+
+ vaccineRequirement += individualVaccineRequirement;
+
+ }
+
+ vaccineRequirement = Math.round( vaccineRequirement * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 );
+ numberOfData.put( "Required", vaccineRequirement + "" );
+
+ Double diffVaccineReq = vaccineActualValue - vaccineRequirement;
+ diffVaccineReq = Math.round( diffVaccineReq * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 );
+ numberOfData.put( "Difference", "" + diffVaccineReq );
+
+ Double diffPercentage = (diffVaccineReq / vaccineActualValue) * 100;
+ if ( diffPercentage < -30.0 )
+ {
+ numberOfData.put( ">30%-1", "0" );
+ numberOfData.put( "10-30%-1", "0" );
+ numberOfData.put( "+/- 10%-1", "0" );
+ numberOfData.put( "10-30%-2", "0" );
+ numberOfData.put( ">30%-2", "1" );
+ }
+ else if ( diffPercentage >= -30.0 && diffPercentage < -10.0 )
+ {
+ numberOfData.put( ">30%-1", "0" );
+ numberOfData.put( "10-30%-1", "0" );
+ numberOfData.put( "+/- 10%-1", "0" );
+ numberOfData.put( "10-30%-2", "1" );
+ numberOfData.put( ">30%-2", "0" );
+ }
+ else if ( diffPercentage >= -10.0 && diffPercentage < 10.0 )
+ {
+ numberOfData.put( ">30%-1", "0" );
+ numberOfData.put( "10-30%-1", "0" );
+ numberOfData.put( "+/- 10%-1", "1" );
+ numberOfData.put( "10-30%-2", "0" );
+ numberOfData.put( ">30%-2", "0" );
+ }
+ else if ( diffPercentage >= 10.0 && diffPercentage < 30.0 )
+ {
+ numberOfData.put( ">30%-1", "0" );
+ numberOfData.put( "10-30%-1", "1" );
+ numberOfData.put( "+/- 10%-1", "0" );
+ numberOfData.put( "10-30%-2", "0" );
+ numberOfData.put( ">30%-2", "0" );
+ }
+ else
+ {
+ numberOfData.put( ">30%-1", "1" );
+ numberOfData.put( "10-30%-1", "0" );
+ numberOfData.put( "+/- 10%-1", "0" );
+ numberOfData.put( "10-30%-2", "0" );
+ numberOfData.put( ">30%-2", "0" );
+ }
+
tableData.add( numberOfData );
}
-
- JRDataSource ds = new JRMapCollectionDataSource(tableData );
+
+ frb.setPrintColumnNames( true );
+ frb.setHeaderHeight( 100 );
+ frb.setColumnsPerPage( 1, 15 ).setUseFullPageWidth( true );
+ frb.setTemplateFile( path + "VACCINE_STORAGE_CAPACITY.jrxml" );
+ Style oddRowStyle = new Style();
+ oddRowStyle.setBorder( Border.NO_BORDER() );
+ oddRowStyle.setBackgroundColor( Color.LIGHT_GRAY );
+ oddRowStyle.setTransparency( Transparency.OPAQUE );
+ JRDataSource ds = new JRMapCollectionDataSource( tableData );
+ frb.setOddRowBackgroundStyle( oddRowStyle );
DynamicReport dynamicReport = frb.build();
- dynamicReport.getOptions().getDefaultDetailStyle().setBackgroundColor( Color.BLUE );
- dynamicReport.getOptions().getDefaultHeaderStyle().setBorder(Border.THIN());
- dynamicReport.getOptions().getDefaultHeaderStyle().setHorizontalAlign(HorizontalAlign.CENTER );
- dynamicReport.getOptions().getDefaultDetailStyle().setBorder(Border.THIN());
- dynamicReport.getOptions().getDefaultDetailStyle().setBackgroundColor( Color.WHITE );
- dynamicReport.getOptions().getDefaultDetailStyle().setHorizontalAlign(HorizontalAlign.CENTER );
- dynamicReport.getOptions().getDefaultDetailStyle().setVerticalAlign( VerticalAlign.MIDDLE );
+ dynamicReport.getOptions().getDefaultHeaderStyle().setBorder( Border.THIN() );
+ dynamicReport.getOptions().getDefaultHeaderStyle().setHorizontalAlign( HorizontalAlign.CENTER );
+ dynamicReport.getOptions().getDefaultDetailStyle().setBorder( Border.THIN() );
+ dynamicReport.getOptions().getDefaultDetailStyle().setHorizontalAlign( HorizontalAlign.CENTER );
+ dynamicReport.getOptions().getDefaultDetailStyle().setVerticalAlign( VerticalAlign.MIDDLE );
jr = DynamicJasperHelper.generateJasperReport( dynamicReport, new ClassicLayoutManager(), hash );
jasperPrint = JasperFillManager.fillReport( jr, hash, ds );
-
+
}
-
+
ServletOutputStream ouputStream = response.getOutputStream();
JRExporter exporter = null;
if ( "pdf".equalsIgnoreCase( type ) )
- {
+ {
response.setContentType( "application/pdf" );
response.setHeader( "Content-Disposition", "inline; fileName=\"file.pdf\"" );
@@ -898,6 +1267,7 @@
}
return SUCCESS;
}
+
private String getOrgunitBranch( OrganisationUnit orgunit )
{
String hierarchyOrgunit = orgunit.getName();
@@ -911,6 +1281,5 @@
return hierarchyOrgunit;
}
-
-
+
}
=== modified file 'local/in/dhis-web-coldchain/src/main/resources/struts.xml'
--- local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-08-03 11:10:18 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-08-17 10:21:10 +0000
@@ -582,7 +582,7 @@
<action name="jrxmlReportsPage" class="org.hisp.dhis.coldchain.reports.action.CCEMReportPageAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-coldchain/jrxmlReportsPage.vm</param>
- <param name="menu">/dhis-web-coldchain/menu.vm</param>
+ <param name="menu">/dhis-web-coldchain/ccemReportMenu.vm</param>
<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/ccemReports.js</param>
<interceptor-ref name="organisationUnitTreeStack" />
</action>
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm 2012-07-24 05:31:29 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm 2012-08-17 10:21:10 +0000
@@ -1,7 +1,10 @@
+<script src="javascript/highcharts.js"></script>
+<script src="javascript/exporting.js"></script>
+<!--
<script>
leftBar.hideAnimated();
</script>
-
+-->
<h3>$i18n.getString( "ccem_reports_page" )</h3>
<form id="ccemReportForm" name="ccemReportForm" >
@@ -10,12 +13,12 @@
#end
<table boarder="1">
<tr>
- <td>
+ <!--<td>
<table style="border-collapse: collapse;border-style: solid;border-width: 1px;">
<tr style="background-color: #C0C0C0;"><td><strong>$i18n.getString( "orgunit_tree" )</strong></td></tr>
<tr><td><div style="height:450px;width:200px;overflow:auto;">#parse( "/dhis-web-commons/ouwt/orgunittree.vm" )</div></td></tr>
</table>
- </td>
+ </td>-->
<td>
<table style="border-collapse: collapse;border-style: solid;border-width: 1px;">
<tr style="background-color: #C0C0C0;"><td><strong>$i18n.getString( "ccem_reports_list" )</strong></td></tr>
@@ -89,11 +92,11 @@
</table>
</td>
<td>
- <table style="border-collapse: collapse;border-style: solid;border-width: 1px;">
+ <!-- <table style="border-collapse: collapse;border-style: solid;border-width: 1px;">
<tr><td><div>#parse( "/dhis-web-commons/loader/loader.vm" )</div>
<div id="resultContent"> </div></td>
</tr>
- </table>
+ </table> -->
</td>
</tr>
</table>