← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8014: Program Tracking support (finished).

 

------------------------------------------------------------
revno: 8014
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-09-07 14:57:47 +0700
message:
  Program Tracking support (finished).
added:
  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/webapp/dhis-web-caseentry/patientProgramTracking.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
  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/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm
  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/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/javascript/smsReminder.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.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/programTrackingRecords.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/searchPatientCriteria.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sendSmsForm.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/program/ProgramStageInstance.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java	2012-08-17 06:42:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java	2012-09-07 07:57:47 +0000
@@ -27,6 +27,7 @@
 package org.hisp.dhis.program;
 
 import java.io.Serializable;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import java.util.Set;
@@ -48,10 +49,17 @@
     private static final long serialVersionUID = 6239130884678145713L;
 
     public static final int COMPLETED_STATUS = 1;
+
     public static final int VISITED_STATUS = 2;
+
     public static final int FUTURE_VISIT_STATUS = 3;
+
     public static final int LATE_VISIT_STATUS = 4;
 
+    public static final int UNKNOWN_STATUS = 5;
+
+    public static final int SKIPPED_STATUS = 6;
+
     private int id;
 
     private ProgramInstance programInstance;
@@ -65,11 +73,13 @@
     private OrganisationUnit organisationUnit;
 
     private boolean completed = false;
-    
+
     private List<OutboundSms> outboundSms;
-    
+
     private Set<Comment> comments;
 
+    private Integer status;
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -122,7 +132,7 @@
         result = result * prime + programStage.hashCode();
         result = result * prime + dueDate.hashCode();
         result = result * prime + ((executionDate == null) ? 0 : executionDate.hashCode());
-        
+
         return result;
     }
 
@@ -255,4 +265,47 @@
     {
         this.comments = comments;
     }
+
+    public Integer getStatus()
+    {
+        return status;
+    }
+
+    public void setStatus( Integer status )
+    {
+        this.status = status;
+    }
+
+    public Integer getEventStatus()
+    {
+        if ( this.isCompleted() )
+        {
+            return ProgramStageInstance.COMPLETED_STATUS;
+        }
+        else if ( this.getExecutionDate() != null )
+        {
+            return ProgramStageInstance.VISITED_STATUS;
+        }
+        else
+        {
+            // -------------------------------------------------------------
+            // If a program stage is not provided even a day after its due
+            // date, then that service is alerted red - because we are
+            // getting late
+            // -------------------------------------------------------------
+
+            Calendar dueDateCalendar = Calendar.getInstance();
+            dueDateCalendar.setTime( this.getDueDate() );
+            dueDateCalendar.add( Calendar.DATE, 1 );
+
+            if ( dueDateCalendar.getTime().before( new Date() ) )
+            {
+                return ProgramStageInstance.LATE_VISIT_STATUS;
+            }
+            else
+            {
+                return ProgramStageInstance.FUTURE_VISIT_STATUS;
+            }
+        }
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-08-16 13:46:23 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-09-07 07:57:47 +0000
@@ -128,35 +128,7 @@
 
         for ( ProgramStageInstance programStageInstance : programStageInstances )
         {
-            if ( programStageInstance.isCompleted() )
-            {
-                colorMap.put( programStageInstance.getId(), ProgramStageInstance.COMPLETED_STATUS );
-            }
-            else if ( programStageInstance.getExecutionDate() != null )
-            {
-                colorMap.put( programStageInstance.getId(), ProgramStageInstance.VISITED_STATUS );
-            }
-            else
-            {
-                // -------------------------------------------------------------
-                // If a program stage is not provided even a day after its due
-                // date, then that service is alerted red - because we are
-                // getting late
-                // -------------------------------------------------------------
-
-                Calendar dueDateCalendar = Calendar.getInstance();
-                dueDateCalendar.setTime( programStageInstance.getDueDate() );
-                dueDateCalendar.add( Calendar.DATE, 1 );
-
-                if ( dueDateCalendar.getTime().before( new Date() ) )
-                {
-                    colorMap.put( programStageInstance.getId(), ProgramStageInstance.LATE_VISIT_STATUS );
-                }
-                else
-                {
-                    colorMap.put( programStageInstance.getId(), ProgramStageInstance.FUTURE_VISIT_STATUS );
-                }
-            }
+            colorMap.put( programStageInstance.getId(), programStageInstance.getEventStatus() );
         }
 
         return colorMap;
@@ -205,8 +177,8 @@
 
         Map<Integer, OrganisationUnitLevel> orgUnitLevelMap = organisationUnitService.getOrganisationUnitLevelMap();
 
-        return programStageInstanceStore.getTabularReport( programStage, orgUnitLevelMap, organisationUnits,
-            columns, level, maxLevel, startDate, endDate, descOrder, min, max );
+        return programStageInstanceStore.getTabularReport( programStage, orgUnitLevelMap, organisationUnits, columns,
+            level, maxLevel, startDate, endDate, descOrder, min, max );
     }
 
     public int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
@@ -289,12 +261,11 @@
 
     public void removeEmptyEvents( ProgramStage programStage )
     {
-    	programStageInstanceStore.removeEmptyEvents(programStage);
+        programStageInstanceStore.removeEmptyEvents( programStage );
     }
 
     @Override
