← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8004: (Tracker) Person management improvements (WIP)

 

------------------------------------------------------------
revno: 8004
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-09-05 21:30:23 +0700
message:
  (Tracker) Person management improvements (WIP)
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.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/PatientIdentifierType.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeService.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/program/Program.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/DefaultPatientIdentifierTypeService.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/patient/hibernate/HibernatePatientIdentifierTypeStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java
  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/PatientIdentifierType.hbm.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java
  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/SaveIdentifierAndAttributeAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.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/java/org/hisp/dhis/caseentry/action/report/LoadPatientPropertiesAction.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/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm
  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/updatePatientForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java
  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/UpdatePatientAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/AddPatientIdentifierTypeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/UpdatePatientIdentifierTypeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.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/org/hisp/dhis/patient/i18n_module.properties
  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/addProgramForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramForm.js
  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
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.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-07-30 04:48:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java	2012-09-05 14:30:23 +0000
@@ -35,7 +35,6 @@
 
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.program.Program;
 
 /**
  * @author Abyot Asalefew
@@ -73,8 +72,6 @@
 
     private Set<PatientAttributeOption> attributeOptions;
 
-    private Program program;
-
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -188,16 +185,6 @@
         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	2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroupService.java	2012-09-05 14:30:23 +0000
@@ -28,8 +28,6 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.program.Program;
-
 /**
  * @author Chau Thu Tran
  * @version $Id$
@@ -49,9 +47,4 @@
     PatientAttributeGroup getPatientAttributeGroupByName( String name );
 
     Collection<PatientAttributeGroup> getAllPatientAttributeGroups();
-    
-    Collection<PatientAttributeGroup> getPatientAttributeGroups( Program program );
-    
-    Collection<PatientAttributeGroup> getPatientAttributeGroupsWithoutProgram();
-    
 }

=== 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	2012-03-29 04:15:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java	2012-09-05 14:30:23 +0000
@@ -28,8 +28,6 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.program.Program;
-
 /**
  * @author Abyot Asalefew
  * @version $Id$
@@ -59,9 +57,4 @@
     PatientAttribute getPatientAttributeByGroupBy(boolean groupBy);
     
     Collection<PatientAttribute> getPatientAttributesWithoutGroup();
-    
-    Collection<PatientAttribute> getPatientAttributes( Program program, PatientAttributeGroup group );
-
-    Collection<PatientAttribute> getPatientAttributes( Program program );
-
 }

=== 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	2012-03-29 04:15:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java	2012-09-05 14:30:23 +0000
@@ -30,7 +30,6 @@
 import java.util.Collection;
 
 import org.hisp.dhis.common.GenericNameableObjectStore;
-import org.hisp.dhis.program.Program;
 
 /**
  * @author Abyot Asalefew Gizaw
@@ -47,11 +46,7 @@
     
     Collection<PatientAttribute> getByMandatory(boolean mandatory);
     
-    Collection<PatientAttribute> get( Program program, PatientAttributeGroup group );
-    
     Collection<PatientAttribute> getWithoutGroup();
 
     PatientAttribute getByGroupBy( boolean groupBy );
-    
-    Collection<PatientAttribute> get( Program program );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierType.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierType.java	2012-09-05 14:30:23 +0000
@@ -33,7 +33,6 @@
 
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.program.Program;
 
 @XmlRootElement( name = "patientIdentifierType", namespace = Dxf2Namespace.NAMESPACE )
 @XmlAccessorType( value = XmlAccessType.NONE )
@@ -63,8 +62,8 @@
 
     private String type;
 
-    private Program program;
-
+    private Boolean personDisplayName;
+    
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -186,14 +185,14 @@
         this.type = type;
     }
 
-    public Program getProgram()
-    {
-        return program;
-    }
-
-    public void setProgram( Program program )
-    {
-        this.program = program;
-    }
-
+    public Boolean getPersonDisplayName()
+    {
+        return personDisplayName;
+    }
+
+    public void setPersonDisplayName( Boolean personDisplayName )
+    {
+        this.personDisplayName = personDisplayName;
+    }
+    
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeService.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeService.java	2012-09-05 14:30:23 +0000
@@ -28,8 +28,6 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.program.Program;
-
 /**
  * @author Abyot Asalefew
  * @version $Id$
@@ -52,8 +50,6 @@
     
     Collection<PatientIdentifierType> getPatientIdentifierTypes( boolean mandatory );
     
-    Collection<PatientIdentifierType> getPatientIdentifierTypes( Program program );
-    
-    Collection<PatientIdentifierType> getPatientIdentifierTypesWithoutProgram();
+    Collection<PatientIdentifierType> getDisplayedPatientIdentifierTypes( boolean personDisplayName );
     
 }

=== 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-27 01:29:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeStore.java	2012-09-05 14:30:23 +0000
@@ -3,14 +3,11 @@
 import java.util.Collection;
 
 import org.hisp.dhis.common.GenericNameableObjectStore;
-import org.hisp.dhis.program.Program;
 
 public interface PatientIdentifierTypeStore
     extends GenericNameableObjectStore<PatientIdentifierType>
 {
     Collection<PatientIdentifierType> get( boolean mandatory );
-
-    Collection<PatientIdentifierType> get( Program program );
-
-    Collection<PatientIdentifierType> getWithoutProgram();
+    
+    Collection<PatientIdentifierType> getByDisplayed( boolean personDisplayName );
 }

=== 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	2012-07-06 09:59:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java	2012-09-05 14:30:23 +0000
@@ -32,7 +32,6 @@
 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
@@ -75,9 +74,4 @@
     Collection<Patient> getPatient( PatientAttribute attribute, String value );
     
     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/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2012-08-06 09:34:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2012-09-05 14:30:23 +0000
@@ -27,6 +27,7 @@
 
 package org.hisp.dhis.program;
 
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -34,6 +35,8 @@
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.validation.ValidationCriteria;
 
 /**
@@ -52,7 +55,6 @@
     public static final int SINGLE_EVENT_WITH_REGISTRATION = 2;
 
     public static final int SINGLE_EVENT_WITHOUT_REGISTRATION = 3;
-    
 
     private String description;
 
@@ -83,9 +85,13 @@
     private Integer type;
 
     private Boolean displayProvidedOtherFacility;
-    
+
     private Boolean displayIncidentDate;
 
+    private Collection<PatientIdentifierType> patientIdentifierTypes;
+
+    private Collection<PatientAttribute> patientAttributes;
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -247,6 +253,26 @@
         this.patientValidationCriteria = patientValidationCriteria;
     }
 
+    public Collection<PatientIdentifierType> getPatientIdentifierTypes()
+    {
+        return patientIdentifierTypes;
+    }
+
+    public void setPatientIdentifierTypes( Collection<PatientIdentifierType> patientIdentifierTypes )
+    {
+        this.patientIdentifierTypes = patientIdentifierTypes;
+    }
+
+    public Collection<PatientAttribute> getPatientAttributes()
+    {
+        return patientAttributes;
+    }
+
+    public void setPatientAttributes( Collection<PatientAttribute> patientAttributes )
+    {
+        this.patientAttributes = patientAttributes;
+    }
+
     // -------------------------------------------------------------------------
     // Logic methods
     // -------------------------------------------------------------------------
@@ -317,14 +343,14 @@
     {
         return Patient.class.getMethod( "get" + property ).invoke( patient );
     }
-    
+
     public boolean isSingleEvent()
     {
-        return type != null && ( SINGLE_EVENT_WITH_REGISTRATION == type || SINGLE_EVENT_WITHOUT_REGISTRATION == type ); 
+        return type != null && (SINGLE_EVENT_WITH_REGISTRATION == type || SINGLE_EVENT_WITHOUT_REGISTRATION == type);
     }
-    
+
     public boolean isRegistration()
     {
-        return type != null && ( SINGLE_EVENT_WITH_REGISTRATION == type || MULTIPLE_EVENTS_WITH_REGISTRATION == type ); 
+        return type != null && (SINGLE_EVENT_WITH_REGISTRATION == type || MULTIPLE_EVENTS_WITH_REGISTRATION == type);
     }
 }

=== 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	2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeGroupService.java	2012-09-05 14:30:23 +0000
@@ -83,16 +83,5 @@
     {
         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	2012-03-29 04:15:07 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java	2012-09-05 14:30:23 +0000
@@ -103,20 +103,10 @@
     {
         return patientAttributeStore.getByMandatory( mandatory );
     }
-
-    public Collection<PatientAttribute> getPatientAttributes( Program program, PatientAttributeGroup group )
-    {
-        return patientAttributeStore.get( program, group );
-    }
     
     public Collection<PatientAttribute> getPatientAttributesWithoutGroup()
     {
         return patientAttributeStore.getWithoutGroup();
     }
-    
-    public Collection<PatientAttribute> getPatientAttributes( Program program )
-    {
-        return patientAttributeStore.get( program );
-    }
 
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierTypeService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierTypeService.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierTypeService.java	2012-09-05 14:30:23 +0000
@@ -28,7 +28,6 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.program.Program;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -89,15 +88,9 @@
         return patientIdentifierTypeStore.get( mandatory );
     }
     
-    public Collection<PatientIdentifierType> getPatientIdentifierTypes( Program program )
-    {
-        return patientIdentifierTypeStore.get( program );
-    }
-    
-    public Collection<PatientIdentifierType> getPatientIdentifierTypesWithoutProgram()
-    {
-        return patientIdentifierTypeStore.getWithoutProgram();
-    }
-
+    public Collection<PatientIdentifierType> getDisplayedPatientIdentifierTypes( boolean personDisplayName )
+    {
+        return patientIdentifierTypeStore.get( personDisplayName );
+    }
 
 }

=== 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	2012-03-29 07:25:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java	2012-09-05 14:30:23 +0000
@@ -29,13 +29,10 @@
 
 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
@@ -70,40 +67,8 @@
     }
 
     @SuppressWarnings("unchecked")
-    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();
     }
-    
-    @SuppressWarnings("unchecked")
-    public Collection<PatientAttribute> get( Program program  )
-    {
-        return getCriteria( Restrictions.eq( "program", program ) ).list();
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierTypeStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierTypeStore.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierTypeStore.java	2012-09-05 14:30:23 +0000
@@ -33,7 +33,6 @@
 import org.hisp.dhis.hibernate.HibernateGenericStore;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeStore;
-import org.hisp.dhis.program.Program;
 
 public class HibernatePatientIdentifierTypeStore
     extends HibernateGenericStore<PatientIdentifierType>
@@ -44,16 +43,10 @@
     {
         return getCriteria( Restrictions.eq( "mandatory", mandatory ) ).list();
     }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<PatientIdentifierType> get( Program program )
-    {
-        return getCriteria( Restrictions.eq( "program", program ) ).list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<PatientIdentifierType> getWithoutProgram()
-    {
-        return getCriteria( Restrictions.isNull( "program" ) ).list();
+    
+    @SuppressWarnings( "unchecked" )
+    public Collection<PatientIdentifierType> getByDisplayed( boolean personDisplayName )
+    {
+        return getCriteria( Restrictions.eq( "personDisplayName", personDisplayName ) ).list();
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-08-16 15:47:08 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-09-05 14:30:23 +0000
@@ -122,6 +122,9 @@
         
         executeSql( "ALTER TABLE patientattribute DROP COLUMN inheritable" );
         executeSql( "ALTER TABLE programstageinstance DROP COLUMN stageInProgram" );
+        
+        updateRelationshipIdentifiers();
+        updateRelationshipAttributes();
     }
 
     // -------------------------------------------------------------------------
@@ -305,6 +308,62 @@
         }
     }
 
+    private void updateRelationshipIdentifiers()
+    {
+        StatementHolder holder = statementManager.getHolder();
+
+        try
+        {
+            Statement statement = holder.getStatement();
+
+            ResultSet resultSet = statement
+                .executeQuery( "SELECT distinct programid, patientidentifiertypeid FROM patientidentifiertype" );
+
+            while ( resultSet.next() )
+            {
+                executeSql( "INSERT into program_patientIdentifierTypes( programid, patientidentifiertypeid) values (" + resultSet.getString( 1 ) + "," + resultSet.getString( 2 ) + ")");
+            }
+
+            executeSql( "ALTER TABLE patientidentifiertype DROP COLUMN programid" );
+        }
+        catch ( Exception ex )
+        {
+            log.debug( ex );
+        }
+        finally
+        {
+            holder.close();
+        } 
+    }
+    
+    private void updateRelationshipAttributes()
+    {
+        StatementHolder holder = statementManager.getHolder();
+
+        try
+        {
+            Statement statement = holder.getStatement();
+
+            ResultSet resultSet = statement
+                .executeQuery( "SELECT distinct programid, patientattributeid FROM program_patientAttributes" );
+
+            while ( resultSet.next() )
+            {
+                executeSql( "INSERT into program_patientAttributes( programid, patientattributeid) values (" + resultSet.getString( 1 ) + "," + resultSet.getString( 2 ) + ")");
+            }
+
+            executeSql( "ALTER TABLE patientattribute DROP COLUMN programid" );
+        }
+        catch ( Exception ex )
+        {
+            log.debug( ex );
+        }
+        finally
+        {
+            holder.close();
+        } 
+    }
+    
     private int executeSql( String sql )
     {
         try

=== 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	2012-07-06 09:59:36 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java	2012-09-05 14:30:23 +0000
@@ -38,7 +38,6 @@
 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;
 
 /**
@@ -219,14 +218,4 @@
     {
         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/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-07-30 04:48:17 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAttribute.hbm.xml	2012-09-05 14:30:23 +0000
@@ -30,7 +30,5 @@
       <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-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientIdentifierType.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientIdentifierType.hbm.xml	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientIdentifierType.hbm.xml	2012-09-05 14:30:23 +0000
@@ -24,7 +24,7 @@
 
     <property name="type" />
     
-    <many-to-one name="program" class="org.hisp.dhis.program.Program" column="programid" foreign-key="fk_identifiertype_program" />
-
+    <property name="personDisplayName" />
+    
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2012-08-06 09:34:34 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2012-09-05 14:30:23 +0000
@@ -44,6 +44,16 @@
     <property name="displayProvidedOtherFacility" />
     
     <property name="displayIncidentDate" />
+    
+    <set name="patientIdentifierTypes" table="program_patientIdentifierTypes">
+      <key column="programid" foreign-key="fk_program_patientIdentifierTypes_programid" />
+      <many-to-many column="patientidentifiertypeid" class="org.hisp.dhis.patient.PatientIdentifierType" foreign-key="fk_program_patientIdentifierTypes_patientidentifiertypeid" />
+    </set>
+    
+    <set name="patientAttributes" table="program_patientAttributes">
+      <key column="programid" foreign-key="fk_program_patientAttributes_programid" />
+      <many-to-many column="patientattributeid" class="org.hisp.dhis.patient.PatientAttribute" foreign-key="fk_program_patientAttributes_patientattributeid" />
+    </set>
         
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java	2012-08-02 05:27:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java	2012-09-05 14:30:23 +0000
@@ -29,19 +29,19 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 
 import org.hisp.dhis.dataentryform.DataEntryForm;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 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.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
-import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramDataEntryService;
 import org.hisp.dhis.program.ProgramService;
@@ -76,13 +76,6 @@
         this.patientAttributeService = patientAttributeService;
     }
 
-    private PatientAttributeGroupService patientAttributeGroupService;
-
-    public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService )
-    {
-        this.patientAttributeGroupService = patientAttributeGroupService;
-    }
-
     private PatientIdentifierTypeService patientIdentifierTypeService;
 
     public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
@@ -110,9 +103,9 @@
 
     private Integer programId;
 
-    private Collection<PatientAttribute> noGroupAttributes;
+    private Collection<PatientAttribute> noGroupAttributes = new HashSet<PatientAttribute>();
 
-    private List<PatientAttributeGroup> attributeGroups;
+    private Map<PatientAttributeGroup, Collection<PatientAttribute>> attributeGroupsMap = new HashMap<PatientAttributeGroup, Collection<PatientAttribute>>();
 
     private Collection<PatientIdentifierType> identifierTypes;
 
@@ -121,23 +114,46 @@
     private String customDataEntryFormCode;
 
     private List<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>();
-    
+
     private ProgramStage programStage;
-    
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
     public String execute()
     {
-        identifierTypes = patientIdentifierTypeService.getPatientIdentifierTypesWithoutProgram();
-
-        noGroupAttributes = patientAttributeService.getPatientAttributes( null, null );
-
-        attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
-            .getPatientAttributeGroupsWithoutProgram() );
-        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
-
+        identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+        Collection<PatientAttribute> patientAttributes = patientAttributeService.getAllPatientAttributes();
+        Collection<Program> programs = programService.getAllPrograms();
+        for ( Program program : programs )
+        {
+            identifierTypes.removeAll( program.getPatientIdentifierTypes() );
+            patientAttributes.removeAll( program.getPatientAttributes() );
+        }
+
+        for( PatientAttribute patientAttribute : patientAttributes )
+        {
+            PatientAttributeGroup attributeGroup = patientAttribute.getPatientAttributeGroup();
+            if( attributeGroup!=null){
+                if( attributeGroupsMap.containsKey( attributeGroup ) )
+                {
+                    Collection<PatientAttribute> attributes = attributeGroupsMap.get( attributeGroup );
+                    attributes.add(patientAttribute);
+                }
+                else
+                {
+                    Collection<PatientAttribute> attributes = new HashSet<PatientAttribute>(); 
+                    attributes.add(patientAttribute);
+                    attributeGroupsMap.put( attributeGroup, attributes );
+                }
+            }
+            else
+            {
+                noGroupAttributes.add( patientAttribute );
+            }
+        }
+        
         organisationUnit = selectionManager.getSelectedOrganisationUnit();
 
         // Get data entry form
@@ -154,8 +170,8 @@
         }
         else
         {
-            programStageDataElements = new ArrayList<ProgramStageDataElement>( programStage
-                .getProgramStageDataElements() );
+            programStageDataElements = new ArrayList<ProgramStageDataElement>(
+                programStage.getProgramStageDataElements() );
         }
 
         return SUCCESS;
@@ -170,9 +186,9 @@
         return identifierTypes;
     }
 
-    public List<PatientAttributeGroup> getAttributeGroups()
+    public Map<PatientAttributeGroup, Collection<PatientAttribute>> getAttributeGroupsMap()
     {
-        return attributeGroups;
+        return attributeGroupsMap;
     }
 
     public void setProgramId( Integer programId )

=== 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-06-14 13:07:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2012-09-05 14:30:23 +0000
@@ -26,24 +26,21 @@
  */
 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.HashSet;
 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;
