← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8148: Only allow 1 scheduled visit per day per person-programme.

 

------------------------------------------------------------
revno: 8148
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-09-20 12:15:30 +0700
message:
  Only allow 1 scheduled visit per day per person-programme.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SetEventStatusAction.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/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientProgramTracking.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.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/java/org/hisp/dhis/caseentry/action/reminder/SetEventStatusAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SetEventStatusAction.java	2012-09-20 04:13:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SetEventStatusAction.java	2012-09-20 05:15:30 +0000
@@ -93,7 +93,12 @@
             programStageInstance.setStatus( null );
             break;
         case ProgramStageInstance.LATE_VISIT_STATUS:
-            programStageInstance.setStatus( status );
+            programStageInstance.setCompleted( false );
+            programStageInstance.setStatus( null );
+            break;
+        case ProgramStageInstance.FUTURE_VISIT_STATUS:
+            programStageInstance.setCompleted( false );
+            programStageInstance.setStatus( null );
             break;
         case ProgramStageInstance.SKIPPED_STATUS:
             programStageInstance.setStatus( status );

=== 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-09-20 04:13:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-09-20 05:15:30 +0000
@@ -455,4 +455,5 @@
 scheduled_overdue_incomplete = Scheduled/Overdue/Incomplete
 relationships = Relationships
 no_program_available_for_enrollment = No program is available for enrollment
-reschedule = Re-schedule
\ No newline at end of file
+reschedule = Re-schedule
+the_date_is_scheduled = The date is scheduled
\ No newline at end of file

=== 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	2012-09-20 04:13:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-09-20 05:15:30 +0000
@@ -441,7 +441,8 @@
 		case 5:
 			boxElement.css('border-color', COLOR_GREY);
 			boxElement.css('background-color', COLOR_LIGHT_GREY);
-			jQuery("#" + dueDateElementId ).datepicker("destroy");
+			disable( 'ps_' + programStageInstanceId );
+			jQuery( "#" + dueDateElementId ).datepicker("destroy");
 			disable( dueDateElementId );
 			return;
 		default:
@@ -790,9 +791,19 @@
 // Save due-date
 //-----------------------------------------------------------------------------
 
