dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30517
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15486: RBF: QualityPaymentScore calculation
------------------------------------------------------------
revno: 15486
committer: Bharath chbharathk@xxxxxxxxx
branch nick: dhis2
timestamp: Sat 2014-05-31 14:40:53 +0100
message:
RBF: QualityPaymentScore calculation
modified:
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValue.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValueService.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValueStore.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueService.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueStore.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java
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/DefaultQualityMaxValueService.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultTariffDataValueService.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateQualityMaxValueStore.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateTariffDataValueStore.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/GetOrganisationUnitForMaxAction.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/LoadQualityMaxDetailsAction.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/java/org/hisp/dhis/rbf/quality/dataentry/QualityMaxInitAction.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/SaveDataValueAction.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/SaveQualityValueAction.java
local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/ValidateQualityMaxDataAction.java
local/in/dhis-web-maintenance-rbf/src/main/resources/org/hisp/dhis/rbf/hibernate/QuantityMaxValue.hbm.xml
local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml
local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/javascript/qualityMaxDataEntry.js
local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadQualityMaxEntryForm.vm
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/menu.vm
local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/qualityMaxEntrySelection.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/api/QualityMaxValue.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValue.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValue.java 2014-05-31 13:40:53 +0000
@@ -6,11 +6,14 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
public class QualityMaxValue implements Serializable
{
private static final long serialVersionUID = 1L;
+ private OrganisationUnitGroup orgUnitGroup;
+
private OrganisationUnit organisationUnit;
private DataElement dataElement;
@@ -45,7 +48,17 @@
this.endDate = endDate;
this.value = value;
}
-
+
+ public QualityMaxValue( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet, Date startDate, Date endDate, Double value)
+ {
+ this.organisationUnit = organisationUnit;
+ this.dataElement = dataElement;
+ this.dataSet = dataSet;
+ this.startDate = startDate;
+ this.endDate = endDate;
+ this.value = value;
+ }
+
// -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
@@ -70,7 +83,7 @@
final QualityMaxValue other = (QualityMaxValue) o;
- return dataElement.equals( other.getDataElement() ) && dataSet.equals( other.getDataSet() ) && organisationUnit.equals( other.getOrganisationUnit() );
+ return dataElement.equals( other.getDataElement() ) && dataSet.equals( other.getDataSet() ) && organisationUnit.equals( other.getOrganisationUnit() ) && orgUnitGroup.equals( other.getOrgUnitGroup() );
}
@Override
@@ -81,6 +94,7 @@
result = result * prime + dataSet.hashCode();
result = result * prime + dataElement.hashCode();
+ result = result * prime + orgUnitGroup.hashCode();
result = result * prime + organisationUnit.hashCode();
return result;
@@ -179,5 +193,15 @@
{
this.dataSet = dataSet;
}
+
+ public OrganisationUnitGroup getOrgUnitGroup()
+ {
+ return orgUnitGroup;
+ }
+
+ public void setOrgUnitGroup( OrganisationUnitGroup orgUnitGroup )
+ {
+ this.orgUnitGroup = orgUnitGroup;
+ }
}
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValueService.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValueService.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValueService.java 2014-05-31 13:40:53 +0000
@@ -2,10 +2,13 @@
import java.util.Collection;
import java.util.Date;
+import java.util.Map;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.period.Period;
public interface QualityMaxValueService
@@ -25,4 +28,12 @@
Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnit organisationUnit, DataElement dataElement );
QualityMaxValue getQualityMaxValue( OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet,Date startDate ,Date endDate );
+
+ QualityMaxValue getQualityMaxValue( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet,Date startDate ,Date endDate);
+
+ Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement);
+
+ Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataSet dataSet);
+
+ Map<Integer, Double> getQualityMaxValues( OrganisationUnitGroup orgUnitGroup, String orgUnitBranchIds, DataSet dataSet, Period period );
}
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValueStore.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValueStore.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/QualityMaxValueStore.java 2014-05-31 13:40:53 +0000
@@ -2,10 +2,13 @@
import java.util.Collection;
import java.util.Date;
+import java.util.Map;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.period.Period;
public interface QualityMaxValueStore
@@ -25,4 +28,13 @@
Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnit organisationUnit, DataElement dataElement );
QualityMaxValue getQualityMaxValue( OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet, Date startDate ,Date endDate);
+
+ QualityMaxValue getQualityMaxValue( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet,Date startDate ,Date endDate);
+
+ Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement);
+
+ Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataSet dataSet);
+
+ Map<Integer, Double> getQualityMaxValues( OrganisationUnitGroup orgUnitGroup, String orgUnitBranchIds, DataSet dataSet, Period period );
+
}
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueService.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueService.java 2014-05-08 11:03:37 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueService.java 2014-05-31 13:40:53 +0000
@@ -47,7 +47,7 @@
Collection<TariffDataValue> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement );
- Map<Integer, Double> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataSet dataSet, Period period );
+ Map<Integer, Double> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, String orgUnitBranchIds, DataSet dataSet, Period period );
String getTariffDataValue( Integer orgunitgroupId, Integer organisationUnitId, Integer dataSetId, Integer dataElementId, String date );
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueStore.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueStore.java 2014-05-08 11:03:37 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueStore.java 2014-05-31 13:40:53 +0000
@@ -46,7 +46,7 @@
Collection<TariffDataValue> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement );
- Map<Integer, Double> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataSet dataSet, Period period );
+ Map<Integer, Double> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, String orgUnitBranchIds, DataSet dataSet, Period period );
String getTariffDataValue( Integer orgunitgroupId, Integer organisationUnitId, Integer dataSetId, Integer dataElementId, String date );
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java 2014-05-08 11:03:37 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java 2014-05-31 13:40:53 +0000
@@ -261,9 +261,16 @@
OrganisationUnitGroup orgUnitGroup = findPBFOrgUnitGroupforTariff( organisationUnit );
+ List<OrganisationUnit> orgUnitBranch = organisationUnitService.getOrganisationUnitBranch( organisationUnit.getId() );
+ String orgUnitBranchIds = "-1";
+ for( OrganisationUnit orgUnit : orgUnitBranch )
+ {
+ orgUnitBranchIds += "," + orgUnit.getId();
+ }
+
if( orgUnitGroup != null )
{
- tariffDataValueMap.putAll( tariffDataValueService.getTariffDataValues( orgUnitGroup, dataSet, period ) );
+ tariffDataValueMap.putAll( tariffDataValueService.getTariffDataValues( orgUnitGroup, orgUnitBranchIds, dataSet, period ) );
}
/*
=== 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-05-23 14:33:01 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultPBFAggregationService.java 2014-05-31 13:40:53 +0000
@@ -217,8 +217,6 @@
" datasetid = "+ dataSet.getId() + " AND " +
" organisationunitid = " + orgUnit.getId();
- System.out.println( "Query After Replace : --" + query );
-
SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
if( rs.next() )
{
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultQualityMaxValueService.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultQualityMaxValueService.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultQualityMaxValueService.java 2014-05-31 13:40:53 +0000
@@ -2,10 +2,13 @@
import java.util.Collection;
import java.util.Date;
+import java.util.Map;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.period.Period;
import org.hisp.dhis.rbf.api.QualityMaxValue;
import org.hisp.dhis.rbf.api.QualityMaxValueService;
import org.hisp.dhis.rbf.api.QualityMaxValueStore;
@@ -76,8 +79,26 @@
@Override
public Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnit organisationUnit, DataElement dataElement )
{
-
return qualityMaxValueStore.getQuanlityMaxValues( organisationUnit, dataElement );
}
+ public Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement)
+ {
+ return qualityMaxValueStore.getQuanlityMaxValues( orgUnitGroup, organisationUnit, dataElement);
+ }
+
+ public QualityMaxValue getQualityMaxValue( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet,Date startDate ,Date endDate )
+ {
+ return qualityMaxValueStore.getQualityMaxValue( orgUnitGroup, organisationUnit, dataElement, dataSet, startDate, endDate );
+ }
+
+ public Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataSet dataSet)
+ {
+ return qualityMaxValueStore.getQuanlityMaxValues( orgUnitGroup, organisationUnit, dataSet );
+ }
+
+ public Map<Integer, Double> getQualityMaxValues( OrganisationUnitGroup orgUnitGroup, String orgUnitBranchIds, DataSet dataSet, Period period )
+ {
+ return qualityMaxValueStore.getQualityMaxValues( orgUnitGroup, orgUnitBranchIds, dataSet, period );
+ }
}
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultTariffDataValueService.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultTariffDataValueService.java 2014-05-08 11:03:37 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultTariffDataValueService.java 2014-05-31 13:40:53 +0000
@@ -122,9 +122,9 @@
return tariffDataValueStore.getTariffDataValues( orgUnitGroup, organisationUnit, dataElement );
}
- public Map<Integer, Double> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataSet dataSet, Period period )
+ public Map<Integer, Double> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, String orgUnitBranchIds, DataSet dataSet, Period period )
{
- return tariffDataValueStore.getTariffDataValues( orgUnitGroup, organisationUnit, dataSet, period );
+ return tariffDataValueStore.getTariffDataValues( orgUnitGroup, orgUnitBranchIds, dataSet, period );
}
public String getTariffDataValue( Integer orgunitgroupId, Integer organisationUnitId, Integer dataSetId, Integer dataElementId, String date )
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateQualityMaxValueStore.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateQualityMaxValueStore.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateQualityMaxValueStore.java 2014-05-31 13:40:53 +0000
@@ -1,7 +1,10 @@
package org.hisp.dhis.rbf.impl;
+import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
import org.hibernate.Criteria;
import org.hibernate.Session;
@@ -10,9 +13,12 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.period.Period;
import org.hisp.dhis.rbf.api.QualityMaxValue;
import org.hisp.dhis.rbf.api.QualityMaxValueStore;
import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
public class HibernateQualityMaxValueStore implements QualityMaxValueStore
{
@@ -71,18 +77,32 @@
@SuppressWarnings("unchecked")
@Override
- public Collection<QualityMaxValue> getQuanlityMaxValues(
- OrganisationUnit organisationUnit, DataSet dataSet) {
-
- Session session = sessionFactory.getCurrentSession();
-
- Criteria criteria = session.createCriteria( QualityMaxValue.class );
- criteria.add( Restrictions.eq( "organisationUnit", organisationUnit ) );
- criteria.add( Restrictions.eq( "dataSet", dataSet ) );
-
- return criteria.list();
- }
-
+ public Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnit organisationUnit, DataSet dataSet)
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( QualityMaxValue.class );
+ criteria.add( Restrictions.eq( "organisationUnit", organisationUnit ) );
+ criteria.add( Restrictions.eq( "dataSet", dataSet ) );
+
+ return criteria.list();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataSet dataSet)
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( QualityMaxValue.class );
+
+ criteria.add( Restrictions.eq( "orgUnitGroup", orgUnitGroup ) );
+ criteria.add( Restrictions.eq( "organisationUnit", organisationUnit ) );
+ criteria.add( Restrictions.eq( "dataSet", dataSet ) );
+
+ return criteria.list();
+ }
+
@Override
public QualityMaxValue getQualityMaxValue(
OrganisationUnit organisationUnit, DataElement dataElement,
@@ -101,6 +121,24 @@
}
@Override
+ public QualityMaxValue getQualityMaxValue( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet,Date startDate ,Date endDate)
+ {
+
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( QualityMaxValue.class );
+
+ criteria.add( Restrictions.eq( "orgUnitGroup", orgUnitGroup ) );
+ criteria.add( Restrictions.eq( "organisationUnit", organisationUnit ) );
+ criteria.add( Restrictions.eq( "dataElement", dataElement ) );
+ criteria.add( Restrictions.eq( "dataSet", dataSet ) );
+ criteria.add( Restrictions.eq( "startDate", startDate ) );
+ criteria.add( Restrictions.eq( "endDate", endDate ) );
+
+ return (QualityMaxValue) criteria.uniqueResult();
+ }
+
+ @Override
public Collection<QualityMaxValue> getQuanlityMaxValues(
OrganisationUnit organisationUnit, DataElement dataElement) {
@@ -113,6 +151,65 @@
return criteria.list();
}
+ @Override
+ public Collection<QualityMaxValue> getQuanlityMaxValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataElement dataElement)
+ {
+
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( QualityMaxValue.class );
+
+ criteria.add( Restrictions.eq( "orgUnitGroup", orgUnitGroup ) );
+ criteria.add( Restrictions.eq( "organisationUnit", organisationUnit ) );
+ criteria.add( Restrictions.eq( "dataElement", dataElement ) );
+
+ return criteria.list();
+ }
+ public Map<Integer, Double> getQualityMaxValues( OrganisationUnitGroup orgUnitGroup, String orgUnitBranchIds, DataSet dataSet, Period period )
+ {
+ Map<Integer, Double> qualityMaxValueMap = new HashMap<Integer, Double>();
+
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ String curPeriod = simpleDateFormat.format( period.getEndDate() );
+
+ try
+ {
+ String query = "select td.dataelementid, td.value from "+
+ "( " +
+ "select max(asd.level) as level,asd.dataelementid,asd.orgunitgroupid,datasetid " +
+ " from " +
+ "( "+
+ " select td.orgunitgroupid,td.organisationunitid,td.datasetid,td.dataelementid,os.level,td.value " +
+ " from qualitymaxvalue td inner join _orgunitstructure os on os.organisationunitid = td.organisationunitid "+
+ " where '" + curPeriod + "' between date(td.startdate) and date(td.enddate) " +
+ " and orgunitgroupid in ( " + orgUnitGroup.getId() + ") " +
+ " and datasetid in ( " +dataSet.getId() + ") "+
+ " )asd "+
+ " group by asd.dataelementid,asd.orgunitgroupid,datasetid " +
+ " )sag1 " +
+ " inner join qualitymaxvalue td on td.dataelementid=sag1.dataelementid " +
+ " where td.orgunitgroupid=sag1.orgunitgroupid " +
+ " and td.datasetid=sag1.datasetid " +
+ " and td.organisationunitid in ("+ orgUnitBranchIds +") ";
+
+ //System.out.println("Query: " + query );
+ SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+ while ( rs.next() )
+ {
+ Integer dataElementId = rs.getInt( 1 );
+ Double value = rs.getDouble( 2 );
+ qualityMaxValueMap.put( dataElementId, value );
+ //System.out.println( dataElementId + " : " + value );
+ }
+ }
+ catch( Exception e )
+ {
+ System.out.println("In getQualityMaxValues Exception :"+ e.getMessage() );
+ }
+
+ return qualityMaxValueMap;
+ }
+
}
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateTariffDataValueStore.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateTariffDataValueStore.java 2014-05-08 11:03:37 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateTariffDataValueStore.java 2014-05-31 13:40:53 +0000
@@ -268,7 +268,7 @@
return tariffDataValueMap;
}
- public Map<Integer, Double> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, OrganisationUnit organisationUnit, DataSet dataSet, Period period )
+ public Map<Integer, Double> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, String orgUnitBranchIds, DataSet dataSet, Period period )
{
Map<Integer, Double> tariffDataValueMap = new HashMap<Integer, Double>();
@@ -286,7 +286,7 @@
" enddate >= '" + curPeriod +"'";
*/
- String query = "select td.value,td.dataelementid from "+
+ String query = "select td.dataelementid,td.value from "+
"( " +
"select max(asd.orgunitlevelid) as level,asd.dataelementid,asd.orgunitgroupid,datasetid " +
" from " +
@@ -303,7 +303,7 @@
" where td.orgunitgroupid=sag1.orgunitgroupid " +
" and td.datasetid=sag1.datasetid " +
" and sag1.level=td.orgunitlevelid " +
- " and td.organisationunitid in ("+ organisationUnit.getId() +") ";
+ " and td.organisationunitid in ("+ orgUnitBranchIds +") ";
//System.out.println("Query: " + query );
SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/GetOrganisationUnitForMaxAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/GetOrganisationUnitForMaxAction.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/GetOrganisationUnitForMaxAction.java 2014-05-31 13:40:53 +0000
@@ -7,9 +7,12 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.rbf.api.Lookup;
import org.hisp.dhis.rbf.api.LookupService;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -40,6 +43,8 @@
this.dataSetService = dataSetService;
}
+ @Autowired
+ private OrganisationUnitGroupService orgUnitGroupService;
// -------------------------------------------------------------------------
// Input/output
@@ -63,7 +68,14 @@
this.orgUnitId = orgUnitId;
}
- private List<DataSet> dataSets = new ArrayList<DataSet>();
+ private String orgUnitGroupId;
+
+ public void setOrgUnitGroupId(String orgUnitGroupId)
+ {
+ this.orgUnitGroupId = orgUnitGroupId;
+ }
+
+ private List<DataSet> dataSets = new ArrayList<DataSet>();
public List<DataSet> getDataSets()
{
@@ -78,6 +90,8 @@
{
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+ OrganisationUnitGroup orgUnitGroup = orgUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( orgUnitGroupId ) );
+
List<Lookup> lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.DS_QUALITY_TYPE ) );
List<DataSet> pbfDataSets = new ArrayList<DataSet>();
@@ -94,16 +108,21 @@
}
}
- dataSets.addAll( pbfDataSets );
+ dataSets.addAll( orgUnitGroup.getDataSets() );
+
+ System.out.println( "Before : " + dataSets.size() );
+
+ dataSets.retainAll( pbfDataSets );
+
Collections.sort(dataSets);
-
- System.out.println( dataSets.size() );
+ System.out.println( "After : " + dataSets.size() );
+
if ( dataSets.size() > 0 )
{
message = organisationUnit.getName();
+
return SUCCESS;
-
}
else
{
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/LoadQualityMaxDetailsAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/LoadQualityMaxDetailsAction.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/LoadQualityMaxDetailsAction.java 2014-05-31 13:40:53 +0000
@@ -17,10 +17,13 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.rbf.api.LookupService;
import org.hisp.dhis.rbf.api.QualityMaxValue;
import org.hisp.dhis.rbf.api.QualityMaxValueService;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -69,6 +72,9 @@
this.constantService = constantService;
}
+ @Autowired
+ private OrganisationUnitGroupService orgUnitGroupService;
+
// -------------------------------------------------------------------------
// Input / Output
// -------------------------------------------------------------------------
@@ -80,7 +86,14 @@
this.orgUnitId = orgUnitId;
}
- private String dataSetId;
+ private String orgUnitGroupId;
+
+ public void setOrgUnitGroupId(String orgUnitGroupId)
+ {
+ this.orgUnitGroupId = orgUnitGroupId;
+ }
+
+ private String dataSetId;
public void setDataSetId( String dataSetId )
{
@@ -134,9 +147,16 @@
Date sDate = dateFormat.parse( startDate );
Date eDate = dateFormat.parse( endDate );
Constant qualityMaxDataElement = constantService.getConstantByName( QUALITY_MAX_DATAELEMENT );
+
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) );
-
+ OrganisationUnitGroup orgUnitGroup = orgUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( orgUnitGroupId ) );
+
+ if( organisationUnit == null || dataSet == null || orgUnitGroup == null )
+ {
+ return SUCCESS;
+ }
+
List<DataElement> dataElementList = new ArrayList<DataElement>( dataSet.getDataElements() );
for ( DataElement de : dataElementList )
{
@@ -149,10 +169,10 @@
}
}
}
+
for ( DataElement dataElement : dataElements )
{
- QualityMaxValue qualityMaxValue = qualityMaxValueService.getQualityMaxValue( organisationUnit, dataElement,
- dataSet, sDate, eDate );
+ QualityMaxValue qualityMaxValue = qualityMaxValueService.getQualityMaxValue( orgUnitGroup, organisationUnit, dataElement, dataSet, sDate, eDate );
if ( qualityMaxValue != null )
{
qualityMaxValueMap.put( dataElement.getId(), qualityMaxValue );
=== 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-23 14:33:01 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/LoadQualityScoreDetailsAction.java 2014-05-31 13:40:53 +0000
@@ -20,13 +20,15 @@
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
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;
@@ -38,7 +40,7 @@
public class LoadQualityScoreDetailsAction
implements Action
{
- private final static String TARIFF_SETTING_AUTHORITY = "MAXSCORE_SETTING_AUTHORITY";
+ private final static String TARIFF_SETTING_AUTHORITY = "TARIFF_SETTING_AUTHORITY";
private final static String QUALITY_MAX_DATAELEMENT = "QUALITY_MAX_DATAELEMENT";
@@ -96,6 +98,9 @@
}
@Autowired
+ private OrganisationUnitGroupService orgUnitGroupService;
+
+ @Autowired
private DefaultPBFAggregationService defaultPBFAggregationService;
@Autowired
@@ -103,7 +108,8 @@
@Autowired
private QualityScorePaymentService qualityScorePaymentService;
-
+
+
// -------------------------------------------------------------------------
// Input / Output
// -------------------------------------------------------------------------
@@ -143,9 +149,9 @@
return simpleDateFormat;
}
- private Map<Integer, QualityMaxValue> qualityMaxValueMap = new HashMap<Integer, QualityMaxValue>();
+ private Map<Integer, Double> qualityMaxValueMap = new HashMap<Integer, Double>();
- public Map<Integer, QualityMaxValue> getQualityMaxValueMap()
+ public Map<Integer, Double> getQualityMaxValueMap()
{
return qualityMaxValueMap;
}
@@ -157,7 +163,7 @@
return dataValueMap;
}
- private String paymentMessage = "No Data avialable for ";
+ private String paymentMessage = "( No data avialable for ";
public String getPaymentMessage()
{
@@ -177,7 +183,7 @@
{
return qualityScorePayments;
}
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -202,10 +208,25 @@
Constant qualityMaxDataElement = constantService.getConstantByName( QUALITY_MAX_DATAELEMENT );
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+
+ List<OrganisationUnit> orgUnitBranch = organisationUnitService.getOrganisationUnitBranch( organisationUnit.getId() );
+ String orgUnitBranchIds = "-1";
+ for( OrganisationUnit orgUnit : orgUnitBranch )
+ {
+ orgUnitBranchIds += "," + orgUnit.getId();
+ }
+
DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) );
DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+ OrganisationUnitGroup orgUnitGroup = findPBFOrgUnitGroupforTariff( organisationUnit );
+
+ if( orgUnitGroup != null )
+ {
+ qualityMaxValueMap.putAll( qualityMaxValueService.getQualityMaxValues( orgUnitGroup, orgUnitBranchIds, dataSet, period ) );
+ }
+
List<DataElement> dataElementList = new ArrayList<DataElement>( dataSet.getDataElements() );
for ( DataElement de : dataElementList )
{
@@ -221,32 +242,14 @@
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 ) );
- }
-
DataValue dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit, optionCombo );
- for ( QualityMaxValue qualityMaxValue : qualityMaxValues )
+
+ if ( dataValue != null )
{
-
- if ( qualityMaxValue.getStartDate().getTime() <= period.getStartDate().getTime()
- && period.getEndDate().getTime() <= qualityMaxValue.getEndDate().getTime() )
- {
- qualityMaxValueMap.put( dataElement.getId(), qualityMaxValue );
- if ( dataValue != null )
- {
- dataValueMap.put( dataElement.getId(), dataValue );
- }
-
- System.out.println( "In Quality Data Value" );
- break;
- }
+ dataValueMap.put( dataElement.getId(), dataValue );
}
}
-
+
Collections.sort( dataElements );
List<Lookup> lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.DS_PAYMENT_TYPE ) );
@@ -270,7 +273,7 @@
if( overAllAdjustedAmt == null || overAllAdjustedAmt == 0 )
{
- paymentMessage += period1.getStartDateString() +", ";
+ paymentMessage += period1.getDisplayName() +", ";
flag = 2;
}
else
@@ -281,7 +284,12 @@
if( flag == 1 )
{
- paymentMessage = "Data available for this quarter";
+ paymentMessage = " ";
+ }
+ else
+ {
+ paymentMessage = paymentMessage.substring(0, paymentMessage.length()-2);
+ paymentMessage += " ) ";
}
qualityScorePayments = new HashSet<QualityScorePayment>( qualityScorePaymentService.getAllQualityScorePayments() );
@@ -289,6 +297,17 @@
return SUCCESS;
}
+ public OrganisationUnitGroup findPBFOrgUnitGroupforTariff( OrganisationUnit organisationUnit )
+ {
+ Constant tariff_authority = constantService.getConstantByName( TARIFF_SETTING_AUTHORITY );
+
+ OrganisationUnitGroupSet orgUnitGroupSet = orgUnitGroupService.getOrganisationUnitGroupSet( (int) tariff_authority.getValue() );
+
+ OrganisationUnitGroup orgUnitGroup = organisationUnit.getGroupInGroupSet( orgUnitGroupSet );
+
+ return orgUnitGroup;
+ }
+
public OrganisationUnit findParentOrgunitforTariff( OrganisationUnit organisationUnit, Integer tariffOULevel )
{
Integer ouLevel = organisationUnitService.getLevelOfOrganisationUnit( organisationUnit.getId() );
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/QualityMaxInitAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/QualityMaxInitAction.java 2014-05-15 06:51:53 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/QualityMaxInitAction.java 2014-05-31 13:40:53 +0000
@@ -9,10 +9,13 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.rbf.api.Lookup;
import org.hisp.dhis.rbf.api.LookupService;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -21,7 +24,7 @@
*/
public class QualityMaxInitAction implements Action
{
- private final static String TARIFF_SETTING_AUTHORITY = "MAXSCORE_SETTING_AUTHORITY";
+ private final static String TARIFF_SETTING_AUTHORITY = "TARIFF_SETTING_AUTHORITY";
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -60,10 +63,22 @@
{
this.constantService = constantService;
}
+
+ @Autowired
+ private OrganisationUnitGroupService orgUnitGroupService;
+
+
// -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
+ private List<OrganisationUnitGroup> orgUnitGroups;
+
+ public List<OrganisationUnitGroup> getOrgUnitGroups()
+ {
+ return orgUnitGroups;
+ }
+
private OrganisationUnit organisationUnit;
public OrganisationUnit getOrganisationUnit()
@@ -141,6 +156,8 @@
}
+ orgUnitGroups = new ArrayList<OrganisationUnitGroup>( orgUnitGroupService.getOrganisationUnitGroupSet( (int) tariff_authority.getValue() ).getOrganisationUnitGroups() );
+
// dataSets = new ArrayList<DataSet>( organisationUnit.getDataSets() );
List<Lookup> lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.DS_QUALITY_TYPE ) );
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/SaveDataValueAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/SaveDataValueAction.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/SaveDataValueAction.java 2014-05-31 13:40:53 +0000
@@ -120,7 +120,8 @@
private String periodIso;
- public void setPeriodIso(String periodIso) {
+ public void setPeriodIso(String periodIso)
+ {
this.periodIso = periodIso;
}
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/SaveQualityValueAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/SaveQualityValueAction.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/SaveQualityValueAction.java 2014-05-31 13:40:53 +0000
@@ -37,11 +37,14 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.rbf.api.QualityMaxValue;
import org.hisp.dhis.rbf.api.QualityMaxValueService;
import org.hisp.dhis.system.util.ValidationUtils;
import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -92,6 +95,10 @@
this.qualityMaxValueService = qualityMaxValueService;
}
+ @Autowired
+ private OrganisationUnitGroupService orgUnitGroupService;
+
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -117,7 +124,14 @@
this.organisationUnitId = organisationUnitId;
}
- private String dataSetId;
+ private String orgUnitGroupId;
+
+ public void setOrgUnitGroupId(String orgUnitGroupId)
+ {
+ this.orgUnitGroupId = orgUnitGroupId;
+ }
+
+ private String dataSetId;
public void setDataSetId(String dataSetId)
{
@@ -126,16 +140,19 @@
private String startDate ;
- public void setStartDate(String startDate) {
+ public void setStartDate(String startDate)
+ {
this.startDate = startDate;
}
private String endDate ;
- public void setEndDate(String endDate) {
+ public void setEndDate(String endDate)
+ {
this.endDate = endDate;
}
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -174,6 +191,12 @@
return logError( "Invalid dataset identifier: " + dataSetId );
}
+ OrganisationUnitGroup orgUnitGroup = orgUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( orgUnitGroupId ) );
+ if ( orgUnitGroup == null )
+ {
+ return logError( "Invalid orgunitgroup identifier: " + orgUnitGroupId );
+ }
+
String storedBy = currentUserService.getCurrentUsername();
Date now = new Date();
@@ -208,16 +231,18 @@
Date sDate = dateFormat.parse( startDate );
Date eDate = dateFormat.parse( endDate );
- QualityMaxValue qualityMaxValue = qualityMaxValueService.getQualityMaxValue(organisationUnit, dataElement, dataSet, sDate, eDate );
+ QualityMaxValue qualityMaxValue = qualityMaxValueService.getQualityMaxValue( orgUnitGroup, organisationUnit, dataElement, dataSet, sDate, eDate );
if ( qualityMaxValue == null )
{
if ( value != null )
{
qualityMaxValue = new QualityMaxValue( );
+
qualityMaxValue.setDataSet(dataSet);
qualityMaxValue.setDataElement(dataElement);
qualityMaxValue.setOrganisationUnit(organisationUnit);
+ qualityMaxValue.setOrgUnitGroup( orgUnitGroup );
qualityMaxValue.setValue(Double.parseDouble(value));
qualityMaxValue.setStartDate(sDate);
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/ValidateQualityMaxDataAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/ValidateQualityMaxDataAction.java 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/quality/dataentry/ValidateQualityMaxDataAction.java 2014-05-31 13:40:53 +0000
@@ -11,9 +11,12 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.rbf.api.QualityMaxValue;
import org.hisp.dhis.rbf.api.QualityMaxValueService;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -45,6 +48,9 @@
this.organisationUnitService = organisationUnitService;
}
+ @Autowired
+ private OrganisationUnitGroupService orgUnitGroupService;
+
// -------------------------------------------------------------------------
// Input / Output
// -------------------------------------------------------------------------
@@ -56,7 +62,14 @@
this.orgUnitId = orgUnitId;
}
- private String dataSetId;
+ private String orgUnitGroupId;
+
+ public void setOrgUnitGroupId(String orgUnitGroupId)
+ {
+ this.orgUnitGroupId = orgUnitGroupId;
+ }
+
+ private String dataSetId;
public void setDataSetId( String dataSetId )
{
@@ -125,9 +138,9 @@
Date eDate = dateFormat.parse( endDate );
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) );
+ OrganisationUnitGroup orgUnitGroup = orgUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( orgUnitGroupId ) );
- List<QualityMaxValue> qualityMaxValues = new ArrayList<QualityMaxValue>(
- qualityMaxValueService.getQuanlityMaxValues( organisationUnit, dataSet ) );
+ List<QualityMaxValue> qualityMaxValues = new ArrayList<QualityMaxValue>( qualityMaxValueService.getQuanlityMaxValues( orgUnitGroup, organisationUnit, dataSet ) );
for ( QualityMaxValue qualityMaxValue : qualityMaxValues )
{
if ( qualityMaxValue.getStartDate().getTime() == sDate.getTime() && qualityMaxValue.getEndDate().getTime() == eDate.getTime() )
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/resources/org/hisp/dhis/rbf/hibernate/QuantityMaxValue.hbm.xml'
--- local/in/dhis-web-maintenance-rbf/src/main/resources/org/hisp/dhis/rbf/hibernate/QuantityMaxValue.hbm.xml 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/resources/org/hisp/dhis/rbf/hibernate/QuantityMaxValue.hbm.xml 2014-05-31 13:40:53 +0000
@@ -6,12 +6,13 @@
<hibernate-mapping>
<class name="org.hisp.dhis.rbf.api.QualityMaxValue" table="qualitymaxvalue">
- <composite-id>
- <key-many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid" foreign-key="fk_tariffdatavalue_organisationunitid" />
- <key-many-to-one name="dataSet" class="org.hisp.dhis.dataset.DataSet" column="datasetid" foreign-key="fk_tariffdatavalue_datasetid" />
- <key-many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" column="dataelementid" foreign-key="fk_tariffdatavalue_dataelementid" />
- <key-property name="startDate" column="startdate" />
- <key-property name="endDate" column="enddate" />
+ <composite-id>
+ <key-many-to-one name="orgUnitGroup" class="org.hisp.dhis.organisationunit.OrganisationUnitGroup" column="orgunitgroupid" foreign-key="fk_tariffdatavalue_organisationunitgroupid" />
+ <key-many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid" foreign-key="fk_tariffdatavalue_organisationunitid" />
+ <key-many-to-one name="dataSet" class="org.hisp.dhis.dataset.DataSet" column="datasetid" foreign-key="fk_tariffdatavalue_datasetid" />
+ <key-many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" column="dataelementid" foreign-key="fk_tariffdatavalue_dataelementid" />
+ <key-property name="startDate" column="startdate" />
+ <key-property name="endDate" column="enddate" />
</composite-id>
<property name="value" />
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml'
--- local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml 2014-05-09 05:53:05 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml 2014-05-31 13:40:53 +0000
@@ -33,7 +33,7 @@
<action name="deleteTariffData" class="org.hisp.dhis.rbf.action.DeleteTariffDataAction">
<result name="success" type="velocity-json">/dhis-web-maintenance-rbf/tariffStatus.vm</result>
<param name="onExceptionReturn">plainTextError</param>
- <param name="requiredAuthorities">F_TARIFFDATAVALUE_UPDATE</param>
+ <param name="requiredAuthorities">F_TARIFFDATAVALUE_UPDATE</param>
</action>
<action name="validateTariffData" class="org.hisp.dhis.rbf.action.ValidateTariffDataAction">
@@ -287,6 +287,7 @@
<param name="page">/dhis-web-maintenance-rbf/qualityScorePaymentList.vm</param>
<param name="javascripts">javascript/qualityScorePayment.js</param>
<param name="menu">/dhis-web-maintenance-rbf/menu.vm</param>
+ <param name="anyAuthorities">F_QUALITY_SCORE_PAYMENT</param>
</action>
@@ -384,21 +385,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<!-- Reports -->
<action name="PBFInvoiceReportForm" class="org.hisp.dhis.rbf.report.action.PBFInvoiceReportFormAction">
<result name="success" type="velocity">/main.vm</result>
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/javascript/qualityMaxDataEntry.js'
--- local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/javascript/qualityMaxDataEntry.js 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/javascript/qualityMaxDataEntry.js 2014-05-31 13:40:53 +0000
@@ -11,44 +11,45 @@
function orgUnitHasBeenSelected( orgUnitIds , orgUnitNames )
{
$( '#dataEntryFormDiv' ).html( '' );
- var bValue = false;
- for(var i=0;i<=countryTags.length-1;i++)
- {
- if(countryTags[i] == orgUnitIds[0] )
- {
- bValue = true;
- }
- }
- if(bValue == false)
- {
- $("#startDate").val('');
- $("#endDate").val('');
- disable('dataSetId');
- disable('selectedPeriodId');
- disable('startDate');
- disable('endDate');
-
- setFieldValue('orgUnitName', orgUnitNames[0] );
- setFieldValue('selectedOrgunitName', orgUnitNames[0] );
- $("select#dataSetId option[value=-1]").attr('selected', 'selected');
- alert('Please Select Correct level OrgUnit');
- }
- else
- {
+
if( orgUnitIds != null && orgUnitIds != "" )
{
- var dataSetId = $( '#dataSetId' ).val();
- $.getJSON( 'getOrganisationUnitForMax.action', {orgUnitId:orgUnitIds[0]}
+ setFieldValue('selectedOrgunitID',orgUnitIds[0]);
+ setFieldValue('selectedOrgunitName', orgUnitNames[0] );
+
+ orgUnitGroupChange();
+ }
+}
+
+selection.setListenerFunction( orgUnitHasBeenSelected );
+
+function orgUnitGroupChange()
+{
+ $( '#dataEntryFormDiv' ).html( '' );
+
+ var dataSetId = $( '#dataSetId' ).val();
+ var orgUnitId = $( '#selectedOrgunitID' ).val();
+ var orgUnitGroupId = $( '#orgUnitGroupId' ).val();
+
+ //alert( orgUnitId + " : " + orgUnitGroupId );
+
+ if( orgUnitId != "" && orgUnitGroupId != "-1" )
+ {
+ $.getJSON( 'getOrganisationUnitForMax.action', { orgUnitId:orgUnitId, orgUnitGroupId:orgUnitGroupId }
, function( json )
{
var type = json.response;
setFieldValue('orgUnitName', json.message );
- setFieldValue('selectedOrgunitName', json.message );
+ setFieldValue('selectedOrgunitName', json.message );
+ setFieldValue('selectedOrgunitID', orgUnitId )
+
if( type == "success" )
{
enable('dataSetId');
enable('startDate');
enable('endDate');
+ enable('orgUnitGroupId');
+
var options = '';
options += '<option value="-1">Please Select</option>';
$.each(json.dataSets, function(i, obj){
@@ -58,10 +59,7 @@
$("select#dataSetId option[value="+dataSetId+"]").attr('selected', 'selected');
- setFieldValue('selectedOrgunitID',orgUnitIds[0])
- setFieldValue('orgUnitName', json.message );
- setFieldValue('selectedOrgunitName', json.message );
- loadDataEntryForm();
+ if( $( '#dataSetId' ).val() != "-1" ) loadDataEntryForm();
}
else if( type == "input" )
{
@@ -69,22 +67,20 @@
disable('selectedPeriodId');
disable('startDate');
disable('endDate');
-
- setFieldValue('orgUnitName', json.message );
- setFieldValue('selectedOrgunitName', json.message );
+ //disable('orgUnitGroupId');
}
} );
}
- }
+
}
-selection.setListenerFunction( orgUnitHasBeenSelected );
-
function loadDataEntryForm()
{
var orgUnitId = $( '#selectedOrgunitID' ).val();
+ var orgUnitGroupId = $( '#orgUnitGroupId' ).val();
var dataSetId = $( '#dataSetId' ).val();
+
$( '#dataEntryFormDiv' ).html('');
var startDate = $("#startDate").val();
@@ -98,7 +94,8 @@
if(startDate != "" && endDate != "")
{
var dataValue = {
- 'orgUnitId' : orgUnitId,
+ 'orgUnitId' : orgUnitId,
+ 'orgUnitGroupId' : orgUnitGroupId,
'startDate' : startDate,
'endDate' : endDate,
'dataSetId': dataSetId
@@ -126,6 +123,7 @@
jQuery('#dataEntryFormDiv').load('loadQualityMaxForm.action',
{
orgUnitId:orgUnitId,
+ orgUnitGroupId : orgUnitGroupId,
dataSetId:dataSetId,
startDate:startDate,
endDate:endDate
@@ -162,12 +160,13 @@
return false;
}
- if(defaultValue != value)
+ if( defaultValue != value )
{
var dataValue = {
'dataElementId' : dataElementId,
'dataSetId' : dataSetId,
- 'organisationUnitId' : $("#selectedOrgunitID").val(),
+ 'organisationUnitId' : $("#selectedOrgunitID").val(),
+ 'orgUnitGroupId' : $("#orgUnitGroupId").val(),
'value' : value,
'startDate' : startDate,
'endDate' : endDate
@@ -212,15 +211,3 @@
}
}
-
-
-
-
-
-
-
-
-
-
-
-
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadQualityMaxEntryForm.vm'
--- local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadQualityMaxEntryForm.vm 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadQualityMaxEntryForm.vm 2014-05-31 13:40:53 +0000
@@ -25,7 +25,8 @@
<tr bgcolor="#CBDDEB">
<th style="text-align: left;width:35%;">$i18n.getString( "dataelement" )</th>
<th style="text-align: center;width:15%;">$i18n.getString( "quality_max" )</th>
- </tr>
+ </tr>
+
#set( $mark = false )
#foreach($dataElement in $dataElements )
#if( $mark1 )
@@ -35,7 +36,8 @@
#end
<tr #if( $mark1 ) bgcolor = "#FFFFFF" #else bgcolor="#E0ECF8" #end>
<td><label>$dataElement.getFormNameFallback()</label></td>
-
+
+ #set( $qualityDataValue = "" )
#set( $qualityDataValue = $!qualityMaxValueMap.get( $dataElement.id ) )
<td>
=== 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-05-23 14:33:01 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadQualityScoreEntryForm.vm 2014-05-31 13:40:53 +0000
@@ -18,6 +18,13 @@
#end
#end
+
+
+<select id="qualityScorePaymentsLB" size="10" style="display:none" >
+ #foreach( $qualityScorePayment in $qualityScorePayments )
+ <option value="$!qualityScorePayment.addQtyPayment">$qualityScorePayment.getStartRange()-$!qualityScorePayment.endRange</option>
+ #end
+</select>
#set( $tabIndex = 1 )
#if ( $dataElements.size() > 0)
@@ -46,7 +53,10 @@
<tr #if( $mark1 ) bgcolor = "#FFFFFF" #else bgcolor="#E0ECF8" #end>
<td><label>$dataElement.getFormNameFallback()</label></td>
+ #set( $qualityMaxValue = "" )
#set( $qualityMaxValue = $!qualityMaxValueMap.get( $dataElement.id ) )
+
+ #set( $dataValue = "" )
#set( $dataValue = $!dataValueMap.get( $dataElement.id ) )
<td>
<input onkeyup="calPercenVal( $dataElement.id )" onblur="saveValue('$dataElement.id')" type="text" name="score_$dataElement.id" id="score_$dataElement.id"
@@ -63,7 +73,7 @@
var percentage = 0.0;
if($("#score_"+$dataElement.id).val() != '' && $("#max_"+$dataElement.id).val() != '')
{
- percentage = (parseFloat($dataValue.value) * 100) / parseFloat($qualityMaxValue.value);
+ percentage = (parseFloat($dataValue.value) * 100) / parseFloat($qualityMaxValue);
$('#percentage_'+$dataElement.id).val(percentage.toFixed(2));
}
@@ -82,25 +92,12 @@
$('#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/>
+ <input type="text" class="max" name="max_$dataElement.id" id="max_$dataElement.id" value="$!qualityMaxValue" tabindex="$tabIndex" style="text-align: center;" readonly/>
</td>
<td >
<input type="text" id="percentage_$dataElement.id" style="text-align: center;" readonly />
@@ -124,7 +121,7 @@
</tr>
<tr>
- <td colspan="3" style="text-align: right;">$paymentMessage -- Total PPS payment for this quarter</td>
+ <td colspan="3" style="text-align: right;"> <font color="red"><strong>$!paymentMessage</strong></font> Total PPS payment for this quarter</td>
<td >
<input type="text" id="ppsPayment" style="text-align: center;" value="$totalUnadjustedAmt" readonly size="18"/>
</td>
@@ -132,7 +129,7 @@
<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"/>
+ <input type="text" id="totalQualitybasedPayment" style="text-align: center;" readonly size="18"/>
</td>
</tr>
</table>
@@ -162,28 +159,42 @@
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
+ $('#all-total').val( allTotal.toFixed(2) );
+
+
+ calCulateQualityScorePayment();
+ }
+
+ function calCulateQualityScorePayment()
+ {
+ var qualityScorePayments = document.getElementById("qualityScorePaymentsLB");
+
+ var allTotal = $('#all-total').val();
+
+ for ( i=0; i < qualityScorePayments.length; i++ )
+ {
+ var qualityScoreRange = qualityScorePayments.options[i].text;
+ var startRange = parseFloat( qualityScoreRange.split("-")[0] );
+ var endRange = parseFloat( qualityScoreRange.split("-")[1] );
+
+ if( endRange == -1 && allTotal >= startRange )
+ {
+ $("#qualityOverHeadPayment").val( qualityScorePayments.options[i].value );
+ break;
+ }
+ else if( allTotal >= startRange && allTotal < endRange )
+ {
+ $("#qualityOverHeadPayment").val( qualityScorePayments.options[i].value );
+ break;
+ }
+ }
+
+ var ppsPayment = $('#ppsPayment').val();
+
+ var totalQualityBasedPayment = parseFloat( ppsPayment ) + ( parseFloat( ppsPayment ) * parseFloat( $("#qualityOverHeadPayment").val() ) / 100 );
+ $("#totalQualitybasedPayment").val( totalQualityBasedPayment );
+ }
+
+ calCulateQualityScorePayment();
</script>
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/menu.vm'
--- local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/menu.vm 2014-05-09 05:53:05 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/menu.vm 2014-05-31 13:40:53 +0000
@@ -29,10 +29,14 @@
<ul>
<li><a href="getAllLookups.action">$i18n.getString( "Lookup" )</a></li>
</ul>
+
+#if( $auth.hasAccess( "dhis-web-maintenance-rbf", "getPaymentAdjustmentDetail") )
<h2>$i18n.getString( "payment_adjustment" )</h2>
<ul>
<li><a href="getPaymentAdjustmentDetail.action">$i18n.getString( "payment_adjustment" )</a></li>
</ul>
+#end
+
<h2>$i18n.getString( "reports" )</h2>
<ul>
<li><a href="PBFInvoiceReportForm.action">$i18n.getString( "quarterly_invoice_for_PBF_indicators_PMA" )</a></li>
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/qualityMaxEntrySelection.vm'
--- local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/qualityMaxEntrySelection.vm 2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/qualityMaxEntrySelection.vm 2014-05-31 13:40:53 +0000
@@ -27,11 +27,7 @@
inset 8px 10px 10px rgba(255,255,255,0.75);
}
</style>
-<div width="100%">
- <div id="tariffSetting">
- Quality Max Score Level : $!tariff_setting_authority
- </div>
-</div>
+
<h3>$i18n.getString( "quality_max_entry" )</h3>
<form id="qualityMaxDataEntryForm" name="qualityMaxDataEntryForm" method="post" >
@@ -41,13 +37,26 @@
</div>
-<div class="inputCriteria" style="width:480px;height:auto;">
+<div class="inputCriteria" style="width:560px;height:auto;">
<table>
<tr>
<td><label for="orgUnitName">$i18n.getString( "organisation_unit" )</label></td>
<td><input type="text" id="orgUnitName" name = "orgUnitName" readonly="readonly" value="$!organisationUnit.name" style="width:352px"></td>
</tr>
-
+
+ <tr>
+ <td>Orgainsation Unit Group: </td>
+ <td>
+ <select id="orgUnitGroupId" name="orgUnitGroupId" onchange="javascript:orgUnitGroupChange()" style="width:352px">
+ <option value="-1">[Please select]</option>
+ #foreach( $orgUnitGroup in $orgUnitGroups )
+ <option value="$!orgUnitGroup.id">$!orgUnitGroup.name</option>
+ #end
+ </select>
+ </td>
+ <td > </td>
+ </tr>
+
<tr>
<td><label>$i18n.getString( "dataset" )</label></td>
<td>