← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6258: (patient) Use Dataset insteads of Dataelement group for Case Aggregation Query Builder.

 

------------------------------------------------------------
revno: 6258
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-03-13 15:24:08 +0700
message:
  (patient) Use Dataset insteads of Dataelement group for Case Aggregation Query Builder.
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseAggerateDataElement.vm
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ShowAddCaseAggregationConditionFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ShowUpdateCaseAggregationConditionFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.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 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ShowAddCaseAggregationConditionFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ShowAddCaseAggregationConditionFormAction.java	2012-01-25 17:11:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ShowAddCaseAggregationConditionFormAction.java	2012-03-13 08:24:08 +0000
@@ -35,6 +35,8 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patient.comparator.PatientAttributeComparator;
@@ -56,7 +58,7 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    public DataElementService dataElementService;
+    public DataSetService dataSetService;
 
     public ProgramService programService;
 
@@ -70,7 +72,7 @@
 	
     private List<PatientAttribute> patientAttributes;
 
-    private List<DataElementGroup> dataElementGroups;
+    private List<DataSet> dataSets;
 
     private List<DataElement> dataElements;
 
@@ -79,7 +81,17 @@
     // -------------------------------------------------------------------------
     // Getters && Setters
     // -------------------------------------------------------------------------
-    
+ 
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
     public Integer getId()
     {
         return id;
@@ -89,37 +101,27 @@
     {
         this.id = id;
     }
-	
-    public List<DataElementGroup> getDataElementGroups()
-    {
-        return dataElementGroups;
-    }
 
     public List<Program> getPrograms()
     {
         return programs;
     }
 
+    public List<DataSet> getDataSets()
+    {
+        return dataSets;
+    }
+
     public List<DataElement> getDataElements()
     {
         return dataElements;
     }
 
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
-    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
-    {
-        this.patientAttributeService = patientAttributeService;
-    }
-
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+   
     public List<PatientAttribute> getPatientAttributes()
     {
         return patientAttributes;
@@ -131,11 +133,10 @@
 
     @Override
     public String execute()
-        throws Exception
     {
-        dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() );
-        Collections.sort( dataElementGroups, IdentifiableObjectNameComparator.INSTANCE );
-
+        dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
+        Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );
+        
         programs = new ArrayList<Program>( programService.getAllPrograms() );
         Collections.sort( programs, new ProgramNameComparator() );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ShowUpdateCaseAggregationConditionFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ShowUpdateCaseAggregationConditionFormAction.java	2012-01-25 17:11:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ShowUpdateCaseAggregationConditionFormAction.java	2012-03-13 08:24:08 +0000
@@ -37,6 +37,8 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patient.comparator.PatientAttributeComparator;
@@ -60,7 +62,7 @@
 
     private CaseAggregationConditionService aggregationConditionService;
 
-    public DataElementService dataElementService;
+    public DataSetService dataSetService;
 
     public ProgramService programService;
 
@@ -78,9 +80,7 @@
 
     private List<PatientAttribute> patientAttributes;
 
-    private List<DataElementGroup> dataElementGroups;
-
-    private List<DataElement> dataElements;
+    private List<DataSet> dataSets;
 
     private List<Program> programs;
 
@@ -93,9 +93,9 @@
         this.aggregationConditionService = aggregationConditionService;
     }
 
-    public void setDataElementService( DataElementService dataElementService )
+    public void setDataSetService( DataSetService dataSetService )
     {
-        this.dataElementService = dataElementService;
+        this.dataSetService = dataSetService;
     }
 
     public void setProgramService( ProgramService programService )
@@ -123,9 +123,9 @@
         return caseAggregation;
     }
 
-    public List<DataElementGroup> getDataElementGroups()
+    public List<DataSet> getDataSets()
     {
-        return dataElementGroups;
+        return dataSets;
     }
 
     public List<Program> getPrograms()
@@ -133,11 +133,6 @@
         return programs;
     }
 
-    public List<DataElement> getDataElements()
-    {
-        return dataElements;
-    }
-
     public List<PatientAttribute> getPatientAttributes()
     {
         return patientAttributes;
@@ -151,8 +146,8 @@
     public String execute()
         throws Exception
     {
-        dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() );
-        Collections.sort( dataElementGroups, IdentifiableObjectNameComparator.INSTANCE );
+        dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
+        Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );
 
         programs = new ArrayList<Program>( programService.getAllPrograms() );
         Collections.sort( programs, new ProgramNameComparator() );