-    public void updateProgramStageInstances( Collection<Integer> programStageInstanceIds,
-        OutboundSms outboundSms )
+    public void updateProgramStageInstances( Collection<Integer> programStageInstanceIds, OutboundSms outboundSms )
     {
         programStageInstanceStore.update( programStageInstanceIds, outboundSms );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml	2012-08-21 13:51:07 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml	2012-09-07 07:57:47 +0000
@@ -36,5 +36,7 @@
       <one-to-many class="org.hisp.dhis.patient.comment.Comment" />
     </set>
     
+    <property name="status" column="status" />
+    
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2012-09-05 14:30:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2012-09-07 07:57:47 +0000
@@ -28,7 +28,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -38,11 +37,9 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeGroup;
-import org.hisp.dhis.patient.PatientAttributeGroupService;
 import org.hisp.dhis.patient.PatientIdentifier;
 import org.hisp.dhis.patient.PatientIdentifierService;
 import org.hisp.dhis.patient.PatientIdentifierType;
-import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
@@ -70,8 +67,6 @@
 
     private PatientIdentifierService patientIdentifierService;
 
-    private PatientAttributeGroupService patientAttributeGroupService;
-
     private PatientAttributeValueService patientAttributeValueService;
 
     private SelectedStateManager selectedStateManager;
@@ -125,12 +120,7 @@
     {
         return patientAttributeValueMap;
     }
-
-    public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService )
-    {
-        this.patientAttributeGroupService = patientAttributeGroupService;
-    }
-
+    
     public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
     {
         this.patientAttributeValueService = patientAttributeValueService;

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SetEventStatusAction.java	2012-09-07 07:57:47 +0000
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.reminder;
+
+import java.util.Date;
+
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version SetEventStatusAction.java 1:13:45 PM Sep 7, 2012 $
+ */
+public class SetEventStatusAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private ProgramStageInstanceService programStageInstanceService;
+
+    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+    {
+        this.programStageInstanceService = programStageInstanceService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Integer programStageInstanceId;
+
+    public void setProgramStageInstanceId( Integer programStageInstanceId )
+    {
+        this.programStageInstanceId = programStageInstanceId;
+    }
+
+    private Integer status;
+
+    public void setStatus( Integer status )
+    {
+        this.status = status;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        ProgramStageInstance programStageInstance = programStageInstanceService
+            .getProgramStageInstance( programStageInstanceId );
+
+        if ( ProgramStageInstance.COMPLETED_STATUS == status.intValue() )
+        {
+            programStageInstance.setExecutionDate( new Date() );
+            programStageInstance.setCompleted( true );
+            programStageInstance.setStatus( null );
+        }
+        else if ( ProgramStageInstance.VISITED_STATUS == status.intValue() )
+        {
+            programStageInstance.setCompleted( false );
+            programStageInstance.setStatus( null );
+        }
+        else if ( ProgramStageInstance.UNKNOWN_STATUS == status.intValue() )
+        {
+            programStageInstance.setStatus( null );
+        }
+        else if ( ProgramStageInstance.SKIPPED_STATUS == status.intValue() )
+        {
+            programStageInstance.setExecutionDate( new Date() );
+            programStageInstance.setCompleted( true );
+            programStageInstance.setStatus( status );
+        }
+
+        programStageInstanceService.updateProgramStageInstance( programStageInstance );
+
+        return SUCCESS;
+    }
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-09-06 09:44:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-09-07 07:57:47 +0000
@@ -627,8 +627,6 @@
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 		<property name="patientIdentifierService"
 			ref="org.hisp.dhis.patient.PatientIdentifierService" />
-		<property name="patientAttributeGroupService"
-			ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 		<property name="selectedStateManager"
@@ -1006,6 +1004,14 @@
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
 	
+	<bean id="org.hisp.dhis.caseentry.action.reminder.SetEventStatusAction"
+		class="org.hisp.dhis.caseentry.action.reminder.SetEventStatusAction"
+		scope="prototype">
+		<property name="programStageInstanceService"
+			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+	</bean>
+	
+	
 	<!-- Dashboard -->
 	
 	<bean id="org.hisp.dhis.caseentry.action.patient.PatientDashboardAction"

=== 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-06 09:44:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-09-07 07:57:47 +0000
@@ -435,5 +435,10 @@
 on_date = on
 no_records = No records
 show_hide_event_flow = Show/Hide event flow
+show_hide_more = Show/Hide more ...
+reschedule_and_set_status = Reschedule and set status
 tracking_history = Tracking history
-show_hide_more = Show/Hide more ...
\ No newline at end of file
+reschedule_due_date = Re-schedule due date
+status = Status
+skipped = Skipped
+unknown = Unknown
\ No newline at end of file

=== 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-09-06 09:44:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-09-07 07:57:47 +0000
@@ -949,7 +949,21 @@
 			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
-
+		
+		<action name="patientProgramTracking"
+			class="org.hisp.dhis.caseentry.action.patient.ProgramEnrollmentAction">
+			<result name="success" type="velocity">/content.vm</result>
+			<param name="page">/dhis-web-caseentry/patientProgramTracking.vm</param>
+			<param name="requiredAuthorities">F_PATIENT_UPDATE</param>
+		</action>
+		
+		<action name="setEventStatus"
+			class="org.hisp.dhis.caseentry.action.reminder.SetEventStatusAction">
+			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+			<result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
+			<param name="requiredAuthorities">F_PATIENT_UPDATE</param>
+		</action>
+		
 		<!-- Dashboard -->
 
 		<action name="patientDashboard"
@@ -958,7 +972,7 @@
 			<param name="page">/dhis-web-caseentry/patientDashboard.vm</param>
 			<param name="stylesheets">style/style.css</param>
 		</action>
-
+		
 		<!-- Comment -->
 
 		<action name="addComment"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm	2012-09-04 10:10:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm	2012-09-07 07:57:47 +0000
@@ -1,31 +1,71 @@
-<table class='mainPageTable'>
+#set($programStageInstances = $programInstance.programStageInstances)
+<table class="mainPageTable">
+	<col width="160px"/>
+	<col/>
 	<tr>
-		<th>$i18n.getString('date')</th>
-		<th>$i18n.getString('program_stage')</th>
-		<th>$i18n.getString('message')</th>
+		<th>$i18n.getString( "date" )</th>
+		<th>$i18n.getString( "program_stage" )</th>
+		<th>$i18n.getString( "message" )</th>
 	</tr>
-	#set( $mark = false )
-	#foreach( $programStageInstance in $programInstance.programStageInstances )	
-		#if( $programStageInstance.outboundSms.size() > 0 || 
-			$programStageInstance.outboundSms.size() > 0 )
-			
-			#foreach( $comment in $programStageInstance.comments )
-			<tr #alternate( $mark ) >
-				<td>$!format.formatDate( $comment.createdDate )</td>
-				<td>$programStageInstance.programStage.name</td>
-				<td>($comment.creator) $comment.commentText</td>
-			</tr>
-			#set( $mark = !$mark )
-			#end
+	
+	<tbody id='commentTB'>
+		#set($index = 0)
+		#set( $mark = false )
+		#foreach($programStageInstance in $programStageInstances)
+			#foreach( $comment in $programStageInstance.comments )
+				#if( $index < 5 )
+					<tr id="comment_$comment.id" #alternate($mark)>
+						<td>$format.formatDate($comment.createdDate)</td>
+						<td>$programStageInstance.programStage.name</td>
+						<td>$comment.creator - $comment.commentText</td>
+						#set($index = $index + 1)
+						#set( $mark = !$mark)
+					</tr>
+				#end
+			#end
+		#end
+	</tbody>	
+	
+	<tbody id='smsManagementList'>
+		#foreach($programStageInstance in $programStageInstances)
+			#foreach( $sms in $programStageInstance.outboundSms )
+				#if( $index < 5 )
+					<tr id="tr${sms.id}" #alternate($mark) >
+						<td>$format.formatDate($!sms.date)</td>
+						<td> $programStageInstance.programStage.name</td>
+						<td>$sms.message</td>
+						#set( $mark = !$mark)
+					</tr>
+				#end
+			#end
+		#end
+	</tbody>
+	
+	<tbody id='moreComments' class='hidden'>
+		#foreach($programStageInstance in $programStageInstances)
+			#foreach( $comment in $programStageInstance.comments )
+				#if( $index >= 5 )
+					<tr id="comment_$comment.id" #alternate($mark)>
+						<td>$format.formatDate($comment.createdDate)</td>
+						<td> $programStageInstance.programStage.name</td>
+						<td>$comment.creator - $comment.commentText</td>
+						#set( $mark = !$mark)
+					</tr>
+				#end
+			#end
+		#end	
 		
+		#foreach($programStageInstance in $programStageInstances)
 			#foreach( $sms in $programStageInstance.outboundSms )
-			<tr #alternate( $mark ) >
-				<td>$!format.formatDate( $sms.date )</td>
-				<td>$programStageInstance.programStage.name</td>
-				<td>$sms.message</td>
-			</tr>
-			#set( $mark = !$mark )
+				#if( $index >= 5 )
+					<tr id="tr${sms.id}" #alternate($mark) >
+						<td>$format.formatDate($!sms.date)</td>
+						<td>$programStageInstance.programStage.name</td>
+						<td>$sms.message</td>
+						#set( $mark = !$mark)
+					</tr>
+				#end
 			#end
 		#end
-	#end
-</table>
+	</tbody>
+</table>
\ 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-06 09:44:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-09-07 07:57:47 +0000
@@ -1,3 +1,17 @@
+var prefixId = 'ps_';
+var COLOR_RED = "#fb4754";
+var COLOR_GREEN = "#8ffe8f";
+var COLOR_YELLOW = "#f9f95a";
+var COLOR_LIGHTRED = "#fb6bfb";
+var COLOR_LIGHT_RED = "#ff7676";
+var COLOR_LIGHT_YELLOW = "#ffff99";
+var COLOR_LIGHT_GREEN = "#ccffcc";
+var COLOR_LIGHT_LIGHTRED = "#ff99ff";
+var SUCCESS_COLOR = '#ccffcc';
+var ERROR_COLOR = '#ccccff';
+var SAVING_COLOR = '#ffffcc';
+var SUCCESS = 'success';
+var ERROR = 'error';
 
 // Disable caching for ajax requests in general 
 
@@ -379,16 +393,6 @@
 	window.location.href = url;
 }
 
