dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27442
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13673: CCEI: AggregationEngine
------------------------------------------------------------
revno: 13673
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-01-09 12:43:23 +0000
message:
CCEI: AggregationEngine
modified:
local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/aggregation/CCEIAggregationService.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportManager.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/lookup/Lookup.java
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultCCEIAggregationService.java
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEIReportAction.java
local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/RunAggregationQueryAction.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/aggregation/CCEIAggregationService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/aggregation/CCEIAggregationService.java 2014-01-06 06:13:15 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/aggregation/CCEIAggregationService.java 2014-01-09 12:43:23 +0000
@@ -12,8 +12,6 @@
{
String ID = CCEIAggregationService.class.getName();
- String getQueryTemplate( String lookupName, Map<String,String> params );
-
String getQueryForRefrigeratorWorkingStatus( Integer equipmentTypeId, Integer modelTypeAttributeId, String modelName, String workingStatus );
String getQueryForRefrigeratorUtilization( Integer equipmentTypeId, Integer modelTypeAttributeId, String modelName, String utilization );
=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportManager.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportManager.java 2013-12-23 12:24:45 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportManager.java 2014-01-09 12:43:23 +0000
@@ -43,6 +43,8 @@
String getMinMaxAvgValues(String orgunitid, String periodid , Integer dataElementid, Integer optionCombo);
+ String getMinMaxAvgValuesForLiveBirths( String orgunitid, String periodid, Integer dataElementid, Integer optionCombo, Double liveBirthsPerThousand );
+
Integer getGrandTotalValue(String orgunitid, String periodid , Integer dataElementid);
Map<String,Integer> getCatalogDatavalueId( String orgUnitIdsByComma, Integer inventoryTypeId, Integer catalogTypeAttributeId );
=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/lookup/Lookup.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/lookup/Lookup.java 2014-01-06 06:13:15 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/lookup/Lookup.java 2014-01-09 12:43:23 +0000
@@ -16,6 +16,7 @@
public static final String CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_MODEL = "REF WORKING STATUS BY MODEL";
public static final String CCEI_AGG_TYPE_REF_UTILIZATION = "REF UTILIZATION";
public static final String CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_TYPE = "REF WORKING STATUS BY TYPE";
+ public static final String CCEI_AGG_TYPE_REF_TEMP_ALARMS = "REF TEMP ALARMS";
public static final String CCEI_WORKING_STATUS_OPTIONSET = "WORKING_STATUS_OPTIONSET";
@@ -99,6 +100,4 @@
this.value = value;
}
-
-
}
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultCCEIAggregationService.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultCCEIAggregationService.java 2014-01-06 06:13:15 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultCCEIAggregationService.java 2014-01-09 12:43:23 +0000
@@ -110,33 +110,12 @@
" modelattributevalue.value = " + modelName + " AND " +
" modelattributevalue.modeltypeattributeid = " + modelTypeAttributeId +" AND " +
" equipment.organisationunitid IN ( " + Lookup.ORGUNITID_BY_COMMA + " ) AND " +
- " equipmentattributevalue.value IN ( " + utilization + " )" +
+ " equipmentattributevalue.value IN ( " + utilization + " ) AND " +
+ " equipment.registrationdate <= '" + Lookup.CURRENT_PERIOD_ENDDATE +"'" +
" GROUP BY equipment.organisationunitid";
return query;
}
- @Override
- public String getQueryTemplate( String lookupName, Map<String, String> params )
- {
- String tempQuery = null;
-
- if ( lookupName.equalsIgnoreCase( Lookup.WS_REF_TYPE ) )
- {
- String equipmenttypeid = params.get( "equipmenttypeid" );
- String modelName = params.get( "modelName" );
- String equipmentattributevalue = params.get( "equipmentattributevalue" );
- tempQuery = "SELECT COUNT(*) FROM modelattributevalue "
- + "INNER JOIN equipment ON modelattributevalue.modelid = equipment.modelid "
- + "INNER JOIN equipmentattributevalue ON equipmentattributevalue.equipmentid = equipment.equipmentid"
- + " WHERE " + " equipment.equipmenttypeid = " + equipmenttypeid + " AND "
- + " modelattributevalue.value = " + modelName + " AND " + " equipment.organisationunitid IN ( ? ) AND "
- + " equipmentattributevalue.value IN ( " + equipmentattributevalue + " )"
- + " GROUP BY modelattributevalue.value";
- }
-
- return tempQuery;
- }
-
public Map<String, Integer> calculateRefrigeratorWorkingStatus( Period period, DataElement dataElement, Set<OrganisationUnit> orgUnits, String query )
{
Map<String, Integer> aggregationResultMap = new HashMap<String, Integer>();
@@ -174,6 +153,8 @@
{
Map<String, Integer> aggregationResultMap = new HashMap<String, Integer>();
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
try
{
Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, orgUnits ) );
@@ -181,6 +162,8 @@
query = query.replace( "ORGUNITID_BY_COMMA", orgUnitIdsByComma );
+ query = query.replace( Lookup.CURRENT_PERIOD_ENDDATE, simpleDateFormat.format( period.getEndDate() ) );
+
SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
while ( rs.next() )
{
@@ -309,13 +292,12 @@
{
vsReqLiveBirthData = Double.parseDouble( tempStr );
constant = constantService.getConstantByName( "LiveBirthsPerThousand" );
- Double liveBirthPerThousand = 39.98;
+ Double liveBirthPerThousand = 40.0;
if( constant != null )
{
liveBirthPerThousand = constant.getValue();
}
- vsReqLiveBirthData = ( vsReqLiveBirthData * liveBirthPerThousand ) / 1000;
-
+ vsReqLiveBirthData = ( vsReqLiveBirthData * liveBirthPerThousand ) / 1000;
}
catch ( Exception e )
{
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java 2014-01-06 06:13:15 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java 2014-01-09 12:43:23 +0000
@@ -335,7 +335,7 @@
+ " GROUP BY equipment.organisationunitid";
}
- //System.out.println("CatalogDataSumByEquipmentData : " + query );
+ System.out.println("CatalogDataSumByEquipmentData : " + query );
SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
while ( rs.next() )
@@ -932,6 +932,49 @@
return dataValue;
}
+ public String getMinMaxAvgValuesForLiveBirths( String orgunitid, String periodid, Integer dataElementid, Integer optionCombo, Double liveBirthsPerThousand )
+ {
+ String dataValue = null;
+
+ DatabaseInfo dataBaseInfo = databaseInfoProvider.getDatabaseInfo();
+
+ try
+ {
+ String query = "";
+
+ if ( dataBaseInfo.getType().equalsIgnoreCase( "postgresql" ) )
+ {
+ query = "SELECT ROUND(Min( (CAST(value AS NUMERIC) * "+liveBirthsPerThousand+" ))), ROUND(Max( (CAST(value AS NUMERIC) * "+liveBirthsPerThousand+" ))), ROUND(AVG( ( CAST(value AS NUMERIC) * "+liveBirthsPerThousand+" ) )) FROM datavalue " +
+ " WHERE " +
+ " sourceid IN (" + orgunitid + ") AND " +
+ " dataelementid = " + dataElementid + " AND " +
+ " periodid IN ( " + periodid + ") AND " +
+ " categoryoptioncomboid = " + optionCombo;
+ }
+ else if ( dataBaseInfo.getType().equalsIgnoreCase( "mysql" ) )
+ {
+ query = "SELECT ROUND(Min( (CAST(value AS UNSIGNED) * "+liveBirthsPerThousand+" ) )), ROUND(Max( (CAST(value AS UNSIGNED) * "+liveBirthsPerThousand+" ) )), ROUND(AVG( (CAST(value AS UNSIGNED) * "+liveBirthsPerThousand+" ) )) FROM datavalue " +
+ " WHERE " +
+ " sourceid IN (" + orgunitid + ") AND " +
+ " dataelementid = " + dataElementid + " AND " +
+ " periodid IN ( " + periodid + ") AND " +
+ " categoryoptioncomboid = " + optionCombo;
+ }
+
+ SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+ while ( rs.next() )
+ {
+ dataValue = rs.getInt( 1 ) + "," + rs.getInt( 2 ) + "," + rs.getInt( 3 );
+ // System.out.println("Minimum and Maximum and Average Value is: "+dataValue);
+ }
+ }
+ catch ( Exception e )
+ {
+ throw new RuntimeException( "Exception: ", e );
+ }
+ return dataValue;
+ }
+
public Integer getCountByOrgUnitGroup( Integer rootOrgUnitId, Integer orgUnitGroupId )
{
Integer orgUnitCount = 0;
=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEIReportAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEIReportAction.java 2014-01-06 06:13:15 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEIReportAction.java 2014-01-09 12:43:23 +0000
@@ -587,10 +587,19 @@
try
{
+ Constant constant = constantService.getConstantByName( "LiveBirthsPerThousand" );
+ Double liveBirthPerThousand = 40.0;
+ if( constant != null )
+ {
+ liveBirthPerThousand = constant.getValue();
+ }
+
+ liveBirthPerThousand /= 1000;
+
for ( Integer orgUnitId : selOrgUnitList )
{
- OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
- List<OrganisationUnit> orgUnitChildren = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( orgUnitId ) );
+ OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+ List<OrganisationUnit> orgUnitChildren = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( orgUnitId ) );
for ( Integer orgUnitGroupId : orgunitGroupList )
{
@@ -598,28 +607,31 @@
OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
List<OrganisationUnit> orgUnitGroupMembers = new ArrayList<OrganisationUnit>( orgUnitGroup.getMembers() );
orgUnitGroupMembers.retainAll( orgUnitChildren );
+
+
if( orgUnitGroupMembers != null && orgUnitGroupMembers.size() > 0 )
{
Collection<Integer> orgUnitGroupMemberIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, orgUnitGroupMembers ) );
String orgUnitidsByComma = getCommaDelimitedString( orgUnitGroupMemberIds );
- String minMaxandAvgValue = ccemReportManager.getMinMaxAvgValues( orgUnitidsByComma, periodIdsByComma, dataElementId, optionComboId );
+ //String minMaxandAvgValue = ccemReportManager.getMinMaxAvgValues( orgUnitidsByComma, periodIdsByComma, dataElementId, optionComboId );
+ String minMaxandAvgValue = ccemReportManager.getMinMaxAvgValuesForLiveBirths( orgUnitidsByComma, periodIdsByComma, dataElementId, optionComboId, liveBirthPerThousand );
- numberOfData.put( "Admin Area", orgUnit.getName() );
- numberOfData.put( "Facility Type", orgUnitGroup.getName() );
- numberOfData.put( "No. Facilities", orgUnitGroupMembers.size() + "" );
- numberOfData.put( "Minimum", minMaxandAvgValue.split( "," )[0] );
- numberOfData.put( "Maximum", minMaxandAvgValue.split( "," )[1] );
- numberOfData.put( "Mean", minMaxandAvgValue.split( "," )[2] );
- tableData.add( numberOfData );
+ numberOfData.put( "Admin Area", orgUnit.getName() );
+ numberOfData.put( "Facility Type", orgUnitGroup.getName() );
+ numberOfData.put( "No. Facilities", orgUnitGroupMembers.size() + "" );
+ numberOfData.put( "Minimum", minMaxandAvgValue.split( "," )[0] );
+ numberOfData.put( "Maximum", minMaxandAvgValue.split( "," )[1] );
+ numberOfData.put( "Mean", minMaxandAvgValue.split( "," )[2] );
+ tableData.add( numberOfData );
}
}
}
}
catch ( Exception e )
{
- System.out.print( "Exception : " + e );
+ e.printStackTrace();
}
frb.setHeaderHeight( 35 );
@@ -2234,9 +2246,7 @@
Integer vsrActualEquipmentTypeAttributeidId = Integer.parseInt( partsOfVSRActualCellContent[2] );
String vsrActualEquipmentValue = partsOfVSRActualCellContent[3];
- Map<Integer, Double> catalogSumByEquipmentDataMap = new HashMap<Integer, Double>( ccemReportManager
- .getCatalogDataSumByEquipmentData( orgUnitIdsByComma, vsrActualEquipmentTypeidId,
- vsrActualModelTypeAttributeidId, vsrActualEquipmentTypeAttributeidId, vsrActualEquipmentValue ) );
+ Map<Integer, Double> catalogSumByEquipmentDataMap = new HashMap<Integer, Double>( ccemReportManager.getCatalogDataSumByEquipmentData( orgUnitIdsByComma, vsrActualEquipmentTypeidId, vsrActualModelTypeAttributeidId, vsrActualEquipmentTypeAttributeidId, vsrActualEquipmentValue ) );
// Calculations for Required Column
ccemReportDesign1 = reportDesignList.get( 2 );
@@ -2323,6 +2333,13 @@
try
{
vsReqLiveBirthData = Double.parseDouble( tempStr );
+ constant = constantService.getConstantByName( "LiveBirthsPerThousand" );
+ Double liveBirthPerThousand = 40.0;
+ if( constant != null )
+ {
+ liveBirthPerThousand = constant.getValue();
+ }
+ vsReqLiveBirthData = ( vsReqLiveBirthData * liveBirthPerThousand ) / 1000;
}
catch ( Exception e )
{
@@ -2362,7 +2379,7 @@
// Formula for calculating Requirement
try
{
- vaccineRequirement = vsReqLiveBirthData * vsReqVaccineVolumePerChildData * ( (vsReqSupplyIntervalData + vsReqReserveStockData) / 52);
+ vaccineRequirement = vsReqLiveBirthData * vsReqVaccineVolumePerChildData * ( (vsReqSupplyIntervalData + vsReqReserveStockData) / 52);
}
catch ( Exception e )
{
=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/RunAggregationQueryAction.java'
--- local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/RunAggregationQueryAction.java 2014-01-06 06:13:15 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/RunAggregationQueryAction.java 2014-01-09 12:43:23 +0000
@@ -124,12 +124,6 @@
{
DataElement dataElement = condition.getAggregationDataElement();
- if ( condition.getOperator().equals( Lookup.CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_MODEL ) || condition.getOperator().equals( Lookup.CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_TYPE ) )
- {
- aggregationResultMap.putAll( cceiAggregationService.calculateRefrigeratorWorkingStatus( period, dataElement, orgUnitList, condition.getAggregationExpression() ) );
- }
-
- /*
if ( condition.getOperator().equals( Lookup.CCEI_AGG_TYPE_STORAGE_CAPACITY ) )
{
aggregationResultMap.putAll( cceiAggregationService.calculateStorageCapacityData( period, dataElement, orgUnitList, orgUnitGroups ) );
@@ -142,7 +136,6 @@
{
aggregationResultMap.putAll( cceiAggregationService.calculateRefrigeratorUtilization( period, dataElement, orgUnitList, condition.getAggregationExpression() ) );
}
- */
dataElements.add( dataElement );
}