@@ -162,7 +157,7 @@
 
         caseAggregation = aggregationConditionService.getCaseAggregationCondition( id );
         description = aggregationConditionService.getConditionDescription( caseAggregation.getAggregationExpression() );
-        
+
         return SUCCESS;
     }
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-02-15 06:47:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-03-13 08:24:08 +0000
@@ -649,8 +649,8 @@
 		id="org.hisp.dhis.patient.action.caseaggregation.ShowAddCaseAggregationConditionFormAction"
 		class="org.hisp.dhis.patient.action.caseaggregation.ShowAddCaseAggregationConditionFormAction"
 		scope="prototype">
-		<property name="dataElementService">
-			<ref bean="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="dataSetService">
+			<ref bean="org.hisp.dhis.dataset.DataSetService" />
 		</property>
 		<property name="programService">
 			<ref bean="org.hisp.dhis.program.ProgramService" />
@@ -664,8 +664,8 @@
 		id="org.hisp.dhis.patient.action.caseaggregation.ShowUpdateCaseAggregationConditionFormAction"
 		class="org.hisp.dhis.patient.action.caseaggregation.ShowUpdateCaseAggregationConditionFormAction"
 		scope="prototype">
-		<property name="dataElementService">
-			<ref bean="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="dataSetService">
+			<ref bean="org.hisp.dhis.dataset.DataSetService" />
 		</property>
 		<property name="programService">
 			<ref bean="org.hisp.dhis.program.ProgramService" />

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-03-05 12:58:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-03-13 08:24:08 +0000
@@ -689,6 +689,12 @@
 				/dhis-web-maintenance-patient/responseAggDataElement.vm
 			</result>
 		</action>
+		
+		<action name="getDataElementsByDataset"
+			class="org.hisp.dhis.commons.action.GetDataSetAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-maintenance-patient/responseAggerateDataElement.vm</result>
+		</action>
 
 		<action name="getProgramStages"
 			class="org.hisp.dhis.patient.action.caseaggregation.GetProgramStagesAction">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2012-03-12 04:19:40 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2012-03-13 08:24:08 +0000
@@ -27,14 +27,13 @@
     </tr>
     
     <tr>
-		<td><label for="dataElementGroup">$i18n.getString( "dataelement_group" )</label></td>
+		<td><label for="dataSets">$i18n.getString( "dataset" )</label></td>
 		<td>
-			<select id="dataElementGroup" name="dataElementGroup" style="width:30.5em" onchange="getAggDataElements();">
+			<select id="dataSets" name="dataSets" style="width:30.5em" onchange="getDataElementsByDataset();">
 				<option value="">[$i18n.getString('please_select')]</option>
-				#foreach( $dataElementGroup in $dataElementGroups)
-					<option value="$dataElementGroup.id" >$dataElementGroup.name</option>
+				#foreach( $dataSet in $dataSets)
+					<option value="$dataSet.id" >$dataSet.name</option>
 				#end
-				<option value="0">$i18n.getString('others')</option>
 			</select>
 		</td>				
 	</tr>
@@ -288,8 +287,6 @@
 
 <script>
 	byId('description').focus();
-	getAggDataElements();
-	getProgramStages();
 	var i18n_run_success = '$encoder.jsEscape( $i18n.getString( "run_success" ) , "'" )';
 	var i18n_run_fail = '$encoder.jsEscape( $i18n.getString( "run_fail" ) , "'" )';
 	jQuery("#tabs").tabs();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js	2012-02-23 04:05:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js	2012-03-13 08:24:08 +0000
@@ -1,40 +1,38 @@
 
 //------------------------------------------------------------------------------
-// Get Aggregated Dataelements
+// Get dataelements by dataset
 //------------------------------------------------------------------------------
 
