← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6386: (patient) Create relationship between PatientAttribute and Program.

 

------------------------------------------------------------
revno: 6386
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-03-27 08:29:30 +0700
message:
  (patient) Create relationship between PatientAttribute and Program.
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroupStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeGroupStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ShowUpdatePatientAttributeAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroupService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeGroupService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAttribute.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.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/entry.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm
  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/programEnrollmentSelectForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientAttribute.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/AddPatientAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/GetPatientAttributesWithoutGroupAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/UpdatePatientAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattributegroup/GetPatientAttributeGroupAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientIdentifierTypeForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientIdentifierType.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatientIdentifierType.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientIdentifierType.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/PatientAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java	2012-02-27 01:07:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java	2012-03-27 01:29:30 +0000
@@ -35,6 +35,7 @@
 
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.program.Program;
 
 /**
  * @author Abyot Asalefew
@@ -76,6 +77,8 @@
 
     private Set<PatientAttributeOption> attributeOptions;
 
+    private Program program;
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -168,7 +171,7 @@
     {
         return groupBy;
     }
-    
+
     public boolean isMandatory()
     {
         return mandatory;
@@ -199,6 +202,16 @@
         this.valueType = valueType;
     }
 
+    public Program getProgram()
+    {
+        return program;
+    }
+
+    public void setProgram( Program program )
+    {
+        this.program = program;
+    }
+
     public PatientAttributeGroup getPatientAttributeGroup()
     {
         return patientAttributeGroup;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroupService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroupService.java	2011-12-14 07:33:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroupService.java	2012-03-27 01:29:30 +0000
@@ -28,6 +28,8 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.program.Program;
+
 /**
  * @author Chau Thu Tran
  * @version $Id$
@@ -47,4 +49,9 @@
     PatientAttributeGroup getPatientAttributeGroupByName( String name );
 
     Collection<PatientAttributeGroup> getAllPatientAttributeGroups();
+    
+    Collection<PatientAttributeGroup> getPatientAttributeGroups( Program program );
+    
+    Collection<PatientAttributeGroup> getPatientAttributeGroupsWithoutProgram();
+    
 }

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroupStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroupStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroupStore.java	2012-03-27 01:29:30 +0000
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2004-2012, 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.
+ */
+
+package org.hisp.dhis.patient;
+
+import java.util.Collection;
+
+import org.hisp.dhis.common.GenericNameableObjectStore;
+import org.hisp.dhis.program.Program;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $PatientAttributeGroupStore.java Mar 26, 2012 1:43:53 PM$
+ */
+public interface PatientAttributeGroupStore
+    extends GenericNameableObjectStore<PatientAttributeGroup>
+{
+    Collection<PatientAttributeGroup> get( Program program );
+
+    Collection<PatientAttributeGroup> getWithoutProgram();
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java	2010-11-12 10:28:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java	2012-03-27 01:29:30 +0000
@@ -28,6 +28,8 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.program.Program;
+
 /**
  * @author Abyot Asalefew
  * @version $Id$
@@ -50,12 +52,15 @@
 
     Collection<PatientAttribute> getPatientAttributesByValueType( String valueType );
     
-    Collection<PatientAttribute> getPatientAttributesNotGroup();
-
     Collection<PatientAttribute> getOptionalPatientAttributesWithoutGroup();
     
     Collection<PatientAttribute> getPatientAttributesByMandatory(boolean mandatory);
     
     PatientAttribute getPatientAttributeByGroupBy(boolean groupBy);
+    
+    Collection<PatientAttribute> getPatientAttributesWithoutGroup();
+    
+    Collection<PatientAttribute> getPatientAttributes( Program program, PatientAttributeGroup group );
+
 
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java	2011-11-03 01:02:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java	2012-03-27 01:29:30 +0000
@@ -30,6 +30,7 @@
 import java.util.Collection;
 
 import org.hisp.dhis.common.GenericNameableObjectStore;
+import org.hisp.dhis.program.Program;
 
 /**
  * @author Abyot Asalefew Gizaw
@@ -44,9 +45,11 @@
     
     Collection<PatientAttribute> getOptionalPatientAttributesWithoutGroup();
     
-    Collection<PatientAttribute> getPatientAttributesByMandatory(boolean mandatory);
-    
-    Collection<PatientAttribute> getPatientAttributesNotGroup();
+    Collection<PatientAttribute> getByMandatory(boolean mandatory);
+    
+    Collection<PatientAttribute> get( Program program, PatientAttributeGroup group );
+    
+    Collection<PatientAttribute> getWithoutGroup();
 
     PatientAttribute getByGroupBy( boolean groupBy );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeStore.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeStore.java	2012-03-27 01:29:30 +0000
@@ -5,11 +5,12 @@
 import org.hisp.dhis.common.GenericNameableObjectStore;
 import org.hisp.dhis.program.Program;
 
-public interface PatientIdentifierTypeStore extends GenericNameableObjectStore<PatientIdentifierType>
+public interface PatientIdentifierTypeStore
+    extends GenericNameableObjectStore<PatientIdentifierType>
 {
     Collection<PatientIdentifierType> get( boolean mandatory );
-    
+
     Collection<PatientIdentifierType> get( Program program );
-    
+
     Collection<PatientIdentifierType> getWithoutProgram();
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java	2011-12-07 02:20:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java	2012-03-27 01:29:30 +0000
@@ -33,6 +33,7 @@
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeOption;
+import org.hisp.dhis.program.Program;
 
 /**
  * @author Abyot Asalefew
@@ -86,4 +87,8 @@
     
     void updatePatientAttributeValues( PatientAttributeOption patientAttributeOption);
     
+    Collection<PatientAttributeValue> getPatientAttributeValues( Patient patient, Program program );
+    
+    Collection<PatientAttributeValue> getPatientAttributeValuesWithoutProgram( Patient patient );
+    
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueStore.java	2011-12-07 02:20:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueStore.java	2012-03-27 01:29:30 +0000
@@ -33,6 +33,7 @@
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeOption;
+import org.hisp.dhis.program.Program;
 
 /**
  * @author Abyot Asalefew
@@ -74,4 +75,8 @@
     int countSearchPatients( List<Integer> patientAttributeIds, List<String> searchTexts );
     
     void updatePatientAttributeValues( PatientAttributeOption patientAttributeOption);
+
+    Collection<PatientAttributeValue> get( Patient patient, Program program );
+    
+    Collection<PatientAttributeValue> getWithoutProgram( Patient patient );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeGroupService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeGroupService.java	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeGroupService.java	2012-03-27 01:29:30 +0000
@@ -28,7 +28,7 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.program.Program;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -43,10 +43,9 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private GenericIdentifiableObjectStore<PatientAttributeGroup> patientAttributeGroupStore;
+    private PatientAttributeGroupStore patientAttributeGroupStore;
 
-    public void setPatientAttributeGroupStore(
-        GenericIdentifiableObjectStore<PatientAttributeGroup> patientAttributeGroupStore )
+    public void setPatientAttributeGroupStore( PatientAttributeGroupStore patientAttributeGroupStore )
     {
         this.patientAttributeGroupStore = patientAttributeGroupStore;
     }
@@ -84,4 +83,16 @@
     {
         return patientAttributeGroupStore.getAll();
     }
+
+    @Override
+    public Collection<PatientAttributeGroup> getPatientAttributeGroups( Program program )
+    {
+        return patientAttributeGroupStore.get( program );
+    }
+
+    @Override
+    public Collection<PatientAttributeGroup> getPatientAttributeGroupsWithoutProgram()
+    {
+        return patientAttributeGroupStore.getWithoutProgram();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java	2012-03-27 01:29:30 +0000
@@ -28,6 +28,7 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.program.Program;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -100,10 +101,17 @@
 
     public Collection<PatientAttribute> getPatientAttributesByMandatory( boolean mandatory )
     {
-        return patientAttributeStore.getPatientAttributesByMandatory( mandatory );
+        return patientAttributeStore.getByMandatory( mandatory );
+    }
+
+    public Collection<PatientAttribute> getPatientAttributes( Program program, PatientAttributeGroup group )
+    {
+        return patientAttributeStore.get( program, group );
     }
     
-    public Collection<PatientAttribute> getPatientAttributesNotGroup(){
-        return patientAttributeStore.getPatientAttributesNotGroup();
+    public Collection<PatientAttribute> getPatientAttributesWithoutGroup()
+    {
+        return patientAttributeStore.getWithoutGroup();
     }
+
 }

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeGroupStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeGroupStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeGroupStore.java	2012-03-27 01:29:30 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2004-2012, 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.
+ */
+
+package org.hisp.dhis.patient.hibernate;
+
+import java.util.Collection;
+
+import org.hibernate.Criteria;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.patient.PatientAttributeGroup;
+import org.hisp.dhis.patient.PatientAttributeGroupStore;
+import org.hisp.dhis.program.Program;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $HibernatePatientAttributeGroupStore.java Mar 26, 2012 1:45:26 PM$
+ */
+public class HibernatePatientAttributeGroupStore
+    extends HibernateGenericStore<PatientAttributeGroup>
+    implements PatientAttributeGroupStore
+{
+
+    @SuppressWarnings( "unchecked" )
+    @Override
+    public Collection<PatientAttributeGroup> get( Program program )
+    {
+        return getCriteria().setResultTransformer( Criteria.DISTINCT_ROOT_ENTITY ).createAlias( "attributes",
+            "attribute" ).add( Restrictions.eq( "attribute.program", program ) ).list();
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Override
+    public Collection<PatientAttributeGroup> getWithoutProgram()
+    {
+        return getCriteria().createAlias( "attributes", "attribute" ).add( Restrictions.isNull( "attribute.program" ) )
+            .list();
+    }
+
+}

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java	2012-03-27 01:29:30 +0000
@@ -29,10 +29,13 @@
 
 import java.util.Collection;
 
+import org.hibernate.Criteria;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.hibernate.HibernateGenericStore;
 import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeGroup;
 import org.hisp.dhis.patient.PatientAttributeStore;
+import org.hisp.dhis.program.Program;
 
 /**
  * @author Abyot Asalefew Gizaw
@@ -49,7 +52,7 @@
     }
 
     @SuppressWarnings( "unchecked" )
-    public Collection<PatientAttribute> getPatientAttributesByMandatory( boolean mandatory )
+    public Collection<PatientAttribute> getByMandatory( boolean mandatory )
     {
         return getCriteria( Restrictions.eq( "mandatory", mandatory ) ).list();
     }
@@ -61,15 +64,42 @@
             .add( Restrictions.eq( "mandatory", false ) ).list();
     }
 
-    @SuppressWarnings( "unchecked" )
-    public Collection<PatientAttribute> getPatientAttributesNotGroup()
-    {
-        return getCriteria( Restrictions.isNull( "patientAttributeGroup" ) ).list();
-    }
-
     public PatientAttribute getByGroupBy( boolean groupBy )
     {
         return (PatientAttribute) getCriteria( Restrictions.eq( "groupBy", groupBy ) ).uniqueResult();
     }
 
+    @SuppressWarnings("unchecked")
+    @Override
+    public Collection<PatientAttribute> get( Program program, PatientAttributeGroup group )
+    {
+        Criteria criteria = getCriteria();
+
+        if ( program == null )
+        {
+            criteria.add( Restrictions.isNull( "program" ) );
+        }
+        else
+        {
+            criteria.add( Restrictions.eq( "program", program ) );
+        }
+
+        if ( group == null )
+        {
+            criteria.add( Restrictions.isNull( "patientAttributeGroup" ) );
+        }
+        else
+        {
+            criteria.add( Restrictions.eq( "patientAttributeGroup", group ) );
+        }
+        
+        return criteria.list();
+    }
+
+    @SuppressWarnings("unchecked")
+    public Collection<PatientAttribute> getWithoutGroup()
+    {
+        return getCriteria( Restrictions.isNull( "patientAttributeGroup" ) ).list();
+    }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java	2011-12-07 02:20:11 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java	2012-03-27 01:29:30 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeOption;
+import org.hisp.dhis.program.Program;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -245,4 +246,14 @@
     {
         patientAttributeValueStore.updatePatientAttributeValues( patientAttributeOption );
     }
+    
+    public Collection<PatientAttributeValue> getPatientAttributeValues( Patient patient, Program program )
+    {
+        return patientAttributeValueStore.get( patient, program );
+    }
+    
+    public Collection<PatientAttributeValue> getPatientAttributeValuesWithoutProgram( Patient patient )
+    {
+        return patientAttributeValueStore.getWithoutProgram( patient );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java	2012-02-11 13:58:02 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java	2012-03-27 01:29:30 +0000
@@ -38,6 +38,7 @@
 import org.hisp.dhis.patient.PatientAttributeOption;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueStore;
+import org.hisp.dhis.program.Program;
 import org.springframework.jdbc.core.JdbcTemplate;
 
 /**
@@ -206,6 +207,35 @@
         return (rs != null) ? rs.intValue() : 0;
     }
 
+    public void updatePatientAttributeValues( PatientAttributeOption patientAttributeOption )
+    {
+        String sql = "UPDATE patientattributevalue SET value='" + patientAttributeOption.getName()
+            + "' WHERE patientattributeoptionid='" + patientAttributeOption.getId() + "'";
+
+        jdbcTemplate.execute( sql );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public Collection<PatientAttributeValue> get( Patient patient, Program program )
+    {
+        String hql = "SELECT pav FROM PatientAttributeValue as pav WHERE pav.patient=:patient and pav.patientAttribute.program=:program";
+        Query query = getQuery( hql );
+        query.setEntity( "patient", patient );
+        query.setEntity( "program", program );
+
+        return query.list();
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public Collection<PatientAttributeValue> getWithoutProgram( Patient patient )
+    {
+        String hql = "SELECT pav FROM PatientAttributeValue as pav WHERE pav.patient=:patient and pav.patientAttribute.program IS NULL";
+        Query query = getQuery( hql );
+        query.setEntity( "patient", patient );
+
+        return query.list();
+    }
+
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
@@ -288,11 +318,4 @@
 
     }
 
-    public void updatePatientAttributeValues( PatientAttributeOption patientAttributeOption )
-    {
-        String sql = "UPDATE patientattributevalue SET value='" + patientAttributeOption.getName()
-            + "' WHERE patientattributeoptionid='" + patientAttributeOption.getId() + "'";
-        
-        jdbcTemplate.execute( sql );
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-03-23 05:58:50 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-03-27 01:29:30 +0000
@@ -108,7 +108,7 @@
 	</bean>
 
 	<bean id="org.hisp.dhis.patient.PatientAttributeGroupStore"
-		class="org.hisp.dhis.hibernate.HibernateGenericStore">
+		class="org.hisp.dhis.patient.hibernate.HibernatePatientAttributeGroupStore">
 		<property name="clazz" value="org.hisp.dhis.patient.PatientAttributeGroup" />
 		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAttribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAttribute.hbm.xml	2012-02-27 01:07:19 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAttribute.hbm.xml	2012-03-27 01:29:30 +0000
@@ -34,5 +34,7 @@
       <one-to-many class="org.hisp.dhis.patient.PatientAttributeOption" />
     </set>
 
+    <many-to-one name="program" class="org.hisp.dhis.program.Program" column="programid" foreign-key="fk_patientattribute_program" />
+
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2012-03-27 01:29:30 +0000
@@ -103,9 +103,9 @@
     private String childContactType;
 
     private String systemIdentifier;
-    
+
     private Patient representative;
-    
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -115,6 +115,12 @@
     {
         patient = patientService.getPatient( id );
 
+        programs = programService.getAllPrograms();
+        
+        // -------------------------------------------------------------------------
+        // Get identifier
+        // -------------------------------------------------------------------------
+
         patientIdentifier = patientIdentifierService.getPatientIdentifier( patient );
 
         identifierTypes = patientIdentifierTypeService.getPatientIdentifierTypesWithoutProgram();
@@ -151,13 +157,18 @@
             }
         }
 
-        for ( PatientAttribute patientAttribute : patient.getAttributes() )
-        {
-            patientAttributeValueMap.put( patientAttribute.getId(), PatientAttributeValue.UNKNOWN );
-        }
-
+        // -------------------------------------------------------------------------
+        // Get patient-attribute values
+        // -------------------------------------------------------------------------
+
+        attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
+            .getPatientAttributeGroupsWithoutProgram() );
+        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
+
+        noGroupAttributes = patientAttributeService.getPatientAttributes( null, null );
+        
         Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
-            .getPatientAttributeValues( patient );
+            .getPatientAttributeValuesWithoutProgram( patient );
 
         for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
         {
@@ -174,14 +185,6 @@
             }
         }
 
-        programs = programService.getAllPrograms();
-
-        noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup();
-
-        attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
-            .getAllPatientAttributeGroups() );
-        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
-
         return SUCCESS;
 
     }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2012-03-27 01:29:30 +0000
@@ -28,15 +28,24 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeGroup;
+import org.hisp.dhis.patient.PatientAttributeGroupService;
+import org.hisp.dhis.patient.PatientAttributeService;
 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.patient.PatientService;
+import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
@@ -66,6 +75,12 @@
 
     private PatientIdentifierService patientIdentifierService;
 
+    private PatientAttributeService patientAttributeService;
+
+    private PatientAttributeGroupService patientAttributeGroupService;
+
+    private PatientAttributeValueService patientAttributeValueService;
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -86,6 +101,12 @@
 
     private Collection<PatientIdentifierType> identifierTypes;
 
+    private Collection<PatientAttribute> noGroupAttributes;
+
+    private List<PatientAttributeGroup> attributeGroups;
+
+    private Map<Integer, String> patientAttributeValueMap = new HashMap<Integer, String>();
+
     // -------------------------------------------------------------------------
     // Getters/Setters
     // -------------------------------------------------------------------------
@@ -95,6 +116,36 @@
         this.patientService = patientService;
     }
 
+    public Collection<PatientAttribute> getNoGroupAttributes()
+    {
+        return noGroupAttributes;
+    }
+
+    public List<PatientAttributeGroup> getAttributeGroups()
+    {
+        return attributeGroups;
+    }
+
+    public Map<Integer, String> getPatientAttributeValueMap()
+    {
+        return patientAttributeValueMap;
+    }
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
+    public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService )
+    {
+        this.patientAttributeGroupService = patientAttributeGroupService;
+    }
+
+    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
+    {
+        this.patientAttributeValueService = patientAttributeValueService;
+    }
+
     public Map<Integer, String> getIdentiferMap()
     {
         return identiferMap;
@@ -186,15 +237,46 @@
             identifierTypes = identifierTypeService.getPatientIdentifierTypes( program );
             identiferMap = new HashMap<Integer, String>();
 
-            Collection<PatientIdentifier> patientIdentifiers = patientIdentifierService.getPatientIdentifiers(
-                identifierTypes, patient );
-
-            for ( PatientIdentifier identifier : patientIdentifiers )
-            {
-                identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
+            if ( identifierTypes != null && identifierTypes.size() > 0 )
+            {
+                Collection<PatientIdentifier> patientIdentifiers = patientIdentifierService.getPatientIdentifiers(
+                    identifierTypes, patient );
+
+                for ( PatientIdentifier identifier : patientIdentifiers )
+                {
+                    identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
+                }
+            }
+
+            // ---------------------------------------------------------------------
+            // Load patient-attributes of the selected program
+            // ---------------------------------------------------------------------
+
+            attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
+                .getPatientAttributeGroups( program ) );
+            Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
+
+            noGroupAttributes = patientAttributeService.getPatientAttributes( program, null );
+
+            Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
+                .getPatientAttributeValues( patient, program );
+
+            for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
+            {
+                if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute()
+                    .getValueType() ) )
+                {
+                    patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
+                        patientAttributeValue.getPatientAttributeOption().getName() );
+                }
+                else
+                {
+                    patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
+                        patientAttributeValue.getValue() );
+                }
             }
         }
-
+        
         return SUCCESS;
     }
 }

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java	2012-03-27 01:29:30 +0000
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2004-2012, 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.
+ */
+
+package org.hisp.dhis.caseentry.action.patient;
+
+import org.apache.commons.lang.math.NumberUtils;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeOption;
+import org.hisp.dhis.patient.PatientAttributeOptionService;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $SavePatientAttributeValueAction.java Mar 26, 2012 4:06:46 PM$
+ */
+public class SavePatientAttributeValueAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PatientService patientService;
+
+    private PatientAttributeValueService patientAttributeValueService;
+
+    private PatientAttributeService patientAttributeService;
+
+    private PatientAttributeOptionService patientAttributeOptionService;
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private Integer patientId;
+
+    private Integer attributeId;
+
+    private String value;
+
+    private Integer statusCode;
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
+
+    public Integer getStatusCode()
+    {
+        return statusCode;
+    }
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
+    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
+    {
+        this.patientAttributeValueService = patientAttributeValueService;
+    }
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
+    public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService )
+    {
+        this.patientAttributeOptionService = patientAttributeOptionService;
+    }
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
+    }
+
+    public void setAttributeId( Integer attributeId )
+    {
+        this.attributeId = attributeId;
+    }
+
+    public void setValue( String value )
+    {
+        this.value = value;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        Patient patient = patientService.getPatient( patientId );
+        
+        PatientAttribute attribute = patientAttributeService.getPatientAttribute( attributeId );
+        
+        if ( value != null && value.trim().length() == 0 )
+        {
+            value = null;
+        }
+
+        PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient,
+            attribute );
+
+        if ( value != null )
+        {
+            attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, attribute );
+
+            if ( !patient.getAttributes().contains( attribute ) )
+            {
+                patient.getAttributes().add( attribute );
+            }
+
+            if ( attributeValue == null )
+            {
+                attributeValue = new PatientAttributeValue();
+                attributeValue.setPatient( patient );
+                attributeValue.setPatientAttribute( attribute );
+                if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
+                {
+                    PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) );
+                    if ( option != null )
+                    {
+                        attributeValue.setPatientAttributeOption( option );
+                        attributeValue.setValue( option.getName() );
+                    }
+                    else
+                    {
+                        // This option was deleted ???
+                    }
+                }
+                else
+                {
+                    attributeValue.setValue( value.trim() );
+                }
+                patientAttributeValueService.savePatientAttributeValue( attributeValue );
+            }
+            else
+            {
+                if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
+                {
+                    PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) );
+                    if ( option != null )
+                    {
+                        attributeValue.setPatientAttributeOption( option );
+                        attributeValue.setValue( option.getName() );
+                    }
+                    else
+                    {
+                        // This option was deleted ???
+                    }
+                }
+                else
+                {
+                    attributeValue.setValue( value.trim() );
+                }
+                patientAttributeValueService.updatePatientAttributeValue( attributeValue );
+            }
+        }
+        else if ( attributeValue != null )
+        {
+            patientAttributeValueService.deletePatientAttributeValue( attributeValue );
+            patient.getAttributes().remove( attribute );
+            patientService.updatePatient( patient );
+        }
+        
+        statusCode = 0;
+
+        return SUCCESS;
+    }
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java	2012-03-27 01:29:30 +0000
@@ -65,7 +65,7 @@
     private String value;
 
     private Integer statusCode;
