← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2434: Fix bug: While Editing Benificiary, the ageType is always selected with default value as 'day' an...

 

------------------------------------------------------------
revno: 2434
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2010-12-28 10:11:15 +0700
message:
  Fix bug: While Editing Benificiary, the ageType is always selected with default value as 'day' and giving invalid date error.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddRepresentativeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/relationship/AddRelationshipPatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/relationship/ValidateAddRelationshipPatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm


--
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-api/src/main/java/org/hisp/dhis/patient/Patient.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java	2010-12-27 07:59:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java	2010-12-28 03:11:15 +0000
@@ -44,14 +44,15 @@
     implements Serializable
 {
     public static final String MALE = "M";
-
     public static final String FEMALE = "F";
 
     public static final char DOB_TYPE_VERIFIED = 'V';
-
     public static final char DOB_TYPE_DECLARED = 'D';
-
     public static final char DOB_TYPE_APPROXIATED = 'A';
+    
+    public static final char AGE_TYPE_YEAR = 'Y';
+    public static final char AGE_TYPE_MONTH = 'M';
+    public static final char AGE_TYPE_DAY = 'D';
 
     private Integer id;
 
@@ -60,7 +61,7 @@
     private String middleName;
 
     private String lastName;
-    
+
     private String fullName;
 
     private String gender;
@@ -404,15 +405,15 @@
         // Assumed relative to the 1st of January
         // todayCalendar.set( Calendar.DATE, 1 );
         // todayCalendar.set( Calendar.MONTH, Calendar.JANUARY );
-        if ( ageType == 'Y' )
+        if ( ageType == AGE_TYPE_YEAR )
         {
             todayCalendar.add( Calendar.YEAR, -1 * age );
         }
-        else if ( ageType == 'M' )
+        else if ( ageType == AGE_TYPE_MONTH )
         {
             todayCalendar.add( Calendar.MONTH, -1 * age );
         }
-        else if ( ageType == 'D' )
+        else if ( ageType == AGE_TYPE_DAY )
         {
             todayCalendar.add( Calendar.DATE, -1 * age );
         }
@@ -420,6 +421,37 @@
         setBirthDate( todayCalendar.getTime() );
     }
 