-var prefixId = 'ps_';
-var COLOR_RED = "#fb4754";
-var COLOR_GREEN = "#8ffe8f";
-var COLOR_YELLOW = "#f9f95a";
-var COLOR_LIGHTRED = "#fb6bfb";
-var COLOR_LIGHT_RED = "#ff7676";
-var COLOR_LIGHT_YELLOW = "#ffff99";
-var COLOR_LIGHT_GREEN = "#ccffcc";
-var COLOR_LIGHT_LIGHTRED = "#ff99ff";
-
 function setEventColorStatus( elementId, status )
 {
 	status = eval(status);
@@ -658,3 +662,185 @@
 	$('#eventMessagesDiv').load("getEventMessages.action", {programInstanceId:programInstanceId});
 }
 
+// ----------------------------------------------------------------
+// Dash board
+// ----------------------------------------------------------------
+
+function activeProgramInstanceDiv( programInstanceId )
+{
+	jQuery(".selected").each(function(){
+		jQuery(this).removeClass();
+	});
+	
+	jQuery("#infor_" + programInstanceId).each(function(){
+		jQuery(this).addClass('selected bold');
+	});
+	
+	showById('pi_' + programInstanceId);
+}
+
+function hideProgramInstanceDiv( programInstanceId )
+{
+	hideById('pi_' + programInstanceId);
+	jQuery('#pi_' + programInstanceId).removeClass("link-area-active");
+	jQuery("#img_" + programInstanceId).attr('src','');
+}
+
+function showPatientDashboardForm( patientId )
+{
+	hideById('listPatientDiv');
+	hideById('editPatientDiv');
+	hideById('selectDiv');
+	hideById('searchDiv');
+	hideById('migrationPatientDiv');
+				
+	jQuery('#loaderDiv').show();
+	jQuery('#patientDashboard').load('patientDashboard.action',
+		{
+			patientId:patientId
+		}, function()
+		{	
+			showById('patientDashboard');
+			hideById('enrollProgramBtn');
+			jQuery('#loaderDiv').hide();
+		});
+}
+
+function loadActiveProgramStageRecords(programInstanceId, activeProgramStageInstanceId)
+{
+	jQuery('#loaderDiv').show();
+	jQuery('#programEnrollmentDiv').load('enrollmentform.action',
+		{
+			programInstanceId:programInstanceId
+		}, function()
+		{
+			showById('programEnrollmentDiv');
+			var type = jQuery('#tr_'+programInstanceId).attr('programType');
+			if(type=='2'){
+				hideById('programInstanceDiv');
+				var programStageInstanceId = jQuery('#tr_'+programInstanceId).attr('programStageInstanceId');
+				loadDataEntry( programStageInstanceId );
+			}
+			else{
+				showById('programInstanceDiv');
+			}
+			activeProgramInstanceDiv( programInstanceId );
+			loadDataEntry( activeProgramStageInstanceId );
+			jQuery('#loaderDiv').hide();
+		});
+}
+
+function loadProgramStageRecords( programStageInstanceId, completed ) 
+{
+	showLoader();
+    jQuery('#dataEntryFormDiv').load( "viewProgramStageRecords.action",
+		{
+			programStageInstanceId: programStageInstanceId
+		}, function() {
+			if(completed){
+				jQuery( "#dataEntryFormDiv :input").each(function(){
+					disable(this.id);
+				});
+			}
+			showById('dataEntryFormDiv');
+			hideLoader();
+		});
+}
+
+function updateEnrollment( patientId, programId, programInstanceId, programName )
+{
+	var dateOfIncident = jQuery('#tab-3 [id=dateOfIncident]').val();
+	var enrollmentDate = jQuery('#tab-3 [id=enrollmentDate]').val();
+	
+	jQuery.postJSON( "saveProgramEnrollment.action",
+		{
+			patientId: getFieldValue('patientId'),
+			programId: programId,
+			dateOfIncident: dateOfIncident,
+			enrollmentDate: enrollmentDate
+		}, 
+		function( json ) 
+		{    
+			var infor = programName + " (" + enrollmentDate + ")";
+			setInnerHTML("infor_" + programInstanceId, infor );
+			showSuccessMessage(i18n_enrol_success);
+		});
+}
+
+//-----------------------------------------------------------------------------
+// Save due-date
+//-----------------------------------------------------------------------------
+
+function saveDueDate( programStageInstanceId, programStageInstanceName )
+{
+	var field = document.getElementById( 'value_' + programStageInstanceId + '_date' );
+	
+	var dateOfIncident = new Date( byId('dateOfIncident').value );
+	var dueDate = new Date(field.value);
+	
+	if( dueDate < dateOfIncident )
+	{
+		field.style.backgroundColor = '#FFCC00';
+		alert( i18n_date_less_incident );
+		return;
+	}
+	
+	field.style.backgroundColor = '#ffffcc';
+	
+	var dateDueSaver = new DateDueSaver( programStageInstanceId, field.value, '#ccffcc' );
+	dateDueSaver.save();
+}
+
+function DateDueSaver( programStageInstanceId_, dueDate_, resultColor_ )
+{
+	var programStageInstanceId = programStageInstanceId_;	
+	var dueDate = dueDate_;
+	var resultColor = resultColor_;	
+
+	this.save = function()
+	{
+		var params = 'programStageInstanceId=' + programStageInstanceId + '&dueDate=' + dueDate;
+		$.ajax({
+			   type: "POST",
+			   url: "saveDueDate.action",
+			   data: params,
+			   dataType: "xml",
+			   success: function(result){
+					handleResponse (result);
+			   },
+			   error: function(request,status,errorThrown) {
+					handleHttpError (request);
+			   }
+			});
+	};
+
+	function handleResponse( rootElement )
+	{
+		var codeElement = rootElement.getElementsByTagName( 'code' )[0];
+		var code = parseInt( codeElement.firstChild.nodeValue );
+   
+		if ( code == 0 )
+		{
+			markValue( resultColor );                   
+		}
+		else
+		{
+			markValue( COLOR_GREY );
+			window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
+		}
+	}
+
+	function handleHttpError( errorCode )
+	{
+		markValue( COLOR_GREY );
+		window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
+	}   
+
+	function markValue( color )
+	{       
+   
+		var element = document.getElementById( 'value_' + programStageInstanceId + '_date' );	
+           
+		element.style.backgroundColor = color;
+	}
+}