-    
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -116,26 +116,33 @@
         Patient patient = patientService.getPatient( patientId );
         PatientIdentifierType identifierType = identifierTypeService.getPatientIdentifierType( identifierTypeId );
 
+        if ( value != null && value.trim().length() == 0 )
+        {
+            value = null;
+        }
+
         PatientIdentifier patientIdentifier = patientIdentifierService.getPatientIdentifier( identifierType, patient );
 
-        if ( patientIdentifier == null )
-        {
-            patientIdentifier = new PatientIdentifier();
-            patientIdentifier.setIdentifierType( identifierType );
-            patientIdentifier.setPatient( patient );
-            patientIdentifier.setIdentifier( value.trim() );
-        }
-        else
-        {
-            patientIdentifier.setIdentifier( value.trim() );
-        }
-        
-        patient.getIdentifiers().add( patientIdentifier );
+        if ( value != null )
+        {
+            if ( patientIdentifier == null )
+            {
+                patientIdentifier = new PatientIdentifier();
+                patientIdentifier.setIdentifierType( identifierType );
+                patientIdentifier.setPatient( patient );
+            }
 
-        patientService.updatePatient( patient );
+            patientIdentifier.setIdentifier( value.trim() );
+            patient.getIdentifiers().add( patientIdentifier );
+            patientService.updatePatient( patient );
+        }
+        else if ( patientIdentifier != null )
+        {
+            patientIdentifierService.deletePatientIdentifier( patientIdentifier );
+        }
 
         statusCode = 0;
