← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8207: Remove unused js-methods

 

------------------------------------------------------------
revno: 8207
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-09-23 19:58:02 +0700
message:
  Remove unused js-methods
modified:
  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/smsReminder.js


--
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/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-09-21 10:08:15 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-09-23 12:58:02 +0000
@@ -19,6 +19,45 @@
 selection.setListenerFunction( organisationUnitSelected );
 
 // -----------------------------------------------------------------------------
+// List && Search patients
+// -----------------------------------------------------------------------------
+
+function listAllPatient()
+{
+	hideById('listPatientDiv');
+	hideById('editPatientDiv');
+	hideById('migrationPatientDiv');
+	
+	jQuery('#loaderDiv').show();
+	contentDiv = 'listPatientDiv';
+	jQuery('#listPatientDiv').load('searchRegistrationPatient.action',{
+			listAll:true
+		},
+		function(){
+			statusSearching = 0;
+			showById('listPatientDiv');
+			jQuery('#loaderDiv').hide();
+		});
+	hideLoader();
+}
+
+function advancedSearch( params )
+{
+	$.ajax({
+		url: 'searchRegistrationPatient.action',
+		type:"POST",
+		data: params,
+		success: function( html ){
+				statusSearching = 1;
+				setInnerHTML( 'listPatientDiv', html );
+				showById('listPatientDiv');
+				setFieldValue('listAll',false);
+				jQuery( "#loaderDiv" ).hide();
+			}
+		});
+}
+
+// -----------------------------------------------------------------------------
 // Remove patient
 // -----------------------------------------------------------------------------
 
@@ -27,25 +66,27 @@
 	removeItem( patientId, fullName, i18n_confirm_delete, 'removePatient.action' );
 }
 
-function sortPatients()
+// -----------------------------------------------------------------------------
+// Add Patient
+// -----------------------------------------------------------------------------
+
+function showAddPatientForm()
 {
-	hideById( 'listPatientDiv' );
+	hideById('listPatientDiv');
+	hideById('selectDiv');
+	hideById('searchDiv');
+	hideById('migrationPatientDiv');
 	
-	contentDiv = 'listPatientDiv';
-	jQuery( "#loaderDiv" ).show();
-	jQuery('#listPatientDiv').load("searchRegistrationPatient.action", 
+	jQuery('#loaderDiv').show();
+	jQuery('#editPatientDiv').load('showAddPatientForm.action'
+		, function()
 		{
-			sortPatientAttributeId: getFieldValue('sortPatientAttributeId')
-		}, function(){
-			showById('listPatientDiv');
-			jQuery( "#loaderDiv" ).hide();
+			showById('editPatientDiv');
+			jQuery('#loaderDiv').hide();
 		});
+	
 }
 
-// -----------------------------------------------------------------------------
-// Add Patient
-// -----------------------------------------------------------------------------
-
 function validateAddPatient()
 {	
 	$("#patientForm :input").attr("disabled", true);
@@ -86,11 +127,73 @@
 	}
 }
 
+function addPatient()
+{
+	$.ajax({
+      type: "POST",
+      url: 'addPatient.action',
+      data: getParamsForDiv('patientForm'),
+      success: function(json) {
+		var patientId = json.message.split('_')[0];
+		jQuery('#resultSearchDiv').dialog('close');
+		showPatientDashboardForm( patientId );
+      }
+     });
+    return false;
+}
+
+function addEventForPatientForm( divname )
+{
+	jQuery("#" + divname + " [id=checkDuplicateBtn]").click(function() {
+		checkDuplicate( divname );
+	});
+	
+	jQuery("#" + divname + " [id=dobType]").change(function() {
+		dobTypeOnChange( divname );
+	});
+}
+
+// -----------------------------------------------------------------------------
+// remove value of all the disabled identifier fields
+// an identifier field is disabled when its value is inherited from another person ( underAge is true ) 
+// we don't save inherited identifiers. Only save the representative id.
+// -----------------------------------------------------------------------------
+
+function removeDisabledIdentifier()
+{
+	jQuery("input.idfield").each(function(){
+		if( jQuery(this).is(":disabled"))
+			jQuery(this).val("");
+	});
+}
 
 // -----------------------------------------------------------------------------
 // Update Patient
 // -----------------------------------------------------------------------------
 
