← Back to team overview

dhis-mobile-devs team mailing list archive

[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 170: add incident date when register patient

 

------------------------------------------------------------
revno: 170
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: lwuit-tracking
timestamp: Tue 2013-10-22 11:04:04 +0700
message:
  add incident date when register patient
modified:
  build.xml
  src/org/hisp/dhis/mobile/model/Patient.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-21 02:58:54 +0000
+++ build.xml	2013-10-22 04:04:04 +0000
@@ -34,11 +34,12 @@
 	<!-- Which logo to use -->
 	<property name="logo" value="dhis2_logo.png" />
 	<!-- Server URL -->
-	<property name="server.url" value="http://mujhu.dhis2.org/"; />
+	<property name="server.url" value="http://localhost:9999"; />
+	<!--<property name="server.url" value="http://apps.dhis2.org/dev"; />-->
 	<!-- User Name -->
-	<property name="username" value="" />
+	<property name="username" value="mobile" />
 	<!-- Password -->
-	<property name="password" value="" />
+	<property name="password" value="district" />
 	<!-- Server Phone Number -->
 	<property name="server.phonenumber" value="+8494485878" />
 	<!-- Default Locale -->

=== modified file 'src/org/hisp/dhis/mobile/model/Patient.java'
--- src/org/hisp/dhis/mobile/model/Patient.java	2013-09-23 07:58:49 +0000
+++ src/org/hisp/dhis/mobile/model/Patient.java	2013-10-22 04:04:04 +0000
@@ -64,6 +64,8 @@
     private String organisationUnitName;
 
     private Vector completedPrograms;
+    
+    private String incidentDate;
 
     public Patient()
     {
@@ -237,6 +239,16 @@
         this.completedPrograms = completedPrograms;
     }
 
+    public String getIncidentDate()
+    {
+        return incidentDate;
+    }
+
+    public void setIncidentDate( String incidentDate )
+    {
+        this.incidentDate = incidentDate;
+    }
+
     public void deSerialize( DataInputStream din )
         throws IOException
     {
@@ -295,6 +307,15 @@
         {
             this.setRegistrationDate( null );
         }
+        
+        if ( din.readBoolean() )
+        {
+            this.setIncidentDate( din.readUTF() );
+        }
+        else
+        {
+            this.setIncidentDate( null );
+        }
 
         if ( din.readBoolean() )
         {
@@ -502,6 +523,16 @@
         {
             dout.writeBoolean( false );
         }
+        
+        if ( incidentDate != null )
+        {
+            dout.writeBoolean( true );
+            dout.writeUTF( incidentDate );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
 
         if ( phoneNumber != null )
         {

=== modified file 'src/org/hisp/dhis/mobile/view/PersonRegistrationView.java'
--- src/org/hisp/dhis/mobile/view/PersonRegistrationView.java	2013-10-21 02:58:54 +0000
+++ src/org/hisp/dhis/mobile/view/PersonRegistrationView.java	2013-10-22 04:04:04 +0000
@@ -69,6 +69,8 @@
     private TextField patientIdentifierTextField;
 
     private TextField patientAttributeTextField;
+    
+    private TextField txtIncidentDate;
 
     private Command personRegistrationBackCommand;
 
@@ -205,8 +207,17 @@
         personRegistrationForm.addComponent( dateOfBirthTextFiled );
         personRegistrationForm.addComponent( getDobWrongFortmatLabel() );
 
+        if ( enrollProgramId != null )
+        {
+            Label lblIncidentDate = new Label("Incident date (*)");
+            personRegistrationForm.addComponent( lblIncidentDate );
+            personRegistrationForm.addComponent( getTxtIncidentDate() );
+            personRegistrationForm.addComponent( getRequiredLabel() );
+        }
         personRegistrationForm.addComponent( phoneNumberLabel );
         personRegistrationForm.addComponent( phoneNumberTextField );
+        
+        
 
         // add attribute
         try
@@ -366,6 +377,12 @@
 
     public TextField getPhoneNumberTextField()
     {
+        if ( phoneNumberTextField == null )
+        {
+            phoneNumberTextField = new TextField();
+            phoneNumberTextField.setConstraint( TextField.NUMERIC );
+            phoneNumberTextField.setInputModeOrder( new String[] { "123" } );
+        }
         return phoneNumberTextField;
     }
 
@@ -492,20 +509,46 @@
 
             String dobType = (String) this.getDateOfBirthComboBox().getSelectedItem();
             String dateOfBirth = this.getDateOfBirthTextFiled().getText();
+            String incidentDate = this.getTxtIncidentDate().getText();
 
             boolean validateDOB = true;
 
+            // Validate Date of Birth
             if ( !dobType.equalsIgnoreCase( "Approximated" ) && !PeriodUtil.isDateValid( dateOfBirth ) )
             {
-                validateDOB = false;
+                getDobWrongFortmatLabel().setText( Text.DOB_WRONG_FORMAT() );
+                validateDOB = false;
+            }
+            else if ( dateOfBirth.equals( "" ) )
+            {
+                getDobWrongFortmatLabel().setText( "(*):Required Field" );
+                validateDOB = false;
+            }
+            else
+            {
+                getDobWrongFortmatLabel().setText( "" );
+            }
+            
+            // Validate Incident Date
+            if ( enrollProgramId != null && incidentDate.trim().equals( "" ))
+            {
+                getRequiredLabel().setText( "(*):Required Field" );
+                validateDOB = false;
+            }
+            else if ( enrollProgramId != null && !PeriodUtil.isDateValid( incidentDate ) )
+            {
+                getRequiredLabel().setText( "YYYY-MM-dd" );
+                validateDOB = false;
+            }
+            else
+            {
+                getRequiredLabel().setText( "" );
             }
 
-            if ( dateOfBirth.equals( "" ) || validateDOB == false )
+            if ( validateDOB == false )
             {
                 patientAttributeValueVector.removeAllElements();
                 patientIdentifierValueVector.removeAllElements();
-                getRequiredLabel().setText( "(*) : Required Field" );
-                getDobWrongFortmatLabel().setText( Text.DOB_WRONG_FORMAT() );
                 getPersonRegistrationForm().show();
             }
             else
@@ -514,7 +557,7 @@
 
                 nameBasedMIDlet.getWaitingView().showView();
                 ConnectionManager.setUrl( dhisMIDlet.getCurrentOrgUnit().getRegisterPersonUrl() );
-                ConnectionManager.registerPerson( patient, this.enrollProgramId );
+                ConnectionManager.registerPerson( patient, enrollProgramId );
                 try
                 {
                     PatientIdentifierRecordStore.deleteRecordStore();
@@ -551,7 +594,6 @@
             {
                 patientAttributeValueVector.removeAllElements();
                 patientIdentifierValueVector.removeAllElements();
-                getRequiredLabel().setText( "(*) : Required Field" );
                 getDobWrongFortmatLabel().setText( Text.DOB_WRONG_FORMAT() );
                 getPersonRegistrationForm().show();
             }
@@ -642,7 +684,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 );
+        int currentMonth = java.util.Calendar.getInstance().get( java.util.Calendar.MONTH )+1;
 
         int birthYear;
 
@@ -652,16 +694,14 @@
             {
                 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();
@@ -671,6 +711,12 @@
         patient.setDobType( dateOfBirthType );
         patient.setPhoneNumber( phoneNumber );
         patient.setBirthDate( dateOfBirth );
+        if ( enrollProgramId != null )
+        {
+            String incidentDate = this.getTxtIncidentDate().getText();
+            patient.setIncidentDate( incidentDate );
+        }
+        
 
         try
         {
@@ -967,4 +1013,18 @@
     {
         this.patient = patient;
     }
+
+    public TextField getTxtIncidentDate()
+    {
+        if ( txtIncidentDate == null )
+        {
+            txtIncidentDate = new TextField();
+        }
+        return txtIncidentDate;
+    }
+
+    public void setTxtIncidentDate( TextField txtIncidentDate )
+    {
+        this.txtIncidentDate = txtIncidentDate;
+    }
 }
\ No newline at end of file