← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12194: No check for uniqueness when editing identifiers in the Dashboard and Enrollment form.

 

------------------------------------------------------------
revno: 12194
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-09-23 11:29:22 +0700
message:
  No check for uniqueness when editing identifiers in the Dashboard and Enrollment form.
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierType.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.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/PatientIdentifierService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java	2013-09-17 06:08:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java	2013-09-23 04:29:22 +0000
@@ -78,5 +78,5 @@
         Patient patient );
 
     boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier,
-        OrganisationUnit orgunit, Program program, PeriodType periodType );
+        Integer patientId, OrganisationUnit orgunit, Program program, PeriodType periodType );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java	2013-09-17 06:08:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java	2013-09-23 04:29:22 +0000
@@ -75,6 +75,6 @@
     Collection<PatientIdentifier> get( Collection<PatientIdentifierType> identifierTypes, Patient patient );
 
     boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier,
-        OrganisationUnit orgunit, Program program, PeriodType periodType );
+        Integer patientId, OrganisationUnit orgunit, Program program, PeriodType periodType );
 
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierType.java	2013-09-17 06:08:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierType.java	2013-09-23 04:29:22 +0000
@@ -66,13 +66,13 @@
 
     private String type;
 
-    private Boolean personDisplayName;
+    private Boolean personDisplayName = false;;
 
     // For Local ID type
 
-    private Boolean orgunitScope;
+    private Boolean orgunitScope = false;
 
-    private Boolean programScope;
+    private Boolean programScope = false;;
 
     private PeriodType periodType;
 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java	2013-09-17 06:08:16 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java	2013-09-23 04:29:22 +0000
@@ -146,8 +146,9 @@
 
     @Override
     public boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier,