@@ -74,8 +71,6 @@
 
     private PatientAttributeService patientAttributeService;
 
-    private PatientAttributeGroupService patientAttributeGroupService;
-
     private PatientIdentifierTypeService patientIdentifierTypeService;
     
     private RelationshipService relationshipService;
@@ -94,7 +89,7 @@
 
     private Map<Integer, String> patientAttributeValueMap = new HashMap<Integer, String>();
 
-    private Collection<PatientAttribute> noGroupAttributes;
+    private Collection<PatientAttribute> noGroupAttributes = new HashSet<PatientAttribute>();
 
     private List<PatientAttributeGroup> attributeGroups;
 
@@ -109,6 +104,8 @@
     private String systemIdentifier;
 
     private Relationship relationship;
+    
+    private Map<PatientAttributeGroup, Collection<PatientAttribute>> attributeGroupsMap = new HashMap<PatientAttributeGroup, Collection<PatientAttribute>>();
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -122,12 +119,46 @@
         programs = programService.getAllPrograms();
         
         // -------------------------------------------------------------------------
-        // Get identifier
+        // Get identifier-types && attributes
         // -------------------------------------------------------------------------
 
         patientIdentifier = patientIdentifierService.getPatientIdentifier( patient );
 
-        identifierTypes = patientIdentifierTypeService.getPatientIdentifierTypesWithoutProgram();
+        identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+        Collection<PatientAttribute> patientAttributes = patientAttributeService.getAllPatientAttributes();
+        
+        Collection<Program> programs = programService.getAllPrograms();
+        for ( Program program : programs )
+        {
+            identifierTypes.removeAll( program.getPatientIdentifierTypes() );
+            patientAttributes.removeAll( program.getPatientAttributes() );
+        }
+        
+        for( PatientAttribute patientAttribute : patientAttributes )
+        {
+            PatientAttributeGroup attributeGroup = patientAttribute.getPatientAttributeGroup();
+            if( attributeGroup!=null){
+                if( attributeGroupsMap.containsKey( attributeGroup ) )
+                {
+                    Collection<PatientAttribute> attributes = attributeGroupsMap.get( attributeGroup );
+                    attributes.add(patientAttribute);
+                }
+                else
+                {
+                    Collection<PatientAttribute> attributes = new HashSet<PatientAttribute>(); 
+                    attributes.add(patientAttribute);
+                    attributeGroupsMap.put( attributeGroup, attributes );
+                }
+            }
+            else
+            {
+                noGroupAttributes.add( patientAttribute );
+            }
+        }
+        
+        // -------------------------------------------------------------------------
+        // Get data
+        // -------------------------------------------------------------------------
 
         identiferMap = new HashMap<Integer, String>();
 
@@ -165,15 +196,32 @@
         // -------------------------------------------------------------------------
         // Get patient-attribute values
         // -------------------------------------------------------------------------
-
-        attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
-            .getPatientAttributeGroupsWithoutProgram() );
-        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
-
-        noGroupAttributes = patientAttributeService.getPatientAttributes( null, null );
+        
+
+        for( PatientAttribute patientAttribute : patientAttributes )
+        {
+            PatientAttributeGroup attributeGroup = patientAttribute.getPatientAttributeGroup();
+            if( attributeGroup!=null){
+                if( attributeGroupsMap.containsKey( attributeGroup ) )
+                {
+                    Collection<PatientAttribute> attributes = attributeGroupsMap.get( attributeGroup );
+                    attributes.add(patientAttribute);
+                }
+                else
+                {
+                    Collection<PatientAttribute> attributes = new HashSet<PatientAttribute>(); 
+                    attributes.add(patientAttribute);
+                    attributeGroupsMap.put( attributeGroup, attributes );
+                }
+            }
+            else
+            {
+                noGroupAttributes.add( patientAttribute );
+            }
+        }
         
         Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
-            .getPatientAttributeValuesWithoutProgram( patient );
+            .getPatientAttributeValues( patient );
 
         for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
         {
@@ -197,7 +245,12 @@
     // -----------------------------------------------------------------------------
     // Getter / Setter
     // -----------------------------------------------------------------------------
-
+    
+    public Map<PatientAttributeGroup, Collection<PatientAttribute>> getAttributeGroupsMap()
+    {
+        return attributeGroupsMap;
+    }
+    
     public void setPatientService( PatientService patientService )
     {
         this.patientService = patientService;
@@ -227,12 +280,7 @@
     {
         this.patientAttributeService = patientAttributeService;
     }
-
-    public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService )
-    {
-        this.patientAttributeGroupService = patientAttributeGroupService;
-    }
-
+    
     public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
     {
         this.patientIdentifierTypeService = patientIdentifierTypeService;

=== 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-08-28 05:48:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2012-09-05 14:30:23 +0000
@@ -30,6 +30,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
@@ -38,11 +39,9 @@
 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.comparator.PatientAttributeGroupSortOrderComparator;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
@@ -69,12 +68,8 @@
 
     private ProgramStageInstanceService programStageInstanceService;
 
-    private PatientIdentifierTypeService identifierTypeService;
-
     private PatientIdentifierService patientIdentifierService;
 
-    private PatientAttributeService patientAttributeService;
-
     private PatientAttributeGroupService patientAttributeGroupService;
 
     private PatientAttributeValueService patientAttributeValueService;
@@ -95,7 +90,7 @@
 
     private Collection<PatientIdentifierType> identifierTypes;
 
-    private Collection<PatientAttribute> noGroupAttributes;
+    private Collection<PatientAttribute> noGroupAttributes = new HashSet<PatientAttribute>();
 
     private List<PatientAttributeGroup> attributeGroups;
 
@@ -105,6 +100,8 @@
 
     private Map<Integer, Integer> statusMap = new HashMap<Integer, Integer>();
 
+    private Map<PatientAttributeGroup, Collection<PatientAttribute>> attributeGroupsMap = new HashMap<PatientAttributeGroup, Collection<PatientAttribute>>();
+
     // -------------------------------------------------------------------------
     // Getters/Setters
     // -------------------------------------------------------------------------
@@ -129,11 +126,6 @@
         return patientAttributeValueMap;
     }
 
-    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
-    {
-        this.patientAttributeService = patientAttributeService;
-    }
-
     public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService )
     {
         this.patientAttributeGroupService = patientAttributeGroupService;
@@ -154,11 +146,6 @@
         this.patientIdentifierService = patientIdentifierService;
     }
 
-    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
-    {
-        this.identifierTypeService = identifierTypeService;
-    }
-    
     public void setProgramInstanceService( ProgramInstanceService programInstanceService )
     {
         this.programInstanceService = programInstanceService;
@@ -193,6 +180,11 @@
     {
         return hasDataEntry;
     }
+    
+    public Map<PatientAttributeGroup, Collection<PatientAttribute>> getAttributeGroupsMap()
+    {
+        return attributeGroupsMap;
+    }
 
     public Map<Integer, Integer> getStatusMap()
     {
@@ -222,9 +214,9 @@
                 .getProgramStageInstances() );
         }
 
-        loadIdentifierTypes(programInstance);
+        loadIdentifierTypes( programInstance );
 
-        loadPatientAttributes(programInstance);
+        loadPatientAttributes( programInstance );
 
         hasDataEntry = showDataEntry( orgunit, programInstance.getProgram(), programInstance );
 
@@ -241,7 +233,7 @@
         // Load identifier types of the selected program
         // ---------------------------------------------------------------------
 
-        identifierTypes = identifierTypeService.getPatientIdentifierTypes( programInstance.getProgram() );
+        identifierTypes = programInstance.getProgram().getPatientIdentifierTypes();
         identiferMap = new HashMap<Integer, String>();
 
         if ( identifierTypes != null && identifierTypes.size() > 0 )
@@ -262,11 +254,30 @@
         // Load patient-attributes of the selected program
         // ---------------------------------------------------------------------
 
-        attributeGroups = new ArrayList<PatientAttributeGroup>(
-            patientAttributeGroupService.getPatientAttributeGroups( programInstance.getProgram() ) );
-        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
+        Collection<PatientAttribute> patientAttributes = programInstance.getProgram().getPatientAttributes();
 
-        noGroupAttributes = patientAttributeService.getPatientAttributes( programInstance.getProgram(), null );
+        for ( PatientAttribute patientAttribute : patientAttributes )
+        {
+            PatientAttributeGroup attributeGroup = patientAttribute.getPatientAttributeGroup();
+            if ( attributeGroup != null )
+            {
+                if ( attributeGroupsMap.containsKey( attributeGroup ) )
+                {
+                    Collection<PatientAttribute> attributes = attributeGroupsMap.get( attributeGroup );
+                    attributes.add( patientAttribute );
+                }
+                else
+                {
+                    Collection<PatientAttribute> attributes = new HashSet<PatientAttribute>();
+                    attributes.add( patientAttribute );
+                    attributeGroupsMap.put( attributeGroup, attributes );
+                }
+            }
+            else
+            {
+                noGroupAttributes.add( patientAttribute );
+            }
+        }
 
         Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
             .getPatientAttributeValues( programInstance.getPatient() );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveIdentifierAndAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveIdentifierAndAttributeAction.java	2012-06-18 03:29:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveIdentifierAndAttributeAction.java	2012-09-05 14:30:23 +0000
