← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13614: Add new object called ProgramPatientIdentifierType.

 

------------------------------------------------------------
revno: 13614
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-01-07 22:02:45 +0700
message:
  Add new object called ProgramPatientIdentifierType.
modified:
  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/program/Program.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.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/DefaultPatientService.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/program/DefaultProgramInstanceService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramDeletionHandler.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientIdentifierType.hbm.xml
  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/test/java/org/hisp/dhis/patient/PatientIdentifierTypeServiceTest.java
  dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientIdentifierTypeStoreTest.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java
  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/PatientDashboardAction.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/report/GetAggregateReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.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/webapp/dhis-web-caseentry/activityPlanRecords.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/identifierAndAttributeForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.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/programTrackingList.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/records.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipPatients.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/GetProgramEnrollmentFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/GetPatientReminderAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/ShowAddProgramPatientReminderAction.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/ShowUpdateProgramFormAction.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/java/org/hisp/dhis/patient/action/validation/GetValidationCriteriaAction.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/webapp/dhis-web-maintenance-patient/addProgramPatientReminder.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm
  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/updateProgramPatientReminder.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm
  dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/SearchPatientAction.java


--
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/PatientIdentifierType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierType.java	2013-09-27 17:04:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierType.java	2014-01-07 15:02:45 +0000
@@ -36,8 +36,8 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlRootElement;
 
-@XmlRootElement(name = "patientIdentifierType", namespace = DxfNamespaces.DXF_2_0)
-@XmlAccessorType(value = XmlAccessType.NONE)
+@XmlRootElement( name = "patientIdentifierType", namespace = DxfNamespaces.DXF_2_0 )
+@XmlAccessorType( value = XmlAccessType.NONE )
 public class PatientIdentifierType
     extends BaseIdentifiableObject
 {
@@ -66,8 +66,6 @@
 
     private String type;
 
-    private Boolean personDisplayName = false;
-
     // For Local ID type
 
     private Boolean orgunitScope = false;
@@ -164,16 +162,6 @@
         this.type = type;
     }
 
-    public Boolean getPersonDisplayName()
-    {
-        return personDisplayName;
-    }
-
-    public void setPersonDisplayName( Boolean personDisplayName )
-    {
-        this.personDisplayName = personDisplayName;
-    }
-
     public Boolean getOrgunitScope()
     {
         return orgunitScope;

=== 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	2013-11-04 03:13:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeService.java	2014-01-07 15:02:45 +0000
@@ -73,8 +73,8 @@
     /**
      * Returns all {@link PatientIdentifierType}
      * 
-     * @return a collection of all PatientIdentifierType, or an empty collection if
-     *         there are no PatientAttributeGroups.
+     * @return a collection of all PatientIdentifierType, or an empty collection
+     *         if there are no PatientAttributeGroups.
      */
     Collection<PatientIdentifierType> getAllPatientIdentifierTypes();
 
@@ -83,7 +83,8 @@
      * 
      * @param name the name of the PatientIdentifierType to return.
      * 
-     * @return the PatientIdentifierType with the given name, or null if no match.
+     * @return the PatientIdentifierType with the given name, or null if no
+     *         match.
      */
     PatientIdentifierType getPatientIdentifierType( String name );
 
@@ -91,7 +92,8 @@
      * Returns the {@link PatientIdentifierType} with the given UID.
      * 
      * @param uid the UID.
-     * @return the PatientIdentifierType with the given UID, or null if no match.
+     * @return the PatientIdentifierType with the given UID, or null if no
+     *         match.
      */
     PatientIdentifierType getPatientIdentifierTypeByUid( String uid );
 
@@ -103,14 +105,4 @@
      * @return PatientIdentifierType list
      */
     Collection<PatientIdentifierType> getPatientIdentifierTypes( boolean mandatory );
-
-    /**
-     * Retrieve patient identifer types which are displayed in person list
-     * instead of full name of person or not
-     * 
-     * @param personDisplayName True/False value
-     * 
-     * @return PatientIdentifierType list
-     */
-    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	2013-10-29 05:04:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierTypeStore.java	2014-01-07 15:02:45 +0000
@@ -43,14 +43,5 @@
      * @return PatientIdentifierType list
      */
     Collection<PatientIdentifierType> get( boolean mandatory );
-
-    /**
-     * Retrieve patient identifer types which are displayed in person list
-     * instead of full name of person or not
-     * 
-     * @param personDisplayName True/False value
-     * 
-     * @return PatientIdentifierType list
-     */
-    Collection<PatientIdentifierType> getByDisplayed( boolean personDisplayName );
+    
 }

=== 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	2014-01-07 10:07:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2014-01-07 15:02:45 +0000
@@ -43,7 +43,6 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientReminder;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.relationship.RelationshipType;
@@ -59,7 +58,7 @@
 /**
  * @author Abyot Asalefew
  */
-@JacksonXmlRootElement(localName = "program", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "program", namespace = DxfNamespaces.DXF_2_0 )
 public class Program
     extends BaseIdentifiableObject
 {
@@ -107,7 +106,7 @@
 
     private Boolean ignoreOverdueEvents = false;
 
-    private List<PatientIdentifierType> patientIdentifierTypes = new ArrayList<PatientIdentifierType>();
+    private List<ProgramPatientIdentifierType> programPatientIdentifierTypes = new ArrayList<ProgramPatientIdentifierType>();
 
     private List<ProgramPatientAttribute> programPatientAttributes = new ArrayList<ProgramPatientAttribute>();
 
@@ -239,8 +238,8 @@
     // -------------------------------------------------------------------------
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getDescription()
     {
         return description;
@@ -252,8 +251,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Integer getVersion()
     {
         return version;
@@ -264,11 +263,11 @@
         this.version = version;
     }
 
-    @JsonProperty(value = "organisationUnits")
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class, ExportView.class })
-    @JacksonXmlElementWrapper(localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( value = "organisationUnits" )
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 )
     public Set<OrganisationUnit> getOrganisationUnits()
     {
         return organisationUnits;
@@ -279,10 +278,10 @@
         this.organisationUnits = organisationUnits;
     }
 
-    @JsonProperty(value = "programInstances")
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "programInstances", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "programInstance", namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( value = "programInstances" )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "programInstances", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "programInstance", namespace = DxfNamespaces.DXF_2_0 )
     public Set<ProgramInstance> getProgramInstances()
     {
         return programInstances;
@@ -293,11 +292,11 @@
         this.programInstances = programInstances;
     }
 