+function showUpdatePatientForm( patientId )
+{
+	hideById('listPatientDiv');
+	setInnerHTML('editPatientDiv', '');
+	hideById('selectDiv');
+	hideById('searchDiv');
+	hideById('migrationPatientDiv');
+	setInnerHTML('patientDashboard','');
+	
+	jQuery('#loaderDiv').show();
+	jQuery('#editPatientDiv').load('showUpdatePatientForm.action',
+		{
+			id:patientId
+		}, function()
+		{
+			jQuery('#searchPatientsDiv').dialog('close');
+			jQuery('#loaderDiv').hide();
+			showById('editPatientDiv');
+		});
+		
+	jQuery('#resultSearchDiv').dialog('close');
+}
+
 function validateUpdatePatient()
 {
 	$("#editPatientDiv :input").attr("disabled", true);
@@ -130,16 +233,30 @@
 		$("#editPatientDiv :input").attr("disabled", false);
 	}
 }
-// get and build a param String of all the identifierType id and its value
-// excluding inherited identifiers
-function getIdParams()
-{
-	var params = "";
-	jQuery("input.idfield").each(function(){
-		if( jQuery(this).val() && !jQuery(this).is(":disabled") )
-			params += "&" + jQuery(this).attr("name") +"="+ jQuery(this).val();
-	});
-	return params;
+
+function updatePatient()
+{
+	$.ajax({
+      type: "POST",
+      url: 'updatePatient.action',
+      data: getParamsForDiv('editPatientDiv'),
+      success: function( json ) {
+		showPatientDashboardForm( getFieldValue('id') );
+      }
+     });
+}
+
+function showRepresentativeInfo( patientId)
+{
+	jQuery('#representativeInfo' ).dialog({
+			title: i18n_representative_info,
+			maximize: true, 
+			closable: true,
+			modal: false,
+			overlay: {background:'#000000', opacity:0.1},
+			width: 400,
+			height: 300
+		});
 }
 
 /**
@@ -255,81 +372,6 @@
 }
 
 // ----------------------------------------------------------------
-// Add Patient
-// ----------------------------------------------------------------
-
-function showAddPatientForm()
-{
-	hideById('listPatientDiv');
-	hideById('selectDiv');
-	hideById('searchDiv');
-	hideById('migrationPatientDiv');
-	
-	jQuery('#loaderDiv').show();
-	jQuery('#editPatientDiv').load('showAddPatientForm.action'
-		, function()
-		{
-			showById('editPatientDiv');
-			jQuery('#loaderDiv').hide();
-		});
-	
-}
-
-function addPatient()
-{
-	$.ajax({
-      type: "POST",
-      url: 'addPatient.action',
-      data: getParamsForDiv('patientForm'),
-      success: function(json) {
-		var patientId = json.message.split('_')[0];
-		jQuery('#resultSearchDiv').dialog('close');
-		showPatientDashboardForm( patientId );
-      }
-     });
-    return false;
-}
-
-// ----------------------------------------------------------------
-// Update Patient
-// ----------------------------------------------------------------
-
-function showUpdatePatientForm( patientId )
-{
-	hideById('listPatientDiv');
-	setInnerHTML('editPatientDiv', '');
-	hideById('selectDiv');
-	hideById('searchDiv');
-	hideById('migrationPatientDiv');
-	setInnerHTML('patientDashboard','');
-	
-	jQuery('#loaderDiv').show();
-	jQuery('#editPatientDiv').load('showUpdatePatientForm.action',
-		{
-			id:patientId
-		}, function()
-		{
-			jQuery('#searchPatientsDiv').dialog('close');
-			jQuery('#loaderDiv').hide();
-			showById('editPatientDiv');
-		});
-		
-	jQuery('#resultSearchDiv').dialog('close');
-}
-
-function updatePatient()
-{
-	$.ajax({
-      type: "POST",
-      url: 'updatePatient.action',
-      data: getParamsForDiv('editPatientDiv'),
-      success: function( json ) {
-		showPatientDashboardForm( getFieldValue('id') );
-      }
-     });
-}
-
-// ----------------------------------------------------------------
 // Enrollment program
 // ----------------------------------------------------------------
 
@@ -436,6 +478,10 @@
 		});
 }
 
+// ----------------------------------------------------------------
+// Load program instance
+// ----------------------------------------------------------------
+
 function loadProgramInstance( programInstanceId, completed )
 {				
 	if( programInstanceId=='') {
@@ -467,6 +513,10 @@
 		});
 }
 
+// ----------------------------------------------------------------
+// Program enrollmment && unenrollment
+// ----------------------------------------------------------------
+
 function validateProgramEnrollment()
 {	
 	jQuery('#loaderDiv').show();
@@ -506,49 +556,6 @@
     return false;
 }
 
-// ----------------------------------------------------------------
-// Un-Enrollment program
-// ----------------------------------------------------------------
-
-function showUnenrollmentSelectForm( patientId )
-{
-	hideById('listPatientDiv');
-	hideById('editPatientDiv');
-	hideById('selectDiv');
-	hideById('searchDiv');
-	hideById('migrationPatientDiv');
-				
-	jQuery('#loaderDiv').show();
-	jQuery('#enrollmentDiv').load('showProgramUnEnrollmentForm.action',
-		{
-			patientId:patientId
-		}, function()
-		{
-			showById('enrollmentDiv');
-			jQuery('#loaderDiv').hide();
-		});
-}
-
-function showUnenrollmentForm( programInstanceId )
-{				
-	if( programInstanceId == 0 )
-	{
-		hideById( 'unenrollmentFormDiv' );
-		return;
-	}
-	
-	jQuery('#loaderDiv').show();
-	jQuery.getJSON( "getProgramInstance.action",
-		{
-			programInstanceId:programInstanceId
-		}, 
-		function( json ) 
-		{   
-			showById( 'unenrollmentFormDiv' );
-			jQuery( "#loaderDiv" ).hide();
-		});
-}
-
 function unenrollmentForm( programInstanceId )
 {	
 	$.ajax({
@@ -568,6 +575,22 @@
 	
 }
 
+function saveIdentifierAndAttribute( patientId, programId, paramsDiv)
+{
+	var params  = getParamsForDiv(paramsDiv);
+		params += "&patientId=" + patientId;
+		params +="&programId=" + programId;
+	$.ajax({
+			type: "POST",
+			url: 'savePatientIdentifierAndAttribute.action',
+			data: params,
+			success: function(json) 
+			{
+				showSuccessMessage( i18n_save_success );
+			}
+		});
+}
+
 //----------------------------------------------------
 // Show relationship with new patient
 //----------------------------------------------------
@@ -600,7 +623,7 @@
 }
 
 // ----------------------------------------------------------------
-// Click Back to Search button
+// Click Back to main form
 // ----------------------------------------------------------------
 
 function onClickBackBtn()
@@ -642,114 +665,9 @@
 	}
 }
 
-// -----------------------------------------------------------------------------
-// Load all patients
-// -----------------------------------------------------------------------------
-
-function listAllPatient()
-{
-	hideById('listPatientDiv');
-	hideById('editPatientDiv');
-	hideById('migrationPatientDiv');
-	
-	jQuery('#loaderDiv').show();
-	contentDiv = 'listPatientDiv';
-	jQuery('#listPatientDiv').load('searchRegistrationPatient.action',{
-			listAll:true
-		},
-		function(){
-			statusSearching = 0;
-			showById('listPatientDiv');
-			jQuery('#loaderDiv').hide();
-		});
-	hideLoader();
-}
-
-// -----------------------------------------------------------------------------
-// remove value of all the disabled identifier fields
-// an identifier field is disabled when its value is inherited from another person ( underAge is true ) 
-// we don't save inherited identifiers. Only save the representative id.
-// -----------------------------------------------------------------------------
-
-function removeDisabledIdentifier()
-{
-	jQuery("input.idfield").each(function(){
-		if( jQuery(this).is(":disabled"))
-			jQuery(this).val("");
-	});
-}
-
-function addEventForPatientForm( divname )
-{
-	jQuery("#" + divname + " [id=checkDuplicateBtn]").click(function() {
-		checkDuplicate( divname );
-	});
-	
-	jQuery("#" + divname + " [id=dobType]").change(function() {
-		dobTypeOnChange( divname );
-	});
-}
-
-function showRepresentativeInfo( patientId)
-{
-	jQuery('#representativeInfo' ).dialog({
-			title: i18n_representative_info,
-			maximize: true, 
-			closable: true,
-			modal: false,
-			overlay: {background:'#000000', opacity:0.1},
-			width: 400,
-			height: 300
-		});
-}
-
-function hideEnrolmentField()
-{
-	setFieldValue( 'enrollmentDate', '' );
-	setFieldValue( 'dateOfIncident', '' );
-	hideById('enrollmentDateTR');
-	hideById('dateOfIncidentTR');
-	hideById('unenrollBtn');
-}
-  
-function showEnrolmentField()
-{
-	showById('enrollmentDateTR');
-	showById('dateOfIncidentTR');
-	enable('dateOfIncident');
-}
-
-function hideIncidentDateField()
-{
-	setFieldValue( 'dateOfIncident', '' );
-	disable('dateOfIncident');
-	hideById('dateOfIncidentTR');
-}
-  
-function showIncidentDateField()
-{
-	showById('dateOfIncidentTR');
-}
-
-function saveIdentifierAndAttribute( patientId, programId, paramsDiv)
-{
-	var params  = getParamsForDiv(paramsDiv);
-		params += "&patientId=" + patientId;
-		params +="&programId=" + programId;
-	$.ajax({
-			type: "POST",
-			url: 'savePatientIdentifierAndAttribute.action',
-			data: params,
-			success: function(json) 
-			{
-				showSuccessMessage( i18n_save_success );
-			}
-		});
-}
-
-//--------------------------------------------------------------------------------------------
+// ----------------------------------------------------------------
 // Show selected data-recording
-//--------------------------------------------------------------------------------------------
+// ----------------------------------------------------------------
 
 function showSelectedDataRecoding( patientId )
 {
@@ -777,25 +695,9 @@
 		});
 }
 
-function advancedSearch( params )
-{
-	$.ajax({
-		url: 'searchRegistrationPatient.action',
-		type:"POST",
-		data: params,
-		success: function( html ){
-				statusSearching = 1;
-				setInnerHTML( 'listPatientDiv', html );
-				showById('listPatientDiv');
-				setFieldValue('listAll',false);
-				jQuery( "#loaderDiv" ).hide();
-			}
-		});
-}
-
-//--------------------------------------------------------------------------------------------
-// Migration patient
-//--------------------------------------------------------------------------------------------
+// ----------------------------------------------------------------
+// Patient Location
+// ----------------------------------------------------------------
 
 function getPatientLocation( patientId )
 {
@@ -826,10 +728,17 @@
 		} );
 }
 
-// load visit schedule
+// ----------------------------------------------------------------
+// Load visit schedule
+// ----------------------------------------------------------------
+
 function getVisitSchedule( programInstanceId )
 {
 	$('#tab-3').load("getVisitSchedule.action", {programInstanceId:programInstanceId});
 }
 
+// ----------------------------------------------------------------
+// Cosmetic UI
+// ----------------------------------------------------------------
+
 function reloadOneRecord(){}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2012-09-23 11:52:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2012-09-23 12:58:02 +0000
@@ -21,6 +21,10 @@
 
 selection.setListenerFunction( orgunitSelected );
 
+// --------------------------------------------------------------------
+// List all events
+// --------------------------------------------------------------------
+
 function listAllPatient()
 {
 	setFieldValue('listAll', "true");
@@ -60,6 +64,10 @@
 		});
 }
 
+// --------------------------------------------------------------------
+// Search events
+// --------------------------------------------------------------------
+
 function advancedSearch( params )
 {
 	setFieldValue('listAll', "false");
@@ -79,6 +87,26 @@
 	});
 }
 
+// --------------------------------------------------------------------
+// Patient program tracking
+// --------------------------------------------------------------------
+
+function showPatientProgramTracking(programInstanceId)
+{
+	hideById("listPatientDiv");
+	hideById("searchDiv");
+	setInnerHTML("smsManagementDiv", "");
+	showLoader();	
+	$( '#patientProgramTrackingDiv' ).load( "patientProgramTracking.action", 
+		{ 
+			programInstanceId:programInstanceId
+		},function( )
+		{
+			showById('patientProgramTrackingDiv');
+			hideLoader();
+		});
+}
+
 function getOutboundSmsList( programStageInstanceId, isSendSMS ) 
 {
 	setFieldValue('sendToList', "false");
@@ -94,6 +122,28 @@
 		});
 }
 
+function eventFlowToggle( programInstanceId )
+{
+	jQuery("#tb_" + programInstanceId + " .stage-object").each( function(){
+		var programStageInstance = this.id.split('_')[1];
+		jQuery('#arrow_' + programStageInstance ).toggle();
+		jQuery('#ps_' + programStageInstance ).toggle();
+		jQuery(this).removeClass("stage-object-selected");
+	});
+		
+	if( jQuery("#tb_" + programInstanceId + " .searched").length>0)
+	{	
+		var id = jQuery("#tb_" + programInstanceId + " .searched").attr('id').split('_')[1];
+		showById("arrow_" + id);
+		showById("ps_" + id );
+	}
+	resize();
+}
+
+// --------------------------------------------------------------------
+// Send SMS 
+// --------------------------------------------------------------------
+
 function showSendSmsForm(programStageName, programStageInstanceId)
 {
 	setFieldValue( 'programStageInstanceId', programStageInstanceId );
@@ -110,27 +160,6 @@
 		});
 }
 
-function showCommentList( programStageInstanceId, isSendSMS ) 
-{
-	setFieldValue('sendToList', "false");
-	$('#smsManagementDiv' ).load("getOutboundSmsList.action",
-		{
-			programStageInstanceId: programStageInstanceId
-		}
-		, function(){
-			hideById('smsManagementForm');
-		}).dialog(
-		{
-			title:i18n_sms_message_management,
-			maximize:true, 
-			closable:true,
-			modal:false,
-			overlay:{background:'#000000', opacity:0.1},
-			width:800,
-			height:500
-		});
-}
-
 function sendSMS()
 {
 	var sendToList = getFieldValue('sendToList');
@@ -146,6 +175,7 @@
 {
 	setInnerHTML('smsError', '');
 	if(field.value==""){
+		field.style.backgroundColor = ERROR_COLOR;
 		jQuery('#smsError').css("color", "red");
 		setInnerHTML('smsError', i18n_this_field_is_required);
 		return;
@@ -209,110 +239,6 @@
 	});
 }
 
-function loadProgramStageRecords( programStageInstanceId ) 
-{
-	setInnerHTML('dataEntryFormDiv', '');
-	showLoader();
-    $('#dataEntryFormDiv' ).load("loadProgramStageRecords.action",
-		{
-			programStageInstanceId: programStageInstanceId
-		}, function() {
-			hideLoader();
-		});
-}
-
-function keypress(event, field, programStageInstanceId )
-{
-	var key = getKeyCode( event );
-	if ( key==13 ){ // Enter
-		addComment( field, programStageInstanceId );
-	}
-}
-
-function addComment( field, programStageInstanceId )
-{
-	field.style.backgroundColor = SAVING_COLOR;
-	var commentText = field.value;
-	if( commentText != '')
-	{
-		jQuery.postUTF8( 'addPatientComment.action',
-			{
-				programStageInstanceId: programStageInstanceId,
-				commentText: commentText 
-			}, function ( json )
-			{
-				var programStageName = jQuery("#ps_" + programStageInstanceId).attr('programStageName');
-				var date = new Date();
-				var currentTime = date.getHours() + ":" + date.getMinutes();
-				jQuery('#commentTB').prepend("<tr><td>" + getFieldValue("currentDate") + " " + currentTime + "</td>"
-						+ "<td>" + programStageName + "</td>"
-						+ "<td>" + getFieldValue('currentUsername') + "</td>"
-						+ "<td>" + commentText + "</td></tr>");
-				field.value="";
-				showSuccessMessage( i18n_comment_added );
-				field.style.backgroundColor = SUCCESS_COLOR;
-				
-				if( jQuery("#commentTB tr.hidden").length > 0 ){
-					commentDivToggle(true);
-				}
-				else{
-					commentDivToggle(false);
-				}
-			});
-	}
-}
-
-function removeComment( programStageInstanceId, commentId )
-{
-	jQuery.postUTF8( 'removePatientComment.action',
-		{
-			programStageInstanceId:programStageInstanceId,
-			id: commentId
-		}, function ( json )
-		{
-			showSuccessMessage( json.message );
-			hideById( 'comment_' + commentId );
-		} );
-}
-
-function eventFlowToggle( programInstanceId )
-{
-	jQuery("#tb_" + programInstanceId + " .stage-object").each( function(){
-		var programStageInstance = this.id.split('_')[1];
-		jQuery('#arrow_' + programStageInstance ).toggle();
-		jQuery('#ps_' + programStageInstance ).toggle();
-		jQuery(this).removeClass("stage-object-selected");
-	});
-		
-	if( jQuery("#tb_" + programInstanceId + " .searched").length>0)
-	{	
-		var id = jQuery("#tb_" + programInstanceId + " .searched").attr('id').split('_')[1];
-		showById("arrow_" + id);
-		showById("ps_" + id );
-	}
-	resize();
-}
-
-// --------------------------------------------------------------------
-// Patient program tracking
-// --------------------------------------------------------------------
-
-function showPatientProgramTracking(programInstanceId)
-{
-	hideById("listPatientDiv");
-	hideById("searchDiv");
-	setInnerHTML("smsManagementDiv", "");
-	showLoader();	
-	$( '#patientProgramTrackingDiv' ).load( "patientProgramTracking.action", 
-		{ 
-			programInstanceId:programInstanceId
-		},function( )
-		{
-			showById('patientProgramTrackingDiv');
-			hideLoader();
-		});
-}
-
 function commentDivToggle(isHide)
 {
 	var index = 1;
@@ -338,13 +264,90 @@
 	}
 }
 
-function onClickBackBtn()
-{
-	showById('searchDiv');
-	showById('listPatientDiv');
-	hideById('smsManagementDiv');
-	hideById('patientProgramTrackingDiv');	
-}
+// --------------------------------------------------------------------
+// Post Comments
+// --------------------------------------------------------------------
+
+function showCommentList( programStageInstanceId, isSendSMS ) 
+{
+	setFieldValue('sendToList', "false");
+	$('#smsManagementDiv' ).load("getOutboundSmsList.action",
+		{
+			programStageInstanceId: programStageInstanceId
+		}
+		, function(){
+			hideById('smsManagementForm');
+		}).dialog(
+		{
+			title:i18n_sms_message_management,
+			maximize:true, 
+			closable:true,
+			modal:false,
+			overlay:{background:'#000000', opacity:0.1},
+			width:800,
+			height:500
+		});
+}
+
+function keypress(event, field, programStageInstanceId )
+{
+	var key = getKeyCode( event );
+	if ( key==13 ){ // Enter
+		addComment( field, programStageInstanceId );
+	}
+}
+
+function addComment( field, programStageInstanceId )
+{
+	field.style.backgroundColor = SAVING_COLOR;
+	var commentText = field.value;
+	if( commentText == ''){
+		field.style.backgroundColor = ERROR_COLOR;
+		return;
+	}
+	
+	jQuery.postUTF8( 'addPatientComment.action',
+		{
+			programStageInstanceId: programStageInstanceId,
+			commentText: commentText 
+		}, function ( json )
+		{
+			var programStageName = jQuery("#ps_" + programStageInstanceId).attr('programStageName');
+			var date = new Date();
+			var currentTime = date.getHours() + ":" + date.getMinutes();
+			jQuery('#commentTB').prepend("<tr><td>" + getFieldValue("currentDate") + " " + currentTime + "</td>"
+					+ "<td>" + programStageName + "</td>"
+					+ "<td>" + getFieldValue('currentUsername') + "</td>"
+					+ "<td>" + commentText + "</td></tr>");
+			field.value="";
+			showSuccessMessage( i18n_comment_added );
+			field.style.backgroundColor = SUCCESS_COLOR;
+			
+			if( jQuery("#commentTB tr.hidden").length > 0 ){
+				commentDivToggle(true);
+			}
+			else{
+				commentDivToggle(false);
+			}
+		});
+}
+
+function removeComment( programStageInstanceId, commentId )
+{
+	jQuery.postUTF8( 'removePatientComment.action',
+		{
+			programStageInstanceId:programStageInstanceId,
+			id: commentId
+		}, function ( json )
+		{
+			showSuccessMessage( json.message );
+			hideById( 'comment_' + commentId );
+		} );
+}
+
+// --------------------------------------------------------------------
+// Cosmetic UI
+// --------------------------------------------------------------------
 
 function reloadRecordList()
 {
@@ -403,3 +406,14 @@
 	}
 }
 
+// --------------------------------------------------------------------
+// Show main form
+// --------------------------------------------------------------------
+
+function onClickBackBtn()
+{
+	showById('searchDiv');
+	showById('listPatientDiv');
+	hideById('smsManagementDiv');
+	hideById('patientProgramTrackingDiv');	
+}