@@ -38,11 +38,9 @@
 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.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.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
@@ -65,14 +63,10 @@
 
     private PatientService patientService;
 
-    private PatientIdentifierTypeService identifierTypeService;
-
     private PatientIdentifierService patientIdentifierService;
 
     private PatientAttributeValueService patientAttributeValueService;
-
-    private PatientAttributeService patientAttributeService;
-
+    
     private PatientAttributeOptionService patientAttributeOptionService;
 
     private ProgramService programService;
@@ -101,11 +95,6 @@
         this.patientAttributeValueService = patientAttributeValueService;
     }
 
-    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
-    {
-        this.patientAttributeService = patientAttributeService;
-    }
-
     public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService )
     {
         this.patientAttributeOptionService = patientAttributeOptionService;
@@ -126,11 +115,6 @@
         this.patientIdentifierService = patientIdentifierService;
     }
 
-    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
-    {
-        this.identifierTypeService = identifierTypeService;
-    }
-
     public void setPatientId( Integer patientId )
     {
         this.patientId = patientId;
@@ -170,7 +154,7 @@
 
         String value = null;
 
-        Collection<PatientIdentifierType> identifierTypes = identifierTypeService.getPatientIdentifierTypes( program );
+        Collection<PatientIdentifierType> identifierTypes = program.getPatientIdentifierTypes();
 
         PatientIdentifier identifier = null;
 
@@ -215,7 +199,7 @@
 
         String value = null;
 
-        Collection<PatientAttribute> attributes = patientAttributeService.getPatientAttributes( program );
+        Collection<PatientAttribute> attributes = program.getPatientAttributes();
 
         PatientAttributeValue attributeValue = null;
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java	2012-08-16 06:20:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java	2012-09-05 14:30:23 +0000
@@ -37,7 +37,10 @@
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 
 /**
  * @author Abyot Asalefew Gizaw
@@ -54,6 +57,8 @@
 
     private PatientService patientService;
 
+    private ProgramService programService;
+
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -63,7 +68,7 @@
     private Boolean searchBySelectedOrgunit;
 
     private boolean listAll;
-    
+
     private Collection<Patient> patients = new ArrayList<Patient>();
 
     // -------------------------------------------------------------------------
@@ -75,6 +80,11 @@
         this.selectionManager = selectionManager;
     }
 
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
     public void setSearchBySelectedOrgunit( Boolean searchBySelectedOrgunit )
     {
         this.searchBySelectedOrgunit = searchBySelectedOrgunit;
@@ -90,6 +100,11 @@
         this.searchTexts = searchTexts;
     }
 
+    public boolean isListAll()
+    {
+        return listAll;
+    }
+
     public void setListAll( boolean listAll )
     {
         this.listAll = listAll;
@@ -114,6 +129,20 @@
         return mapPatientOrgunit;
     }
 
+    private List<Integer> programIds;
+
+    public void setProgramIds( List<Integer> programIds )
+    {
+        this.programIds = programIds;
+    }
+
+    private List<PatientIdentifierType> identifierTypes = new ArrayList<PatientIdentifierType>();
+
+    public List<PatientIdentifierType> getIdentifierTypes()
+    {
+        return identifierTypes;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -147,6 +176,15 @@
             {
                 mapPatientOrgunit.put( patient.getId(), getHierarchyOrgunit( patient.getOrganisationUnit() ) );
             }
+
+            if ( programIds != null )
+            {
+                for( Integer programId : programIds )
+                {
+                    Program progam = programService.getProgram( programId );
+                    identifierTypes.addAll( progam.getPatientIdentifierTypes() );
+                }
+            }
         }
 
         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-09-05 01:41:15 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java	2012-09-05 14:30:23 +0000
@@ -27,20 +27,20 @@
 
 package org.hisp.dhis.caseentry.action.patient;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 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.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
-import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -69,13 +69,6 @@
         this.patientAttributeService = patientAttributeService;
     }
 
-    private PatientAttributeGroupService patientAttributeGroupService;
-
-    public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService )
-    {
-        this.patientAttributeGroupService = patientAttributeGroupService;
-    }
-
     private PatientIdentifierTypeService patientIdentifierTypeService;
 
     public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
@@ -83,12 +76,19 @@
         this.patientIdentifierTypeService = patientIdentifierTypeService;
     }
 
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
     private Boolean addNewForm;
-    
+
     public Boolean getAddNewForm()
     {
         return addNewForm;
@@ -99,27 +99,52 @@
         this.addNewForm = addNewForm;
     }
 
-    private Collection<PatientAttribute> noGroupAttributes;
-
-    private List<PatientAttributeGroup> attributeGroups;
+    private Collection<PatientAttribute> noGroupAttributes = new HashSet<PatientAttribute>();
 
     private Collection<PatientIdentifierType> identifierTypes;
 
     private OrganisationUnit organisationUnit;
 
+    private Map<PatientAttributeGroup, Collection<PatientAttribute>> attributeGroupsMap = new HashMap<PatientAttributeGroup, Collection<PatientAttribute>>();
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
     public String execute()
     {
-        identifierTypes = patientIdentifierTypeService.getPatientIdentifierTypesWithoutProgram();
-
-        noGroupAttributes = patientAttributeService.getPatientAttributes( null, null );
-
-        attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
-            .getPatientAttributeGroupsWithoutProgram() );
-        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
+        identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+        Collection<PatientAttribute> patientAttributes = patientAttributeService.getAllPatientAttributes();
+        Collection<Program> programs = programService.getAllPrograms();
+        for ( Program program : programs )
+        {
+            identifierTypes.removeAll( program.getPatientIdentifierTypes() );
+            patientAttributes.removeAll( program.getPatientAttributes() );
+        }
+
+        attributeGroupsMap = new HashMap<PatientAttributeGroup, Collection<PatientAttribute>>();
+        for ( PatientAttribute patientAttribute : patientAttributes )
+        {
+            PatientAttributeGroup attributeGroup = patientAttribute.getPatientAttributeGroup();
+            if ( attributeGroup != null )
+            {
+                if ( attributeGroupsMap.containsKey( attributeGroup ) )
+                {
+                    Collection<PatientAttribute> attributes = attributeGroupsMap.get( attributeGroup );
+                    attributes.add( patientAttribute );
+                }
+                else
+                {
+                    Collection<PatientAttribute> attributes = new HashSet<PatientAttribute>();
+                    attributes.add( patientAttribute );
+                    attributeGroupsMap.put( attributeGroup, attributes );
+                }
+            }
+            else
+            {
+                noGroupAttributes.add( patientAttribute );
+            }
+        }
 
         organisationUnit = selectionManager.getSelectedOrganisationUnit();
 
@@ -134,12 +159,7 @@
     {
         return identifierTypes;
     }
-
-    public List<PatientAttributeGroup> getAttributeGroups()
-    {
-        return attributeGroups;
-    }
-
+    
     public Collection<PatientAttribute> getNoGroupAttributes()
     {
         return noGroupAttributes;
@@ -149,4 +169,9 @@
     {
         return organisationUnit;
     }
+
+    public Map<PatientAttributeGroup, Collection<PatientAttribute>> getAttributeGroupsMap()
+    {
+        return attributeGroupsMap;
+    }
 }

=== 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	2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java	2012-09-05 14:30:23 +0000
@@ -27,25 +27,24 @@
 
 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.HashSet;
 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.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.ProgramService;
 import org.hisp.dhis.relationship.RelationshipType;
 import org.hisp.dhis.relationship.RelationshipTypeService;
 
@@ -67,23 +66,21 @@
 
     private PatientAttributeService patientAttributeService;
 
-    private PatientAttributeGroupService patientAttributeGroupService;
-
     private PatientIdentifierTypeService patientIdentifierTypeService;
 
     private RelationshipTypeService relationshipTypeService;
 
     private PatientAttributeValueService patientAttributeValueService;
 
+    private ProgramService programService;
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
     private Integer id;
 
-    private Collection<PatientAttribute> noGroupAttributes;
-
-    private List<PatientAttributeGroup> attributeGroups;
+    private Collection<PatientAttribute> noGroupAttributes = new HashSet<PatientAttribute>();
 
     private Collection<PatientIdentifierType> identifierTypes;
 
@@ -95,6 +92,8 @@
 
     private Map<Integer, String> attributeMap;
 
+    private Map<PatientAttributeGroup, Collection<PatientAttribute>> attributeGroupsMap = new HashMap<PatientAttributeGroup, Collection<PatientAttribute>>();
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -104,8 +103,36 @@
         patient = patientService.getPatient( id.intValue() );
 
         identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+        Collection<PatientAttribute> patientAttributes = patientAttributeService.getAllPatientAttributes();
+        Collection<Program> programs = programService.getAllPrograms();
+        for ( Program program : programs )
+        {
+            identifierTypes.removeAll( program.getPatientIdentifierTypes() );
+            patientAttributes.removeAll( program.getPatientAttributes() );
+        }
 
-        noGroupAttributes = new ArrayList<PatientAttribute>( patientAttributeService.getPatientAttributes( null, null ) );
+        for ( PatientAttribute patientAttribute : patientAttributes )
+        {
+            PatientAttributeGroup attributeGroup = patientAttribute.getPatientAttributeGroup();
+            if ( attributeGroup != null )
+            {
+                if ( attributeGroupsMap.containsKey( attributeGroup ) )
+                {
+                    Collection<PatientAttribute> attributes = attributeGroupsMap.get( attributeGroup );
+                    attributes.add( patientAttribute );
+                }
+                else
+                {
+                    Collection<PatientAttribute> attributes = new HashSet<PatientAttribute>();
+                    attributes.add( patientAttribute );
+                    attributeGroupsMap.put( attributeGroup, attributes );
+                }
+            }
+            else
+            {
+                noGroupAttributes.add( patientAttribute );
+            }
+        }
 
         relationshipTypes = relationshipTypeService.getAllRelationshipTypes();
 
@@ -121,14 +148,8 @@
         // 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 );
+            .getPatientAttributeValues( patient );
 
         for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
         {
@@ -151,6 +172,16 @@
     // -------------------------------------------------------------------------
     // Getter/Setter
     // -------------------------------------------------------------------------
+    
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    public Map<PatientAttributeGroup, Collection<PatientAttribute>> getAttributeGroupsMap()
+    {
+        return attributeGroupsMap;
+    }
 
     public void setId( Integer id )
     {
@@ -161,12 +192,7 @@
     {
         return identifierTypes;
     }
-
-    public Collection<PatientAttributeGroup> getAttributeGroups()
-    {
-        return attributeGroups;
-    }
-
+    
     public Collection<PatientAttribute> getNoGroupAttributes()
     {
         return noGroupAttributes;
@@ -202,11 +228,6 @@
         this.patientAttributeService = patientAttributeService;
     }
 
-    public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService )
-    {
-        this.patientAttributeGroupService = patientAttributeGroupService;
-    }
-
     public void setPatientService( PatientService patientService )
     {
         this.patientService = patientService;

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadPatientPropertiesAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadPatientPropertiesAction.java	2012-05-29 13:03:38 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadPatientPropertiesAction.java	2012-09-05 14:30:23 +0000
@@ -111,11 +111,17 @@
     {
         Program program = programService.getProgram( programId );
 
-        identifierTypes = identifierTypeService.getPatientIdentifierTypesWithoutProgram();
-        identifierTypes.addAll( identifierTypeService.getPatientIdentifierTypes( program ) );
+        identifierTypes = identifierTypeService.getAllPatientIdentifierTypes();
+        patientAttributes = attributeService.getAllPatientAttributes();
 
-        patientAttributes.addAll( attributeService.getPatientAttributes( null, null ) );
-        patientAttributes.addAll( attributeService.getPatientAttributes( program ) );
+        Collection<Program> programs = programService.getAllPrograms();
+        programs.remove( program );
+        
+        for ( Program _program : programs )
+        {
+            identifierTypes.removeAll( _program.getPatientIdentifierTypes() );
+            patientAttributes.removeAll( _program.getPatientAttributes() );
+        }
 
         return SUCCESS;
     }

=== 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-09-04 10:10:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-09-05 14:30:23 +0000
@@ -31,6 +31,7 @@
 		<property name="selectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 	
 	<bean
@@ -213,8 +214,6 @@
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 		<property name="patientAttributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
-		<property name="patientAttributeGroupService"
-			ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
 		<property name="patientIdentifierTypeService"
 			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		<property name="programService"
@@ -471,8 +470,6 @@
 		<property name="patientAttributeService">
 			<ref bean="org.hisp.dhis.patient.PatientAttributeService" />
 		</property>
-		<property name="patientAttributeGroupService"
-			ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
 		<property name="patientIdentifierTypeService"
 			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		<property name="relationshipService"
@@ -530,11 +527,12 @@
 		<property name="patientAttributeService">
 			<ref bean="org.hisp.dhis.patient.PatientAttributeService" />
 		</property>
-		<property name="patientAttributeGroupService"
-			ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
 		<property name="patientIdentifierTypeService">
 			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		</property>
+		<property name="programService">
+			<ref bean="org.hisp.dhis.program.ProgramService" />
+		</property>
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.ValidatePatientAction"
@@ -625,12 +623,8 @@
 		class="org.hisp.dhis.caseentry.action.patient.ProgramEnrollmentAction"
 		scope="prototype">
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
-		<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"
@@ -678,14 +672,10 @@
 		class="org.hisp.dhis.caseentry.action.patient.SaveIdentifierAndAttributeAction"
 		scope="prototype">
 		<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="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" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
@@ -806,14 +796,13 @@
 			<ref
 				bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 		</property>
-		<property name="patientAttributeGroupService"
-			ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
 		<property name="patientIdentifierTypeService">
 			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		</property>
 		<property name="relationshipTypeService">
 			<ref bean="org.hisp.dhis.relationship.RelationshipTypeService" />
 		</property>
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-09-05 01:41:15 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-09-05 14:30:23 +0000
@@ -429,4 +429,5 @@
 show_hide_content = Show/Hide content
 completed_date = Completed date
 find_and_add_person = Find/Add Person
-add_person = Add Person
\ No newline at end of file
+add_person = Add Person
+identifiers_and_attributes = Identifiers / attributes
\ No newline at end of file

=== 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-09-05 01:41:15 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-09-05 14:30:23 +0000
@@ -66,14 +66,14 @@
 			class="org.hisp.dhis.caseentry.action.caseentry.CompleteDataEntryAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-		<param name="requiredAuthorities">F_PATIENT_DATAVALUE_ADD,F_PATIENT_DATAVALUE_UPDATE,F_PATIENT_DATAVALUE_DELETE</param>
+			<param name="requiredAuthorities">F_PATIENT_DATAVALUE_ADD,F_PATIENT_DATAVALUE_UPDATE,F_PATIENT_DATAVALUE_DELETE</param>
 		</action>
-		
+
 		<action name="uncompleteDataEntry"
 			class="org.hisp.dhis.caseentry.action.caseentry.UncompleteDataEntryAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-		<param name="requiredAuthorities">F_PATIENT_DATAVALUE_ADD,F_PATIENT_DATAVALUE_UPDATE,F_PATIENT_DATAVALUE_DELETE</param>
+			<param name="requiredAuthorities">F_PATIENT_DATAVALUE_ADD,F_PATIENT_DATAVALUE_UPDATE,F_PATIENT_DATAVALUE_DELETE</param>
 		</action>
 
 		<action name="saveExecutionDate"
@@ -85,7 +85,7 @@
 			<param name="onExceptionReturn">plainTextError</param>
 			<param name="requiredAuthorities">F_PATIENT_DATAVALUE_ADD,F_PATIENT_DATAVALUE_UPDATE,F_PATIENT_DATAVALUE_DELETE</param>
 		</action>
-		
+
 		<action name="registerIrregularEncounter"
 			class="org.hisp.dhis.caseentry.action.caseentry.RegisterIrregularEncounterAction">
 			<result name="success" type="velocity-json">
@@ -107,28 +107,28 @@
 			<param name="stylesheets">style/style.css</param>
 			<param name="requiredAuthorities">F_NAME_BASED_DATA_ENTRY</param>
 		</action>
-		
+
 		<action name="anonymousPrograms"
 			class="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction">
 			<result name="success" type="velocity-json">/dhis-web-caseentry/jsonSingleEventPrograms.vm</result>
 			<param name="requiredAuthorities">F_NAME_BASED_DATA_ENTRY</param>
 		</action>
-		
+
 		<action name="createAnonymousEncounter"
 			class="org.hisp.dhis.caseentry.action.caseentry.CreateAnonymousEncounterAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>			
+				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
 			<param name="requiredAuthorities">F_PATIENT_DATAVALUE_ADD,F_PATIENT_DATAVALUE_UPDATE,F_PATIENT_DATAVALUE_DELETE</param>
 		</action>
-		
+
 		<action name="loadAnonymousPrograms"
 			class="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-caseentry/jsonProgramInstances.vm</result>
 		</action>
-		
+
 		<action name="removeCurrentEncounter"
 			class="org.hisp.dhis.caseentry.action.caseentry.RemoveCurrentEncounterAction">
 			<result name="success" type="velocity-json">
@@ -137,36 +137,37 @@
 				/dhis-web-commons/ajax/jsonResponseError.vm</result>
 			<param name="requiredAuthorities">F_PATIENT_DATAVALUE_ADD,F_PATIENT_DATAVALUE_UPDATE,F_PATIENT_DATAVALUE_DELETE</param>
 		</action>
-		
+
 		<action name="validateProgram"
 			class="org.hisp.dhis.caseentry.action.caseentry.ValidateProgramInstanceAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/validationResult.vm</param>
 		</action>
-		
-		<action name="getOptions" class="org.hisp.dhis.caseentry.action.caseentry.GetOptionsByDataElementAction">
-	      <result name="success" type="velocity-json">/dhis-web-caseentry/jsonOptions.vm</result>
-	    </action>
-		
+
+		<action name="getOptions"
+			class="org.hisp.dhis.caseentry.action.caseentry.GetOptionsByDataElementAction">
+			<result name="success" type="velocity-json">/dhis-web-caseentry/jsonOptions.vm</result>
+		</action>
+
 		<action name="getProgramStageDataElementList"
 			class="org.hisp.dhis.caseentry.action.caseentry.GetProgramStageDataElementsAction">
 			<result name="success" type="velocity-json">/dhis-web-caseentry/jsonProgramStageDataElements.vm</result>
 		</action>
-		
+
 		<action name="searchProgramStageInstances"
 			class="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/programStageInstancesList.vm</param>
 			<param name="requiredAuthorities">F_NAME_BASED_DATA_ENTRY</param>
 		</action>
-		
+
 		<action name="removeEmptyEvents"
 			class="org.hisp.dhis.caseentry.action.caseentry.RemoveEmptyEventsAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 			<param name="requiredAuthorities">F_PATIENT_REMOVE_EMPTY_EVENTS</param>
 		</action>
-		
+
 		<!-- save value -->
 
 		<action name="saveValue"
@@ -197,7 +198,7 @@
 			<param name="page">/dhis-web-caseentry/multiDataEntrySelect.vm</param>
 			<param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>
 			<param name="stylesheets">style/style.css</param>
-			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/commons.js,javascript/multiDataEntry.js</param>			
+			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/commons.js,javascript/multiDataEntry.js</param>
 			<param name="requiredAuthorities">F_NAME_BASED_DATA_ENTRY</param>
 		</action>
 
@@ -234,9 +235,9 @@
 				getDataRecords.action?programId=${programId}</result>
 			<param name="requiredAuthorities">F_PATIENT_DATAVALUE_ADD,F_PATIENT_DATAVALUE_UPDATE,F_PATIENT_DATAVALUE_DELETE</param>
 		</action>
-		
+
 		<!-- Single-event DataEntry -->
-		
+
 		<action name="singleEventSelect"
 			class="org.hisp.dhis.caseentry.action.patient.SelectAction">
 			<interceptor-ref name="organisationUnitTreeStack" />
@@ -253,26 +254,26 @@
 			<param name="stylesheets">style/style.css</param>
 			<param name="requiredAuthorities">F_NAME_BASED_DATA_ENTRY</param>
 		</action>
-		
+
 		<action name="singleEventPrograms"
 			class="org.hisp.dhis.caseentry.action.caseentry.GetSingleEventProgramListAction">
 			<result name="success" type="velocity-json">/dhis-web-caseentry/jsonSingleEventPrograms.vm</result>
 			<param name="requiredAuthorities">F_NAME_BASED_DATA_ENTRY</param>
 		</action>
-		
+
 		<action name="showEventWithRegistrationForm"
 			class="org.hisp.dhis.caseentry.action.caseentry.ShowEventWithRegistrationFormAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/addSingleEventRegistration.vm</param>
 			<param name="stylesheets">style/style.css</param>
 		</action>
-		
+
 		<action name="saveValues"
 			class="org.hisp.dhis.caseentry.action.caseentry.SaveValuesAction">
 			<result name="success" type="velocity-xml">status.vm</result>
 			<param name="requiredAuthorities">F_PATIENT_DATAVALUE_ADD,F_PATIENT_DATAVALUE_UPDATE,F_PATIENT_DATAVALUE_DELETE</param>
 		</action>
-		
+
 		<!-- Visit Plan -->
 
 		<action name="visitplan"
@@ -319,18 +320,18 @@
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/records.vm</param>
 		</action>
-        
-        <action name="getReportPrograms"
+
+		<action name="getReportPrograms"
 			class="org.hisp.dhis.caseentry.action.caseentry.GetProgramsByOrgunitAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-caseentry/responsePrograms.vm</result>
 		</action>
 		<!-- i18n -->
 
-        <action name="i18n" class="org.hisp.dhis.caseentry.action.NoAction">
-            <result name="success" type="velocity-javascript">/dhis-web-caseentry/i18n.vm</result>
-        </action>
-        
+		<action name="i18n" class="org.hisp.dhis.caseentry.action.NoAction">
+			<result name="success" type="velocity-javascript">/dhis-web-caseentry/i18n.vm</result>
+		</action>
+
 		<!-- Case Aggregation -->
 
 		<action name="caseAggregationForm"
@@ -367,7 +368,7 @@
 			<param name="javascripts">javascript/caseagg.js</param>
 			<param name="requiredAuthorities">F_PATIENT_AGGREGATION</param>
 		</action>
-		
+
 		<action name="saveAggregateDataValue"
 			class="org.hisp.dhis.caseentry.action.caseaggregation.SaveAggregateDataValueAction">
 			<result name="success" type="velocity-json">
@@ -410,7 +411,7 @@
 			<param name="stylesheets">style/style.css</param>
 			<param name="requiredAuthorities">F_PATIENT_MANAGEMENT</param>
 		</action>
-		
+
 		<action name="showAddPatientFormFormMenu"
 			class="org.hisp.dhis.caseentry.action.patient.ShowAddPatientFormAction">
 			<interceptor-ref name="organisationUnitTreeStack" />
@@ -427,7 +428,7 @@
 			<param name="stylesheets">style/style.css</param>
 			<param name="requiredAuthorities">F_PATIENT_ADD</param>
 		</action>
-		
+
 
 		<action name="searchRegistrationPatient"
 			class="org.hisp.dhis.caseentry.action.patient.SearchPatientAction">
@@ -435,7 +436,7 @@
 			<param name="page">/dhis-web-caseentry/patientRegistrationList.vm</param>
 			<param name="requiredAuthorities">F_PATIENT_MANAGEMENT</param>
 		</action>
-		
+
 		<action name="removePatient"
 			class="org.hisp.dhis.caseentry.action.patient.RemovePatientAction">
 			<result name="success" type="velocity-json">
@@ -510,35 +511,35 @@
 			</result>
 			<param name="requiredAuthorities">F_PATIENT_ADD</param>
 		</action>
- 
-   		<action name="getPatientHistory"
+
+		<action name="getPatientHistory"
 			class="org.hisp.dhis.caseentry.action.patient.GetPatientHistoryAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<result name="xls" type="gridXlsResult" />
-      		<result name="pdf" type="gridPdfResult" />
+			<result name="pdf" type="gridPdfResult" />
 			<param name="page">/dhis-web-caseentry/patientHistory.vm</param>
 		</action>
-		
+
 		<action name="getProgramReportHistory"
 			class="org.hisp.dhis.caseentry.action.patient.GetProgramInstanceHistoryAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/programInstanceHistory.vm</param>
 		</action>
-		
+
 		<action name="getPatientLocation"
 			class="org.hisp.dhis.caseentry.action.patient.GetPatientLocationAction">
 			<result name="success" type="velocity">/content.vm</result>
-			<param name="page">/dhis-web-caseentry/patientLocation.vm</param>			
+			<param name="page">/dhis-web-caseentry/patientLocation.vm</param>
 			<param name="requiredAuthorities">F_PATIENT_UPDATE</param>
 		</action>
-		
+
 		<action name="registerPatientLocation"
 			class="org.hisp.dhis.caseentry.action.patient.RegisterPatientLocationAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 			<param name="requiredAuthorities">F_PATIENT_UPDATE</param>
 		</action>
-		
+
 		<!-- Patient-Program Enrollment -->
 
 		<action name="showProgramEnrollmentForm"
@@ -577,7 +578,7 @@
 			<result name="success" type="velocity-json">
 				/dhis-web-caseentry/responseProgramInstance.vm</result>
 		</action>
-		
+
 		<action name="getEventMessages"
 			class="org.hisp.dhis.caseentry.action.patient.GetProgramInstanceAction">
 			<result name="success" type="velocity">/content.vm</result>
@@ -598,19 +599,19 @@
 			<param name="onExceptionReturn">plainTextError</param>
 			<param name="requiredAuthorities">F_PROGRAM_ENROLLMENT</param>
 		</action>
-		
+
 		<action name="savePatientIdentifierAndAttribute"
 			class="org.hisp.dhis.caseentry.action.patient.SaveIdentifierAndAttributeAction">
 			<result name="success" type="velocity-xml">status.vm</result>
 			<param name="requiredAuthorities">F_PATIENT_UPDATE, F_PROGRAM_ENROLLMENT</param>
 		</action>
-		
+
 		<action name="removeEnrollment"
 			class="org.hisp.dhis.caseentry.action.patient.RemoveEnrollmentAction">
 			<result name="success" type="velocity-xml">status.vm</result>
 			<param name="requiredAuthorities">F_PATIENT_UPDATE, F_PROGRAM_ENROLLMENT</param>
 		</action>
-		
+
 		<!-- Relationship -->
 
 		<action name="getPartner"
@@ -660,7 +661,7 @@
 				/dhis-web-commons/ajax/xmlResponseError.vm</result>
 			<result name="input" type="velocity-xml">
 				/dhis-web-commons/ajax/xmlResponseInput.vm</result>
-			<param name="onExceptionReturn">plainTextError</param>			
+			<param name="onExceptionReturn">plainTextError</param>
 			<param name="requiredAuthorities">F_RELATIONSHIP_ADD</param>
 		</action>
 
@@ -690,7 +691,7 @@
 				/dhis-web-commons/ajax/xmlResponseError.vm</result>
 			<result name="input" type="velocity-xml">
 				/dhis-web-commons/ajax/xmlResponseInput.vm</result>
-			<param name="onExceptionReturn">plainTextError</param>			
+			<param name="onExceptionReturn">plainTextError</param>
 			<param name="requiredAuthorities">F_RELATIONSHIP_DELETE</param>
 		</action>
 
@@ -720,9 +721,9 @@
 				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 			<param name="requiredAuthorities">F_RELATIONSHIP_ADD</param>
 		</action>
-		
+
 		<!-- Tabular report -->
-		
+
 		<action name="tabularReportSelect"
 			class="org.hisp.dhis.caseentry.action.report.TabularReportSelectAction">
 			<interceptor-ref name="organisationUnitTreeStack" />
@@ -733,40 +734,40 @@
 			<param name="stylesheets">style/style.css</param>
 			<param name="requiredAuthorities">F_GENERATE_BENEFICIARY_TABULAR_REPORT</param>
 		</action>
-		
+
 		<action name="getOrganisationUnitChildren"
 			class="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitChildrenAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-caseentry/jsonminOrganisationUnitChildren.vm</result>
 		</action>
-		
+
 		<action name="tabularInitialize"
 			class="org.hisp.dhis.caseentry.action.report.TabularInitializeAction">
-			 <result name="success" type="velocity-json">
-		        /dhis-web-caseentry/jsonTabularInitialize.vm</result>
+			<result name="success" type="velocity-json">
+				/dhis-web-caseentry/jsonTabularInitialize.vm</result>
 		</action>
-		
+
 		<action name="loadPatientProperties"
 			class="org.hisp.dhis.caseentry.action.report.LoadPatientPropertiesAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-caseentry/jsonPatientProperties.vm</result>
 		</action>
-		
+
 		<action name="loadReportProgramStages"
 			class="org.hisp.dhis.caseentry.action.report.LoadProgramStagesAction">
 			<result name="success" type="velocity-json">/dhis-web-caseentry/jsonProgramStages.vm</result>
 		</action>
-	
+
 		<action name="loadDataElements"
 			class="org.hisp.dhis.caseentry.action.report.LoadDataElementsAction">
 			<result name="success" type="velocity-json">/dhis-web-caseentry/responseDataElements.vm</result>
 		</action>
-		
+
 		<action name="getTabularParams"
 			class="org.hisp.dhis.caseentry.action.report.GetTabularParamsAction">
 			<result name="success" type="velocity-json">/dhis-web-caseentry/responseTabularParams.vm</result>
 		</action>
-		
+
 		<action name="validateTabularReport"
 			class="org.hisp.dhis.caseentry.action.report.ValidateTabularReportAction">
 			<result name="success" type="velocity-json">
@@ -774,51 +775,51 @@
 			<result name="input" type="velocity-json">
 				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
 		</action>
-		
+
 		<action name="generateTabularReport"
 			class="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction">
 			<result name="success" type="velocity-json">/dhis-web-caseentry/jsonTabularReportResult.vm</result>
 			<result name="xls" type="gridXlsResult" />
-		    <result name="pdf" type="gridPdfResult" />
+			<result name="pdf" type="gridPdfResult" />
 			<param name="requiredAuthorities">F_GENERATE_BENEFICIARY_TABULAR_REPORT</param>
 		</action>
-			
+
 		<action name="saveTabularReport"
-            class="org.hisp.dhis.caseentry.action.report.SaveTabularReportAction">
-            <result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-        </action>
-        
-        <action name="getTabularReports"
-            class="org.hisp.dhis.caseentry.action.report.GetTabularReportsAction">
-            <result name="success" type="velocity-json">
-                /dhis-web-caseentry/jsonTabularReportList.vm</result>
-        </action>
-
- 		<action name="getTabularReport"
-            class="org.hisp.dhis.caseentry.action.report.GetTabularReportAction">
-            <result name="success" type="velocity-json">
-                /dhis-web-caseentry/jsonTabularReport.vm</result>
-        </action>
-        
-        <action name="updateTabularReportName"
-            class="org.hisp.dhis.caseentry.action.report.UpdateTabularReportNameAction">
-            <result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-        </action>
-        
-        <action name="deleteTabularReport"
-            class="org.hisp.dhis.caseentry.action.report.DeleteTabularReportAction">
-            <result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-        </action>
-        
-        <action name="viewRecord"
+			class="org.hisp.dhis.caseentry.action.report.SaveTabularReportAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+		</action>
+
+		<action name="getTabularReports"
+			class="org.hisp.dhis.caseentry.action.report.GetTabularReportsAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-caseentry/jsonTabularReportList.vm</result>
+		</action>
+
+		<action name="getTabularReport"
+			class="org.hisp.dhis.caseentry.action.report.GetTabularReportAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-caseentry/jsonTabularReport.vm</result>
+		</action>
+
+		<action name="updateTabularReportName"
+			class="org.hisp.dhis.caseentry.action.report.UpdateTabularReportNameAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+		</action>
+
+		<action name="deleteTabularReport"
+			class="org.hisp.dhis.caseentry.action.report.DeleteTabularReportAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+		</action>
+
+		<action name="viewRecord"
 			class="org.hisp.dhis.caseentry.action.caseentry.ProgramStageCustomDataEntryAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/programStageDataEntryForm.vm</param>
 		</action>
-		
+
 		<!-- SMS Reminder -->
 
 		<action name="smsReminderSelect"
@@ -828,60 +829,65 @@
 			<param name="page">/dhis-web-caseentry/smsReminderSelect.vm</param>
 			<param name="menu">/dhis-web-caseentry/smsMenu.vm</param>
 			<param name="stylesheets">style/style.css</param>
-			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/commons.js,javascript/smsReminder.js</param>			
+			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/commons.js,javascript/smsReminder.js</param>
 			<param name="requiredAuthorities">F_SMS_REMINDER</param>
 		</action>
-		
+
 		<action name="getSMSPatientRecords"
 			class="org.hisp.dhis.caseentry.action.caseentry.GetDataRecordsAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/smsPatientRecords.vm</param>
 			<param name="stylesheets">style/style.css</param>
 		</action>
-		
+
 		<action name="getOutboundSmsList"
 			class="org.hisp.dhis.caseentry.action.reminder.GetOutboundSmsListAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/smsReminderList.vm</param>
 			<param name="stylesheets">style/style.css</param>
 		</action>
-		
+
 		<action name="getGateway"
 			class="org.hisp.dhis.caseentry.action.reminder.GetGatewayAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/sendSmsForm.vm</param>
 			<param name="stylesheets">style/style.css</param>
 		</action>
-		
-	    <action name="sendSMS" class="org.hisp.dhis.caseentry.action.reminder.SendSmsAction">
-	      <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-	      <result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
-	      <param name="onExceptionReturn">plainTextError</param>
-	    </action>
-	    
-	    <action name="sendSMSTotList" class="org.hisp.dhis.caseentry.action.reminder.SendSmsToListAction">
-	      <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-	      <result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
-	      <param name="onExceptionReturn">plainTextError</param>
-	    </action>
-	    
-	    <!-- Dashboard -->
-	    
-	    <action name="patientDashboard" class="org.hisp.dhis.caseentry.action.patient.PatientDashboardAction">
-	      <result name="success" type="velocity">/content.vm</result>
-		  <param name="page">/dhis-web-caseentry/patientDashboard.vm</param>
-		  <param name="stylesheets">style/style.css</param>
-	    </action>
-	    
-	     <!-- Comment -->
-	    
-	    <action name="addComment" class="org.hisp.dhis.caseentry.action.reminder.AddCommentAction">
-	       <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-	    </action>
-	    
-	    <action name="removeComment" class="org.hisp.dhis.caseentry.action.reminder.RemoveCommentAction">
-	       <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-	    </action>
-	    
+
+		<action name="sendSMS"
+			class="org.hisp.dhis.caseentry.action.reminder.SendSmsAction">
+			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+			<result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
+			<param name="onExceptionReturn">plainTextError</param>
+		</action>
+
+		<action name="sendSMSTotList"
+			class="org.hisp.dhis.caseentry.action.reminder.SendSmsToListAction">
+			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+			<result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
+			<param name="onExceptionReturn">plainTextError</param>
+		</action>
+
+		<!-- Dashboard -->
+
+		<action name="patientDashboard"
+			class="org.hisp.dhis.caseentry.action.patient.PatientDashboardAction">
+			<result name="success" type="velocity">/content.vm</result>
+			<param name="page">/dhis-web-caseentry/patientDashboard.vm</param>
+			<param name="stylesheets">style/style.css</param>
+		</action>
+
+		<!-- Comment -->
+
+		<action name="addComment"
+			class="org.hisp.dhis.caseentry.action.reminder.AddCommentAction">
+			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+		</action>
+
+		<action name="removeComment"
+			class="org.hisp.dhis.caseentry.action.reminder.RemoveCommentAction">
+			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+		</action>
+
 	</package>
 </struts>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-08-29 01:33:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-09-05 14:30:23 +0000
@@ -218,6 +218,7 @@
 function getSearchParams()
 {
 	var params = "";
+	var programIds = "";
 	var programStageId = jQuery('#programStageAddPatient').val();
 	if( getFieldValue('searchByProgramStage') == "true" && programStageId!=''){
 		var statusEvent = jQuery('#programStageAddPatientTR [id=statusEvent]').val();
@@ -226,12 +227,17 @@
 		params += '&searchTexts=prgst_' + programStageId + '_' + statusEvent + '_' + startDueDate + '_' + endDueDate;
 	}
 	
+	var flag = false;
 	jQuery( '#advancedSearchTB tr' ).each( function( i, row ){
 		var dateOperator = "";
 		var p = "";
 		jQuery( this ).find(':input').each( function( idx, item ){
 			if( idx == 0){
 				p = "&searchTexts=" + item.value;
+				if(item.value=='prg'){
+					programIds += '&programIds=';
+					flag = true;
+				}
 			}
 			else if( item.name == 'dateOperator'){
 				dateOperator = item.value;
@@ -246,6 +252,11 @@
 					else{
 						p += htmlEncode( item.value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, "") );
 					}
+					
+					if( flag ){
+						programIds += item.value;
+						flag = false;
+					}
 				}
 				else {
 					p = "";
@@ -257,6 +268,7 @@
 		
 	params += '&listAll=false';
 	params += '&searchBySelectedOrgunit=' + byId('searchBySelectedOrgunit').checked;
+	params += programIds;
 	
 	return params;
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2012-08-29 06:02:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2012-09-05 14:30:23 +0000
@@ -90,12 +90,11 @@
 #end
 
 <!-- ATTRIBUTES IN GROUPS -->
-#foreach ($attributeGroup in $attributeGroups )
+#foreach ($attributeGroup in $attributeGroupsMap.keySet() )
 	<tr><td>&nbsp;</td></tr>
 	<tr><th colspan="2" class="heading-column">$attributeGroup.name</th></tr>
-	#foreach($attribute in $attributeGroup.attributes )
-		#if( $!attribute && $attribute.program )
-		#elseif( $!attribute)
+	#set($attributes = $attributeGroupsMap.get($attributeGroup))
+	#foreach($attribute in $attributes )
 		<tr>
 			<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">
@@ -122,7 +121,6 @@
 				#end
 			</td>		
 		</tr>
-		#end
 	#end
 #end
 

=== 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-09-05 01:41:15 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2012-09-05 14:30:23 +0000
@@ -28,7 +28,13 @@
 			#foreach( $attribute in $patientAttributes )
 				#if($attribute)<col/>#end
 			#end
-          <col/>
+			
+			#foreach( $identifierType in $identifierTypes)
+				<col/>
+			#end
+			#if( $identifierTypes.size()==0 )
+				<col/>       
+			#end
           <col/>
           <col/>
           <col/>
@@ -42,16 +48,27 @@
 				<th>#</th>
 				#foreach( $attribute in $patientAttributes )
 					#if($attribute)
-					<th id="patientAttributeName">$attribute.name</th>
+						<th id="patientAttributeName">$attribute.name</th>
 					#end
 				#end
-				<th>$i18n.getString( "full_name" )</th>          
+				
+				#foreach( $identifierType in $identifierTypes)
+					<th>
+						$identifierType.name
+					</th>
+				#end
+				#if( $identifierTypes.size()==0 )
+					<th>$i18n.getString( "full_name" )</th>          
+				#end
+				
 				<th>$i18n.getString( "gender" )</th>
 				<th>$i18n.getString( "date_of_birth" )</th> 
 				<th class="{sorter: false}">$i18n.getString( "age" )</th>
+				
 				#if($mapPatientOrgunit.size()!=0)
-				<th>$i18n.getString( "hierachy_orgunit" )</th>
+					<th>$i18n.getString( "hierachy_orgunit" )</th>
 				#end
+				
 				<th style="text-align:center" class="{sorter: false}">$i18n.getString( "operations" )</th>
 			  </tr>
           </thead>
@@ -79,7 +96,21 @@
 					#end
 				#end
 					
-				<td onclick="javascript:showPatientDashboardForm( '$patient.id' )">$!patient.getFullName()</td>
+				#foreach( $identifierType in $identifierTypes)
+					#foreach( $identifier in $patient.identifiers)
+						#if($identifier.identifierType.id==$identifierType.id)
+							<td onclick="javascript:showPatientDashboardForm( '$patient.id' )">
+								$identifier.identifier
+							</td>
+						#end
+					#end
+				#end
+				#if( $identifierTypes.size()==0 )
+					<td onclick="javascript:showPatientDashboardForm( '$patient.id' )">
+						$!patient.getFullName()
+					</td>
+				#end
+				
 				
 				<td>$i18n.getString($!patient.gender)</td>
 				

=== 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-09-04 10:10:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2012-09-05 14:30:23 +0000
@@ -1,5 +1,4 @@
 #set($noIden = $identifierTypes.size() )
-#set($noOtherGroup = $noGroupAttributes.size() )
 #set($noGroup = $attributeGroups.size() )
 #if( $programInstance || $hasDataEntry=='true')
 <input type='hidden' id='programInstanceId' name='programInstanceId' value='$programInstance.id' />
@@ -66,13 +65,12 @@
 					#end
 					
 				<!-- ATTRIBUTES IN GROUPS -->
-				#foreach ($attributeGroup in $attributeGroups )
+				#foreach ($attributeGroup in $attributeGroupsMap.keySet() )
 					<tr><td>&nbsp;</td></tr>	
 					<tr><th colspan="2" class="heading-column">$attributeGroup.name</th></tr>
 					#set( $mark = false )
-					#foreach($attribute in $attributeGroup.attributes)
-						#if( $attribute.program && $attribute.program.id == $programInstance.program.id )
-							#set( $attributeValue = '')
+					#set($attributes = $attributeGroupsMap.get($attributeGroup))
+						#foreach($attribute in $attributes )
 							#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>
@@ -101,48 +99,6 @@
 								</td>		
 							</tr>
 							#set( $mark = !$mark  )
-						#end
-					#end
-				#end
-				<tr><td>&nbsp;</td></tr>
-
-				<!-- ATTRIBUTES NOT IN GROUPS -->
-
-				#if ( $noGroupAttributes && $noOtherGroup > 0) 	
-					<tr><th colspan="2" class="heading-column">$i18n.getString( "Other details" )</th></tr>
-					#set( $mark = false )
-					#foreach($attribute in $noGroupAttributes )
-						#if( $attribute.program && $attribute.program.id == $programInstance.program.id)
-							#set( $attributeValue = '')
-							#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" >              
-											<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 )' >
-										<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 )' >
-											 <option value="">[$i18n.getString( "please_select" )]</option>
-										#foreach ($option in $attribute.attributeOptions )
-											<option value="$option.id" #if($attributeValue == $option.name) selected="selected" #end>$option.name</option>
-										#end
-										</select>
-									#else
-										<input type="text"  id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" >
-									#end
-								</td>		
-							</tr>
-							#set( $mark = !$mark  )
-						#end
 					#end
 				#end
 				<tr><td>&nbsp;</td></tr>

=== 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-08-12 06:10:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm	2012-09-05 14:30:23 +0000
@@ -170,45 +170,43 @@
 			#end
 		#end
 	#end
+	
 	<!-- ATTRIBUTES IN GROUPS -->
-
-	#foreach ($attributeGroup in $attributeGroups )
-		<tr><td>&nbsp;</td></tr>	
+	
+	#foreach ($attributeGroup in $attributeGroupsMap.keySet() )
+		<tr><td>&nbsp;</td></tr>
 		<tr><th colspan="2" class="heading-column">$attributeGroup.name</th></tr>
-		#foreach($attribute in $attributeGroup.attributes)
-			#if( $!attribute && $attribute.program )
-			#elseif( $!attribute )
-				#set( $attributeValue = "" )
-				#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>
-					<td class="input-column">
-						#if( $attribute.valueType == "YES/NO" )
-							<select id="attr$attribute.id"  name="attr$attribute.id" >              
-								<option value="">[$i18n.getString( "please_select" )]</option>
-								<option value="true" #if( $attributeValue=='true') selected="selected" #end>$i18n.getString( "yes" )</option>
-								<option value="false" #if( $attributeValue=='false') selected="selected" #end>$i18n.getString( "no" )</option>
-							</select>                
-						#elseif( $attribute.valueType == "DATE" )
-							<input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class=' #validate( "default"  $attribute.mandatory )'>
-							<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 )'>
-								 <option value="">[$i18n.getString( "please_select" )]</option>
+		#set($attributes = $attributeGroupsMap.get($attributeGroup))
+		#foreach($attribute in $attributes )
+			<tr>
+				<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"> 
+							<option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
+							<option value="true">$i18n.getString( "yes" )</option>
+							<option value="false">$i18n.getString( "no" )</option>
+						</select>                
+					#elseif( $attribute.valueType == "DATE" )
+						<input type="text" id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )'/>
+						<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 )'>
+							<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>
+								<option value="$option.id" >$option.name</option>
 							#end
-							</select>
-						#else 
-							<input type="text"  id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" >
-						#end
-					</td>		
-				</tr>
-			#end
+						</select>
+					#else 
+						<input type="text" id="attr$attribute.id" name="attr$attribute.id" class="{validate:{required:$attribute.mandatory #if($attribute.valueType=='NUMBER'),number:true #end }}" />
+					#end
+				</td>		
+			</tr>
 		#end
 	#end
+
 	<tr><td>&nbsp;</td></tr>
 
 	<!-- ATTRIBUTES NOT IN GROUPS -->

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java	2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java	2012-09-05 14:30:23 +0000
@@ -102,8 +102,15 @@
 
         if ( program.isRegistration() )
         {
-            patientAttributes.addAll( attributeService.getPatientAttributes( null, null ) );
-            patientAttributes.addAll( attributeService.getPatientAttributes( program ) );
+            patientAttributes = attributeService.getAllPatientAttributes();
+
+            Collection<Program> programs = programService.getAllPrograms();
+            programs.remove( program );
+            
+            for ( Program _program : programs )
+            {
+                patientAttributes.remove( _program.getPatientAttributes() );
+            }
         }
         
         return SUCCESS;

=== 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	2012-07-30 04:48:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/AddPatientAttributeAction.java	2012-09-05 14:30:23 +0000
@@ -33,8 +33,6 @@
 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;
 
@@ -62,14 +60,7 @@
     {
         this.patientAttributeOptionService = patientAttributeOptionService;
     }
-
-    private ProgramService programService;
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
+    
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -109,13 +100,6 @@
         this.attrOptions = attrOptions;
     }
 
-    private Integer programId;
-
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -132,9 +116,6 @@
         mandatory = (mandatory == null) ? false : true;
         patientAttribute.setMandatory( mandatory );
         
-        Program program = (programId != null) ? programService.getProgram( programId ) : null;
-        patientAttribute.setProgram( program );
-
         patientAttributeService.savePatientAttribute( patientAttribute );
 
         if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( valueType ) )

=== 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	2012-07-30 04:48:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/UpdatePatientAttributeAction.java	2012-09-05 14:30:23 +0000
@@ -39,8 +39,6 @@
 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;
 
@@ -78,13 +76,6 @@
         this.patientAttributeValueService = patientAttributeValueService;
     }
 
-    private ProgramService programService;
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -154,9 +145,6 @@
         mandatory = (mandatory == null) ? false : true;
         patientAttribute.setMandatory( mandatory );
         
-        Program program = (programId != null) ? programService.getProgram( programId ) : null;
-        patientAttribute.setProgram( program );
-
         HttpServletRequest request = ServletActionContext.getRequest();
 
         Collection<PatientAttributeOption> attributeOptions = patientAttributeOptionService.get( patientAttribute );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/AddPatientIdentifierTypeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/AddPatientIdentifierTypeAction.java	2012-05-24 03:51:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/AddPatientIdentifierTypeAction.java	2012-09-05 14:30:23 +0000
@@ -29,8 +29,6 @@
 
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -46,9 +44,7 @@
     // -------------------------------------------------------------------------
 
     private PatientIdentifierTypeService patientIdentifierTypeService;
-
-    private ProgramService programService;
-
+    
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -65,8 +61,6 @@
 
     private String type;
 
-    private Integer programId;
-
     // -------------------------------------------------------------------------
     // Getters && Setters
     // -------------------------------------------------------------------------
@@ -91,11 +85,6 @@
         this.description = description;
     }
 
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
     public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
     {
         this.patientIdentifierTypeService = patientIdentifierTypeService;
@@ -111,11 +100,6 @@
         this.related = related;
     }
 
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -136,9 +120,6 @@
         identifierType.setNoChars( noChars );
         identifierType.setType( type );
 
-        Program program = (programId != null) ? programService.getProgram( programId ) : null;
-        identifierType.setProgram( program );
-
         patientIdentifierTypeService.savePatientIdentifierType( identifierType );
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/UpdatePatientIdentifierTypeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/UpdatePatientIdentifierTypeAction.java	2012-05-24 03:51:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/UpdatePatientIdentifierTypeAction.java	2012-09-05 14:30:23 +0000
@@ -47,8 +47,6 @@
 
     private PatientIdentifierTypeService patientIdentifierTypeService;
 
-    private ProgramService programService;
-
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -67,8 +65,6 @@
 
     private String type;
 
-    private Integer programId;
-
     // -------------------------------------------------------------------------
     // Getters && Setters
     // -------------------------------------------------------------------------
@@ -93,11 +89,6 @@
         this.name = name;
     }
 
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
     public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
     {
         this.patientIdentifierTypeService = patientIdentifierTypeService;
@@ -117,12 +108,7 @@
     {
         this.related = related;
     }
-
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -145,9 +131,6 @@
             identifierType.setNoChars( noChars );
             identifierType.setType( type );
 
-            Program program = (programId != null) ? programService.getProgram( programId ) : null;
-            identifierType.setProgram( program );
-
             patientIdentifierTypeService.updatePatientIdentifierType( identifierType );
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java	2012-08-06 09:34:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java	2012-09-05 14:30:23 +0000
@@ -27,8 +27,17 @@
 
 package org.hisp.dhis.patient.action.program;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
 
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
@@ -72,6 +81,20 @@
         this.programInstanceService = programInstanceService;
     }
 
+    private PatientIdentifierTypeService patientIdentifierTypeService;
+
+    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
+    {
+        this.patientIdentifierTypeService = patientIdentifierTypeService;
+    }
+
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -132,6 +155,20 @@
         this.displayIncidentDate = displayIncidentDate;
     }
 
+    private List<String> selectedPropertyIds = new ArrayList<String>();
+
+    public void setSelectedPropertyIds( List<String> selectedPropertyIds )
+    {
+        this.selectedPropertyIds = selectedPropertyIds;
+    }
+
+    private List<Boolean> personDisplayNames = new ArrayList<Boolean>();
+
+    public void setPersonDisplayNames( List<Boolean> personDisplayNames )
+    {
+        this.personDisplayNames = personDisplayNames;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -141,7 +178,7 @@
     {
         displayProvidedOtherFacility = (displayProvidedOtherFacility == null) ? false : displayProvidedOtherFacility;
         displayIncidentDate = (displayIncidentDate == null) ? false : displayIncidentDate;
-        
+
         Program program = new Program();
 
         program.setName( name );
@@ -152,8 +189,38 @@
         program.setMaxDaysAllowedInputData( maxDaysAllowedInputData );
         program.setType( type );
         program.setDisplayProvidedOtherFacility( displayProvidedOtherFacility );
-        program.setDisplayIncidentDate(displayIncidentDate);
-        
+        program.setDisplayIncidentDate( displayIncidentDate );
+
+        Collection<PatientIdentifierType> identifierTypes = new HashSet<PatientIdentifierType>();
+        Collection<PatientAttribute> patientAttributes = new HashSet<PatientAttribute>();
+        int index = 0;
+        for ( String selectedPropertyId : selectedPropertyIds )
+        {
+            String[] ids = selectedPropertyId.split( "_" );
+
+            if ( ids[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) )
+            {
+                PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer
+                    .parseInt( ids[1] ) );
+
+                identifierType.setPersonDisplayName( personDisplayNames.get( index ) );
+                patientIdentifierTypeService.updatePatientIdentifierType( identifierType );
+
+                identifierTypes.add( identifierType );
+            }
+            else if ( ids[0].equals( Patient.PREFIX_PATIENT_ATTRIBUTE ) )
+            {
+                PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( Integer
+                    .parseInt( ids[1] ) );
+                patientAttributes.add( patientAttribute );
+            }
+
+            index++;
+        }
+
+        program.setPatientIdentifierTypes( identifierTypes );
+        program.setPatientAttributes( patientAttributes );
+
         programService.saveProgram( program );
 
         if ( program.getType().equals( Program.SINGLE_EVENT_WITH_REGISTRATION )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.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/program/ShowAddProgramFormAction.java	2012-09-05 14:30:23 +0000
@@ -27,11 +27,14 @@
 
 package org.hisp.dhis.patient.action.program;
 
-import java.util.ArrayList;
 import java.util.Collection;
 
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -46,22 +49,43 @@
     // Dependency
     // -------------------------------------------------------------------------
 
-    private ProgramStageService programStageService;
-
-    public void setProgramStageService( ProgramStageService programStageService )
-    {
-        this.programStageService = programStageService;
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    private PatientIdentifierTypeService patientIdentifierTypeService;
+
+    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
+    {
+        this.patientIdentifierTypeService = patientIdentifierTypeService;
+    }
+
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
     }
 
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
 
-    private Collection<ProgramStage> programStages;
-
-    public Collection<ProgramStage> getProgramStages()
-    {
-        return programStages;
+    private Collection<PatientIdentifierType> availableIdentifierTypes;
+
+    public Collection<PatientIdentifierType> getAvailableIdentifierTypes()
+    {
+        return availableIdentifierTypes;
+    }
+
+    private Collection<PatientAttribute> availableAttributes;
+
+    public Collection<PatientAttribute> getAvailableAttributes()
+    {
+        return availableAttributes;
     }
 
     // -------------------------------------------------------------------------
@@ -70,8 +94,18 @@
 
     public String execute()
     {
-        programStages = new ArrayList<ProgramStage>( programStageService.getAllProgramStages() );
-
+        availableIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+
+        availableAttributes = patientAttributeService.getAllPatientAttributes();
+
+        Collection<Program> programs = programService.getAllPrograms();
+        
+        for ( Program program : programs )
+        {
+            availableIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
+            availableAttributes.removeAll( program.getPatientAttributes() );
+        }
+        
         return SUCCESS;
     }
 }

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.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/program/ShowUpdateProgramFormAction.java	2012-09-05 14:30:23 +0000
@@ -0,0 +1,175 @@
+/*
+ * 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.program;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $Id$
+ */
+public class ShowUpdateProgramFormAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    private PatientIdentifierTypeService patientIdentifierTypeService;
+
+    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
+    {
+        this.patientIdentifierTypeService = patientIdentifierTypeService;
+    }
+
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private int id;
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    private Program program;
+
+    public Program getProgram()
+    {
+        return program;
+    }
+
+    private List<OrganisationUnitLevel> levels;
+
+    public List<OrganisationUnitLevel> getLevels()
+    {
+        return levels;
+    }
+
+    private List<OrganisationUnitGroup> groups;
+
+    public List<OrganisationUnitGroup> getGroups()
+    {
+        return groups;
+    }
+
+    private Integer level;
+
+    public Integer getLevel()
+    {
+        return level;
+    }
+
+    public void setLevel( Integer level )
+    {
+        this.level = level;
+    }
+
+    private Integer organisationUnitGroupId;
+
+    public Integer getOrganisationUnitGroupId()
+    {
+        return organisationUnitGroupId;
+    }
+
+    public void setOrganisationUnitGroupId( Integer organisationUnitGroupId )
+    {
+        this.organisationUnitGroupId = organisationUnitGroupId;
+    }
+
+    private Collection<PatientIdentifierType> availableIdentifierTypes;
+
+    public Collection<PatientIdentifierType> getAvailableIdentifierTypes()
+    {
+        return availableIdentifierTypes;
+    }
+
+    private Collection<PatientAttribute> availableAttributes;
+
+    public Collection<PatientAttribute> getAvailableAttributes()
+    {
+        return availableAttributes;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        program = programService.getProgram( id );
+
+        availableIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+
+        availableAttributes = patientAttributeService.getAllPatientAttributes();
+
+        Collection<Program> programs = programService.getAllPrograms();
+
+        for ( Program program : programs )
+        {
+            availableIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
+            availableAttributes.removeAll( program.getPatientAttributes() );
+        }
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java	2012-08-06 09:34:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java	2012-09-05 14:30:23 +0000
@@ -27,6 +27,16 @@
 
 package org.hisp.dhis.patient.action.program;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
 
@@ -50,6 +60,20 @@
         this.programService = programService;
     }
 
+    private PatientIdentifierTypeService patientIdentifierTypeService;
+
+    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
+    {
+        this.patientIdentifierTypeService = patientIdentifierTypeService;
+    }
+
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -129,6 +153,20 @@
         this.displayIncidentDate = displayIncidentDate;
     }
 