-    @JsonProperty(value = "programStages")
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "programStages", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "programStage", namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( value = "programStages" )
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "programStages", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "programStage", namespace = DxfNamespaces.DXF_2_0 )
     public Set<ProgramStage> getProgramStages()
     {
         return programStages;
@@ -309,8 +308,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getDateOfEnrollmentDescription()
     {
         return dateOfEnrollmentDescription;
@@ -322,8 +321,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getDateOfIncidentDescription()
     {
         return dateOfIncidentDescription;
@@ -335,14 +334,14 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getKind()
     {
         return TYPE_LOOKUP.get( type );
     }
 
     @JsonProperty
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Integer getType()
     {
         return type;
@@ -353,11 +352,11 @@
         this.type = type;
     }
 
-    @JsonProperty(value = "validationCriterias")
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "validationCriterias", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "validationCriteria", namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( value = "validationCriterias" )
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "validationCriterias", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "validationCriteria", namespace = DxfNamespaces.DXF_2_0 )
     public Set<ValidationCriteria> getPatientValidationCriteria()
     {
         return patientValidationCriteria;
@@ -368,23 +367,20 @@
         this.patientValidationCriteria = patientValidationCriteria;
     }
 
-    @JsonProperty(value = "identifierTypes")
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "identifierTypes", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "identifierType", namespace = DxfNamespaces.DXF_2_0)
-    public List<PatientIdentifierType> getPatientIdentifierTypes()
+    public List<ProgramPatientIdentifierType> getProgramPatientIdentifierTypes()
+
     {
-        return patientIdentifierTypes;
+        return programPatientIdentifierTypes;
     }
 
-    public void setPatientIdentifierTypes( List<PatientIdentifierType> patientIdentifierTypes )
+    public void setProgramPatientIdentifierTypes( List<ProgramPatientIdentifierType> programPatientIdentifierTypes )
     {
-        this.patientIdentifierTypes = patientIdentifierTypes;
+        this.programPatientIdentifierTypes = programPatientIdentifierTypes;
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getDisplayIncidentDate()
     {
         return displayIncidentDate;
@@ -396,8 +392,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     private Object getValueFromPatient( String property, Patient patient )
         throws Exception
     {
@@ -405,8 +401,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getIgnoreOverdueEvents()
     {
         return ignoreOverdueEvents;
@@ -418,26 +414,26 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public boolean isSingleEvent()
     {
         return type != null && (SINGLE_EVENT_WITH_REGISTRATION == type || SINGLE_EVENT_WITHOUT_REGISTRATION == type);
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public boolean isRegistration()
     {
         return type != null && (SINGLE_EVENT_WITH_REGISTRATION == type || MULTIPLE_EVENTS_WITH_REGISTRATION == type);
     }
 
     @JsonProperty
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "userRoles", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "userRole", namespace = DxfNamespaces.DXF_2_0)
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "userRoles", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "userRole", namespace = DxfNamespaces.DXF_2_0 )
     public Set<UserAuthorityGroup> getUserRoles()
     {
         return userRoles;
@@ -449,8 +445,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getOnlyEnrollOnce()
     {
         return onlyEnrollOnce;
@@ -462,8 +458,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Set<PatientReminder> getPatientReminders()
     {
         return patientReminders;
@@ -475,10 +471,10 @@
     }
 
     @JsonProperty
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0)
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0 )
     public Set<OrganisationUnitGroup> getOrganisationUnitGroups()
     {
         return organisationUnitGroups;
@@ -490,8 +486,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getDisplayOnAllOrgunit()
     {
         return displayOnAllOrgunit;
@@ -503,8 +499,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getSelectEnrollmentDatesInFuture()
     {
         return selectEnrollmentDatesInFuture;
@@ -516,8 +512,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getSelectIncidentDatesInFuture()
     {
         return selectIncidentDatesInFuture;
@@ -529,8 +525,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getRelationshipText()
     {
         return relationshipText;
@@ -542,8 +538,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public RelationshipType getRelationshipType()
     {
         return relationshipType;
@@ -555,8 +551,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Program getRelatedProgram()
     {
         return relatedProgram;
@@ -568,8 +564,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getRelationshipFromA()
     {
         return relationshipFromA;
@@ -581,8 +577,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getDataEntryMethod()
     {
         return dataEntryMethod;
@@ -595,7 +591,7 @@
 
     @JsonProperty( value = "programPersonAttributes" )
     @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
-    @JacksonXmlElementWrapper(localName = "programPersonAttributes", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlElementWrapper( localName = "programPersonAttributes", namespace = DxfNamespaces.DXF_2_0 )
     @JacksonXmlProperty( localName = "programPersonAttribute", namespace = DxfNamespaces.DXF_2_0 )
     public List<ProgramPatientAttribute> getProgramPatientAttributes()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2014-01-07 15:02:45 +0000
@@ -73,6 +73,7 @@
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageService;
@@ -81,8 +82,6 @@
 import org.hisp.dhis.system.util.Timer;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import com.sun.org.apache.bcel.internal.classfile.Attribute;
-
 /**
  * @author Lars Helge Overland
  */
@@ -90,55 +89,67 @@
     implements EventAnalyticsService
 {
     private static final String ITEM_EVENT = "psi";
+
     private static final String ITEM_PROGRAM_STAGE = "ps";
+
     private static final String ITEM_EXECUTION_DATE = "eventdate";
+
     private static final String ITEM_LONGITUDE = "longitude";
+
     private static final String ITEM_LATITUDE = "latitude";
+
     private static final String ITEM_ORG_UNIT = "ou";
+
     private static final String ITEM_ORG_UNIT_NAME = "ouname";
+
     private static final String ITEM_ORG_UNIT_CODE = "oucode";
-    
+
     private static final String COL_NAME_EVENTDATE = "executiondate";
 
-    private static final List<String> SORTABLE_ITEMS = Arrays.asList( ITEM_EXECUTION_DATE, ITEM_ORG_UNIT_NAME, ITEM_ORG_UNIT_CODE );
-    
+    private static final List<String> SORTABLE_ITEMS = Arrays.asList( ITEM_EXECUTION_DATE, ITEM_ORG_UNIT_NAME,
+        ITEM_ORG_UNIT_CODE );
+
     @Autowired
     private ProgramService programService;
-    
+
     @Autowired
     private ProgramStageService programStageService;
 
     @Autowired
     private DataElementService dataElementService;
-    
+
     @Autowired
     private PatientAttributeService attributeService;
 
     @Autowired
     private PatientIdentifierTypeService identifierTypeService;
-    
+
     @Autowired
     private OrganisationUnitService organisationUnitService;
-    
+
     @Autowired
     private EventAnalyticsManager analyticsManager;
-    
+
     @Autowired
     private EventQueryPlanner queryPlanner;
-    
+
     @Autowired
     private AnalyticsService analyticsService;
 
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // EventAnalyticsService implementation
     // -------------------------------------------------------------------------
 
-    //TODO order event analytics tables on execution date to avoid default sorting in queries
-    //TODO parallel processing of queries
-    
+    // TODO order event analytics tables on execution date to avoid default
+    // sorting in queries
+    // TODO parallel processing of queries
+
     public Grid getAggregatedEventData( EventQueryParams params )
     {
         queryPlanner.validate( params );
@@ -153,45 +164,49 @@
         {
             grid.addHeader( new GridHeader( dimension.getDimension(), dimension.getDisplayName() ) );
         }
-        
+
         for ( QueryItem item : params.getItems() )
         {
             grid.addHeader( new GridHeader( item.getItem().getUid(), item.getItem().getName() ) );
         }
-        
+
         grid.addHeader( new GridHeader( "value", "Value" ) );
 
         // ---------------------------------------------------------------------
         // Data
         // ---------------------------------------------------------------------
-        
+
         List<EventQueryParams> queries = queryPlanner.planQuery( params );
 
         for ( EventQueryParams query : queries )
         {
             analyticsManager.getAggregatedEventData( query, grid );
-        }        
+        }
 
         // ---------------------------------------------------------------------
         // Meta-data
         // ---------------------------------------------------------------------
 
-        Map<Object, Object> metaData = new HashMap<Object, Object>();        
-        
+        Map<Object, Object> metaData = new HashMap<Object, Object>();
+
         Map<String, String> uidNameMap = getUidNameMap( params );
-        
+
         metaData.put( NAMES_META_KEY, uidNameMap );
-        
+
         if ( params.isHierarchyMeta() )
         {
-            metaData.put( OU_HIERARCHY_KEY, getParentGraphMap( asTypedList( params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class ) ) );
+            metaData
+                .put(
+                    OU_HIERARCHY_KEY,
+                    getParentGraphMap( asTypedList( params.getDimensionOrFilter( ORGUNIT_DIM_ID ),
+                        OrganisationUnit.class ) ) );
         }
-        
+
         grid.setMetaData( metaData );
 
-        return grid;        
+        return grid;
     }
-    
+
     public Grid getEvents( EventQueryParams params )
     {
         queryPlanner.validate( params );
@@ -214,7 +229,7 @@
         for ( QueryItem queryItem : params.getItems() )
         {
             IdentifiableObject item = queryItem.getItem();
-            
+
             grid.addHeader( new GridHeader( item.getUid(), item.getName() ) );
         }
 
@@ -223,38 +238,42 @@
         // ---------------------------------------------------------------------
 
         Timer t = new Timer().start();
-        
+
         List<EventQueryParams> queries = queryPlanner.planQuery( params );
-        
+
         t.getSplitTime( "Planned query, got: " + queries.size() );
-        
+
         int count = 0;
-        
+
         for ( EventQueryParams query : queries )
         {
             if ( params.isPaging() )
             {
                 count += analyticsManager.getEventCount( query );
             }
-            
+
             analyticsManager.getEvents( query, grid );
         }
-        
+
         t.getTime( "Queried events, got: " + grid.getHeight() );
-        
+
         // ---------------------------------------------------------------------
         // Meta-data
         // ---------------------------------------------------------------------
 
         Map<Object, Object> metaData = new HashMap<Object, Object>();
-        
+
         Map<String, String> uidNameMap = getUidNameMap( params );
-        
+
         metaData.put( NAMES_META_KEY, uidNameMap );
-        
+
         if ( params.isHierarchyMeta() )
-        {        
-            metaData.put( OU_HIERARCHY_KEY, getParentGraphMap( asTypedList( params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class ) ) );
+        {
+            metaData
+                .put(
+                    OU_HIERARCHY_KEY,
+                    getParentGraphMap( asTypedList( params.getDimensionOrFilter( ORGUNIT_DIM_ID ),
+                        OrganisationUnit.class ) ) );
         }
 
         if ( params.isPaging() )
@@ -262,47 +281,50 @@
             Pager pager = new Pager( params.getPageWithDefault(), count, params.getPageSizeWithDefault() );
             metaData.put( AnalyticsService.PAGER_META_KEY, pager );
         }
-        
+
         grid.setMetaData( metaData );
-        
+
         return grid;
     }
 
-    public EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate, 
-        Set<String> dimension, Set<String> filter, boolean hierarchyMeta, SortOrder sortOrder, Integer limit, I18nFormat format )
+    public EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
+        Set<String> dimension, Set<String> filter, boolean hierarchyMeta, SortOrder sortOrder, Integer limit,
+        I18nFormat format )
     {
-        EventQueryParams params = getFromUrl( program, stage, startDate, endDate, dimension, filter, null, null, null, hierarchyMeta, false, null, null, format );
+        EventQueryParams params = getFromUrl( program, stage, startDate, endDate, dimension, filter, null, null, null,
+            hierarchyMeta, false, null, null, format );
         params.setSortOrder( sortOrder );
         params.setLimit( limit );
         params.setAggregate( true );
-        
+
         return params;
     }
-    
-    public EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate, Set<String> dimension, Set<String> filter, 
-        String ouMode, Set<String> asc, Set<String> desc, boolean hierarchyMeta, boolean coordinatesOnly, Integer page, Integer pageSize, I18nFormat format )
+
+    public EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
+        Set<String> dimension, Set<String> filter, String ouMode, Set<String> asc, Set<String> desc,
+        boolean hierarchyMeta, boolean coordinatesOnly, Integer page, Integer pageSize, I18nFormat format )
     {
         EventQueryParams params = new EventQueryParams();
-        
+
         Date date = new Date();
-        
+
         Program pr = programService.getProgram( program );
-        
+
         if ( pr == null )
         {
             throw new IllegalQueryException( "Program does not exist: " + program );
         }
-        
+
         ProgramStage ps = programStageService.getProgramStage( stage );
-        
+
         if ( stage != null && !stage.isEmpty() && ps == null )
         {
             throw new IllegalQueryException( "Program stage is specified but does not exist: " + stage );
         }
-        
+
         Date start = null;
         Date end = null;
-        
+
         if ( startDate != null && endDate != null )
         {
             try
@@ -315,13 +337,13 @@
                 throw new IllegalQueryException( "Start date or end date is invalid: " + startDate + " - " + endDate );
             }
         }
-        
+
         if ( dimension != null )
         {
             for ( String dim : dimension )
             {
                 String dimensionId = DataQueryParams.getDimensionFromParam( dim );
-                
+
                 if ( ORGUNIT_DIM_ID.equals( dimensionId ) || PERIOD_DIM_ID.equals( dimensionId ) )
                 {
                     List<String> items = DataQueryParams.getDimensionItemsFromParam( dim );
@@ -333,13 +355,13 @@
                 }
             }
         }
-        
+
         if ( filter != null )
         {
             for ( String dim : filter )
             {
                 String dimensionId = DataQueryParams.getDimensionFromParam( dim );
-                
+
                 if ( ORGUNIT_DIM_ID.equals( dimensionId ) || PERIOD_DIM_ID.equals( dimensionId ) )
                 {
                     List<String> items = DataQueryParams.getDimensionItemsFromParam( dim );
@@ -348,16 +370,16 @@
                 else
                 {
                     params.getItemFilters().addAll( getQueryItems( dim, pr ) );
-                }            
+                }
             }
         }
-        
+
         for ( NameableObject object : params.getDimensionOrFilter( ORGUNIT_DIM_ID ) )
         {
             OrganisationUnit unit = (OrganisationUnit) object;
             unit.setLevel( organisationUnitService.getLevelOfOrganisationUnit( unit.getUid() ) );
         }
-        
+
         if ( asc != null )
         {
             for ( String sort : asc )
@@ -373,7 +395,7 @@
                 params.getDesc().add( getSortItem( sort, pr ) );
             }
         }
-        
+
         params.setProgram( pr );
         params.setProgramStage( ps );
         params.setStartDate( start );
@@ -391,39 +413,40 @@
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
-    
+
     private List<QueryItem> getQueryItems( String dimension, Program program )
     {
         List<QueryItem> items = new ArrayList<QueryItem>();
-        
+
         if ( !dimension.contains( DIMENSION_NAME_SEP ) )
         {
             items.add( getItem( program, dimension, null, null ) );
         }
-        else // Filter
+        else
+        // Filter
         {
             String[] split = dimension.split( DIMENSION_NAME_SEP );
-            
+
             if ( split == null || split.length != 3 )
             {
                 throw new IllegalQueryException( "Item filter has invalid format: " + dimension );
             }
-            
+
             items.add( getItem( program, split[0], split[1], split[2] ) );
         }
-        
+
         return items;
     }
-    
+
     private Map<String, String> getUidNameMap( EventQueryParams params )
     {
         Map<String, String> map = new HashMap<String, String>();
-        
+
         Program program = params.getProgram();
         ProgramStage stage = params.getProgramStage();
-        
+
         map.put( program.getUid(), program.getName() );
-        
+
         if ( stage != null )
         {
             map.put( stage.getUid(), stage.getName() );
@@ -445,13 +468,13 @@
         {
             map.put( item.getItem().getUid(), item.getItem().getDisplayName() );
         }
-        
+
         map.putAll( getUidNameMap( params.getDimensions(), params.isHierarchyMeta() ) );
         map.putAll( getUidNameMap( params.getFilters(), params.isHierarchyMeta() ) );
-                
+
         return map;
     }
-    
+
     private Map<String, String> getUidNameMap( List<DimensionalObject> dimensions, boolean hierarchyMeta )
     {
         Map<String, String> map = new HashMap<String, String>();
@@ -459,59 +482,59 @@
         for ( DimensionalObject dimension : dimensions )
         {
             boolean hierarchy = hierarchyMeta && DimensionType.ORGANISATIONUNIT.equals( dimension.getType() );
-            
+
             for ( IdentifiableObject idObject : dimension.getItems() )
             {
                 map.put( idObject.getUid(), idObject.getDisplayName() );
-                
+
                 if ( hierarchy )
                 {
                     OrganisationUnit unit = (OrganisationUnit) idObject;
-                    
+
                     map.putAll( IdentifiableObjectUtils.getUidNameMap( unit.getAncestors() ) );
                 }
             }
         }
-        
+
         return map;
     }
-    
+
     private String getSortItem( String item, Program program )
     {
         if ( !SORTABLE_ITEMS.contains( item.toLowerCase() ) && getItem( program, item, null, null ) == null )
         {
             throw new IllegalQueryException( "Descending sort item is invalid: " + item );
         }
-        
+
         item = ITEM_EXECUTION_DATE.equalsIgnoreCase( item ) ? COL_NAME_EVENTDATE : item;
-        
+
         return item;
     }
-    
+
     private QueryItem getItem( Program program, String item, String operator, String filter )
     {
         DataElement de = dataElementService.getDataElement( item );
-        
+
         if ( de != null && program.getAllDataElements().contains( de ) )
         {
             return new QueryItem( de, operator, filter, de.isNumericType() );
         }
-        
+
         PatientAttribute at = attributeService.getPatientAttribute( item );
-        
+
         Collection<PatientAttribute> attributes = programPatientAttributeService.getListPatientAttribute( program );
         if ( at != null && attributes.contains( at ) )
         {
             return new QueryItem( at, operator, filter, at.isNumericType() );
         }
-        
+
         PatientIdentifierType it = identifierTypeService.getPatientIdentifierType( item );
-        
-        if ( it != null && program.getPatientIdentifierTypes().contains( it ) )
+
+        if ( it != null && programPatientIdentifierTypeService.getListPatientIdentifierType( program ).contains( it ) )
         {
             return new QueryItem( it, operator, filter, false );
         }
-        
-        throw new IllegalQueryException( "Item identifier does not reference any item part of the program: " + item );           
+
+        throw new IllegalQueryException( "Item identifier does not reference any item part of the program: " + item );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2014-01-07 15:02:45 +0000
@@ -45,6 +45,7 @@
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.system.util.MathUtils;
@@ -66,6 +67,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Implementation
     // -------------------------------------------------------------------------
@@ -243,7 +247,8 @@
             columns.add( col );
         }
 
-        for ( PatientIdentifierType identifierType : table.getProgram().getPatientIdentifierTypes() )
+        for ( PatientIdentifierType identifierType : programPatientIdentifierTypeService
+            .getListPatientIdentifierType( table.getProgram() ) )
         {
             String sql = "(select identifier from patientidentifier where patientid=pi.patientid and "
                 + "patientidentifiertypeid=" + identifierType.getId() + ") as " + quote( identifierType.getUid() );

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-01-07 15:02:45 +0000
@@ -84,6 +84,7 @@
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElement;
@@ -171,6 +172,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Setters
     // -------------------------------------------------------------------------
@@ -1610,7 +1614,8 @@
         Collection<Program> programs = programService.getAllPrograms();
         for ( Program program : programs )
         {
-            patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
+            patientIdentifierTypes.removeAll( programPatientIdentifierTypeService
+                .getListPatientIdentifierType( program ) );
         }
         return patientIdentifierTypes;
     }
@@ -1635,7 +1640,7 @@
         if ( programId != null && !programId.trim().equals( "" ) )
         {
             Program program = programService.getProgram( Integer.parseInt( programId ) );
-            patientIdentifierTypes = program.getPatientIdentifierTypes();
+            patientIdentifierTypes = programPatientIdentifierTypeService.getListPatientIdentifierType( program );
         }
         else
         {

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java	2014-01-07 15:02:45 +0000
@@ -128,7 +128,7 @@
     public Collection<PatientAttribute> getPatientAttributesWithoutProgram()
     {
         Collection<PatientAttribute> programPatientAttributes = programPatientAttributeService.getPatientAttributes();
-        
+
         Collection<PatientAttribute> patientAttributes = patientAttributeStore.getAll();
         patientAttributes.removeAll( programPatientAttributes );
 

=== 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	2013-11-08 03:05:02 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierTypeService.java	2014-01-07 15:02:45 +0000
@@ -128,9 +128,4 @@
         return i18n( i18nService, patientIdentifierTypeStore.get( mandatory ) );
     }
 
-    public Collection<PatientIdentifierType> getDisplayedPatientIdentifierTypes( boolean personDisplayName )
-    {
-        return i18n( i18nService, patientIdentifierTypeStore.getByDisplayed( personDisplayName ) );
-    }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2014-01-07 15:02:45 +0000
@@ -28,6 +28,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 import org.apache.commons.lang.StringUtils;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
@@ -37,21 +45,15 @@
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.relationship.Relationship;
 import org.hisp.dhis.relationship.RelationshipService;
 import org.hisp.dhis.relationship.RelationshipType;
 import org.hisp.dhis.relationship.RelationshipTypeService;
 import org.hisp.dhis.system.grid.ListGrid;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
 /**
  * @author Abyot Asalefew Gizaw
  * @version $Id$
@@ -113,6 +115,9 @@
         this.relationshipTypeService = relationshipTypeService;
     }
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Implementation methods
     // -------------------------------------------------------------------------
@@ -555,7 +560,8 @@
         grid.addHeader( new GridHeader( i18n.getString( "gender" ), true, true ) );
         grid.addHeader( new GridHeader( i18n.getString( "phone_number" ), false, true ) );
 
-        Collection<PatientIdentifierType> patientIdentifierTypes = program.getPatientIdentifierTypes();
+        Collection<PatientIdentifierType> patientIdentifierTypes = programPatientIdentifierTypeService
+            .getListPatientIdentifierType( program );
         for ( PatientIdentifierType patientIdentifierType : patientIdentifierTypes )
         {
             grid.addHeader( new GridHeader( patientIdentifierType.getDisplayName(), false, true ) );

=== 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	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierTypeStore.java	2014-01-07 15:02:45 +0000
@@ -45,9 +45,4 @@
         return getCriteria( Restrictions.eq( "mandatory", mandatory ) ).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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2014-01-07 15:02:45 +0000
@@ -289,13 +289,18 @@
 
         executeSql( "ALTER TABLE program DROP COLUMN useBirthDateAsIncidentDate" );
         executeSql( "ALTER TABLE program DROP COLUMN useBirthDateAsEnrollmentDate" );
-        
-        executeSql( "UPDATE patientattribute set displayedInList=false WHERE displayedInList is null" );
-        executeSql( "INSERT INTO program_programpatientAttributes (programid, programpatientattributeid, displayedInList ) "
-            + "SELECT programid,patientattributeid, displayedInList FROM program_patientattributes pp "
+
+        executeSql( "INSERT INTO program_attributes (programid, patientattributeid, displayedInList ) "
+            + "SELECT programid, pp.patientattributeid, displayedInList FROM program_patientattributes pp "
             + "INNER JOIN patientattribute pa ON pp.patientattributeid=pa.patientattributeid" );
-//        executeSql( "DROP TABLE program_patientattributes" );
-//        executeSql( "ALTER TABLE patientattribute DROP COLUMN displayedInList" );
+        executeSql( "DROP TABLE program_patientattributes" );
+        executeSql( "ALTER TABLE patientattribute DROP COLUMN displayedInList" );
+
+        executeSql( "INSERT INTO program_identifierTypes (programid, patientidentifiertypeid, displayedInList ) "
+            + "SELECT programid, pp.patientidentifiertypeid, personDisplayName FROM program_patientidentifiertypes pp "
+            + "INNER JOIN patientidentifiertype pi ON pp.patientidentifiertypeid=pi.patientidentifiertypeid" );
+        executeSql( "DROP TABLE program_patientidentifiertypes" );
+        executeSql( "ALTER TABLE patientidentifiertype DROP COLUMN personDisplayName" );
     }
 
     // -------------------------------------------------------------------------
@@ -469,7 +474,7 @@
         try
         {
             Statement statement = holder.getStatement();
-            
+
             ResultSet resultSet = statement.executeQuery( "SELECT gender FROM patientattribute" );
 
             // Only execute once
@@ -776,7 +781,8 @@
                     + "','Staff', 'Staff','"
                     + PatientAttribute.TYPE_USERS + "', false, false, false)" );
                 executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid,"
-                    + max + ",healthworkerid from patient inner join userinfo on patient.healthworkerid=userinfo.userinfoid where patient.healthworkerid is not null" );
+                    + max
+                    + ",healthworkerid from patient inner join userinfo on patient.healthworkerid=userinfo.userinfoid where patient.healthworkerid is not null" );
 
                 // Update custom entry form
                 removeFixedAttributeInCustomRegistrationForm( "associate", uid );

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2014-01-07 15:02:45 +0000
@@ -54,6 +54,7 @@
 import org.hisp.dhis.system.grid.ListGrid;
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
@@ -146,6 +147,9 @@
         this.programPatientAttributeService = programPatientAttributeService;
     }
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Implementation methods
     // -------------------------------------------------------------------------
@@ -332,7 +336,8 @@
 
         for ( Program program : programs )
         {
-            Collection<PatientIdentifierType> identifierTypes = program.getPatientIdentifierTypes();
+            Collection<PatientIdentifierType> identifierTypes = programPatientIdentifierTypeService
+                .getListPatientIdentifierType( program );
             while ( iterIdentifier.hasNext() )
             {
                 PatientIdentifier identifier = iterIdentifier.next();
@@ -413,7 +418,8 @@
 
         Patient patient = programInstance.getPatient();
 
-        Collection<PatientIdentifierType> identifierTypes = programInstance.getProgram().getPatientIdentifierTypes();
+        Collection<PatientIdentifierType> identifierTypes = programPatientIdentifierTypeService
+            .getListPatientIdentifierType( programInstance.getProgram() );
 
         Collection<PatientIdentifier> identifiers = patient.getIdentifiers();
 
@@ -442,8 +448,9 @@
 
         // Get patient-attribute-values which belong to the program
 
-        Collection<PatientAttribute> atttributes = programPatientAttributeService.getListPatientAttribute( programInstance.getProgram() );
-       
+        Collection<PatientAttribute> atttributes = programPatientAttributeService
+            .getListPatientAttribute( programInstance.getProgram() );
+
         for ( PatientAttribute attrtibute : atttributes )
         {
             PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient,

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramDeletionHandler.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramDeletionHandler.java	2014-01-07 15:02:45 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.system.deletion.DeletionHandler;
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.validation.ValidationCriteria;
+import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * @author Chau Thu Tran
@@ -77,18 +78,6 @@
     }
 
     @Override
-    public void deletePatientIdentifierType( PatientIdentifierType patientIdentifierType )
-    {
-        Collection<Program> programs = programService.getAllPrograms();
-
-        for ( Program program : programs )
-        {
-            program.getPatientIdentifierTypes().clear();
-            programService.updateProgram( program );
-        }
-    }
-
-    @Override
     public void deleteOrganisationUnit( OrganisationUnit unit )
     {
         // TODO improve performance

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2014-01-07 15:02:45 +0000
@@ -484,6 +484,17 @@
 		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>
 
+	<bean id="org.hisp.dhis.program.ProgramPatientIdentifierTypeService"
+		class="org.hisp.dhis.program.DefaultProgramPatientIdentiferTypeService">
+		<property name="programPatientIdentifierTypeStore"
+			ref="org.hisp.dhis.program.ProgramPatientIdentifierTypeStore" />
+	</bean>
+
+	<bean id="org.hisp.dhis.program.ProgramPatientIdentifierTypeStore"
+		class="org.hisp.dhis.program.hibernate.HibernateProgramPatientIdentifierTypeStore">
+		<property name="sessionFactory" ref="sessionFactory" />
+	</bean>
+
 	<!-- Startup -->
 
 	<bean id="org.hisp.dhis.patient.startup.TableAlteror" class="org.hisp.dhis.patient.startup.TableAlteror">

=== 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	2013-09-17 06:08:16 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientIdentifierType.hbm.xml	2014-01-07 15:02:45 +0000
@@ -25,8 +25,6 @@
 
     <property name="type" />
 
-    <property name="personDisplayName" />
-
     <property name="orgunitScope" />
 
     <property name="programScope" />

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2014-01-07 15:02:45 +0000
@@ -48,11 +48,10 @@
 
 		<property name="onlyEnrollOnce" />
 
-		<list name="patientIdentifierTypes" table="program_patientIdentifierTypes">
+		<list name="programPatientIdentifierTypes" table="program_programpatientIdentifierTypes">
 			<key column="programid" foreign-key="fk_program_patientIdentifierTypes_programid" />
 			<list-index column="sort_order" base="0" />
-			<many-to-many column="patientidentifiertypeid"
-				class="org.hisp.dhis.patient.PatientIdentifierType" foreign-key="fk_program_patientIdentifierTypes_patientidentifiertypeid" />
+			<one-to-many class="org.hisp.dhis.program.ProgramPatientIdentifierType" />
 		</list>
 
 		<list name="programPatientAttributes" table="program_programpatientAttributes">

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientIdentifierTypeServiceTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientIdentifierTypeServiceTest.java	2013-11-11 02:42:44 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientIdentifierTypeServiceTest.java	2014-01-07 15:02:45 +0000
@@ -167,23 +167,4 @@
         assertTrue( equals( identifierTypes, identifierTypeC ) );
     }
 
-    @Test
-    public void testGetDisplayedPatientIdentifierTypes()
-    {
-        identifierTypeA.setPersonDisplayName( true );
-        identifierTypeB.setPersonDisplayName( true );
-
-        identifierTypeService.savePatientIdentifierType( identifierTypeA );
-        identifierTypeService.savePatientIdentifierType( identifierTypeB );
-        identifierTypeService.savePatientIdentifierType( identifierTypeC );
-        
-        Collection<PatientIdentifierType> identifierTypes = identifierTypeService
-            .getDisplayedPatientIdentifierTypes( true );
-        assertEquals( 2, identifierTypes.size() );
-        assertTrue( equals( identifierTypes, identifierTypeA, identifierTypeB ) );
-
-        identifierTypes = identifierTypeService.getDisplayedPatientIdentifierTypes( false );
-        assertEquals( 1, identifierTypes.size() );
-        assertTrue( equals( identifierTypes, identifierTypeC ) );
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientIdentifierTypeStoreTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientIdentifierTypeStoreTest.java	2013-11-08 07:40:31 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientIdentifierTypeStoreTest.java	2014-01-07 15:02:45 +0000
@@ -79,23 +79,5 @@
         assertEquals( 1, identifierTypes.size() );
         assertTrue( equals( identifierTypes, identifierTypeC ) );
     }
-
-    @Test
-    public void testGetDisplayedPatientIdentifierTypes()
-    {
-        identifierTypeA.setPersonDisplayName( true );
-        identifierTypeB.setPersonDisplayName( true );
-
-        identifierTypeStore.save( identifierTypeA );
-        identifierTypeStore.save( identifierTypeB );
-        identifierTypeStore.save( identifierTypeC );
-
-        Collection<PatientIdentifierType> identifierTypes = identifierTypeStore.getByDisplayed( true );
-        assertEquals( 2, identifierTypes.size() );
-        assertTrue( equals( identifierTypes, identifierTypeA, identifierTypeB ) );
-
-        identifierTypes = identifierTypeStore.getByDisplayed( false );
-        assertEquals( 1, identifierTypes.size() );
-        assertTrue( equals( identifierTypes, identifierTypeC ) );
-    }
+    
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java	2014-01-07 15:02:45 +0000
@@ -30,32 +30,25 @@
 
 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.common.Grid;
-import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.paging.ActionPagingSupport;
 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.PatientService;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramPatientAttributeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceService;
-import org.springframework.beans.factory.annotation.Autowired;
 
 public class GetDataRecordsAction
     extends ActionPagingSupport<Patient>
@@ -92,23 +85,6 @@
         this.programStageInstanceService = programStageInstanceService;
     }
 
-    private PatientAttributeService patientAttributeService;
-
-    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
-    {
-        this.patientAttributeService = patientAttributeService;
-    }
-
-    private PatientAttributeValueService patientAttributeValueService;
-
-    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
-    {
-        this.patientAttributeValueService = patientAttributeValueService;
-    }
-
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
     private I18n i18n;
 
     public void setI18n( I18n i18n )
@@ -197,20 +173,6 @@
         return grid;
     }
 
-    private List<PatientAttribute> patientAttributes;
-
-    public List<PatientAttribute> getPatientAttributes()
-    {
-        return patientAttributes;
-    }
-
-    private Map<Integer, List<String>> patientAttributeValueMap = new HashMap<Integer, List<String>>();
-
-    public Map<Integer, List<String>> getPatientAttributeValueMap()
-    {
-        return patientAttributeValueMap;
-    }
-
     private Boolean followup;
 
     public void setFollowup( Boolean followup )
@@ -240,20 +202,12 @@
         if ( programId != null )
         {
             program = programService.getProgram( programId );
-            identifierTypes = program.getPatientIdentifierTypes();
-            attributes = new ArrayList<PatientAttribute>(
-                programPatientAttributeService.getListPatientAttribute( program ) );
         }
 
         if ( searchTexts.size() > 0 )
         {
             if ( type == null )
             {
-                patientAttributes = new ArrayList<PatientAttribute>(
-                    patientAttributeService.getPatientAttributesByDisplayOnVisitSchedule( true ) );
-
-                Collections.sort( patientAttributes, IdentifiableObjectNameComparator.INSTANCE );
-
                 total = patientService.countSearchPatients( searchTexts, orgunits, followup,
                     ProgramInstance.STATUS_ACTIVE );
                 this.paging = createPaging( total );
@@ -263,27 +217,9 @@
 
                 for ( Integer stageInstanceId : stageInstanceIds )
                 {
-                    // Get programStageInstance
-
                     ProgramStageInstance programStageInstance = programStageInstanceService
                         .getProgramStageInstance( stageInstanceId );
                     programStageInstances.add( programStageInstance );
-
-                    // Get Patient-attributes
-
-                    Patient patient = programStageInstance.getProgramInstance().getPatient();
-                    if ( patientAttributeValueMap.get( patient.getId() ) == null )
-                    {
-                        List<String> values = new ArrayList<String>();
-                        for ( PatientAttribute patientAttribute : patientAttributes )
-                        {
-                            PatientAttributeValue patientAttributeValue = patientAttributeValueService
-                                .getPatientAttributeValue( patient, patientAttribute );
-                            String value = (patientAttributeValue == null) ? "" : patientAttributeValue.getValue();
-                            values.add( value );
-                        }
-                        patientAttributeValueMap.put( patient.getId(), values );
-                    }
                 }
             }
             else if ( trackingReport != null && trackingReport )

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java	2014-01-07 15:02:45 +0000
@@ -52,6 +52,7 @@
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramDataEntryService;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElement;
@@ -122,6 +123,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     private I18n i18n;
 
     public void setI18n( I18n i18n )
@@ -192,7 +196,7 @@
             programs.remove( program );
             for ( Program p : programs )
             {
-                identifierTypes.removeAll( p.getPatientIdentifierTypes() );
+                identifierTypes.removeAll( programPatientIdentifierTypeService.getListPatientIdentifierType( p ) );
                 patientAttributesInProgram.addAll( programPatientAttributeService.getListPatientAttribute( p ) );
             }
 

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2014-01-07 15:02:45 +0000
@@ -57,6 +57,7 @@
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.relationship.Relationship;
 import org.hisp.dhis.relationship.RelationshipService;
@@ -100,6 +101,8 @@
 
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
 
     private I18n i18n;
 
@@ -252,13 +255,13 @@
                 Collection<Program> programs = programService.getAllPrograms();
                 for ( Program p : programs )
                 {
-                    identifierTypes.removeAll( p.getPatientIdentifierTypes() );
+                    identifierTypes.removeAll( programPatientIdentifierTypeService.getListPatientIdentifierType( p ) );
                     attributes.removeAll( programPatientAttributeService.getListPatientAttribute( p ) );
                 }
             }
             else
             {
-                identifierTypes = program.getPatientIdentifierTypes();
+                identifierTypes = programPatientIdentifierTypeService.getListPatientIdentifierType( program );
                 attributes.removeAll( programPatientAttributeService.getListPatientAttribute( program ) );
             }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2014-01-07 15:02:45 +0000
@@ -50,6 +50,7 @@
 import org.hisp.dhis.program.ProgramIndicatorService;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.relationship.Relationship;
 import org.hisp.dhis.relationship.RelationshipService;
@@ -87,6 +88,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -251,7 +255,8 @@
 
         for ( Program program : programs )
         {
-            Collection<PatientIdentifierType> identifierTypes = program.getPatientIdentifierTypes();
+            Collection<PatientIdentifierType> identifierTypes = programPatientIdentifierTypeService
+                .getListPatientIdentifierType( program );
             for ( PatientIdentifier identifier : _identifiers )
             {
                 if ( !identifierTypes.contains( identifier.getIdentifierType() ) )

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2014-01-07 15:02:45 +0000
@@ -48,6 +48,7 @@
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.comparator.ProgramStageInstanceVisitDateComparator;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -71,6 +72,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -196,7 +200,8 @@
         // Load identifier types of the selected program
         // ---------------------------------------------------------------------
 
-        identifierTypes = programInstance.getProgram().getPatientIdentifierTypes();
+        identifierTypes = new ArrayList<PatientIdentifierType>(
+            programPatientIdentifierTypeService.getListPatientIdentifierType( programInstance.getProgram() ) );
         identiferMap = new HashMap<Integer, String>();
 
         if ( identifierTypes != null && identifierTypes.size() > 0 )

=== 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	2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveIdentifierAndAttributeAction.java	2014-01-07 15:02:45 +0000
@@ -48,7 +48,9 @@
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -76,6 +78,9 @@
 
     private ProgramService programService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     private I18nFormat format;
 
     // -------------------------------------------------------------------------
@@ -181,7 +186,8 @@
 
         String value = null;
 
-        Collection<PatientIdentifierType> identifierTypes = program.getPatientIdentifierTypes();
+        Collection<PatientIdentifierType> identifierTypes = programPatientIdentifierTypeService
+            .getListPatientIdentifierType( program );
 
         PatientIdentifier identifier = 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java	2014-01-07 15:02:45 +0000
@@ -28,29 +28,28 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
 /**
  * @author Abyot Asalefew Gizaw
  */
@@ -82,6 +81,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -181,20 +183,6 @@
         this.programId = programId;
     }
 
-    private List<PatientIdentifierType> identifierTypes = new ArrayList<PatientIdentifierType>();
-
-    public List<PatientIdentifierType> getIdentifierTypes()
-    {
-        return identifierTypes;
-    }
-
-    private List<PatientAttribute> attributes = new ArrayList<PatientAttribute>();
-
-    public List<PatientAttribute> getAttributes()
-    {
-        return attributes;
-    }
-
     private OrganisationUnit organisationUnit;
 
     public OrganisationUnit getOrganisationUnit()
@@ -209,6 +197,13 @@
         return mapUsers;
     }
 
+    private Program program;
+
+    public Program getProgram()
+    {
+        return program;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -283,10 +278,7 @@
 
             if ( programId != null )
             {
-                Program program = programService.getProgram( programId );
-                identifierTypes = program.getPatientIdentifierTypes();
-                attributes = new ArrayList<PatientAttribute>(
-                    programPatientAttributeService.getListPatientAttribute( program ) );
+                program = programService.getProgram( programId );
             }
         }
 

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java	2014-01-07 15:02:45 +0000
@@ -50,6 +50,7 @@
 import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.relationship.RelationshipType;
 import org.hisp.dhis.relationship.RelationshipTypeService;
@@ -121,6 +122,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     private I18n i18n;
 
     public void setI18n( I18n i18n )
@@ -321,14 +325,15 @@
                 Collection<Program> programs = programService.getAllPrograms();
                 for ( Program p : programs )
                 {
-                    identifierTypes.removeAll( p.getPatientIdentifierTypes() );
+                    identifierTypes.removeAll( programPatientIdentifierTypeService.getListPatientIdentifierType( p ));
                     attributes.removeAll( programPatientAttributeService.getListPatientAttribute( p ) );
                 }
             }
             else
             {
-                identifierTypes = program.getPatientIdentifierTypes();
-                attributes = new ArrayList<PatientAttribute>( programPatientAttributeService.getListPatientAttribute( program ) );
+                identifierTypes = programPatientIdentifierTypeService.getListPatientIdentifierType( program );
+                attributes = new ArrayList<PatientAttribute>(
+                    programPatientAttributeService.getListPatientAttribute( program ) );
             }
 
             for ( PatientAttribute attribute : attributes )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetAggregateReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetAggregateReportAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetAggregateReportAction.java	2014-01-07 15:02:45 +0000
@@ -51,6 +51,7 @@
 import org.hisp.dhis.patientreport.PatientAggregateReportService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramStage;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -106,6 +107,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -265,7 +269,7 @@
             {
                 PatientIdentifierType it = patientIdentifierTypeService.getPatientIdentifierType( dimensionId );
 
-                if ( it != null && program.getPatientIdentifierTypes().contains( it ) )
+                if ( it != null && programPatientIdentifierTypeService.getListPatientIdentifierType( program ).contains( it ) )
                 {
                     dimensionIdentifierTypes.add( it );
                 }
@@ -302,7 +306,7 @@
 
             PatientIdentifierType it = patientIdentifierTypeService.getPatientIdentifierType( filterId );
 
-            if ( it != null && program.getPatientIdentifierTypes().contains( it ) )
+            if ( it != null && programPatientIdentifierTypeService.getListPatientIdentifierType( program ).contains( it ) )
             {
                 filterIdentifierTypes.add( it );
             }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularReportAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularReportAction.java	2014-01-07 15:02:45 +0000
@@ -50,6 +50,7 @@
 import org.hisp.dhis.patientreport.PatientTabularReportService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramStage;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -105,6 +106,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
@@ -244,7 +248,7 @@
             {
                 PatientIdentifierType it = patientIdentifierTypeService.getPatientIdentifierType( dimensionId );
 
-                if ( it != null && program.getPatientIdentifierTypes().contains( it ) )
+                if ( it != null && programPatientIdentifierTypeService.getListPatientIdentifierType( program ).contains( it ) )
                 {
                     dimensionIdentifierTypes.add( it );
                 }
@@ -281,7 +285,7 @@
 
             PatientIdentifierType it = patientIdentifierTypeService.getPatientIdentifierType( filterId );
 
-            if ( it != null && program.getPatientIdentifierTypes().contains( it ) )
+            if ( it != null && programPatientIdentifierTypeService.getListPatientIdentifierType( program ).contains( it ) )
             {
                 filterIdentifierTypes.add( it );
             }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java	2014-01-07 15:02:45 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageSection;
@@ -73,6 +74,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -137,7 +141,8 @@
 
         if ( program != null && program.isRegistration() )
         {
-            identifierTypes = new ArrayList<PatientIdentifierType>( program.getPatientIdentifierTypes() );
+            identifierTypes = new ArrayList<PatientIdentifierType>(
+                programPatientIdentifierTypeService.getListPatientIdentifierType( program ) );
             patientAttributes = new ArrayList<PatientAttribute>(
                 programPatientAttributeService.getListPatientAttribute( program ) );
         }

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2014-01-07 15:02:45 +0000
@@ -201,10 +201,6 @@
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="patientAttributeService"
-			ref="org.hisp.dhis.patient.PatientAttributeService" />
-		<property name="patientAttributeValueService"
-			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
 
 	<!-- Single-event DataEntry -->

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm	2014-01-07 15:02:45 +0000
@@ -18,15 +18,15 @@
 			<th>$i18n.getString('orgunit')</th>
 			
 			#if( $auth.hasAccess( "dhis-web-caseentry", "accessPatientAttributes" ) )
-				#foreach( $identifierType in $identifierTypes)
-					#if($identifierType.personDisplayName=='true')
-						<th>$encoder.htmlEncode($identifierType.displayName)</th>
+				#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
+					#if($programIdentifierType.displayedInList=='true')
+						<th>$encoder.htmlEncode($programIdentifierType.patientIdentifierType.displayName)</th>
 					#end
 				#end
 				
-				#foreach( $attribute in $attributes )
-					#if($attribute.displayedInList=='true')
-						<th id="patientAttributeName">$encoder.htmlEncode($attribute.displayName)</th>
+				#foreach( $programAttribute in $program.programPatientAttributes )
+					#if($programAttribute.displayedInList=='true')
+						<th id="patientAttributeName">$encoder.htmlEncode($programAttribute.patientAttribute.displayName)</th>
 					#end
 				#end
 			#end
@@ -63,12 +63,12 @@
 			
 			#if( $auth.hasAccess( "dhis-web-caseentry", "accessPatientAttributes" ) )
 			
-				#foreach( $identifierType in $identifierTypes)
+				#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
 					#set($value="")
-					#if($identifierType.personDisplayName=='true')
+					#if($programIdentifierType.displayedInList=='true')
 						<td><a href="javascript:isDashboard=false;showPatientDashboardForm( '$patient.uid' )">
-							#foreach( $identifier in $programStageInstance.programInstance.patient.identifiers)
-								#if($!identifier.identifierType.id==$identifierType.id)
+							#foreach( $identifier in $patient.identifiers)
+								#if($!identifier.identifierType.id==$programIdentifierType.patientIdentifierType.id)
 									#set($value=$identifier.identifier)
 								#end
 							#end 
@@ -77,17 +77,17 @@
 					#end
 				#end
 				
-				#foreach( $attribute in $attributes )
-					#if($attribute.displayedInList=='true')
+				#foreach( $programAttribute in $program.programPatientAttributes )
+					#if($programAttribute.displayedInList=='true')
 						<td style="cursor:pointer;" onclick="javascript:isDashboard=true;showPatientDashboardForm( '$patient.uid' )">
-							#foreach( $attributeValue in $programStageInstance.programInstance.patient.attributeValues)
-								#if($!attributeValue.patientAttribute.id==$attribute.id)
+							#foreach( $attributeValue in $patient.attributeValues)
+								#if($!attributeValue.patientAttribute.id==$programAttribute.patientAttribute.id)
 									#set($value=$attributeValue.value)
-									#if( $attribute.valueType == 'bool')
+									#if( $programAttribute.patientAttribute.valueType == 'bool')
 										#set($value=$i18n.getString($attributeValue.value))
 									#end
 								#end
-							#end 
+							#end  
 							<a>$encoder.htmlEncode($value)</a>
 						</td>
 					#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.vm	2014-01-07 15:02:45 +0000
@@ -58,12 +58,12 @@
 			</td>
 			
 			#if( $auth.hasAccess( "dhis-web-caseentry", "accessPatientAttributes" ) )
-				#foreach( $identifierType in $identifierTypes)
+				#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
 					#set($value="")
-					#if($identifierType.personDisplayName=='true')
+					#if($programIdentifierType.displayedInList=='true')
 						<td><a href="javascript:isDashboard=false;showPatientDashboardForm( '$patient.uid' )">
 							#foreach( $identifier in $patient.identifiers)
-								#if($!identifier.identifierType.id==$identifierType.id)
+								#if($!identifier.identifierType.id==$programIdentifierType.patientIdentifierType.id)
 									#set($value=$identifier.identifier)
 								#end
 							#end 
@@ -72,13 +72,13 @@
 					#end
 				#end
 
-				#foreach( $attribute in $attributes )
-					#if($attribute.displayedInList=='true')
+				#foreach( $programAttribute in $program.programPatientAttributes )
+					#if($programAttribute.displayedInList=='true')
 						<td><a href="javascript:isDashboard=false;showPatientDashboardForm( '$patient.uid' )">
 							#foreach( $attributeValue in $patient.attributeValues)
-								#if($!attributeValue.patientAttribute.id==$attribute.id)
+								#if($!attributeValue.patientAttribute.id==$programAttribute.patientAttribute.id)
 									#set($value=$attributeValue.value)
-									#if( $attribute.valueType == 'bool')
+									#if( $programAttribute.patientAttribute.valueType == 'bool')
 										#set($value=$i18n.getString($attributeValue.value))
 									#end
 								#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/identifierAndAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/identifierAndAttributeForm.vm	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/identifierAndAttributeForm.vm	2014-01-07 15:02:45 +0000
@@ -1,6 +1,7 @@
 
 	
-#foreach ($identifierType in $program.patientIdentifierTypes) 
+#foreach ($prorgamIdentifierType in $program.programIdentifierTypes) 
+	#set( $identifierType = $prorgamIdentifierType.patientIdentifierType )
 	<tr>
 		<td class='text-column'><label>$identifierType.displayName #if($identifierType.mandatory == true )<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>       
 		<td class="input-column">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm	2014-01-07 15:02:45 +0000
@@ -26,14 +26,18 @@
 <tr><td>
 	<table class="listTable" id="patientList" width='100%'>               
           <col width="30"/>
-			#foreach( $identifierType in $identifierTypes)
-				#if($identifierType.personDisplayName=='true')<col/>#end
-			#end
-			
-			#foreach( $attribute in $attributes )
-				#if($attribute.displayedInList=='true')<col/>#end
-			#end
-			
+			#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
+				#if($programIdentifierType.displayedInList=='true')
+					<col/>
+				#end
+			#end
+
+			#foreach( $programAttribute in $program.programPatientAttributes )
+				#if($programAttribute.displayedInList=='true')
+					<col/>
+				#end
+			#end
+
 		  #if($mapPatientOrgunit.size()!=0)
 		  <col/>
 		  #end
@@ -43,17 +47,18 @@
 			<tr>
 				<th>#</th>
 				
-				#foreach( $identifierType in $identifierTypes)
-					#if($identifierType.personDisplayName=='true')
-						<th>$encoder.htmlEncode($identifierType.displayName)</th>
+				#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
+					#if($programIdentifierType.displayedInList=='true')
+						<th>$encoder.htmlEncode($programIdentifierType.patientIdentifierType.displayName)</th>
+					#end
+				#end
+
+				#foreach( $programAttribute in $program.programPatientAttributes )
+					#if($programAttribute.displayedInList=='true')
+						<th id="patientAttributeName">$encoder.htmlEncode($programAttribute.patientAttribute.displayName)</th>
 					#end
 				#end
 				
-				#foreach( $attribute in $attributes )
-					#if($attribute.displayedInList=='true')
-						<th id="patientAttributeName">$encoder.htmlEncode($attribute.displayName)</th>
-					#end
-				#end
 				
 				#if($mapPatientOrgunit.size()!=0)
 					<th>$i18n.getString( "hierachy_orgunit" )</th>
@@ -72,12 +77,12 @@
 					$nr
 				</td>
 					
-				#foreach( $identifierType in $identifierTypes)
+				#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
 					#set($value="")
-					#if($identifierType.personDisplayName=='true')
+					#if($programIdentifierType.displayedInList=='true')
 						<td style="cursor:pointer;" onclick="javascript:isDashboard=true;showPatientDashboardForm( '$patient.uid' )">
 							#foreach( $identifier in $patient.identifiers)
-								#if($!identifier.identifierType.id==$identifierType.id)
+								#if($!identifier.identifierType.id==$programIdentifierType.patientIdentifierType.id)
 									#set($value=$identifier.identifier)
 								#end
 							#end 
@@ -86,13 +91,13 @@
 					#end
 				#end
 				
-				#foreach( $attribute in $attributes )
-					#if($attribute.displayedInList=='true')
+				#foreach( $programAttribute in $program.programPatientAttributes )
+					#if($programAttribute.displayedInList=='true')
 						<td style="cursor:pointer;" onclick="javascript:isDashboard=true;showPatientDashboardForm( '$patient.uid' )">
 							#foreach( $attributeValue in $patient.attributeValues)
-								#if($!attributeValue.patientAttribute.id==$attribute.id)
+								#if($!attributeValue.patientAttribute.id==$programAttribute.patientAttribute.id)
 									#set($value=$attributeValue.value)
-									#if( $attribute.valueType == 'bool')
+									#if( $programAttribute.patientAttribute.valueType == 'bool')
 										#set($value=$i18n.getString($attributeValue.value))
 									#end
 								#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2014-01-07 15:02:45 +0000
@@ -43,9 +43,7 @@
 				#foreach( $identifier in $identifiers )
 				<tr>
 					<td>
-					#if($!identifier.identifierType.personDisplayName=='true')
 						$!identifier.identifierType.displayName
-					#end
 					</td>
 					<td id='dashboard_iden$identifier.identifierType.id'>$identifier.identifier</td>
 				</tr>
@@ -200,9 +198,7 @@
 								#set($patient=$rel.patientB)
 								#set($value="")
 								#foreach( $identifier in $patient.identifiers)
-									#if($!identifier.identifierType.personDisplayName=='true')
-										#set($value=$identifier.identifier)
-									#end
+									#set($value=$identifier.identifier)
 								#end
 								<a href='#'>$value</a>
 							</td>
@@ -213,9 +209,7 @@
 							<td><a href='#'>
 								#set($patient=$!rel.patientA)
 								#foreach( $identifier in $patient.identifiers)
-									#if($!identifier.identifierType.personDisplayName=='true')
-										#set($value=$identifier.identifier)
-									#end
+									#set($value=$identifier.identifier)
 								#end
 								<a href='#'>$value</a>
 							</td>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.vm	2014-01-07 15:02:45 +0000
@@ -12,11 +12,8 @@
 <table>
 	#foreach( $identifier in $patient.identifiers)
 		<tr>
-			#if($!identifier.identifierType.personDisplayName=='true')
-				<td>$identifier.identifierType.displayName:</td>
-				<td>$identifier.identifier</td>
-			#end
-			
+			<td>$identifier.identifierType.displayName:</td>
+			<td>$identifier.identifier</td>
 		</tr>
 	#end
 </table>

=== 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	2014-01-06 18:15:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2014-01-07 15:02:45 +0000
@@ -34,12 +34,16 @@
     <td>    
       <table class="listTable" id="patientList" width='100%'>               
           <col width="30"/>
-			#foreach( $identifierType in $identifierTypes)
-				#if($identifierType.personDisplayName=='true')<col/>#end
+			#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
+				#if($programIdentifierType.displayedInList=='true')
+					<col/>
+				#end
 			#end
-			
-			#foreach( $attribute in $attributes )
-				#if($attribute.displayedInList=='true')<col/>#end
+
+			#foreach( $programAttribute in $program.programPatientAttributes )
+				#if($programAttribute.displayedInList=='true')
+					<col/>
+				#end
 			#end
 			
 		  #if($mapPatientOrgunit.size()!=0)
@@ -51,15 +55,15 @@
 			<tr>
 				<th>#</th>
 				
-				#foreach( $identifierType in $identifierTypes)
-					#if($identifierType.personDisplayName=='true')
-						<th>$encoder.htmlEncode($identifierType.displayName)</th>
+				#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
+					#if($programIdentifierType.displayedInList=='true')
+						<th>$encoder.htmlEncode($programIdentifierType.patientIdentifierType.displayName)</th>
 					#end
 				#end
-				
-				#foreach( $attribute in $attributes )
-					#if($attribute.displayedInList=='true')
-						<th id="patientAttributeName">$encoder.htmlEncode($attribute.displayName)</th>
+
+				#foreach( $programAttribute in $program.programPatientAttributes )
+					#if($programAttribute.displayedInList=='true')
+						<th id="patientAttributeName">$encoder.htmlEncode($programAttribute.patientAttribute.displayName)</th>
 					#end
 				#end
 				
@@ -79,35 +83,33 @@
 					#set( $nr = ( ( $paging.getCurrentPage() - 1  ) * $paging.pageSize ) + $velocityCount )
 					$nr
 				</td>
-					
-				#foreach( $identifierType in $identifierTypes)
-					#set($id="")
-					#if($identifierType.personDisplayName=='true')
+				
+				#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
+					#set($value="")
+					#if($programIdentifierType.displayedInList=='true')
 						<td style="cursor:pointer;" onclick="javascript:isDashboard=true;showPatientDashboardForm( '$patient.uid' )">
 							#foreach( $identifier in $patient.identifiers)
-								#if($!identifier.identifierType.id==$identifierType.id)
-									#set($id=$identifier.identifier)
+								#if($!identifier.identifierType.id==$programIdentifierType.patientIdentifierType.id)
+									#set($value=$identifier.identifier)
 								#end
 							#end 
-						<a>$encoder.htmlEncode($id)</a>
+						<a>$encoder.htmlEncode($value)</a>
 					</td>
 					#end
 				#end
 				
-				#foreach( $attribute in $attributes )
-					#if($attribute.displayedInList=='true')
+				#foreach( $programAttribute in $program.programPatientAttributes )
+					#if($programAttribute.displayedInList=='true')
 						<td style="cursor:pointer;" onclick="javascript:isDashboard=true;showPatientDashboardForm( '$patient.uid' )">
 							#foreach( $attributeValue in $patient.attributeValues)
-								#if($!attributeValue.patientAttribute.id==$attribute.id)
+								#if($!attributeValue.patientAttribute.id==$programAttribute.patientAttribute.id)
 									#set($value=$attributeValue.value)
-									#if( $attribute.valueType == 'bool')
+									#if( $programAttribute.patientAttribute.valueType == 'bool')
 										#set($value=$i18n.getString($attributeValue.value))
-									#elseif( $attribute.valueType == 'users')
-										#set($value=$mapUsers.get($attributeValue.value))
 									#end
 								#end
 							#end 
-							<a>$!encoder.htmlEncode($value)</a>
+							<a>$encoder.htmlEncode($value)</a>
 						</td>
 					#end
 				#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm	2014-01-07 15:02:45 +0000
@@ -13,23 +13,19 @@
 	#set($status = $programStageInstance.getEventStatus())
 	#if( $auth.hasAccess( "dhis-web-caseentry", "accessPatientAttributes" ) )
 		<table>
-			#foreach( $identifierType in $programStageInstance.programInstance.program.patientIdentifierTypes)
+			#foreach( $programIdentifierType in $programInstance.program.programPatientIdentifierTypes)
 				<tr> 
-					#if($identifierType.personDisplayName=='true')
-						<th>$encoder.htmlEncode($identifierType.displayName)</th>
-						#foreach( $identifierType in $identifierTypes)
+					<th>$encoder.htmlEncode($identifierType.displayName)</th>
+					#foreach( $identifierType in $identifierTypes)
 						#set($id="")
-							#if($identifierType.personDisplayName=='true')
-								<th style="cursor:pointer;" onclick="javascript:isDashboard=true;showPatientDashboardForm( '$patient.uid' )">
-									#foreach( $identifier in $patient.identifiers)
-										#if($!identifier.identifierType.id==$identifierType.id)
-											#set($id=$identifier.identifier)
-										#end
-									#end 
-									$encoder.htmlEncode($id)
-								</th>
-							#end
-						#end
+						<th style="cursor:pointer;" onclick="javascript:isDashboard=true;showPatientDashboardForm( '$patient.uid' )">
+							#foreach( $identifier in $patient.identifiers)
+								#if($!identifier.identifierType.id==$identifierType.id)
+									#set($id=$identifier.identifier)
+								#end
+							#end 
+							$encoder.htmlEncode($id)
+						</th>
 					#end
 				</tr>
 			#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm	2014-01-07 15:02:45 +0000
@@ -22,15 +22,15 @@
 	<thead>
 		<tr>
 			<th>$i18n.getString('risk')</th>
-			#foreach( $identifierType in $identifierTypes)
-				#if($identifierType.personDisplayName=='true')
-					<th>$encoder.htmlEncode($identifierType.displayName)</th>
+			#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
+				#if($programIdentifierType.displayedInList=='true')
+					<th>$encoder.htmlEncode($programIdentifierType.patientIdentifierType.displayName)</th>
 				#end
 			#end
-			
-			#foreach( $attribute in $attributes )
-				#if($attribute.displayedInList=='true')
-					<th id="patientAttributeName">$encoder.htmlEncode($attribute.displayName)</th>
+
+			#foreach( $programAttribute in $program.programPatientAttributes )
+				#if($programAttribute.displayedInList=='true')
+					<th id="patientAttributeName">$encoder.htmlEncode($programAttribute.patientAttribute.displayName)</th>
 				#end
 			#end
 			<th>$i18n.getString( "events" )</th>
@@ -56,12 +56,12 @@
 				#end
 			</td>
 			
-			#foreach( $identifierType in $identifierTypes)
+			#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
 				#set($id="")
-				#if($identifierType.personDisplayName=='true')
+				#if($programIdentifierType.displayedInList=='true')
 					<td name='infor_$patient.id' class='$class'><a href="javascript:isDashboard=false;showPatientDashboardForm( '$patient.id' )">
 						#foreach( $identifier in $patient.identifiers)
-							#if($!identifier.identifierType.id==$identifierType.id)
+							#if($!identifier.identifierType.id==$programIdentifierType.patientIdentifierType.id)
 								$identifier.identifier
 							#end
 						#end 
@@ -70,13 +70,13 @@
 				#end
 			#end
 			
-			#foreach( $attribute in $attributes )
-				#if($attribute.displayedInList=='true')
+			#foreach( $programAttribute in $program.programPatientAttributes )
+				#if($programAttribute.displayedInList=='true')
 					<td name='infor_$patient.id' class='$class'><a href="javascript:isDashboard=false;showPatientDashboardForm( '$patient.uid' )">
 						#foreach( $attributeValue in $patient.attributeValues)
-							#if($!attributeValue.patientAttribute.id==$attribute.id)
+							#if($!attributeValue.patientAttribute.id==$programAttribute.patientAttribute.id)
 								#set($value=$attributeValue.value)
-								#if( $attribute.valueType == 'bool')
+								#if( $programAttribute.patientAttribute.valueType == 'bool')
 									#set($value=$i18n.getString($attributeValue.value))
 								#end
 							#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/records.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/records.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/records.vm	2014-01-07 15:02:45 +0000
@@ -1,24 +1,20 @@
 <table>
 	#foreach( $identifier in $patient.identifiers)
-		#if($!identifier.identifierType.personDisplayName=='true')
-			<tr>
-				<td>$!identifier.identifierType.displayName:</td>
-				<td>$!identifier.identifier</td>
-			</tr>
-		#end
+		<tr>
+			<td>$!identifier.identifierType.displayName:</td>
+			<td>$!identifier.identifier</td>
+		</tr>
 	#end 
 	
 	#foreach( $attributeValue in $patient.attributeValues)
-		#if($!attributeValue.patientAttribute.displayedInList=='true')
-			#set($value=$attributeValue.value)
-			#if( $attribute.valueType == 'bool')
-				#set($value=$i18n.getString($attributeValue.value))
-			#end
-			<tr>
-				<td>$!attributeValue.patientAttribute.displayName:</td>
-				<td>$!attributeValue.value</td>
-			</tr>
+		#set($value=$attributeValue.value)
+		#if( $attribute.valueType == 'bool')
+			#set($value=$i18n.getString($attributeValue.value))
 		#end
+		<tr>
+			<td>$!attributeValue.patientAttribute.displayName:</td>
+			<td>$!attributeValue.value</td>
+		</tr>
 	#end  
 </table>
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm	2014-01-07 15:02:45 +0000
@@ -14,25 +14,21 @@
 		<td>
 			<table>
 				#foreach( $identifier in $patient.identifiers)
-					#if($!identifier.identifierType.personDisplayName=='true')
-						<tr>
-							<td>$!identifier.identifierType.displayName:</td>
-							<td>$!identifier.identifier</td>
-						</tr>
-					#end
+					<tr>
+						<td>$!identifier.identifierType.displayName:</td>
+						<td>$!identifier.identifier</td>
+					</tr>
 				#end 
 				
 				#foreach( $attributeValue in $patient.attributeValues)
-					#if($!attributeValue.patientAttribute.displayedInList=='true')
-						#set($value=$attributeValue.value)
-						#if( $attribute.valueType == 'bool')
-							#set($value=$i18n.getString($attributeValue.value))
-						#end
-						<tr>
-							<td>$!attributeValue.patientAttribute.displayName:</td>
-							<td>$!attributeValue.value</td>
-						</tr>
+					#set($value=$attributeValue.value)
+					#if( $attribute.valueType == 'bool')
+						#set($value=$i18n.getString($attributeValue.value))
 					#end
+					<tr>
+						<td>$!attributeValue.patientAttribute.displayName:</td>
+						<td>$!attributeValue.value</td>
+					</tr>
 				#end 
 			</table>
 		</td>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipPatients.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipPatients.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipPatients.vm	2014-01-07 15:02:45 +0000
@@ -37,12 +37,10 @@
 			<td style="cursor:pointer;" onclick="javascript:isDashboard=true;showPatientDashboardForm( '$patient.uid' )">
 				<a>
 				#foreach( $identifier in $patient.identifiers)
-					#if($!identifier.identifierType.personDisplayName=='true')
-						<tr>
-							<td>$!identifier.identifierType.displayName:</td>
-							<td>$!identifier.identifier</td>
-						</tr>
-					#end
+					<tr>
+						<td>$!identifier.identifierType.displayName:</td>
+						<td>$!identifier.identifier</td>
+					</tr>
 				#end 
 				</a>
 			</td>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm	2014-01-07 15:02:45 +0000
@@ -24,16 +24,13 @@
                 <tr #alternate( $mark )>                
 					<td>
 						#set( $value="")
-						#if($program.patientIdentifierTypes)
-							#foreach( $identifierType in $program.patientIdentifierTypes )
-								#foreach( $pIdentifier in $programInstance.patient.identifiers )
-									#if($identifierType.personDisplayName=="true" && $identifierType.id==$pIdentifier.identifierType.id)
-										#set( $value= $value + $pIdentifier.identifier + '&#13;&#10;' )
-									#end
+						#foreach( $programIdentifierType in $program.programPatientIdentifierTypes)
+							#foreach( $identifier in $patient.identifiers)
+								#if($!identifier.identifierType.id==$programIdentifierType.patientIdentifierType.id)
+									#set( $value= $value + $pIdentifier.identifier + '&#13;&#10;' )
 								#end
-							#end
+							#end 
 						#end
-							
 						<input type='button' class='patient-object' value="$value"
 							onclick='javascript:showPatientHistory( $programInstance.patient.id )' title='$i18n.getString( "patient_details_and_history" )'>
 					</td>	

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm	2014-01-07 15:02:45 +0000
@@ -1,9 +1,7 @@
 <div id='reportTitle' name='reportTitle' style="display:none;">
 	#set($id = '')
 	#foreach( $identifier in $patient.identifiers)
-		#if($!identifier.identifierType.personDisplayName=='true')
-			#set($id=$!identifier.identifier)
-		#end
+		#set($id=$!identifier.identifier)
 	#end 
 				
 	<h3>$i18n.getString('records_of') $!encoder.htmlEncode( $id )  $i18n.getString('at') $programStage.displayName $i18n.getString('in') $organisationUnit.name $i18n.getString('on_value') $format.formatDate($programStageInstance.executionDate)</h3>

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/GetProgramEnrollmentFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/GetProgramEnrollmentFormAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/GetProgramEnrollmentFormAction.java	2014-01-07 15:02:45 +0000
@@ -38,6 +38,7 @@
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -67,6 +68,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------
@@ -170,7 +174,7 @@
         }
 
         patientAttributes = programPatientAttributeService.getListPatientAttribute( program );
-        patientIdentifierTypes = program.getPatientIdentifierTypes();
+        patientIdentifierTypes = programPatientIdentifierTypeService.getListPatientIdentifierType( program );
         now = new SimpleDateFormat( "yyyy-MM-dd" ).format( new Date() );
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java	2014-01-07 15:02:45 +0000
@@ -57,6 +57,7 @@
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstance;
@@ -110,6 +111,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     private FormUtils formUtils;
 
     public FormUtils getFormUtils()
@@ -309,7 +313,7 @@
         patient = patientService.getPatient( patientId );
         program = programService.getProgram( programId );
         patientAttributes = programPatientAttributeService.getListPatientAttribute( program );
-        patientIdentifierTypes = program.getPatientIdentifierTypes();
+        patientIdentifierTypes = programPatientIdentifierTypeService.getListPatientIdentifierType( program );
 
         List<PatientAttributeValue> patientAttributeValues = new ArrayList<PatientAttributeValue>();
 

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java	2014-01-07 15:02:45 +0000
@@ -36,6 +36,7 @@
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -90,6 +91,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------
@@ -186,7 +190,8 @@
 
         for ( Program program : programs )
         {
-            patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
+            patientIdentifierTypes.removeAll( programPatientIdentifierTypeService
+                .getListPatientIdentifierType( program ) );
             patientAttributes.removeAll( programPatientAttributeService.getListPatientAttribute( program ) );
         }
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java	2014-01-07 15:02:45 +0000
@@ -53,6 +53,7 @@
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.system.util.MathUtils;
 import org.hisp.dhis.util.ContextUtils;
@@ -155,6 +156,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------
@@ -344,7 +348,7 @@
 
         for ( Program program : programs )
         {
-            patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
+            patientIdentifierTypes.removeAll(programPatientIdentifierTypeService.getListPatientIdentifierType( program ) );
             patientAttributes.removeAll( programPatientAttributeService.getListPatientAttribute( program ) );
         }
 
@@ -369,7 +373,7 @@
 
         for ( Program program : programs )
         {
-            patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
+            patientIdentifierTypes.removeAll(programPatientIdentifierTypeService.getListPatientIdentifierType( program ) );
             patientAttributes.removeAll( programPatientAttributeService.getListPatientAttribute( program ) );
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java	2014-01-07 15:02:45 +0000
@@ -41,6 +41,7 @@
 import org.hisp.dhis.patient.PatientRegistrationFormService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.user.UserSettingService;
@@ -105,6 +106,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Getters & Setters
     // -------------------------------------------------------------------------
@@ -177,15 +181,15 @@
             attributes = patientAttributeService.getAllPatientAttributes();
             for ( Program p : programs )
             {
-                identifierTypes.remove( p.getPatientIdentifierTypes() );
-                attributes.remove(programPatientAttributeService.getListPatientAttribute( p ) );
+                identifierTypes.remove( programPatientIdentifierTypeService.getListPatientIdentifierType( p ) );
+                attributes.remove( programPatientAttributeService.getListPatientAttribute( p ) );
             }
         }
         else
         {
             program = programService.getProgram( programId );
-            identifierTypes = program.getPatientIdentifierTypes();
-            attributes.remove(programPatientAttributeService.getListPatientAttribute( program ) );
+            identifierTypes = programPatientIdentifierTypeService.getListPatientIdentifierType( program );
+            attributes = programPatientAttributeService.getListPatientAttribute( program );
             registrationForm = patientRegistrationFormService.getPatientRegistrationForm( program );
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/GetPatientReminderAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/GetPatientReminderAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/GetPatientReminderAction.java	2014-01-07 15:02:45 +0000
@@ -31,10 +31,12 @@
 import java.util.List;
 
 import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientReminder;
 import org.hisp.dhis.patient.PatientReminderService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupService;
@@ -78,6 +80,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -124,6 +129,13 @@
         return attributes;
     }
 
+    public List<PatientIdentifierType> identifierTypes;
+
+    public List<PatientIdentifierType> getIdentifierTypes()
+    {
+        return identifierTypes;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -137,9 +149,12 @@
         program = programService.getProgram( programId );
 
         userGroups = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
-        
+
         attributes = new ArrayList<PatientAttribute>( programPatientAttributeService.getListPatientAttribute( program ) );
 
+        identifierTypes = new ArrayList<PatientIdentifierType>(
+            programPatientIdentifierTypeService.getListPatientIdentifierType( program ) );
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/ShowAddProgramPatientReminderAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/ShowAddProgramPatientReminderAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/ShowAddProgramPatientReminderAction.java	2014-01-07 15:02:45 +0000
@@ -31,8 +31,10 @@
 import java.util.List;
 
 import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupService;
@@ -65,6 +67,8 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
 
     // -------------------------------------------------------------------------
     // Input/Output
@@ -98,6 +102,13 @@
         return attributes;
     }
 
+    public List<PatientIdentifierType> identifierTypes;
+
+    public List<PatientIdentifierType> getIdentifierTypes()
+    {
+        return identifierTypes;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -111,7 +122,9 @@
 
         attributes = new ArrayList<PatientAttribute>( programPatientAttributeService.getListPatientAttribute( program ) );
 
+        identifierTypes = new ArrayList<PatientIdentifierType>(
+            programPatientIdentifierTypeService.getListPatientIdentifierType( program ) );
+        
         return SUCCESS;
     }
-
 }

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java	2014-01-07 15:02:45 +0000
@@ -42,11 +42,14 @@
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramPatientAttribute;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierType;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageService;
 import org.hisp.dhis.relationship.RelationshipType;
 import org.hisp.dhis.relationship.RelationshipTypeService;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -114,6 +117,9 @@
         this.programPatientAttributeService = programPatientAttributeService;
     }
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -309,10 +315,9 @@
             {
                 PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer
                     .parseInt( ids[1] ) );
-                identifierType.setPersonDisplayName( personDisplayNames.get( index ) );
-                patientIdentifierTypeService.updatePatientIdentifierType( identifierType );
-
-                identifierTypes.add( identifierType );
+                ProgramPatientIdentifierType programPatientIdentifierType = new ProgramPatientIdentifierType( program,
+                    identifierType, personDisplayNames.get( index ) );
+                programPatientIdentifierTypeService.addProgramPatientIdentifierType( programPatientIdentifierType );
             }
             else if ( ids[0].equals( Patient.PREFIX_PATIENT_ATTRIBUTE ) )
             {
@@ -327,9 +332,6 @@
             index++;
         }
 
-        program.setPatientIdentifierTypes( identifierTypes );
-        // program.setPatientAttributes( patientAttributes );
-
         programService.updateProgram( 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/ShowUpdateProgramFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java	2014-01-07 15:02:45 +0000
@@ -43,6 +43,7 @@
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.relationship.RelationshipType;
 import org.hisp.dhis.relationship.RelationshipTypeService;
@@ -101,6 +102,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -207,7 +211,8 @@
         program = programService.getProgram( id );
 
         availableIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
-        availableIdentifierTypes.removeAll( new HashSet<PatientIdentifierType>( program.getPatientIdentifierTypes() ) );
+        availableIdentifierTypes.removeAll( new HashSet<PatientIdentifierType>( programPatientIdentifierTypeService
+            .getListPatientIdentifierType( program ) ) );
 
         availableAttributes = patientAttributeService.getAllPatientAttributes();
         availableAttributes.removeAll( new HashSet<PatientAttribute>( programPatientAttributeService

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java	2014-01-07 15:02:45 +0000
@@ -39,9 +39,12 @@
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramPatientAttribute;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.program.ProgramPatientIdentifierType;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.relationship.RelationshipType;
 import org.hisp.dhis.relationship.RelationshipTypeService;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -91,6 +94,9 @@
         this.programPatientAttributeService = programPatientAttributeService;
     }
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -334,10 +340,21 @@
                 PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer
                     .parseInt( ids[1] ) );
 
-                identifierType.setPersonDisplayName( personDisplayNames.get( index ) );
-                patientIdentifierTypeService.updatePatientIdentifierType( identifierType );
+                ProgramPatientIdentifierType programPatientIdentifierType = programPatientIdentifierTypeService.get(
+                    program, identifierType );
 
-                identifierTypes.add( identifierType );
+                if ( programPatientIdentifierType == null )
+                {
+                    programPatientIdentifierType = new ProgramPatientIdentifierType( program, identifierType,
+                        personDisplayNames.get( index ) );
+                    programPatientIdentifierTypeService.addProgramPatientIdentifierType( programPatientIdentifierType );
+                }
+                else
+                {
+                    programPatientIdentifierType.setDisplayedInList( personDisplayNames.get( index ) );
+                    programPatientIdentifierTypeService
+                        .updateProgramPatientIdentifierType( programPatientIdentifierType );
+                }
             }
             else if ( ids[0].equals( Patient.PREFIX_PATIENT_ATTRIBUTE ) )
             {
@@ -346,7 +363,7 @@
 
                 ProgramPatientAttribute programPatientAttribute = programPatientAttributeService.get( program,
                     patientAttribute );
-                
+
                 if ( programPatientAttribute == null )
                 {
                     programPatientAttribute = new ProgramPatientAttribute( program, patientAttribute,
@@ -362,8 +379,6 @@
             index++;
         }
 
-        program.setPatientIdentifierTypes( identifierTypes );
-
         if ( relatedProgramId != null )
         {
             Program relatedProgram = programService.getProgram( relatedProgramId );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetValidationCriteriaAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetValidationCriteriaAction.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetValidationCriteriaAction.java	2014-01-07 15:02:45 +0000
@@ -35,7 +35,9 @@
 import org.hisp.dhis.program.ProgramPatientAttributeService;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.validation.ValidationCriteria;
 import org.hisp.dhis.validation.ValidationCriteriaService;
@@ -71,6 +73,9 @@
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -81,6 +86,8 @@
 
     private List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
 
+    private List<PatientIdentifierType> patientIdentifierTypes = new ArrayList<PatientIdentifierType>();
+
     private ValidationCriteria validationCriteria;
 
     private Program program;
@@ -94,6 +101,11 @@
         this.id = id;
     }
 
+    public List<PatientIdentifierType> getPatientIdentifierTypes()
+    {
+        return patientIdentifierTypes;
+    }
+
     public void setProgramId( int programId )
     {
         this.programId = programId;
@@ -129,6 +141,9 @@
         patientAttributes = new ArrayList<PatientAttribute>(
             programPatientAttributeService.getListPatientAttribute( program ) );
 
+        patientIdentifierTypes = new ArrayList<PatientIdentifierType>(
+            programPatientIdentifierTypeService.getListPatientIdentifierType( program ) );
+
         Collections.sort( patientAttributes, IdentifiableObjectNameComparator.INSTANCE );
 
         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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2014-01-07 15:02:45 +0000
@@ -252,6 +252,8 @@
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
 		<property name="relationshipTypeService"
 			ref="org.hisp.dhis.relationship.RelationshipTypeService" />
+		<property name="programPatientAttributeService"
+			ref="org.hisp.dhis.program.ProgramPatientAttributeService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.patient.action.program.ValidateProgramAction"

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2014-01-07 15:02:45 +0000
@@ -492,4 +492,4 @@
 data_entry_method_for_option_sets=Data entry method for option sets
 users = Users
 attribute_users = Attribute users
-view_template_reminder_message = view template reminder message 
\ No newline at end of file
+view_template_reminder_message = View template reminder message 
\ 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/addProgramPatientReminder.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramPatientReminder.vm	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramPatientReminder.vm	2014-01-07 15:02:45 +0000
@@ -107,7 +107,7 @@
 					<option value="{enrollement-date}">$i18n.getString("enrollement_date")</option>
 					<option value="{days-since-enrollement-date}">$i18n.getString("days_since_enrollment_date")</option>
 					<option value="{orgunit-name}">$i18n.getString("orgunit_name")</option>
-					#foreach($identifierType in $program.patientIdentifierTypes)
+					#foreach($identifierType in $identifierTypes)
 						<option value={identifierid=$identifierType.uid}>$identifierType.displayName</option>
 					#end
 					#foreach($attribute in $attributes)

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm	2014-01-07 15:02:45 +0000
@@ -277,7 +277,8 @@
 	#end
 	
 	var idenAttrOptions = "";
-	#foreach($identifierType in $program.patientIdentifierTypes)
+	#foreach($programPatientIdentifierType in $program.programPatientIdentifierTypes)
+		#set($identifierType = $programPatientIdentifierType.patientIdentifierType)
 		idenAttrOptions+="<option value={identifierid=$identifierType.uid}>$identifierType.displayName</option>";
 	#end
 	#foreach($programPatientAttribute in $program.programPatientAttributes)

=== 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	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm	2014-01-07 15:02:45 +0000
@@ -261,7 +261,8 @@
                             </tr>
 						</thead>
 						<tbody id="selectedList" #if($program.type==3) style="display:none;" #end>
-							#foreach( $identifier in $program.patientIdentifierTypes )
+							#foreach( $programIdentifier in $program.programPatientIdentifierTypes )
+								#set($identifier = $programIdentifier.patientIdentifierType)
 								<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 #if($program.type==3) disabled #end /></td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramPatientReminder.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramPatientReminder.vm	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramPatientReminder.vm	2014-01-07 15:02:45 +0000
@@ -150,7 +150,7 @@
 					<option value="{enrollement-date}">$i18n.getString("enrollement_date")</option>
 					<option value="{days-since-enrollement-date}">$i18n.getString("days_since_enrollment_date")</option>
 					<option value="{orgunit-name}">$i18n.getString("orgunit_name")</option>
-					#foreach($identifierType in $program.patientIdentifierTypes)
+					#foreach($identifierType in $identifierTypes)
 						<option value={identifierid=$identifierType.uid}>$identifierType.displayName</option>
 					#end
 					#foreach($attribute in $attributes)

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm	2014-01-07 15:02:45 +0000
@@ -321,7 +321,8 @@
 							<option value="{due-date}">$i18n.getString("due_date")</option>
 							<option value="{days-since-due-date}">$i18n.getString("days_since_due_date")</option>
 							<option value="{orgunit-name}">$i18n.getString("orgunit_name")</option>
-							#foreach($identifierType in $program.patientIdentifierTypes)
+							#foreach($programPatientIdentifierType in $program.programPatientIdentifierTypes)
+								#set($identifierType = $programPatientIdentifierType.patientIdentifierType)
 								<option value={identifierid=$identifierType.uid}>$identifierType.displayName</option>
 							#end
 							#foreach($programPatientAttribute in $program.programPatientAttributes)
@@ -394,7 +395,8 @@
 	var i18n_both = '$encoder.jsEscape( $i18n.getString( "both" ) , "'")';
 	
 	var idenAttrOptions = "";
-	#foreach($identifierType in $programStage.program.patientIdentifierTypes)
+	#foreach($programPatientIdentifierType in $programStage.program.programPatientIdentifierTypes)
+		#set($identifierType = $programPatientIdentifierType.patientIdentifierType)
 		idenAttrOptions+="<option value={identifierid=$identifierType.uid}>$identifierType.displayName</option>";
 	#end
 	#foreach($programPatientAttribute in $programStage.program.programPatientAttributes)

=== modified file 'dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/SearchPatientAction.java	2013-10-14 16:17:44 +0000
+++ dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/SearchPatientAction.java	2014-01-07 15:02:45 +0000
@@ -36,6 +36,7 @@
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramService;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -62,6 +63,9 @@
     @Autowired
     private ProgramService programService;
 
+    @Autowired
+    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
+
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -135,7 +139,7 @@
     {
         OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
         Collection<OrganisationUnit> orgunits = new HashSet<OrganisationUnit>();
-        
+
         // List all patients
         if ( listAll )
         {
@@ -150,15 +154,15 @@
         else if ( searchTexts.size() > 0 )
         {
             organisationUnit = (searchBySelectedOrgunit) ? organisationUnit : null;
-            if( organisationUnit != null )
+            if ( organisationUnit != null )
             {
                 orgunits.add( organisationUnit );
             }
 
             total = patientService.countSearchPatients( searchTexts, orgunits, null, ProgramInstance.STATUS_ACTIVE );
             this.paging = createPaging( total );
-            patients = patientService.searchPatients( searchTexts, orgunits, null, null, null, ProgramInstance.STATUS_ACTIVE, paging.getStartPos(), paging
-                .getPageSize() );
+            patients = patientService.searchPatients( searchTexts, orgunits, null, null, null,
+                ProgramInstance.STATUS_ACTIVE, paging.getStartPos(), paging.getPageSize() );
 
             if ( !searchBySelectedOrgunit )
             {
@@ -173,7 +177,8 @@
                 for ( Integer programId : programIds )
                 {
                     Program program = programService.getProgram( programId );
-                    identifierTypes.addAll( program.getPatientIdentifierTypes() );
+                    identifierTypes
+                        .addAll( programPatientIdentifierTypeService.getListPatientIdentifierType( program ) );
                 }
             }
         }