=== 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-08-28 09:11:19 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-09-07 07:57:47 +0000
@@ -1,9 +1,3 @@
-var SUCCESS_COLOR = '#ccffcc';
-var ERROR_COLOR = '#ccccff';
-var SAVING_COLOR = '#ffffcc';
-var SUCCESS = 'success';
-var ERROR = 'error';
-	
 //--------------------------------------------------------------------------------------------
 // Load program-stages by the selected program
 //--------------------------------------------------------------------------------------------

=== 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-06 09:44:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-09-07 07:57:47 +0000
@@ -571,30 +571,6 @@
 	
 }
 
-//-----------------------------------------------------------------------------
-//Save
-//-----------------------------------------------------------------------------
-
-function saveDueDate( programStageInstanceId, programStageInstanceName )
-{
-	var field = document.getElementById( 'value_' + programStageInstanceId + '_date' );
-	
-	var dateOfIncident = new Date( byId('dateOfIncident').value );
-	var dueDate = new Date(field.value);
-	
-	if( dueDate < dateOfIncident )
-	{
-		field.style.backgroundColor = '#FFCC00';
-		alert( i18n_date_less_incident );
-		return;
-	}
-	
-	field.style.backgroundColor = '#ffffcc';
-	
-	var dateDueSaver = new DateDueSaver( programStageInstanceId, field.value, '#ccffcc' );
-	dateDueSaver.save();
-}
-
 //----------------------------------------------------
 // Show relationship with new patient
 //----------------------------------------------------
@@ -691,65 +667,6 @@
 	hideLoader();
 }
 
-//-----------------------------------------------------------------------------
-// Saver objects
-//-----------------------------------------------------------------------------
-
-function DateDueSaver( programStageInstanceId_, dueDate_, resultColor_ )
-{
-	var programStageInstanceId = programStageInstanceId_;	
-	var dueDate = dueDate_;
-	var resultColor = resultColor_;	
-
-	this.save = function()
-	{
-		var params = 'programStageInstanceId=' + programStageInstanceId + '&dueDate=' + dueDate;
-		$.ajax({
-			   type: "POST",
-			   url: "saveDueDate.action",
-			   data: params,
-			   dataType: "xml",
-			   success: function(result){
-					handleResponse (result);
-			   },
-			   error: function(request,status,errorThrown) {
-					handleHttpError (request);
-			   }
-			});
-	};
-
-	function handleResponse( rootElement )
-	{
-		var codeElement = rootElement.getElementsByTagName( 'code' )[0];
-		var code = parseInt( codeElement.firstChild.nodeValue );
-   
-		if ( code == 0 )
-		{
-			markValue( resultColor );                   
-		}
-		else
-		{
-			markValue( COLOR_GREY );
-			window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
-		}
-	}
-
-	function handleHttpError( errorCode )
-	{
-		markValue( COLOR_GREY );
-		window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
-	}   
-
-	function markValue( color )
-	{       
-   
-		var element = document.getElementById( 'value_' + programStageInstanceId + '_date' );	
-           
-		element.style.backgroundColor = color;
-	}
-}
-
-
 // -----------------------------------------------------------------------------
 // remove value of all the disabled identifier fields
 // an identifier field is disabled when its value is inherited from another person ( underAge is true ) 
@@ -908,107 +825,3 @@
 			showSuccessMessage( i18n_save_success );
 		} );
 }
-
-// ----------------------------------------------------------------
-// Dash board
-// ----------------------------------------------------------------
-
-function activeProgramInstanceDiv( programInstanceId )
-{
-	jQuery(".selected").each(function(){
-		jQuery(this).removeClass();
-	});
-	
-	jQuery("#infor_" + programInstanceId).each(function(){
-		jQuery(this).addClass('selected bold');
-	});
-	
-	showById('pi_' + programInstanceId);
-}
-
-function hideProgramInstanceDiv( programInstanceId )
-{
-	hideById('pi_' + programInstanceId);
-	jQuery('#pi_' + programInstanceId).removeClass("link-area-active");
-	jQuery("#img_" + programInstanceId ).attr('src','');
-}
-
-function showPatientDashboardForm( patientId )
-{
-	hideById('listPatientDiv');
-	hideById('editPatientDiv');
-	hideById('selectDiv');
-	hideById('searchDiv');
-	hideById('migrationPatientDiv');
-				
-	jQuery('#loaderDiv').show();
-	jQuery('#patientDashboard').load('patientDashboard.action',
-		{
-			patientId:patientId
-		}, function()
-		{	
-			showById('patientDashboard');
-			jQuery('#loaderDiv').hide();
-		});
-}
-
-function loadActiveProgramStageRecords(programInstanceId, activeProgramStageInstanceId)
-{
-	jQuery('#loaderDiv').show();
-	jQuery('#programEnrollmentDiv').load('enrollmentform.action',
-		{
-			programInstanceId:programInstanceId
-		}, function()
-		{
-			showById('programEnrollmentDiv');
-			var type = jQuery('#tr_'+programInstanceId).attr('programType');
-			if(type=='2'){
-				hideById('programInstanceDiv');
-				var programStageInstanceId = jQuery('#tr_'+programInstanceId).attr('programStageInstanceId');
-				loadDataEntry( programStageInstanceId );
-			}
-			else{
-				showById('programInstanceDiv');
-			}
-			activeProgramInstanceDiv( programInstanceId );
-			loadDataEntry( activeProgramStageInstanceId );
-			jQuery('#loaderDiv').hide();
-		});
-}
-
-function loadProgramStageRecords( programStageInstanceId, completed ) 
-{
-	showLoader();
-    jQuery('#dataEntryFormDiv').load( "viewProgramStageRecords.action",
-		{
-			programStageInstanceId: programStageInstanceId
-		}, function() {
-			if(completed){
-				jQuery( "#dataEntryFormDiv :input").each(function(){
-					disable(this.id);
-				});
-			}
-			showById('dataEntryFormDiv');
-			hideLoader();
-		});
-}
-
-function updateEnrollment( patientId, programId, programInstanceId, programName )
-{
-	var dateOfIncident = jQuery('#tab-3 [id=dateOfIncident]').val();
-	var enrollmentDate = jQuery('#tab-3 [id=enrollmentDate]').val();
-	
-	jQuery.postJSON( "saveProgramEnrollment.action",
-		{
-			patientId: getFieldValue('patientId'),
-			programId: programId,
-			dateOfIncident: dateOfIncident,
-			enrollmentDate: enrollmentDate
-		}, 
-		function( json ) 
-		{    
-			var infor = programName + " (" + enrollmentDate + ")";
-			setInnerHTML("infor_" + programInstanceId, infor );
-			showSuccessMessage(i18n_enrol_success);
-		});
-}
\ No newline at end of file

