← Back to team overview

dhis-mobile-devs team mailing list archive

[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 151: fix bugs by editing patient object

 

------------------------------------------------------------
revno: 151
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: lwuit-tracking
timestamp: Mon 2013-09-23 14:58:49 +0700
message:
  fix bugs by editing patient object
modified:
  build.xml
  src/org/hisp/dhis/mobile/connection/ConnectionManager.java
  src/org/hisp/dhis/mobile/connection/task/GetAllAnonymousProgramTask.java
  src/org/hisp/dhis/mobile/connection/task/GetVariesInfoTask.java
  src/org/hisp/dhis/mobile/model/Patient.java
  src/org/hisp/dhis/mobile/recordstore/PatientRecordStore.java
  src/org/hisp/dhis/mobile/recordstore/filter/OfflinePatientFilter.java
  src/org/hisp/dhis/mobile/view/AnonymousOrgUnitSelectView.java
  src/org/hisp/dhis/mobile/view/OfflineView.java
  src/org/hisp/dhis/mobile/view/PersonDashboardView.java
  src/org/hisp/dhis/mobile/view/PersonListView.java
  src/org/hisp/dhis/mobile/view/PersonRegistrationOrgUnitSelectView.java
  src/org/hisp/dhis/mobile/view/PersonRegistrationView.java
  src/org/hisp/dhis/mobile/view/ProgramStageListView.java
  src/org/hisp/dhis/mobile/view/RegistrationProgramSelectionView.java
  src/org/hisp/dhis/mobile/view/SectionListView.java
  src/org/hisp/dhis/mobile/view/SettingView.java
  src/org/hisp/dhis/mobile/view/TrackingMainMenuView.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 'build.xml'
--- build.xml	2013-09-11 16:17:08 +0000
+++ build.xml	2013-09-23 07:58:49 +0000
@@ -34,11 +34,11 @@
 	<!-- Which logo to use -->
 	<property name="logo" value="dhis2_logo.png" />
 	<!-- Server URL -->
-	<property name="server.url" value="http://192.168.137.1:9999"; />
+	<property name="server.url" value="http://localhost:9999"; />
 	<!-- User Name -->
-	<property name="username" value="long" />
+	<property name="username" value="mobile" />
 	<!-- Password -->
-	<property name="password" value="District1" />
+	<property name="password" value="district" />
 	<!-- Server Phone Number -->
 	<property name="server.phonenumber" value="+8494485878" />
 	<!-- Default Locale -->

=== modified file 'src/org/hisp/dhis/mobile/connection/ConnectionManager.java'
--- src/org/hisp/dhis/mobile/connection/ConnectionManager.java	2013-09-10 16:25:58 +0000
+++ src/org/hisp/dhis/mobile/connection/ConnectionManager.java	2013-09-23 07:58:49 +0000
@@ -50,8 +50,6 @@
 import org.hisp.dhis.mobile.model.ProgramStage;
 import org.hisp.dhis.mobile.model.Relationship;
 import org.hisp.dhis.mobile.model.Section;
-import org.hisp.dhis.mobile.recordstore.OrgUnitRecordStore;
-import org.hisp.dhis.mobile.recordstore.ProgramRecordStore;
 
 public class ConnectionManager
 
@@ -202,9 +200,9 @@
         runTask( updateContactTask );
     }
 
-    public static void getAllAnonymousProgram()
+    public static void getAllAnonymousProgram( String programType )
     {
-        GetAllAnonymousProgramTask getAllAnonymousProgramTask = new GetAllAnonymousProgramTask();
+        GetAllAnonymousProgramTask getAllAnonymousProgramTask = new GetAllAnonymousProgramTask( programType );
         runTask( getAllAnonymousProgramTask );
     }
 

=== modified file 'src/org/hisp/dhis/mobile/connection/task/GetAllAnonymousProgramTask.java'
--- src/org/hisp/dhis/mobile/connection/task/GetAllAnonymousProgramTask.java	2013-06-20 08:18:17 +0000
+++ src/org/hisp/dhis/mobile/connection/task/GetAllAnonymousProgramTask.java	2013-09-23 07:58:49 +0000
@@ -35,7 +35,6 @@
 import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
 import org.hisp.dhis.mobile.model.Program;
 import org.hisp.dhis.mobile.model.ProgramStage;