-        
+
         return SUCCESS;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java	2012-03-27 01:29:30 +0000
@@ -28,17 +28,26 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeGroup;
+import org.hisp.dhis.patient.PatientAttributeGroupService;
+import org.hisp.dhis.patient.PatientAttributeService;
 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.patient.PatientService;
+import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
@@ -118,6 +127,12 @@
 
     private PatientIdentifierTypeService identifierTypeService;
 
+    private PatientAttributeService patientAttributeService;
+
+    private PatientAttributeGroupService patientAttributeGroupService;
+
+    private PatientAttributeValueService patientAttributeValueService;
+    
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -128,9 +143,24 @@
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
-    
+
     private Collection<PatientIdentifierType> identifierTypes;
 
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
+    public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService )
+    {
+        this.patientAttributeGroupService = patientAttributeGroupService;
+    }
+
+    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
+    {
+        this.patientAttributeValueService = patientAttributeValueService;
+    }
+
     private Map<Integer, String> identiferMap;
 
     private Integer patientId;
@@ -189,6 +219,27 @@
         return programStageInstances;
     }
 
+    private Collection<PatientAttribute> noGroupAttributes;
+
+    public Collection<PatientAttribute> getNoGroupAttributes()
+    {
+        return noGroupAttributes;
+    }
+
+    private List<PatientAttributeGroup> attributeGroups;
+
+    public List<PatientAttributeGroup> getAttributeGroups()
+    {
+        return attributeGroups;
+    }
+
+    private Map<Integer, String> patientAttributeValueMap = new HashMap<Integer, String>();
+
+    public Map<Integer, String> getPatientAttributeValueMap()
+    {
+        return patientAttributeValueMap;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -275,6 +326,33 @@
             identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
         }
 
