← Back to team overview

dhis-mobile-devs team mailing list archive

[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 231: backport lwuit-tracking-2.15 revision number 121, 126-134

 

------------------------------------------------------------
revno: 231
committer: sherylyn.marie
branch nick: lwuit-tracking
timestamp: Tue 2014-06-24 11:59:44 +0800
message:
  backport lwuit-tracking-2.15 revision number 121, 126-134
added:
  src/org/hisp/dhis/mobile/connection/task/CompleteProgramInstanceTask.java
modified:
  src/org/hisp/dhis/mobile/connection/ConnectionManager.java
  src/org/hisp/dhis/mobile/connection/task/FindVisitScheduleTask.java
  src/org/hisp/dhis/mobile/connection/task/GetPatientTask.java
  src/org/hisp/dhis/mobile/connection/task/LoginTask.java
  src/org/hisp/dhis/mobile/connection/task/UploadTrackingFormTask.java
  src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java
  src/org/hisp/dhis/mobile/model/OrgUnit.java
  src/org/hisp/dhis/mobile/model/ProgramStage.java
  src/org/hisp/dhis/mobile/view/DashboardLinkView.java
  src/org/hisp/dhis/mobile/view/GenerateRepeatableEventView.java
  src/org/hisp/dhis/mobile/view/PersonDashboardView.java
  src/org/hisp/dhis/mobile/view/PersonListView.java
  src/org/hisp/dhis/mobile/view/ProgramSelectView.java
  src/org/hisp/dhis/mobile/view/ProgramStageListView.java
  src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java
  src/org/hisp/dhis/mobile/view/VisitScheduleListView.java


--
lp:~dhis-mobile-devs/dhis-mobile/lwuit-tracking
https://code.launchpad.net/~dhis-mobile-devs/dhis-mobile/lwuit-tracking

Your team DHIS mobile developers is subscribed to branch lp:~dhis-mobile-devs/dhis-mobile/lwuit-tracking.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis-mobile-devs/dhis-mobile/lwuit-tracking/+edit-subscription
=== modified file 'src/org/hisp/dhis/mobile/connection/ConnectionManager.java'
--- src/org/hisp/dhis/mobile/connection/ConnectionManager.java	2014-06-05 06:58:28 +0000
+++ src/org/hisp/dhis/mobile/connection/ConnectionManager.java	2014-06-24 03:59:44 +0000
@@ -28,6 +28,7 @@
 
 import org.hisp.dhis.mobile.connection.task.AbstractTask;
 import org.hisp.dhis.mobile.connection.task.AddRelationshipTask;
+import org.hisp.dhis.mobile.connection.task.CompleteProgramInstanceTask;
 import org.hisp.dhis.mobile.connection.task.DownloadAllResourceTask;
 import org.hisp.dhis.mobile.connection.task.DownloadMessageConversationTask;
 import org.hisp.dhis.mobile.connection.task.DownloadMessageTask;
@@ -61,6 +62,7 @@
 import org.hisp.dhis.mobile.model.OrgUnit;
 import org.hisp.dhis.mobile.model.Patient;
 import org.hisp.dhis.mobile.model.Program;
+import org.hisp.dhis.mobile.model.ProgramInstance;
 import org.hisp.dhis.mobile.model.ProgramStage;
 import org.hisp.dhis.mobile.model.Relationship;
 import org.hisp.dhis.mobile.model.Section;
@@ -211,10 +213,12 @@
         runTask( findVisitScheduleTask );
     }
 
-    public static void getPatientById( String patientId )
+    public static void getPatientById( String patientId, int previousScreen, Program vsProgram )
     {
         GetPatientTask getPatientTask = new GetPatientTask();
         getPatientTask.setPatientId( patientId );
+        getPatientTask.setPreviousScreen( previousScreen );
+        getPatientTask.setVSProgram( vsProgram );
         runTask( getPatientTask );
     }
 
@@ -313,6 +317,12 @@
         runTask( generateRepeatableEventTask );
     }
 
