dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19941
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8914: Minor fix for program validation rules.
------------------------------------------------------------
revno: 8914
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-11-06 22:55:46 +0700
message:
Minor fix for program validation rules.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java
--
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/program/DefaultProgramValidationService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java 2012-11-06 15:44:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java 2012-11-06 15:55:46 +0000
@@ -160,7 +160,7 @@
}
}
}
-
+
return null;
}
@@ -218,6 +218,7 @@
Date currentDate = dataValue.getTimestamp();
Date value = format.parseDate( dataValue.getValue() );
String operator = "";
+ int daysValue = 0;
int index = rightSide.indexOf( 'D' );
if ( index < 0 )
@@ -262,21 +263,30 @@
valid = (value.after( dueDate ) || value.equals( dueDate ));
break;
default:
- rightValidation = Integer.parseInt( rightSide.substring( 0, index ) );
- int daysValue = Integer.parseInt( rightSide.substring( index + 1, rightSide.length() ) );
- if ( rightValidation == BEFORE_DUE_DATE_PLUS_OR_MINUS_MAX_DAYS )
- {
- long maxDays = dueDate.getTime() / 86400000 + daysValue;
- long minDays = dueDate.getTime() / 86400000 - daysValue;
- long valueDays = value.getTime() / 86400000;
- valid = (valueDays <= maxDays && valueDays >= minDays);
- }
break;
}
}
+ else
+ {
+ int rightValidation = Integer.parseInt( rightSide.substring( 0, index ) );
+ daysValue = Integer.parseInt( rightSide.substring( index + 1, rightSide.length() ) );
+ if ( rightValidation == BEFORE_DUE_DATE_PLUS_OR_MINUS_MAX_DAYS )
+ {
+ long maxDays = dueDate.getTime() / 86400000 + daysValue;
+ long minDays = dueDate.getTime() / 86400000 - daysValue;
+ long valueDays = value.getTime() / 86400000;
+ valid = (valueDays <= maxDays && valueDays >= minDays);
+ operator = "=";
+ }
+ }
+
if ( !valid )
{
String result = dataValue.getValue() + " " + operator + " " + format.formatDate( currentDate );
+ if( daysValue!=0 )
+ {
+ result += " +/- " + daysValue;
+ }
return new ProgramValidationResult( programStageInstance, programValidation, result, null );
}
}
@@ -409,13 +419,13 @@
else if ( leftSideValue != null
&& rightSideValue != null
&& ((comparetor.equals( "==" ) && leftSideValue.equals( rightSideValue ))
- || (comparetor.equals( "<" ) && leftSideValue.compareTo( rightSideValue ) < 0)
- || (comparetor.equals( "<=" ) && (leftSideValue.equals( rightSideValue ) || leftSideValue
- .compareTo( rightSideValue ) < 0))
- || (comparetor.equals( ">" ) && leftSideValue.compareTo( rightSideValue ) > 0)
- || (comparetor.equals( ">=" ) && (leftSideValue.equals( rightSideValue ) || leftSideValue
- .compareTo( rightSideValue ) > 0))
- || (comparetor.equals( "!=" ) && !leftSideValue.equals( rightSideValue )) ))
+ || (comparetor.equals( "<" ) && leftSideValue.compareTo( rightSideValue ) < 0)
+ || (comparetor.equals( "<=" ) && (leftSideValue.equals( rightSideValue ) || leftSideValue
+ .compareTo( rightSideValue ) < 0))
+ || (comparetor.equals( ">" ) && leftSideValue.compareTo( rightSideValue ) > 0)
+ || (comparetor.equals( ">=" ) && (leftSideValue.equals( rightSideValue ) || leftSideValue
+ .compareTo( rightSideValue ) > 0)) || (comparetor.equals( "!=" ) && !leftSideValue
+ .equals( rightSideValue ))) )
{
valid = true;
}
@@ -424,7 +434,7 @@
valid = false;
}
}
-System.out.println("\n\n === \n " + valid + SEPARATE_SIDE_VALUE + leftSideValue + " " + comparetor + " " + rightSideValue );
+
return valid + SEPARATE_SIDE_VALUE + leftSideValue + " " + comparetor + " " + rightSideValue;
}