← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6091: (patient) Group details of aggregation result by orgunit and period.

 

------------------------------------------------------------
revno: 6091
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-02-23 15:38:50 +0700
message:
  (patient) Group details of aggregation result by orgunit and period.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js


--
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-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java	2012-01-25 17:11:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java	2012-02-23 08:38:50 +0000
@@ -31,9 +31,12 @@
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
+import org.apache.struts.taglib.html.FormTag;
 import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
 import org.hisp.dhis.caseaggregation.CaseAggregationConditionService;
 import org.hisp.dhis.caseentry.state.PeriodGenericManager;
@@ -135,20 +138,41 @@
         this.dataSetId = dataSetId;
     }
 
-    private Map<DataValue, String> mapDataValues;
-
-    public Map<DataValue, String> getMapDataValues()
+    private Map<String, String> mapStatusValues = new HashMap<String, String>();
+
+    public Map<String, String> getMapStatusValues()
+    {
+        return mapStatusValues;
+    }
+
+    private Map<String, Set<DataValue>> mapDataValues = new HashMap<String, Set<DataValue>>();
+
+    public Map<String, Set<DataValue>> getMapDataValues()
     {
         return mapDataValues;
     }
 
-    private Map<DataValue, CaseAggregationCondition> mapCaseAggCondition;
+    private Map<DataValue, CaseAggregationCondition> mapCaseAggCondition = new HashMap<DataValue, CaseAggregationCondition>();
 
     public Map<DataValue, CaseAggregationCondition> getMapCaseAggCondition()
     {
         return mapCaseAggCondition;
     }
 
+    private List<OrganisationUnit> orgunits = new ArrayList<OrganisationUnit>();
+
+    public List<OrganisationUnit> getOrgunits()
+    {
+        return orgunits;
+    }
+
+    private List<Period> periods = new ArrayList<Period>();
+
+    public List<Period> getPeriods()
+    {
+        return periods;
+    }
+
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -156,9 +180,6 @@
     public String execute()
         throws Exception
     {
-        mapDataValues = new HashMap<DataValue, String>();
-        mapCaseAggCondition = new HashMap<DataValue, CaseAggregationCondition>();
-
         String storedBy = currentUserService.getCurrentUsername() + "_CAE";
 
         // ---------------------------------------------------------------------
@@ -172,21 +193,21 @@
             return SUCCESS;
         }
 
-        List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>();
-        if ( facilityLB.equals( "children" ) )
+        if ( facilityLB.equals( "random" ) )
         {
-            orgUnitList = getChildOrgUnitTree( selectedOrgunit );
+            orgunits.add( selectedOrgunit );
         }
         else if ( facilityLB.equals( "immChildren" ) )
         {
-            orgUnitList.add( selectedOrgunit );
+            orgunits.addAll( getChildOrgUnitTree( selectedOrgunit ) );
+        }
+        else
+        {
             List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>( selectedOrgunit.getChildren() );
             Collections.sort( organisationUnits, IdentifiableObjectNameComparator.INSTANCE );
-            orgUnitList.addAll( organisationUnits );
-        }
-        else
-        {
-            orgUnitList.add( selectedOrgunit );
+
+            orgunits.addAll( organisationUnits );
+            orgunits.add( selectedOrgunit );
         }
 
         // ---------------------------------------------------------------------
@@ -201,8 +222,6 @@
         // Get selected periods list
         // ---------------------------------------------------------------------
 
-        List<Period> periodList = new ArrayList<Period>();
-
         Period startPeriod = periodGenericManager.getSelectedPeriod(
             PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START,
             PeriodGenericManager.SESSION_KEY_BASE_PERIOD_START );
@@ -211,13 +230,13 @@
             PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END,
             PeriodGenericManager.SESSION_KEY_BASE_PERIOD_END );
 
-        periodList = getPeriodList( (CalendarPeriodType) selectedDataSet.getPeriodType(), startPeriod, endPeriod );
+        periods = getPeriodList( (CalendarPeriodType) selectedDataSet.getPeriodType(), startPeriod, endPeriod );
 
         // ---------------------------------------------------------------------
         // Aggregation
         // ---------------------------------------------------------------------
 
