← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5720: (patient) Add validation for date data element with range duedate and max days.

 

------------------------------------------------------------
revno: 5720
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-01-13 11:29:08 +0700
message:
  (patient) Add validation for date data element with range duedate and max days.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidation.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-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties


--
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/ProgramValidation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidation.java	2012-01-13 02:14:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidation.java	2012-01-13 04:29:08 +0000
@@ -64,6 +64,8 @@
     public int AFTER_DUE_DATE = -3;
 
     public int AFTER_OR_EQUALS_TO_DUE_DATE = -4;
+    
+    public int BEFORE_DUE_DATE_PULS_MAX_DAYS_OF_DATA_ENTRY = -5;
 
     // -------------------------------------------------------------------------
     // Fields

=== 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-01-13 02:14:28 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2012-01-13 04:29:08 +0000
@@ -265,6 +265,12 @@
                 return value.after( dueDate );
             case -4:
                 return (value.after( dueDate ) || value.equals( dueDate ));
+            case -5:
+                Integer maxDaysInProgram = programStageInstance.getProgramStage().getProgram().getMaxDaysAllowedInputData();
+                long maxDays = dueDate.getTime() / 86400000 + maxDaysInProgram ;
+                long minDays = dueDate.getTime() / 86400000 - maxDaysInProgram ;
+                long valueDays = value.getTime() / 86400000;
+                return ( valueDays <= maxDays && valueDays >= minDays );
             default:
                 return true;
             }

=== 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-01-13 02:14:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java	2012-01-13 04:29:08 +0000
@@ -301,8 +301,11 @@
                     case -4:
                         rightsideFormulaMap.put( validation.getId(), i18n.getString( "after_or_equals_to_due_date" ) );
                         break;
+                    case -5:
+                        rightsideFormulaMap.put( validation.getId(), i18n.getString( "due_date_with_max_number_of_days_of_data_entry" ) );
+                        break;
                     default:
-                        rightsideFormulaMap.put( validation.getId(), i18n.getString( "before_current_date" ) );
+                        rightsideFormulaMap.put( validation.getId(), "" );
                         break;
                     }
                 }

=== 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-01-13 02:14:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-01-13 04:29:08 +0000
@@ -466,4 +466,5 @@
 after_due_date = After due date
 after_or_equals_to_due_date = After or equals to due date
 leftSide = Left Side
-rightSide = Right Side
\ No newline at end of file
+rightSide = Right Side
+due_date_with_max_number_of_days_of_data_entry = Due date +/- Max number of days of data entry
\ No newline at end of file

=== 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-01-13 02:14:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-01-13 04:29:08 +0000
@@ -398,6 +398,7 @@
 before_or_equals_to_due_date = Before or equals to due date
 after_due_date = After due date
 after_or_equals_to_due_date = After or equals to due date
+due_date_with_max_number_of_days_of_data_entry = Due date +/- Max number of days of data entry
 data_element = Data element
 condition = Condition
 no_date_data_element_in_selected_program_stage = No data elements with date-type in the selected program stage
\ No newline at end of file