+    private List<String> selectedPropertyIds = new ArrayList<String>();
+
+    public void setSelectedPropertyIds( List<String> selectedPropertyIds )
+    {
+        this.selectedPropertyIds = selectedPropertyIds;
+    }
+    
+    private List<Boolean> personDisplayNames = new ArrayList<Boolean>();
+
+    public void setPersonDisplayNames( List<Boolean> personDisplayNames )
+    {
+        this.personDisplayNames = personDisplayNames;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -150,6 +188,33 @@
         program.setDisplayProvidedOtherFacility( displayProvidedOtherFacility );
         program.setDisplayIncidentDate(displayIncidentDate);
 
+        Collection<PatientIdentifierType> identifierTypes = new HashSet<PatientIdentifierType>();
+        Collection<PatientAttribute> patientAttributes = new HashSet<PatientAttribute>();
+        int index = 0;
+        for( String selectedPropertyId : selectedPropertyIds )
+        {
+            String[] ids = selectedPropertyId.split( "_" );
+            
+            if( ids[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ))
+            {
+                PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer.parseInt( ids[1] ));
+                
+                identifierType.setPersonDisplayName( personDisplayNames.get( index ) );
+                patientIdentifierTypeService.updatePatientIdentifierType( identifierType );
+                
+                identifierTypes.add( identifierType );
+            }
+            else if( ids[0].equals( Patient.PREFIX_PATIENT_ATTRIBUTE ))
+            {
+                PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( Integer.parseInt( ids[1] ));
+                patientAttributes.add( patientAttribute );
+            }
+            index++;
+        }
+        
+        program.setPatientIdentifierTypes( identifierTypes );
+        program.setPatientAttributes( patientAttributes );
+        
         programService.updateProgram( program );
 
         return SUCCESS;

