dhis-mobile-devs team mailing list archive
-
dhis-mobile-devs team
-
Mailing list archive
-
Message #00318
[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 175: enhance the validation in madatory identifier
------------------------------------------------------------
revno: 175
committer: Long <Long@Long-Laptop>
branch nick: lwuit-tracking
timestamp: Wed 2013-10-23 15:18:01 +0700
message:
enhance the validation in madatory identifier
modified:
build.xml
src/org/hisp/dhis/mobile/model/PatientIdentifier.java
src/org/hisp/dhis/mobile/view/PersonRegistrationView.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-10-22 04:04:04 +0000
+++ build.xml 2013-10-23 08:18:01 +0000
@@ -34,12 +34,11 @@
<!-- Which logo to use -->
<property name="logo" value="dhis2_logo.png" />
<!-- Server URL -->
- <property name="server.url" value="http://localhost:9999" />
- <!--<property name="server.url" value="http://apps.dhis2.org/dev" />-->
+ <property name="server.url" value="http://localhost:9999/" />
<!-- User Name -->
- <property name="username" value="mobile" />
+ <property name="username" value="long" />
<!-- Password -->
- <property name="password" value="district" />
+ <property name="password" value="District1" />
<!-- Server Phone Number -->
<property name="server.phonenumber" value="+8494485878" />
<!-- Default Locale -->
=== modified file 'src/org/hisp/dhis/mobile/model/PatientIdentifier.java'
--- src/org/hisp/dhis/mobile/model/PatientIdentifier.java 2013-05-16 09:14:12 +0000
+++ src/org/hisp/dhis/mobile/model/PatientIdentifier.java 2013-10-23 08:18:01 +0000
@@ -30,6 +30,8 @@
private String identifier;
+ private boolean isMandatory;
+
public PatientIdentifier( String identifierType, String identifier )
{
this.identifierType = identifierType;
@@ -60,11 +62,22 @@
this.identifier = identifier;
}
+ public boolean isMandatory()
+ {
+ return isMandatory;
+ }
+
+ public void setMandatory( boolean isMandatory )
+ {
+ this.isMandatory = isMandatory;
+ }
+
public void serialize( DataOutputStream dataOutputStream )
throws IOException
{
dataOutputStream.writeUTF( this.identifierType );
dataOutputStream.writeUTF( this.identifier );
+ dataOutputStream.writeBoolean( this.isMandatory );
}
public void deSerialize( DataInputStream dataInputStream )
@@ -72,5 +85,6 @@
{
this.setIdentifierType( dataInputStream.readUTF() );
this.setIdentifier( dataInputStream.readUTF() );
+ this.setMandatory( dataInputStream.readBoolean() );
}
}
\ No newline at end of file
=== modified file 'src/org/hisp/dhis/mobile/view/PersonRegistrationView.java'
--- src/org/hisp/dhis/mobile/view/PersonRegistrationView.java 2013-10-23 07:41:35 +0000
+++ src/org/hisp/dhis/mobile/view/PersonRegistrationView.java 2013-10-23 08:18:01 +0000
@@ -1,6 +1,7 @@
package org.hisp.dhis.mobile.view;
import java.io.IOException;
+import java.util.Hashtable;
import java.util.Vector;
import javax.microedition.rms.RecordStoreException;
@@ -68,7 +69,7 @@
private TextField patientIdentifierTextField;
private TextField patientAttributeTextField;
-
+
private TextField txtIncidentDate;
private Command personRegistrationBackCommand;
@@ -97,16 +98,20 @@
private Vector patientAttributeValueVector = new Vector();
+ private Hashtable requiredIdentifierTable = new Hashtable();
+
private Vector requiredIdentifierVector = new Vector();
private Vector requireAttributeVector = new Vector();
-
+
private Vector offlinePatientAttributeVector;
private Vector offlinePatientIdentifierVector;
private String enrollProgramId = "";
+ private boolean isValid = true;
+
public PersonRegistrationView( DHISMIDlet dhisMIDlet )
{
super( dhisMIDlet );
@@ -116,14 +121,20 @@
public void prepareView()
{
System.gc();
+
getMainForm();
mainForm.removeAll();
- /*dobWrongFortmatLabel = null;
- requiredLabel = null;
- patientIdentifierVector = null;
- offlinePatientIdentifierVector = null;*/
- patientIdentifierValueVector = new Vector();
- patientAttributeValueVector = new Vector();
+ this.setDobWrongFortmatLabel( null );
+ this.setRequiredLabel( null );
+ this.patientIdentifierVector = null;
+ this.offlinePatientIdentifierVector = null;
+ this.patientIdentifierValueVector = new Vector();
+ this.patientAttributeValueVector = new Vector();
+ this.requiredIdentifierTable = new Hashtable();
+ this.requireAttributeVector = new Vector();
+ this.requiredIdentifierVector = new Vector();
+ this.isValid = true;
+ System.gc();
fullNameLabel = new Label( "Fullname(*)" );
genderLabel = new Label( Text.GENDER() );
@@ -179,14 +190,20 @@
for ( int i = 0; i < patientIdentifierVector.size(); i++ )
{
+
PatientIdentifier patientIdentifier = (PatientIdentifier) patientIdentifierVector.elementAt( i );
-
requiredIdentifierVector.addElement( patientIdentifier.getIdentifierType().substring(
patientIdentifier.getIdentifierType().length() - 1 ) );
- patientIdentifierLabel = new Label( patientIdentifier.getIdentifierType() );
- patientIdentifierTextField = new TextField();
- patientIdentifierTextField.setLabelForComponent( patientIdentifierLabel );
+ // Add warning field
+ Label warningLabel = this.getWarningLabel();
+ mainForm.addComponent( warningLabel );
+ requiredIdentifierTable.put( patientIdentifier.getIdentifierType(), warningLabel );
+
+ // Add Name label and text field
+ this.patientIdentifierLabel = new Label( patientIdentifier.getIdentifierType() );
+ this.patientIdentifierTextField = new TextField();
+ this.patientIdentifierTextField.setLabelForComponent( patientIdentifierLabel );
mainForm.addComponent( patientIdentifierLabel );
mainForm.addComponent( patientIdentifierTextField );
@@ -211,7 +228,7 @@
if ( enrollProgramId != null )
{
- Label lblIncidentDate = new Label("Incident date (*)");
+ Label lblIncidentDate = new Label( "Incident date (*)" );
mainForm.addComponent( lblIncidentDate );
mainForm.addComponent( getTxtIncidentDate() );
mainForm.addComponent( getRequiredLabel() );
@@ -283,8 +300,8 @@
{
mainForm = new Form( Text.PERSON_REGISTRATION() );
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.addCommand( getPersonRegistrationBackCommand() );
mainForm.addCommand( getPeronRegistrationSendCommand() );
mainForm.addCommand( getPersonRegistrationSaveCommand() );
@@ -310,41 +327,43 @@
String dateOfBirth = getDateOfBirthTextFiled().getText();
String incidentDate = getTxtIncidentDate().getText();
- boolean validateDOB = true;
+ this.patient = this.collectData();
// Validate Date of Birth
if ( !dobType.equalsIgnoreCase( "Approximated" ) && !PeriodUtil.isDateValid( dateOfBirth ) )
{
+
getDobWrongFortmatLabel().setText( Text.DOB_WRONG_FORMAT() );
- validateDOB = false;
+ this.isValid = false;
}
else if ( dateOfBirth.equals( "" ) )
{
getDobWrongFortmatLabel().setText( "(*):Required Field" );
- validateDOB = false;
+ this.isValid = false;
}
else
{
getDobWrongFortmatLabel().setText( "" );
}
-
+
// Validate Incident Date
- if ( enrollProgramId != null && incidentDate.trim().equals( "" ))
+ if ( enrollProgramId != null && incidentDate.trim().equals( "" ) )
{
getRequiredLabel().setText( "(*):Required Field" );
- validateDOB = false;
+ this.isValid = false;
}
else if ( enrollProgramId != null && !PeriodUtil.isDateValid( incidentDate ) )
{
getRequiredLabel().setText( "YYYY-MM-dd" );
- validateDOB = false;
+ this.isValid = false;
}
else
{
getRequiredLabel().setText( "" );
}
- if ( validateDOB == false )
+ if ( this.isValid == false )
+
{
patientAttributeValueVector.removeAllElements();
patientIdentifierValueVector.removeAllElements();
@@ -352,6 +371,7 @@
}
else
{
+
patient = collectData();
nameBasedMIDlet.getWaitingView().showView();
@@ -382,14 +402,14 @@
String dobType = (String) getDateOfBirthComboBox().getSelectedItem();
String dateOfBirth = getDateOfBirthTextFiled().getText();
- boolean validateDOB = true;
+ this.patient = this.collectData();
if ( !dobType.equalsIgnoreCase( "Approximated" ) && !PeriodUtil.isDateValid( dateOfBirth ) )
{
- validateDOB = false;
+ this.isValid = false;
}
- if ( dateOfBirth.equals( "" ) || validateDOB == false )
+ if ( dateOfBirth.equals( "" ) || this.isValid == false )
{
patientAttributeValueVector.removeAllElements();
patientIdentifierValueVector.removeAllElements();
@@ -401,8 +421,10 @@
patient = collectData();
nameBasedMIDlet.getWaitingView().showView();
- /*saveUnregisteredPersonTask = new SaveUnregisteredPersonTask( patient );
- saveUnregisteredPersonTask.run();*/
+ /*
+ * saveUnregisteredPersonTask = new SaveUnregisteredPersonTask(
+ * patient ); saveUnregisteredPersonTask.run();
+ */
ConnectionManager.saveUnregisterdPatient( patient );
try
{
@@ -472,6 +494,7 @@
{
// No fullName for Uganda case
// String fullName = this.getFullNameTextField().getText().trim();
+ this.isValid = true;
String fullName = "";
String gender = (String) getGenderComboBox().getSelectedItem();
String dobType = (String) getDateOfBirthComboBox().getSelectedItem();
@@ -508,7 +531,7 @@
int currentYear = java.util.Calendar.getInstance().get( java.util.Calendar.YEAR );
int currentDate = java.util.Calendar.getInstance().get( java.util.Calendar.DATE );
- int currentMonth = java.util.Calendar.getInstance().get( java.util.Calendar.MONTH )+1;
+ int currentMonth = java.util.Calendar.getInstance().get( java.util.Calendar.MONTH ) + 1;
int birthYear;
@@ -518,14 +541,15 @@
{
birthYear = currentYear - Integer.parseInt( dateOfBirth );
dateOfBirth = birthYear + "-" + currentMonth + "-" + currentDate;
- //dateOfBirth = currentDate + "-" + currentMonth + "-" + birthYear;
+ // dateOfBirth = currentDate + "-" + currentMonth + "-" +
+ // birthYear;
}
catch ( Exception e )
{
e.printStackTrace();
}
}
-
+
Patient patient = new Patient();
Vector attributeVector = new Vector();
Vector identiferVector = new Vector();
@@ -540,7 +564,6 @@
String incidentDate = getTxtIncidentDate().getText();
patient.setIncidentDate( incidentDate );
}
-
try
{
@@ -580,14 +603,13 @@
patientAttribute.setType( "" );
patientAttribute.setPredefinedValues( new Vector() );
// patientAttributeValueVector.setElementAt( patientAttribute, i
- // ););
+
attributeVector.addElement( patientAttribute );
}
}
catch ( Exception e )
{
e.printStackTrace();
-
}
try
@@ -598,15 +620,24 @@
TextField field = (TextField) patientIdentifierValueVector.elementAt( i );
int endIndex = field.getLabelForComponent().getText().indexOf( "(" );
String typeName = "";
+ boolean isRequired = false;
if ( rqId.equals( ")" ) )
{
typeName = field.getLabelForComponent().getText().substring( 0, endIndex ).trim();
+ isRequired = true;
}
else
{
typeName = field.getLabelForComponent().getText().toString().trim();
}
+ if ( isRequired && field.getText().trim().equals( "" ) )
+ {
+ Label warningLabel = (Label) requiredIdentifierTable.get( field.getLabelForComponent().getText() );
+ warningLabel.setText( "(*)Required" );
+ this.isValid = false;
+ }
+
PatientIdentifier patientIdentifier = new PatientIdentifier();
patientIdentifier.setIdentifierType( typeName );
patientIdentifier.setIdentifier( field.getText() );
@@ -614,7 +645,6 @@
}
patient.setIdentifiers( identiferVector );
patient.setPatientAttValues( attributeVector );
-
}
catch ( Exception e )
{
@@ -623,6 +653,13 @@
return patient;
}
+ public Label getWarningLabel()
+ {
+ Label label = new Label();
+ label.getStyle().setFgColor( 0xcc0000 );
+ return label;
+ }
+
public Label getRequiredLabel()
{
if ( requiredLabel == null )
@@ -823,7 +860,7 @@
{
this.txtIncidentDate = txtIncidentDate;
}
-
+
public Label getFullNameLabel()
{
return fullNameLabel;
@@ -1023,4 +1060,15 @@
{
this.patientAttributeTextField = patientAttributeTextField;
}
+
+ public void setDobWrongFortmatLabel( Label dobWrongFortmatLabel )
+ {
+ this.dobWrongFortmatLabel = dobWrongFortmatLabel;
+ }
+
+ public void setRequiredLabel( Label requiredLabel )
+ {
+ this.requiredLabel = requiredLabel;
+ }
+
}
\ No newline at end of file