dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24282
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11873: Fix bug - Don't allow to select enrollement date in the future if this property of the program i...
------------------------------------------------------------
revno: 11873
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-09-03 13:39:59 +0700
message:
Fix bug - Don't allow to select enrollement date in the future if this property of the program is unactive.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgram.vm
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/javascript/program.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.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/PatientRegistrationFormService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java 2013-09-03 06:39:59 +0000
@@ -81,7 +81,7 @@
PatientRegistrationForm getCommonPatientRegistrationForm();
- String prepareDataEntryFormForAdd( String htmlCode, Collection<User> healthWorkers, Patient patient,
+ String prepareDataEntryFormForAdd( String htmlCode, Program program, Collection<User> healthWorkers, Patient patient,
ProgramInstance programInstance, I18n i18n, I18nFormat format );
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java 2013-09-02 16:32:38 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java 2013-09-03 06:39:59 +0000
@@ -141,7 +141,7 @@
}
@Override
- public String prepareDataEntryFormForAdd( String htmlCode, Collection<User> healthWorkers, Patient patient,
+ public String prepareDataEntryFormForAdd( String htmlCode, Program program, Collection<User> healthWorkers, Patient patient,
ProgramInstance programInstance, I18n i18n, I18nFormat format )
{
int index = 1;
@@ -149,7 +149,7 @@
StringBuffer sb = new StringBuffer();
Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
-
+
while ( inputMatcher.find() )
{
// -----------------------------------------------------------------
@@ -163,7 +163,7 @@
Matcher programMatcher = PROGRAM_PATTERN.matcher( inputHtml );
Matcher suggestedMarcher = SUGGESTED_VALUE_PATTERN.matcher( inputHtml );
Matcher classMarcher = CLASS_PATTERN.matcher( inputHtml );
-
+
index++;
if ( fixedAttrMatcher.find() && fixedAttrMatcher.groupCount() > 0 )
@@ -192,17 +192,18 @@
}
}
}
- else if( suggestedMarcher.find())
+ else if ( suggestedMarcher.find() )
{
value = suggestedMarcher.group( 2 );
}
-
- if( classMarcher.find() )
+
+ if ( classMarcher.find() )
{
hidden = classMarcher.group( 1 );
}
-
- inputHtml = getFixedAttributeField( inputHtml, fixedAttr, value.toString(), hidden, healthWorkers, i18n, index );
+
+ inputHtml = getFixedAttributeField( inputHtml, fixedAttr, value.toString(), hidden, healthWorkers,
+ i18n, index );
}
else if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
{
@@ -253,7 +254,7 @@
{
String uid = dynamicAttrMatcher.group( 1 );
PatientAttribute attribute = attributeService.getPatientAttribute( uid );
-
+
if ( attribute == null )
{
inputHtml = "<input value='[" + i18n.getString( "missing_patient_attribute" ) + " " + uid
@@ -291,7 +292,14 @@
inputHtml = "<input id=\"" + property + "\" name=\"" + property + "\" tabindex=\"" + index
+ "\" value=\"" + value + "\" " + TAG_CLOSE;
- inputHtml += "<script>datePicker(\"" + property + "\", true);</script>";
+ if ( program != null && program.getSelectEnrollmentDatesInFuture() )
+ {
+ inputHtml += "<script>datePicker(\"" + property + "\", true);</script>";
+ }
+ else
+ {
+ inputHtml += "<script>datePickerValid(\"" + property + "\", true);</script>";
+ }
}
inputMatcher.appendReplacement( sb, inputHtml );
@@ -397,13 +405,13 @@
inputHtml += " class=\"{validate:{phone:true}}\" " + hidden + " " + TAG_CLOSE;
inputHtml += " <input type=\"button\" value=\"+\" style=\"width:20px;\" class=\"phoneNumberTR\" onclick=\"addCustomPhoneNumberField(\'\');\" />";
}
-
+
// Age fields
else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_AGE ) )
{
inputHtml += " class=\"{validate:{number:true}}\" " + hidden + " " + TAG_CLOSE;
}
-
+
// Gender selector
if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_GENDER ) )
{
@@ -435,7 +443,7 @@
|| fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_DEATH_DATE )
|| fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_REGISTRATION_DATE ) )
{
- inputHtml += " class='" + hidden + "' "+ TAG_CLOSE;
+ inputHtml += " class='" + hidden + "' " + TAG_CLOSE;
if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_BIRTHDATE )
|| fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_REGISTRATION_DATE ) )
{
@@ -450,7 +458,7 @@
// DobType field
else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_DOB_TYPE ) )
{
- inputHtml = inputHtml.replaceFirst( "input", "select" ) + " class='" + hidden + "' >" ;
+ inputHtml = inputHtml.replaceFirst( "input", "select" ) + " class='" + hidden + "' >";
if ( value.equals( "" ) || value.equals( Patient.DOB_TYPE_VERIFIED + "" ) )
{
@@ -525,7 +533,6 @@
{
try
{
-
return ProgramInstance.class.getMethod( "get" + property ).invoke( programInstance );
}
catch ( Exception ex )
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2013-09-02 21:20:47 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2013-09-03 06:39:59 +0000
@@ -222,7 +222,7 @@
executeSql( "update patientattribute set displayonvisitschedule = false where displayonvisitschedule is null");
executeSql( "update program set useBirthDateAsIncidentDate = false where useBirthDateAsIncidentDate is null");
executeSql( "update program set useBirthDateAsEnrollmentDate = false where useBirthDateAsEnrollmentDate is null");
- executeSql( "update program set selectEnrollmentDatesInFuture = true where selectEnrollmentDatesInFuture is null");
+ executeSql( "update program set selectEnrollmentDatesInFuture = false where selectEnrollmentDatesInFuture is null");
executeSql( "update programstage set relatedPatient = false where relatedPatient is null");
executeSql( "update validationcriteria set description = name where description is null or description='' ");
executeSql( "update programstage set generatedByEnrollmentDate = false where generatedByEnrollmentDate is null ");
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java 2013-09-03 06:39:59 +0000
@@ -174,7 +174,8 @@
if ( patientRegistrationForm != null )
{
customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd( patientRegistrationForm
- .getDataEntryForm().getHtmlCode(), healthWorkers, null, null, i18n, format );
+ .getDataEntryForm().getHtmlCode(), patientRegistrationForm.getProgram(), healthWorkers, null, null,
+ i18n, format );
}
if ( customRegistrationForm == null )
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java 2013-09-03 06:39:59 +0000
@@ -191,8 +191,8 @@
if ( patientRegistrationForm != null )
{
customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd(
- patientRegistrationForm.getDataEntryForm().getHtmlCode(), healthWorkers, patient, null, i18n,
- format );
+ patientRegistrationForm.getDataEntryForm().getHtmlCode(), patientRegistrationForm.getProgram(),
+ healthWorkers, patient, null, i18n, format );
}
}
else
@@ -214,8 +214,8 @@
if ( patientRegistrationForm != null )
{
customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd(
- patientRegistrationForm.getDataEntryForm().getHtmlCode(), healthWorkers, patient, programInstance,
- i18n, format );
+ patientRegistrationForm.getDataEntryForm().getHtmlCode(), patientRegistrationForm.getProgram(),
+ healthWorkers, patient, programInstance, i18n, format );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java 2013-09-03 06:39:59 +0000
@@ -227,7 +227,8 @@
if ( patientRegistrationForm != null && patientRegistrationForm.getDataEntryForm() != null )
{
customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd(
- patientRegistrationForm.getDataEntryForm().getHtmlCode(), healthWorkers, null, null, i18n, format );
+ patientRegistrationForm.getDataEntryForm().getHtmlCode(), patientRegistrationForm.getProgram(),
+ healthWorkers, null, null, i18n, format );
}
}
else
@@ -238,7 +239,8 @@
if ( patientRegistrationForm != null && patientRegistrationForm.getDataEntryForm() != null )
{
customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd(
- patientRegistrationForm.getDataEntryForm().getHtmlCode(), healthWorkers, null, null, i18n, format );
+ patientRegistrationForm.getDataEntryForm().getHtmlCode(), patientRegistrationForm.getProgram(),
+ healthWorkers, null, null, i18n, format );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgram.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgram.vm 2013-09-02 21:20:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgram.vm 2013-09-03 06:39:59 +0000
@@ -15,6 +15,6 @@
"displayOnAllOrgunit": "$!program.displayOnAllOrgunit",
"useBirthDateAsIncidentDate": "$!program.useBirthDateAsIncidentDate",
"useBirthDateAsEnrollmentDate": "$!program.useBirthDateAsEnrollmentDate",
- "selecteEnrollmentDatesInFuture": "$!program.selecteEnrollmentDatesInFuture"
+ "selectEnrollmentDatesInFuture": "$!program.selectEnrollmentDatesInFuture"
}
}
\ 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 2013-08-12 06:23:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-09-03 06:39:59 +0000
@@ -449,4 +449,5 @@
default_form_name = Default form name
custom_form_name = Custom form name
allow_select_enrollment_dates_in_future = Allow seleting enrollment dates in future
-related_patient = Related person
\ No newline at end of file
+related_patient = Related person
+allow_select_enrollment_date_in_future = Allow select enrollment date in future
\ 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 2013-09-02 21:20:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2013-09-03 06:39:59 +0000
@@ -139,6 +139,12 @@
</tr>
<tr name='nonAnonymous'>
+ <td><label>$i18n.getString( "allow_select_enrollment_date_in_future" )</label></td>
+ <td><input type="checkbox" id="selectEnrollmentDatesInFuture" name="selectEnrollmentDatesInFuture" value='true'></td>
+ <td></td>
+ </tr>
+
+ <tr name='nonAnonymous'>
<td><label>$i18n.getString( "skip_to_generate_overdue_events" )</label></td>
<td><input type="checkbox" id="ignoreOverdueEvents" name="ignoreOverdueEvents" value='true'></td>
<td></td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js 2013-09-02 21:20:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js 2013-09-03 06:39:59 +0000
@@ -35,6 +35,9 @@
var useBirthDateAsEnrollmentDate = ( json.program.useBirthDateAsEnrollmentDate == 'true') ? i18n_yes : i18n_no;
setInnerHTML( 'useBirthDateAsEnrollmentDateField', useBirthDateAsEnrollmentDate );
+ var displayOnAllOrgunit= ( json.program.selectEnrollmentDatesInFuture == 'true') ? i18n_yes : i18n_no;
+ setInnerHTML( 'selectEnrollmentDatesInFutureField', selectEnrollmentDatesInFuture );
+
setInnerHTML( 'dateOfEnrollmentDescriptionField', json.program.dateOfEnrollmentDescription );
setInnerHTML( 'dateOfIncidentDescriptionField', json.program.dateOfIncidentDescription );
setInnerHTML( 'programStageCountField', json.program.programStageCount );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm 2013-09-02 21:20:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm 2013-09-03 06:39:59 +0000
@@ -88,6 +88,7 @@
<p><label class="bold">$i18n.getString( "description" ):</label><br><span id="descriptionField"></span></p>
<p><label class="bold">$i18n.getString( "type" ):</label><br><span id="typeField"></span></p>
<p><label class="bold">$i18n.getString( "display_date_of_incident" ):</label><br><span id="displayIncidentDateField"></span></p>
+ <p><label class="bold">$i18n.getString( "allow_select_enrollment_date_in_future" ):</label><br><span id="selectEnrollmentDatesInFutureField"></span></p>
<p><label class="bold">$i18n.getString( "skip_to_generate_overdue_events" ):</label><br><span id="ignoreOverdueEventsField"></span></p>
<p><label class="bold">$i18n.getString( "only_enroll_once" ):</label><br><span id="onlyEnrollOnceField"></span></p>
<p><label class="bold">$i18n.getString( "used_by_all_orgunits" ):</label><br><span id="displayOnAllOrgunitField"></span></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 2013-09-02 21:20:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2013-09-03 06:39:59 +0000
@@ -150,6 +150,12 @@
<tr name='nonAnonymous'>
<th colspan="2">$i18n.getString( "enrollment_details" )</th>
</tr>
+
+ <tr name='nonAnonymous'>
+ <td><label>$i18n.getString( "allow_select_enrollment_date_in_future" )</label></td>
+ <td><input type="checkbox" id="selectEnrollmentDatesInFuture" name="selectEnrollmentDatesInFuture" value='true' #if($program.selectEnrollmentDatesInFuture=='true') checked #end ></td>
+ <td></td>
+ </tr>
<tr name='nonAnonymous'>
<td><label>$i18n.getString( "skip_to_generate_overdue_events" )</label></td>