=== 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-06 09:44:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2012-09-07 07:57:47 +0000
@@ -71,6 +71,7 @@
 function getOutboundSmsList( programStageInstanceId, isSendSMS ) 
 {
 	setFieldValue('sendToList', "false");
+	setInnerHTML('patientProgramTrackingDiv', '');
 	$('#smsManagementDiv' ).load("getOutboundSmsList.action",
 		{
 			programStageInstanceId: programStageInstanceId
@@ -82,9 +83,10 @@
 		});
 }
 
-function showSendSmsForm()
+function showSendSmsForm(programStageName, programStageInstanceId)
 {
-	setFieldValue('sendToList', "true");
+	setFieldValue( 'programStageInstanceId', programStageInstanceId );
+	setFieldValue( 'programStageName', programStageName );
 	$('#sendSmsFormDiv' ).load("getGateway.action").dialog(
 		{
 			title:i18n_send_sms,
@@ -121,7 +123,6 @@
 function sendSMS()
 {
 	var sendToList = getFieldValue('sendToList');
-	
 	if( sendToList == 'false'){	
 		sendSmsOnePatient()
 	}
@@ -143,9 +144,10 @@
 		{
 			if ( json.response == "success" ) {
 				showSuccessMessage( json.message );
-				jQuery('#smsManagementList').prepend("<tr><td>" + getFieldValue('currentDate') + "</td><td>" + getFieldValue('smsMessage') + "</td></tr>");
+				jQuery('#commentTB').prepend("<tr><td>" + getFieldValue('currentDate') + "</td>"
+					+ "<td>" + getFieldValue('programStageName') + "</td>"
+					+ "<td>" + getFieldValue('smsMessage') + "</td></tr>");
 				var noMessage = eval( getInnerHTML('noMessageDiv_' + programStageInstanceId)) + 1;
-				jQuery('#noMessageDiv_' + programStageInstanceId).html(noMessage);
 			}
 			else {
 				showErrorMessage( json.message, 7000 );
@@ -158,18 +160,18 @@
 	params = getSearchParams();
 	params += "&gatewayId=" + getFieldValue( 'gatewayId' );
 	params += "&msg=" + getFieldValue( 'smsMessage' );
+	params += "&programStageInstanceId=" + getFieldValue('programStageInstanceId');
 	$.ajax({
 		url: 'sendSMSTotList.action',
 		type:"POST",
 		data: params,
 		success: function( json ){
 			if ( json.response == "success" ) {
+				var programStageName = getFieldValue('programStageName');
+				jQuery('#commentTB').prepend("<tr><td>" + getFieldValue("currentDate") + "</td>"
+						+ "<td>" + programStageName + "</td>"
+						+ "<td>" + getFieldValue( 'smsMessage' ) + "</td></tr>");
 				showSuccessMessage( json.message );
-				jQuery("#patientList [programStageId=" + programStageId + "][status=" + status + "]" ).each( function(){
-					var programStageInstanceId = jQuery(this).attr('programStageInstanceId');
-					var noMessage = eval( getInnerHTML('noMessageDiv_' + programStageInstanceId)) + 1;
-					jQuery('#noMessageDiv_' + programStageInstanceId).html(noMessage);
-				});
 			}
 			else {
 				showErrorMessage( json.message );
@@ -190,16 +192,17 @@
 		});
 }
 
-function keypress(event, programStageInstanceId )
+function keypress(event, field, programStageInstanceId )
 {
 	var key = getKeyCode( event );
 	if ( key==13 ){ // Enter
-		addComment( programStageInstanceId );
+		addComment( field, programStageInstanceId );
 	}
 }
 
-function addComment( programStageInstanceId )
+function addComment( field, programStageInstanceId )
 {
+	field.style.backgroundColor = SAVING_COLOR;
 	var commentText = getFieldValue( 'commentText' );
 	if( commentText != '')
 	{
@@ -209,12 +212,13 @@
 				commentText: commentText 
 			}, function ( json )
 			{
-				var programStageName = jQuery("#ps_" + programStageInstanceId).attr('programStageName');
+				var programStageName = jQuery("#box_" + programStageInstanceId).attr('programStageName');
 				jQuery('#commentTB').prepend("<tr><td>" + getFieldValue("currentDate") + "</td>"
 						+ "<td>" + programStageName + "</td>"
 						+ "<td>" + getFieldValue('currentUsername') + " - " + commentText + "</td></tr>");
-				setFieldValue( 'commentText','' );
-				showSuccessMessage( i18n_comment_added );
+				field.value="";
+				jQuery(field).attr('placeholder', i18n_comment_added );
+				field.style.backgroundColor = SUCCESS_COLOR;
 			} );
 	}
 }
@@ -243,7 +247,7 @@
 	
 	jQuery("#tb_" + programInstanceId + " .arrow-left").toggle();
 	jQuery("#tb_" + programInstanceId + " .arrow-right").toggle();
-	if( jQuery("#tb_" + programInstanceId + " .searched").length==0)
+	if( jQuery("#tb_" + programInstanceId + " .searched").length>0)
 	{	
 		var id = jQuery("#tb_" + programInstanceId + " .searched").attr('id').split('_')[1];
 		showById("arrow_" + id);
@@ -251,9 +255,79 @@
 	}
 }
 
-function backToSelect()
+// --------------------------------------------------------------------
+// Patient program tracking
+// --------------------------------------------------------------------
+
+function showPatientProgramTracking(programInstanceId)
+{
+	hideById("listPatientDiv");
+	hideById("searchDiv");
+	setInnerHTML("smsManagementDiv", "");
+	showLoader();	
+	$( '#patientProgramTrackingDiv' ).load( "patientProgramTracking.action", 
+		{ 
+			programInstanceId:programInstanceId
+		},function( )
+		{
+			showById('patientProgramTrackingDiv');
+			hideLoader();
+		});
+}
+
+function setEventStatus( field, programStageInstanceId )
+{	
+	field.style.backgroundColor = SAVING_COLOR;
+	jQuery.postUTF8( 'setEventStatus.action',
+		{
+			programStageInstanceId:programStageInstanceId,
+			status:field.value
+		}, function ( json )
+		{
+			field.style.backgroundColor = SUCCESS_COLOR;
+		} );
+}
+
+function removeEvent( programStageId )
+{	
+    var result = window.confirm( i18n_comfirm_delete_event );
+    
+    if ( result )
+    {
+    	$.postJSON(
+    	    "removeCurrentEncounter.action",
+    	    {
+    	        "id": programStageId   
+    	    },
+    	    function( json )
+    	    { 
+    	    	if ( json.response == "success" )
+    	    	{
+					jQuery( "tr#tr" + programStageId ).remove();
+	                
+					jQuery( "table.listTable tbody tr" ).removeClass( "listRow listAlternateRow" );
+	                jQuery( "table.listTable tbody tr:odd" ).addClass( "listAlternateRow" );
+	                jQuery( "table.listTable tbody tr:even" ).addClass( "listRow" );
+					jQuery( "table.listTable tbody" ).trigger("update");
+					
+					hideById('smsManagementDiv');
+					
+					showSuccessMessage( i18n_delete_success );
+    	    	}
+    	    	else if ( json.response == "error" )
+    	    	{ 
+					showWarningMessage( json.message );
+    	    	}
+    	    }
+    	);
+    }
+}
+
+
+function onClickBackBtn()
 {
 	showById('searchDiv');
 	showById('listPatientDiv');
 	hideById('smsManagementDiv');
-}
\ No newline at end of file
+	hideById('patientProgramTrackingDiv');	
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2012-09-04 10:10:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2012-09-07 07:57:47 +0000
@@ -74,8 +74,8 @@
 							</div>
 						</div>
 					</td>
-					<td class="link-area">
-						<div class="link-area"  style='height:160px;'>
+					<td class="link-area" style="vertical-align:top">
+						<div class="link-area" style='height:160px;border:none;'>
 							<table width='100%'>
 								<tr><th>$i18n.getString("active_programs")</th></tr>
 							</table>
@@ -119,7 +119,7 @@
 								</table>
 							</div>
 						</div>
-						<br><input type='button' value='$i18n.getString("enroll_program")' onclick='showProgramEnrollmentForm( "$patient.id" )'/>
+						<br><input type='button' value='$i18n.getString("enroll_program")' id="enrollProgramBtn" name="enrollProgramBtn" onclick='showProgramEnrollmentForm( "$patient.id" )'/>
 					</td>
 					<td>
 						<div class="link-area">

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientProgramTracking.vm	2012-09-07 07:57:47 +0000
@@ -0,0 +1,187 @@
+<h4>$programInstance.program.name</h4>
+<input type='hidden' id='programInstanceId' name='programInstanceId' value='$programInstance.id' />
+<input type='hidden' id='patientId' name='patientId' value='$programInstance.patient.id' />
+
+<table>
+	<tr>
+		<td>$i18n.getString("full_name")</td>
+		<td>$!programInstance.patient.getFullName()</td>
+	</tr>
+	<tr>
+		<td>$i18n.getString("gender")</td>
+		<td>$programInstance.patient.gender</td>
+	</tr>
+	<tr>
+		<td>$i18n.getString("date_of_birth")</td>
+		<td>$format.formatDate( $!programInstance.patient.birthDate) $!programInstance.patient.getAge()</td>
+	</tr>
+	<tr>
+		<td>$i18n.getString("phone_number")</td>
+		<td>
+			#if($!programInstance.patient.phoneNumber && $!programInstance.patient.phoneNumber!='')
+				$!programInstance.patient.phoneNumber
+			#else
+				[$i18n.getString('none')]
+			#end
+		</td>
+	</tr>
+	<tr>
+		<td><input type="button" value='$i18n.getString("back_to_search")' onclick="javascript:onClickBackBtn();"></td>
+	</tr>
+</table>
+
+<div id="tabs">
+	<ul>
+		<li><a href="#tab-2">$i18n.getString("demographics")</a></li>
+		<li><a href="#tab-3">$i18n.getString("reschedule_and_set_status")</a></li>
+		<li><a href="#tab-4">$i18n.getString("tracking_history")</a></li>
+		<li><a href="#tab-5">$i18n.getString("program_reports")</a></li>
+	</ul>
+	
+	<!-- Demographics -->
+	<div id="tab-2">
+		<table class="mainPageTable">
+			#set( $mark = false )
+			#foreach ($identifierType in $identifierTypes) 
+				#set( $identifier = '')
+				#set( $identifier = $identiferMap.get( $identifierType.id ) )
+				#if($identifier)
+					<tr #alternate( $mark )>
+						<td>$identifierType.name</td>       
+						<td>$identifier</td>
+					</tr>
+					#set( $mark = !$mark  )
+				#end
+			#end
+						
+			<!-- ATTRIBUTES IN GROUPS -->
+			#foreach ($attributeGroup in $attributeGroupsMap.keySet() )
+				#set($attributes = $attributeGroupsMap.get($attributeGroup))
+				#foreach($attribute in $attributes )
+					#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
+					#if($attributeValue)
+						<tr #alternate( $mark )>
+							<td>$attribute.name</td>
+							<td>$attributeValue</td>	
+						</tr>
+						#set( $mark = !$mark  )
+					#end
+				#end
+			#end
+		</table>
+	</div>
+
+	<!-- Program-stage-instance TAB -->
+	<div id="tab-3">
+		<fieldset>
+			<legend>$i18n.getString("program")</legend>
+			<table>
+				<tr>
+					<td class='text-column'>$programInstance.program.dateOfEnrollmentDescription:</td>
+					<td><input name="enrollmentDate" id="enrollmentDate" readonly value="$!format.formatDate( $programInstance.enrollmentDate )"></td>
+				</tr>
+				<tr>
+					<td class='text-column'>$programInstance.program.dateOfIncidentDescription:</td>
+					<td><input name="dateOfIncident" id="dateOfIncident" readonly value="$!format.formatDate( $programInstance.dateOfIncident )"></td>
+				</tr>				
+			</table>
+		</fieldset>
+		<br>
+		#if( $programStageInstances.size() > 0 )
+			<table class='mainPageTable' id='progarmStageListDiv' name='progarmStageListDiv' >
+				<col width="10px">
+				<col width="200px">
+				<col width="180px">
+				<col width="100px">
+				<col/>
+				<col width='60px'/>  
+				<tr>
+					<th>$i18n.getString( "nr" )</th>
+					<th>$i18n.getString( "program_stage" )</th>                   
+					<th>$i18n.getString( "reschedule_due_date" )</th>       
+					<th>$i18n.getString( "status" )</th>
+					<th>$i18n.getString( "post_comment" )</th>
+					<th>$i18n.getString( "operation" )</th>
+				</tr>
+				
+			#set( $rowCount = 0 )
+			#set( $mark = false )
+			#foreach( $programStageInstance in $programStageInstances )
+				#set( $rowCount = $rowCount + 1 )   
+				<tr id="tr${programStageInstance.id}" #alternate( $mark ) >
+					##rowCount
+					<td>$rowCount</td>        
+					##stage name
+					<td>
+						$encoder.htmlEncode( $programStageInstance.programStage.name )						
+					</td>
+					#set( $duedateId = "value_" + $programStageInstance.id + "_date" )        
+					<td>        
+						<input type="text" id="$duedateId" style='width:150px;' value="$!format.formatDate( $programStageInstance.dueDate )" onchange="saveDueDate( $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" />
+						<script type="text/javascript">
+							datePicker( '$duedateId' );
+						</script> 
+					</td> 
+					<td>
+						<select id="stat_$programStageInstance.id" name="status_$programStageInstance.id" style='width:120px;' onchange="setEventStatus(this, $programStageInstance.id)">
+							<option value='5'>$i18n.getString("unknown")</option>
+							<option value='1'>$i18n.getString("completed")</option>
+							<option value='2'>$i18n.getString("incompleted")</option>
+							<option value='6'>$i18n.getString("skipped")</option>
+						</select>
+						<script>
+							var status = $statusMap.get( $programStageInstance.id ); 
+							setFieldValue("stat_$programStageInstance.id", status);
+						</script>
+					</td>
+					<td>
+						<input type='text' id='commentText' name='commentText' style="width:380px;" onkeypress="keypress(event,this,'$programStageInstance.id')">
+						<input type='button' value="+" class='tiny-button' title='$i18n.getString("post_comment")' onclick="addComment(this,'$programStageInstance.id')">
+					</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.irregular!='true')
+							<a href="javascript:removeEvent($programStageInstance.id)" title='$i18n.getString( "remove" )'><img src="../images/delete.png" alt='$i18n.getString( "remove" )'></a>
+						#end
+					</td>
+				</tr>
+				#set( $mark = !$mark  )
+			#end
+			</table>
+		#end
+	</div>
+	
+	<!-- Comments and SMS messages -->
+	<div id='tab-4'>
+		#parse( "/dhis-web-caseentry/eventMessage.vm" )
+	</div>
+
+	<div id='tab-5'><div id='programReportDiv'></div></div>
+	
+</div>
+
+<script type="text/javascript">
+	
+	jQuery("#programEnrollmentInforForm").ready( function(){
+		validation( 'programEnrollmentInforForm', function(form){
+			saveIdentifierAndAttribute();
+		});
+		
+		disable("dateOfIncident");
+		disable("enrollmentDate");
+		
+	});
+	
+	$('#tabs').tabs();
+	$( "#tabs" ).bind( "tabsselect", function(event, ui) {
+		if( ui.tab.hash == '#tab-5' ){
+			programReports(getFieldValue('programInstanceId'));
+		}
+	});
+	
+	if ( getFieldValue('enrollmentDate' ) == ''){	
+		jQuery('#enrollBtn').attr( 'value',i18n_enroll );
+	}else{
+		jQuery('#enrollBtn').attr( 'value',i18n_update );
+	}	
+</script>

=== 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-06 10:29:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm	2012-09-07 07:57:47 +0000
@@ -4,12 +4,14 @@
 		validation( 'sendSMSForm', function(form){
 			sendSMS();
 		});
+		setFieldValue('programStageName', "$programStageInstance.programStage.name");
 	});
 </script>
 
+<h4>$programStageInstance.programStage.name</h4>
+
 <input type='hidden' id='currentUsername' name='currentUsername' value='$currentUsername'>
 <input type='hidden' id='programInstanceId' name='programInstanceId' value='$programStageInstance.programInstance.id'>
-
 <table>
 	<tr>            
 		<td class="bold">$i18n.getString( "full_name" ):</td>
@@ -38,38 +40,67 @@
 		</td>
 	</tr>
 	<tr>
-		<td><input type='button' value='$i18n.getString("back")' onclick='backToSelect();'></td>
+		<td>
+			<br><input type='button' value='$i18n.getString("back")' onclick='onClickBackBtn();'>
+			<input type='button' value='$i18n.getString("patient_dashboard")' onclick='javascript:showPatientProgramTracking( "$programStageInstance.programInstance.id" );'>
+		</td>
 	</tr>
 </table>
 
 <div id="smsManagementForm">
 	<ul>
-		<li><a href="#tab-1">$i18n.getString("demographics")</a></li>
+		<li><a href="#tab-1">$i18n.getString("reschedule_and_set_status")</a></li>
+		<li><a href="#tab-3">$i18n.getString("send_sms")</a></li>
 		<li><a href="#tab-2">$i18n.getString("tracking_history")</a></li>
-		<li><a href="#tab-3">$i18n.getString("send_sms")</a></li>
-		<li><a href="#tab-4">$i18n.getString("program_reports")</a></li>
 	</ul>
-		
-	<div id='tab-1'>
-		<table width='100%'>
-			#set($mark = true)
-			#foreach( $identifier in $programStageInstance.programInstance.patient.identifiers )
-				<tr #alternate($mark)>
-					#if($!identifier.identifierType)
-						<td>$identifier.identifierType.name</td>
-					#else
-						<td>$i18n.getString("system_identifier")</td>
-					#end
-					<td>$identifier.identifier</td>
-				</tr>
-				#set($mark = !$mark)
-			#end
-			#foreach( $attributeValue in $attributeValues )
-				<tr #alternate($mark)>
-					<td>$attributeValue.patientAttribute.name</td>
-					<td>$attributeValue.value</td>
-				</tr>
-				#set($mark = !$mark)
+	
+	<div id="tab-1">
+		<table class='mainPageTable' id='progarmStageListDiv' name='progarmStageListDiv' >
+				<tr>
+					<th></th>       
+					<th>$i18n.getString( "operation" )</th>
+				</tr>
+			<tr>
+				<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="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">
+						datePicker( '$duedateId' );
+					</script> 
+				</td> 
+			</tr>
+			<tr>
+				<td>$i18n.getString( "status" )</td>
+				<td>
+					<select id="stat_$programStageInstance.id" name="status_$programStageInstance.id" onchange="setEventStatus(this, $programStageInstance.id)">
+						<option value='5'>$i18n.getString("unknown")</option>
+						<option value='1'>$i18n.getString("completed")</option>
+						<option value='2'>$i18n.getString("incompleted")</option>
+						<option value='6'>$i18n.getString("skipped")</option>
+					</select>
+						<script>
+							var status = $programStageInstance.getEventStatus(); 
+							setFieldValue("stat_$programStageInstance.id", status);
+						</script>
+				</td>
+			</tr>
+			<tr>
+				<td>$i18n.getString( "post_comment" )</td>
+				<td>
+					<input type='text' id='commentText' name='commentText' onkeypress="keypress(event,this,'$programStageInstance.id')">
+					<input type='button' value="+" class='tiny-button' title='$i18n.getString("post_comment")' onclick="addComment(this,'$programStageInstance.id')">
+				</td>
+			</tr>
+			
+			#if($programStageInstance.irregular!='true')
+			<tr>
+				<td>
+					<input type="hidden" value="$i18n.getString('remove_this_event')" onclick="javascript:removeEvent($programStageInstance.id)" title='$i18n.getString( "remove_this_event" )'></a>
+				</td>
+			</tr>
 			#end
 		</table>
 	</div>
@@ -77,14 +108,8 @@
 	<div id="tab-2">
 		<table class="mainPageTable">
 			<col width="160px"/>
+			<col width="300px"/>
 			<col/>
-			<tr>
-				<td class="bold">$i18n.getString('post_comment'):</td>
-				<td>
-					<input type='textbox' id='commentText' name='commentText' style="width:320px;" onkeypress="keypress(event,'$programStageInstance.id')">
-					<input type='button' value="+" class='tiny-button' onclick="addComment('$programStageInstance.id')">
-				</td>
-			</tr>
 			<tr><td>&nbsp;</td></tr>
 			<tr>
 				<th>$i18n.getString( "date" )</th>
@@ -153,7 +178,6 @@
 		#parse( "/dhis-web-caseentry/sendSmsForm.vm" )
 	</div>
 	
-	<div id='tab-4'><div id='programReportDiv'></div></div>
 </div>
 
 <script type="text/javascript">
@@ -161,12 +185,6 @@
 		var i18n_color_quick_help = '$encoder.jsEscape( $i18n.getString( "color_quick_help" ) , "'")';
 		var i18n_comment_added = '$encoder.jsEscape( $i18n.getString( "comment_added" ) , "'")';
 		setFieldValue( "programStageInstanceId", "$!programStageInstance.id" );
-		
-		$( "#smsManagementForm" ).bind( "tabsselect", function(event, ui) {
-			if( ui.tab.hash == '#tab-4' ){
-				programReports(getFieldValue('programInstanceId'));
-			}
-		});
 	});
 	
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm	2012-09-06 09:44:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm	2012-09-07 07:57:47 +0000
@@ -31,7 +31,7 @@
 			#set( $programInstance = $programInstanceMap.get( $patient ) )
 				<tr #alternate( $mark )>
 					<td>
