← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8957: Improve program validation rule.

 

------------------------------------------------------------
revno: 8957
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-11-09 11:05:20 +0700
message:
  Improve program validation rule.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramExpression.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramExpressionService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramExpressionService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java
  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/expressionBuilderForm.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-api/src/main/java/org/hisp/dhis/program/ProgramExpression.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramExpression.java	2012-11-08 13:33:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramExpression.java	2012-11-09 04:05:20 +0000
@@ -47,24 +47,9 @@
     public static final String SEPARATOR_OBJECT = ":";
     
 
-    public static final int BEFORE_CURRENT_DATE = 1;
-
-    public static final int BEFORE_OR_EQUALS_TO_CURRENT_DATE = 2;
-
-    public static final int AFTER_CURRENT_DATE = 3;
-
-    public static final int AFTER_OR_EQUALS_TO_CURRENT_DATE = 4;
-    
-
-    public static final int BEFORE_DUE_DATE = -1;
-
-    public static final int BEFORE_OR_EQUALS_TO_DUE_DATE = -2;
-
-    public static final int AFTER_DUE_DATE = -3;
-
-    public static final int AFTER_OR_EQUALS_TO_DUE_DATE = -4;
-    
-    public static final int BEFORE_DUE_DATE_PLUS_OR_MINUS_MAX_DAYS = -5;
+    public static final String DUE_DATE = "DUE_DATE";
+
+    public static final String RANGE_IN_DUE_DATE = "RANGE_IN_DUE_DATE";
     
     public static final String NOT_NULL_VALUE_IN_EXPRESSION = "NOT-NULL-VALUE";
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramExpressionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramExpressionService.java	2012-11-08 13:33:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramExpressionService.java	2012-11-09 04:05:20 +0000
@@ -29,6 +29,8 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.i18n.I18nFormat;
+
 
 /**
  * @author Chau Thu Tran
@@ -49,7 +51,7 @@
     
     Collection<ProgramExpression> getAllProgramExpressions();
     
-    String getProgramExpressionValue( ProgramExpression programExpression, ProgramStageInstance programStageInstance );
+    String getProgramExpressionValue( ProgramExpression programExpression, ProgramStageInstance programStageInstance, I18nFormat format );
     
     String getExpressionDescription( String programExpression );
     

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramExpressionService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramExpressionService.java	2012-11-08 13:33:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramExpressionService.java	2012-11-09 04:05:20 +0000
@@ -38,6 +38,7 @@
 import org.hisp.dhis.common.GenericStore;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.springframework.transaction.annotation.Transactional;
@@ -53,7 +54,7 @@
 {
     private final String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+["
         + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
-    
+
     private final String INVALID_CONDITION = "Invalid condition";
 
     // -------------------------------------------------------------------------
@@ -124,8 +125,15 @@
 
     @Override
     public String getProgramExpressionValue( ProgramExpression programExpression,
-        ProgramStageInstance programStageInstance )
+        ProgramStageInstance programStageInstance, I18nFormat format )
     {
+        String value = "";
+        if( ProgramExpression.DUE_DATE.equals( programExpression.getExpression()))
+        {
+            value = format.formatDate( programStageInstance.getDueDate() );
+        }
+        else
+        {
         StringBuffer description = new StringBuffer();
 
         Pattern pattern = Pattern.compile( regExp );
@@ -145,8 +153,10 @@
         }
 
         matcher.appendTail( description );
-
-        return description.toString();
+        value = description.toString();
+        }
+        return value;
+        
     }
 
     @Override

=== 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-09 03:14:42 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2012-11-09 04:05:20 +0000
@@ -126,9 +126,9 @@
         if ( !validation.getDateType() )
         {
             String leftSideValue = expressionService.getProgramExpressionValue( validation.getLeftSide(),
-                programStageInstance );
+                programStageInstance, format );
             String rightSideValue = expressionService.getProgramExpressionValue( validation.getRightSide(),
-                programStageInstance );
+                programStageInstance, format );
             String operator = validation.getOperator().getMathematicalOperator();
             
             if ( (leftSideValue != null && rightSideValue.equals( NOT_NULL_VALUE_IN_EXPRESSION ) && rightSideValue == null)

=== 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 16:19:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-11-09 04:05:20 +0000
@@ -1,10 +1,9 @@
 groupBy=Group by
-equal_to=Equal
-greater_than=Greater than
-greater_than_or_equal_to=Greater than or equal
-less_than=Less than
-less_than_or_equal_to=Less than or equal
-in_between=In between
+equal_to= =
+greater_than=>
+greater_than_or_equal_to= >=
+less_than=<
+less_than_or_equal_to=<=
 is_equal_to_patient_domain=Is equal to person domain
 group=Group
 duplicate_names=Name is already in use
@@ -321,4 +320,5 @@
 edit_right_side = Edit right side
 update_program_validation_rule = Edit program validation rule
 description_not_null = Description is not null
-expression_not_null = Expression is not null
\ No newline at end of file
+expression_not_null = Expression is not null
+range_in_due_date = Range in due date
\ 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/expressionBuilderForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/expressionBuilderForm.vm	2012-11-08 16:19:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/expressionBuilderForm.vm	2012-11-09 04:05:20 +0000
@@ -39,16 +39,20 @@
 				<th>$i18n.getString( "available_data_elements" )</th>
 			</tr>
 			<tr>
-				<td>
+				<td rowspan='2'>
 					<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')" onkeyup="filterList( this.value, 'dataElementId' )" {>
-					<input type="button" value="$i18n.getString( 'filter' )" onclick="getOperandsPage()" style="width:80px">
+					<input type="text" id="filter" name="filter" style="width:240px" placeholder="$i18n.getString('filter')" onkeyup="filterList( this.value, 'dataElementId' )" {>
 					<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>
+					<select id="dataElementId" name="dataElementId" size="8" ondblclick="insertText( 'expression', this.value )" style="height:100px"></select>
+				</td>
+			</tr>
+			<tr>
+				<td>
+					<input type="button" value="$i18n.getString('due_date')" onclick="insertText( 'expression', 'DUE_DATE' )">
 				</td>
 			</tr>
 			<tr>