+    public static void completeProgramInstance( ProgramInstance programInstance, Patient patient )
+    {
+        CompleteProgramInstanceTask completeProgramInstanceTask = new CompleteProgramInstanceTask( programInstance, patient );
+        runTask( completeProgramInstanceTask );
+    }
+    
     public static void uploadSingleEventWithoutRegistration( ProgramStage programStage )
     {
         UploadSingleEventWithoutRegistration uploadSingleEventWithoutRegistration = new UploadSingleEventWithoutRegistration();

=== added file 'src/org/hisp/dhis/mobile/connection/task/CompleteProgramInstanceTask.java'
--- src/org/hisp/dhis/mobile/connection/task/CompleteProgramInstanceTask.java	1970-01-01 00:00:00 +0000
+++ src/org/hisp/dhis/mobile/connection/task/CompleteProgramInstanceTask.java	2014-06-24 03:59:44 +0000
@@ -0,0 +1,71 @@
+package org.hisp.dhis.mobile.connection.task;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+import org.hisp.dhis.mobile.connection.ConnectionManager;
+import org.hisp.dhis.mobile.log.LogMan;
+import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
+import org.hisp.dhis.mobile.model.Patient;
+import org.hisp.dhis.mobile.model.ProgramInstance;
+import org.hisp.dhis.mobile.util.SerializationUtil;
+
+public class CompleteProgramInstanceTask
+    extends AbstractTask
+{
+
+    private static final String CLASS_TAG = "CompleteProgramInstanceTask";
+    
+    private static final String PROGRAM_COMPLETED = "program_completed";
+
+    private NameBasedMIDlet nameBasedMIDlet;
+
+    private ProgramInstance programInstance;
+
+    private Patient patient;
+
+    public CompleteProgramInstanceTask( ProgramInstance programInstance, Patient patient )
+    {
+        super();
+        nameBasedMIDlet = (NameBasedMIDlet) ConnectionManager.getDhisMIDlet();
+        this.programInstance = programInstance;
+        this.patient = patient;
+    }
+
+    public void run()
+    {
+        LogMan.log( LogMan.INFO, "Network," + CLASS_TAG, "Starting CompleteProgramInstanceTask..." );
+        try
+        {
+            DataInputStream messageStream = this.upload( SerializationUtil.serialize( programInstance ) );
+            String message = this.readMessage( messageStream );
+            if(message.equals( PROGRAM_COMPLETED ))
+            {
+                patient.getEnrollmentPrograms().removeElement( programInstance );
+                patient.getCompletedPrograms().addElement( programInstance );
+            }
+            nameBasedMIDlet.getPersonDashboardView().setPatient( patient );
+            nameBasedMIDlet.getPersonDashboardView().showView();
+            messageStream = null;
+            System.gc();
+        }
+        catch ( IOException e )
+        {
+            LogMan.log( CLASS_TAG, e );
+            e.printStackTrace();
+        }
+    }
+
+    public Patient getPatient()
+    {
+        return patient;
+    }
+
+    public void setPatient( Patient patient )
+    {
+        this.patient = patient;
+    }
+
+}
+
+

=== modified file 'src/org/hisp/dhis/mobile/connection/task/FindVisitScheduleTask.java'
--- src/org/hisp/dhis/mobile/connection/task/FindVisitScheduleTask.java	2014-05-21 09:09:34 +0000
+++ src/org/hisp/dhis/mobile/connection/task/FindVisitScheduleTask.java	2014-06-24 03:59:44 +0000
@@ -45,8 +45,9 @@
                     message = message.substring( message.indexOf( "$" ) + 1, message.length() );
                 }
                 nameBasedMIDlet.getVisitScheduleListView().setInstanceInfos( instanceInfos );
+                nameBasedMIDlet.getVisitScheduleListView().setProgram( program );
+                nameBasedMIDlet.getVisitScheduleListView().showView();
                 instanceInfos = null;
-                nameBasedMIDlet.getVisitScheduleListView().showView();
             }
             inputStream = null;
             System.gc();

=== modified file 'src/org/hisp/dhis/mobile/connection/task/GetPatientTask.java'
--- src/org/hisp/dhis/mobile/connection/task/GetPatientTask.java	2014-04-03 01:58:41 +0000
+++ src/org/hisp/dhis/mobile/connection/task/GetPatientTask.java	2014-06-24 03:59:44 +0000
@@ -6,17 +6,22 @@
 import org.hisp.dhis.mobile.log.LogMan;
 import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
 import org.hisp.dhis.mobile.model.Patient;
+import org.hisp.dhis.mobile.model.Program;
 import org.hisp.dhis.mobile.recordstore.PatientRecordStore;
 
 public class GetPatientTask
     extends AbstractTask
 {
     private static final String CLASS_TAG = "GetPatientTask";
-    
+
     private String patientId;
 
     private NameBasedMIDlet nameBasedMIDlet;
 
+    private Program vsProgram;
+
+    private int previousScreen;
+
     public GetPatientTask()
     {
         this.nameBasedMIDlet = (NameBasedMIDlet) ConnectionManager.getDhisMIDlet();
@@ -39,12 +44,14 @@
 
             // show the patient dashboard
             nameBasedMIDlet.getPersonDashboardView().setPatient( patient );
+            nameBasedMIDlet.getPersonDashboardView().setVSProgram( vsProgram );
+            nameBasedMIDlet.getPersonDashboardView().setPreviousScreen( previousScreen );
             nameBasedMIDlet.getPersonDashboardView().showView();
         }
         catch ( Exception e )
         {
             e.printStackTrace();
-            LogMan.log( "Network,"+CLASS_TAG, e );
+            LogMan.log( "Network," + CLASS_TAG, e );
         }
     }
 
