← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8565: Don't add new event when to update report-date for anonymous event.

 

------------------------------------------------------------
revno: 8565
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-10-18 11:24:34 +0700
message:
  Don't add new event when to update report-date for anonymous event.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java
  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/anonymousRegistration.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.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/programEnrollmentForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.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/caseentry/SaveExecutionDateAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java	2012-09-21 06:20:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java	2012-10-18 04:24:34 +0000
@@ -142,10 +142,7 @@
         Date dateValue = format.parseDate( executionDate );
         
         if ( dateValue != null )
-        {
-//            // Get program-stage-instance of the patient
-//            ProgramStageInstance programStageInstance = selectedStateManager.getSelectedProgramStageInstance();
-            
+        {           
             ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
 
             // If the program-stage-instance of the patient not exists,

=== 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	2012-10-06 15:55:56 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-10-18 04:24:34 +0000
@@ -89,11 +89,11 @@
 
 		<action name="saveExecutionDate"
 			class="org.hisp.dhis.caseentry.action.caseentry.SaveExecutionDateAction">
-			<result name="success" type="velocity-xml">
-				/dhis-web-commons/ajax/xmlResponseSuccess.vm
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
 			</result>
-			<result name="input" type="velocity-xml">
-				/dhis-web-commons/ajax/xmlResponseInput.vm
+			<result name="input" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseInput.vm
 			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 			<param name="requiredAuthorities">F_PATIENT_DATAVALUE_ADD,F_PATIENT_DATAVALUE_UPDATE,F_PATIENT_DATAVALUE_DELETE</param>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2012-10-18 03:43:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2012-10-18 04:24:34 +0000
@@ -14,7 +14,7 @@
 				
 <h3 id='mainLinkLbl'>$i18n.getString( "anonymous_events" ) #openHelp('single_event_without_registration')</h3>
 <input type='hidden' id='orgunitId' name='orgunitId' value='$orgunit.id'>
-<input type='hidden' id='programStageInstanceId' name='programStageInstanceId'>
+<input type='hidden' id='programStageInstanceId' name='programStageInstanceId' value='0'>
 <input type='hidden' id='programStageId' name='programStageId' class='stage-object-selected'>
 <input type='hidden' id='isShowEventList' name='isShowEventList'>
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-10-05 07:47:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-10-18 04:24:34 +0000
@@ -10,10 +10,6 @@
 			setFieldValue( 'dueDate', "$!format.formatDate( $programStageInstance.dueDate )" );
 			setFieldValue( 'executionDate', "$!format.formatDate( $programStageInstance.executionDate )" );
 		#end
-		$('#executionDate').unbind("change");
-		$('#executionDate').change(function() {
-			saveExecutionDate( getFieldValue('programId'), $programStageInstance.id, byId('executionDate') );
-		});
 		
 		entryFormContainerOnReady();
 	});

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2012-10-11 09:44:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2012-10-18 04:24:34 +0000
@@ -347,25 +347,35 @@
 	hideById('mainLinkLbl');
 	hideById('actionDiv');
 	showById('dataEntryInfor');