+        // ---------------------------------------------------------------------
+        // Load patient-attributes of the selected program
+        // ---------------------------------------------------------------------
+
+        attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
+            .getPatientAttributeGroups( program ) );
+        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
+
+        noGroupAttributes = patientAttributeService.getPatientAttributes( program, null );
+
+        Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
+            .getPatientAttributeValues( patient, program );
+
+        for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
+        {
+            if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute()
+                .getValueType() ) )
+            {
+                patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
+                    patientAttributeValue.getPatientAttributeOption().getName() );
+            }
+            else
+            {
+                patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
+                    patientAttributeValue.getValue() );
+            }
+        }
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java	2012-03-27 01:29:30 +0000
@@ -107,10 +107,10 @@
     {
         identifierTypes = patientIdentifierTypeService.getPatientIdentifierTypesWithoutProgram();
 
-        noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup();
+        noGroupAttributes = patientAttributeService.getPatientAttributes( null, null );
 
         attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
-            .getAllPatientAttributeGroups() );
+            .getPatientAttributeGroupsWithoutProgram() );
         Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
 
         organisationUnit = selectionManager.getSelectedOrganisationUnit();

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java	2012-03-27 01:29:30 +0000
@@ -27,8 +27,11 @@
 
 package org.hisp.dhis.caseentry.action.patient;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.hisp.dhis.patient.Patient;
@@ -40,6 +43,7 @@
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.relationship.RelationshipType;
@@ -47,51 +51,50 @@
 
 import com.opensymphony.xwork2.Action;
 
-
 /**
  * @author Viet
- *
+ * 
  * @version $Id$
  */
-public class ShowAddRelationshipPatientAction 
+public class ShowAddRelationshipPatientAction
     implements Action
 {
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-    
+
     private PatientService patientService;
 
     private PatientAttributeService patientAttributeService;
-    
+
     private PatientAttributeGroupService patientAttributeGroupService;
-    
+
     private PatientIdentifierTypeService patientIdentifierTypeService;
-    
+
     private RelationshipTypeService relationshipTypeService;
-    
+
     private PatientAttributeValueService patientAttributeValueService;
-    
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
     private Integer id;
-    
+
     private Collection<PatientAttribute> noGroupAttributes;
-   
-    private Collection<PatientAttributeGroup> attributeGroups;
-    
+
+    private List<PatientAttributeGroup> attributeGroups;
+
     private Collection<PatientIdentifierType> identifierTypes;
-    
+
     private Collection<RelationshipType> relationshipTypes;
-    
+
     private Patient patient;
-    
+
     private Map<Integer, String> identiferMap;
-    
+
     private Map<Integer, String> attributeMap;
-    
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -99,15 +102,13 @@
     public String execute()
     {
         patient = patientService.getPatient( id.intValue() );
-    
-        identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); 
-       
-        noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup();
-        
-        attributeGroups = patientAttributeGroupService.getAllPatientAttributeGroups();
-        
+
+        identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+
+        noGroupAttributes = new ArrayList<PatientAttribute>( patientAttributeService.getPatientAttributes( null, null ) );
+
         relationshipTypes = relationshipTypeService.getAllRelationshipTypes();
-        
+
         identiferMap = new HashMap<Integer, String>();
 
         for ( PatientIdentifier identifier : patient.getIdentifiers() )
@@ -115,22 +116,38 @@
             if ( identifier.getIdentifierType() != null )
                 identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
         }
-        
-        attributeMap = new HashMap<Integer , String>();
-        
-        Collection<PatientAttributeValue> attributeValues = patientAttributeValueService.getPatientAttributeValues( patient );
-        
-        if( attributeValues != null && attributeValues.size() > 0 )
+
+        // -------------------------------------------------------------------------
+        // Get patient-attribute values
+        // -------------------------------------------------------------------------
+
+        attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
+            .getPatientAttributeGroupsWithoutProgram() );
+        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
+
+        noGroupAttributes = patientAttributeService.getPatientAttributes( null, null );
+
+        Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
+            .getPatientAttributeValuesWithoutProgram( patient );
+
+        for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
         {
-            for( PatientAttributeValue attributeValue : attributeValues )
-            {
-                attributeMap.put( attributeValue.getPatientAttribute().getId(), attributeValue.getValue() );
+            if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute()
+                .getValueType() ) )
+            {
+                attributeMap.put( patientAttributeValue.getPatientAttribute().getId(), patientAttributeValue
+                    .getPatientAttributeOption().getName() );
+            }
+            else
+            {
+                attributeMap
+                    .put( patientAttributeValue.getPatientAttribute().getId(), patientAttributeValue.getValue() );
             }
         }
-        
+
         return SUCCESS;
     }
-    
+
     // -------------------------------------------------------------------------
     // Getter/Setter
     // -------------------------------------------------------------------------
@@ -139,7 +156,7 @@
     {
         this.id = id;
     }
-    
+
     public Collection<PatientIdentifierType> getIdentifierTypes()
     {
         return identifierTypes;
@@ -149,6 +166,7 @@
     {
         return attributeGroups;
     }
+
     public Collection<PatientAttribute> getNoGroupAttributes()
     {
         return noGroupAttributes;
@@ -173,12 +191,12 @@
     {
         return identiferMap;
     }
-    
+
     public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
     {
         this.patientIdentifierTypeService = patientIdentifierTypeService;
     }
-    
+
     public void setPatientAttributeService( PatientAttributeService patientAttributeService )
     {
         this.patientAttributeService = patientAttributeService;

=== 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	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-03-27 01:29:30 +0000
@@ -610,6 +610,9 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="identifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
+		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientAttributeGroupService" ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
+		<property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
 
 	<bean
@@ -623,6 +626,9 @@
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="identifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
+		<property name="patientAttributeValueService" ref=" org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientAttributeOptionService" ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.SaveDueDateAction"
@@ -679,6 +685,16 @@
 		<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
 	</bean>
 	
+	<bean
+		id="org.hisp.dhis.caseentry.action.patient.SavePatientAttributeValueAction"
+		class="org.hisp.dhis.caseentry.action.patient.SavePatientAttributeValueAction"
+		scope="prototype">
+		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+		<property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientAttributeOptionService" ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
+	</bean>
+	
 	<!--  Relationship -->
 	
 		<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	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-03-27 01:29:30 +0000
@@ -555,7 +555,13 @@
 		
 		<action name="savePatientIdentifier"
 			class="org.hisp.dhis.caseentry.action.patient.SavePatientIdentifierAction">
-			<result name="success" type="velocity">status.vm</result>
+			<result name="success" type="velocity-xml">status.vm</result>
+			<param name="requiredAuthorities">F_PATIENT_UPDATE, F_PROGRAM_ENROLLMENT</param>
+		</action>
+		
+		<action name="savePatientAttribueValue"
+			class="org.hisp.dhis.caseentry.action.patient.SavePatientAttributeValueAction">
+			<result name="success" type="velocity-xml">status.vm</result>
 			<param name="requiredAuthorities">F_PATIENT_UPDATE, F_PROGRAM_ENROLLMENT</param>
 		</action>
 		
@@ -563,7 +569,7 @@
 
 		<action name="getPartner"
 			class="org.hisp.dhis.caseentry.action.patient.GetPartnerAction">
-			<result name="success" type="velocity">/content.vm</result>
+			<result name="success" type="velocity-xml">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/detailsPartner.vm</param>
 		</action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-03-27 01:29:30 +0000
@@ -808,25 +808,3 @@
 			input.focus();
 		});
 }