-						<input type='button' class='patient-object' value='$patient.getFullName()' onclick='javascript:showPatientHistory( "$patient.id" );' title='$i18n.getString( "patient_details_and_history" )'>
+						<input type='button' class='patient-object' value='$patient.getFullName()' onclick='javascript:showPatientProgramTracking( "$programInstance.id" );' title='$i18n.getString( "patient_dashboard" )'>
 					</td>
 					<td class='bold' style='cursor:pointer;font-size:25px' onclick="eventFlowToggle($programInstance.id)">
 						<a>&raquo;</a>
@@ -69,7 +69,7 @@
 																#end
 															#end
 																	
-															<input type='button' id='ps_$programStageInstance.id' name='programStageBtn' 
+															<input type='button' id='box_$programStageInstance.id' name='programStageBtn' 
 																programStageInstanceId='$programStageInstance.id' 
 																programStageName='$programStageInstance.programStage.name' 
 																programStageId='$programStageInstance.programStage.id' 
@@ -81,7 +81,7 @@
 														<script>
 															var status = $statusMap.get( $programStageInstance.id ); 
 															var dueDate = "$format.formatDate($programStageInstance.dueDate)";
-															setEventColorStatus( 'ps_' + $programStageInstance.id ,status, dueDate );
+															setEventColorStatus( 'box_' + $programStageInstance.id ,status, dueDate );
 														</script>
 													</tr>
 												</table>
