dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19924
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8898: Removed unused methods to check patient data values of each data element in multi-stages when to ...
------------------------------------------------------------
revno: 8898
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-11-06 15:39:16 +0700
message:
Removed unused methods to check patient data values of each data element in multi-stages when to click Validation Rule button.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java
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/META-INF/dhis/beans.xml
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/validationResult.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/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<DataElement, String> getResultDEMultiStages()
{
return resultDEMultiStages;
@@ -163,22 +150,7 @@
// ---------------------------------------------------------------------
ProgramStageInstance programStageInstance = selectedStateManager.getSelectedProgramStageInstance();
-
- ProgramStage programStage = programStageInstance.getProgramStage();
-
- // ---------------------------------------------------------------------
- // Get selected objects
- // ---------------------------------------------------------------------
-
- Set<ProgramStageDataElement> 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<ProgramStageInstance> pogramStageInstances = new ArrayList<ProgramStageInstance>(
- programInstance.getProgramStageInstances() );
-
- int index=0;
- for ( index=0; index<pogramStageInstances.size(); index++ )
- {
- if ( programStageInstance.equals( pogramStageInstances.get( index ) ) )
- {
- break;
- }
- }
-
- if ( 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<ProgramValidation> 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">
<property name="selectedStateManager"
ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
- <property name="patientDataValueService"
- ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
<property name="programValidationService"
ref="org.hisp.dhis.program.ProgramValidationService" />
</bean>
=== 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 @@
<p class="bold">$encoder.htmlEncode( $i18n.getString( "successful_validation" ) )</p>
#else
<p class="bold">$encoder.htmlEncode( $i18n.getString( "unsuccessful_validation" ) )</p>
-
- <p class="bold">$encoder.htmlEncode( $i18n.getString( "the_following_dataelements_are_in_multi_stages" ) )</p>
- <table class="listTable" id="multiValidation" name="multiValidation" style="width:100%">
- <thead>
- <tr>
- <th>$i18n.getString( "validation_rule" )</th>
- <th>$i18n.getString( "description" )</th>
- <th>$i18n.getString( "left_value" )</th>
- <th>$i18n.getString( "right_value" )</th>
- <th>$i18n.getString( "description" )</th>
- </tr>
- </thead>
- #set( $mark = false )
- <tbody>
- #foreach( $validationResult in $programValidationResults )
- <tr #alternate( $mark )>
- <td>$validationResult.programValidation.description</td>
- <td>$leftsideFormulaMap.get( $validationResult.programValidation.id )</td>
- <td>$validationResult.leftsideValue</td>
- #if( $validationResult.programValidation.rightSide!="1==1")
- <td>$validationResult.rightsideValue</td>
- <td>$rightsideFormulaMap.get( $validationResult.programValidation.id )</td>
- #end
- #set( $mark = !$mark )
- #end
- </tbody>
- </table>
+ #if($programValidationResults.size()>0 )
+ <p class="bold">$encoder.htmlEncode( $i18n.getString( "the_following_dataelements_are_in_predefined_validate_rules" ) )</p>
+ <table class="listTable" id="multiValidation" name="multiValidation" style="width:100%">
+ <thead>
+ <tr>
+ <th>$i18n.getString( "validation_rule" )</th>
+ <th>$i18n.getString( "description" )</th>
+ <th>$i18n.getString( "left_value" )</th>
+ <th>$i18n.getString( "right_value" )</th>
+ <th>$i18n.getString( "description" )</th>
+ </tr>
+ </thead>
+ #set( $mark = false )
+ <tbody>
+ #foreach( $validationResult in $programValidationResults )
+ <tr #alternate( $mark )>
+ <td>$validationResult.programValidation.description</td>
+ <td>$leftsideFormulaMap.get( $validationResult.programValidation.id )</td>
+ <td>$validationResult.leftsideValue</td>
+ #if( $validationResult.programValidation.rightSide!="1==1")
+ <td>$validationResult.rightsideValue</td>
+ <td>$rightsideFormulaMap.get( $validationResult.programValidation.id )</td>
+ #end
+ #set( $mark = !$mark )
+ #end
+ </tbody>
+ </table>
+ #end
#end
\ No newline at end of file