dhis-mobile-devs team mailing list archive
-
dhis-mobile-devs team
-
Mailing list archive
-
Message #00418
[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 227: https://blueprints.launchpad.net/dhis-mobile/+spec/enhance-tracker-client
------------------------------------------------------------
revno: 227
committer: sherylyn.marie
branch nick: lwuit-tracking
timestamp: Fri 2014-05-30 11:43:28 +0800
message:
https://blueprints.launchpad.net/dhis-mobile/+spec/enhance-tracker-client
Enhance the feature and offline capacity of tracker client
#2 DATAENTRY FOR OFFLINE PATIENT
- View thru Find Instance screen
added:
src/org/hisp/dhis/mobile/view/WarningView.java
modified:
src/org/hisp/dhis/mobile/connection/task/FindPatientTask.java
src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java
src/org/hisp/dhis/mobile/view/PersonListView.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/task/FindPatientTask.java'
--- src/org/hisp/dhis/mobile/connection/task/FindPatientTask.java 2014-04-03 01:58:41 +0000
+++ src/org/hisp/dhis/mobile/connection/task/FindPatientTask.java 2014-05-30 03:43:28 +0000
@@ -46,7 +46,7 @@
extends AbstractTask
{
private static final String CLASS_TAG = "FindPatientTask";
-
+
private String keyWord;
private NameBasedMIDlet nameBasedMIDlet;
@@ -98,9 +98,11 @@
else if ( e.getMessage().equalsIgnoreCase( Text.HTTP_ERROR() )
|| e.getMessage().equalsIgnoreCase( "TCP open" ) )
{
- nameBasedMIDlet.getAlertBoxView( "Internet is not available, Please try again later.", "Alert" )
- .showView();
- nameBasedMIDlet.getFindBeneficiaryView().showView();
+ message = "Your internet connection is currently unavailable. The search result you are about to see are from your local database. Click Next to continue or Back to go to the previous screen.";
+ nameBasedMIDlet.getWarningView().prepareView();
+ nameBasedMIDlet.getWarningView().setKeyword( keyWord );
+ nameBasedMIDlet.getWarningView().getTxtNotification().setText( message );
+ nameBasedMIDlet.getWarningView().getMainForm().show();
}
else if ( e.getMessage().equalsIgnoreCase( "NO_PROGRAM_BELONG_ORGUNIT" ) )
{
=== modified file 'src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java'
--- src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java 2014-05-28 11:14:44 +0000
+++ src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java 2014-05-30 03:43:28 +0000
@@ -46,6 +46,7 @@
import org.hisp.dhis.mobile.view.UpdateContactView;
import org.hisp.dhis.mobile.view.VisitScheduleListView;
import org.hisp.dhis.mobile.view.VisitScheduleMenuView;
+import org.hisp.dhis.mobile.view.WarningView;
public class NameBasedMIDlet
extends DHISMIDlet
@@ -85,6 +86,8 @@
private OfflineOrgUnitSelectView offlineOrgUnitSelectView;
private NoMatchingView noMatchingView;
+
+ private WarningView warningView;
private ProgramSelectView programSelectView;
@@ -307,6 +310,15 @@
}
return noMatchingView;
}
+
+ public WarningView getWarningView()
+ {
+ if (warningView == null )
+ {
+ warningView = new WarningView( this );
+ }
+ return warningView;
+ }
public ProgramSelectView getProgramSelectView()
{
=== modified file 'src/org/hisp/dhis/mobile/view/PersonListView.java'
--- src/org/hisp/dhis/mobile/view/PersonListView.java 2014-05-05 07:06:56 +0000
+++ src/org/hisp/dhis/mobile/view/PersonListView.java 2014-05-30 03:43:28 +0000
@@ -29,10 +29,13 @@
import java.util.Vector;
import org.hisp.dhis.mobile.connection.ConnectionManager;
+import org.hisp.dhis.mobile.log.LogMan;
import org.hisp.dhis.mobile.midlet.DHISMIDlet;
import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
import org.hisp.dhis.mobile.model.LinkButton;
+import org.hisp.dhis.mobile.model.Patient;
import org.hisp.dhis.mobile.model.Relationship;
+import org.hisp.dhis.mobile.recordstore.PatientRecordStore;
import org.hisp.dhis.mobile.ui.Text;
import com.sun.lwuit.Command;
@@ -53,6 +56,8 @@
extends AbstractView
implements ActionListener
{
+ private static final String CLASS_TAG = "PersonListView";
+
private NameBasedMIDlet nameBasedMIDlet;
private Form mainForm;
@@ -63,6 +68,8 @@
private Relationship enrollmentRelationship;
+ private boolean isOffline;
+
public PersonListView( DHISMIDlet dhisMIDlet )
{
super( dhisMIDlet );
@@ -78,12 +85,12 @@
for ( int i = 0; i < patientInfos.size(); i++ )
{
String patientInfo = (String) patientInfos.elementAt( i );
-
- if(patientInfo.indexOf( "/" ) == -1)
+
+ if ( patientInfo.indexOf( "/" ) == -1 )
{
Style labelStyle = new Style();
labelStyle.setBgColor( 0xcccccc );
-
+
Label trackedEntitylbl = new Label( patientInfo );
trackedEntitylbl.setUnselectedStyle( labelStyle );
trackedEntitylbl.setSelectedStyle( labelStyle );
@@ -93,11 +100,11 @@
else
{
final String id = patientInfo.substring( 0, patientInfo.indexOf( "/" ) );
-
+
patientInfo = patientInfo.substring( patientInfo.indexOf( "/" ) + 1, patientInfo.length() );
/*
- * String name = patientInfo.substring( 0, patientInfo.indexOf( "/"
- * ) ); String birthday = patientInfo.substring(
+ * String name = patientInfo.substring( 0, patientInfo.indexOf(
+ * "/" ) ); String birthday = patientInfo.substring(
* patientInfo.indexOf( "/" ) + 1, patientInfo.length() );
* LinkButton personLink = new LinkButton( name + ", DOB: " +
* birthday );
@@ -108,15 +115,32 @@
public void actionPerformed( ActionEvent ae )
{
nameBasedMIDlet.getWaitingView().showView();
- if ( enrollmentRelationship == null )
+ if ( isOffline )
{
- ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getFindPatientUrl() );
- ConnectionManager.getPatientById( id );
+ try
+ {
+ Patient patient = PatientRecordStore.getPatient( Integer.parseInt( id ) );
+ nameBasedMIDlet.getPersonDashboardView().setPatient( patient );
+ nameBasedMIDlet.getPersonDashboardView().showView();
+ }
+ catch ( Exception e )
+ {
+ LogMan.log( "UI," + CLASS_TAG, e );
+ e.printStackTrace();
+ }
}
else
{
- enrollmentRelationship.setPersonBId( Integer.parseInt( id ) );
- ConnectionManager.addRelationship( enrollmentRelationship );
+ if ( enrollmentRelationship == null )
+ {
+ ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getFindPatientUrl() );
+ ConnectionManager.getPatientById( id );
+ }
+ else
+ {
+ enrollmentRelationship.setPersonBId( Integer.parseInt( id ) );
+ ConnectionManager.addRelationship( enrollmentRelationship );
+ }
}
mainForm = null;
patientInfos = null;
@@ -214,4 +238,14 @@
this.enrollmentRelationship = enrollmentRelationship;
}
+ public void setIsOffline( boolean isOffline )
+ {
+ this.isOffline = isOffline;
+ }
+
+ public boolean getIsOffline()
+ {
+ return isOffline;
+ }
+
}
=== added file 'src/org/hisp/dhis/mobile/view/WarningView.java'
--- src/org/hisp/dhis/mobile/view/WarningView.java 1970-01-01 00:00:00 +0000
+++ src/org/hisp/dhis/mobile/view/WarningView.java 2014-05-30 03:43:28 +0000
@@ -0,0 +1,159 @@
+package org.hisp.dhis.mobile.view;
+
+import java.util.Vector;
+
+import org.hisp.dhis.mobile.log.LogMan;
+import org.hisp.dhis.mobile.midlet.DHISMIDlet;
+import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
+import org.hisp.dhis.mobile.model.Model;
+import org.hisp.dhis.mobile.model.ModelList;
+import org.hisp.dhis.mobile.model.Patient;
+import org.hisp.dhis.mobile.model.PatientAttribute;
+import org.hisp.dhis.mobile.recordstore.PatientRecordStore;
+import org.hisp.dhis.mobile.ui.Text;
+
+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;
+import com.sun.lwuit.layouts.BoxLayout;
+
+public class WarningView
+ extends AbstractView
+ implements ActionListener
+{
+ private static final String CLASS_TAG = "WarningView";
+
+ private NameBasedMIDlet namebasedMidlet;
+
+ private Form mainForm;
+
+ private TextArea txtNotification;
+
+ private String keyword;
+
+ public WarningView( DHISMIDlet dhisMIDlet )
+ {
+ super( dhisMIDlet );
+ this.namebasedMidlet = (NameBasedMIDlet) dhisMIDlet;
+ }
+
+ public void actionPerformed( ActionEvent ae )
+ {
+ mainForm.removeAll();
+ mainForm = null;
+ txtNotification = null;
+ System.gc();
+
+ if ( ae.getCommand().getCommandName().equals( "Back" ) )
+ {
+ namebasedMidlet.getFindBeneficiaryView().showView();
+ }
+ // "Next"
+ else
+ {
+ ModelList modelList;
+ try
+ {
+ modelList = PatientRecordStore.getCurrentPatients();
+ Vector models = modelList.getModels();
+ Vector modelInfos = new Vector();
+ String trackedEntityName = "$$$";
+ for ( int i = 0; i < models.size(); i++ )
+ {
+ Model instanceModel = (Model) models.elementAt( i );
+ if ( !instanceModel.getName().startsWith( trackedEntityName ) )
+ {
+ trackedEntityName = instanceModel.getName().substring( 0, instanceModel.getName().indexOf( "/" ) );
+ modelInfos.addElement( trackedEntityName );
+ }
+
+ String instanceName = instanceModel.getName();
+ Patient patient = PatientRecordStore.getPatient( instanceModel.getId() );
+ for ( int j = 0; j < patient.getPatientAttValues().size(); j++ )
+ {
+ PatientAttribute attribute = (PatientAttribute) patient.getPatientAttValues().elementAt( j );
+ if ( attribute.getValue().equals( keyword ) )
+ {
+ modelInfos.addElement( instanceModel.getId() + "/"
+ + instanceName.substring( instanceName.indexOf( "/" ) + 1, instanceName.length() ) );
+ break;
+ }
+ }
+
+ }
+ namebasedMidlet.getPersonListView().setPatientInfos( modelInfos );
+ namebasedMidlet.getPersonListView().setIsOffline( true );
+ modelInfos = null;
+ namebasedMidlet.getPersonListView().showView();
+ }
+ catch ( Exception e )
+ {
+ LogMan.log( "UI," + CLASS_TAG, e );
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void prepareView()
+ {
+ System.gc();
+ getMainForm();
+ mainForm.removeAll();
+ mainForm.addComponent( getTxtNotification() );
+ }
+
+ public void showView()
+ {
+ getMainForm().show();
+ }
+
+ public Form getMainForm()
+ {
+ if ( mainForm == null )
+ {
+ mainForm = new Form( "Warning" );
+ mainForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
+ mainForm.setSmoothScrolling( true );
+ mainForm.addCommand( new Command( Text.BACK() ) );
+ mainForm.addCommand( new Command( Text.NEXT() ) );
+ mainForm.setTransitionOutAnimator( CommonTransitions.createSlide( CommonTransitions.SLIDE_HORIZONTAL, true,
+ 200 ) );
+ mainForm.addCommandListener( this );
+ }
+ return mainForm;
+ }
+
+ public void setMainForm( Form mainForm )
+ {
+ this.mainForm = mainForm;
+ }
+
+ public TextArea getTxtNotification()
+ {
+ if ( txtNotification == null )
+ {
+ txtNotification = new TextArea();
+ txtNotification.setEditable( false );
+ }
+ return txtNotification;
+ }
+
+ public void setTxtNotification( TextArea txtNotification )
+ {
+ this.txtNotification = txtNotification;
+ }
+
+ public String getKeyword()
+ {
+ return keyword;
+ }
+
+ public void setKeyword( String keyword )
+ {
+ this.keyword = keyword;
+ }
+
+}