← Back to team overview

dhis-mobile-devs team mailing list archive

[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 214: https://blueprints.launchpad.net/dhis-mobile/+spec/enhance-tracker-client

 

------------------------------------------------------------
revno: 214
committer: sherylyn.marie
branch nick: lwuit-tracking
timestamp: Fri 2014-05-09 17:04:54 +0800
message:
  https://blueprints.launchpad.net/dhis-mobile/+spec/enhance-tracker-client
  #1 ALL TRACKED ENTITY SUPPORT
  History Screen
modified:
  src/org/hisp/dhis/mobile/model/Patient.java
  src/org/hisp/dhis/mobile/recordstore/PatientRecordStore.java
  src/org/hisp/dhis/mobile/view/HistoryPersonListView.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/model/Patient.java'
--- src/org/hisp/dhis/mobile/model/Patient.java	2014-02-07 11:02:56 +0000
+++ src/org/hisp/dhis/mobile/model/Patient.java	2014-05-09 09:04:54 +0000
@@ -35,6 +35,8 @@
     private int id;
 
     private String organisationUnitName;
+    
+    private String trackedEntityName;
 
     private Vector patientAttributes = new Vector();
 
@@ -97,6 +99,16 @@
     {
         this.organisationUnitName = organisationUnitName;
     }
+    
+    public String getTrackedEntityName()
+    {
+    	return trackedEntityName;
+    }
+    
+    public void setTrackedEntityName( String trackedEntityName )
+    {
+    	this.trackedEntityName = trackedEntityName;
+    }
 
     public Vector getCompletedPrograms()
     {
@@ -113,6 +125,7 @@
     {
         this.setId( din.readInt() );
         this.setOrganisationUnitName( din.readUTF() );
+        this.setTrackedEntityName( din.readUTF() );
 
         // Read attributes
         int attsNumb = din.readInt();
@@ -178,6 +191,7 @@
     {
         dout.writeInt( this.getId() );
         dout.writeUTF( this.getOrganisationUnitName() );
+        dout.writeUTF( this.getTrackedEntityName() );
 
         // Write Attribute
         dout.writeInt( patientAttributes.size() );

=== modified file 'src/org/hisp/dhis/mobile/recordstore/PatientRecordStore.java'
--- src/org/hisp/dhis/mobile/recordstore/PatientRecordStore.java	2014-02-07 11:02:56 +0000
+++ src/org/hisp/dhis/mobile/recordstore/PatientRecordStore.java	2014-05-09 09:04:54 +0000
@@ -27,6 +27,8 @@
 package org.hisp.dhis.mobile.recordstore;
 
 import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Hashtable;
 import java.util.Vector;
 
 import javax.microedition.rms.RecordEnumeration;
@@ -132,6 +134,7 @@
         RecordStore recordStore = null;
         RecordEnumeration recordEnumeration = null;
         Patient patient;
+
         try
         {
             recordStore = RecordStore.openRecordStore( PATIENT_DB, true );
@@ -154,9 +157,27 @@
                 }
                 patientInfo = patientInfo.trim();
 
-                model.setName( patientInfo );
+                model.setName( patient.getTrackedEntityName() + "/" + patientInfo );
                 model.setId( patient.getId() );
-                modelList.getModels().addElement( model );
+
+                int index;
+                for ( index = modelList.getModels().size(); index > 0; index-- )
+                {
+                    if ( ((Model) modelList.getModels().elementAt( index - 1 )).getName().startsWith(
+                        patient.getTrackedEntityName() ) )
+                    {
+                        break;
+                    }
+                }
+
+                if ( index > 0 )
+                {
+                    modelList.getModels().insertElementAt( model, index - 1 );
+                }
+                else
+                {
+                    modelList.getModels().addElement( model );
+                }
                 patient = null;
                 model = null;
             }
@@ -167,6 +188,7 @@
             recordStore.closeRecordStore();
             System.gc();
         }
+
         return modelList;
     }
 }

=== modified file 'src/org/hisp/dhis/mobile/view/HistoryPersonListView.java'
--- src/org/hisp/dhis/mobile/view/HistoryPersonListView.java	2014-04-03 01:58:41 +0000
+++ src/org/hisp/dhis/mobile/view/HistoryPersonListView.java	2014-05-09 09:04:54 +0000
@@ -40,11 +40,13 @@
 
 import com.sun.lwuit.Command;
 import com.sun.lwuit.Form;
+import com.sun.lwuit.Label;
 import com.sun.lwuit.TextArea;
 import com.sun.lwuit.animations.CommonTransitions;
 import com.sun.lwuit.events.ActionEvent;
 import com.sun.lwuit.events.ActionListener;
 import com.sun.lwuit.layouts.BoxLayout;
+import com.sun.lwuit.plaf.Style;
 
 /**
  * @author Nguyen Kim Lai
@@ -56,6 +58,7 @@
     implements ActionListener
 {
     private static final String CLASS_TAG = "HistoryPersonListView";
+
     private NameBasedMIDlet nameBasedMIDlet;
 
     private Form mainForm;
@@ -75,17 +78,32 @@
         System.gc();
         this.getMainForm();
         mainForm.removeAll();
-        TextArea txtHint = new TextArea( "Select one person below: " );
+        TextArea txtHint = new TextArea( "Select one instance below: " );
         txtHint.setEditable( false );
         mainForm.addComponent( txtHint );
 
         Vector offlinePatients = modelList.getModels();
+        String trackedEntityName = "$$$";
         for ( int i = 0; i < offlinePatients.size(); i++ )
         {
             final Model patientModel = (Model) offlinePatients.elementAt( i );
-            String patientInfo = patientModel.getName();
-//            String name = patientInfo.substring( 0, patientInfo.indexOf( "/" ) );
-//            String birthday = patientInfo.substring( patientInfo.indexOf( "/" ) + 1, patientInfo.length() );
+
+            if ( !patientModel.getName().startsWith( trackedEntityName ) )
+            {
+                trackedEntityName = patientModel.getName().substring( 0, patientModel.getName().indexOf( "/" ) );
+
+                Style labelStyle = new Style();
+                labelStyle.setBgColor( 0xcccccc );
+
+                Label trackedEntitylbl = new Label( trackedEntityName );
+                trackedEntitylbl.setUnselectedStyle( labelStyle );
+                trackedEntitylbl.setSelectedStyle( labelStyle );
+                trackedEntitylbl.setFocusable( false );
+                mainForm.addComponent( trackedEntitylbl );
+
+            }
+
+            String patientInfo = patientModel.getName().substring( patientModel.getName().indexOf( "/" ) + 1 );
             LinkButton personLink = new LinkButton( patientInfo );
             /*
              * name = null; birthday = null; patientInfo = null;