@@ -58,6 +65,16 @@
         this.patientId = patientId;
     }
 
+    public Program getVSProgram()
+    {
+        return vsProgram;
+    }
+
+    public void setVSProgram( Program vsProgram )
+    {
+        this.vsProgram = vsProgram;
+    }
+
     public NameBasedMIDlet getNameBasedMIDlet()
     {
         return nameBasedMIDlet;
@@ -68,4 +85,14 @@
         this.nameBasedMIDlet = nameBasedMIDlet;
     }
 
+    public int getPreviousScreen()
+    {
+        return previousScreen;
+    }
+
+    public void setPreviousScreen( int previousScreen )
+    {
+        this.previousScreen = previousScreen;
+    }
+
 }

=== modified file 'src/org/hisp/dhis/mobile/connection/task/LoginTask.java'
--- src/org/hisp/dhis/mobile/connection/task/LoginTask.java	2014-04-07 07:57:37 +0000
+++ src/org/hisp/dhis/mobile/connection/task/LoginTask.java	2014-06-24 03:59:44 +0000
@@ -99,7 +99,7 @@
                 ConnectionManager.getDhisMIDlet().getLoginView().showView();
             }
             e.printStackTrace();
-            LogMan.log( "Network,Authentication," + CLASS_TAG, e );
+            LogMan.log( "Network,Authentication3," + CLASS_TAG, e );
         }
         finally
         {
@@ -120,7 +120,7 @@
     public static void handleLogIn( DataInputStream dis )
         throws Exception
     {
-        LogMan.log( LogMan.INFO, "Network,Authentication," + CLASS_TAG, "Handling Login" );
+        LogMan.log( LogMan.INFO, "Network,Authentication4," + CLASS_TAG, "Handling Login" );
 
         try
         {
@@ -149,7 +149,7 @@
             orgUnit = null;
             System.gc();
         } catch (Exception e) {
-            LogMan.log( "Network,Authentication," + CLASS_TAG, e );
+            LogMan.log( "Network,Authentication1," + CLASS_TAG, e );
         }
         finally
         {
@@ -162,7 +162,7 @@
             catch ( IOException ioe )
             {
                 ioe.printStackTrace();
-                LogMan.log( "Network,Authentication," + CLASS_TAG, ioe );
+                LogMan.log( "Network,Authentication2," + CLASS_TAG, ioe );
             }
 
         }

=== modified file 'src/org/hisp/dhis/mobile/connection/task/UploadTrackingFormTask.java'
--- src/org/hisp/dhis/mobile/connection/task/UploadTrackingFormTask.java	2014-05-23 10:03:40 +0000
+++ src/org/hisp/dhis/mobile/connection/task/UploadTrackingFormTask.java	2014-06-24 03:59:44 +0000
@@ -126,6 +126,7 @@
             }
             else if ( message.equalsIgnoreCase( PROGRAM_STAGE_SECTION_UPLOADED ) )
             {
+                LogMan.log( LogMan.DEBUG, "Network," + CLASS_TAG, "PROGRAM_STAGE_SECTION_UPLOADED" );
                 nameBasedMIDlet.getSectionListView().setPatient( patient );
                 nameBasedMIDlet.getSectionListView().setProgramStage( programStage );
                 nameBasedMIDlet.getAlertBoxView( section.getName(), Text.UPLOAD_COMPLETED() ).showView();
@@ -133,11 +134,13 @@
             }
             else if ( message.equalsIgnoreCase( ANONYMOUS_PROGRAM_UPLOADED ) )
             {
+                LogMan.log( LogMan.DEBUG, "Network," + CLASS_TAG, "ANONYMOUS_PROGRAM_UPLOADED" );
                 nameBasedMIDlet.getAlertBoxView( programStage.getName(), Text.UPLOAD_COMPLETED() ).showView();
                 nameBasedMIDlet.getTrackingMainMenuView().showView();
             }
             else if ( message.equalsIgnoreCase( SINGLE_EVENT_UPLOADED ) )
             {
+                LogMan.log( LogMan.DEBUG, "Network," + CLASS_TAG, "--SINGLE_EVENT_UPLOADED" );
                 programStage.setCompleted( true );
                 nameBasedMIDlet.getAlertBoxView( programStage.getName(), Text.UPLOAD_COMPLETED() ).showView();
                 nameBasedMIDlet.getTrackingMainMenuView().showView();
@@ -163,12 +166,27 @@
                 nameBasedMIDlet.getAlertBoxView( "Invalid Program Stage", Text.ERROR() ).showView();
                 nameBasedMIDlet.getPersonDashboardView().showView();
             }
+            else if ( e.getMessage().equalsIgnoreCase( Text.HTTP_ERROR() )
+                || e.getMessage().equalsIgnoreCase( "TCP open" )
+                || e.getMessage().equalsIgnoreCase( "Error in HTTP operation" ) )
+            {
+                nameBasedMIDlet.getAlertBoxView( "Internet is not available, Please try again later.", "Alert" )
+                    .showView();
+                nameBasedMIDlet.getTrackingDataEntryView().setPatient( patient );
+                nameBasedMIDlet.getTrackingDataEntryView().setProgramStage( programStage );
+                nameBasedMIDlet.getTrackingDataEntryView().setTitle( programStage.getName() );
+                nameBasedMIDlet.getTrackingDataEntryView().showView();
+            }
             patient = null;
             programStage = null;
             uploadProgramStage = null;
             section = null;
             System.gc();
         }