-        OrganisationUnit orgunit, Program program, PeriodType periodType )
+        Integer patientId, OrganisationUnit orgunit, Program program, PeriodType periodType )
     {
-        return patientIdentifierStore.checkDuplicateIdentifier( patientIdentifierType, identifier, orgunit, program, periodType );
+        return patientIdentifierStore.checkDuplicateIdentifier( patientIdentifierType, identifier, patientId, orgunit,
+            program, periodType );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java	2013-09-17 18:07:42 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java	2013-09-23 04:29:22 +0000
@@ -152,27 +152,33 @@
 
     @SuppressWarnings( "deprecation" )
     public boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier,
-        OrganisationUnit orgunit, Program program, PeriodType periodType )
+        Integer patientId, OrganisationUnit orgunit, Program program, PeriodType periodType )
     {
         String sql = "select count(*) from patientidentifier pi inner join patient p on pi.patientid=p.patientid "
             + "inner join programinstance pis on pis.patientid=pi.patientid where pi.patientidentifiertypeid="
             + patientIdentifierType.getId() + " and pi.identifier='" + identifier + "' ";
-        if ( orgunit != null )
+
+        if ( patientId != null )
+        {
+            sql += " and pi.patientid!=" + patientId;
+        }
+
+        if ( patientIdentifierType.getType().equals( PatientIdentifierType.VALUE_TYPE_LOCAL_ID ) && orgunit != null )
         {
             sql += " and p.organisationunitid=" + orgunit.getId();
         }
 
-        if ( program != null )
+        if ( patientIdentifierType.getType().equals( PatientIdentifierType.VALUE_TYPE_LOCAL_ID ) && program != null )
         {
             sql += " and pis.programid=" + program.getId();
         }
 
-        if ( periodType != null )
+        if ( patientIdentifierType.getType().equals( PatientIdentifierType.VALUE_TYPE_LOCAL_ID ) && periodType != null )
         {
             Date currentDate = new Date();
             Period period = periodType.createPeriod( currentDate );
             sql += " and pis.enrollmentdate >='" + period.getStartDateString() + "' and pis.enrollmentdate <='"
-                + DateUtils.getMediumDateString( period.getEndDate() )  + "'";
+                + DateUtils.getMediumDateString( period.getEndDate() ) + "'";
         }
 
         return jdbcTemplate.queryForInt( sql ) == 0 ? false : true;

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2013-09-19 08:26:17 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2013-09-23 04:29:22 +0000
@@ -245,6 +245,9 @@
 
         executeSql( "update programstage set openAfterEnrollment=false where openAfterEnrollment is null" );
         executeSql( "update programstage set reportDateToUse=false where reportDateToUse is null" );
+
+        executeSql( "update patientidentifiertype set orgunitScope=false where orgunitScope is null" );
+        executeSql( "update patientidentifiertype set programScope=false where programScope is null" );
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java	2013-09-17 06:08:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java	2013-09-23 04:29:22 +0000
@@ -199,24 +199,12 @@
                     {
                         boolean isDuplicate = false;
 
-                        if ( idType.getType().equals( PatientIdentifierType.VALUE_TYPE_LOCAL_ID ) )
-                        {
-                            OrganisationUnit orgunit = (idType.getOrgunitScope()) ? selectionManager
-                                .getSelectedOrganisationUnit() : null;
+                        OrganisationUnit orgunit = (idType.getOrgunitScope()) ? selectionManager
+                            .getSelectedOrganisationUnit() : null;
+                        Program program = (idType.getProgramScope()) ? programService.getProgram( programId ) : null;
 
-                            Program program = (idType.getProgramScope()) ? programService.getProgram( programId )
-                                : null;
-                            isDuplicate = patientIdentifierService.checkDuplicateIdentifier( idType, value, orgunit,
-                                program, idType.getPeriodType() );
-                        }
-                        else
-                        {
-                            PatientIdentifier identifier = patientIdentifierService.get( idType, value );
-                            if ( identifier != null && (id == null || identifier.getPatient().getId() != id) )
-                            {
-                                idDuplicate += idType.getName() + ", ";
-                            }
-                        }
+                        isDuplicate = patientIdentifierService.checkDuplicateIdentifier( idType, value, id,
+                            orgunit, program, idType.getPeriodType() );
 
                         if ( isDuplicate )
                         {

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java	2013-09-23 04:29:22 +0000
@@ -0,0 +1,201 @@
+package org.hisp.dhis.caseentry.action.patient;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.patient.PatientIdentifier;
+import org.hisp.dhis.patient.PatientIdentifierService;
+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 com.opensymphony.xwork2.Action;
+
+/**
+ * @author Abyot Asalefew Gizaw
+ */
+public class ValidatePatientIdentifierAction
+    implements Action
+{
+    public static final String PATIENT_DUPLICATE = "duplicate";
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PatientIdentifierService patientIdentifierService;
+
+    private PatientIdentifierTypeService identifierTypeService;
+
+    private ProgramService programService;
+
+    private OrganisationUnitSelectionManager selectionManager;
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Integer programId;
+
+    private Integer patientId;
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private String message;
+
+    private I18n i18n;
+
+    private Map<String, String> patientAttributeValueMap = new HashMap<String, String>();
+
+    private PatientIdentifier patientIdentifier;
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        HttpServletRequest request = ServletActionContext.getRequest();
+
+        Collection<PatientIdentifierType> identifiers = identifierTypeService.getAllPatientIdentifierTypes();
+
+        if ( identifiers != null && identifiers.size() > 0 )
+        {
+            String value = null;
+            String idDuplicate = "";
+
+            for ( PatientIdentifierType idType : identifiers )
+            {
+
+                value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + idType.getId() );
+
+                if ( StringUtils.isNotBlank( value ) )
+                {
+                    boolean isDuplicate = false;
+
+                     OrganisationUnit orgunit = (idType.getOrgunitScope()) ? selectionManager
+                            .getSelectedOrganisationUnit() : null;
+
+                        Program program = (idType.getProgramScope()) ? programService.getProgram( programId ) : null;
+                        isDuplicate = patientIdentifierService.checkDuplicateIdentifier( idType, value, patientId,  orgunit,
+                            program, idType.getPeriodType() );
+                 
+                    if ( isDuplicate )
+                    {
+                        idDuplicate += idType.getName() + ", ";
+                    }
+                }
+
+            }
+
+            if ( StringUtils.isNotBlank( idDuplicate ) )
+            {
+                idDuplicate = StringUtils.substringBeforeLast( idDuplicate, "," );
+                message = i18n.getString( "identifier_duplicate" ) + ": " + idDuplicate;
+                return INPUT;
+            }
+        }
+
+        // ---------------------------------------------------------------------
+        // Validation success
+        // ---------------------------------------------------------------------
+
+        message = i18n.getString( "everything_is_ok" );
+
+        return SUCCESS;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getter/Setter
+    // -------------------------------------------------------------------------
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
+    }
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
+    {
+        this.identifierTypeService = identifierTypeService;
+    }
+
+    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
+    {
+        this.patientIdentifierService = patientIdentifierService;
+    }
+
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+    {
+        this.selectionManager = selectionManager;
+    }
+
+    public String getMessage()
+    {
+        return message;
+    }
+
+    public void setI18n( I18n i18n )
+    {
+        this.i18n = i18n;
+    }
+
+    public Map<String, String> getPatientAttributeValueMap()
+    {
+        return patientAttributeValueMap;
+    }
+
+    public PatientIdentifier getPatientIdentifier()
+    {
+        return patientIdentifier;
+    }
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-09-18 06:54:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-09-23 04:29:22 +0000
@@ -617,6 +617,22 @@
 			ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
 	</bean>
 
+	<bean
+		id="org.hisp.dhis.caseentry.action.patient.ValidatePatientIdentifierAction"
+		class="org.hisp.dhis.caseentry.action.patient.ValidatePatientIdentifierAction"
+		scope="prototype">
+		<property name="patientIdentifierService"
+			ref="org.hisp.dhis.patient.PatientIdentifierService" />
+		<property name="identifierTypeService">
+			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		</property>
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="selectionManager">
+			<ref bean="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+		</property>
+	</bean>
+
+
 	<!-- Patient-Program Enrollment -->
 
 	<bean
@@ -874,7 +890,7 @@
 		<property name="organisationUnitService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.caseentry.action.report.LoadProgramStagesAction"
 		class="org.hisp.dhis.caseentry.action.report.LoadProgramStagesAction"
 		scope="prototype">
@@ -1042,7 +1058,7 @@
 		<property name="organisationUnitGroupService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.report.ValidateAggregateReportAction"
 		class="org.hisp.dhis.caseentry.action.report.ValidateAggregateReportAction"
@@ -1071,8 +1087,7 @@
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
 		<property name="patientReminderService" ref="org.hisp.dhis.patient.PatientReminderService" />
-		<property name="programInstanceService"
-			ref="org.hisp.dhis.program.ProgramInstanceService" />
+		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.reminder.SendSmsToListAction"
@@ -1122,13 +1137,15 @@
 
 	<!-- Comment && Message -->
 
-	<bean id="org.hisp.dhis.caseentry.action.reminder.SavePatientCommentAction"
+	<bean
+		id="org.hisp.dhis.caseentry.action.reminder.SavePatientCommentAction"
 		class="org.hisp.dhis.caseentry.action.reminder.SavePatientCommentAction"
 		scope="prototype">
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
-		<property name="patientCommentService" ref="org.hisp.dhis.patientcomment.PatientCommentService" />
+		<property name="patientCommentService"
+			ref="org.hisp.dhis.patientcomment.PatientCommentService" />
 	</bean>
 
 	<bean
@@ -1161,8 +1178,10 @@
 			ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
 	</bean>
 
-    <bean id="org.hisp.dhis.caseentry.action.reminder.GetProgramStageInstanceByIdAction"
-		class="org.hisp.dhis.caseentry.action.reminder.GetProgramStageInstanceByIdAction" scope="prototype">
+	<bean
+		id="org.hisp.dhis.caseentry.action.reminder.GetProgramStageInstanceByIdAction"
+		class="org.hisp.dhis.caseentry.action.reminder.GetProgramStageInstanceByIdAction"
+		scope="prototype">
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-09-11 16:02:06 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-09-23 04:29:22 +0000
@@ -729,6 +729,18 @@
 			<param name="requiredAuthorities">F_PROGRAM_ENROLLMENT</param>
 		</action>
 
+		<action name="validatePatientIdentifier"
+			class="org.hisp.dhis.caseentry.action.patient.ValidatePatientIdentifierAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
+			<result name="input" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
+			<param name="onExceptionReturn">plainTextError</param>
+		</action>
+
+
 		<!-- Relationship -->
 
 		<action name="getPartner"
@@ -1197,19 +1209,19 @@
 			</result>
 			<param name="requiredAuthorities">F_ACCESS_PATIENT_ATTRIBUTES</param>
 		</action>
-		
+
 		<action name="allowEditPatientFixedAttributes" class="org.hisp.dhis.caseentry.action.NoAction">
 			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm
 			</result>
 			<param name="requiredAuthorities">F_ALLOW_EDIT_PATIENT_PROPERTIES</param>
 		</action>
-		
+
 		<action name="allowEditPatientAttributes" class="org.hisp.dhis.caseentry.action.NoAction">
 			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm
 			</result>
 			<param name="requiredAuthorities">F_ALLOW_EDIT_PATIENT_ATTRIBUTES</param>
 		</action>
-		
+
 		<action name="allowEditPatientIdentifier" class="org.hisp.dhis.caseentry.action.NoAction">
 			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm
 			</result>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-09-17 07:53:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-09-23 04:29:22 +0000
@@ -1400,7 +1400,7 @@
 			
 			jQuery('#activeTB' ).append(activedRow);
 			jQuery('#enrollmentDiv').dialog("close");
-			saveIdentifierAndAttribute( patientId, programId,'identifierAndAttributeDiv' );
+			validateIdentifier( patientId, programId,'identifierAndAttributeDiv' );
 			loadActiveProgramStageRecords( programInstanceId );
 			showSuccessMessage(i18n_enrol_success);
 		});