=== 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-08-24 10:09:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-09-05 14:30:23 +0000
@@ -88,8 +88,6 @@
 			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
@@ -110,8 +108,6 @@
 			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
@@ -165,6 +161,8 @@
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.patient.action.program.GetProgramListAction"
@@ -196,13 +194,26 @@
 	<bean id="org.hisp.dhis.patient.action.program.ShowAddProgramFormAction"
 		class="org.hisp.dhis.patient.action.program.ShowAddProgramFormAction"
 		scope="prototype">
-		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-	</bean>
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+	</bean>
+	
+	<bean id="org.hisp.dhis.patient.action.program.ShowUpdateProgramFormAction"
+		class="org.hisp.dhis.patient.action.program.ShowUpdateProgramFormAction"
+		scope="prototype">
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+	</bean>
+	
 
 	<bean id="org.hisp.dhis.patient.action.program.UpdateProgramAction"
 		class="org.hisp.dhis.patient.action.program.UpdateProgramAction"
 		scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.patient.action.program.ValidateProgramAction"
@@ -490,9 +501,6 @@
 		<property name="patientIdentifierTypeService">
 			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		</property>
-		<property name="programService">
-			<ref bean="org.hisp.dhis.program.ProgramService" />
-		</property>
 	</bean>
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-08-24 10:09:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-09-05 14:30:23 +0000
@@ -261,4 +261,10 @@
 update_program_stage_section = Update program stage section
 section_management = Section management
 sort_order = Sort order