-import org.hisp.dhis.mobile.ui.Text;
 
 /**
  * @author Nguyen Kim Lai
@@ -45,27 +44,50 @@
 public class GetAllAnonymousProgramTask
     extends AbstractTask
 {
+    String programType;
+    
     NameBasedMIDlet nameBasedMIDlet;
 
+    public GetAllAnonymousProgramTask( String programType )
+    {
+        super();
+        this.programType = programType;
+    }
+
     public void run()
     {
         this.nameBasedMIDlet = (NameBasedMIDlet) ConnectionManager.getDhisMIDlet();
         DataInputStream dataInputStream = null;
         try
         {
-            dataInputStream = this.download( "useless-part", "useless-part" );
-
-            Program anonymousProgram = new Program();
-            anonymousProgram.deSerialize( dataInputStream );
-            ProgramStage programStage = (ProgramStage) anonymousProgram.getProgramStages().elementAt( 0 );
+            dataInputStream = this.download( programType, "programType" );
+            Program program = new Program();
+            program.deSerialize( dataInputStream );
             
-            nameBasedMIDlet.getTrackingDataEntryView().setProgramStage( programStage );
-            nameBasedMIDlet.getTrackingDataEntryView().setTitle( anonymousProgram.getName() );
-            nameBasedMIDlet.getTrackingDataEntryView().showView();
+            // Anonymous is 3
+            if ( programType.equals( "3" ) )
+            {
+                ProgramStage programStage = (ProgramStage) program.getProgramStages().elementAt( 0 );
+                
+                nameBasedMIDlet.getTrackingDataEntryView().setProgramStage( programStage );
+                nameBasedMIDlet.getTrackingDataEntryView().setTitle( program.getName() );
+                nameBasedMIDlet.getTrackingDataEntryView().showView();
+                programStage = null;
+            }
+            // Multiple events with registration is 1
+            else
+            {
+                Vector programInfos = new Vector();
+                programInfos.addElement( program.getId()+"/"+program.getName() );
+                nameBasedMIDlet.getRegistrationProgramSelectionView().prepareView();
+                nameBasedMIDlet.getRegistrationProgramSelectionView().setProgramInfos( programInfos );
+                nameBasedMIDlet.getRegistrationProgramSelectionView().getMainForm().show();
+                programInfos = null;
+            }
             
             dataInputStream = null;
-            anonymousProgram = null;
-            programStage = null;
+            programType = null;
+            program = null;
             System.gc();
         }
         catch ( IOException e )
@@ -78,23 +100,39 @@
             
             if ( message.equalsIgnoreCase( "NO_PROGRAM_FOUND" ) )
             {
-                nameBasedMIDlet.getAlertBoxView( "No anonymous program found on server", "Opps" ).showView();
+                nameBasedMIDlet.getAlertBoxView( "No program found for "+nameBasedMIDlet.getCurrentOrgUnit().getName(), "Opps" ).showView();
                 nameBasedMIDlet.getAnonymousOrgUnitSelectView().showView();
             }
             else
             {
-                Vector anonymousProgramInfos = new Vector();
+                Vector programInfos = new Vector();
                 while ( message.length() > 0 )
                 {
-                    anonymousProgramInfos.addElement( message.substring( 0, message.indexOf( "$" ) ) );
+                    programInfos.addElement( message.substring( 0, message.indexOf( "$" ) ) );
                     message = message.substring( message.indexOf( "$" ) + 1, message.length() );
                 }
+                
+                // Anonymous is 3
+                if ( programType.equals( "3" ) )
+                {
+                    nameBasedMIDlet.getAnonymousProgramListView().setAnonymousProgramInfos( programInfos );
+                    nameBasedMIDlet.getAnonymousProgramListView().showView();
+                }
+                // Multiple events with registration is 1
+                else
+                {
+                    nameBasedMIDlet.getRegistrationProgramSelectionView().setProgramInfos( programInfos );
+                    nameBasedMIDlet.getRegistrationProgramSelectionView().showView();
+                }
+                
                 message = null;
-                nameBasedMIDlet.getAnonymousProgramListView().setAnonymousProgramInfos( anonymousProgramInfos );
-                nameBasedMIDlet.getAnonymousProgramListView().showView();
+                programInfos = null;
             }
+            programType = null;
+            nameBasedMIDlet = null;
+            System.gc();
         }
-
     }
-
+    
+    
 }

=== modified file 'src/org/hisp/dhis/mobile/connection/task/GetVariesInfoTask.java'
--- src/org/hisp/dhis/mobile/connection/task/GetVariesInfoTask.java	2013-09-10 16:25:58 +0000
+++ src/org/hisp/dhis/mobile/connection/task/GetVariesInfoTask.java	2013-09-23 07:58:49 +0000
@@ -3,10 +3,6 @@
 import java.io.DataInputStream;
 import java.util.Vector;
 
-import javax.microedition.rms.RecordStoreException;
-import javax.microedition.rms.RecordStoreFullException;
-import javax.microedition.rms.RecordStoreNotFoundException;
-
 import org.hisp.dhis.mobile.connection.ConnectionManager;
 import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
 import org.hisp.dhis.mobile.model.PatientIdentifierAndAttribute;

=== modified file 'src/org/hisp/dhis/mobile/model/Patient.java'
--- src/org/hisp/dhis/mobile/model/Patient.java	2013-09-18 09:05:12 +0000
+++ src/org/hisp/dhis/mobile/model/Patient.java	2013-09-23 07:58:49 +0000
@@ -35,7 +35,7 @@
 {
     private int id;
 
-    private String firstName, middleName, lastName;
+    private String name;
 
     private int age;
 
@@ -69,6 +69,16 @@
     {
     }
 
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
     public String getGender()
     {
         return gender;
@@ -109,32 +119,6 @@
         this.dobType = dobType;
     }
 
-    public String getFullName()
-    {
-        boolean space = false;
-        String name = "";
-
-        if ( firstName != null && firstName.length() != 0 )
-        {
-            name = firstName;
-            space = true;
-        }
-        if ( middleName != null && middleName.length() != 0 )
-        {
-            if ( space )
-                name += " ";
-            name += middleName;
-            space = true;
-        }
-        if ( lastName != null && lastName.length() != 0 )
-        {
-            if ( space )
-                name += " ";
-            name += lastName;
-        }
-        return name;
-    }
-
     public int getId()
     {
         return id;
@@ -155,36 +139,6 @@
         this.age = age;
     }
 
-    public String getFirstName()
-    {
-        return firstName;
-    }
-
-    public void setFirstName( String firstName )
-    {
-        this.firstName = firstName;
-    }
-
-    public String getMiddleName()
-    {
-        return middleName;
-    }
-
-    public void setMiddleName( String middleName )
-    {
-        this.middleName = middleName;
-    }
-
-    public String getLastName()
-    {
-        return lastName;
-    }
-
-    public void setLastName( String lastName )
-    {
-        this.lastName = lastName;
-    }
-
     public Vector getPatientAttValues()
     {
         return patientAttValues;
@@ -287,10 +241,15 @@
         throws IOException
     {
         this.setId( din.readInt() );
-        this.setFirstName( din.readUTF() );
-        this.setMiddleName( din.readUTF() );
-        this.setLastName( din.readUTF() );
-
+        
+        if ( din.readBoolean() )
+        {
+            this.setName( din.readUTF() );
+        }
+        else
+        {
+            this.setName( null );
+        }
         if ( din.readBoolean() )
         {
             this.setOrganisationUnitName( din.readUTF() );
@@ -484,10 +443,16 @@
         throws IOException
     {
         dout.writeInt( this.getId() );
-        dout.writeUTF( this.getFirstName() );
-        dout.writeUTF( this.getMiddleName() );
-        dout.writeUTF( this.getLastName() );
-
+        
+        if ( name != null )
+        {
+            dout.writeBoolean( true );
+            dout.writeUTF( this.getName() );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
         if ( organisationUnitName != null )
         {
             dout.writeBoolean( true );

=== modified file 'src/org/hisp/dhis/mobile/recordstore/PatientRecordStore.java'
--- src/org/hisp/dhis/mobile/recordstore/PatientRecordStore.java	2013-09-11 15:25:01 +0000
+++ src/org/hisp/dhis/mobile/recordstore/PatientRecordStore.java	2013-09-23 07:58:49 +0000
@@ -39,7 +39,6 @@
 import org.hisp.dhis.mobile.model.ModelList;
 import org.hisp.dhis.mobile.model.Patient;
 import org.hisp.dhis.mobile.recordstore.filter.PatientFilter;
-import org.hisp.dhis.mobile.util.PeriodUtil;
 import org.hisp.dhis.mobile.util.SerializationUtil;
 
 /**
@@ -146,7 +145,7 @@
                 //String t = PeriodUtil.dateToString( patient.getBirthDate(), y, m, d );
                 
                 model.setId( patient.getId() );
-                model.setName( patient.getFullName()+"/"+patient.getBirthDate() );
+                model.setName( patient.getName()+"/"+patient.getBirthDate() );
                 modelList.getModels().addElement( model );
                 patient = null;
                 model = null;

=== modified file 'src/org/hisp/dhis/mobile/recordstore/filter/OfflinePatientFilter.java'
--- src/org/hisp/dhis/mobile/recordstore/filter/OfflinePatientFilter.java	2013-08-23 06:43:42 +0000
+++ src/org/hisp/dhis/mobile/recordstore/filter/OfflinePatientFilter.java	2013-09-23 07:58:49 +0000
@@ -28,7 +28,7 @@
             {
                 Patient suspectPatient = new Patient();
                 SerializationUtil.deSerialize( suspectPatient, suspect );
-                return patient.getFullName() == suspectPatient.getFullName();
+                return patient.getName() == suspectPatient.getName();
 
             }
             catch ( Exception e )

=== modified file 'src/org/hisp/dhis/mobile/view/AnonymousOrgUnitSelectView.java'
--- src/org/hisp/dhis/mobile/view/AnonymousOrgUnitSelectView.java	2013-04-24 04:25:42 +0000
+++ src/org/hisp/dhis/mobile/view/AnonymousOrgUnitSelectView.java	2013-09-23 07:58:49 +0000
@@ -146,7 +146,7 @@
             
             ConnectionManager.setUrl( nameBasedMidlet.getCurrentOrgUnit().getDownloadAnonymousProgramUrl() );
             
-            ConnectionManager.getAllAnonymousProgram();
+            ConnectionManager.getAllAnonymousProgram("3");
         }
         else if ( ae.getCommand().getCommandName().equals( "Back" ) )
         {

=== modified file 'src/org/hisp/dhis/mobile/view/OfflineView.java'
--- src/org/hisp/dhis/mobile/view/OfflineView.java	2013-09-06 13:27:45 +0000
+++ src/org/hisp/dhis/mobile/view/OfflineView.java	2013-09-23 07:58:49 +0000
@@ -46,7 +46,7 @@
             for ( int i = 0; i < offlinePatientVector.size(); i++ )
             {
                 Patient patient = (Patient) offlinePatientVector.elementAt( i );
-                this.patientLabel = new Label( patient.getFullName() + " (" + patient.getPhoneNumber() + ")" );
+                this.patientLabel = new Label( patient.getName() + " (" + patient.getPhoneNumber() + ")" );
                 offlineForm.addComponent( patientLabel );
 
             }

=== modified file 'src/org/hisp/dhis/mobile/view/PersonDashboardView.java'
--- src/org/hisp/dhis/mobile/view/PersonDashboardView.java	2013-09-18 09:05:12 +0000
+++ src/org/hisp/dhis/mobile/view/PersonDashboardView.java	2013-09-23 07:58:49 +0000
@@ -219,7 +219,7 @@
     {
         if ( mainForm == null )
         {
-            mainForm = new Form( patient.getFullName() );
+            mainForm = new Form( patient.getName() );
             mainForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
             mainForm.setScrollableY( true );
             mainForm.setTransitionOutAnimator( CommonTransitions.createSlide( CommonTransitions.SLIDE_HORIZONTAL, true,
@@ -424,7 +424,7 @@
 
                     public void actionPerformed( ActionEvent ae )
                     {
-                        enrollmentRelationship.setPersonAName( patient.getFullName() );
+                        enrollmentRelationship.setPersonAName( patient.getName() );
                         enrollmentRelationship.setPersonAId( patient.getId() );
                         namebasedMidlet.getAddingRelationshipView().setEnrollmentRelationship( enrollmentRelationship );
                         namebasedMidlet.getAddingRelationshipView().showView();

=== modified file 'src/org/hisp/dhis/mobile/view/PersonListView.java'
--- src/org/hisp/dhis/mobile/view/PersonListView.java	2013-09-12 13:27:11 +0000
+++ src/org/hisp/dhis/mobile/view/PersonListView.java	2013-09-23 07:58:49 +0000
@@ -37,7 +37,6 @@
 
 import com.sun.lwuit.Command;
 import com.sun.lwuit.Form;
-import com.sun.lwuit.TextArea;
 import com.sun.lwuit.animations.CommonTransitions;
 import com.sun.lwuit.events.ActionEvent;
 import com.sun.lwuit.events.ActionListener;
@@ -71,11 +70,9 @@
     public void prepareView()
     {
         System.gc();
-        this.getMainForm();
+        getMainForm();
         mainForm.removeAll();
-        TextArea txtHint = new TextArea( "Select person below: " );
-        txtHint.setEditable( false );
-        mainForm.addComponent( txtHint );
+
         for ( int i = 0; i < patientInfos.size(); i++ )
         {
             String patientInfo = (String) patientInfos.elementAt( i );
@@ -147,7 +144,7 @@
     {
         if ( mainForm == null )
         {
-            mainForm = new Form( "Person List" );
+            mainForm = new Form( "Select Person" );
             mainForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
             mainForm.setTransitionOutAnimator( CommonTransitions.createSlide( CommonTransitions.SLIDE_HORIZONTAL, true,
                 200 ) );

=== modified file 'src/org/hisp/dhis/mobile/view/PersonRegistrationOrgUnitSelectView.java'
--- src/org/hisp/dhis/mobile/view/PersonRegistrationOrgUnitSelectView.java	2013-09-10 16:25:58 +0000
+++ src/org/hisp/dhis/mobile/view/PersonRegistrationOrgUnitSelectView.java	2013-09-23 07:58:49 +0000
@@ -2,12 +2,11 @@
 
 import java.util.Vector;
 
+import org.hisp.dhis.mobile.connection.ConnectionManager;
 import org.hisp.dhis.mobile.midlet.DHISMIDlet;
 import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
 import org.hisp.dhis.mobile.model.OrgUnit;
 import org.hisp.dhis.mobile.recordstore.OrgUnitRecordStore;
-import org.hisp.dhis.mobile.recordstore.PatientAttributeRecordStore;
-import org.hisp.dhis.mobile.recordstore.PatientIdentifierRecordStore;
 
 import com.sun.lwuit.Command;
 import com.sun.lwuit.Form;
@@ -23,7 +22,7 @@
 {
     private Vector orgUnitVector;
 
-    private Form orgUnitForm;
+    private Form mainForm;
 
     private List orgUnitSelectList;
 
@@ -41,23 +40,22 @@
 
     public void prepareView()
     {
-        getOrgUnitForm();
-
+        getMainForm();
     }
 
-    public Form getOrgUnitForm()
+    public Form getMainForm()
     {
-        if ( orgUnitForm == null )
+        if ( mainForm == null )
         {
-            orgUnitForm = new Form( "Select Org Unit" );
-            orgUnitForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
-            orgUnitForm.setTransitionOutAnimator( CommonTransitions.createSlide( CommonTransitions.SLIDE_HORIZONTAL,
+            mainForm = new Form( "Select Org Unit" );
+            mainForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
+            mainForm.setTransitionOutAnimator( CommonTransitions.createSlide( CommonTransitions.SLIDE_HORIZONTAL,
                 true, 200 ) );
-            orgUnitForm.addCommandListener( this );
-            orgUnitForm.addComponent( this.getOrgUnitSelectList() );
-            orgUnitForm.addCommand( new Command( "Back" ) );
+            mainForm.addCommandListener( this );
+            mainForm.addComponent( this.getOrgUnitSelectList() );
+            mainForm.addCommand( new Command( "Back" ) );
         }
-        return orgUnitForm;
+        return mainForm;
 
     }
 
@@ -89,7 +87,7 @@
     public void showView()
     {
         this.prepareView();
-        this.getOrgUnitForm().show();
+        this.getMainForm().show();
     }
 
     public Vector getOrgUnitVector()
@@ -102,9 +100,9 @@
         this.orgUnitVector = orgUnitVector;
     }
 
-    public void setOrgUnitForm( Form orgUnitForm )
+    public void setMainForm( Form mainForm )
     {
-        this.orgUnitForm = orgUnitForm;
+        this.mainForm = mainForm;
     }
 
     public void setOrgUnitSelectList( List orgUnitSelectList )
@@ -136,30 +134,20 @@
     {
         try
         {
-            this.patientIdentifierValueVector = PatientIdentifierRecordStore.loadPatientIdentifiers();
-            this.patientAttributeValueVector = PatientAttributeRecordStore.loadPatientAttribute();
-            int pIdSize = this.patientIdentifierValueVector.size();
-            int pAtSize = this.patientAttributeValueVector.size();
             if ( ae.getSource() == this.getOrgUnitSelectList() )
             {
+                nameBasedMidlet.getWaitingView().showView();
+                
                 dhisMIDlet.setCurrentOrgUnit( ((OrgUnit) getOrgUnitVector().elementAt(
                     getOrgUnitSelectList().getSelectedIndex() )) );
-                // if ( pIdSize == 0 && pAtSize == 0 )
-                // {
-                // ConnectionManager.setUrl(
-                // nameBasedMidlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
-                // ConnectionManager.getVariesInfo();
-                // }
-                // else
-                // {
-                // ConnectionManager.setUrl(
-                // nameBasedMidlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
-                // }
-                nameBasedMidlet.getRegistrationProgramSelectionView().showView();
+                
+                ConnectionManager.setUrl( nameBasedMidlet.getCurrentOrgUnit().getDownloadAnonymousProgramUrl() );
+                
+                ConnectionManager.getAllAnonymousProgram("1");
             }
             else if ( ae.getCommand().getCommandName().equals( "Back" ) )
             {
-                orgUnitForm = null;
+                mainForm = null;
                 orgUnitVector = null;
                 orgUnitSelectList = null;
 

=== modified file 'src/org/hisp/dhis/mobile/view/PersonRegistrationView.java'
--- src/org/hisp/dhis/mobile/view/PersonRegistrationView.java	2013-09-12 13:27:11 +0000
+++ src/org/hisp/dhis/mobile/view/PersonRegistrationView.java	2013-09-23 07:58:49 +0000
@@ -833,9 +833,7 @@
         Vector attributeVector = new Vector();
         Vector identiferVector = new Vector();
 
-        patient.setFirstName( fullName );
-        patient.setMiddleName( "" );
-        patient.setLastName( "" );
+        patient.setName( fullName );
         patient.setGender( genderChar );
         patient.setDobType( dateOfBirthType );
         patient.setPhoneNumber( phoneNumber );

=== modified file 'src/org/hisp/dhis/mobile/view/ProgramStageListView.java'
--- src/org/hisp/dhis/mobile/view/ProgramStageListView.java	2013-09-10 07:17:17 +0000
+++ src/org/hisp/dhis/mobile/view/ProgramStageListView.java	2013-09-23 07:58:49 +0000
@@ -134,7 +134,7 @@
     {
         if ( personProgramStageListForm == null )
         {
-            personProgramStageListForm = new Form( patient.getFullName() );
+            personProgramStageListForm = new Form( patient.getName() );
             personProgramStageListForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
             personProgramStageListForm.setScrollableY( true );
             personProgramStageListForm.setTransitionOutAnimator( CommonTransitions.createSlide(

=== modified file 'src/org/hisp/dhis/mobile/view/RegistrationProgramSelectionView.java'
--- src/org/hisp/dhis/mobile/view/RegistrationProgramSelectionView.java	2013-09-10 16:25:58 +0000
+++ src/org/hisp/dhis/mobile/view/RegistrationProgramSelectionView.java	2013-09-23 07:58:49 +0000
@@ -5,18 +5,13 @@
 import org.hisp.dhis.mobile.connection.ConnectionManager;
 import org.hisp.dhis.mobile.midlet.DHISMIDlet;
 import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
-import org.hisp.dhis.mobile.model.OrgUnit;
-import org.hisp.dhis.mobile.model.Program;
-import org.hisp.dhis.mobile.model.ProgramStage;
-import org.hisp.dhis.mobile.recordstore.OrgUnitRecordStore;
+import org.hisp.dhis.mobile.model.LinkButton;
 import org.hisp.dhis.mobile.recordstore.PatientAttributeRecordStore;
 import org.hisp.dhis.mobile.recordstore.PatientIdentifierRecordStore;
-import org.hisp.dhis.mobile.recordstore.ProgramRecordStore;
 import org.hisp.dhis.mobile.ui.Text;
 
 import com.sun.lwuit.Command;
 import com.sun.lwuit.Form;
-import com.sun.lwuit.List;
 import com.sun.lwuit.animations.CommonTransitions;
 import com.sun.lwuit.events.ActionEvent;
 import com.sun.lwuit.events.ActionListener;
@@ -26,17 +21,14 @@
     extends AbstractView
     implements ActionListener
 {
-
-    private Form registrationProgramSelectionForm;
-
-    private List programList;
+    private Form mainForm;
+    
+    private Vector programInfos;
 
     private Command backCommand;
 
     private NameBasedMIDlet nameBasedMIDlet;
 
-    private Vector programVector;
-
     public RegistrationProgramSelectionView( DHISMIDlet dhisMIDlet )
     {
         super( dhisMIDlet );
@@ -45,101 +37,59 @@
 
     public void actionPerformed( ActionEvent ae )
     {
-        if ( ae.getSource() == this.getProgramList() )
-        {
-            Program selectedProgram = (Program) programVector.elementAt( this.getProgramList().getSelectedIndex() );
-            nameBasedMIDlet.getPersonRegistrationView().setEnrollProgramId( String.valueOf( ((Program) programVector.elementAt( this.getProgramList().getSelectedIndex() )).getId() ) );
-            try
-            {
-                Vector orgUnitVector = OrgUnitRecordStore.loadAllOrgUnit();
-
-                dhisMIDlet.setCurrentOrgUnit( ((OrgUnit) orgUnitVector.elementAt( 0 )) );
-                if ( PatientIdentifierRecordStore.loadPatientIdentifiers().size() == 0
-                    && PatientAttributeRecordStore.loadPatientAttribute().size() == 0 )
-                {
-                    ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
-                    ConnectionManager.getVariesInfo( String.valueOf( selectedProgram.getId() ) );
-                }
-                else
-                {
-                    ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
-                    nameBasedMIDlet.getPersonRegistrationView().prepareView();
-                    nameBasedMIDlet.getPersonRegistrationView().showView();
-                }
-
-            }
-            catch ( Exception e )
-            {
-                e.printStackTrace();
-            }
-        }
-        else
-        {
-            nameBasedMIDlet.getTrackingMainMenuView().showView();
+        if ( ae.getCommand().getCommandName().equals( Text.BACK() ) )
+        {
+            nameBasedMIDlet.getPersonRegistrationOrgUnitSelectView().showView();
         }
     }
 
     public void prepareView()
     {
-        // programList = null;
-        // try
-        // {
-        // programVector = ProgramRecordStore.getAllProgram();
-        // }
-        // catch ( Exception e )
-        // {
-        // e.printStackTrace();
-        // }
-        //
-        // for ( int i = 0; i < programVector.size(); i++ )
-        // {
-        // Program program = (Program) programVector.elementAt( i );
-        // ProgramStage firstStage = (ProgramStage)
-        // program.getProgramStages().elementAt( 0 );
-        //
-        // if ( !firstStage.isSingleEvent() )
-        // {
-        // this.getProgramList().addItem( program.getName() );
-        // }
-        // }
+        System.gc();
+        getMainForm();
+        mainForm.removeAll();
+        
+        for ( int i = 0; i < programInfos.size(); i++ )
+        {
+            String patientInfo = (String) programInfos.elementAt( i );
+
+            final String id = patientInfo.substring( 0, patientInfo.indexOf( "/" ) );
+            String programName = patientInfo.substring( patientInfo.indexOf( "/" ) + 1, patientInfo.length() );
+            
+            LinkButton personLink = new LinkButton( programName );
+            personLink.addActionListener( new ActionListener()
+            {
+                public void actionPerformed( ActionEvent ae )
+                {
+                    nameBasedMIDlet.getWaitingView().showView();
+                    try
+                    {
+                        if ( PatientIdentifierRecordStore.loadPatientIdentifiers().size() == 0
+                            && PatientAttributeRecordStore.loadPatientAttribute().size() == 0 )
+                        {
+                            ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
+                            ConnectionManager.getVariesInfo( String.valueOf( id ) );
+                        }
+                        else
+                        {
+                            ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
+                            nameBasedMIDlet.getPersonRegistrationView().prepareView();
+                            nameBasedMIDlet.getPersonRegistrationView().showView();
+                        }
+                    }
+                    catch ( Exception e )
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
+        }
     }
 
     public void showView()
     {
-        this.getRegistrationProgramSelectionForm().show();
-
-    }
-
-    public List getProgramList()
-    {
-        if ( programList == null )
-        {
-            programList = new List();
-            programList.setSmoothScrolling( true );
-            programList.setFixedSelection( List.FIXED_NONE );
-            programList.addActionListener( this );
-
-            try
-            {
-                programVector = ProgramRecordStore.getAllProgram();
-            }
-            catch ( Exception e )
-            {
-                e.printStackTrace();
-            }
-
-            for ( int i = 0; i < programVector.size(); i++ )
-            {
-                Program program = (Program) programVector.elementAt( i );
-                ProgramStage firstStage = (ProgramStage) program.getProgramStages().elementAt( 0 );
-
-                if ( !firstStage.isSingleEvent() )
-                {
-                    this.getProgramList().addItem( program.getName() );
-                }
-            }
-        }
-        return programList;
+        prepareView();
+        mainForm.show();
     }
 
     public Command getBackCommand()
@@ -151,24 +101,32 @@
         return backCommand;
     }
 
-    public Form getRegistrationProgramSelectionForm()
+    public Form getMainForm()
     {
-        if ( registrationProgramSelectionForm == null )
+        if ( mainForm == null )
         {
-            registrationProgramSelectionForm = new Form( "Select Program" );
-            registrationProgramSelectionForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
-            registrationProgramSelectionForm.setTransitionOutAnimator( CommonTransitions.createSlide(
+            mainForm = new Form( "Select Program" );
+            mainForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
+            mainForm.setTransitionOutAnimator( CommonTransitions.createSlide(
                 CommonTransitions.SLIDE_HORIZONTAL, true, 200 ) );
-            registrationProgramSelectionForm.addCommandListener( this );
-            registrationProgramSelectionForm.addComponent( this.getProgramList() );
-            registrationProgramSelectionForm.addCommand( new Command( "Back" ) );
+            mainForm.addCommandListener( this );
+            mainForm.addCommand( new Command( "Back" ) );
         }
-        return registrationProgramSelectionForm;
-    }
-
-    public void setRegistrationProgramSelectionForm( Form registrationProgramSelectionForm )
-    {
-        this.registrationProgramSelectionForm = registrationProgramSelectionForm;
-    }
-
+        return mainForm;
+    }
+
+    public void setMainForm( Form mainForm )
+    {
+        this.mainForm = mainForm;
+    }
+
+    public Vector getProgramInfos()
+    {
+        return programInfos;
+    }
+
+    public void setProgramInfos( Vector programInfos )
+    {
+        this.programInfos = programInfos;
+    }
 }

=== modified file 'src/org/hisp/dhis/mobile/view/SectionListView.java'
--- src/org/hisp/dhis/mobile/view/SectionListView.java	2013-04-18 04:04:51 +0000
+++ src/org/hisp/dhis/mobile/view/SectionListView.java	2013-09-23 07:58:49 +0000
@@ -156,7 +156,7 @@
     {
         if ( sectionListForm == null )
         {
-            sectionListForm = new Form( patient.getFullName() );
+            sectionListForm = new Form( patient.getName() );
             sectionListForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
             sectionListForm.setScrollableY( true );
             sectionListForm.setTransitionOutAnimator( CommonTransitions.createSlide(

=== modified file 'src/org/hisp/dhis/mobile/view/SettingView.java'
--- src/org/hisp/dhis/mobile/view/SettingView.java	2013-04-05 07:53:02 +0000
+++ src/org/hisp/dhis/mobile/view/SettingView.java	2013-09-23 07:58:49 +0000
@@ -20,6 +20,7 @@
  */
 
 import java.util.Vector;
