← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12039: [j2me] change patient's DOB into string type to make it simple for client

 

------------------------------------------------------------
revno: 12039
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-09-11 21:28:23 +0700
message:
  [j2me] change patient's DOB into string type to make it simple for client
modified:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/PeriodUtil.java
  dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java	2013-09-10 16:29:20 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java	2013-09-11 14:28:23 +0000
@@ -65,7 +65,7 @@
 
     private String gender;
 
-    private Date birthDate;
+    private String birthDate;
 
     private Date registrationDate;
 
@@ -194,12 +194,12 @@
         this.gender = gender;
     }
 
-    public Date getBirthDate()
+    public String getBirthDate()
     {
         return birthDate;
     }
 
-    public void setBirthDate( Date birthDate )
+    public void setBirthDate( String birthDate )
     {
         this.birthDate = birthDate;
     }
@@ -378,7 +378,7 @@
         if ( birthDate != null )
         {
             dout.writeBoolean( true );
-            dout.writeLong( birthDate.getTime() );
+            dout.writeUTF( birthDate );
         }
         else
         {
@@ -533,7 +533,7 @@
         // DOB
         if ( din.readBoolean() )
         {
-            this.setBirthDate( new Date( din.readLong() ) );
+            this.setBirthDate( din.readUTF() );
         }
         else
         {
@@ -565,7 +565,6 @@
         
         // Patient Attribute & Identifiers
         int attsNumb = din.readInt();
-        System.out.println("Att numb: " + attsNumb);
         if( attsNumb > 0 )
         {
             this.patientAttValues = new ArrayList<PatientAttribute>();
@@ -582,7 +581,6 @@
         }
 
         int numbIdentifiers = din.readInt();
-        System.out.println("Ids numb: " + attsNumb);
         this.identifiers = new ArrayList<PatientIdentifier>();
         if ( numbIdentifiers > 0 )
         {
@@ -605,7 +603,6 @@
                 Program program = new Program();
                 program.deSerialize( din );
                 this.programs.add( program );
-    
             }
         }
         else
@@ -622,7 +619,6 @@
                 Relationship relationship = new Relationship();
                 relationship.deSerialize( din );
                 this.relationships.add( relationship );
-    
             }
         }
         else
@@ -639,7 +635,6 @@
                 Program program = new Program();
                 program.deSerialize( din );
                 this.enrollmentPrograms.add( program );
-    
             }
         }
         else
@@ -656,7 +651,6 @@
                 Relationship relationship = new Relationship();
                 relationship.deSerialize( din );
                 this.enrollmentRelationships.add( relationship );
-    
             }
         }
         else
@@ -673,7 +667,6 @@
                 Program program = new Program();
                 program.deSerialize( din );
                 this.completedPrograms.add( program );
-    
             }
         }
         else

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-09-10 16:29:20 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-09-11 14:28:23 +0000
@@ -882,6 +882,8 @@
 
         Period period = new Period( new DateTime( patient.getBirthDate() ), new DateTime() );
         patientModel.setAge( period.getYears() );
+        /*DateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy" );
+        patientModel.setAge( dateFormat.format( patient.getBirthDate() ) );*/
         if ( patient.getOrganisationUnit() != null )
         {
             patientModel.setOrganisationUnitName( patient.getOrganisationUnit().getName() );
@@ -902,7 +904,8 @@
             }
             if ( setting.getBirthdate() )
             {
-                patientModel.setBirthDate( patient.getBirthDate() );
+                DateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy" );
+                patientModel.setBirthDate( dateFormat.format( patient.getBirthDate()) );
             }
             if ( setting.getRegistrationdate() )
             {
@@ -1817,7 +1820,7 @@
         throws NotAllowedException
     {
         org.hisp.dhis.patient.Patient patientWeb = new org.hisp.dhis.patient.Patient();
-
+        
         int startIndex = patient.getFirstName().indexOf( ' ' );
         int endIndex = patient.getFirstName().lastIndexOf( ' ' );
 
@@ -1846,7 +1849,7 @@
         patientWeb.setGender( patient.getGender() );
         patientWeb.setDobType( patient.getDobType() );
         patientWeb.setPhoneNumber( patient.getPhoneNumber() );
-        patientWeb.setBirthDate( patient.getBirthDate() );
+        patientWeb.setBirthDate( PeriodUtil.stringToDate( patient.getBirthDate() ) );
         patientWeb.setOrganisationUnit( organisationUnitService.getOrganisationUnit( orgUnitId ) );
         patientWeb.setRegistrationDate( new Date() );
 
@@ -1883,7 +1886,7 @@
         // --------------------------------------------------------------------------------
         if ( identifierTypes.size() == 0 )
         {
-            String identifier = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(),
+            String identifier = PatientIdentifierGenerator.getNewIdentifier( PeriodUtil.stringToDate( patient.getBirthDate() ),
                 patient.getGender() );
 
             org.hisp.dhis.patient.PatientIdentifier systemGenerateIdentifier = new org.hisp.dhis.patient.PatientIdentifier();
@@ -1977,7 +1980,7 @@
         {
             String patientsInfo = new String();
 
-            DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+            DateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy" );
 
             int i = 1;
             for ( Patient each : patients )

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/PeriodUtil.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/PeriodUtil.java	2013-09-07 12:47:54 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/PeriodUtil.java	2013-09-11 14:28:23 +0000
@@ -164,13 +164,13 @@
 
     public static String dateToString( Date date )
     {
-        DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+        DateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy" );
         return dateFormat.format( date );
     }
 
     public static Date stringToDate( String dateString )
     {
-        SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+        SimpleDateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy" );
         Date date = null;
         try
         {

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java	2013-09-10 09:00:47 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java	2013-09-11 14:28:23 +0000
@@ -71,7 +71,7 @@
     {
         Patient patient = new Patient();
         patient.setAge( 1 );
-        patient.setBirthDate( new Date() );
+        patient.setBirthDate( "25-09-1990" );
         patient.setFirstName( "Firstname" + uniqueCharacter );
         patient.setMiddleName( "Middlename" + uniqueCharacter );
         patient.setLastName( "Lastname" + uniqueCharacter );