← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8950: Improve program-validation-rule (WIP).

 

------------------------------------------------------------
revno: 8950
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-11-08 23:07:27 +0700
message:
  Improve program-validation-rule (WIP).
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/expressionBuilderForm.vm
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.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/webapp/dhis-web-caseentry/anonymousRegistration.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/validationResult.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramValidationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateProgramValidationAction.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/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addSingleProgramValidationForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateSingleProgramValidationForm.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-11-08 04:13:48 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-11-08 16:07:27 +0000
@@ -147,6 +147,10 @@
         executeSql( "ALTER TABLE period ALTER COLUMN periodid SET DEFAULT NEXTVAL('period_periodid_seq')");
         
         executeSql( "UPDATE program SET programstage_dataelements=false WHERE displayInReports is null" );
+        
+        executeSql( "ALTER TABLE programvalidation DROP COLUMN leftside" );
+        executeSql( "ALTER TABLE programvalidation DROP COLUMN rightside" );
+
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2012-11-08 13:09:31 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2012-11-08 16:07:27 +0000
@@ -130,7 +130,7 @@
             String rightSideValue = expressionService.getProgramExpressionValue( validation.getRightSide(),
                 programStageInstance );
             String operator = validation.getOperator().getMathematicalOperator();
-
+            
             if ( (leftSideValue != null && rightSideValue.equals( NOT_NULL_VALUE_IN_EXPRESSION ) && rightSideValue == null)
                 || ( !(leftSideValue != null && rightSideValue != null 
                     && ((operator.equals( "==" ) && leftSideValue.equals( rightSideValue ))
@@ -192,7 +192,7 @@
         {
             ProgramValidation validation = iter.next();
 
-            String expression = validation.getLeftSide() + " " + validation.getRightSide();
+            String expression = validation.getLeftSide().getExpression() + " " + validation.getRightSide().getExpression();
             Matcher matcher = pattern.matcher( expression );
 
             boolean flag = false;

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-11-08 13:09:31 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-11-08 16:07:27 +0000
@@ -219,6 +219,7 @@
 		<property name="validationStore" ref="org.hisp.dhis.program.ProgramValidationStore" />
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="expressionService" ref="org.hisp.dhis.program.ProgramExpressionService" />
 	</bean>
 	
 	<bean id="org.hisp.dhis.program.ProgramExpressionService" class="org.hisp.dhis.program.DefaultProgramExpressionService">

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml	2012-11-08 13:09:31 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml	2012-11-08 16:07:27 +0000
@@ -13,7 +13,7 @@
 		<property name="description" type="text" />
 
 		<many-to-one name="leftSide" column="leftprogramexpressionid"
-			class="org.hisp.dhis.expression.Expression" cascade="all"
+			class="org.hisp.dhis.program.ProgramExpression" cascade="all"
 			foreign-key="fk_programvalidation_leftprogramexpressionid" />
 
 		<property name="operator" type="org.hisp.dhis.expression.OperatorUserType">
@@ -21,7 +21,7 @@
 		</property>
 
 		<many-to-one name="rightSide" column="rightprogramexpressionid"
-			class="org.hisp.dhis.expression.Expression" cascade="all"
+			class="org.hisp.dhis.program.ProgramExpression" cascade="all"
 			foreign-key="fk_programvalidation_rightprogramexpressionid" />
 
 		<many-to-one name="program" class="org.hisp.dhis.program.Program"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java	2012-11-08 13:33:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java	2012-11-08 16:07:27 +0000
@@ -68,8 +68,6 @@
     // Output
     // -------------------------------------------------------------------------
 
-    private Map<DataElement, String> resultDEMultiStages;
-
     private List<ProgramValidationResult> programValidationResults;
 
     private Map<Integer, String> leftsideFormulaMap;
@@ -109,11 +107,6 @@
     {
         this.programValidationService = programValidationService;
     }
-    
-    public Map<DataElement, String> getResultDEMultiStages()
-    {
-        return resultDEMultiStages;
-    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -123,8 +116,6 @@
     public String execute()
         throws Exception
     {
-        resultDEMultiStages = new HashMap<DataElement, String>();
-
         programValidationResults = new ArrayList<ProgramValidationResult>();
 
         // ---------------------------------------------------------------------

=== 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-11-08 13:09:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-11-08 16:07:27 +0000
@@ -470,6 +470,4 @@
 left_value = Left value
 right_value = Right value
 validation_rule = Validation rule
-add_filter = Add filter
-edit_left_side = Edit left side
-edit_right_side = Edit right side
\ No newline at end of file
+add_filter = Add filter
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2012-11-08 06:20:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2012-11-08 16:07:27 +0000
@@ -22,7 +22,7 @@
 
 <div>
 	<div id='selectDiv'>
-		<table class='criteriaDiv'>		
+		<table>		
 			<tr>
 				<td><label>$i18n.getString( "registering_unit" )</label></td>
 				<td colspan='2'><input type="text" id='orgunitName' name='orgunitName' #if( $orgunit ) value="$encoder.htmlEncode( $orgunit.name )" #else value="[$i18n.getString( 'please_select_village' )]" #end readonly></td>
@@ -42,36 +42,29 @@
 					</select>
 					<input type='hidden' class='stage-object-selected hidden'>
 				</td>
+				<td>
+					<input type="button" class='large-button' id='addBtn' value='$i18n.getString( "add_new" )' onclick="setFieldValue('isShowEventList', true);showAddEventForm();">
+				</td>
+				<td>
+					<input type="button" id='removeBtn' value='$i18n.getString( "remove_empty_events" )' onclick="removeEmptyEvents();" style="width:140px;">
+				</td>
 			</tr>
 			<tr>
 				<td><label>$i18n.getString('from')</label></td>
-				<td colspan='2'>
-					<input type="text" id='startDate' name='startDate'>
-				</td>
-			</tr>
-			<tr>
-				<td><label>$i18n.getString('to')</label></td>
-				<td colspan='2'>
-					<input type="text" id='endDate' name='endDate'>
-				</td>
-			</tr>
-			<tr>
-				<td></td>
-				<td width="110px">
+				<td>
+					<input type="text" id='startDate' name='startDate' style="width:90px;">
+				</td>
+				<td>
+					<label>$i18n.getString('to')</label>
+					<input type="text" id='endDate' name='endDate' style="width:90px;">
+				</td>
+				<td>
 					<input type="button" class='large-button' id='listBtn' value="$i18n.getString( 'update' )" onclick='validateSearchEvents( true );'>
 				</td>
 				<td>
-					<input type="button" class='large-button' id='addBtn' value='$i18n.getString( "add_new" )' onclick="setFieldValue('isShowEventList', true);showAddEventForm();" style="width:140px;">
-				</td>
-			</tr>
-			<tr>
-				<td></td>
-				<td>
-					<input type="button" class='large-button' id='advancedBtn' value='$i18n.getString( "add_filter" )' onclick="filterDivToogle();" isShown="false">
-				</td>
-				<td>
-					<input type="button" id='removeBtn' value='$i18n.getString( "remove_empty_events" )' onclick="removeEmptyEvents();" style="width:140px;">
-				</td>
+					<input type="button" class='large-button' id='advancedBtn' value='$i18n.getString( "add_filter" )' onclick="filterDivToogle();" isShown="false" style="width:140px;">
+				</td>
+				
 			</tr>
 		</table>
 		

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css	2012-11-08 06:20:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css	2012-11-08 16:07:27 +0000
@@ -101,17 +101,6 @@
 	background-color: #FFCFCF
 }
 
-.criteriaDiv
-{
-  position: relative;
-  border: 1px solid #a4d2a3;
-  background-color: #d5efd5;
-  padding: 5px;
-  margin-bottom: 10px;
-  border-radius: 3px;
-  width:450px;
-}
-
 #advanced-search 
 {
   position: relative;

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/validationResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/validationResult.vm	2012-11-06 15:44:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/validationResult.vm	2012-11-08 16:07:27 +0000
@@ -15,32 +15,31 @@
 		<table class="listTable" id="multiValidation" name="multiValidation" style="width:100%">
 			<thead>
 				<tr>
-					<th>$i18n.getString( "validation_rule" )</th>                
+					<th style="width:110px">$i18n.getString( "validation_rule" )</th>                
+					<th>$i18n.getString( "expression" )</th>
 					<th>$i18n.getString( "description" )</th>
-					<th>$i18n.getString( "left_value" )</th>
-					<th>$i18n.getString( "right_value" )</th>
+					<th>$i18n.getString( "value" )</th>
+					<th>$i18n.getString( "operator" )</th>
+					<th>$i18n.getString( "value" )</th>
 					<th>$i18n.getString( "description" )</th>
 				</tr>
 			</thead>
 			#set( $mark = false )	    
 			<tbody>
-				#foreach( $validationResult in $programValidationResults )
+				#foreach( $result in $programValidationResults )
 					<tr #alternate( $mark )>	    
-						<td>$validationResult.programValidation.description 
-						#if($validationResult.programValidation.dateType=="true")
-							$rightsideFormulaMap.get( $validationResult.programValidation.id )
-						#end
-						</td>
-						<td>$leftsideFormulaMap.get( $validationResult.programValidation.id )</td>
-						<td>$validationResult.leftsideValue</td>
-						#if( $validationResult.programValidation.dateType=="false" 
-							&& $validationResult.programValidation.rightSide!="1==1")
-							<td>$!validationResult.rightsideValue</td>
-							<td>$rightsideFormulaMap.get( $validationResult.programValidation.id )</td>	        
-						#else
-							<td></td>
-							<td></td>
-						#end
+						#set ( $id = $result.programValidation.id )
+						#set ( $leftFormula = $leftsideFormulaMap.get( $id ) )
+						#set ( $rightFormula = $rightsideFormulaMap.get( $id ) )
+						<tr>
+							<td style="height:32px">$encoder.htmlEncode( $result.programValidation.description )</td>
+							<td>$!encoder.htmlEncode( $leftFormula ) $encoder.htmlEncode( $i18n.getString( $result.programValidation.operator.mathematicalOperator ) ) $!encoder.htmlEncode( $rightFormula )</td>
+							<td>$!encoder.htmlEncode( $result.programValidation.leftSide.description )</td>
+							<td>$result.leftsideValue</td>
+							<td>$encoder.htmlEncode( $i18n.getString( $result.programValidation.operator.mathematicalOperator ) )</td>
+							<td>$result.rightsideValue</td>
+							<td>$!encoder.htmlEncode( $result.programValidation.rightSide.description )</td>
+						</tr>
 					#set( $mark = !$mark )
 				#end
 			</tbody>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramValidationAction.java	2012-11-08 13:09:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramValidationAction.java	2012-11-08 16:07:27 +0000
@@ -99,15 +99,14 @@
     {
         this.rightSideExpression = rightSideExpression;
     }
-    
+
     private String rightSideDescription;
 
     public void setRightSideDescription( String rightSideDescription )
     {
         this.rightSideDescription = rightSideDescription;
     }
-    
-    
+
     private Boolean dateType;
 
     public void setDateType( Boolean dateType )
@@ -122,6 +121,11 @@
         this.programId = programId;
     }
 
+    public Integer getProgramId()
+    {
+        return programId;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -132,17 +136,17 @@
     {
         ProgramExpression leftExpression = new ProgramExpression( leftSideExpression, leftSideDescription );
         ProgramExpression rightExpression = new ProgramExpression( rightSideExpression, rightSideDescription );
-        
+
         ProgramValidation validation = new ProgramValidation();
         validation.setDescription( description.trim() );
-        validation.setOperator( Operator.valueOf(operator)  );
+        validation.setOperator( Operator.valueOf( operator ) );
         validation.setLeftSide( leftExpression );
         validation.setRightSide( rightExpression );
         validation.setDateType( dateType );
 
         Program program = programService.getProgram( programId );
         validation.setProgram( program );
-        
+
         programValidationService.addProgramValidation( validation );
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationAction.java	2012-11-08 13:09:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationAction.java	2012-11-08 16:07:27 +0000
@@ -27,6 +27,8 @@
 
 package org.hisp.dhis.patient.action.validation;
 
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramExpressionService;
 import org.hisp.dhis.program.ProgramValidation;
 import org.hisp.dhis.program.ProgramValidationService;
 
@@ -50,6 +52,13 @@
         this.programValidationService = programValidationService;
     }
 
+    private ProgramExpressionService programExpressionService;
+
+    public void setProgramExpressionService( ProgramExpressionService programExpressionService )
+    {
+        this.programExpressionService = programExpressionService;
+    }
+
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -68,6 +77,27 @@
         return validation;
     }
 
+    private String leftSideTextualExpression;
+
+    public String getLeftSideTextualExpression()
+    {
+        return leftSideTextualExpression;
+    }
+
+    private String rightSideTextualExpression;
+
+    public String getRightSideTextualExpression()
+    {
+        return rightSideTextualExpression;
+    }
+
+    private Program program;
+
+    public Program getProgram()
+    {
+        return program;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -78,7 +108,12 @@
     {
         validation = programValidationService.getProgramValidation( validationId );
 
+        leftSideTextualExpression = programExpressionService.getExpressionDescription( validation.getLeftSide().getExpression() );
+        
+        rightSideTextualExpression = programExpressionService.getExpressionDescription( validation.getRightSide().getExpression() );
+        
+        program = validation.getProgram();
+
         return SUCCESS;
     }
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateProgramValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateProgramValidationAction.java	2012-11-08 13:09:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateProgramValidationAction.java	2012-11-08 16:07:27 +0000
@@ -28,6 +28,7 @@
 package org.hisp.dhis.patient.action.validation;
 
 import org.hisp.dhis.expression.Operator;
+import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramExpression;
 import org.hisp.dhis.program.ProgramValidation;
 import org.hisp.dhis.program.ProgramValidationService;
@@ -112,6 +113,25 @@
         this.dateType = dateType;
     }
 
+    private Program program;
+
+    public Program getProgram()
+    {
+        return program;
+    }
+
+    private Integer programId;
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    public Integer getProgramId()
+    {
+        return programId;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -121,7 +141,7 @@
         throws Exception
     {
         ProgramValidation validation = programValidationService.getProgramValidation( id );
-
+        
         ProgramExpression leftExpression = new ProgramExpression( leftSideExpression, leftSideDescription );
         ProgramExpression rightExpression = new ProgramExpression( rightSideExpression, rightSideDescription );
 

=== 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-11-08 13:09:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-11-08 16:07:27 +0000
@@ -856,6 +856,9 @@
 		<property name="programValidationService">
 			<ref bean="org.hisp.dhis.program.ProgramValidationService" />
 		</property>
+		<property name="programExpressionService">
+			<ref bean="org.hisp.dhis.program.ProgramExpressionService" />
+		</property>
 	</bean>
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-11-08 13:09:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-11-08 16:07:27 +0000
@@ -316,4 +316,7 @@
 age_at_visit_days_since_birth = Age at visit (days since birth)
 formula = Formula
 schedule_automated_message_reminder_form = Schedule automated message reminder
-display_in_reports = Display in reports
\ No newline at end of file
+display_in_reports = Display in reports
+edit_left_side = Edit left side
+edit_right_side = Edit right side
+update_program_validation_rule = Edit program validation rule
\ 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/addSingleProgramValidationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addSingleProgramValidationForm.vm	2012-11-08 13:33:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addSingleProgramValidationForm.vm	2012-11-08 16:07:27 +0000
@@ -22,10 +22,10 @@
 		</td>
 	</tr>
 	<tr>
-		<td><label for="operatorId">$encoder.htmlEncode( $i18n.getString( "operator" ) ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+		<td><label>$encoder.htmlEncode( $i18n.getString( "operator" ) ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 		<td>
 			<select id="operator" name="operator">
-				<option value="">[ $i18n.getString( "select_operator" ) ]</option>
+				<option value="">[ $i18n.getString( "please_select" ) ]</option>
 				<option value="equal_to">$encoder.htmlEncode( $i18n.getString( "equal_to" ) )</option>
 				<option value="not_equal_to">$encoder.htmlEncode( $i18n.getString( "not_equal_to" ) )</option>
 				<option value="greater_than">$encoder.htmlEncode( $i18n.getString( "greater_than" ) )</option>
@@ -38,13 +38,13 @@
 	<tr>
 		<td></td>
 		<td>
-			<input type="button" value="$i18n.getString( 'edit_left_side' )" style="width:10em" onclick="editLeftExpression();">
+			<input type="button" value="$i18n.getString( 'edit_left_side' )" onclick="editLeftExpression();">
 			<input type="hidden" id="leftSideDescription" name="leftSideDescription">
 			<input type="hidden" id="leftSideExpression" name="leftSideExpression">
 			<input type="hidden" id="leftSideTextualExpression" name="leftSideTextualExpression">
 			<input type="hidden" id="leftSideNullIfBlank" name="leftSideNullIfBlank">
 			
-			<input type="button" value="$i18n.getString( 'edit_right_side' )" style="width:10em" onclick="editRightExpression();"></td>
+			<input type="button" value="$i18n.getString( 'edit_right_side' )" onclick="editRightExpression();"></td>
 			<input type="hidden" id="rightSideDescription" name="rightSideDescription">
 			<input type="hidden" id="rightSideExpression" name="rightSideExpression">
 			<input type="hidden" id="rightSideTextualExpression" name="rightSideTextualExpression">

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/expressionBuilderForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/expressionBuilderForm.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/expressionBuilderForm.vm	2012-11-08 16:07:27 +0000
@@ -0,0 +1,71 @@
+<script type="text/javascript">
+	jQuery('#expression-container').ready(	function(){
+		validation( 'expression-form', function(form){
+				insertExpression();
+			}); 
+	});
+		
+	var i18n_description_not_null = '$encoder.jsEscape( $i18n.getString( "description_not_null" ) , "'")';
+	var i18n_expression_not_null = '$encoder.jsEscape( $i18n.getString( "expression_not_null" ) , "'")';
+	var i18n_no_constant_to_select = '$encoder.jsEscape( $i18n.getString( "no_constant_to_select" ) , "'")';
+</script>
+
+<div id="expression-container" class="page">
+	<form id="expression-form" name="expression-form" method="post">
+		<table>
+			<tr>
+				<th>$i18n.getString( "description" ) <em title="$i18n.getString( "required" )" class="required">*</em></th>
+				<th>$i18n.getString("program_stage")</th>
+			</tr>
+			<tr>
+				<td>
+					<input type="text" id="description" name="description" class="{validate:{required:true}}"/><br>
+					<span id="exp-descriptionInfo" generated="true" class="error"></span>
+				</td>
+				<td>
+					<select id='leftStage' name='leftStage' onchange="getLeftPrgramStageDataElements();" style='width:320px;'>
+						<option value=''>[$i18n.getString( "please_select" )]</option>
+						#foreach($stage in $program.programStages)
+						<option value='$stage.id'>$stage.name</option>
+						#end
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2"></td>
+			</tr>
+			<tr>
+				<th>$i18n.getString( "expression" ) <em title="$i18n.getString( "required" )" class="required">*</em></th>
+				<th>$i18n.getString( "available_data_elements" )</th>
+			</tr>
+			<tr>
+				<td>
+					<textarea id="expression" name="expression" style="width:316px;height:138px" wrap="virtual" onchange="getExpressionText()" class="{validate:{required:true}}"></textarea><br/>
+					<span id="exp-expressionInfo" generated="true" class="error"></span>
+				</td>
+				<td valign="top">
+					<input type="text" id="filter" name="filter" style="width:150px" placeholder="$i18n.getString('filter')">
+					<input type="button" value="$i18n.getString( 'filter' )" onclick="getOperandsPage()" style="width:80px">
+					<input type="button" value="$i18n.getString( 'clear' )" onclick="clearSearchText();" style="width:80px"><br/>
+
+					<select id="dataElementId" name="dataElementId" size="8" ondblclick="insertText( 'expression', this.value )"></select>
+				</td>
+			</tr>
+			<tr>
+				<th colspan="2">$i18n.getString( "description" )</th>		
+			</tr>
+			<tr>
+				<td colspan="2"><div id="formulaText" style="width:740px;height:100px;overflow:auto"></div></td>
+			</tr>
+			<tr>
+				<td colspan="2"></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="$i18n.getString( 'save' )" onclick="validateExpression();"/>
+					<input type="button" value="$i18n.getString( 'cancel' )" onclick="dialog.dialog('close')"/>
+				</td>
+			</tr>	
+		</table>
+	</form>
+</div>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js	2012-11-08 13:33:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js	2012-11-08 16:07:27 +0000
@@ -213,9 +213,13 @@
 	left = true;
 	
 	$( '#expression' ).val( $( '#leftSideExpression' ).val() );
-	$( '#description' ).val( $( '#leftSideDescription' ).val() );
+	$( '#expression-container [id=description]' ).val( $( '#leftSideDescription' ).val() );
 	$( '#formulaText' ).text( $( '#leftSideTextualExpression' ).val() );
 	$( '#nullIfBlank' ).attr( 'checked', ( $( '#leftSideNullIfBlank' ).val() == 'true' || $( '#leftSideNullIfBlank' ).val() == '' ) );
+	setInnerHTML( "exp-descriptionInfo", "" );
+	setInnerHTML( "exp-expressionInfo", "" );
+	$("#expression-container [id=description]" ).css( "background-color", "#ffffff" );
+	$("#expression-container [id=expression]" ).css( "background-color", "#ffffff" );
 	
 	dialog.dialog("open");
 }
@@ -225,7 +229,7 @@
 	left = false;
 	
 	$( '#expression' ).val( $( '#rightSideExpression' ).val() );
-	$( '#description' ).val( $( '#rightSideDescription' ).val() );
+	$( '#expression-container [id=description]' ).val( $( '#rightSideDescription' ).val() );
 	$( '#formulaText' ).text( $( '#rightSideTextualExpression' ).val() );
 	$( '#nullIfBlank' ).attr( 'checked', ( $( '#rightSideNullIfBlank' ).val() == 'true' || $( '#rightSideNullIfBlank' ).val() == '' ) );
 	
@@ -260,20 +264,47 @@
 function insertExpression()
 {
 	var expression = $( '#expression' ).val();
-	var description = $( '#description' ).val();
+	var description = $( '#expression-container [id=description]' ).val();
 							
 	if ( left )
 	{
 		$( '#leftSideExpression' ).val( expression );
 		$( '#leftSideDescription' ).val( description );					
 		$( '#leftSideTextualExpression' ).val( $( '#formulaText' ).text() );
+		$( '#leftSideNullIfBlank' ).val( $( '#nullIfBlank' ).is( ':checked' ) );
 	}
 	else
 	{
 		$( '#rightSideExpression' ).val( expression );
 		$( '#rightSideDescription' ).val( description );					
 		$( '#rightSideTextualExpression' ).val( $( '#formulaText' ).text() );
+		$( '#rightSideNullIfBlank' ).val( $( '#nullIfBlank' ).is( ':checked' ) );								
 	}
 	
 	dialog.dialog( "close" );
 }
+
+function validateExpression()
+{
+    if ( checkNotEmpty( jQuery( "#expression-container [id=description]" ), i18n_description_not_null ) == false )
+        return;
+    if ( checkNotEmpty( jQuery( "#expression-container [id=expression]" ), i18n_expression_not_null ) == false )
+        return;
+	insertExpression();
+}
+
+function checkNotEmpty( field, message )
+{
+    if ( field.val().length == 0 )
+    {
+        setInnerHTML( "exp-" + field.attr("name") + "Info", message );
+        $('#expression-container [id=' + field.attr("name") + "]" ).css( "background-color", "#ffc5c5" );
+        return false;
+    } else
+    {
+        setInnerHTML( "exp-" + field.attr("name") + "Info", '' );
+        $('#expression-container [id=' + field.attr("name") + "]" ).css( "background-color", "#ffffff" );
+    }
+
+    return true;
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm	2012-11-08 13:33:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm	2012-11-08 16:07:27 +0000
@@ -45,12 +45,9 @@
 					
 					<td onclick="showProgramValidationDetails( $validation.id )">$validation.description</td>
 					<td>
-						#if($validation.rightSide=="1==1")
-							<a href="showUpdateSingleProgramValidationForm.action?validationId=$validation.id&id=$program.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
-						#else
-							<a href="showUpdateMultiProgramValidationForm.action?validationId=$validation.id&id=$program.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
-						#end
-					  <a href="javascript:removeProgramValidation( '$validation.id', '$encoder.jsEncode( $validation.description )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+						<a href="showUpdateSingleProgramValidationForm.action?validationId=$validation.id&id=$program.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
+						<!-- a href="showUpdateMultiProgramValidationForm.action?validationId=$validation.id&id=$program.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a -->
+						<a href="javascript:removeProgramValidation( '$validation.id', '$encoder.jsEncode( $validation.description )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
 					  <a href="javascript:showProgramValidationDetails( $validation.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
 					</td>
 				  </tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateSingleProgramValidationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateSingleProgramValidationForm.vm	2012-11-07 04:33:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateSingleProgramValidationForm.vm	2012-11-08 16:07:27 +0000
@@ -1,83 +1,78 @@
-<h3>$i18n.getString( "edit_program_validation_rule" )</h3>
+<h3>$i18n.getString( "update_program_validation_rule" )</h3>
 
 <h4>$validation.program.name</h4>
 
 <form id='programValidationForm' name='programValidationForm' method='post' action='updateProgramValidation.action'>
 
 <input type='hidden' id='id' name='id' value='$validation.id'>
+<input type='hidden' id='programId' name='programId' value='$validation.program.id'>
+<input type='hidden' id='dateType' name='dateType' value='$validation.dateType'>
 <table>
-	
 	<thead>
       <tr>
-        <th colspan="2">$i18n.getString( "program_validation_rule_details" )</th>
+        <th colspan='2'>$i18n.getString( "program_validation_rule_details" )</th>
       </tr>
     </thead>
-    <tbody>
+    
+	<tbody>
 	
 	<tr>
-		<td>
-			<label>$i18n.getString('name') <em title="$i18n.getString( "required" )" class="required">*</em></label>
-		</td>
-		<td colspan='2'>			
-			<input type="text" id='description' name='description' value='$validation.description' class="{validate:{required:true,minlength:4}}">
-		</td>
-	</tr>
-	<tr>
-		<td><label>$i18n.getString("program_stage")</label></td>
-		<td>
-			<select id='leftStage' name='leftStage' onchange="getLeftPrgramStageDataElements();">
-				<option value=''>[$i18n.getString( "please_select" )]</option>
-				#foreach($stage in $validation.program.programStages)
-				<option value='$stage.id'>$stage.name</option>
-				#end
-			</select>
-		</td>
-	</tr>
-	<tr>
-		<td>$i18n.getString("data_elements")</td>
-		<td>
-			<select id='leftSideDE' name='leftSideDE' size='7' ondblclick="insertDataElement(this, 'leftSide', 'leftStageDescription');">
+		<td><label>$i18n.getString('name') <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+		<td>			
+			<input type="text" id='description' name='description' class="{validate:{required:true,minlength:4}}" value="$validation.description" >
+		</td>
+	</tr>
+	<tr>
+		<td><label>$encoder.htmlEncode( $i18n.getString( "operator" ) ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+		<td>
+			<select id="operator" name="operator" class="{validate:{required:true}}">
+				<option value="">[ $i18n.getString( "please_select" ) ]</option>
+				<option value="equal_to" #if ( $validation.operator == 'equal_to' )selected="selected"#end>$encoder.htmlEncode( $i18n.getString( "equal_to" ) )</option>
+				<option value="not_equal_to" #if ( $validation.operator == 'not_equal_to' )selected="selected"#end>$encoder.htmlEncode( $i18n.getString( "not_equal_to" ) )</option>
+				<option value="greater_than" #if ( $validation.operator == 'greater_than' )selected="selected"#end>$encoder.htmlEncode( $i18n.getString( "greater_than" ) )</option>
+				<option value="greater_than_or_equal_to" #if ( $validation.operator == 'greater_than_or_equal_to' )selected="selected"#end>$encoder.htmlEncode( $i18n.getString( "greater_than_or_equal_to" ) )</option>
+				<option value="less_than" #if ( $validation.operator == 'less_than' )selected="selected"#end>$encoder.htmlEncode( $i18n.getString( "less_than" ) )</option>
+				<option value="less_than_or_equal_to" #if ( $validation.operator == 'less_than_or_equal_to' )selected="selected"#end>$encoder.htmlEncode( $i18n.getString( "less_than_or_equal_to" ) )</option>			
 			</select>
 		</td>
 	</tr>
 	<tr>
 		<td></td>
 		<td>
-			<input type='button' value="+" title="$i18n.getString( 'plus' )" onclick='insertOperator( "leftStageDescription", "leftSide", "+" );' class="small-button" >
-			&nbsp;&nbsp;
-			<input type='button' value="<" title="$i18n.getString( 'less_then' )" onclick='insertOperator( "leftStageDescription", "leftSide", "<" );' class="small-button" />
-			<input type='button' value="<=" title="$i18n.getString( 'less_then_or_equal_to' )" onclick='insertOperator( "leftStageDescription", "leftSide", "<=" );' class="small-button" />
-			<input type='button' value=">" title="$i18n.getString( 'greater_then' )" onclick='insertOperator( "leftStageDescription", "leftSide", ">" );' class="small-button" />
-			<input type='button' value=">=" title="$i18n.getString( 'greater_then_or_equal_to' )" onclick='insertOperator( "leftStageDescription", "leftSide", ">=" );' class="small-button" />
-			<input type='button' value="=" title="$i18n.getString( 'equals_to' )" onclick='insertOperator( "leftStageDescription", "leftSide", "==" );' class="small-button" />
-			<input type='button' value="!=" title="$i18n.getString( 'diff_from' )" onclick='insertOperator( "leftStageDescription", "leftSide", "!=" );' class="small-button"/>
-			<input type='button' value="!=NULL" title="$i18n.getString( 'not_null' )" onclick='insertOperator( "leftStageDescription", "leftSide", "=={NOT-NULL-VALUE}" );' class="nornal-button" />
-			&nbsp;&nbsp;
-			<input type='button' value="$i18n.getString( 'clear' )" title="$i18n.getString( 'clear' )" align='right'  onclick="clearValidation( 'leftSide', 'leftStageDescription' )" style="width:45px;" />
-		</td>
-	</tr>
-	<tr>
-		<td><label>$i18n.getString("formula") <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-		<td>
-			<textarea rows='5' id='leftSide' name='leftSide' onkeyup="getValidationDescription('leftStageDescription', 'leftSide')" style='width:320px;' class="{validate:{required:true,minlength:4}}">$validation.leftSide</textarea>
-			<input type='hidden' id='rightSide' name='rightSide' value='1==1'>
-		</td>
-	</tr>
-	<tr>	
-		<td><label>$i18n.getString("description")</label></td>
-		<td>
-			<fieldset style='width:300px;'>
-				<div id='leftStageDescription' style='width:300px;'>$!leftDescription</div>
-			</fieldset>
+			<input type="button" value="$i18n.getString( 'edit_left_side' )" onclick="editLeftExpression();">
+			<input type="hidden" id="leftSideDescription" name="leftSideDescription" value="$!validation.leftSide.description">
+			<input type="hidden" id="leftSideExpression" name="leftSideExpression" value="$!validation.leftSide.expression">
+			<input type="hidden" id="leftSideTextualExpression" name="leftSideTextualExpression" value="$!leftSideTextualExpression">
+			<input type="hidden" id="leftSideNullIfBlank" name="leftSideNullIfBlank" value="$!validation.leftSide.nullIfBlank">
+			
+			<input type="button" value="$i18n.getString( 'edit_right_side' )" onclick="editRightExpression();">
+			<input type="hidden" id="rightSideDescription" name="rightSideDescription" value="$!validation.rightSide.description">
+			<input type="hidden" id="rightSideExpression" name="rightSideExpression" value="$!validation.rightSide.expression">
+			<input type="hidden" id="rightSideTextualExpression" name="rightSideTextualExpression" value="$!rightSideTextualExpression">
+			<input type="hidden" id="rightSideNullIfBlank" name="rightSideNullIfBlank" value="$!validation.rightSide.nullIfBlank">
+		</td>
 		</td>
 	</tr>
 	<tr>
 		<td></td>
 		<td>
 			<input type='submit' value="$i18n.getString( 'update' )" >
-			<input type='button' value="$i18n.getString( 'cancel' )" onclick="window.location.href='programValidation.action?programId=$validation.program.id'">
+			<input type='button' value="$i18n.getString( 'cancel' )" onclick="window.location.href='programValidation.action?programId=$program.id'">
 		</td>
-		<td></td>
 	</tr>
-	
 </table>
+
+#parse( "/dhis-web-maintenance-patient/expressionBuilderForm.vm" )
+
+</form>
+
+<script>
+	hideById( "expression-container" );
+	var dialog = jQuery( "#expression-container" ).dialog({
+		modal: true,
+		autoOpen: false,
+		width: 780,
+		height: 500,
+		title: "Expression"
+	});
+</script>