-
-
-//--------------------------------------------------------------------------------------------
-// Show selected data-recording
-//--------------------------------------------------------------------------------------------
-
-function showSelectedDataRecoding( patientId )
-{
-	showLoader();
-	hideById('searchPatientDiv');
-	hideById('dataEntryFormDiv');
-	jQuery('#dataRecordingSelectDiv').load( 'selectDataRecording.action', 
-		{
-			patientId: patientId
-		},
-		function()
-		{
-			showById('dataRecordingSelectDiv');
-			hideLoader();
-			hideById('contentDiv');
-		});
-}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js	2012-03-27 01:29:30 +0000
@@ -123,3 +123,24 @@
         showWarningMessage( message );
     }
 }
+
+//--------------------------------------------------------------------------------------------
+// Show selected data-recording
+//--------------------------------------------------------------------------------------------
+
+function showSelectedDataRecoding( patientId )
+{
+	showLoader();
+	hideById('searchPatientDiv');
+	hideById('dataEntryFormDiv');
+	jQuery('#dataRecordingSelectDiv').load( 'selectDataRecording.action', 
+		{
+			patientId: patientId
+		},
+		function()
+		{
+			showById('dataRecordingSelectDiv');
+			hideLoader();
+			hideById('contentDiv');
+		});
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-03-27 01:29:30 +0000
@@ -1,3 +1,9 @@
+var COLOR_GREEN = '#b9ffb9';
+var COLOR_YELLOW = '#fffe8c';
+var COLOR_WHITE = '#ffffff';
+var COLOR_ORANGE = '#ff6600';
+var COLOR_RED = '#ff8a8a';
+var COLOR_GREY = '#cccccc';
 
 function organisationUnitSelected( orgUnits )
 {	
@@ -765,9 +771,6 @@
 
 function DateDueSaver( programStageInstanceId_, dueDate_, resultColor_ )
 {
-	var SUCCESS = '#ccffcc';
-	var ERROR = '#ccccff';
-	
 	var programStageInstanceId = programStageInstanceId_;	
 	var dueDate = dueDate_;
 	var resultColor = resultColor_;	
@@ -800,14 +803,14 @@
 		}
 		else
 		{
-			markValue( ERROR );
+			markValue( COLOR_GREY );
 			window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
 		}
 	}
 
 	function handleHttpError( errorCode )
 	{
-		markValue( ERROR );
+		markValue( COLOR_GREY );
 		window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
 	}   
 
@@ -902,24 +905,54 @@
 	jQuery( "#" + div ).slideToggle( "fast" );
 }
 
-//--------------------------------------------------------------------------------------------
-// Show search-form
-//--------------------------------------------------------------------------------------------
-
 function savePatientIdentifier( identifierTypeId, field )
 {
-	var patientId = getFieldValue("patientId");
-	field.style.backgroundColor = '#ffffcc';
-	
-	var valueSaver = new PatientIdentifierSaver( patientId, identifierTypeId, field.value, '#ccffcc' );
-    valueSaver.save();
+	field.blur();
+	field.style.backgroundColor = COLOR_WHITE;
+	if( validateValue( "iden" + identifierTypeId ) )
+	{
+		var patientId = getFieldValue("patientId");
+		field.style.backgroundColor = COLOR_YELLOW;
+		
+		var valueSaver = new PatientIdentifierSaver( patientId, identifierTypeId, field.value, COLOR_GREEN );
+		valueSaver.save();
+	}
+	else
+	{
+		field.style.backgroundColor = COLOR_ORANGE;
+	}
+}
+
+function savePatientAttrValue( patientAttributeId, field )
+{
+	field.blur();
+	field.style.backgroundColor = COLOR_WHITE;
+	if( validateValue( "attr" + patientAttributeId ) )
+	{
+		var patientId = getFieldValue("patientId");
+		field.style.backgroundColor = COLOR_YELLOW;
+		
+		var valueSaver = new PatientAttributeValueSaver( patientId, patientAttributeId, field.value, COLOR_GREEN );
+		valueSaver.save();
+	}
+	else
+	{
+		field.style.backgroundColor = COLOR_ORANGE;
+	}
+}
+
+//--------------------------------------------------------------------------------------------
+// For saving patient-identifier and patient-attribute-value
+//--------------------------------------------------------------------------------------------
+
+function validateValue( spanErrorId )
+{
+	var classes = jQuery( 'span[for=' + spanErrorId + ']' ).attr('class');
+	return ( classes == "error") ? false : true;
 }
 
 function PatientIdentifierSaver( patientId_, identifierTypeId_, value_, resultColor_  )
 {
-    var SUCCESS = '#ccffcc';
-    var ERROR = '#ccccff';
-	
     var patientId = patientId_;
 	var identifierTypeId = identifierTypeId_;
 	var value = value_;
@@ -957,7 +990,7 @@
         {
             if(value!="")
             {
-                markValue( ERROR );
+                markValue( COLOR_GREY );
                 window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
             }
             else
@@ -969,7 +1002,7 @@
  
     function handleHttpError( errorCode )
     {
-        markValue( ERROR );
+        markValue( COLOR_GREY );
         window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
     }
  
@@ -980,3 +1013,88 @@
         element.style.backgroundColor = color;
     }
 }
+	
+function PatientAttributeValueSaver( patientId_, attributeId_, value_, resultColor_  )
+{
+    var patientId = patientId_;
+	var attributeId = attributeId_;
+	var value = value_;
+    var resultColor = resultColor_;
+	
+    this.save = function()
+    {
+		var params  = 'patientId=' + patientId;
+			params += '&attributeId=' + attributeId;
+			params += '&value=' + value;
+		
+		$.ajax({
+			   url: "savePatientAttribueValue.action",
+			   data: params,
+			   type: "POST",
+			   dataType: "xml",
+			   success: function(result){
+					handleResponse (result);
+			   },
+			   error: function(request,status,errorThrown) {
+					handleHttpError (request);
+			   }
+			});
+    };
+ 
+    function handleResponse( rootElement )
+    {
+        var codeElement = rootElement.getElementsByTagName( 'code' )[0];
+        var code = parseInt( codeElement.firstChild.nodeValue );
+        if ( code == 0 )
+        {
+            markValue( resultColor );
+        }
+        else
+        {
+            if(value!="")
+            {
+                markValue( COLOR_GREY );
+                window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
+            }
+            else
+            {
+                markValue( resultColor );
+            }
+        }
+    }
+ 
+    function handleHttpError( errorCode )
+    {
+        markValue( COLOR_GREY );
+        window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
+    }
+ 
+    function markValue( color )
+    {
+		var programStageId = getFieldValue('programStageId');
+        var element = byId( 'attr' + attributeId );
+        element.style.backgroundColor = color;
+    }
+}
+
+//--------------------------------------------------------------------------------------------
+// Show selected data-recording
+//--------------------------------------------------------------------------------------------
+
+function showSelectedDataRecoding( patientId )
+{
+	showLoader();
+	hideById('searchPatientDiv');
+	hideById('dataEntryFormDiv');
+	jQuery('#dataRecordingSelectDiv').load( 'selectDataRecording.action', 
+		{
+			patientId: patientId
+		},
+		function()
+		{
+			jQuery('#dataRecordingSelectDiv [id=patientInfoDiv]').hide();
+			showById('dataRecordingSelectDiv');
+			hideLoader();
+			hideById('contentDiv');
+		});
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2012-03-09 01:56:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2012-03-27 01:29:30 +0000
@@ -127,4 +127,30 @@
 		tableSorter( 'patientList' );
 	});
 	var i18n_patient_details_and_history = '$encoder.jsEscape( $i18n.getString( "patient_details_and_history" ) , "'" )';