-        for ( OrganisationUnit orgUnit : orgUnitList )
+        for ( OrganisationUnit orgUnit : orgunits )
         {
             for ( DataElement dElement : dataElementList )
             {
@@ -231,16 +250,17 @@
 
                     if ( condition != null )
                     {
-                        for ( Period period : periodList )
+                        for ( Period period : periods )
                         {
-                            String message = i18n.getString( "in" ) + " " + format.formatPeriod( period );
-
                             Double resultValue = aggregationConditionService.parseConditition( condition, orgUnit,
                                 period );
 
                             DataValue dataValue = dataValueService
                                 .getDataValue( orgUnit, dElement, period, optionCombo );
 
+                            String key = orgUnit.getId() + "-" + format.formatPeriod( period );
+                            String keyStatus = key + "-" + dElement.getId();
+
                             if ( resultValue != null && resultValue != 0.0 )
                             {
                                 if ( dataValue == null )
@@ -249,7 +269,7 @@
                                         new Date(), null, optionCombo );
 
                                     dataValueService.addDataValue( dataValue );
-                                    mapDataValues.put( dataValue, i18n.getString( "added" ) + " " + message );
+                                    mapStatusValues.put( keyStatus, i18n.getString( "added" ) );
                                 }
                                 else
                                 {
@@ -259,7 +279,7 @@
 
                                     dataValueService.updateDataValue( dataValue );
 
-                                    mapDataValues.put( dataValue, i18n.getString( "updated" ) + " " + message );
+                                    mapStatusValues.put( keyStatus, i18n.getString( "updated" ) );
                                 }
 
                                 mapCaseAggCondition.put( dataValue, condition );
@@ -267,18 +287,32 @@
                             }
                             else if ( dataValue != null )
                             {
-                                DataValue dvalue = new DataValue( dElement, period, orgUnit, "", storedBy, new Date(),
+                                String value = dataValue.getValue();
+
+                                dataValueService.deleteDataValue( dataValue );
+
+                                dataValue = new DataValue( dElement, period, orgUnit, value, storedBy, new Date(),
                                     null, optionCombo );
-                                
-                                dvalue.setValue( dataValue.getValue() + " " + i18n.getString( "old_value" ) );
-
-                                dataValueService.deleteDataValue( dataValue );
-
-                                mapDataValues.put( dvalue, i18n.getString( "deleted" ) + " " + message );
-                            }
-
+                                    
+                                mapStatusValues.put( keyStatus, i18n.getString( "deleted" ) );
+                            }
+                            
+                            if ( dataValue != null )
+                            {
+                                Set<DataValue> dataValues = null;
+                                if ( mapDataValues.containsKey( key ) )
+                                {
+                                    dataValues = mapDataValues.get( key );
+                                }
+                                else
+                                {
+                                    dataValues = new HashSet<DataValue>();
+                                }
+
+                                dataValues.add( dataValue );
+                                mapDataValues.put( key, dataValues );
+                            }
                         }
-
                     }
                 }
             }
@@ -320,7 +354,7 @@
             period = periodType.getNextPeriod( period );
             periods.add( period );
         }
-        
+
         return periods;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-02-21 19:40:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-02-23 08:38:50 +0000
@@ -83,7 +83,7 @@
 in=in
 value=Value
 status=Status
-no_value_added_or_update=No values added or updated.
+no_value_added_or_update=No values added or updated
 date_less_incident_date=This date is less then the incident date.
 deleted=Deleted
 old_value=Old Value
@@ -251,4 +251,5 @@
 show_all_items=Show all items
 see_history_plan=See history / plan
 name_based_data_entry=Name-based data entry
-multiple_name_based_data_entry=Multiple name-based data entry
\ No newline at end of file
+multiple_name_based_data_entry=Multiple name-based data entry
+ga_facilityby=Organisation Unit By
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-02-13 19:27:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-02-23 08:38:50 +0000
@@ -261,6 +261,7 @@
 			<param name="page">/dhis-web-caseentry/caseAggregationForm.vm</param>
 			<param name="menu">/dhis-web-caseentry/caseAggregationMenu.vm</param>
 			<param name="javascripts">javascript/caseagg.js,javascript/date.js,javascript/caseAggregationForm.js</param>
