← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5424: Add validation to the anonymous data entry.

 

------------------------------------------------------------
revno: 5424
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-12-15 11:13:03 +0700
message:
  Add validation to the anonymous data entry.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationService.java
  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/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  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/dataRecordingSelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/patient.css


--
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/ProgramValidationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationService.java	2011-04-29 07:41:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationService.java	2011-12-15 04:13:03 +0000
@@ -29,6 +29,8 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+
 /**
  * @author Chau Thu Tran
  * @version $ ProgramValidationService.java Apr 28, 2011 10:32:20 AM $
@@ -49,5 +51,5 @@
 
     Collection<ProgramValidation> getProgramValidation( Program program );
 
-    boolean runValidation( ProgramValidation validation, ProgramInstance programInstance );
+    boolean runValidation( ProgramValidation validation, ProgramInstance programInstance, OrganisationUnit orgunit );
 }

=== 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	2011-07-08 05:52:59 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2011-12-15 04:13:03 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.nfunk.jep.JEP;
@@ -132,19 +133,20 @@
     }
 
     @Override
-    public boolean runValidation( ProgramValidation validation, ProgramInstance programInstance )
+    public boolean runValidation( ProgramValidation validation, ProgramInstance programInstance,
+        OrganisationUnit orgunit )
     {
         // ---------------------------------------------------------------------
         // parse left-expressions
         // ---------------------------------------------------------------------
 
-        boolean resultLeft = runExpression( validation.getLeftSide(), programInstance );
+        boolean resultLeft = runExpression( validation.getLeftSide(), programInstance, orgunit );
 
         // ---------------------------------------------------------------------
         // parse right-expressions
         // ---------------------------------------------------------------------
 
-        boolean resultRight = runExpression( validation.getRightSide(), programInstance );
+        boolean resultRight = runExpression( validation.getRightSide(), programInstance, orgunit );
 
         return (resultLeft == resultRight);
 
@@ -155,7 +157,7 @@
         return validationStore.get( program );
     }
 
-    private boolean runExpression( String expression, ProgramInstance programInstance )
+    private boolean runExpression( String expression, ProgramInstance programInstance, OrganisationUnit orgunit )
     {
         final String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+["
             + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
@@ -181,13 +183,14 @@
             DataElement dataElement = dataElementService.getDataElement( dataElementId );
 
             int optionComboId = Integer.parseInt( ids[2] );
-            DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );
+            DataElementCategoryOptionCombo optionCombo = categoryService
+                .getDataElementCategoryOptionCombo( optionComboId );
 
             ProgramStageInstance stageInstance = stageInstanceService.getProgramStageInstance( programInstance,
                 programStage );
 
             PatientDataValue dataValue = valueService.getPatientDataValue( stageInstance, dataElement, optionCombo,
-                programInstance.getPatient().getOrganisationUnit() );
+                orgunit );
 
             if ( dataValue == null )
             {

=== 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	2011-07-08 07:22:42 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java	2011-12-15 04:13:03 +0000
@@ -168,7 +168,7 @@
         // ---------------------------------------------------------------------
 
         runProgramValidation( programValidationService.getProgramValidation( programStageInstance.getProgramInstance().getProgram() ),
-            programStageInstance.getProgramInstance() );
+            programStageInstance.getProgramInstance(), organisationUnit );
 
         return SUCCESS;
     }
@@ -213,13 +213,13 @@
 
     }
 
-    private void runProgramValidation( Collection<ProgramValidation> validations, ProgramInstance programInstance )
+    private void runProgramValidation( Collection<ProgramValidation> validations, ProgramInstance programInstance, OrganisationUnit orgunit )
     {
         if ( validations != null )
         {
             for ( ProgramValidation validation : validations )
             {
-                boolean valid = programValidationService.runValidation( validation, programInstance );
+                boolean valid = programValidationService.runValidation( validation, programInstance, orgunit );
 
                 if ( !valid )
                 {

=== 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	2011-12-14 11:15:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2011-12-15 04:13:03 +0000
@@ -307,7 +307,7 @@
 the_following_dataelements_are_in_multi_stages=The following dataelements are in multi-program stages
 validation_result=Validation Result
 should=should
-validation=Validation
+run_validation=Run validation
 program_validation_description=Program Validation Description
 please_select_village=Please select village
 select_sorting_attribute=Select a specfied attribute / ALL

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-12-14 07:33:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-12-15 04:13:03 +0000
@@ -431,6 +431,7 @@
 				,javascript/anonymousRegistration.js
 				,javascript/entry.js
 				,../dhis-web-commons/javascripts/date.js</param>
+			<param name="stylesheets">../dhis-web-caseentry/style/patient.css</param>
 		</action>
 		
 		<action name="loadAnonymousPrograms"

=== 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	2011-12-14 11:15:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2011-12-15 04:13:03 +0000
@@ -1,35 +1,57 @@
 <h3>$i18n.getString( "event_registration" )</h3>	
 
-	<div id="dataRecordingSelectDiv" class="inputCriteria" style="width:420px;height:80px;">
-		
-		<input type='hidden' id="programStageId">
-		
-		<table>
-			<tr>
-				<td>$i18n.getString('program')</td>
-				<td>
-					<select id='programId' style='width:300px' onchange='showEventForm();'>
-						<option value="">[ $i18n.getString('please_select') ]</option>
-						#foreach( $program in $programs)
-							<option value="$program.id" singleevent='$program.singleEvent'>$program.name</option>
-						#end
-					</select>
-				</td>
-			</tr>
-			<tr>
-				<td><label for="executionDate">$i18n.getString( "report_date" ) </label></td>
-				<td><input type="text" id="executionDate" name="executionDate" disabled style="width:300px" value="$!format.formatDate( $programStageInstance.executionDate )" >
-					<script type="text/javascript">
-					   datePickerValid( 'executionDate', false );
-					</script>
-			</tr>
-		</table>
-	</div>
-
-	#parse( "dhis-web-commons/loader/loader.vm" )
-
-	<div id="dataEntryFormDiv"> </div>
+	
+<div id="actions">	
+	<input type="button" id="validationBtn" value="$i18n.getString('run_validation')" onClick="javascript: runValidation();" style="width:12em " disabled="disabled" >
+</div>	
+			
+<div id="dataRecordingSelectDiv" class="inputCriteria" style="width:420px;height:80px;">
+
+	<input type='hidden' id="programStageId">
+	
+	<table>
+		<tr>
+			<td>$i18n.getString('program')</td>
+			<td>
+				<select id='programId' style='width:300px' onchange='showEventForm();'>
+					<option value="">[ $i18n.getString('please_select') ]</option>
+					#foreach( $program in $programs)
+						<option value="$program.id" singleevent='$program.singleEvent'>$program.name</option>
+					#end
+				</select>
+			</td>
+		</tr>
+		<tr>
+			<td><label for="executionDate">$i18n.getString( "report_date" ) </label></td>
+			<td><input type="text" id="executionDate" name="executionDate" disabled style="width:300px" value="$!format.formatDate( $programStageInstance.executionDate )" >
+				<script type="text/javascript">
+				   datePickerValid( 'executionDate', false );
+				</script>
+		</tr>
+	</table>
+</div>
+
+#parse( "dhis-web-commons/loader/loader.vm" )
+
+<div id="dataEntryFormDiv"> </div>
 
 <script>
 	var i18n_please_select = '[ ' + '$encoder.jsEscape( $i18n.getString( "please_select" ) , "'" )' + ' ]';
+	
+	var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
+	var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
+	var i18n_value_must_positive_integer = '$encoder.jsEscape( $i18n.getString( "value_must_positive_integer" ) , "'")';
+	var i18n_value_must_negative_integer = '$encoder.jsEscape( $i18n.getString( "value_must_negative_integer" ) , "'")';
+    var i18n_invalid_date =   '$encoder.jsEscape( $i18n.getString( "invalid_date" ) , "'")' + ".\n " 
+							+ '$encoder.jsEscape( $i18n.getString( "format_date" ) , "'")' + " '" 
+							+ dateFormat.replace('yy', 'yyyy') + " '" ; 
+    var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
+    var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
+    var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")';
+    var i18n_complete_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_confirm_message" ) , "'")';
+    var i18n_error_required_field = '$encoder.jsEscape( $i18n.getString( "error_required_field" ) , "'")';
+	var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
+	var i18n_date_is_greater_then_or_equals_due_date = '$encoder.jsEscape( $i18n.getString( "date_is_greater_then_or_equals_due_date" ) , "'")';
+	
+	var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
 </script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm	2011-11-21 12:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm	2011-12-15 04:13:03 +0000
@@ -76,7 +76,7 @@
 				</tr>
 				<tr>
 					<td align='right' colspan='2'>
-						<input type="button" id="validationBtn" value="$i18n.getString('validation')" onClick="javascript: runValidation();" style="width:12em " disabled="disabled" >
+						<input type="button" id="validationBtn" value="$i18n.getString('run_validation')" onClick="javascript: runValidation();" style="width:12em " disabled="disabled" >
 					</td>
 				</tr>
 				<tr>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2011-12-14 07:33:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2011-12-15 04:13:03 +0000
@@ -27,6 +27,7 @@
 	{
 		disable('executionDate');
 		setFieldValue('executionDate', '');
+		hideById('dataEntryFormDiv');
 		return;
 	}
 	
@@ -53,5 +54,6 @@
 		{
 			enable('executionDate');
 			hideById('loaderDiv');
+			showById('dataEntryFormDiv');
 		} );
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/patient.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/patient.css	2011-10-29 14:16:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/patient.css	2011-12-15 04:13:03 +0000
@@ -57,3 +57,11 @@
 {
 	width: 130px;
 }
+
+#actions
+{
+  float: right;
+  width:200px;
+  text-align: right;
+}
+