← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7757: [mobile] validate person name and check duplicated id number

 

------------------------------------------------------------
revno: 7757
committer: Long <thanhlongngo1988@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-07-30 15:50:53 +0700
message:
  [mobile] validate person name and check duplicated id number
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties


--
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-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java	2012-07-15 07:10:03 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java	2012-07-30 08:50:53 +0000
@@ -32,7 +32,6 @@
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
-import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
 
 import java.util.Collection;

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java	2012-07-16 08:15:37 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java	2012-07-30 08:50:53 +0000
@@ -39,7 +39,6 @@
 import org.joda.time.DateTime;
 import org.joda.time.format.DateTimeFormatter;
 import org.joda.time.format.ISODateTimeFormat;
-
 import javax.servlet.http.HttpServletRequest;
 import java.util.*;
 
@@ -86,6 +85,18 @@
         this.patientIdentifierTypeService = patientIdentifierTypeService;
     }
 
+    private PatientIdentifierService patientIdentifierService;
+
+    public PatientIdentifierService getPatientIdentifierService()
+    {
+        return patientIdentifierService;
+    }
+
+    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
+    {
+        this.patientIdentifierService = patientIdentifierService;
+    }
+
     private PatientAttributeService patientAttributeService;
 
     public PatientAttributeService getPatientAttributeService()
@@ -259,7 +270,7 @@
         patientAttributes = patientAttributeService.getAllPatientAttributes();
         patient.setOrganisationUnit( organisationUnitService.getOrganisationUnit( orgUnitId ) );
 
-        if ( this.patientFullName.trim().length() < 2 )
+        if ( this.patientFullName.trim().length() < 7 )
         {
             validationMap.put( "fullName", "is_invalid_name" );
         }
@@ -303,7 +314,8 @@
             try
             {
                 patient.setBirthDateFromAge( Integer.parseInt( dateOfBirth ), Patient.AGE_TYPE_YEAR );
-            } catch ( NumberFormatException nfe )
+            }
+            catch ( NumberFormatException nfe )
             {
                 validationMap.put( "dob", "is_invalid_number" );
             }
@@ -315,7 +327,8 @@
                 DateTimeFormatter sdf = ISODateTimeFormat.yearMonthDay();
                 DateTime date = sdf.parseDateTime( dateOfBirth );
                 patient.setBirthDate( date.toDate() );
-            } catch ( Exception e )
+            }
+            catch ( Exception e )
             {
                 validationMap.put( "dob", "is_invalid_date" );
             }
@@ -331,6 +344,7 @@
             {
                 String key = "IDT" + patientIdentifierType.getId();
                 String value = parameterMap.get( key );
+                PatientIdentifier duplicateId = patientIdentifierService.get( patientIdentifierType, value );
                 if ( value != null )
                 {
                     if ( patientIdentifierType.isMandatory() && value.trim().equals( "" ) )
@@ -341,6 +355,10 @@
                     {
                         this.validationMap.put( key, "is_invalid_number" );
                     }
+                    else if ( duplicateId != null )
+                    {
+                        this.validationMap.put( key, "is_duplicate" );
+                    }
                     else
                     {
                         PatientIdentifier patientIdentifier = new PatientIdentifier();
@@ -368,12 +386,14 @@
                     {
                         this.validationMap.put( key, "is_empty" );
                     }
-                    else if ( value.trim().length() > 0 && patientAttribute.getValueType().equals( PatientAttribute.TYPE_INT )
+                    else if ( value.trim().length() > 0
+                        && patientAttribute.getValueType().equals( PatientAttribute.TYPE_INT )
                         && !FormUtils.isInteger( value ) )
                     {
                         this.validationMap.put( key, "is_invalid_number" );
                     }
-                    else if ( value.trim().length() > 0 && patientAttribute.getValueType().equals( PatientAttribute.TYPE_DATE )
+                    else if ( value.trim().length() > 0
+                        && patientAttribute.getValueType().equals( PatientAttribute.TYPE_DATE )
                         && !FormUtils.isDate( value ) )
                     {
                         this.validationMap.put( key, "is_invalid_date" );

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2012-07-25 13:18:48 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2012-07-30 08:50:53 +0000
@@ -292,6 +292,7 @@
 		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
 		<property name="patientAttributeOptionService" ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
+		<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
 	</bean>
 
 	<!-- Beneficiary Enrollment -->

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2012-07-23 09:58:04 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2012-07-30 08:50:53 +0000
@@ -30,6 +30,7 @@
 is_invalid_positive_integer=is not a valid positive integer
 is_invalid_negative_integer=is not a valid negative integer
 is_invalid_name=is not a valid name
+is_duplicate=person identifier number is duplicated
 warnings_and_errors=Warnings and errors
 validation_rule_violation_warnings=Validation Rule Violation Warnings
 minmax_violation_warnings=Min/Max Violation Warnings