dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08228
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1960: Build a funtion to validate Date-values into caseentry - Finished.
------------------------------------------------------------
revno: 1960
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-10-26 15:15:37 +0700
message:
Build a funtion to validate Date-values into caseentry - Finished.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/TableAlteror.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.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/javascript/dataEntry.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/status.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java
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/webapp/dhis-web-maintenance-patient/addProgramForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.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-api/src/main/java/org/hisp/dhis/patient/Patient.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2010-10-25 17:44:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2010-10-26 08:15:37 +0000
@@ -44,15 +44,14 @@
implements Serializable
{
public static final String MALE = "M";
-
public static final String FEMALE = "F";
+
public static final char DOB_TYPE_VERIFIED = 'V';
-
public static final char DOB_TYPE_DECLARED = 'D';
-
public static final char DOB_TYPE_APPROXIATED = 'A';
+
private Integer id;
private String firstName;
@@ -282,16 +281,6 @@
return registrationDate;
}
- // public Set<PatientAttribute> getAttributes()
- // {
- // return attributes;
- // }
- //
- // public void setAttributes( Set<PatientAttribute> attributes )
- // {
- // this.attributes = attributes;
- // }
-
public void setRepresentative( Patient representative )
{
this.representative = representative;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2010-10-25 17:44:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2010-10-26 08:15:37 +0000
@@ -70,6 +70,10 @@
private Set<ValidationCriteria> patientValidationCriteria = new HashSet<ValidationCriteria>();
+ private Integer minDaysAllowedInputData;
+
+ private Integer maxDaysAllowedInputData;
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -191,6 +195,26 @@
this.dateOfEnrollmentDescription = dateOfEnrollmentDescription;
}
+ public Integer getMinDaysAllowedInputData()
+ {
+ return minDaysAllowedInputData;
+ }
+
+ public void setMinDaysAllowedInputData( Integer minDaysAllowedInputData )
+ {
+ this.minDaysAllowedInputData = minDaysAllowedInputData;
+ }
+
+ public Integer getMaxDaysAllowedInputData()
+ {
+ return maxDaysAllowedInputData;
+ }
+
+ public void setMaxDaysAllowedInputData( Integer maxDaysAllowedInputData )
+ {
+ this.maxDaysAllowedInputData = maxDaysAllowedInputData;
+ }
+
public String getDateOfIncidentDescription()
{
return dateOfIncidentDescription;
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/TableAlteror.java 2010-10-25 17:44:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/TableAlteror.java 2010-10-26 08:15:37 +0000
@@ -31,6 +31,10 @@
updateDOBType();
executeSql("UPDATE patientidentifiertype SET type='" + PatientIdentifierType.VALUE_TYPE_TEXT +"' WHERE type IS NULL");
+
+ executeSql("UPDATE program SET minDaysAllowedInputData=0 WHERE minDaysAllowedInputData IS NULL");
+
+ executeSql("UPDATE program SET maxDaysAllowedInputData=0 WHERE maxDaysAllowedInputData IS NULL");
}
private void updatePatientOrgunitAssociation(){
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml 2010-05-17 02:59:28 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml 2010-10-26 08:15:37 +0000
@@ -35,5 +35,9 @@
class="org.hisp.dhis.validation.ValidationCriteria" />
</set>
+ <property name="minDaysAllowedInputData"/>
+
+ <property name="maxDaysAllowedInputData"/>
+
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.java 2010-08-05 12:25:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.java 2010-10-26 08:15:37 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.patient.Patient;
@@ -146,6 +147,20 @@
this.statusCode = statusCode;
}
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -153,7 +168,6 @@
public String execute()
throws Exception
{
-
OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
Patient patient = selectedStateManager.getSelectedPatient();
@@ -192,6 +206,55 @@
return SUCCESS;
}
+
+ // -----------------------------------------------------------------
+ // Check inputed value :
+ // value >= DueDate - program.minDaysAllowedInputData
+ // value <= DueDate + program.maxDaysAllowedInputData
+ // -----------------------------------------------------------------
+
+ Date dueDate = programStageInstance.getDueDate();
+
+ if(dateValue.before(dueDate)){
+
+ long diffMillis = dueDate.getTime()-dateValue.getTime();
+
+ long diffMinDays = diffMillis/86400000;
+
+ if(diffMinDays > program.getMinDaysAllowedInputData() )
+ {
+ statusCode = 2;
+
+ message = "- " + i18n.getString( "date_is_greater_then_or_equals_due_date_minus_no_min_days" ) + " "
+ + " ( " + i18n.getString( "min_days") + " : ( " + program.getMinDaysAllowedInputData() + i18n.getString("days") + " )"
+ + "\n"
+ + "- " + i18n.getString( "date_is_less_then_or_equals_plus_no_max_days" ) + " "
+ + " ( "+ i18n.getString( "max_days") + " : " + program.getMaxDaysAllowedInputData() + i18n.getString("days") + " )";
+
+
+ return SUCCESS;
+ }
+
+ }else{
+
+ long diffMillis = dateValue.getTime() - dueDate.getTime();
+
+ long diffMaxDays = diffMillis/86400000;
+
+ if(diffMaxDays > program.getMaxDaysAllowedInputData() )
+ {
+ statusCode = 2;
+
+ message = "- " + i18n.getString( "date_is_greater_then_or_equals_due_date_minus_no_min_days" ) + " "
+ + " ( " + i18n.getString( "min_days") + " : ( " + program.getMinDaysAllowedInputData() + i18n.getString("days") + " )"
+ + "\n"
+ + "- " + i18n.getString( "date_is_less_then_or_equals_plus_no_max_days" ) + " "
+ + " ( "+ i18n.getString( "max_days") + " : " + program.getMaxDaysAllowedInputData() + i18n.getString("days") + " )";
+
+ return SUCCESS;
+ }
+ }
+
}
if ( programStageInstance.getExecutionDate() == null )
=== 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 2010-10-14 08:54:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2010-10-26 08:15:37 +0000
@@ -457,4 +457,9 @@
from = From
to = To
ga_orgunit = OrganisationUnit
-ga_facilityby = OrganisationUnit By
\ No newline at end of file
+ga_facilityby = OrganisationUnit By
+date_is_greater_then_or_equals_due_date_minus_no_min_days = Date inputed is greater then or equals [ Due Date - Number of min days allowed to input data ]
+date_is_less_then_or_equals_plus_no_max_days = Date inputed is less then or equals [ Due Date + Number of max days allowed to input data ]
+min_days = Min days
+max_days = Max days
+days = days
=== 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 2010-09-21 12:42:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2010-10-26 08:15:37 +0000
@@ -110,7 +110,7 @@
</action>
<action name="saveDateValueChain" class="org.hisp.dhis.caseentry.action.caseentry.SaveDateValueAction">
- <result name="success" type="velocity">status.vm</result>
+ <result name="success" type="velocity-xml">status.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js 2010-09-01 16:55:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js 2010-10-26 08:15:37 +0000
@@ -265,6 +265,11 @@
markValue( resultColor );
}
}
+ else if(code == 2)
+ {
+ markValue( ERROR );
+ window.alert( i18n_invalid_date + ":\n" + rootElement.getElementsByTagName( 'message' )[0].firstChild.nodeValue );
+ }
else
{
if(value != "")
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/status.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/status.vm 2010-05-17 02:59:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/status.vm 2010-10-26 08:15:37 +0000
@@ -5,4 +5,5 @@
<validation>$validation.description</validation>
#end
</validations>
+ <message>$message</message>
</status>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java 2010-09-25 10:03:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java 2010-10-26 08:15:37 +0000
@@ -66,30 +66,44 @@
public void setDescription( String description )
{
this.description = description;
- }
-
+ }
+
/**
- * Description of Date of Enrollment
- * This description is differ from each program
+ * Description of Date of Enrollment This description is differ from each
+ * program
*/
private String dateOfEnrollmentDescription;
-
+
public void setDateOfEnrollmentDescription( String dateOfEnrollmentDescription )
{
this.dateOfEnrollmentDescription = dateOfEnrollmentDescription;
}
-
+
/**
- * Description of Date of Incident
- * This description is differ from each program
+ * Description of Date of Incident This description is differ from each
+ * program
*/
private String dateOfIncidentDescription;
-
+
public void setDateOfIncidentDescription( String dateOfIncidentDescription )
{
this.dateOfIncidentDescription = dateOfIncidentDescription;
}
+ private Integer minDaysAllowedInputData;
+
+ public void setMinDaysAllowedInputData( Integer minDaysAllowedInputData )
+ {
+ this.minDaysAllowedInputData = minDaysAllowedInputData;
+ }
+
+ private Integer maxDaysAllowedInputData;
+
+ public void setMaxDaysAllowedInputData( Integer maxDaysAllowedInputData )
+ {
+ this.maxDaysAllowedInputData = maxDaysAllowedInputData;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -97,15 +111,15 @@
public String execute()
throws Exception
{
+ Program program = new Program();
- Program program = new Program();
-
program.setName( name );
program.setDescription( description );
program.setDateOfEnrollmentDescription( dateOfEnrollmentDescription );
program.setDateOfIncidentDescription( dateOfIncidentDescription );
+ program.setMinDaysAllowedInputData( minDaysAllowedInputData );
+ program.setMaxDaysAllowedInputData( maxDaysAllowedInputData );
-
programService.saveProgram( program );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java 2010-09-25 10:03:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java 2010-10-26 08:15:37 +0000
@@ -73,29 +73,44 @@
public void setDescription( String description )
{
this.description = description;
- }
+ }
/**
- * Description of Date of Enrollment
- * This description is differ from each program
+ * Description of Date of Enrollment This description is differ from each
+ * program
*/
private String dateOfEnrollmentDescription;
-
+
public void setDateOfEnrollmentDescription( String dateOfEnrollmentDescription )
{
this.dateOfEnrollmentDescription = dateOfEnrollmentDescription;
}
-
+
/**
- * Description of Date of Incident
- * This description is differ from each program
+ * Description of Date of Incident This description is differ from each
+ * program
*/
private String dateOfIncidentDescription;
-
+
public void setDateOfIncidentDescription( String dateOfIncidentDescription )
{
this.dateOfIncidentDescription = dateOfIncidentDescription;
}
+
+ private Integer minDaysAllowedInputData;
+
+ public void setMinDaysAllowedInputData( Integer minDaysAllowedInputData )
+ {
+ this.minDaysAllowedInputData = minDaysAllowedInputData;
+ }
+
+ private Integer maxDaysAllowedInputData;
+
+ public void setMaxDaysAllowedInputData( Integer maxDaysAllowedInputData )
+ {
+ this.maxDaysAllowedInputData = maxDaysAllowedInputData;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -103,13 +118,15 @@
public String execute()
throws Exception
{
- Program program = programService.getProgram( id );
-
+ Program program = programService.getProgram( id );
+
program.setName( name );
program.setDescription( description );
program.setDateOfEnrollmentDescription( dateOfEnrollmentDescription );
program.setDateOfIncidentDescription( dateOfIncidentDescription );
-
+ program.setMinDaysAllowedInputData( minDaysAllowedInputData );
+ program.setMaxDaysAllowedInputData( maxDaysAllowedInputData );
+
programService.updateProgram( program );
return SUCCESS;
=== 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 2010-10-25 17:44:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2010-10-26 08:15:37 +0000
@@ -411,4 +411,7 @@
please_verify_birthday = Please verify the birthday.
state_format = State Format
no_of_char = Number of characters
-letter = Letter
\ No newline at end of file
+letter = Letter
+date_of_incident_invalid = Date of incident is invalid.
+no_min_days_allowed_input_data = Number of min days allowed to input data
+no_max_days_allowed_input_data = Number of max days allowed to input data
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2010-09-25 10:03:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2010-10-26 08:15:37 +0000
@@ -36,7 +36,22 @@
<td><input type="text" id="dateOfIncidentDescription" name="dateOfIncidentDescription" style="width:30em" class="{validate:{required:true,minlength:4}}"></td>
<td></td>
</tr>
-
+
+ <tr>
+ <td><label>$i18n.getString( "no_min_days_allowed_input_data" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+ <td><input type="text" id="minDaysAllowedInputData" name="minDaysAllowedInputData" style="width:30em" class="{validate:{required:true,number:true}}"></td>
+ <td></td>
+ </tr>
+
+ <tr>
+ <td><label>$i18n.getString( "no_max_days_allowed_input_data" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+ <td><input type="text" id="maxDaysAllowedInputData" name="maxDaysAllowedInputData" style="width:30em" class="{validate:{required:true,number:true}}"></td>
+ <td></td>
+ </tr>
+
+ <tr>
+ <td colspan="2" style="height:15px"></td>
+ </tr>
</table>
<p>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2010-09-25 10:03:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2010-10-26 08:15:37 +0000
@@ -44,7 +44,19 @@
<td><label>$i18n.getString( "dateOfIncidentDescription" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
<td><input type="text" id="dateOfIncidentDescription" name="dateOfIncidentDescription" value="$!program.dateOfIncidentDescription" style="width:30em" class="{validate:{required:true,minlength:4}}"></td>
<td></td>
- </tr>
+ </tr>
+
+ <tr>
+ <td><label>$i18n.getString( "no_min_days_alowed_input_data" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+ <td><input type="text" id="minDaysAllowedInputData" name="minDaysAllowedInputData" value="$!program.minDaysAllowedInputData" style="width:30em" class="{validate:{required:true,number:true}}"></td>
+ <td></td>
+ </tr>
+
+ <tr>
+ <td><label>$i18n.getString( "no_max_days_alowed_input_data" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+ <td><input type="text" id="maxDaysAllowedInputData" name="maxDaysAllowedInputData" value="$!program.maxDaysAllowedInputData" style="width:30em" class="{validate:{required:true,number:true}}"></td>
+ <td></td>
+ </tr>
<tr>
<td colspan="2" style="height:15px"></td>
</tr>