-program_stage_section_sort_order = Program stage section sort order 
\ No newline at end of file
+program_stage_section_sort_order = Program stage section sort order 
+add_selected = Add selected
+add_all = Add all
+available_identifiers_and_attributes = Available identifiers / attributes
+select_identifiers_and_attributes = Select identifiers / attributes
+identifiers_and_attributes = Identifiers / Attributes
+displayed_in_list = Displayed in list
\ No newline at end of file

=== 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-09-03 19:53:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-09-05 14:30:23 +0000
@@ -220,7 +220,7 @@
 		</action>
 
 		<action name="showUpdateProgramForm"
-			class="org.hisp.dhis.patient.action.program.GetProgramAction">
+			class="org.hisp.dhis.patient.action.program.ShowUpdateProgramFormAction">
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/updateProgramForm.vm</param>
 			<param name="javascripts">javascript/program.js</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-07-30 04:48:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm	2012-09-05 14:30:23 +0000
@@ -49,25 +49,12 @@
 		<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> 
-	
     </tbody>
 	<tr>
 		<td></td>
 		<td>
 			<input type="submit" value="$i18n.getString( 'add' )" />
-    <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='patientAttribute.action'" />
+			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='patientAttribute.action'" />
 		</td>
 	</tr>
 </table>

=== 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-06-14 06:37:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientIdentifierTypeForm.vm	2012-09-05 14:30:23 +0000
@@ -59,28 +59,14 @@
 			<td></td>
 		</tr>
 		