+        catch ( Exception e )
+        {
+            LogMan.log( LogMan.DEV, "Network," + CLASS_TAG, e.getMessage() );
+        }
     }
 
     public Patient getPatient()

=== modified file 'src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java'
--- src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java	2014-06-05 06:58:28 +0000
+++ src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java	2014-06-24 03:59:44 +0000
@@ -137,14 +137,17 @@
     private MessageReplyView messageReplyView;
 
     private String previousScreen = "";
-
-    public final int PERSON_REGISTRATION_VIEW = 1;
-
-    public final int LOST_TO_FOLLOW_UP_VIEW = 2;
-
-    public final int VISIT_SCHEDULE_VIEW = 3;
-
-    public final int HISTORY_PERSON_LIST_VIEW = 4;
+    public final int FIND_INSTANCE_VIEW = 1;
+    
+    public final int PERSON_REGISTRATION_VIEW = 2;
+
+    public final int LOST_TO_FOLLOW_UP_VIEW = 3;
+
+    public final int VISIT_SCHEDULE_VIEW = 4;
+    
+    public final int HISTORY_PERSON_LIST_VIEW = 5;
+    
+    public final int SINGLE_EVENT_WITHOUT_REGISTRATION = 6;
 
     public NameBasedMIDlet()
     {
@@ -392,6 +395,7 @@
         {
             generateRepeatableEventView.setProgramStage( programStage );
             generateRepeatableEventView.setDefaultDueDate( defaultDueDate );
+            generateRepeatableEventView.setPatient( patient );
         }
         return generateRepeatableEventView;
     }

=== modified file 'src/org/hisp/dhis/mobile/model/OrgUnit.java'
--- src/org/hisp/dhis/mobile/model/OrgUnit.java	2014-05-28 11:14:44 +0000
+++ src/org/hisp/dhis/mobile/model/OrgUnit.java	2014-06-24 03:59:44 +0000
@@ -97,6 +97,8 @@
 
     private String uploadSingleEventWithoutRegistration;
 
+    private String completeProgramInstanceUrl;
+
     public static double serverVersion;
 
     public int getId()
@@ -269,6 +271,11 @@
         return generateRepeatableEventUrl;
     }
 
+    public String getCompleteProgramInstanceUrl()
+    {
+        return completeProgramInstanceUrl;
+    }
+
     public String getUploadSingleEventWithoutRegistration()
     {
         return uploadSingleEventWithoutRegistration;
@@ -315,6 +322,7 @@
         dataOutputStream.writeUTF( handleLostToFollowUpUrl );
         dataOutputStream.writeUTF( generateRepeatableEventUrl );
         dataOutputStream.writeUTF( uploadSingleEventWithoutRegistration );
+        dataOutputStream.writeUTF( completeProgramInstanceUrl );
     }
 
     public void deSerialize( DataInputStream dataInputStream )
@@ -421,6 +429,9 @@
         uploadSingleEventWithoutRegistration = dataInputStream.readUTF();
         LogMan.log( LogMan.DEBUG, "OrgUnit," + CLASS_TAG, "uploadSingleEventWithoutRegistration="
             + uploadSingleEventWithoutRegistration );
+
+        completeProgramInstanceUrl = dataInputStream.readUTF();
+        LogMan.log( LogMan.DEBUG, "OrgUnit," + CLASS_TAG, "completeProgramInstanceUrl=" + completeProgramInstanceUrl );
     }
 
     public boolean checkNewVersion( double serverVersion )