+	
+	var i18n_id = '$encoder.jsEscape( $i18n.getString( "id" ), "'")';
+	var i18n_full_name = '$encoder.jsEscape( $i18n.getString( "full_name" ), "'")';
+	var i18n_gender = '$encoder.jsEscape( $i18n.getString( "gender" ), "'")';
+	var i18n_dob_type = '$encoder.jsEscape( $i18n.getString( "dob_type" ), "'")';
+	var i18n_date_of_birth = '$encoder.jsEscape( $i18n.getString( "date_of_birth" ), "'")';
+	var i18n_blood_group = '$encoder.jsEscape( $i18n.getString( "blood_group" ), "'")';
+	var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ), "'")';
+	var i18n_select = '[' + '$encoder.jsEscape( $i18n.getString( "select" ), "'")' + ']';
+	var i18n_program_stages_history_plan = '$encoder.jsEscape( $i18n.getString( "program_stages_history_plan" ) , "'")';	
+	var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
+	var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
+	var i18n_value_must_positive_integer = '$encoder.jsEscape( $i18n.getString( "value_must_positive_integer" ) , "'")';
+	var i18n_value_must_negative_integer = '$encoder.jsEscape( $i18n.getString( "value_must_negative_integer" ) , "'")';
+    var i18n_invalid_date = '$encoder.jsEscape( $i18n.getString( "invalid_date" ) , "'")' + ".\n " + '$encoder.jsEscape( $i18n.getString( "format_date" ) , "'")' + " '" + dateFormat.replace('yy', 'yyyy') + " '" ; 
+    var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
+    var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
+    var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")';
+    var i18n_complete_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_confirm_message" ) , "'")';
+    var i18n_error_required_field = '$encoder.jsEscape( $i18n.getString( "error_required_field" ) , "'")';
+	var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
+	var i18n_date_is_greater_then_or_equals_due_date = '$encoder.jsEscape( $i18n.getString( "date_is_greater_then_or_equals_due_date" ) , "'")';	
+	var i18n_program_stage = '$encoder.jsEscape( $i18n.getString( "program_stage" ) , "'")';
+    var i18n_scheduled_for = '$encoder.jsEscape( $i18n.getString( "scheduled_for" ) , "'")';
+	var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'")';
+	
 </script>

=== 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	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2012-03-27 01:29:30 +0000
@@ -1,14 +1,17 @@
 <hr>
+<form id='programEnrollmentInforForm' name='programEnrollmentInforForm' action='#' method="POST" >
 <!-- IDENTIFIERS -->
-#if( $identifierTypes.size() > 0)
+#if( $identifierTypes.size() > 0 || $noGroupAttributes.size() > 0 || $attributeGroups.size() > 0 )
 	<h3>$i18n.getString('patient_identifier_and_attributes') <img src='../images/down.png' onclick='toogleDiv( "enrollmentInforDiv" );'></h3>
+	
 	<table class='mainPageTable' id='enrollmentInforDiv' name='enrollmentInforDiv' >
 		<col id="stageCol">    
 		<col id="entryCol">    
+		#if( $identifierTypes.size() > 0 )
 		<tr>
-			<th>$i18n.getString( "patient_identifier" )</th>                   
-			<th>$i18n.getString( "value" )</th>        
+			<th colspan='2'>$i18n.getString( "patient_identifier" )</th> 
 		</tr>
+		#end
 		
 		#set( $tabIndex = 1 )
 		#set( $mark = false )
@@ -17,12 +20,93 @@
 			<tr #alternate( $mark )>
 				<td class='text-column'><label>$identifierType.name #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 }}" onchange='savePatientIdentifier( $identifierType.id, this);' onkeypress="return keyPress(event, this)" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" /></td>
+					<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 }}" onchange='savePatientIdentifier( $identifierType.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" /></td>
 			</tr>
-		#set( $tabIndex = $tabIndex + 1 )
-		#set( $mark = !$mark  )
-		#end
-	</table>
+			#set( $tabIndex = $tabIndex + 1 )
+			#set( $mark = !$mark  )
+		#end
+
+	<!-- ATTRIBUTES IN GROUPS -->
+	#set( $mark = false )
+	#foreach ($attributeGroup in $attributeGroups )
+		<tr><td>&nbsp;</td></tr>	
+		<tr><th colspan="2" class="heading-column">$attributeGroup.name</th></tr>
+		#foreach($attribute in $attributeGroup.attributes)
+			#if( $!attribute.program )
+				#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
+				<tr #alternate( $mark )>
+					<td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
+					<td class="input-column" >
+						#if( $attribute.valueType == "YES/NO" )
+							<select id="attr$attribute.id" name="attr$attribute.id" onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >              
+								<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" class=' #validate( "default"  $attribute.mandatory )'  onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
+							<script type="text/javascript">
+								datePickerValid( 'attr$attribute.id' );
+							</script>                 
+						#elseif( $attribute.valueType == "COMBO" )
+							<select  id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
+								 <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 }}"  onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" > 
+						#end
+					</td>		
+				</tr>
+			#end
+			#set( $tabIndex = $tabIndex + 1 )
+			#set( $mark = !$mark  )
+		#end
+	#end
+	<tr><td>&nbsp;</td></tr>
+
+	<!-- ATTRIBUTES NOT IN GROUPS -->
+
+	#if ( $noGroupAttributes && $noGroupAttributes.size() > 0) 	
+		<tr><th colspan="2" class="heading-column">$i18n.getString( "Other details" )</th></tr>
+		#set( $mark = false )
+		#foreach($attribute in $noGroupAttributes )
+			#if( $attribute.program )
+				#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
+				<tr #alternate( $mark )>
+					<td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
+					<td class="input-column" >
+						#if( $attribute.valueType == "YES/NO" )
+							<select id="attr$attribute.id"  name="attr$attribute.id" onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex">              
+								<option value="">[$i18n.getString( "please_select" )]</option>
+								<option value="true" #if( $attributeValue ) selected="selected" #end>$i18n.getString( "yes" )</option>
+								<option value="false" #if( !$attributeValue ) 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" class=' #validate( "default"  $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex">
+							<script type="text/javascript">
+								datePickerValid( 'attr$attribute.id' );
+							</script>                    
+						#elseif( $attribute.valueType == "COMBO" )
+							<select  id="attr$attribute.id"  name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex">
+								 <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 }}" onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
+						#end
+					</td>		
+				</tr>
+			#end
+			#set( $tabIndex = $tabIndex + 1 )
+			#set( $mark = !$mark  )
+		#end
+	#end
+</table>
 #end
 
 <!-- Program-stage-instance list -->
@@ -42,9 +126,7 @@
 	#set( $rowCount = 0 )
 	#set( $mark = false )
 	#set( $tabIndex = 1 )
-	
 	#foreach( $programStageInstance in $programStageInstances )
-	
 		#set( $rowCount = $rowCount + 1 )   
 		<tr #alternate( $mark ) >
 			##rowCount
@@ -70,9 +152,17 @@
 	#end
 	</table>
 #end
-
+<input type='submit' value='sfda' class='hidden'>
+</form>
 
 <script type="text/javascript">
+	
+	jQuery(document).ready(	function(){
+		validation( 'programEnrollmentInforForm', function(form){
+			return false;
+		});	
+	});
+		
 	byId('enrollBtn').value = i18n_update;
 	setInnerHTML('enrollmentDateDescription', "$!program.dateOfEnrollmentDescription" );
 	setInnerHTML('dateOfIncidentDescription', "$!program.dateOfIncidentDescription" );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm	2012-03-27 01:29:30 +0000