+
 import javax.microedition.lcdui.ChoiceGroup;
 import javax.microedition.lcdui.Command;
 import javax.microedition.lcdui.CommandListener;
@@ -28,6 +29,7 @@
 import javax.microedition.lcdui.Item;
 import javax.microedition.lcdui.TextField;
 import javax.microedition.rms.RecordStoreException;
+
 import org.hisp.dhis.mobile.connection.ConnectionManager;
 import org.hisp.dhis.mobile.midlet.DHISMIDlet;
 import org.hisp.dhis.mobile.midlet.FacilityMIDlet;

=== modified file 'src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java'
--- src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java	2013-09-12 13:27:11 +0000
+++ src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java	2013-09-23 07:58:49 +0000
@@ -19,9 +19,18 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.io.IOException;
+
+import javax.microedition.rms.RecordStoreException;
+import javax.microedition.rms.RecordStoreFullException;
+import javax.microedition.rms.RecordStoreNotFoundException;
+
+import org.hisp.dhis.mobile.connection.ConnectionManager;
 import org.hisp.dhis.mobile.midlet.DHISMIDlet;
 import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
 import org.hisp.dhis.mobile.model.ModelList;
+import org.hisp.dhis.mobile.model.OrgUnit;
+import org.hisp.dhis.mobile.recordstore.OrgUnitRecordStore;
 import org.hisp.dhis.mobile.recordstore.PatientRecordStore;
 import org.hisp.dhis.mobile.ui.Text;
 
