=== 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 07:09:13 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java 2012-11-06 08:39:16 +0000 @@ -67,7 +67,7 @@ + SEPARATOR_ID + "[0-9]*]*)" + "\\]"; private final String regExpComparator = "(<=|>=|==|!=|<|>|>)+"; - + private final String SEPARATE_SIDE_VALUE = "&&"; private final String INVALID_CONDITION = "Invalid condition"; @@ -145,17 +145,18 @@ { String resultLeft = runExpression( validation.getLeftSide(), programStageInstance ); String resultRight = runExpression( validation.getRightSide(), programStageInstance ); + if ( resultLeft != null && resultRight != null ) + { + boolean validLeftSide = Boolean.parseBoolean( resultLeft.split( SEPARATE_SIDE_VALUE )[0] ); + boolean validRightSide = Boolean.parseBoolean( resultRight.split( SEPARATE_SIDE_VALUE )[0] ); + if ( validLeftSide != validRightSide ) + { + return new ProgramValidationResult( programStageInstance, validation, + resultLeft.split( SEPARATE_SIDE_VALUE )[1], resultRight.split( SEPARATE_SIDE_VALUE )[1] ); + } + } - boolean validLeftSide = Boolean.parseBoolean( resultLeft.split( SEPARATE_SIDE_VALUE )[0] ); - boolean validRightSide = Boolean.parseBoolean( resultRight.split( SEPARATE_SIDE_VALUE )[0] ); - if ( validLeftSide == validRightSide ) - { - return null; - } - else - { - return new ProgramValidationResult( programStageInstance, validation, resultLeft.split( SEPARATE_SIDE_VALUE )[1], resultRight.split( SEPARATE_SIDE_VALUE )[1] ); - } + return null; } return runDateExpression( validation, programStageInstance, format ); @@ -356,7 +357,7 @@ } matcher.appendReplacement( description, programStage.getName() + SEPARATOR_ID + dataElement.getName() ); - + } matcher.appendTail( description ); @@ -385,26 +386,29 @@ String[] sides = expression.split( regExpComparator ); String leftSideValue = getOneSideExpressionValue( sides[0].trim(), programStageInstance ); - String rightSideValue = getOneSideExpressionValue( sides[1].trim(), programStageInstance ); - if ( leftSideValue == null || rightSideValue == null ) - { - return null; - } + String rightSideValue = getOneSideExpressionValue( sides[1].trim(), programStageInstance ); - if ( expression.indexOf( SUM_OPERATOR_IN_EXPRESSION ) != -1 ) - { - String result = leftSideValue + comparetor + rightSideValue; - final JEP parser = new JEP(); - parser.parseExpression( result ); - valid = (parser.getValue() == 1.0); + if( leftSideValue==null && rightSideValue== null ) + { + return "false&& "; + } + else if ( expression.indexOf( SUM_OPERATOR_IN_EXPRESSION ) != -1 ) + { + if ( leftSideValue != null && rightSideValue != null ) + { + String result = leftSideValue + comparetor + rightSideValue; + final JEP parser = new JEP(); + parser.parseExpression( result ); + valid = (parser.getValue() == 1.0); + } } else { - if ( rightSideValue.equals( NOT_NULL_VALUE_IN_EXPRESSION ) ) + if ( rightSideValue!= null && rightSideValue.equals( NOT_NULL_VALUE_IN_EXPRESSION ) ) { - valid = !( leftSideValue == null ); + valid = !(leftSideValue == null); } - else if ( (comparetor.equals( "==" ) && leftSideValue.equals( rightSideValue )) + 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)) === 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-06 07:09:13 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java 2012-11-06 08:39:16 +0000 @@ -42,17 +42,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import org.hisp.dhis.caseentry.state.SelectedStateManager; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.patientdatavalue.PatientDataValue; -import org.hisp.dhis.patientdatavalue.PatientDataValueService; -import org.hisp.dhis.program.ProgramInstance; -import org.hisp.dhis.program.ProgramStage; -import org.hisp.dhis.program.ProgramStageDataElement; import org.hisp.dhis.program.ProgramStageInstance; import org.hisp.dhis.program.ProgramValidation; import org.hisp.dhis.program.ProgramValidationResult; @@ -73,8 +67,6 @@ private SelectedStateManager selectedStateManager; - private PatientDataValueService patientDataValueService; - private ProgramValidationService programValidationService; // ------------------------------------------------------------------------- @@ -131,11 +123,6 @@ this.programValidationService = programValidationService; } - public void setPatientDataValueService( PatientDataValueService patientDataValueService ) - { - this.patientDataValueService = patientDataValueService; - } - public Map getResultDEMultiStages() { return resultDEMultiStages; @@ -163,22 +150,7 @@ // --------------------------------------------------------------------- ProgramStageInstance programStageInstance = selectedStateManager.getSelectedProgramStageInstance(); - - ProgramStage programStage = programStageInstance.getProgramStage(); - - // --------------------------------------------------------------------- - // Get selected objects - // --------------------------------------------------------------------- - - Set dataElements = programStage.getProgramStageDataElements(); - - for ( ProgramStageDataElement psDataElement : dataElements ) - { - DataElement dataElement = psDataElement.getDataElement(); - - checkDataElementInMultiStage( programStageInstance, dataElement ); - } - + // --------------------------------------------------------------------- // Check validations for dataelement into multi-stages // --------------------------------------------------------------------- @@ -193,45 +165,6 @@ // Support method // ------------------------------------------------------------------------- - /** - * ------------------------------------------------------------------------ - * // Check value of the dataElment into previous. // If the value - * exists,allow users to enter data of // the dataElement into the - * programStageInstance // Else, disable Input-field of the dataElement - * ------------------------------------------------------------------------ - **/ - - private void checkDataElementInMultiStage( ProgramStageInstance programStageInstance, DataElement dataElement ) - { - ProgramInstance programInstance = programStageInstance.getProgramInstance(); - List pogramStageInstances = new ArrayList( - programInstance.getProgramStageInstances() ); - - int index=0; - for ( index=0; index 0 ) - { - ProgramStageInstance prevStageInstance = pogramStageInstances.get( index ); - PatientDataValue prevValue = patientDataValueService.getPatientDataValue( prevStageInstance, dataElement ); - if ( prevValue == null ) - { - String message = i18n.getString( "selected" ) + " " + i18n.getString( "program_stage" ) + " " - + i18n.getString( "should" ) + " " + i18n.getString( "data_value" ) + " " - + i18n.getString( "is_null" ); - - resultDEMultiStages.put( dataElement, message ); - } - } - - } - private void runProgramValidation( Collection validations, ProgramStageInstance programStageInstance ) { === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-11-02 04:25:31 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-11-06 08:39:16 +0000 @@ -321,8 +321,6 @@ scope="prototype"> - === 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-06 07:09:13 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-11-06 08:39:16 +0000 @@ -95,7 +95,7 @@ data_value=data value successful_validation=The data entry screen successfully passed validation unsuccessful_validation=The data entry screen has validation errors, please correct these before proceeding -the_following_dataelements_are_in_multi_stages=The following data elements are in multi-program stages +the_following_dataelements_are_in_predefined_validate_rules=The following data elements are in pre-define validation rules validation_result=Validation Result should=should run_validation=Run validation === 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 07:09:13 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/validationResult.vm 2012-11-06 08:39:16 +0000 @@ -10,31 +10,32 @@

$encoder.htmlEncode( $i18n.getString( "successful_validation" ) )

#else

$encoder.htmlEncode( $i18n.getString( "unsuccessful_validation" ) )

- -

$encoder.htmlEncode( $i18n.getString( "the_following_dataelements_are_in_multi_stages" ) )

- - - - - - - - - - - #set( $mark = false ) - - #foreach( $validationResult in $programValidationResults ) - - - - - #if( $validationResult.programValidation.rightSide!="1==1") - - - #end - #set( $mark = !$mark ) - #end - -
$i18n.getString( "validation_rule" )$i18n.getString( "description" )$i18n.getString( "left_value" )$i18n.getString( "right_value" )$i18n.getString( "description" )
$validationResult.programValidation.description$leftsideFormulaMap.get( $validationResult.programValidation.id )$validationResult.leftsideValue$validationResult.rightsideValue$rightsideFormulaMap.get( $validationResult.programValidation.id )
+ #if($programValidationResults.size()>0 ) +

$encoder.htmlEncode( $i18n.getString( "the_following_dataelements_are_in_predefined_validate_rules" ) )

+ + + + + + + + + + + #set( $mark = false ) + + #foreach( $validationResult in $programValidationResults ) + + + + + #if( $validationResult.programValidation.rightSide!="1==1") + + + #end + #set( $mark = !$mark ) + #end + +
$i18n.getString( "validation_rule" )$i18n.getString( "description" )$i18n.getString( "left_value" )$i18n.getString( "right_value" )$i18n.getString( "description" )
$validationResult.programValidation.description$leftsideFormulaMap.get( $validationResult.programValidation.id )$validationResult.leftsideValue$validationResult.rightsideValue$rightsideFormulaMap.get( $validationResult.programValidation.id )
+ #end #end \ No newline at end of file