@@ -80,9 +80,9 @@
                 	<td colspan='3'><span id='message'></span></td>
                 </tr>
 			</table>
+			</form>
 			
 			<div id='programEnrollmentDiv' class='hidden'></div>
-			</form>
 		</div>
 
 		<!-- register-event TAB -->
@@ -104,7 +104,7 @@
 			
 			datePickerInRange( 'dateOfIncident' , 'enrollmentDate' );
 		}); 
-	
+		
 	jQuery("#tabs").tabs();
 	datePickerValid( 'enrollmentDate' );
 	datePickerValid( 'dateOfIncident' );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm	2012-02-28 03:44:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm	2012-03-27 01:29:30 +0000
@@ -187,12 +187,14 @@
 		<!--IDENTIFIERS -->
 		<tr><th colspan="2" class="heading-column">$i18n.getString("patient_identifiers")</th></tr>
 		#foreach ($identifierType in $identifierTypes)
-		#set( $identifier = "" )
-		#set( $identifier = $identiferMap.get( $identifierType.id ) )
-		<tr>
-			<td class='text-column'><label for="bloodGroup">$identifierType.name #if($identifierType.mandatory)<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" data="{related:$identifierType.related}" #if($identifierType.related && $!patient.underAge) disabled="disabled" #end 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 }}" /></td>	
-		</tr>
+			#if( $identifierType.program )
+			#else
+				#set( $identifier = $identiferMap.get( $identifierType.id ) )
+				<tr>
+					<td class='text-column'><label for="bloodGroup">$identifierType.name #if($identifierType.mandatory)<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" data="{related:$identifierType.related}" #if($identifierType.related && $!patient.underAge) disabled="disabled" #end 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 }}" /></td>	
+				</tr>
+			#end
 		#end
 		<tr><td>&nbsp;</td></tr>
 	#end
@@ -202,8 +204,8 @@
 		<tr><td>&nbsp;</td></tr>	
 		<tr><th colspan="2" class="heading-column">$attributeGroup.name</th></tr>
 		#foreach($attribute in $attributeGroup.attributes)
-			#if($!attribute)
-				#set( $attributeValue = "" )
+			#if( $attribute.program )
+			#else
 				#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
 				<tr>
 					<td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientAttribute.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientAttribute.vm	2011-10-04 07:27:50 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientAttribute.vm	2012-03-27 01:29:30 +0000
@@ -5,6 +5,7 @@
 	"description": "$!encoder.jsonEncode( ${patientAttribute.description} )",
 	"mandatory":  "$!{patientAttribute.mandatory}",
 	"inheritable": "$!{patientAttribute.inheritable}",
-	"valueType": "$!encoder.jsonEncode( ${patientAttribute.valueType} )"
+	"valueType": "$!encoder.jsonEncode( ${patientAttribute.valueType} )",
+	"program": "$!encoder.jsonEncode( ${patientAttribute.program.name} )"
   }
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/AddPatientAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/AddPatientAttributeAction.java	2010-12-10 05:57:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/AddPatientAttributeAction.java	2012-03-27 01:29:30 +0000
@@ -33,6 +33,8 @@
 import org.hisp.dhis.patient.PatientAttributeOption;
 import org.hisp.dhis.patient.PatientAttributeOptionService;
 import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -61,6 +63,13 @@
         this.patientAttributeOptionService = patientAttributeOptionService;
     }
 
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -121,6 +130,13 @@
         this.groupBy = groupBy;
     }
 
+    private Integer programId;
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -135,8 +151,11 @@
         patientAttribute.setValueType( valueType );
         patientAttribute.setMandatory( mandatory );
         patientAttribute.setInheritable( inheritable );
-        patientAttribute.setNoChars (noChars);
-        
+        patientAttribute.setNoChars( noChars );
+
+        Program program = (programId != null) ? programService.getProgram( programId ) : null;
+        patientAttribute.setProgram( program );
+
         patientAttribute.setGroupBy( groupBy );
         if ( groupBy )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/GetPatientAttributesWithoutGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/GetPatientAttributesWithoutGroupAction.java	2012-01-11 05:31:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/GetPatientAttributesWithoutGroupAction.java	2012-03-27 01:29:30 +0000
@@ -72,7 +72,7 @@
     public String execute()
         throws Exception
     {
-        patientAttributes = patientAttributeService.getPatientAttributesNotGroup();
+        patientAttributes = patientAttributeService.getPatientAttributesWithoutGroup();
 
         return SUCCESS;
     }

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ShowUpdatePatientAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ShowUpdatePatientAttributeAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ShowUpdatePatientAttributeAction.java	2012-03-27 01:29:30 +0000
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2004-2009, 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.
+ */
+
+package org.hisp.dhis.patient.action.patientattribute;
+
+import java.util.Collection;
+
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $ShowUpdatePatientAttributeAction.java Mar 26, 2012 1:58:26 PM$
+ */
+public class ShowUpdatePatientAttributeAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private int id;
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    private PatientAttribute patientAttribute;
+
+    public PatientAttribute getPatientAttribute()
+    {
+        return patientAttribute;
+    }
+
+    private Collection<Program> programs;
+
+    public Collection<Program> getPrograms()
+    {
+        return programs;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        patientAttribute = patientAttributeService.getPatientAttribute( id );
+        
+        programs = programService.getAllPrograms();
+        
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/UpdatePatientAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/UpdatePatientAttributeAction.java	2011-12-07 02:20:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/UpdatePatientAttributeAction.java	2012-03-27 01:29:30 +0000
@@ -39,6 +39,8 @@
 import org.hisp.dhis.patient.PatientAttributeOptionService;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -76,6 +78,13 @@
         this.patientAttributeValueService = patientAttributeValueService;
     }
 
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -143,6 +152,13 @@
         this.groupBy = groupBy;
     }
 
+    private Integer programId;
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -158,6 +174,8 @@
         patientAttribute.setMandatory( mandatory );
         patientAttribute.setInheritable( inheritable );
         patientAttribute.setNoChars( noChars );
+        Program program = (programId != null) ? programService.getProgram( programId ) : null;
+        patientAttribute.setProgram( program );
 
         if ( groupBy )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattributegroup/GetPatientAttributeGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattributegroup/GetPatientAttributeGroupAction.java	2011-03-31 01:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattributegroup/GetPatientAttributeGroupAction.java	2012-03-27 01:29:30 +0000
