← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8732: Don't generate aggregate data values if it was generated by dhis-system before in scheduling Pers...

 

------------------------------------------------------------
revno: 8732
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-10-26 15:30:46 +0700
message:
  Don't generate aggregate data values if it was generated by dhis-system before in scheduling Person Aggregation.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.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 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java	2012-10-26 03:05:57 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java	2012-10-26 08:30:46 +0000
@@ -140,7 +140,7 @@
         {
             String periodType = dataSet.getPeriodType().getName();
             List<Period> periods = getPeriods( periodType );
-            
+
             String sql = "select caseaggregationconditionid, aggregationdataelementid, optioncomboid "
                 + "from caseaggregationcondition cagg inner join datasetmembers dm "
                 + "on cagg.aggregationdataelementid=dm.dataelementid " + "inner join dataset ds "
@@ -173,11 +173,14 @@
                 {
                     for ( Period period : periods )
                     {
+                        DataValue dataValue = dataValueService.getDataValue( orgUnit, dElement, period, optionCombo );
+
+                        if ( dataValue != null && dataValue.getStoredBy().equals( STORED_BY_DHIS_SYSTEM ) )
+                            continue;
+
                         Integer resultValue = aggregationConditionService.parseConditition( aggCondition, orgUnit,
                             period );
 
-                        DataValue dataValue = dataValueService.getDataValue( orgUnit, dElement, period, optionCombo );
-
                         if ( resultValue != null && resultValue != 0 )
                         {
                             // -----------------------------------------------------
@@ -192,7 +195,7 @@
                             // -----------------------------------------------------
                             // Update dataValue
                             // -----------------------------------------------------
-                            else
+                            else if ( (double)resultValue != Double.parseDouble( dataValue.getValue() ) )
                             {
                                 dataValue.setValue( "" + resultValue );
                                 dataValue.setTimestamp( new Date() );
@@ -241,9 +244,9 @@
 
         Iterator<Period> iter = relatives.iterator();
         Date currentDate = new Date();
-        while(iter.hasNext())
+        while ( iter.hasNext() )
         {
-            if(currentDate.before( iter.next().getEndDate() ))
+            if ( currentDate.before( iter.next().getEndDate() ) )
             {
                 iter.remove();
             }