-function saveDueDate( programStageInstanceId, programStageInstanceName )
+function saveDueDate( programInstanceId, programStageInstanceId, programStageInstanceName )
 {
 	var field = document.getElementById( 'value_' + programStageInstanceId + '_date' );
+	var flag = false;
+	jQuery('#flow_' + programInstanceId + ' .stage-object').each(function(){
+		var dueDate = jQuery(this).attr('dueDate');
+		var boxId = "ps_" + programStageInstanceId;
+		if( dueDate == field.value && this.id != boxId ){
+			showWarningMessage(i18n_the_date_is_scheduled);
+			flag = true;
+		}
+	})
+	if(flag) return;
 	
 	var dateOfIncident = new Date( byId('dateOfIncident').value );
 	var dueDate = new Date(field.value);
@@ -825,6 +836,7 @@
 			   data: params,
 			   dataType: "xml",
 			   success: function(result){
+					jQuery('#ps_' + programStageInstanceId ).attr('dueDate', dueDate );
 					handleResponse (result);
 			   },
 			   error: function(request,status,errorThrown) {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientProgramTracking.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientProgramTracking.vm	2012-09-20 04:13:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientProgramTracking.vm	2012-09-20 05:15:30 +0000
@@ -129,7 +129,7 @@
 					#set( $duedateId = "value_" + $programStageInstance.id + "_date" )        
 					#set($status = $statusMap.get( $programStageInstance.id ))
 					<td>        
-						<input type="text" id="$duedateId" style='width:150px;' value="$!format.formatDate( $programStageInstance.dueDate )" onchange="saveDueDate( $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" />
+						<input type="text" id="$duedateId" style='width:150px;' value="$!format.formatDate( $programStageInstance.dueDate )" onchange="saveDueDate( $programInstance.id, $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" />
 						<script type="text/javascript">
 							#if($status==1 || $status==5 )
 								disable('$duedateId');
@@ -141,10 +141,14 @@
 					<td>
 						<select id="stat_$programStageInstance.id" name="status_$programStageInstance.id" style='width:150px;' onchange="setEventStatus(this, $programStageInstance.id)">
 							#if($status==4)
-								<option value='4' selected>$i18n.getString("overdue")</option>
+								<option value='4'>$i18n.getString("overdue")</option>
 								<option value='5'>$i18n.getString("skipped")</option>
 							#elseif($status==3)
-								<option value='3' selected>$i18n.getString("scheduled_in_future")</option>
+								<option value='3'>$i18n.getString("scheduled_in_future")</option>
+								<option value='5'>$i18n.getString("skipped")</option>
+							#elseif($status==5)
+								<option value='4'>$i18n.getString("overdue")</option>
+								<option value='3'>$i18n.getString("scheduled_in_future")</option>
 								<option value='5'>$i18n.getString("skipped")</option>
 							#else
 								<option value='1'>$i18n.getString("completed")</option>
@@ -161,7 +165,7 @@
 					</td>
 					<td>
 						<a href="javascript:setFieldValue('sendToList', false);showSendSmsForm('$programStageInstance.programStage.name',$programStageInstance.id)" title='$i18n.getString( "send_sms" )'><img src="images/sms.png" alt='$i18n.getString( "send_sms" )'></a>
-						#if($programStageInstance.programStage.irregular=='true' && ($status==3 || $status==4 $status==5 ))
+						#if($programStageInstance.programStage.irregular=='true' && ($status==3 || $status==4 || $status==5 ))
 							<a href="javascript:removeEvent($programStageInstance.id, false)" title='$i18n.getString( "remove" )'><img src="../images/delete.png" alt='$i18n.getString( "remove" )'></a>
 						#end
 					</td>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2012-09-20 04:13:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2012-09-20 05:15:30 +0000
@@ -165,7 +165,7 @@
 					#set( $duedateId = "value_" + $programStageInstance.id + "_date" )        
 					#set($status = $statusMap.get( $programStageInstance.id ))
 					<td class='input-column '>        
-						<input type="text" id="$duedateId" name="entryfield" value="$!format.formatDate( $programStageInstance.dueDate )" onchange="saveDueDate( $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" />
+						<input type="text" id="$duedateId" name="entryfield" value="$!format.formatDate( $programStageInstance.dueDate )" onchange="saveDueDate( $programInstance.id, $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" />
 						<script type="text/javascript">
 							#if($status==1 || $status==5 )
 								disable('$duedateId');
@@ -175,13 +175,17 @@
 						</script> 
 					</td> 
 
-					<td>
+					<td>$status
 						<select id="stat_$programStageInstance.id" name="status_$programStageInstance.id" style='width:150px;' onchange="setEventStatus(this, $programStageInstance.id)">
 							#if($status==4)
-								<option value='4' selected>$i18n.getString("overdue")</option>
+								<option value='4'>$i18n.getString("overdue")</option>
 								<option value='5'>$i18n.getString("skipped")</option>
 							#elseif($status==3)
-								<option value='3' selected>$i18n.getString("scheduled_in_future")</option>
+								<option value='3'>$i18n.getString("scheduled_in_future")</option>
+								<option value='5'>$i18n.getString("skipped")</option>
+							#elseif($status==5)
+								<option value='4'>$i18n.getString("overdue")</option>
+								<option value='3'>$i18n.getString("scheduled_in_future")</option>
 								<option value='5'>$i18n.getString("skipped")</option>
 							#else
 								<option value='1'>$i18n.getString("completed")</option>
@@ -189,7 +193,7 @@
 							#end
 						</select>
 						<script>
-							setFieldValue("stat_$programStageInstance.id", $status);
+							setFieldValue("stat_$programStageInstance.id", "$status");
 						</script>
 					</td>
 					

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm	2012-09-20 04:13:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm	2012-09-20 05:15:30 +0000
@@ -75,7 +75,7 @@
 				<td>$i18n.getString( "reschedule_due_date" )</td>        
 				#set( $duedateId = "value_" + $programStageInstance.id + "_date" )        
 				<td>        
-					<input type="text" id="$duedateId" value="$!format.formatDate( $programStageInstance.dueDate )" onchange="saveDueDate( $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" />
+					<input type="text" id="$duedateId" value="$!format.formatDate( $programStageInstance.dueDate )" onchange="saveDueDate( $programInstance.id, $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" />
 					<input type="hidden" name="enrollmentDate" id="enrollmentDate" value="$!format.formatDate( $programInstance.enrollmentDate )">
 					<input type="hidden" name="dateOfIncident" id="dateOfIncident" value="$!format.formatDate( $programInstance.dateOfIncident )">
 					<script type="text/javascript">
@@ -92,10 +92,14 @@
 				<td>
 					<select id="stat_$programStageInstance.id" name="status_$programStageInstance.id" onchange="setEventStatus(this, $programStageInstance.id)">
 						#if($status==4)
-							<option value='4' selected>$i18n.getString("overdue")</option>
+							<option value='4'>$i18n.getString("overdue")</option>
 							<option value='5'>$i18n.getString("skipped")</option>
 						#elseif($status==3)
-							<option value='3' selected>$i18n.getString("scheduled_in_future")</option>
+							<option value='3'>$i18n.getString("scheduled_in_future")</option>
+							<option value='5'>$i18n.getString("skipped")</option>
+						#elseif($status==5)
+							<option value='4'>$i18n.getString("overdue")</option>
+							<option value='3'>$i18n.getString("scheduled_in_future")</option>
 							<option value='5'>$i18n.getString("skipped")</option>
 						#else
 							<option value='1'>$i18n.getString("completed")</option>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm	2012-09-15 04:18:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm	2012-09-20 05:15:30 +0000
@@ -59,7 +59,8 @@
 	var i18n_update = '$encoder.jsEscape( $i18n.getString( "update" ) , "'")';
 	var i18n_comfirm_delete_event = '$encoder.jsEscape( $i18n.getString( "comfirm_delete_event" ) , "'")';
 	var i18n_please_select_criteria = '[' + '$encoder.jsEscape( $i18n.getString( "please_select_criteria" ) , "'")' + ']';
-	
+	var i18n_the_date_is_scheduled = '$encoder.jsEscape( $i18n.getString( "the_date_is_scheduled" ) , "'")';
+
 	var date = new Date();
 	var d = date.getDate();
 	var m = date.getMonth();

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2012-09-20 04:13:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2012-09-20 05:15:30 +0000
@@ -104,7 +104,7 @@
 	var i18n_create_new_event = '$encoder.jsEscape( $i18n.getString( "create_new_event" ) , "'")';
 	var i18n_enroll_program = '$encoder.jsEscape( $i18n.getString( "enroll_program" ) , "'")';
 	var i18n_comfirm_delete_event = '$encoder.jsEscape( $i18n.getString( "comfirm_delete_event" ) , "'")';
-
+	var i18n_the_date_is_scheduled = '$encoder.jsEscape( $i18n.getString( "the_date_is_scheduled" ) , "'")';
 	var checkedDuplicate = false;
 	// -1: no search anything
 	//  0: show list all patient