=== modified file 'src/org/hisp/dhis/mobile/model/ProgramStage.java'
--- src/org/hisp/dhis/mobile/model/ProgramStage.java	2013-10-31 08:06:34 +0000
+++ src/org/hisp/dhis/mobile/model/ProgramStage.java	2014-06-24 03:59:44 +0000
@@ -28,6 +28,8 @@
     extends Model
 {
     private String reportDate;
+    
+    private String dueDate;
 
     private String reportDateDescription;
 
@@ -37,7 +39,7 @@
 
     private boolean isSingleEvent;
     
-    private int standardInterval; 
+    private int standardInterval;
 
     private Vector dataElements = new Vector();
 
@@ -113,6 +115,16 @@
         this.reportDateDescription = reportDateDescription;
     }
 
+    public String getDueDate()
+    {
+        return dueDate;
+    }
+
+    public void setDueDate( String dueDate )
+    {
+        this.dueDate = dueDate;
+    }
+
     public int getStandardInterval()
     {
         return standardInterval;
@@ -127,8 +139,14 @@
         throws IOException
     {
         super.serialize( dout );
+
+        if ( dueDate == null )
+        {
+            dueDate = "";
+        }
         dout.writeUTF( this.reportDate );
         dout.writeUTF( "" );
+        dout.writeUTF( this.dueDate );
         dout.writeBoolean( this.isRepeatable() );
         dout.writeInt( standardInterval );
         dout.writeBoolean( this.isCompleted() );
@@ -156,6 +174,7 @@
         super.deSerialize( din );
         this.setReportDate( din.readUTF() );
         this.setReportDateDescription( din.readUTF() );
+        this.setDueDate( din.readUTF() );
         this.setRepeatable( din.readBoolean() );
         setStandardInterval( din.readInt() );
         this.setCompleted( din.readBoolean() );

=== modified file 'src/org/hisp/dhis/mobile/view/DashboardLinkView.java'
--- src/org/hisp/dhis/mobile/view/DashboardLinkView.java	2014-04-03 01:58:41 +0000
+++ src/org/hisp/dhis/mobile/view/DashboardLinkView.java	2014-06-24 03:59:44 +0000
@@ -117,13 +117,13 @@
             {
                 ProgramInstance currentProgram = (ProgramInstance) patient.getEnrollmentPrograms().elementAt( 0 );
                 ProgramStage programStage = (ProgramStage) currentProgram.getProgramStageInstances().elementAt( 0 );
-                if ( programStage.getSections().size() > 0 )
+                if ( currentProgram.getProgramStageInstances().size() > 1 )
                 {
-                    namebasedMidlet.getSectionListView().setPatient( patient );
-                    namebasedMidlet.getSectionListView().setProgramStage( programStage );
-                    namebasedMidlet.getSectionListView().showView();
+                    namebasedMidlet.getProgramStageListView().setPatient( patient );
+                    namebasedMidlet.getProgramStageListView().setProgramInstance( currentProgram );
+                    namebasedMidlet.getProgramStageListView().showView();
                 }
-                else
+                else if ( currentProgram.getProgramStageInstances().size() == 1 )
                 {
                     namebasedMidlet.getTrackingDataEntryView().setPatient( patient );
                     namebasedMidlet.getTrackingDataEntryView().setProgramStage( programStage );

=== modified file 'src/org/hisp/dhis/mobile/view/GenerateRepeatableEventView.java'
--- src/org/hisp/dhis/mobile/view/GenerateRepeatableEventView.java	2013-11-01 10:05:16 +0000
+++ src/org/hisp/dhis/mobile/view/GenerateRepeatableEventView.java	2014-06-24 03:59:44 +0000
@@ -30,6 +30,7 @@
 import org.hisp.dhis.mobile.midlet.DHISMIDlet;
 import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
 import org.hisp.dhis.mobile.model.Patient;
+import org.hisp.dhis.mobile.model.ProgramInstance;
 import org.hisp.dhis.mobile.model.ProgramStage;
 import org.hisp.dhis.mobile.ui.Text;
 import org.hisp.dhis.mobile.util.PeriodUtil;
@@ -55,24 +56,25 @@
     private Form mainForm;
 
     private Command createCommand, noCommand;
-    
+
     private Label lblProgramStageName;
 
     private TextField txtDueDate;
 
     private Label lbldueDate;
-    
+
     private Label lblWrongFormat;
-    
+
     private String defaultDueDate;
 
     private ProgramStage programStage;
-    
+
     private Patient patient;
-    
+
     private NameBasedMIDlet nameBasedMidlet;
 
-    public GenerateRepeatableEventView( DHISMIDlet dhisMIDlet, ProgramStage programStage, String defaultDueDate, Patient patient )
+    public GenerateRepeatableEventView( DHISMIDlet dhisMIDlet, ProgramStage programStage, String defaultDueDate,
+        Patient patient )
     {
         super( dhisMIDlet );
         this.programStage = programStage;
@@ -85,8 +87,17 @@
     {
         if ( ae.getCommand().getCommandName().equalsIgnoreCase( Text.NO() ) )
         {
-            nameBasedMidlet.getPersonDashboardView().setPatient( patient );
-            nameBasedMidlet.getPersonDashboardView().showView();
+            ProgramInstance programInstance = findProgramInstance();
+            if ( programStage.isRepeatable() && isAllProgramStageFinished( programInstance ) )
+            {
+                ConnectionManager.setUrl( nameBasedMidlet.getCurrentOrgUnit().getCompleteProgramInstanceUrl() );
+                ConnectionManager.completeProgramInstance( programInstance, patient );
+            }
+            else
+            {
+                nameBasedMidlet.getPersonDashboardView().setPatient( patient );
+                nameBasedMidlet.getPersonDashboardView().showView();
+            }
         }
         else
         {
@@ -99,14 +110,49 @@
             {
                 ConnectionManager.setUrl( nameBasedMidlet.getCurrentOrgUnit().getGenerateRepeatableEventUrl() );
                 nameBasedMidlet.getWaitingView().showView();
-                ConnectionManager.generateRepeatableEvent( programStage.getId()+"$"+dueDate );
-            }
-        }
-    }
-    
+                ConnectionManager.generateRepeatableEvent( programStage.getId() + "$" + dueDate );
+            }
+        }
+    }
+
+    private ProgramInstance findProgramInstance()
+    {
+        for ( int i = 0; i < patient.getEnrollmentPrograms().size(); i++ )
+        {
+            ProgramInstance programInstance = (ProgramInstance) patient.getEnrollmentPrograms().elementAt( i );
+            for ( int j = 0; j < programInstance.getProgramStageInstances().size(); j++ )
+            {
+                ProgramStage programStage = (ProgramStage) programInstance.getProgramStageInstances().elementAt( j );
+                System.out.println( programStage.getId() + "==" + programStage.getId() );
+                if ( programStage.getId() == programStage.getId() )
+                {
+                    return programInstance;
+                }
+            }
+        }
+        return null;
+    }
+
+    private boolean isAllProgramStageFinished( ProgramInstance programInstance )
+    {
+        if ( programInstance == null )
+        {
+            return false;
+        }
+        for ( int j = 0; j < programInstance.getProgramStageInstances().size(); j++ )
+        {
+            final ProgramStage programStage = (ProgramStage) programInstance.getProgramStageInstances().elementAt( j );
+            if ( !programStage.isCompleted() )
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
     public boolean validateDueDate( String dueDate )
     {
-        if( dueDate.equals( "" ) )
+        if ( dueDate.equals( "" ) )
         {
             lblWrongFormat.setText( "(*):Required Field" );
             return false;
@@ -138,14 +184,17 @@
         mainForm.addComponent( getTxtDueDate() );
         mainForm.addComponent( getLblWrongFormat() );
     }
-    
+
     public Form getMainForm()
     {
         if ( mainForm == null )
         {
             mainForm = new Form( "Create new event" );
             mainForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
-            mainForm.setTransitionOutAnimator( CommonTransitions.createSlide( CommonTransitions.SLIDE_HORIZONTAL, true, 200 ) );
+            mainForm.setTransitionOutAnimator( CommonTransitions.createSlide( CommonTransitions.SLIDE_HORIZONTAL, true,
+                200 ) );
+            mainForm.setTransitionOutAnimator( CommonTransitions.createSlide( CommonTransitions.SLIDE_HORIZONTAL, true,
+                200 ) );
             mainForm.addCommand( getNoCommand() );
             mainForm.addCommand( getCreateCommand() );
             mainForm.addCommandListener( this );
@@ -209,6 +258,11 @@
         this.programStage = programStage;
     }
 
+    public void setPatient( Patient patient )
+    {
+        this.patient = patient;
+    }
+
     public Label getLblProgramStageName()
     {
         if ( lblProgramStageName == null )
@@ -227,5 +281,5 @@
         }
         return lblWrongFormat;
     }
-    
+
 }

=== modified file 'src/org/hisp/dhis/mobile/view/PersonDashboardView.java'
--- src/org/hisp/dhis/mobile/view/PersonDashboardView.java	2014-05-28 11:14:44 +0000
+++ src/org/hisp/dhis/mobile/view/PersonDashboardView.java	2014-06-24 03:59:44 +0000
@@ -79,6 +79,8 @@
 
     private Patient patient;
 
+    private Program vsProgram;
+
     private int previousScreen;
 
     public PersonDashboardView( DHISMIDlet dhisMIDlet )
@@ -210,6 +212,11 @@
                     e.printStackTrace();
                 }
             }
+            else if ( previousScreen == namebasedMidlet.VISIT_SCHEDULE_VIEW )
+            {
+                namebasedMidlet.getVisitScheduleMenuView().setProgram( vsProgram );
+                namebasedMidlet.getVisitScheduleMenuView().showView();
+            }
             else
             {
                 namebasedMidlet.getFindBeneficiaryView().getMainForm()
@@ -298,7 +305,12 @@
                             .elementAt( j );
                         if ( programStage.isCompleted() == false )
                         {
-                            LinkButton programStageLink = new LinkButton( "--" + programStage.getName() );
+                            String label = programStage.getName();
+                            if ( programStage.getDueDate() != null && !programStage.getDueDate().equals( "" ) )
+                            {
+                                label += " (" + programStage.getDueDate() + ")";
+                            }
+                            LinkButton programStageLink = new LinkButton( "--" + label );
                             programStageLink.addActionListener( new ActionListener()
                             {
                                 public void actionPerformed( ActionEvent arg )
@@ -493,4 +505,14 @@
     {
         this.patient = patient;
     }
+
+    public Program getVSProgram()
+    {
+        return vsProgram;
+    }
+
+    public void setVSProgram( Program vsProgram )
+    {
+        this.vsProgram = vsProgram;
+    }
 }

=== modified file 'src/org/hisp/dhis/mobile/view/PersonListView.java'
--- src/org/hisp/dhis/mobile/view/PersonListView.java	2014-05-30 03:43:28 +0000
+++ src/org/hisp/dhis/mobile/view/PersonListView.java	2014-06-24 03:59:44 +0000
@@ -134,7 +134,7 @@
                             if ( enrollmentRelationship == null )
                             {
                                 ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getFindPatientUrl() );
-                                ConnectionManager.getPatientById( id );
+                                ConnectionManager.getPatientById( id, nameBasedMIDlet.FIND_INSTANCE_VIEW, null );
                             }
                             else
                             {
@@ -152,7 +152,7 @@
                 mainForm.addComponent( personLink );
             }
         }
-        if ( patientInfos.size() == 10 )
+        if ( patientInfos.size() >= 10 )
         {
             nameBasedMIDlet.getAlertBoxView( "Too many results, be more specific", "Warning" ).showView();
         }

=== modified file 'src/org/hisp/dhis/mobile/view/ProgramSelectView.java'
--- src/org/hisp/dhis/mobile/view/ProgramSelectView.java	2014-05-21 09:09:34 +0000
+++ src/org/hisp/dhis/mobile/view/ProgramSelectView.java	2014-06-24 03:59:44 +0000
@@ -116,7 +116,8 @@
                     nameBasedMIDlet.getWaitingView().showView();
                     try
                     {
-                        if ( targetScreen == nameBasedMIDlet.PERSON_REGISTRATION_VIEW )
+                        if ( targetScreen == nameBasedMIDlet.PERSON_REGISTRATION_VIEW ||
+                            targetScreen == nameBasedMIDlet.SINGLE_EVENT_WITHOUT_REGISTRATION )
                         {
                             if ( program.getType() != 3 )
                             {
@@ -139,8 +140,7 @@
                             nameBasedMIDlet.getVisitScheduleMenuView().setProgram( program );
                             nameBasedMIDlet.getVisitScheduleMenuView().showView();
                         }
-                        // nameBasedMIDlet.LOST_TO_FOLLOW_UP_VIEW
-                        else
+                        else if ( targetScreen == nameBasedMIDlet.LOST_TO_FOLLOW_UP_VIEW )
                         {
                             String status = (String) cbbStatus.getSelectedItem();
                             boolean isRiskCase = chbRisk.isSelected();

=== modified file 'src/org/hisp/dhis/mobile/view/ProgramStageListView.java'
--- src/org/hisp/dhis/mobile/view/ProgramStageListView.java	2014-05-28 11:14:44 +0000
+++ src/org/hisp/dhis/mobile/view/ProgramStageListView.java	2014-06-24 03:59:44 +0000
@@ -68,10 +68,16 @@
             if ( programStage.isSingleEvent() == false )
             {
                 String programStageText = programStage.getName();
-                if ( !programStage.getReportDate().equals( "" ))
+
+
+                if ( !programStage.getReportDate().equals( "" ) )
                 {
                     programStageText += " (" + programStage.getReportDate() + ")";
                 }
+                else if ( !programStage.getDueDate().equals( "" ) )
+                {
+                    programStageText += " (" + programStage.getDueDate() + ")";
+                }
                 LinkButton programStageLink = new LinkButton( programStageText );
                 if ( programStage.isCompleted() )
                 {
@@ -154,12 +160,13 @@
     {
         if ( ae.getCommand().getCommandName().equals( Text.BACK() ) )
         {
+            nameBasedMIDlet.getPersonDashboardView().setPatient( patient );
+            nameBasedMIDlet.getPersonDashboardView().showView();
+            
             personProgramStageListForm = null;
             backCommand = null;
             patient = null;
-
             System.gc();
-            nameBasedMIDlet.getPersonDashboardView().showView();
         }
     }
 

=== modified file 'src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java'
--- src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java	2014-06-03 10:32:05 +0000
+++ src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java	2014-06-24 03:59:44 +0000
@@ -194,12 +194,13 @@
                 {
                     nameBasedMidlet.getWaitingView().showView();
                     nameBasedMidlet.getOrgUnitSelectView().setProgramType( "3" );
-                    nameBasedMidlet.getOrgUnitSelectView().setTargetScreen( nameBasedMidlet.PERSON_REGISTRATION_VIEW );
+                    nameBasedMidlet.getProgramSelectView().setTargetScreen( nameBasedMidlet.SINGLE_EVENT_WITHOUT_REGISTRATION );
                     nameBasedMidlet.getOrgUnitSelectView().showView();
                 }
                 else
                 {
                     nameBasedMidlet.getProgramSelectView().setPrograms( ProgramRecordStore.getProgramByType( 3 ) );
+                    nameBasedMidlet.getProgramSelectView().setTargetScreen( nameBasedMidlet.SINGLE_EVENT_WITHOUT_REGISTRATION );
                     nameBasedMidlet.getProgramSelectView().showView();
                 }
             }

=== modified file 'src/org/hisp/dhis/mobile/view/VisitScheduleListView.java'
--- src/org/hisp/dhis/mobile/view/VisitScheduleListView.java	2014-05-28 11:14:44 +0000
+++ src/org/hisp/dhis/mobile/view/VisitScheduleListView.java	2014-06-24 03:59:44 +0000
@@ -82,7 +82,7 @@
                         nameBasedMIDlet.getWaitingView().showView();
 
                         ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getFindPatientUrl() );
-                        ConnectionManager.getPatientById( id );
+                        ConnectionManager.getPatientById( id, nameBasedMIDlet.VISIT_SCHEDULE_VIEW, program );
 
                         visitScheduleListForm = null;
                         program = null;
@@ -130,25 +130,33 @@
         }
         else if ( ae.getCommand().getCommandName().equals( "Save All" ) )
         {
-            try
-            {
-                String ids = "";
-                for (int i=0; i<instanceInfos.size(); i++)
+            if ( instanceInfos.size() >= 50 )
+            {
+                nameBasedMIDlet.getAlertBoxView( "Please refine your search before saving data.", "Warning" )
+                    .showView();
+            }
+            else
+            {
+                try
                 {
-                    String instanceInfo = (String) instanceInfos.elementAt( i );
-                    if ( instanceInfo.indexOf( "/" ) > -1 )
+                    String ids = "";
+                    for ( int i = 0; i < instanceInfos.size(); i++ )
                     {
-                        ids += instanceInfo.substring( 0, instanceInfo.indexOf( "/" ) ) + "$";
+                        String instanceInfo = (String) instanceInfos.elementAt( i );
+                        if ( instanceInfo.indexOf( "/" ) > -1 )
+                        {
+                            ids += instanceInfo.substring( 0, instanceInfo.indexOf( "/" ) ) + "$";
+                        }
                     }
-                }
-                
-                ConnectionManager.setUrl( dhisMIDlet.getCurrentOrgUnit().getFindPatientsUrl() );
-                ConnectionManager.getPatientsById( ids );
-            }
-            catch ( Exception e )
-            {
-                LogMan.log( "UI," + CLASS_TAG, e );
-                e.printStackTrace();
+
+                    ConnectionManager.setUrl( dhisMIDlet.getCurrentOrgUnit().getFindPatientsUrl() );
+                    ConnectionManager.getPatientsById( ids );
+                }
+                catch ( Exception e )
+                {
+                    LogMan.log( "UI," + CLASS_TAG, e );
+                    e.printStackTrace();
+                }
             }
         }
     }