-		<tr>
-			<td><label for="programId">$i18n.getString( "program" )</label></td>
-			<td>
-				<select style="width: 336px;" type="text" name="programId" id="programId" value="$!patientIdentifierType.program" >
-					<option value=''>[$i18n.getString('all')]</option>
-					#foreach( $program in $programs)
-						<option value='$program.id'>$program.name</option>
-					#end
-				</select>
-			</td>		
-			<td></td>				
-		</tr> 
-		
-		<tbody>
-		<tr>
-			<td></td>
-			<td>
-				<input type="submit" value="$i18n.getString( 'add' )" />
-				<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='patientIdentifierType.action'" />
-			</td>
-		</tr>
 	</tbody>
+	<tr>
+		<td></td>
+		<td>
+			<input type="submit" value="$i18n.getString( 'add' )" />
+			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='patientIdentifierType.action'" />
+		</td>
+	</tr>
 </table>
 
 </form>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm	2012-08-06 09:34:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm	2012-09-05 14:30:23 +0000
@@ -65,16 +65,57 @@
 			<td><label>$i18n.getString( "duration_in_days" )</label></td>
 			<td><input style="width: 330px;" type="text" id="maxDaysAllowedInputData" name="maxDaysAllowedInputData" class="{validate:{number:true}}"></td>
 			<td></td>
-		</tr>	
-		
-		<tr>
-			<td></td>
-			<td>
-				<input type="submit" value="$i18n.getString( 'add' )" >
-				<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='program.action'" >
-			</td>
 		</tr>
-	</tbody>
+	<tbody>
+</table>
+	
+<table id="programStageMembersArea">    
+	<thead>
+	  <tr>        
+		<th>$i18n.getString( "available_identifiers_and_attributes" )</th>
+		<th></th>
+		<th>$i18n.getString( "select_identifiers_and_attributes" )							
+			<select style='display:none;' multiple id="selectedPropertyIds" name="selectedPropertyIds" ></select>
+			<select style='display:none;' multiple id="personDisplayNames" name="personDisplayNames" ></select>
+		</th>
+	  </tr>
+	</thead>
+	<tr>
+		<td>
+			<select size="15" style="width: 330px;" multiple id="availablePropertyIds" name="availablePropertyIds" ondblclick="selectProperties();">
+				#foreach( $identifier in $availableIdentifierTypes )
+					<option value="iden_$identifier.id">$identifier.name</option>
+				#end
+				#foreach( $attribute in $availableAttributes )
+					<option value="attr_$attribute.id">$attribute.name</option>
+				#end
+			</select>
+		</td>
+		<td style="text-align:center">
+        	<input type="button" value="&gt;" class='filterButton' onclick="selectProperties();"/><br/>
+            <input type="button" value="&lt;" class='filterButton' onclick="unSelectProperties();"/><br/>
+			<input type="button" value="&gt;&gt;" class='filterButton' onclick="selectAllProperties();"/><br/>
+			<input type="button" value="&lt;&lt;" class='filterButton' onclick="unSelectAllProperties();"/>
+		</td>
+		<td>
+			<div class="dataElementDiv">
+				<table>
+					<thead>
+						<tr>
+							<th>$i18n.getString( "identifiers_and_attributes" )</th>
+							<th width="20px">$i18n.getString( "displayed_in_list" )</th>
+					</thead>
+					<tbody id="selectedList"></tbody>
+				</table>
+			</div>
+		</td>
+	</tr>
+	<tr>
+		<td>
+			<input type="submit" value="$i18n.getString( 'add' )" >
+			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='program.action'" >
+		</td>
+	</tr>
 </table>
 
 </form>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramForm.js	2012-03-27 07:20:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramForm.js	2012-09-05 14:30:23 +0000
@@ -1,9 +1,25 @@
 jQuery(document).ready(	function(){
-	validation( 'addProgramForm', function( form ){		
+	
+	validation( 'addProgramForm', function( form ){ 
 		enable('dateOfEnrollmentDescription');
 		enable('dateOfIncidentDescription');
 		form.submit();
-	});				
+	}, function(){
+		var selectedPropertyIds = jQuery( "#selectedPropertyIds" );
+		selectedPropertyIds.empty();
+		var personDisplayNames = jQuery( "#personDisplayNames" );
+		personDisplayNames.empty();
+		
+		jQuery("#selectedList").find("tr").each( function( i, item ){ 
+			
+			selectedPropertyIds.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" );
+			
+			var displayed = jQuery( item ).find( "input[name='displayed']:first");
+			var checked = displayed.attr('checked') ? true : false;
+			personDisplayNames.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
+		});
+	});
+	
 	
 	checkValueIsExist( "name", "validateProgram.action");
 });	
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js	2012-08-07 08:14:58 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js	2012-09-05 14:30:23 +0000
@@ -63,3 +63,100 @@
 		}
 	}
 }
