← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4227: Add validation for case aggregation in Update form ( Patient module ).

 

------------------------------------------------------------
revno: 4227
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-07-28 14:45:31 +0700
message:
  Add validation for case aggregation in Update form ( Patient module ).
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ValidateCaseAggregationConditionAction.java
  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/ValidateCaseAggregationConditionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ValidateCaseAggregationConditionAction.java	2011-07-28 06:36:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ValidateCaseAggregationConditionAction.java	2011-07-28 07:45:31 +0000
@@ -34,6 +34,7 @@
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.patient.PatientAttribute;
 
 import com.opensymphony.xwork2.Action;
 
@@ -74,6 +75,12 @@
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
 
     private String aggregationDataElementId;
 
@@ -114,16 +121,23 @@
         CaseAggregationCondition condition = aggregationConditionService.getCaseAggregationCondition(
             aggregationDataElement, optionCombo );
 
-        if ( condition != null )
+        if ( id != null && condition != null )
+        {
+            CaseAggregationCondition match = aggregationConditionService.getCaseAggregationCondition( id );
+
+            if ( match != condition )
+            {
+                message = i18n.getString( "aggregation_data_element_in_use" );
+                return INPUT;
+            }
+        }
+        else if ( condition != null )
         {
             message = i18n.getString( "aggregation_data_element_in_use" );
-
             return INPUT;
         }
 
         message = i18n.getString( "everything_is_ok" );
-
         return SUCCESS;
-
     }
 }

=== 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	2011-07-22 03:53:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2011-07-28 07:45:31 +0000
@@ -3,6 +3,8 @@
 		validation( 'updateCaseAggregationForm', function(form){
 			form.submit();
 		}); 
+		
+		checkValueIsExist( "aggregationDataElementId", "validateCaseAggregation.action", {id:getFieldValue('id')});
 	});	
 	
 </script>
@@ -12,7 +14,6 @@
 <form id="updateCaseAggregationForm" action="updateCaseAggregation.action" method="post" >
 
 <input type='hidden' id='id' name='id' value='$caseAggregation.id'>
-
 <table> 
 	<thead>
       <tr>