@@ -127,7 +127,7 @@
 		#foreach( $id in $programStageInstanceIds )
 			showById('arrow_$id');
 			showById('td_$id');
-			jQuery("#ps_$id").addClass("stage-object-selected searched");
+			jQuery("#box_$id").addClass("stage-object-selected searched");
 		#end
 	#end
 </script>
\ No newline at end of file

=== 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-06 09:44:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm	2012-09-07 07:57:47 +0000
@@ -15,6 +15,7 @@
 		disable('advancedSearchBtn');
 		hideById('searchBySelectedUnitTD');
 		setFieldValue('searchByProgramStage', 'true');
+		setFieldValue('hideLink', 'true');
 		showById('dueDateTR');
 	});	
 </script>
@@ -25,16 +26,17 @@
 	<input type='hidden' id='listAll' name='listAll'>
 	<input type='hidden' id='sendToList' name='sendToList'>
 	<input type='hidden' id='programStageInstanceId' name='programStageInstanceId' value='$programStageInstance.id'>
+	<input type='hidden' id='programStageName' name='programStageName'>
 	<div id='searchDiv'>
 		#parse( "dhis-web-caseentry/searchPatientCriteria.vm" )	
 	</div>
 </form>
 
-#parse( "dhis-web-commons/loader/loader.vm" )
-
 <div id='listPatientDiv'></div>