@@ -90,69 +99,60 @@
     }
 
     private void navigate( String nextPageName )
+    {
+        try
+        {
+            ConnectionManager.setOrgUnit( (OrgUnit) OrgUnitRecordStore.loadAllOrgUnit().elementAt( 0 ) );
 
-    {
-        if ( nextPageName.equals( "Find Person" ) )
-        {
-            nameBasedMidlet.getFindBeneficiaryView().showView();
-        }
-        if ( nextPageName.equals( "Add Person" ) )
-        {
-//            try
-//            {
-//                Vector orgUnitVector = OrgUnitRecordStore.loadAllOrgUnit();
-//                if ( orgUnitVector.size() > 1 )
-//                {
-//                    nameBasedMidlet.getWaitingView().showView();
-//                    nameBasedMidlet.getPersonRegistrationOrgUnitSelectView().showView();
-//                }
-//                else
-//                {
-//                    dhisMIDlet.setCurrentOrgUnit( ((OrgUnit) orgUnitVector.elementAt( 0 )) );
-//                    if ( PatientIdentifierRecordStore.loadPatientIdentifiers().size() == 0
-//                        && PatientAttributeRecordStore.loadPatientAttribute().size() == 0 )
-//                    {
-//                        ConnectionManager.setUrl( nameBasedMidlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
-//                        ConnectionManager.getVariesInfo();
-//                    }
-//                    else
-//                    {
-//                        ConnectionManager.setUrl( nameBasedMidlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
-//                    }
-//                }
-//            }
-//            catch ( Exception e )
-//            {
-//                e.printStackTrace();
-//            }
-            nameBasedMidlet.getRegistrationProgramSelectionView().prepareView();
-            nameBasedMidlet.getRegistrationProgramSelectionView().showView();
-        }
-        if ( nextPageName.equals( "Anonymous" ) )
-        {
-            nameBasedMidlet.getWaitingView().showView();
-            nameBasedMidlet.getAnonymousOrgUnitSelectView().showView();
-        }
-        if ( nextPageName.equals( "History" ) )
-        {
-            try
+            if ( nextPageName.equals( "Find Person" ) )
+            {
+                nameBasedMidlet.getFindBeneficiaryView().showView();
+            }
+            if ( nextPageName.equals( "Add Person" ) )
+            {
+                if ( OrgUnitRecordStore.loadAllOrgUnit().size() > 1 )
+                {
+                    nameBasedMidlet.getWaitingView().showView();
+                    nameBasedMidlet.getPersonRegistrationOrgUnitSelectView().showView();
+                }
+                else
+                {
+                    ConnectionManager.setUrl( nameBasedMidlet.getCurrentOrgUnit().getDownloadAnonymousProgramUrl() );
+                    ConnectionManager.getAllAnonymousProgram( "1" );
+                }
+            }
+            if ( nextPageName.equals( "Anonymous" ) )
+            {
+                if ( OrgUnitRecordStore.loadAllOrgUnit().size() > 1 )
+                {
+                    nameBasedMidlet.getWaitingView().showView();
+                    nameBasedMidlet.getAnonymousOrgUnitSelectView().showView();
+                }
+                else
+                {
+                    ConnectionManager.setUrl( nameBasedMidlet.getCurrentOrgUnit().getDownloadAnonymousProgramUrl() );
+                    ConnectionManager.getAllAnonymousProgram( "3" );
+                }
+            }
+            if ( nextPageName.equals( "History" ) )
             {
                 ModelList modelList = PatientRecordStore.getCurrentPatients();
                 nameBasedMidlet.getHistoryPersonListView().setModelList( modelList );
                 nameBasedMidlet.getHistoryPersonListView().showView();
+
             }
-            catch ( Exception e )
+            if ( nextPageName.equals( "Offline" ) )
             {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
+                nameBasedMidlet.getWaitingView().showView();
+                nameBasedMidlet.getOfflineOrgUnitSelectView().showView();
             }
         }
-        if ( nextPageName.equals( "Offline" ) )
+
+        catch ( Exception e )
         {
-            nameBasedMidlet.getWaitingView().showView();
-            nameBasedMidlet.getOfflineOrgUnitSelectView().showView();
+            // TODO Auto-generated catch block
+            e.printStackTrace();
         }
-
     }
 
     public List getMenuList()