-function getAggDataElements( )
+function getDataElementsByDataset()
 {
-	var dataElementGroup = document.getElementById( 'dataElementGroup' );
-	var dataElementGroupId = dataElementGroup.options[ dataElementGroup.selectedIndex ].value;
-	if( dataElementGroupId == "" ){
+	var dataSets = document.getElementById( 'dataSets' );
+	var dataSetId = dataSets.options[ dataSets.selectedIndex ].value;
+	if( dataSetId == "" ){
 		clearList( byId('aggregationDataElementId'));
 		return;
 	}
 
-	$.post( 'getAggDataElements.action', { dataElementGroupId:dataElementGroupId }, getAggDataElementsCompleted );
-}
-
-function getAggDataElementsCompleted( dataelementElement )
-{
-	var de = document.getElementById( 'aggregationDataElementId' );
-  
-	clearList( de );
-  
-	var dataElementList = $(dataelementElement).find( 'dataelement' );
-  
-	$( dataElementList ).each( function( i, item )
-	{
-        var id = $(item).find("id").text();
-        var name = $(item).find("name").text();
-
-        var option = document.createElement("option");
-        option.value = id;
-        option.text = name;
-        option.title = name;
-        
-        de.add(option, null);  			
-	} );
+	jQuery.getJSON( 'getDataElementsByDataset.action', 
+		{ 
+			id:dataSetId 
+		}, function( json )
+        {
+			var de = document.getElementById( 'aggregationDataElementId' );
+			clearList( de );
+		  
+			for ( i in json.dataElements ) 
+			{ 
+				var id = json.dataElements[i].id;
+				var name = json.dataElements[i].name;
+
+				var option = document.createElement("option");
+				option.value = id;
+				option.text = name;
+				option.title = name;
+				
+				de.add(option, null);  			
+			}
+		});
 }
 
 //------------------------------------------------------------------------------

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseAggerateDataElement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseAggerateDataElement.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseAggerateDataElement.vm	2012-03-13 08:24:08 +0000
@@ -0,0 +1,15 @@
+#set( $size = $dataSet.dataElements.size() )
+{ 
+	"dataElements": [
+		#foreach( $dataElement in $dataSet.dataElements )
+			#set( $subSize = $dataElement.categoryCombo.optionCombos.size() )
+			#foreach ( $optionCombo in $dataElement.categoryCombo.optionCombos )
+			{
+				#set( $name="${dataElement.name} ${optionCombo.name}")
+				"id":  "${dataElement.id}.${optionCombo.id}",
+				"name": "$!encoder.jsonEncode( $name )"
+			}#if( $velocityCount < $subSize ),#end
+			#end#if( $velocityCount < $size ),#end
+		#end
+	]
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2012-03-12 04:19:40 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2012-03-13 08:24:08 +0000
@@ -29,14 +29,13 @@
     </tr>
     
     <tr>
-		<td><label for="dataElementGroup">$i18n.getString( "dataelement_group" )</label></td>
+		<td><label for="dataSets">$i18n.getString( "dataset" )</label></td>
 		<td>
-			<select id="dataElementGroup" name="dataElementGroup" style="width:30.5em" onchange="getAggDataElements();">
-				<option value="0">[$i18n.getString('please_select')]</option>
-				#foreach( $dataElementGroup in $dataElementGroups)
-					<option value="$dataElementGroup.id" >$dataElementGroup.name</option>
+			<select id="dataSets" name="dataSets" style="width:30.5em" onchange="getDataElementsByDataset();">
+				<option value="">[$i18n.getString('please_select')]</option>
+				#foreach( $dataSet in $dataSets)
+					<option value="$dataSet.id" >$dataSet.name</option>
 				#end
-				<option value="0">$i18n.getString('others')</option>
 			</select>
 		</td>				
 	</tr>
@@ -45,7 +44,7 @@
 		<td><label for="dataElement">$i18n.getString( "dataelement" )<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 		<td>
 			<select id="aggregationDataElementId" name="aggregationDataElementId" style="width:30.5em" class="{validate:{required:true}}" >
-				<option value="$caseAggregation.aggregationDataElement.id.$caseAggregation.optionCombo.id">$caseAggregation.aggregationDataElement.name ($caseAggregation.optionCombo.name)</option>
+				<option value="$caseAggregation.aggregationDataElement.id.$caseAggregation.optionCombo.id">$caseAggregation.aggregationDataElement.name $caseAggregation.optionCombo.name</option>
 			</select>
 		</td>				
 	</tr>