+<div id='patientProgramTrackingDiv'></div>
 <div id='smsManagementDiv'></div>
 <div id='sendSmsFormDiv'></div>
+#parse( "dhis-web-commons/loader/loader.vm" )
 
 <div class='hidden'>
 	<input type='textbox' id='currentDate' name='currentDate'>
@@ -53,4 +55,6 @@
 	var i18n_patient_details_and_history = '$encoder.jsEscape( $i18n.getString( "patient_details_and_history" ) , "'")';
 	var i18n_please_select_program_stage = '[' + '$encoder.jsEscape( $i18n.getString( "please_select_program_stage" ) , "'")' + ']';
 	var i18n_comment_added = '$encoder.jsEscape( $i18n.getString( "comment_added" ) , "'")';
+	var i18n_update = '$encoder.jsEscape( $i18n.getString( "update" ) , "'")';
+	var i18n_comfirm_delete_event = '$encoder.jsEscape( $i18n.getString( "comfirm_delete_event" ) , "'")';
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2012-09-06 09:44:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2012-09-07 07:57:47 +0000
@@ -1,5 +1,6 @@
 <input type='hidden' id='searchByProgramStage' name='searchByProgramStage' value="false">
 <input type='hidden' id='orgunitId' name='orgunitId' value='$organisationUnit.id' >
+<input type="hidden" id='hideLink' name='hideLink' value='false'>
 
 <table style="margin-bottom:8px">    
 	<tr>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sendSmsForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sendSmsForm.vm	2012-08-17 07:24:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sendSmsForm.vm	2012-09-07 07:57:47 +0000
@@ -30,7 +30,7 @@
 			
 				<tr>
 					<td></td>
-					<td><input type="submit" name="send" value="$i18n.getString( 'send_sms' )"/></td>
+					<td><input type="submit" name="send" value="$i18n.getString( 'send_sms' )" onclick="jQuery('#sendSmsFormDiv').dialog('close')"/></td>
 				</tr>
 				
 			</tbody>