+
+// -----------------------------------------------------------------------------
+// select identifiers / attributes
+// -----------------------------------------------------------------------------
+
+function selectProperties()
+{
+	var selectedList = jQuery("#selectedList");
+	jQuery("#availablePropertyIds").children().each(function(i, item){
+		if( item.selected ){
+			html = "<tr class='selected' id='" + item.value + "' ondblclick='unSelectDataElement( this )'><td onmousedown='select(event,this)'>" + item.text + "</td>";
+			html += "<td align='center'><input type='checkbox' name='displayed' value='" + item.value + "'";
+			if( item.value.match("^attr_")=="attr_" )
+			{
+				html += " style='display:none' ";
+			}
+			html += "></td></tr>";
+			selectedList.append( html );
+			jQuery( item ).remove();
+		}
+	});
+}
+
+
+function selectAllProperties()
+{
+	var selectedList = jQuery("#selectedList");
+	jQuery("#availablePropertyIds").children().each(function(i, item){
+		html = "<tr class='selected' id='" + item.value + "' ondblclick='unSelectDataElement( this )'><td onmousedown='select(this)'>" + item.text + "</td>";
+		html += "<td align='center'><input type='checkbox' name='displayed' value='" + item.value + "'";
+		if( item.value.match("^attr_")=="attr_" )
+		{
+			html += " style='display:none' ";
+		}
+		html += "'></td></tr>";
+		selectedList.append( html );
+		jQuery( item ).remove();
+	});
+}
+
+function unSelectProperties()
+{
+	var availableList = jQuery("#availablePropertyIds");
+	jQuery("#selectedList").find("tr").each( function( i, item ){
+		item = jQuery(item);
+		if( item.hasClass("selected") )
+		{		
+			availableList.append( "<option value='" + item.attr( "id" ) + "' selected='true'>" + item.find("td:first").text() + "</option>" );
+			item.remove();
+		}
+	});
+}
+
+
+function unSelectAllProperties()
+{
+	var availableList = jQuery("#availablePropertyIds");
+	jQuery("#selectedList").find("tr").each( function( i, item ){
+		item = jQuery(item);
+		availableList.append( "<option value='" + item.attr( "id" ) + "' selected='true'>" + item.find("td:first").text() + "</option>" );
+		item.remove();
+	});
+}
+
+function select( event, element )
+{
+	if ( !getKeyCode( event ) )// Ctrl
+	{
+		jQuery("#selectedList .selected").removeClass( 'selected' );
+	}
+	
+	element = jQuery( element ).parent();
+	if( element.hasClass( 'selected') ) element.removeClass( 'selected' );
+	else element.addClass( 'selected' );
+}
+
+function getKeyCode(e)
+{
+	var ctrlPressed=0;
+
+	if (parseInt(navigator.appVersion)>3) {
+
+		var evt = e ? e:window.event;
+
+		if (document.layers && navigator.appName=="Netscape"
+		&& parseInt(navigator.appVersion)==4) {
+			// NETSCAPE 4 CODE
+			var mString =(e.modifiers+32).toString(2).substring(3,6);
+			ctrlPressed =(mString.charAt(1)=="1");
+		}
+		else {
+			// NEWER BROWSERS [CROSS-PLATFORM]
+			ctrlPressed=evt.ctrlKey;
+		}
+	}
+	return ctrlPressed;
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramForm.js	2012-03-27 07:20:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramForm.js	2012-09-05 14:30:23 +0000
@@ -1,9 +1,24 @@
 jQuery(document).ready(	function(){
+	
 	validation( 'updateProgramForm', function( form ){ 
 		enable('dateOfEnrollmentDescription');
 		enable('dateOfIncidentDescription');
-		form.submit();			
-	});	
+		form.submit();
+	}, function(){
+		var selectedPropertyIds = jQuery( "#selectedPropertyIds" );
+		selectedPropertyIds.empty();
+		var personDisplayNames = jQuery( "#personDisplayNames" );
+		personDisplayNames.empty();
+		
+		jQuery("#selectedList").find("tr").each( function( i, item ){ 
+			
+			selectedPropertyIds.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" );
+			
+			var displayed = jQuery( item ).find( "input[name='displayed']:first");
+			var checked = displayed.attr('checked') ? true : false;
+			personDisplayNames.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
+		});
+	});
 	
 	checkValueIsExist( "name", "validateProgram.action", {id:getFieldValue('id')});
 });	

=== 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-07-30 04:48:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm	2012-09-05 14:30:23 +0000
@@ -59,19 +59,6 @@
 		<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> 
-	
     </tbody>
 	
 	<tr>
@@ -81,7 +68,7 @@
 			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='patientAttribute.action'">
 		</td>
 	</tr>
-  </table>  
+  </table>
 </form>
 
 <script>

=== 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-06-14 06:37:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientIdentifierType.vm	2012-09-05 14:30:23 +0000
@@ -60,19 +60,6 @@
 			<td></td>				
 		</tr>
 		
-		<tr>
-			<td><label for="programId">$i18n.getString( "program" )</label></td>
-			<td>
-				<select style="width: 336px;" 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> 
-		
 	</tbody>
 	<tr>
 		<td></td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm	2012-08-06 09:34:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm	2012-09-05 14:30:23 +0000
@@ -2,7 +2,7 @@
 
 <h3>$i18n.getString( "edit_program" )</h3>
 
-<form id="updateProgramForm" name="updateProgramForm" action="updateProgram.action" method="post" >
+<form id="updateProgramForm" name="updateProgramForm" action="updateProgram.action" method="post" onsubmit="selectAllById('selectedPropertyIds');" >
   <input type="hidden" id="id" name="id" value="$program.id">
   
   <table id="detailsList">
@@ -12,66 +12,123 @@
       </tr>
     </thead>
     <tbody>
-      <tr>
-		<td><label>$i18n.getString( "name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-		<td><input style="width: 330px;" type="text" id="name" name="name" value="$encoder.htmlEncode( $program.name )" class="{validate:{required:true,minlength:4}}"></td>
-		<td></td>
-	  </tr>	  
-      <tr>
-		<td><label>$i18n.getString( "description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-		<td><input style="width: 330px;" type="text" id="description" name="description" value="$encoder.htmlEncode( $program.description )" class="{validate:{required:true,minlength:2}}"></td>
-		<td></td>
+		<tr>
+			<td><label>$i18n.getString( "name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input style="width: 330px;" type="text" id="name" name="name" value="$encoder.htmlEncode( $program.name )" class="{validate:{required:true,minlength:4}}"></td>
+			<td></td>
+		</tr>	
+		
+		<tr>
+			<td><label>$i18n.getString( "description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input style="width: 330px;" type="text" id="description" name="description" value="$encoder.htmlEncode( $program.description )" class="{validate:{required:true,minlength:2}}"></td>
+			<td></td>
+		</tr>
+
+		<tr>
+			<td><label>$i18n.getString( "type" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td>
+				<select style="width: 336px;" id="type" name="type" onchange='programOnChange();' class="{validate:{required:true}}">
+					<option value=''>[$i18n.getString('please_select')]</option>
+					<option value='1' #if( $program.type=='1' ) selected #end>$i18n.getString('multiple_events_with_registration')</option>
+					<option value='2' #if( $program.type=='2' ) selected #end>$i18n.getString('single_event_with_registration')</option>
+					<option value='3' #if( $program.type=='3' ) selected #end>$i18n.getString('single_event_without_registration')</option>
+				</select>
+			</td>
+			<td></td>
+		</tr>
+
+		<tr>
+			<td><label>$i18n.getString( "show_provided_provided_elsewhere" )</label></td>
+			<td><input style="margin: 0;" type="checkbox" id="displayProvidedOtherFacility" name="displayProvidedOtherFacility" value='true' #if( $program.displayProvidedOtherFacility=='false' ) checked #end ></td>
+			<td></td>
+		</tr>
+
+		<tr>
+			<td><label>$i18n.getString( "show_incident_date" )</label></td>
+			<td><input style="margin: 0;"type="checkbox" id="displayIncidentDate" name="displayIncidentDate" value='true' onchange='programOnChange();' #if( $program.type=='3' ) disabled #elseif($program.displayIncidentDate=='true') checked #end></td>
+			<td></td>
+		</tr>
+
+		<tr>
+			<td><label>$i18n.getString( "version" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input style="width: 330px;" type="text" id="version" name="version" value="$program.version" class="{validate:{required:true,number:true}}"></td>
+			<td></td>
+		</tr>		
+		<tr>
+			<td><label>$i18n.getString( "date_of_enrollment_description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input style="width: 330px;" type="text" id="dateOfEnrollmentDescription" name="dateOfEnrollmentDescription"  value="$!program.dateOfEnrollmentDescription" class="{validate:{required:true,minlength:4}}" #if( $program.type=='3' ) disabled #end></td>
+			<td></td>
+		</tr>	
+		<tr>
+			<td><label>$i18n.getString( "date_of_incident_description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input style="width: 330px;" type="text" id="dateOfIncidentDescription" name="dateOfIncidentDescription" value="$!program.dateOfIncidentDescription" class="{validate:{required:true,minlength:4}}" #if( $program.type=='2' || $program.type=='3') disabled #end ></td>
+			<td></td>
+		</tr>
+
+		<tr>
+			<td><label>$i18n.getString( "duration_in_days" )</label></td>
+			<td><input style="width: 330px;" type="text" id="maxDaysAllowedInputData" name="maxDaysAllowedInputData" value="$!program.maxDaysAllowedInputData" class="{validate:{number:true}}"></td>
+			<td></td>
+		</tr>		 
+	<tbody>
+	</table>
+
+	<table>
+		<thead>
+		  <tr>        
+			<th>$i18n.getString( "available_identifiers_and_attributes" )</th>
+			<th></th>
+			<th>$i18n.getString( "select_identifiers_and_attributes" )							
+				<select style='display:none;' multiple id="selectedPropertyIds" name="selectedPropertyIds" ></select>
+				<select style='display:none;' multiple id="personDisplayNames" name="personDisplayNames" ></select>
+			</th>
+		  </tr>
+		</thead>
+	
+		<tr>
+			<td>
+				<select size="15" style="width: 330px;" multiple id="availablePropertyIds" name="availablePropertyIds" ondblclick="selectProperties();">
+					#foreach( $identifier in $availableIdentifierTypes )
+						<option value="iden_$identifier.id">$identifier.name</option>
+					#end
+					#foreach( $attribute in $availableAttributes )
+						<option value="attr_$attribute.id">$attribute.name</option>
+					#end
+				</select>
+			</td>
+			<td style="text-align:center">
+				<input type="button" value="&gt;" class='filterButton' onclick="selectProperties();"/><br/>
+				<input type="button" value="&lt;" class='filterButton' onclick="unSelectProperties();"/><br/>
+				<input type="button" value="&gt;&gt;" class='filterButton' onclick="selectAllProperties();"/><br/>
+				<input type="button" value="&lt;&lt;" class='filterButton' onclick="unSelectAllProperties();"/>
+			</td>
+			<td>
+				<div class="dataElementDiv">
+					<table>
+						<thead>
+							<tr>
+								<th>$i18n.getString( "identifiers_and_attributes" )</th>
+								<th width="20px">$i18n.getString( "displayed_in_list" )</th>
+						</thead>
+						<tbody id="selectedList">
+							#foreach( $identifier in $program.patientIdentifierTypes )
+								<tr ondblclick="unSelectProperties( this )" id="iden_$identifier.id">
+									<td onmousedown="select(event, this)">$encoder.htmlEncode( $identifier.name )</td>
+									<td align="center"><input type="checkbox" name="displayed" value="iden_$identifier.id" #if($identifier.personDisplayName == true ) checked #end /></td>
+								</tr>
+							#end
+							#foreach( $attribute in $program.patientAttributes )
+								<tr ondblclick="unSelectProperties( this )" id="attr_$attribute.id">
+									<td onmousedown="select(event, this)">$encoder.htmlEncode( $attribute.name )</td>
+									<td align="center"><input type="checkbox" name="displayed" style='display:none' /></td>
+								</tr>
+							#end
+						</tbody>
+					</table>
+				</div>
+			</td>
 	  </tr>
-	  
-      <tr>
-		<td><label>$i18n.getString( "type" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-		<td>
-			<select style="width: 336px;" id="type" name="type" onchange='programOnChange();' class="{validate:{required:true}}">
-				<option value=''>[$i18n.getString('please_select')]</option>
-				<option value='1' #if( $program.type=='1' ) selected #end>$i18n.getString('multiple_events_with_registration')</option>
-				<option value='2' #if( $program.type=='2' ) selected #end>$i18n.getString('single_event_with_registration')</option>
-				<option value='3' #if( $program.type=='3' ) selected #end>$i18n.getString('single_event_without_registration')</option>
-			</select>
-		</td>
-		<td></td>
-	</tr>
-		
-	<tr>
-		<td><label>$i18n.getString( "show_provided_provided_elsewhere" )</label></td>
-		<td><input style="margin: 0;" type="checkbox" id="displayProvidedOtherFacility" name="displayProvidedOtherFacility" value='true' #if( $program.displayProvidedOtherFacility=='false' ) checked #end ></td>
-		<td></td>
-	</tr>
-	
-	<tr>
-		<td><label>$i18n.getString( "show_incident_date" )</label></td>
-		<td><input style="margin: 0;"type="checkbox" id="displayIncidentDate" name="displayIncidentDate" value='true' onchange='programOnChange();' #if( $program.type=='3' ) disabled #elseif($program.displayIncidentDate=='true') checked #end></td>
-		<td></td>
-	</tr>
-		
-	<tr>
-		<td><label>$i18n.getString( "version" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-		<td><input style="width: 330px;" type="text" id="version" name="version" value="$program.version" class="{validate:{required:true,number:true}}"></td>
-		<td></td>
-	</tr>		
-	<tr>
-		<td><label>$i18n.getString( "date_of_enrollment_description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-		<td><input style="width: 330px;" type="text" id="dateOfEnrollmentDescription" name="dateOfEnrollmentDescription"  value="$!program.dateOfEnrollmentDescription" class="{validate:{required:true,minlength:4}}" #if( $program.type=='3' ) disabled #end></td>
-		<td></td>
-	</tr>	
-	<tr>
-		<td><label>$i18n.getString( "date_of_incident_description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-		<td><input style="width: 330px;" type="text" id="dateOfIncidentDescription" name="dateOfIncidentDescription" value="$!program.dateOfIncidentDescription" class="{validate:{required:true,minlength:4}}" #if( $program.type=='2' || $program.type=='3') disabled #end ></td>
-		<td></td>
-	</tr>
-	
-	  <tr>
-		<td><label>$i18n.getString( "duration_in_days" )</label></td>
-		<td><input style="width: 330px;" type="text" id="maxDaysAllowedInputData" name="maxDaysAllowedInputData" value="$!program.maxDaysAllowedInputData" class="{validate:{number:true}}"></td>
-		<td></td>
-	  </tr>	
-		  
-      <tr>
-		<td></td>
+      <tr>
       	<td>
 			<input type="submit" value="$i18n.getString( 'update' )">
 			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='program.action'">