@@ -102,7 +102,7 @@
     {
         patientAttributeGroup = patientAttributeGroupService.getPatientAttributeGroup( id );
 
-        patientAttributes = new ArrayList<PatientAttribute>( patientAttributeService.getPatientAttributesNotGroup() );
+        patientAttributes = new ArrayList<PatientAttribute>( patientAttributeService.getPatientAttributesWithoutGroup() );
 
         Collections.sort( patientAttributes, new PatientAttributeComparator() );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-03-27 01:29:30 +0000
@@ -88,6 +88,8 @@
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
 		<property name="patientAttributeOptionService"
 			ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
+		<property name="programService"
+			ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 
 	<bean
@@ -108,6 +110,8 @@
 			ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+		<property name="programService"
+			ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 
 	<bean
@@ -144,6 +148,16 @@
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
 
+	<bean
+		id="org.hisp.dhis.patient.action.patientattribute.ShowUpdatePatientAttributeAction"
+		class="org.hisp.dhis.patient.action.patientattribute.ShowUpdatePatientAttributeAction"
+		scope="prototype">
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="programService"
+			ref="org.hisp.dhis.program.ProgramService" />
+	</bean>
+	
 	<!-- Organisation Registration -->
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-03-27 01:29:30 +0000
@@ -129,7 +129,8 @@
 			<param name="requiredAuthorities">F_PATIENTATTRIBUTE_ADD</param>
 		</action>
 
-		<action name="showAddPatientAttributeForm" class="org.hisp.dhis.patient.action.NoAction">
+		<action name="showAddPatientAttributeForm"
+			class="org.hisp.dhis.patient.action.program.GetProgramListAction">
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">
 				/dhis-web-maintenance-patient/addPatientAttributeForm.vm</param>
@@ -139,7 +140,7 @@
 		</action>
 
 		<action name="showUpdatePatientAttributeForm"
-			class="org.hisp.dhis.patient.action.patientattribute.GetPatientAttributeAction">
+			class="org.hisp.dhis.patient.action.patientattribute.ShowUpdatePatientAttributeAction">
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">
 				/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm</param>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm	2012-03-19 09:35:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm	2012-03-27 01:29:30 +0000
@@ -49,6 +49,7 @@
 		</td>		
 		<td></td>				
 	</tr>
+		
     <tr>
         <td><label for="valueType">$i18n.getString( "value_type" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
         <td>
@@ -68,6 +69,20 @@
 		</td>
 		<td><span id="attrMessage"  name="attrMessage" style="color:red;"></span></td>
 	</tr>
+	
+	<tr>
+		<td><label for="programId">$i18n.getString( "program" )</label></td>
+		<td>
+			<select type="text" name="programId" id="programId" value="$!patientIdentifierType.program" >
+				<option value=''>[$i18n.getString('all')]</option>
+				#foreach( $program in $programs)
+					<option value='$program.id' #if($patientIdentifierType.program.id==$program.id) selected #end>$program.name</option>
+				#end
+			</select>
+		</td>		
+		<td></td>				
+	</tr> 
+	
 	<tr>
     	<td><label for="groupBy">$i18n.getString( "groupBy" )</td>
     	<td><input type="checkbox" name="groupBy" value="true"/></td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientIdentifierTypeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientIdentifierTypeForm.vm	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientIdentifierTypeForm.vm	2012-03-27 01:29:30 +0000
@@ -69,7 +69,7 @@
 			<td><label for="programId">$i18n.getString( "program" )</label></td>
 			<td>
 				<select type="text" name="programId" id="programId" value="$!patientIdentifierType.program" >
-					<option value=''>$i18n.getString('all')</option>
+					<option value=''>[$i18n.getString('all')]</option>
 					#foreach( $program in $programs)
 						<option value='$program.id'>$program.name</option>
 					#end

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js	2012-03-15 09:28:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js	2012-03-27 01:29:30 +0000
@@ -17,6 +17,13 @@
 			
 			setInnerHTML( 'valueTypeField', json.patientAttribute.valueType );    
 	   
+			var programName = json.patientAttribute.program;
+			if( programName == '')
+			{
+				programName = i18n_all;
+			}
+			setInnerHTML( 'programField', programName );
+			
 			showDetails();
 	});
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientIdentifierType.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientIdentifierType.js	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientIdentifierType.js	2012-03-27 01:29:30 +0000
@@ -21,8 +21,12 @@
 			var valueType = json.patientIdentifierType.type;
 			setInnerHTML( 'typeField', valueTypeMap[valueType] );
 			
-			var valueType = json.patientIdentifierType.type;
-			setInnerHTML( 'programField', json.patientIdentifierType.program );
+			var programName = json.patientIdentifierType.program;
+			if( programName == '')
+			{
+				programName = i18n_all;
+			}
+			setInnerHTML( 'programField', programName );
 			
 			showDetails();
 	});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatientIdentifierType.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatientIdentifierType.vm	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatientIdentifierType.vm	2012-03-27 01:29:30 +0000
@@ -69,4 +69,5 @@
 	var i18n_alphabet = '$encoder.jsEscape( $i18n.getString( "alphabet" ), "'")';
 	var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ), "'")';
 	var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ), "'")';
+	var i18n_all = '$encoder.jsEscape( $i18n.getString( "all" ), "'")';
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm	2012-01-11 07:42:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm	2012-03-27 01:29:30 +0000
@@ -60,6 +60,7 @@
                 <p><label class="bold">$i18n.getString( "mandatory" ):</label><br><span id="mandatoryField"></span></p>
                 <p><label class="bold">$i18n.getString( "inheritable" ):</label><br><span id="inheritableField"></span></p>
                 <p><label class="bold">$i18n.getString( "value_type" ):</label><br><span id="valueTypeField"></span></p>
+				<p><label class="bold">$i18n.getString( "program" ):</label><br><span id="programField"></span></p>
 			</div>
 
 		</td>
@@ -78,4 +79,5 @@
     var i18n_combo = '$encoder.jsEscape( $i18n.getString( "combo" ) , "'")';
 	var i18n_processing = '$encoder.jsEscape( $i18n.getString( "processing" ) , "'")';
 	var i18n_done = '$encoder.jsEscape( $i18n.getString( "done" ) , "'")';
+	var i18n_all = '$encoder.jsEscape( $i18n.getString( "all" ) , "'")';
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm	2012-03-19 09:35:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm	2012-03-27 01:29:30 +0000
@@ -52,6 +52,7 @@
 		</td>		
 		<td></td>				
 	</tr>
+	
     <tr>
         <td>$i18n.getString( "value_type" ) <em title="$i18n.getString( "required" )" class="required">*</em></td>
         <td>
@@ -65,27 +66,39 @@
         </td>
     </tr>
       
-	  <tr id="attributeComboRow"> 
-    	<td><label>$i18n.getString( "attribute_options" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-    	<td >
-    		<table id="attrOptionContainer">
-    			 #foreach($option in $patientAttribute.attributeOptions) 
-    			 	<tr><td>
-    			 		<input type='text' name='attrOption$option.id' value="$option.name" style="width:28em;"/><a href='#' style='text-decoration: none; margin-left:0.5em;' title='$i18n.getString( "remove_option" )'  onClick='ATTRIBUTE_OPTION.remove(this,$option.id)'>[ - ]</a>
-   			 		</td>
-					</tr>
-    			 #end
-    		</table><a href="#" style="text-decoration: none;margin-top: 0.5em"  onclick="ATTRIBUTE_OPTION.addOption()">[ $i18n.getString( "add_more_option" ) ]</a></td>
-    	<td><span id="attrMessage"  name="attrMessage" style="color:red;"></span></td>
-      </tr>
-      <tr>
-        <td colspan="3"></td>
-      </tr>
-	  <tr>
+	<tr id="attributeComboRow"> 
+		<td><label>$i18n.getString( "attribute_options" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+		<td >
+			<table id="attrOptionContainer">
+			 #foreach($option in $patientAttribute.attributeOptions) 
+				<tr><td>
+					<input type='text' name='attrOption$option.id' value="$option.name" style="width:28em;"/><a href='#' style='text-decoration: none; margin-left:0.5em;' title='$i18n.getString( "remove_option" )'  onClick='ATTRIBUTE_OPTION.remove(this,$option.id)'>[ - ]</a>
+				</td>
+				</tr>
+			 #end
+		</table><a href="#" style="text-decoration: none;margin-top: 0.5em"  onclick="ATTRIBUTE_OPTION.addOption()">[ $i18n.getString( "add_more_option" ) ]</a></td>
+		<td><span id="attrMessage"  name="attrMessage" style="color:red;"></span></td>
+	</tr>
+	
+	<tr>
+		<td><label for="programId">$i18n.getString( "program" )</label></td>
+		<td>
+			<select type="text" name="programId" id="programId" value="$!patientAttribute.program" >
+				<option value=''>[$i18n.getString('all')]</option>
+				#foreach( $program in $programs)
+					<option value='$program.id' #if($patientAttribute.program.id==$program.id) selected #end>$program.name</option>
+				#end
+			</select>
+		</td>		
+		<td></td>				
+	</tr> 
+	
+	<tr>
     	<td><label for="groupBy">$i18n.getString( "groupBy" )</td>
     	<td><input type="checkbox" name="groupBy" value="true" #if( $patientAttribute.groupBy == 'true' ) checked #end></td>
-      </tr>
+    </tr>
     </tbody>
+	
 	<tr>
 		<td></td>
 		<td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientIdentifierType.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientIdentifierType.vm	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientIdentifierType.vm	2012-03-27 01:29:30 +0000
@@ -70,7 +70,7 @@
 			<td><label for="programId">$i18n.getString( "program" )</label></td>
 			<td>
 				<select type="text" name="programId" id="programId" value="$!patientIdentifierType.program" >
-					<option value=''>$i18n.getString('all')</option>
+					<option value=''>[$i18n.getString('all')]</option>
 					#foreach( $program in $programs)
 						<option value='$program.id' #if($patientIdentifierType.program.id==$program.id) selected #end>$program.name</option>
 					#end