+    public char getAgeType()
+    {
+        Calendar todayCalendar = Calendar.getInstance();
+        todayCalendar.clear( Calendar.MILLISECOND );
+        todayCalendar.clear( Calendar.SECOND );
+        todayCalendar.clear( Calendar.MINUTE );
+        todayCalendar.set( Calendar.HOUR_OF_DAY, 0 );
+
+        Calendar birthCalendar = Calendar.getInstance();
+        birthCalendar.setTime( birthDate );
+
+        int age = todayCalendar.get( Calendar.YEAR ) - birthCalendar.get( Calendar.YEAR );
+
+        if ( age > 0 )
+        {
+            return AGE_TYPE_YEAR;
+        }
+
+        age = todayCalendar.get( Calendar.MONTH ) - birthCalendar.get( Calendar.MONTH );
+        if ( age > 0 )
+        {
+            return AGE_TYPE_MONTH;
+        }
+
+        return AGE_TYPE_DAY;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getter && Setter
+    // -------------------------------------------------------------------------
+
     public void setFullName( String fullName )
     {
         this.fullName = fullName;
@@ -469,9 +501,9 @@
     {
         switch ( dobType )
         {
-        case 'V':
+        case DOB_TYPE_VERIFIED:
             return "Verified";
-        case 'D':
+        case DOB_TYPE_DECLARED:
             return "Declared";
         default:
             return "Approxiated";

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java	2010-12-27 07:59:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java	2010-12-28 03:11:15 +0000
@@ -169,7 +169,7 @@
         patient.setUnderAge( underAge );
         patient.setOrganisationUnit( organisationUnit );
 
-        if ( dobType == 'V' || dobType == 'D' )
+        if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED)
         {
             birthDate = birthDate.trim();
             patient.setBirthDate( format.parseDate( birthDate ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddRepresentativeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddRepresentativeAction.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddRepresentativeAction.java	2010-12-28 03:11:15 +0000
@@ -121,7 +121,7 @@
         patient.setBloodGroup( bloodGroup );
         patient.setOrganisationUnit( organisationUnit );
 
-        if ( dobType == 'V' || dobType == 'D' )
+        if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED )
         {
             birthDate = birthDate.trim();
             patient.setBirthDate( format.parseDate( birthDate ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientAction.java	2010-06-16 12:16:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientAction.java	2010-12-28 03:11:15 +0000
@@ -134,7 +134,6 @@
                if( representativeIdentifier.getIdentifierType() != null && representativeIdentifier.getIdentifierType().isRelated() ) 
                 {
                     identiferMap.put( representativeIdentifier.getIdentifierType().getId(), representativeIdentifier.getIdentifier() );
-                    //System.out.println( "if patient uderage "+representativeIdentifier.getIdentifierType().getId()+ representativeIdentifier.getIdentifier() );
                 }
             }
         }
@@ -145,7 +144,7 @@
             if ( idType != null )
             {
                 identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
-                //System.out.println( "if type is not null "+identifier.getIdentifierType().getId()+ identifier.getIdentifier()  );
+
                 if(idType.getFormat().equals("State Format"))
                 {
                      String iden = identifier.getIdentifier();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java	2010-11-09 09:07:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java	2010-12-28 03:11:15 +0000
@@ -172,7 +172,7 @@
             return INPUT;
         }
 
-        if ( dobType != null && (dobType == 'V' || dobType == 'D') )
+        if ( dobType != null && (dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED ) )
         {
             birthDate = birthDate.trim();
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/relationship/AddRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/relationship/AddRelationshipPatientAction.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/relationship/AddRelationshipPatientAction.java	2010-12-28 03:11:15 +0000
@@ -134,7 +134,7 @@
         patient.setUnderAge( underAge );
         patient.setOrganisationUnit( organisationUnit );
 
-        if ( dobType == 'V' || dobType == 'D')
+        if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED )
         {
            birthDate = birthDate.trim();
            patient.setBirthDate( format.parseDate( birthDate ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/relationship/ValidateAddRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/relationship/ValidateAddRelationshipPatientAction.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/relationship/ValidateAddRelationshipPatientAction.java	2010-12-28 03:11:15 +0000
@@ -192,7 +192,7 @@
         // Check Identifiers duplicate
 
         Patient p = new Patient();
-        if ( dobType == 'V' || dobType == 'D' )
+        if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED )
         {
             birthDate = birthDate.trim();
             p.setBirthDate( format.parseDate( birthDate ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2010-12-27 07:59:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2010-12-28 03:11:15 +0000
@@ -5,7 +5,6 @@
 	<li><a href="patientAttributeGroup.action">$i18n.getString( "patient_attribute_group" )</a></li>
 	<li><a href="patientIdentifierType.action">$i18n.getString( "patient_identifier_type" )</a></li>
 	<li><a href="relationshipType.action">$i18n.getString( "relationship_type" )</a></li>
-	<li><a href="patient.action">$i18n.getString( "orgunit_registration" )</a></li>
 	<li><a href="program.action">$i18n.getString( "program" )</a></li>
 	<li><a href="programAttribute.action">$i18n.getString( "program_attribute" )</a></li>
 	<li><a href="caseAggregation.action">$i18n.getString( "case_aggregation_mapping" )</a></li>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm	2010-12-10 05:57:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm	2010-12-28 03:11:15 +0000
@@ -114,9 +114,9 @@
 		<td><label for="age">$i18n.getString( "age" ) </label><em title="$i18n.getString( "required" )" class="required">*</em> </label></td>
 		<td>
 			<select id="ageType" name="ageType" style="width:15em" >
-				<option value="D"> $i18n.getString('day')</option>
-				<option value="M"> $i18n.getString('month')</option>
-				<option value="Y"> $i18n.getString('year')</option>
+				<option value="D" #if($patient.getAgeType()=='D') selected #end> $i18n.getString('day')</option>
+				<option value="M" #if($patient.getAgeType()=='M') selected #end> $i18n.getString('month')</option>
+				<option value="Y" #if($patient.getAgeType()=='Y') selected #end> $i18n.getString('year')</option>
 			</select>
 			<input type="text" id="age" name="age" value="$patient.getIntegerValueOfAge()" style="width:14.5em"  style="width:12em" onchange="ageOnchange()" class="{validate:{number:true, alphanumeric: true}}">
 		</td>