+	setFieldValue('programStageInstanceId','0');
 	setInnerHTML('programName', jQuery('#programId option:selected').text());
 }
 
 function addNewEvent()
 {
-	jQuery.postJSON( "createAnonymousEncounter.action",
+	var programStageInstanceId = getFieldValue('programStageInstanceId');
+	var programId = jQuery('#programId option:selected').val();
+	var executionDate = getFieldValue('executionDate');
+	jQuery("#executionDate").css('background-color', SAVING_COLOR);
+	jQuery.postJSON( "saveExecutionDate.action",
 		{
-			programId: jQuery('#programId option:selected').val(),
-			executionDate: getFieldValue('executionDate')
+			programStageInstanceId:programStageInstanceId,
+			programId:programId,
+			executionDate:executionDate
 		}, 
 		function( json ) 
 		{    
 			if(json.response=='success')
 			{
+				jQuery("#executionDate").css('background-color', SUCCESS_COLOR);
 				setFieldValue('programStageInstanceId',json.message);
-				showUpdateEvent( json.message );
+				if(programStageInstanceId != json.message){
+					showUpdateEvent( json.message );
+				}
 			}
 			else
 			{
+				jQuery("#executionDate").css('background-color', ERROR_COLOR);
 				showWarningMessage( json.message );
 			}
 		});

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-10-06 13:46:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-10-18 04:24:34 +0000
@@ -354,8 +354,8 @@
 			   type: "POST",
 			   url: "saveExecutionDate.action",
 			   data: params,
-			   dataType: "xml",
-			   success: function( result ){	
+			   dataType: "json",
+			   success: function( json ){	
 					var selectedProgramStageInstance = jQuery( '#' + prefixId + getFieldValue('programStageInstanceId') );
 					var box = jQuery(".stage-object-selected");
 					var boxName = box.attr('psname') + "\n" + executionDate;
@@ -372,7 +372,7 @@
 					jQuery("#org_" + programStageInstanceId ).html(getFieldValue("orgunitName"));
 					showById('inputCriteriaDiv');
 					
-					handleResponse (result);
+					handleResponse (json);
 			   },
 			   error: function(request,status,errorThrown) {
 					handleHttpError (request);
@@ -380,16 +380,14 @@
 			});
     };
 
-    function handleResponse( rootElement )
+    function handleResponse( json )
     {
-		rootElement = rootElement.getElementsByTagName( 'message' )[0];
-        var codeElement = rootElement.getAttribute( 'type' );
-        if ( codeElement == 'success' )
-        {
+		if(json.response=='success')
+		{
             markValue( resultColor );
 			if( getFieldValue('programStageInstanceId' )=='' )
 			{
-				var programStageInstanceId = rootElement.firstChild.nodeValue;
+				var programStageInstanceId = json.message;
 				setFieldValue('programStageInstanceId', programStageInstanceId);
 				loadDataEntry( programStageInstanceId );
 			}

=== 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	2012-10-17 07:23:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-10-18 04:24:34 +0000
@@ -204,6 +204,12 @@
 	disableCompletedButton(true);
 	disable('uncompleteBtn');
 	
+	$('#executionDate').unbind("change");
+	$('#executionDate').change(function() {
+		saveExecutionDate( getFieldValue('programId'), programStageInstanceId, byId('executionDate') );
+	});
+		
+		
 	jQuery(".stage-object-selected").removeClass('stage-object-selected');
 	var selectedProgramStageInstance = jQuery( '#' + prefixId + programStageInstanceId );
 	selectedProgramStageInstance.addClass('stage-object-selected');

=== 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-10-17 04:17:37 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2012-10-18 04:24:34 +0000
@@ -33,7 +33,7 @@
 						<table id='executionDateTB' name="executionDateTB" class='hidden'>
 							<tr>
 								<th class='text-column'><span id="reportDateDescriptionField">$i18n.getString( "report_date" ) </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
-								<th><input type="text" id="executionDate" name="executionDate" class='criteria' value="$!format.formatDate( $programStageInstance.executionDate )" >
+								<th><input type="text" id="executionDate" name="executionDate" class='criteria' value="$!format.formatDate( $programStageInstance.executionDate )">
 									<script type="text/javascript">
 									   datePickerValid( 'executionDate', false );
 									</script>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.vm	2012-10-17 09:19:19 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.vm	2012-10-18 04:24:34 +0000
@@ -27,7 +27,7 @@
 		#if( $programStageInstance )
 			<tr>
 				<th><label for="executionDate">$programStageInstance.programStage.reportDateDescription &nbsp;&nbsp;&nbsp;</label></th>
-				<th><input type="text" id="executionDate" name="executionDate" value="$!format.formatDate( $programStageInstance.executionDate )" onchange="saveExecutionDate( $programStageInstance.id, $programStageInstance.id, byId('executionDate') )" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
+				<th><input type="text" id="executionDate" name="executionDate" value="$!format.formatDate( $programStageInstance.executionDate )" onchange="saveExecutionDate( $programStageInstance.programInstance.progam.id, $programStageInstance.id, byId('executionDate') )" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
 					<script type="text/javascript">
 					   datePickerValid( 'executionDate', false );
 					</script>