dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30295
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15379: RBF work in progress: QualityBasedPayment
------------------------------------------------------------
revno: 15379
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-05-23 15:33:01 +0100
message:
RBF work in progress: QualityBasedPayment
modified:
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultPBFAggregationService.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/LoadQualityScoreDetailsAction.java
local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadQualityScoreEntryForm.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-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultPBFAggregationService.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultPBFAggregationService.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultPBFAggregationService.java 2014-05-23 14:33:01 +0000
@@ -15,6 +15,7 @@
import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -204,6 +205,33 @@
return aggregationResultMap;
}
+ public Double calculateOverallUnadjustedPBFAmount( Period period, OrganisationUnit orgUnit, DataSet dataSet )
+ {
+ Double overAllAdjustedAmt = null;
+
+ try
+ {
+ String query = "SELECT SUM( ( qtyvalidated * tariffamount ) ) FROM pbfdatavalue " +
+ " WHERE " +
+ " periodid = "+ period.getId() +" AND "+
+ " datasetid = "+ dataSet.getId() + " AND " +
+ " organisationunitid = " + orgUnit.getId();
+
+ System.out.println( "Query After Replace : --" + query );
+
+ SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+ if( rs.next() )
+ {
+ overAllAdjustedAmt = rs.getDouble( 1 );
+ }
+ }
+ catch( Exception e )
+ {
+ System.out.println("Exception in calculateOverallUnadjustedPBFAmount :"+ e.getMessage() );
+ }
+
+ return overAllAdjustedAmt;
+ }
public Double calculateOverallQualityScore( Period period, Set<OrganisationUnit> orgUnits, Integer dataSetId, int maxScoreOrgUnitId )
{
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/LoadQualityScoreDetailsAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/LoadQualityScoreDetailsAction.java 2014-05-15 06:51:53 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/LoadQualityScoreDetailsAction.java 2014-05-23 14:33:01 +0000
@@ -22,10 +22,16 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.rbf.api.Lookup;
import org.hisp.dhis.rbf.api.LookupService;
import org.hisp.dhis.rbf.api.QualityMaxValue;
import org.hisp.dhis.rbf.api.QualityMaxValueService;
+import org.hisp.dhis.rbf.api.QualityScorePayment;
+import org.hisp.dhis.rbf.api.QualityScorePaymentService;
+import org.hisp.dhis.rbf.impl.DefaultPBFAggregationService;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -89,6 +95,15 @@
this.categoryService = categoryService;
}
+ @Autowired
+ private DefaultPBFAggregationService defaultPBFAggregationService;
+
+ @Autowired
+ private PeriodService periodService;
+
+ @Autowired
+ private QualityScorePaymentService qualityScorePaymentService;
+
// -------------------------------------------------------------------------
// Input / Output
// -------------------------------------------------------------------------
@@ -142,6 +157,27 @@
return dataValueMap;
}
+ private String paymentMessage = "No Data avialable for ";
+
+ public String getPaymentMessage()
+ {
+ return paymentMessage;
+ }
+
+ private Double totalUnadjustedAmt = 0.0;
+
+ public Double getTotalUnadjustedAmt()
+ {
+ return totalUnadjustedAmt;
+ }
+
+ private Set<QualityScorePayment> qualityScorePayments;
+
+ public Set<QualityScorePayment> getQualityScorePayments()
+ {
+ return qualityScorePayments;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -162,8 +198,8 @@
else
{
tariff_setting_authority = (int) tariff_authority.getValue();
-
}
+
Constant qualityMaxDataElement = constantService.getConstantByName( QUALITY_MAX_DATAELEMENT );
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) );
@@ -182,15 +218,16 @@
}
}
}
+
for ( DataElement dataElement : dataElements )
{
List<QualityMaxValue> qualityMaxValues = new ArrayList<QualityMaxValue>();
OrganisationUnit parentOrgunit = findParentOrgunitforTariff( organisationUnit, tariff_setting_authority );
if ( parentOrgunit != null )
{
- qualityMaxValues = new ArrayList<QualityMaxValue>( qualityMaxValueService.getQuanlityMaxValues(
- parentOrgunit, dataElement ) );
+ qualityMaxValues = new ArrayList<QualityMaxValue>( qualityMaxValueService.getQuanlityMaxValues( parentOrgunit, dataElement ) );
}
+
DataValue dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit, optionCombo );
for ( QualityMaxValue qualityMaxValue : qualityMaxValues )
{
@@ -209,7 +246,46 @@
}
}
}
+
Collections.sort( dataElements );
+
+ List<Lookup> lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.DS_PAYMENT_TYPE ) );
+ DataSet paymentDataSet = null;
+ for ( Lookup lookup : lookups )
+ {
+ String[] lookupType = lookup.getValue().split( ":" );
+ System.out.println( lookup.getValue() +" " + Integer.parseInt( lookupType[0] ) + " " + Integer.parseInt( dataSetId ) );
+ if ( Integer.parseInt( lookupType[1] ) == Integer.parseInt( dataSetId ) )
+ {
+ paymentDataSet = dataSetService.getDataSet( Integer.parseInt( lookupType[0] ) );
+ break;
+ }
+ }
+
+ int flag = 1;
+ Set<Period> periods = new HashSet<Period>( periodService.getIntersectingPeriodsByPeriodType( paymentDataSet.getPeriodType(), period.getStartDate(), period.getEndDate() ) );
+ for( Period period1 : periods )
+ {
+ Double overAllAdjustedAmt = defaultPBFAggregationService.calculateOverallUnadjustedPBFAmount( period1, organisationUnit, paymentDataSet );
+
+ if( overAllAdjustedAmt == null || overAllAdjustedAmt == 0 )
+ {
+ paymentMessage += period1.getStartDateString() +", ";
+ flag = 2;
+ }
+ else
+ {
+ totalUnadjustedAmt += overAllAdjustedAmt;
+ }
+ }
+
+ if( flag == 1 )
+ {
+ paymentMessage = "Data available for this quarter";
+ }
+
+ qualityScorePayments = new HashSet<QualityScorePayment>( qualityScorePaymentService.getAllQualityScorePayments() );
+
return SUCCESS;
}
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadQualityScoreEntryForm.vm'
--- local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadQualityScoreEntryForm.vm 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadQualityScoreEntryForm.vm 2014-05-23 14:33:01 +0000
@@ -80,15 +80,30 @@
allTotal = (allScore / allMax ) * 100;
}
- $('#all-total').val(allTotal.toFixed(2));
+ $('#all-total').val(allTotal.toFixed(2));
+
+ for( var qualityScoreRange in qualityScorePayments )
+ {
+ var startRange = parseFloat( qualityScoreRange.split("-")[0] );
+
+ var endRange = parseFloat( qualityScoreRange.split("-")[1] );
+
+ alert( qualityScoreRange );
+
+ if( allTotal >= startRange && allTotal <= endRange )
+ {
+ $("#qualityOverHeadPayment").val() = qualityScorePayments[ qualityScoreRange ];
+ }
+ }
}
+
changeInt();
</script>
<td>
<input type="text" class="max" name="max_$dataElement.id" id="max_$dataElement.id" value="$!qualityMaxValue.value" tabindex="$tabIndex" style="text-align: center;" readonly/>
</td>
<td >
- <input type="text" id="percentage_$dataElement.id" style="text-align: center;" readonly/>
+ <input type="text" id="percentage_$dataElement.id" style="text-align: center;" readonly />
</td>
</tr>
@@ -100,8 +115,30 @@
<input type="text" id="all-total" style="text-align: center;" readonly size="18"/>%
</td>
</tr>
+
+ <tr>
+ <td colspan="3" style="text-align: right;">Quality overhead payment</td>
+ <td >
+ <input type="text" id="qualityOverHeadPayment" style="text-align: center;" readonly size="18"/>%
+ </td>
+ </tr>
+
+ <tr>
+ <td colspan="3" style="text-align: right;">$paymentMessage -- Total PPS payment for this quarter</td>
+ <td >
+ <input type="text" id="ppsPayment" style="text-align: center;" value="$totalUnadjustedAmt" readonly size="18"/>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" style="text-align: right;">Total quality based payment for this quarter</td>
+ <td >
+ <input type="text" id="all-total" style="text-align: center;" readonly size="18"/>
+ </td>
+ </tr>
</table>
+
<script >
+
function calPercenVal( dataElementId )
{
var percentage = 0.0;
@@ -119,11 +156,34 @@
score = score + parseFloat($("#score_"+$dataElement.id).val());
}
#end
- if(allMax != 0.0)
+
+ if( allMax != 0.0 )
{
- allTotal = (score / allMax ) * 100;
+ allTotal = ( score / allMax ) * 100;
}
$('#all-total').val(allTotal.toFixed(2));
- }
+
+ for( var qualityScoreRange in qualityScorePayments )
+ {
+ var startRange = parseFloat( qualityScoreRange.split("-")[0] );
+
+ var endRange = parseFloat( qualityScoreRange.split("-")[1] );
+
+ alert( qualityScoreRange );
+
+ if( allTotal >= startRange && allTotal <= endRange )
+ {
+ $("#qualityOverHeadPayment").val() = qualityScorePayments[ qualityScoreRange ];
+ }
+ }
+
+ }
+
+ var qualityScorePayments = new Array();
+
+ #foreach( $qualityScorePayment in $qualityScorePayments)
+ qualityScorePayments['$qualityScorePayment.startRange-$qualityScorePayment.endRange'] = $qualityScorePayment.addQtyPayment;
+ #end
+
</script>