+			<param name="stylesheets">style/dataEntry.css</param>
 		</action>
 
 		<action name="loadPeriods"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm	2011-11-07 07:56:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm	2012-02-23 08:38:50 +0000
@@ -1,46 +1,58 @@
 <h4> $i18n.getString( "case_aggregation_result" )</h4>
-		
+
 <div>
     <input type="button" value="$i18n.getString( "back" )" onclick="backBtnOnClick();" style="width:10em">
 </div>
 
 <p></p>
-<div>
-#if( $mapDataValues.keySet().size() > 0 )
-<table class='mainPageTable listTable'>
-	<col width="40">          
-	<col>
-	<col>
-	<col>  
-	<thead>
-		<tr>
-			<th>#</th>
-			<th>$i18n.getString('name')</th>
-			<th>$i18n.getString('value')</th>
-			<th>$i18n.getString('status')</th>
-		</tr>
-	</thead>
-	
-	#set ( $keys = $mapDataValues.keySet() )
-	#set ($index = 1)
-	<tbody>
-		#set( $mark = false )
-		#foreach( $key in $keys)
-			<tr #alternate( $mark ) style="cursor: pointer" title="$i18n.getString('show_details')" onclick="viewResultDetails($key.source.id,$key.period.id,$mapCaseAggCondition.get($key).id)">
-				<td>$index</td>
-				<td>$key.dataElement.getName()</td>
-				<td>$key.getValue()</td>
-				<td>$mapDataValues.get($key)</td>
-			</tr>
-			#set( $mark = !$mark  )
-			#set ($index = $index + 1)
+
+#set( $index = 0 )
+#foreach( $orgunit in $orgunits)
+	<h2>$orgunit.name</h2>
+	#foreach( $period in $periods)
+		#set( $index = $index + 1 )
+		#set( $periodInfo = $orgunit.id + '-' + $index )
+		#set( $periodButton = $periodInfo + "-button")
+		#set( $periodDiv = $periodInfo + "-div")
+		#set( $key = $orgunit.id + '-' + $format.formatPeriod($period) )
+		
+		<h4>$format.formatPeriod( $period )
+		#if( $!mapDataValues.get( $key ) )
+			<img id='$periodButton' src="../images/down.png" onclick="toggleResult('$periodInfo');" style="cursor: pointer;"></h4>
+		
+			#set( $dataValues = $mapDataValues.get( $key ) ) 
+			<table class="formSection mainPageTable hidden" id='$periodDiv'>
+				<col width="40">          
+				<col>
+				<col>
+				<col>
+				<tbody>
+				#set( $mark = false )
+				#set($no = 1)
+					<tr>
+						<th>#</th>
+						<th>$i18n.getString('name')</th>
+						<th>$i18n.getString('value')</th>
+						<th>$i18n.getString('status')</th>
+					</tr>
+					#foreach( $dataValue in $dataValues)
+						#set( $statusKey = $key + '-' + $dataValue.dataElement.id )
+						<tr #alternate( $mark ) style="cursor: pointer" title="$i18n.getString('show_details')" onclick="viewResultDetails($orgunit.id,$period.id,$mapCaseAggCondition.get($dataValue).id)">
+							<td>$no</td>
+							<td>$dataValue.dataElement.name</td>
+							<td>$dataValue.value</td>
+							<td>$!mapStatusValues.get( $statusKey )</td>
+						</tr>
+						#set( $mark = !$mark  )
+						#set ($no = $no + 1)
+					#end
+				</tbody>
+			</table>
+		#else
+			($i18n.getString('no_value_added_or_update')) </h4>
 		#end
-	</tbody>
-</table>
-#else
-	$i18n.getString('no_value_added_or_update')
+	#end
 #end
-</div>
 
 <div id='contentDetails'></div>
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js	2012-02-14 03:37:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js	2012-02-23 08:38:50 +0000
@@ -144,3 +144,7 @@
 	showById('caseAggregationForm');
 }
 
+function toggleResult( id )
+{
+	$( "#" + id + "-div" ).slideToggle( "fast" );
+}