@@ -1611,12 +1611,30 @@
 // Identifiers && Attributes for selected program
 // ----------------------------------------------------------------
 
-function saveIdentifierAndAttribute( patientId, programId, paramsDiv)
+function validateIdentifier(  patientId, programId, paramsDiv)
 {
 	var params  = getParamsForDiv(paramsDiv);
 		params += "&patientId=" + patientId;
 		params +="&programId=" + programId;
 	$.ajax({
+		type: "POST",
+		url: 'validatePatientIdentifier.action',
+		data: params,
+		success: function(json) 
+		{
+			if( json.response=='success'){
+				saveIdentifierAndAttribute( params);
+			}
+			else{
+				showErrorMessage( json.message );
+			}
+		}
+	});
+}
+
+function saveIdentifierAndAttribute(params)
+{
+	$.ajax({
 			type: "POST",
 			url: 'savePatientIdentifierAndAttribute.action',
 			data: params,

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2013-09-17 09:14:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2013-09-23 04:29:22 +0000
@@ -64,7 +64,7 @@
 					#foreach ($identifierType in $identifierTypes) 
 						#set( $identifier = '')
 						#set( $identifier = $identiferMap.get( $identifierType.id ) )
-						<tr #alternate( $mark ) name='idenFields'>
+						<tr name='idenFields'>
 							<td class='text-column'><label>$identifierType.displayName #if($identifierType.mandatory == true )<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>       
 							<td class="input-column">
 								<input type="text" id="iden$identifierType.id" name="iden$identifierType.id" value='$!identifier' class="{validate:{required:$identifierType.mandatory, #if($!identifierType.noChars) maxlength:$identifierType.noChars, #end #if($identifierType.type=='number') number:true #elseif($!identifierType.type=='letter') lettersonly:true #end }}" />
@@ -75,35 +75,35 @@
 					
 					<!-- ATTRIBUTES IN GROUPS -->
 					#foreach($attribute in $patientAttributes )
-							#set( $attributeValue = '')
-							#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
-							<tr #alternate( $mark ) name='attributesFields'>
-								<td class='text-column'><label>$attribute.displayName #if($attribute.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
-								<td class="input-column" >
-									#if( $attribute.valueType == "bool" )
-										<select id="attr$attribute.id" name="attr$attribute.id" >              
-											<option value="">[$i18n.getString( "please_select" )]</option>
-											<option value="true" #if( $attributeValue=='true') selected="selected" #end>$i18n.getString( "yes" )</option>
-											<option value="false" #if( $attributeValue=='false') selected="selected" #end>$i18n.getString( "no" )</option>
-										</select>                
-									#elseif( $attribute.valueType == "date" )
-										<input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue"  objectId='$attribute.id' objectType='attr' class=' #validate( "default"  $attribute.mandatory )' >
-										<script type="text/javascript">
-											datePickerValid( 'attr$attribute.id', false, false );
-										</script>                 
-									#elseif( $attribute.valueType == "combo" )
-										<select  id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )' >
-											 <option value="">[$i18n.getString( "please_select" )]</option>
-											#foreach ($option in $attribute.attributeOptions )
-												<option value="$option.id" #if($attributeValue == $option.name) selected="selected" #end>$option.name</option>
-											#end
-										</select>
-									#else 
-										<input type="text"  id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}"  > 
-									#end
-								</td>		
-							</tr>
-						#set( $mark = !$mark  )
+						#set( $attributeValue = '')
+						#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
+						<tr name='attributesFields'>
+							#set($mandatory = $attribute.mandatory )
+							<td class='text-column'><label>$attribute.displayName #if($mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
+							<td class="input-column" >
+								#if( $attribute.valueType == "bool" ) 
+									<select id="attr$attribute.id" name="attr$attribute.id" class="{validate:{required:$mandatory}}" >              
+										<option value="">[$i18n.getString( "please_select" )]</option>
+										<option value="true" #if( $attributeValue=='true') selected="selected" #end>$i18n.getString( "yes" )</option>
+										<option value="false" #if( $attributeValue=='false') selected="selected" #end>$i18n.getString( "no" )</option>
+									</select>                
+								#elseif( $attribute.valueType == "date" )
+									<input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue"  objectId='$attribute.id' objectType='attr' class="{validate:{required:$mandatory}}" >
+									<script type="text/javascript">
+										datePickerValid( 'attr$attribute.id', false, false );
+									</script>                 
+								#elseif( $attribute.valueType == "combo" )
+									<select  id="attr$attribute.id" name="attr$attribute.id" class="{validate:{required:$mandatory}}" >
+										 <option value="">[$i18n.getString( "please_select" )]</option>
+										#foreach ($option in $attribute.attributeOptions )
+											<option value="$option.id" #if($attributeValue == $option.name) selected="selected" #end>$option.name</option>
+										#end
+									</select>
+								#else 
+									<input type="text"  id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}"  > 
+								#end
+							</td>		
+						</tr>
 					#end
 					<tr><td>&nbsp;</td></tr>
 					<tr>
@@ -141,7 +141,7 @@
 <script type="text/javascript">
 	jQuery("#patientPropertyForm").ready( function(){
 		validation( 'patientPropertyForm', function(form){
-			saveIdentifierAndAttribute( $programInstance.patient.id, $programInstance.program.id, 'patientPropertyForm' );
+			validateIdentifier( $programInstance.patient.id, $programInstance.program.id, 'patientPropertyForm' );
 		});	
 		
 		validation( 'coordinatesForm', function(form){