dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24784
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12203: Fixed bug - Non-repeatable stages are available in Create New Event list even if a program stage ...
------------------------------------------------------------
revno: 12203
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-09-23 16:00:29 +0700
message:
Fixed bug - Non-repeatable stages are available in Create New Event list even if a program stage instance with that program stage already exists.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.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-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-09-23 04:29:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-09-23 09:00:29 +0000
@@ -613,15 +613,20 @@
function setSuggestedDueDate( programInstanceId )
{
- var lastVisit = jQuery('.stage-object-selected').attr('reportDate');
- jQuery('#tb_' + programInstanceId + ' input').each(function()
+ var lastVisit = "";
+ if( jQuery('.stage-object-selected').length!=0 )
{
- var reportDate = jQuery(this).attr('reportDate');
- if( reportDate > lastVisit )
+ var lastVisit = jQuery('.stage-object-selected').attr('reportDate');
+ jQuery('#tb_' + programInstanceId + ' input').each(function()
{
- lastVisit = reportDate;
- }
- });
+ var reportDate = jQuery(this).attr('reportDate');
+ if( reportDate > lastVisit )
+ {
+ lastVisit = reportDate;
+ }
+ });
+ }
+
if( lastVisit == ''){
lastVisit = getCurrentDate();
}
@@ -645,15 +650,13 @@
// Register Irregular-encounter
//------------------------------------------------------
-function registerIrregularEncounter( programInstanceId, programStageId, programStageName, dueDate )
+function registerIrregularEncounter( programInstanceId, programStageId, programStageUid, programStageName, dueDate )
{
if(dueDate==''){
showById("spanDueDateNewEncounter_" + programInstanceId);
}
else
{
- hideById("spanDueDateNewEncounter_" + programInstanceId);
-
jQuery.postJSON( "registerIrregularEncounter.action",
{
programInstanceId:programInstanceId,
@@ -668,47 +671,44 @@
var elementId = prefixId + programStageInstanceId;
var flag = false;
var programType = jQuery('.stage-object-selected').attr('type');
-
+ var selectedStage = jQuery('#repeatableProgramStage_' + programInstanceId + ' option:selected');
+ var elementBox = '<td>'
+ + '<div class="orgunit-object" id="org_' + programStageInstanceId + '"> </div>'
+ + '<input name="programStageBtn" '
+ + 'pi="' + programInstanceId + '" '
+ + 'id="' + elementId + '" '
+ + 'psid="' + programStageId + '" '
+ + 'psuid="' + programStageUid + '" '
+ + 'psname="' + programStageName + '" '
+ + 'status=3'
+ + 'programType="' + selectedStage.attr('programType') + '" '
+ + 'reportDate="" '
+ + 'reportDateDes="' + selectedStage.attr('reportDateDes') + '" '
+ + 'dueDate="' + dueDate + '" '
+ + 'openAfterEnrollment="' + selectedStage.attr('selectedStage') + '" '
+ + 'reportDateToUse="' + selectedStage.attr('reportDateToUse') + '" '
+ + 'class="stage-object" '
+ + 'value="'+ programStageName + ' ' + dueDate + '" '
+ + 'onclick="javascript:loadDataEntry(' + programStageInstanceId + ')" '
+ + 'type="button" '
+ + '></td>';
+
jQuery("#programStageIdTR_" + programInstanceId + " input[name='programStageBtn']").each(function(i,item){
var element = jQuery(item);
var dueDateInStage = element.attr('dueDate');
+
if( dueDate < dueDateInStage && !flag)
{
- jQuery('<td>'
- + '<div class="orgunit-object" id="org_' + programStageInstanceId + '"> </div>'
- + '<input name="programStageBtn" '
- + 'pi="' + programInstanceId + '" '
- + 'id="' + elementId + '" '
- + 'psid="' + programStageId + '" '
- + 'programType="' + programType + '" '
- + 'psname="' + programStageName + '" '
- + 'dueDate="' + dueDate + '" '
- + 'value="'+ programStageName + ' ' + dueDate + '" '
- + 'onclick="javascript:loadDataEntry(' + programStageInstanceId + ')" '
- + 'type="button" class="stage-object" '
- + '></td>'
- + '<td id="arrow_' + programStageInstanceId + '"><img src="images/rightarrow.png"></td>')
- .insertBefore(element.parent());
+ jQuery(elementBox + '<td id="arrow_' + programStageInstanceId + '"><img src="images/rightarrow.png"></td>').insertBefore(element.parent());
flag = true;
}
});
if( !flag )
{
- jQuery("#programStageIdTR_" + programInstanceId).append('<td id="arrow_' + programStageInstanceId + '"><img src="images/rightarrow.png"></td>'
- + '<td>'
- + '<div class="orgunit-object" id="org_' + programStageInstanceId + '"> </div>'
- + '<input name="programStageBtn" '
- + 'pi="' + programInstanceId + '" '
- + 'id="' + elementId + '" '
- + 'psid="' + programStageId + '" '
- + 'programType="' + programType + '" '
- + 'psname="' + programStageName + '" '
- + 'dueDate="' + dueDate + '" '
- + 'value="'+ programStageName + ' ' + dueDate + '" '
- + 'onclick="javascript:loadDataEntry(' + programStageInstanceId + ')" '
- + 'type="button" class="stage-object" '
- + '></td>');
+ jQuery("#programStageIdTR_" + programInstanceId).append(
+ '<td id="arrow_' + programStageInstanceId + '">'
+ + '<img src="images/rightarrow.png"></td>' + elementBox );
}
if( jQuery('#tb_' + programInstanceId + " :input" ).length > 4 ){
jQuery('#tb_' + programInstanceId + ' .arrow-left').removeClass("hidden");
@@ -730,6 +730,21 @@
jQuery('#createNewEncounterDiv_' + programInstanceId).dialog("close");
resetActiveEvent(programInstanceId);
loadDataEntry( programStageInstanceId );
+
+ // Disable Create new event button in the entry form if doesn't have any stage for register
+ flag = true;
+ jQuery('#repeatableProgramStage_' + programInstanceId + " option ").each(function(){
+ if( jQuery(this).attr('localid')== programStageId){
+ jQuery(this).css("display","none");
+ }
+ if( jQuery(this).css('display')!= "none"){
+ flag = false;
+ }
+ });
+ if( flag ){
+ disable( 'newEncounterBtn_' + programInstanceId );
+ }
+ closeDueDateDiv( programInstanceId );
showSuccessMessage(i18n_create_event_success);
});
}
@@ -999,6 +1014,14 @@
jQuery('#arrow_' + programStageInstanceId).remove();
jQuery('#org_' + programStageInstanceId).remove();
resetActiveEvent( programInstanceId );
+
+ jQuery('#repeatableProgramStage_' + programInstanceId + " option ").each(function(){
+ if( jQuery(this).attr('localid')== programStageId){
+ jQuery(this).css('display','block');
+ }
+ });
+ enable( 'newEncounterBtn_' + programInstanceId );
+
showSuccessMessage( i18n_delete_success );
}
else if ( json.response == "error" )
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2013-09-19 08:26:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2013-09-23 09:00:29 +0000
@@ -409,14 +409,6 @@
}
}
- var linkedEvent = jQuery(".stage-object-selected").attr("linkedEvent");
- if( linkedEvent=='true' ) {
- blockEntryForm();
- disable('executionDate');
- }
- else{
- enable('executionDate');
- }
$(window).scrollTop(200);
}
else
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm 2013-09-19 08:26:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm 2013-09-23 09:00:29 +0000
@@ -45,7 +45,6 @@
reportDateToUse="$reportDateToUse"
class="stage-object"
value="$programStageInstance.programStage.displayName $valueDate"
- linkedEvent='false'
onclick="javascript:loadDataEntry( $programStageInstance.id );">
<script>
var status = $programStageInstance.getEventStatus();
@@ -96,10 +95,25 @@
#set($hasEvent="true")
#end
#end
+
+ #set($reportDateToUse = "")
+ #if($programStageInstance.programStage.reportDateToUse=='registrationDate' )
+ #set($reportDateToUse = "$format.formatDate( $programInstance.patient.registrationDate)")
+ #elseif($programStageInstance.programStage.reportDateToUse=='dateOfIncident' )
+ #set($reportDateToUse = "$format.formatDate( $programInstance.dateOfIncident)")
+ #elseif($programStageInstance.programStage.reportDateToUse=='enrollmentDate' )
+ #set($reportDateToUse = "$format.formatDate( $programInstance.enrollmentDate)")
+ #end
<option
#if($hasEvent=="true") style="display:none;" #else selected #end
value="$programStage.uid" localid='$programStage.id' prevStageId='$prevStageId'
- standardInterval='$programStage.minDaysFromStart' allowGenerateNextVisit='$allowGenerateNextVisit' repeatable="false">$!programStage.displayName</option>
+ standardInterval='$programStage.minDaysFromStart' allowGenerateNextVisit='$allowGenerateNextVisit'
+ programType = '$programStage.program.type'
+ reportDateDes='$programStage.reportDateDescription'
+ repeatable="false"
+ openAfterEnrollment="$programStage.openAfterEnrollment"
+ reportDateToUse="$reportDateToUse"
+ >$!programStage.displayName</option>
#end
@@ -130,7 +144,7 @@
<tr>
<td></td>
<td>
- <input type='button' value='$i18n.getString("create")' onclick='registerIrregularEncounter( "$!programInstance.id",jQuery("#repeatableProgramStage_$!programInstance.id option:selected").attr("localid"), jQuery("#repeatableProgramStage_$!programInstance.id option:selected").text(),getFieldValue("dueDateNewEncounter_$programInstance.id" ) );' />
+ <input type='button' value='$i18n.getString("create")' onclick='registerIrregularEncounter( "$!programInstance.id", jQuery("#repeatableProgramStage_$!programInstance.id option:selected").attr("localid"),jQuery("#repeatableProgramStage_$!programInstance.id option:selected").val(), jQuery("#repeatableProgramStage_$!programInstance.id option:selected").text(),getFieldValue("dueDateNewEncounter_$programInstance.id" ) );' />
<input type='button' value='$i18n.getString("cancel")' onclick="closeDueDateDiv('$!programInstance.id');" />
</td>
</tr>
@@ -148,16 +162,21 @@
var i18n_create_new_event = '$encoder.jsEscape( $i18n.getString( "create_new_event" ) , "'" )';
var i18n_create_event_success = '$encoder.jsEscape( $i18n.getString( "create_event_success" ) , "'" )';
jQuery(document).ready( function(){
- var options = jQuery("#repeatableProgramStage_$!programInstance.id option").length;
+ var options = jQuery('#repeatableProgramStage_' + $programInstance.id + " option ").length;
if( options==0 ){
jQuery("[name=newEncounterBtn]").addClass("hidden");
}
else{
jQuery("[name=newEncounterBtn]").addClass("show-new-event");
}
+
+ if( jQuery('.stage-object').length > 0 ){
+ disable( 'newEncounterBtn_$programInstance.id' );
+ }
resize();
});
+
$(window).bind('resize', function(e){
resize();
});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2013-09-19 08:26:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2013-09-23 09:00:29 +0000
@@ -41,11 +41,6 @@
<td><input type="text" id="minDaysFromStart" name="minDaysFromStart" class="{validate:{number:true,min:0}}"/></td>
</tr>
- <tr>
- <td><label>$i18n.getString( "auto_generate_event" )</label></td>
- <td><input type="checkbox" id="autoGenerateEvent" name="autoGenerateEvent" value='true' checked /></td>
- </tr>
-
<tr><th colspan="2">$i18n.getString( "repeatable_program_stage_details" )</th></tr>
<tr>
@@ -74,6 +69,12 @@
#end
#end
+ <tr>
+ <td><label>$i18n.getString( "auto_generate_event" )</label></td>
+ <td><input type="checkbox" id="autoGenerateEvent" name="autoGenerateEvent" value='true' checked onchange='autoGenerateEventOnChange("$openAfterEnrollment")' /></td>
+ </tr>
+
+
#if($openAfterEnrollment!='' )
<tr>
<td colspan='2' style="color:grey;font-style:italic">$i18n.getString('the_properties_to_open_data_entry_form_after_enrolment_is_active_in_the_stage'): $openAfterEnrollment</td>
@@ -84,8 +85,7 @@
<tr>
<td><label>$i18n.getString( "open_data_entry_form_after_enrolment" )</label></td>
<td><input type="checkbox" id="openAfterEnrollment" name="openAfterEnrollment" value='true'
- onchange="openAfterEnrollmentOnchange();"
- #if($openAfterEnrollment!='' ) disabled #end >
+ onchange="openAfterEnrollmentOnchange();" disabled >
</td>
<td></td>
</tr>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js 2013-09-19 08:26:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js 2013-09-23 09:00:29 +0000
@@ -466,3 +466,17 @@
disable('reportDateToUse');
}
}
+
+function autoGenerateEventOnChange(openAfterEnrollment)
+{
+ if(openAfterEnrollment==''){
+ if( byId('autoGenerateEvent').checked ){
+ enable('openAfterEnrollment');
+ }
+ else{
+ disable('openAfterEnrollment');
+ disable('reportDateToUse');
+ }
+ }
+}
+
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2013-09-19 08:26:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2013-09-23 09:00:29 +0000
@@ -43,11 +43,6 @@
<td><input type="text" id="minDaysFromStart" name="minDaysFromStart" value="$programStage.minDaysFromStart" class="{validate:{number:true,min:0}}"/></td>
</tr>
- <tr>
- <td><label>$i18n.getString( "auto_generate_event" )</label></td>
- <td><input type="checkbox" id="autoGenerateEvent" name="autoGenerateEvent" value='true' #if( $programStage.autoGenerateEvent && $programStage.autoGenerateEvent=='true' ) checked #end /></td>
- </tr>
-
<tr><th colspan="2">$i18n.getString( "repeatable_program_stage_details" )</th></tr>
<tr>
@@ -76,6 +71,11 @@
#end
#end
+ <tr>
+ <td><label>$i18n.getString( "auto_generate_event" )</label></td>
+ <td><input type="checkbox" id="autoGenerateEvent" name="autoGenerateEvent" value='true' onchange='autoGenerateEventOnChange("$openAfterEnrollment")' #if( $programStage.autoGenerateEvent && $programStage.autoGenerateEvent=='true' ) checked #end /></td>
+ </tr>
+
#if($openAfterEnrollment!='' )
<tr>
<td colspan='2' style="color:grey;font-style:italic">$i18n.getString('the_properties_to_open_data_entry_form_after_enrolment_is_active_in_the_stage'): $openAfterEnrollment</td>
@@ -87,7 +87,7 @@
<td><label>$i18n.getString( "open_data_entry_form_after_enrolment" )</label></td>
<td><input type="checkbox" id="openAfterEnrollment" name="openAfterEnrollment" value='true'
#if($programStage.openAfterEnrollment=='true') checked #end
- #if($openAfterEnrollment!='' ) disabled #end
+ #if($openAfterEnrollment!='' || $programStage.autoGenerateEvent=='false' ) disabled #end
onchange="openAfterEnrollmentOnchange()" ></td>
<td></td>
</tr>
@@ -96,7 +96,7 @@
<td><label>$i18n.getString( "report_date_to_use" )</label></td>
<td>
<select id="reportDateToUse" name="reportDateToUse" class="{validate:{required:true}}"
- #if($openAfterEnrollment!='' ) disabled #elseif($programStage.openAfterEnrollment=='false') disabled #end >
+ #if($openAfterEnrollment!='' || $programStage.autoGenerateEvent=='false' ) disabled #elseif($programStage.openAfterEnrollment=='false') disabled #end >
<option value=''>[$i18n.getString('please_select')]</option>
<option value='registrationDate' #if($programStage.reportDateToUse=='registrationDate') selected #end >$i18n.getString("registration_date")</option>
<option value='dateOfIncident' #if($programStage.reportDateToUse=='dateOfIncident') selected #end >$i18n.getString("date_of_incident")</option>