← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13676: Tracker, refactored the ProgramPatientAttribute stuff. Removed the stores/services and using hibe...

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 13676 [merge]
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-01-09 16:34:25 +0100
message:
  Tracker, refactored the ProgramPatientAttribute stuff. Removed the stores/services and using hibernate cascade instead. Removed Program from the ProgramPatientAttribute class and from primary key, as that solution made it impossible to delete and was not necessary.
removed:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttributeService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttributeStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierTypeService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierTypeStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramPatientAttributeService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramPatientIdentiferTypeService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramAttributeDeletionHandler.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramIdentifierTypeDeletionHandler.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramPatientAttributeStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramPatientIdentifierTypeStore.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttribute.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierType.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/DefaultPatientService.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/DefaultProgramValidationService.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/program/hibernate/Program.hbm.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientAttribute.hbm.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientIdentifierType.hbm.xml
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonAttributeTypeController.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ShowPatientAttributeInListNoProgramAction.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/patientreminder/ValidateProgramPatientReminderAction.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


--
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/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2014-01-07 16:28:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2014-01-09 15:34:25 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
@@ -42,6 +43,8 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientReminder;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.relationship.RelationshipType;
@@ -176,6 +179,30 @@
 
         return elements;
     }
+    
+    public List<PatientIdentifierType> getIdentifierTypes()
+    {
+        List<PatientIdentifierType> types = new ArrayList<PatientIdentifierType>();
+        
+        for ( ProgramPatientIdentifierType type : programPatientIdentifierTypes )
+        {
+            types.add( type.getPatientIdentifierType() );
+        }
+        
+        return types;
+    }
+    
+    public List<PatientAttribute> getAttributes()
+    {
+        List<PatientAttribute> attributes = new ArrayList<PatientAttribute>();
+        
+        for ( ProgramPatientAttribute attribute : programPatientAttributes )
+        {
+            attributes.add( attribute.getPatientAttribute() );
+        }
+        
+        return attributes;
+    }
 
     public ProgramStage getProgramStageByStage( int stage )
     {

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttribute.java	2014-01-07 16:28:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttribute.java	2014-01-09 12:49:36 +0000
@@ -41,13 +41,14 @@
 {
     private static final long serialVersionUID = -2420475559273198337L;
 
-    private Program program;
-
+    private int id;
+    
     private PatientAttribute patientAttribute;
+    
+    private Integer sortOrder;
 
     private boolean displayedInList;
 
-    private Integer sortOrder;
 
     // -------------------------------------------------------------------------
     // Constructors
@@ -57,12 +58,11 @@
     {
     }
 
-    public ProgramPatientAttribute( Program program, PatientAttribute patientAttribute, boolean displayedInList, int sortOrder )
+    public ProgramPatientAttribute( PatientAttribute patientAttribute, int sortOrder, boolean displayedInList )
     {
-        this.program = program;
         this.patientAttribute = patientAttribute;
+        this.sortOrder = sortOrder;
         this.displayedInList = displayedInList;
-        this.sortOrder = sortOrder;
     }
 
     // -------------------------------------------------------------------------
@@ -75,8 +75,8 @@
         final int prime = 31;
         int result = 1;
 
-        result = result * prime + program.hashCode();
         result = result * prime + patientAttribute.hashCode();
+        result = result * prime + sortOrder;
 
         return result;
     }
@@ -96,22 +96,21 @@
 
         final ProgramPatientAttribute other = (ProgramPatientAttribute) object;
 
-        return program.getId() == other.getProgram().getId()
-            && patientAttribute.getId() == other.getPatientAttribute().getId();
+        return patientAttribute.equals( other.getPatientAttribute() ) && sortOrder == other.getSortOrder();
     }
 
     // -------------------------------------------------------------------------
     // Getters && Setters
     // -------------------------------------------------------------------------
 
-    public Program getProgram()
+    public int getId()
     {
-        return program;
+        return id;
     }
 
-    public void setProgram( Program program )
+    public void setId( int id )
     {
-        this.program = program;
+        this.id = id;
     }
 
     public PatientAttribute getPatientAttribute()
@@ -124,6 +123,16 @@
         this.patientAttribute = patientAttribute;
     }
 
+    public Integer getSortOrder()
+    {
+        return sortOrder;
+    }
+
+    public void setSortOrder( Integer sortOrder )
+    {
+        this.sortOrder = sortOrder;
+    }
+    
     public Boolean getDisplayedInList()
     {
         return displayedInList;
@@ -133,15 +142,4 @@
     {
         this.displayedInList = displayedInList;
     }
-
-    public Integer getSortOrder()
-    {
-        return sortOrder;
-    }
-
-    public void setSortOrder( Integer sortOrder )
-    {
-        this.sortOrder = sortOrder;
-    }
-
 }

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttributeService.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttributeService.java	1970-01-01 00:00:00 +0000
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.program;
-
-import java.util.Collection;
-
-import org.hisp.dhis.patient.PatientAttribute;
-
-/**
- * @author Chau Thu Tran
- *
- * @version $ ProgramPatientAttributeService.java Jan 7, 2014 9:33:20 AM $
- */
-public interface ProgramPatientAttributeService
-{
-    String ID = ProgramPatientAttributeService.class.getName();
-
-    /**
-     * Adds an {@link ProgramPatientAttribute}
-     * 
-     * @param programPatientAttribute The to ProgramPatientAttribute add.
-     * 
-     * @return A generated unique id of the added
-     *         {@link ProgramPatientAttribute}.
-     */
-    void addProgramPatientAttribute( ProgramPatientAttribute programPatientAttribute );
-
-    /**
-     * Updates an {@link ProgramPatientAttribute}.
-     * 
-     * @param programPatientAttribute the ProgramPatientAttribute to update.
-     */
-    void updateProgramPatientAttribute( ProgramPatientAttribute programPatientAttribute );
-
-    /**
-     * Deletes a {@link ProgramPatientAttribute}.
-     * 
-     * @param programPatientAttribute the ProgramPatientAttribute to delete.
-     */
-    void deleteProgramPatientAttribute( ProgramPatientAttribute programPatientAttribute );
-
-    /**
-     * Retrieve ProgramPatientAttribute list on a program  and a data
-     * element
-     * 
-     * @param program Program
-     * @param patientAttribute PatientAttribute
-     * 
-     * @return ProgramPatientAttribute
-     */
-    ProgramPatientAttribute get( Program program, PatientAttribute patientAttribute );
-
-    /**
-     * Returns all {@link ProgramPatientAttribute}
-     * 
-     * @return a collection of all ProgramPatientAttribute, or an empty
-     *         collection if there are no ProgramPatientAttributes.
-     */
-    Collection<ProgramPatientAttribute> getAllProgramPatientAttributes();
-
-    /**
-     * Retrieve ProgramPatientAttribute list on a program
-     * 
-     * @param program Program
-     * 
-     * @return ProgramPatientAttribute list
-     */
-    Collection<ProgramPatientAttribute> get( Program program );
-
-    /**
-     * Retrieve PatientAttribute list on a program
-     * 
-     * @param program Program
-     * 
-     * @return ProgramPatientAttribute list
-     */
-    Collection<PatientAttribute> getListPatientAttribute( Program program );
-    
-
-    /**
-     * Retrieve PatientAttribute list on a program
-     * 
-     * @return ProgramPatientAttribute list
-     */
-    Collection<PatientAttribute> getPatientAttributes();
-
-}
\ No newline at end of file

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttributeStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttributeStore.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientAttributeStore.java	1970-01-01 00:00:00 +0000
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.program;
-
-import java.util.Collection;
-
-import org.hisp.dhis.patient.PatientAttribute;
-
-/**
- * @author Chau Thu Tran
- * 
- * @version $ ProgramPatientAttributeStore.java Jan 7, 2014 9:40:31 AM $
- */
-public interface ProgramPatientAttributeStore
-{
-    String ID = ProgramPatientAttributeStore.class.getName();
-
-    /**
-     * Adds an {@link ProgramPatientAttribute}
-     * 
-     * @param programPatientAttribute The to ProgramPatientAttribute add.
-     * 
-     * @return A generated unique id of the added
-     *         {@link ProgramPatientAttribute}.
-     */
-    void save( ProgramPatientAttribute programPatientAttribute );
-
-    /**
-     * Updates an {@link ProgramPatientAttribute}.
-     * 
-     * @param programPatientAttribute the ProgramPatientAttribute to update.
-     */
-    void update( ProgramPatientAttribute programPatientAttribute );
-
-    /**
-     * Deletes a {@link ProgramPatientAttribute}.
-     * 
-     * @param programPatientAttribute the ProgramPatientAttribute to delete.
-     */
-    void delete( ProgramPatientAttribute programPatientAttribute );
-
-    /**
-     * Retrieve ProgramPatientAttribute list on a program and a data element
-     * 
-     * @param program Program
-     * @param patientAttribute PatientAttribute
-     * 
-     * @return ProgramPatientAttribute
-     */
-    ProgramPatientAttribute get( Program program, PatientAttribute patientAttribute );
-
-    /**
-     * Returns all {@link ProgramPatientAttribute}
-     * 
-     * @return a collection of all ProgramPatientAttribute, or an empty
-     *         collection if there are no ProgramPatientAttributes.
-     */
-    Collection<ProgramPatientAttribute> getAll();
-
-    /**
-     * Retrieve ProgramPatientAttribute list on a program
-     * 
-     * @param program Program
-     * 
-     * @return ProgramPatientAttribute list
-     */
-    Collection<ProgramPatientAttribute> get( Program program );
-
-    /**
-     * Retrieve PatientAttribute list on a program
-     * 
-     * @param program Program
-     * 
-     * @return PatientAttribute list
-     */
-    Collection<PatientAttribute> getListPatientAttribute( Program program );
-
-    /**
-     * Retrieve PatientAttribute list on a program
-     * 
-     * @param program Program
-     * 
-     * @return PatientAttribute list
-     */
-    Collection<PatientAttribute> getPatientAttributes();
-}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierType.java	2014-01-07 16:28:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierType.java	2014-01-09 12:49:36 +0000
@@ -41,14 +41,14 @@
 {
     private static final long serialVersionUID = -2420475559273198337L;
 
-    private Program program;
-
+    private int id;
+    
     private PatientIdentifierType patientIdentifierType;
 
+    private Integer sortOrder;
+
     private boolean displayedInList;
 
-    private Integer sortOrder;
-
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -57,13 +57,11 @@
     {
     }
 
-    public ProgramPatientIdentifierType( Program program, PatientIdentifierType patientIdentifierType,
-        boolean displayedInList, int sortOrder )
+    public ProgramPatientIdentifierType( PatientIdentifierType patientIdentifierType, int sortOrder, boolean displayedInList )
     {
-        this.program = program;
         this.patientIdentifierType = patientIdentifierType;
+        this.sortOrder = sortOrder;
         this.displayedInList = displayedInList;
-        this.sortOrder = sortOrder;
     }
 
     // -------------------------------------------------------------------------
@@ -76,8 +74,8 @@
         final int prime = 31;
         int result = 1;
 
-        result = result * prime + program.hashCode();
         result = result * prime + patientIdentifierType.hashCode();
+        result = result * prime + sortOrder;
 
         return result;
     }
@@ -97,22 +95,21 @@
 
         final ProgramPatientIdentifierType other = (ProgramPatientIdentifierType) object;
 
-        return program.getId() == other.getProgram().getId()
-            && patientIdentifierType.getId() == other.getPatientIdentifierType().getId();
+        return patientIdentifierType.equals( other.getPatientIdentifierType() ) && sortOrder == other.getSortOrder();
     }
 
     // -------------------------------------------------------------------------
     // Getters && Setters
     // -------------------------------------------------------------------------
 
-    public Program getProgram()
+    public int getId()
     {
-        return program;
+        return id;
     }
 
-    public void setProgram( Program program )
+    public void setId( int id )
     {
-        this.program = program;
+        this.id = id;
     }
 
     public PatientIdentifierType getPatientIdentifierType()
@@ -125,6 +122,16 @@
         this.patientIdentifierType = patientIdentifierType;
     }
 
+    public Integer getSortOrder()
+    {
+        return sortOrder;
+    }
+
+    public void setSortOrder( Integer sortOrder )
+    {
+        this.sortOrder = sortOrder;
+    }
+
     public Boolean getDisplayedInList()
     {
         return displayedInList;
@@ -134,15 +141,4 @@
     {
         this.displayedInList = displayedInList;
     }
-
-    public Integer getSortOrder()
-    {
-        return sortOrder;
-    }
-
-    public void setSortOrder( Integer sortOrder )
-    {
-        this.sortOrder = sortOrder;
-    }
-
-}
\ No newline at end of file
+}

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierTypeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierTypeService.java	2014-01-07 15:14:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierTypeService.java	1970-01-01 00:00:00 +0000
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.program;
-
-import java.util.Collection;
-
-import org.hisp.dhis.patient.PatientIdentifierType;
-
-/**
- * @author Chau Thu Tran
- *
- * @version $ ProgramPatientIdentifierTypeService.java Jan 7, 2014 9:33:20 AM $
- */
-public interface ProgramPatientIdentifierTypeService
-{
-    String ID = ProgramPatientIdentifierTypeService.class.getName();
-
-    /**
-     * Adds an {@link ProgramPatientIdentifierType}
-     * 
-     * @param programPatientIdentifierType The to ProgramPatientIdentifierType add.
-     * 
-     * @return A generated unique id of the added
-     *         {@link ProgramPatientIdentifierType}.
-     */
-    void addProgramPatientIdentifierType( ProgramPatientIdentifierType programPatientIdentifierType );
-
-    /**
-     * Updates an {@link ProgramPatientIdentifierType}.
-     * 
-     * @param programPatientIdentifierType the ProgramPatientIdentifierType to update.
-     */
-    void updateProgramPatientIdentifierType( ProgramPatientIdentifierType programPatientIdentifierType );
-
-    /**
-     * Deletes a {@link ProgramPatientIdentifierType}.
-     * 
-     * @param programPatientIdentifierType the ProgramPatientIdentifierType to delete.
-     */
-    void deleteProgramPatientIdentifierType( ProgramPatientIdentifierType programPatientIdentifierType );
-
-    /**
-     * Retrieve ProgramPatientIdentifierType list on a program  and a data
-     * element
-     * 
-     * @param program Program
-     * @param patientIdentifierType PatientIdentifierType
-     * 
-     * @return ProgramPatientIdentifierType
-     */
-    ProgramPatientIdentifierType get( Program program, PatientIdentifierType patientIdentifierType );
-
-    /**
-     * Returns all {@link ProgramPatientIdentifierType}
-     * 
-     * @return a collection of all ProgramPatientIdentifierType, or an empty
-     *         collection if there are no ProgramPatientIdentifierTypes.
-     */
-    Collection<ProgramPatientIdentifierType> getAllProgramPatientIdentifierTypes();
-
-    /**
-     * Retrieve ProgramPatientIdentifierType list on a program
-     * 
-     * @param program Program
-     * 
-     * @return ProgramPatientIdentifierType list
-     */
-    Collection<ProgramPatientIdentifierType> get( Program program );
-
-    /**
-     * Retrieve PatientIdentifierType list on a program
-     * 
-     * @param program Program
-     * 
-     * @return ProgramPatientIdentifierType list
-     */
-    Collection<PatientIdentifierType> getListPatientIdentifierType( Program program );
-    
-
-    /**
-     * Retrieve PatientIdentifierType list on a program
-     * 
-     * @return ProgramPatientIdentifierType list
-     */
-    Collection<PatientIdentifierType> getPatientIdentifierTypes();
-
-}
\ No newline at end of file

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierTypeStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierTypeStore.java	2014-01-07 15:14:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientIdentifierTypeStore.java	1970-01-01 00:00:00 +0000
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.program;
-
-import java.util.Collection;
-
-import org.hisp.dhis.patient.PatientIdentifierType;
-
-/**
- * @author Chau Thu Tran
- *            
- * @version $ ProgramPatientIdentifierTypeStore.java Jan 7, 2014 9:40:31 AM $
- */
-public interface ProgramPatientIdentifierTypeStore
-{
-    String ID = ProgramPatientIdentifierTypeStore.class.getName();
-
-    /**
-     * Adds an {@link ProgramPatientIdentifierType}
-     * 
-     * @param programPatientIdentifierType The to ProgramPatientIdentifierType add.
-     * 
-     * @return A generated unique id of the added
-     *         {@link ProgramPatientIdentifierType}.
-     */
-    void save( ProgramPatientIdentifierType programPatientIdentifierType );
-
-    /**
-     * Updates an {@link ProgramPatientIdentifierType}.
-     * 
-     * @param programPatientIdentifierType the ProgramPatientIdentifierType to update.
-     */
-    void update( ProgramPatientIdentifierType programPatientIdentifierType );
-
-    /**
-     * Deletes a {@link ProgramPatientIdentifierType}.
-     * 
-     * @param programPatientIdentifierType the ProgramPatientIdentifierType to delete.
-     */
-    void delete( ProgramPatientIdentifierType programPatientIdentifierType );
-
-    /**
-     * Retrieve ProgramPatientIdentifierType list on a program and a data element
-     * 
-     * @param program Program
-     * @param patientIdentifierType PatientIdentifierType
-     * 
-     * @return ProgramPatientIdentifierType
-     */
-    ProgramPatientIdentifierType get( Program program, PatientIdentifierType patientIdentifierType );
-
-    /**
-     * Returns all {@link ProgramPatientIdentifierType}
-     * 
-     * @return a collection of all ProgramPatientIdentifierType, or an empty
-     *         collection if there are no ProgramPatientIdentifierTypes.
-     */
-    Collection<ProgramPatientIdentifierType> getAll();
-
-    /**
-     * Retrieve ProgramPatientIdentifierType list on a program
-     * 
-     * @param program Program
-     * 
-     * @return ProgramPatientIdentifierType list
-     */
-    Collection<ProgramPatientIdentifierType> get( Program program );
-
-    /**
-     * Retrieve PatientIdentifierType list on a program
-     * 
-     * @param program Program
-     * 
-     * @return PatientIdentifierType list
-     */
-    Collection<PatientIdentifierType> getListPatientIdentifierType( Program program );
-
-    /**
-     * Retrieve PatientIdentifierType list on a program
-     * 
-     * @param program Program
-     * 
-     * @return PatientIdentifierType list
-     */
-    Collection<PatientIdentifierType> getPatientIdentifierTypes();
-}

=== 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 15:02:45 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2014-01-09 15:34:25 +0000
@@ -38,7 +38,6 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -72,8 +71,6 @@
 import org.hisp.dhis.patient.PatientIdentifierType;
 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;
@@ -136,12 +133,6 @@
     @Autowired
     private AnalyticsService analyticsService;
 
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // EventAnalyticsService implementation
     // -------------------------------------------------------------------------
@@ -522,15 +513,14 @@
 
         PatientAttribute at = attributeService.getPatientAttribute( item );
 
-        Collection<PatientAttribute> attributes = programPatientAttributeService.getListPatientAttribute( program );
-        if ( at != null && attributes.contains( at ) )
+        if ( at != null && program.getAttributes().contains( at ) )
         {
             return new QueryItem( at, operator, filter, at.isNumericType() );
         }
 
         PatientIdentifierType it = identifierTypeService.getPatientIdentifierType( item );
 
-        if ( it != null && programPatientIdentifierTypeService.getListPatientIdentifierType( program ).contains( it ) )
+        if ( it != null && program.getIdentifierTypes().contains( it ) )
         {
             return new QueryItem( it, operator, filter, false );
         }

=== 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 15:02:45 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2014-01-09 15:34:25 +0000
@@ -28,6 +28,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.system.util.TextUtils.removeLast;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -44,8 +46,6 @@
 import org.hisp.dhis.period.Period;
 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;
@@ -53,8 +53,6 @@
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.transaction.annotation.Transactional;
 
-import static org.hisp.dhis.system.util.TextUtils.removeLast;
-
 /**
  * @author Lars Helge Overland
  */
@@ -64,12 +62,6 @@
     @Autowired
     private ProgramService programService;
 
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // Implementation
     // -------------------------------------------------------------------------
@@ -231,10 +223,7 @@
             columns.add( col );
         }
 
-        Collection<PatientAttribute> attributes = programPatientAttributeService.getListPatientAttribute( table
-            .getProgram() );
-
-        for ( PatientAttribute attribute : attributes )
+        for ( PatientAttribute attribute : table.getProgram().getAttributes() )
         {
             String dataType = attribute.isNumericType() ? dbl : text;
             String dataClause = attribute.isNumericType() ? numericClause : "";
@@ -247,8 +236,7 @@
             columns.add( col );
         }
 
-        for ( PatientIdentifierType identifierType : programPatientIdentifierTypeService
-            .getListPatientIdentifierType( table.getProgram() ) )
+        for ( PatientIdentifierType identifierType : table.getProgram().getIdentifierTypes() )
         {
             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 15:02:45 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-01-09 15:34:25 +0000
@@ -83,8 +83,6 @@
 import org.hisp.dhis.program.Program;
 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;
@@ -160,21 +158,11 @@
 
     private PatientAttributeService patientAttributeService;
 
-    private Collection<PatientIdentifierType> patientIdentifierTypes;
-
-    private Collection<org.hisp.dhis.patient.PatientAttribute> patientAttributes;
-
     private Integer patientId;
 
     @Autowired
     private OrganisationUnitService organisationUnitService;
 
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // Setters
     // -------------------------------------------------------------------------
@@ -501,7 +489,6 @@
     {
         if ( isNumber( keyword ) == false )
         {
-            OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
             List<Patient> patients = new ArrayList<Patient>();
 
             if ( patients.size() > 1 )
@@ -1313,9 +1300,6 @@
         }
         else
         {
-
-            OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
-            String fullName = enrollmentRelationship.getPersonBName();
             List<Patient> patients = new ArrayList<Patient>();
 
             // remove the own searcher
@@ -1610,22 +1594,18 @@
 
     public Collection<PatientIdentifierType> getIdentifierTypes()
     {
-        patientIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
-        Collection<Program> programs = programService.getAllPrograms();
-        for ( Program program : programs )
-        {
-            patientIdentifierTypes.removeAll( programPatientIdentifierTypeService
-                .getListPatientIdentifierType( program ) );
-        }
+        Collection<PatientIdentifierType> patientIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
         return patientIdentifierTypes;
     }
 
     public Collection<org.hisp.dhis.patient.PatientAttribute> getPatientAtts( String programId )
     {
+        Collection<org.hisp.dhis.patient.PatientAttribute> patientAttributes = new HashSet<org.hisp.dhis.patient.PatientAttribute>();
+        
         if ( programId != null && !programId.trim().equals( "" ) )
         {
             Program program = programService.getProgram( Integer.parseInt( programId ) );
-            patientAttributes = programPatientAttributeService.getListPatientAttribute( program );
+            patientAttributes = program.getAttributes();
         }
         else
         {
@@ -1637,10 +1617,12 @@
 
     public Collection<PatientIdentifierType> getIdentifiers( String programId )
     {
+        Collection<PatientIdentifierType> patientIdentifierTypes = new HashSet<PatientIdentifierType>();
+        
         if ( programId != null && !programId.trim().equals( "" ) )
         {
             Program program = programService.getProgram( Integer.parseInt( programId ) );
-            patientIdentifierTypes = programPatientIdentifierTypeService.getListPatientIdentifierType( program );
+            patientIdentifierTypes = program.getIdentifierTypes();
         }
         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-08 15:08:21 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java	2014-01-09 15:34:25 +0000
@@ -29,9 +29,10 @@
  */
 
 import java.util.Collection;
+import java.util.Iterator;
 
-import org.hisp.dhis.program.ProgramPatientAttributeService;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -52,9 +53,13 @@
     {
         this.patientAttributeStore = patientAttributeStore;
     }
+    
+    private ProgramService programService;
 
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
 
     // -------------------------------------------------------------------------
     // Implementation methods
@@ -127,11 +132,24 @@
 
     public Collection<PatientAttribute> getPatientAttributesWithoutProgram()
     {
-        Collection<PatientAttribute> programPatientAttributes = programPatientAttributeService.getPatientAttributes();
-
         Collection<PatientAttribute> patientAttributes = patientAttributeStore.getAll();
-        patientAttributes.removeAll( programPatientAttributes );
+        Iterator<PatientAttribute> iterator = patientAttributes.iterator();
+        
+        Collection<Program> programs = programService.getAllPrograms();
 
+        for ( Program program : programs )
+        {
+            while ( iterator.hasNext() )
+            {
+                PatientAttribute attribute = iterator.next();
+                
+                if ( program.getAttributes().contains( attribute ) )
+                {
+                    iterator.remove();
+                }
+            }
+        }
+        
         return patientAttributes;
     }
     

=== 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-07 15:02:45 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2014-01-09 15:34:25 +0000
@@ -45,13 +45,11 @@
 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;
 
 /**
@@ -115,9 +113,6 @@
         this.relationshipTypeService = relationshipTypeService;
     }
 
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // Implementation methods
     // -------------------------------------------------------------------------
@@ -560,8 +555,8 @@
         grid.addHeader( new GridHeader( i18n.getString( "gender" ), true, true ) );
         grid.addHeader( new GridHeader( i18n.getString( "phone_number" ), false, true ) );
 
-        Collection<PatientIdentifierType> patientIdentifierTypes = programPatientIdentifierTypeService
-            .getListPatientIdentifierType( program );
+        Collection<PatientIdentifierType> patientIdentifierTypes = program.getIdentifierTypes();
+        
         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/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2014-01-08 16:13:32 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2014-01-09 15:34:25 +0000
@@ -290,26 +290,31 @@
         executeSql( "ALTER TABLE program DROP COLUMN useBirthDateAsIncidentDate" );
         executeSql( "ALTER TABLE program DROP COLUMN useBirthDateAsEnrollmentDate" );
 
-        executeSql( "INSERT INTO program_attributes (programid, patientattributeid, displayedInList, sort_order ) "
-            + "SELECT programid, pp.patientattributeid, displayedInList, pp.sort_order FROM program_patientattributes pp "
+        executeSql( "UPDATE patientattribute SET displayInListNoProgram=false WHERE displayInListNoProgram is null" );
+        executeSql( "UPDATE patientidentifiertype SET displayInListNoProgram=false WHERE displayInListNoProgram is null" );
+
+        executeSql( "ALTER TABLE patientattribute DROP COLUMN displayedInList" );
+        executeSql( "ALTER TABLE patientidentifiertype DROP COLUMN personDisplayName" );
+        
+    }
+
+    // -------------------------------------------------------------------------
+    // Supporting methods
+    // -------------------------------------------------------------------------
+
+    private void updateProgramAttributes()
+    {
+        executeSql( "INSERT INTO program_attributes (programattributeid, sort_order, displayinlist ) "
+            + "SELECT pp.patientattributeid, displayedInList, pp.sort_order 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( "INSERT INTO program_identifierTypes (programid, patientidentifiertypeid, displayedInList, sort_order ) "
             + "SELECT programid, pp.patientidentifiertypeid, personDisplayName, pp.sort_order 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" );
-        
-        executeSql( "UPDATE patientattribute SET displayInListNoProgram=false WHERE displayInListNoProgram is null" );
-        executeSql( "UPDATE PatientIdentifierType SET displayInListNoProgram=false WHERE displayInListNoProgram is null" );
+        executeSql( "DROP TABLE program_patientidentifiertypes" );        
     }
-
-    // -------------------------------------------------------------------------
-    // Supporting methods
-    // -------------------------------------------------------------------------
-
+    
     private void updateUid()
     {
         updateUidColumn( "patientattribute" );

=== 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 15:02:45 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2014-01-09 15:34:25 +0000
@@ -28,6 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
 import org.hisp.dhis.dataelement.DataElement;
@@ -54,18 +63,8 @@
 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;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
 /**
  * @author Abyot Asalefew
  */
@@ -140,16 +139,6 @@
         this.programStageInstanceService = programStageInstanceService;
     }
 
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    public void setProgramPatientAttributeService( ProgramPatientAttributeService programPatientAttributeService )
-    {
-        this.programPatientAttributeService = programPatientAttributeService;
-    }
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // Implementation methods
     // -------------------------------------------------------------------------
@@ -303,7 +292,7 @@
 
         for ( Program program : programs )
         {
-            Collection<PatientAttribute> atttributes = programPatientAttributeService.getListPatientAttribute( program );
+            List<PatientAttribute> atttributes = program.getAttributes();
             while ( iterAttribute.hasNext() )
             {
                 PatientAttributeValue attributeValue = iterAttribute.next();
@@ -336,8 +325,8 @@
 
         for ( Program program : programs )
         {
-            Collection<PatientIdentifierType> identifierTypes = programPatientIdentifierTypeService
-                .getListPatientIdentifierType( program );
+            List<PatientIdentifierType> identifierTypes = program.getIdentifierTypes();
+            
             while ( iterIdentifier.hasNext() )
             {
                 PatientIdentifier identifier = iterIdentifier.next();
@@ -418,8 +407,7 @@
 
         Patient patient = programInstance.getPatient();
 
-        Collection<PatientIdentifierType> identifierTypes = programPatientIdentifierTypeService
-            .getListPatientIdentifierType( programInstance.getProgram() );
+        List<PatientIdentifierType> identifierTypes = programInstance.getProgram().getIdentifierTypes();
 
         Collection<PatientIdentifier> identifiers = patient.getIdentifiers();
 
@@ -448,13 +436,11 @@
 
         // Get patient-attribute-values which belong to the program
 
-        Collection<PatientAttribute> atttributes = programPatientAttributeService
-            .getListPatientAttribute( programInstance.getProgram() );
+        Collection<PatientAttribute> atttributes = programInstance.getProgram().getAttributes();
 
         for ( PatientAttribute attrtibute : atttributes )
         {
-            PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient,
-                attrtibute );
+            PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, attrtibute );
             if ( attributeValue != null )
             {
                 grid.addRow();

=== removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramPatientAttributeService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramPatientAttributeService.java	2014-01-08 18:51:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramPatientAttributeService.java	1970-01-01 00:00:00 +0000
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.program;
-
-import java.util.Collection;
-
-import org.hisp.dhis.patient.PatientAttribute;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * @author Chau Thu Tran
- */
-@Transactional
-public class DefaultProgramPatientAttributeService
-    implements ProgramPatientAttributeService
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ProgramPatientAttributeStore programPatientAttributeStore;
-
-    public void setProgramPatientAttributeStore( ProgramPatientAttributeStore programPatientAttributeStore )
-    {
-        this.programPatientAttributeStore = programPatientAttributeStore;
-    }
-
-    // -------------------------------------------------------------------------
-    // Implementation methods
-    // -------------------------------------------------------------------------
-
-    public void addProgramPatientAttribute( ProgramPatientAttribute programPatientAttribute )
-    {
-        programPatientAttributeStore.save( programPatientAttribute );
-    }
-
-    public void deleteProgramPatientAttribute( ProgramPatientAttribute programPatientAttribute )
-    {
-        programPatientAttributeStore.delete( programPatientAttribute );
-    }
-
-    public Collection<ProgramPatientAttribute> getAllProgramPatientAttributes()
-    {
-        return programPatientAttributeStore.getAll();
-    }
-
-    public Collection<ProgramPatientAttribute> get( Program program )
-    {
-        return programPatientAttributeStore.get( program );
-    }
-
-    public ProgramPatientAttribute get( Program program, PatientAttribute patientAttribute )
-    {
-        return programPatientAttributeStore.get( program, patientAttribute );
-    }
-
-    public void updateProgramPatientAttribute( ProgramPatientAttribute programPatientAttribute )
-    {
-        programPatientAttributeStore.update( programPatientAttribute );
-    }
-
-    public Collection<PatientAttribute> getListPatientAttribute( Program program )
-    {
-        return programPatientAttributeStore.getListPatientAttribute( program );
-    }
-
-    public Collection<PatientAttribute> getPatientAttributes()
-    {
-        return programPatientAttributeStore.getPatientAttributes();
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramPatientIdentiferTypeService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramPatientIdentiferTypeService.java	2014-01-07 15:14:19 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramPatientIdentiferTypeService.java	1970-01-01 00:00:00 +0000
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.program;
-
-import java.util.Collection;
-
-import org.hisp.dhis.patient.PatientIdentifierType;
-
-/**
- * @author Chau Thu Tran
- * 
- * @version $ DefaultProgramPatientIdentiferTypeService.java Jan 7, 2014 10:07:21 AM
- *          $
- */
-public class DefaultProgramPatientIdentiferTypeService
-    implements ProgramPatientIdentifierTypeService
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ProgramPatientIdentifierTypeStore programPatientIdentifierTypeStore;
-
-    public void setProgramPatientIdentifierTypeStore( ProgramPatientIdentifierTypeStore programPatientIdentifierTypeStore )
-    {
-        this.programPatientIdentifierTypeStore = programPatientIdentifierTypeStore;
-    }
-
-    // -------------------------------------------------------------------------
-    // Implementation methods
-    // -------------------------------------------------------------------------
-
-    public void addProgramPatientIdentifierType( ProgramPatientIdentifierType programPatientIdentifierType )
-    {
-        programPatientIdentifierTypeStore.save( programPatientIdentifierType );
-    }
-
-    public void deleteProgramPatientIdentifierType( ProgramPatientIdentifierType programPatientIdentifierType )
-    {
-        programPatientIdentifierTypeStore.delete( programPatientIdentifierType );
-    }
-
-    public Collection<ProgramPatientIdentifierType> getAllProgramPatientIdentifierTypes()
-    {
-        return programPatientIdentifierTypeStore.getAll();
-    }
-
-    public Collection<ProgramPatientIdentifierType> get( Program program )
-    {
-        return programPatientIdentifierTypeStore.get( program );
-    }
-
-    public ProgramPatientIdentifierType get( Program program, PatientIdentifierType patientIdentifierType )
-    {
-        return programPatientIdentifierTypeStore.get( program, patientIdentifierType );
-    }
-
-    public void updateProgramPatientIdentifierType( ProgramPatientIdentifierType programPatientIdentifierType )
-    {
-        programPatientIdentifierTypeStore.update( programPatientIdentifierType );
-    }
-
-    public Collection<PatientIdentifierType> getListPatientIdentifierType( Program program )
-    {
-        return programPatientIdentifierTypeStore.getListPatientIdentifierType( program );
-    }
-
-    public Collection<PatientIdentifierType> getPatientIdentifierTypes()
-    {
-        return programPatientIdentifierTypeStore.getPatientIdentifierTypes();
-    }
-}

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2014-01-08 02:53:44 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2014-01-09 15:34:25 +0000
@@ -230,7 +230,7 @@
             String expression = validation.getLeftSide().getExpression() + " "
                 + validation.getRightSide().getExpression();
             Matcher matcher = pattern.matcher( expression );
-System.out.println("\n\n===\n expression : " + expression);
+            
             boolean flag = false;
             while ( matcher.find() )
             {
@@ -241,7 +241,7 @@
                 String[] ids = info[1].split( SEPARATOR_ID );
 
                 int programStageId = Integer.parseInt( ids[0] );
-System.out.println("\n\n === programStageId "  + programStageId );
+                
                 if ( programStageId == programStage.getId() )
                 {
                     flag = true;

=== removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramAttributeDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramAttributeDeletionHandler.java	2014-01-09 11:38:47 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramAttributeDeletionHandler.java	1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
-package org.hisp.dhis.program;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.Iterator;
-
-import org.hisp.dhis.system.deletion.DeletionHandler;
-
-public class ProgramAttributeDeletionHandler
-    extends DeletionHandler
-{
-    @Override
-    public String getClassName()
-    {
-        return ProgramPatientAttribute.class.getSimpleName();
-    }
-
-    private ProgramPatientAttributeService programAttributeService;
-    
-    public void setProgramAttributeService( ProgramPatientAttributeService programAttributeService )
-    {
-        this.programAttributeService = programAttributeService;
-    }
-    
-    @Override
-    public void deleteProgram( Program program )
-    {
-        Iterator<ProgramPatientAttribute> iterator = program.getProgramPatientAttributes().iterator();
-        
-        while ( iterator.hasNext() )
-        {
-            ProgramPatientAttribute attribute = iterator.next();
-            iterator.remove();
-            programAttributeService.deleteProgramPatientAttribute( attribute );
-        }
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramIdentifierTypeDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramIdentifierTypeDeletionHandler.java	2014-01-09 11:44:02 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramIdentifierTypeDeletionHandler.java	1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
-package org.hisp.dhis.program;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.Iterator;
-
-import org.hisp.dhis.system.deletion.DeletionHandler;
-
-public class ProgramIdentifierTypeDeletionHandler
-    extends DeletionHandler
-{
-    private ProgramPatientIdentifierTypeService programIdentifierTypeService;
-    
-    public void setProgramIdentifierTypeService( ProgramPatientIdentifierTypeService programIdentifierTypeService )
-    {
-        this.programIdentifierTypeService = programIdentifierTypeService;
-    }
-
-    @Override
-    public String getClassName()
-    {
-        return ProgramPatientIdentifierType.class.getSimpleName();
-    }
-
-    @Override
-    public void deleteProgram( Program program )
-    {
-        Iterator<ProgramPatientIdentifierType> iterator = program.getProgramPatientIdentifierTypes().iterator();
-        
-        while ( iterator.hasNext() )
-        {
-            ProgramPatientIdentifierType identifierType = iterator.next();
-            iterator.remove();
-            programIdentifierTypeService.deleteProgramPatientIdentifierType( identifierType );            
-        }
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramPatientAttributeStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramPatientAttributeStore.java	2014-01-09 11:38:47 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramPatientAttributeStore.java	1970-01-01 00:00:00 +0000
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.program.hibernate;
-
-import java.util.Collection;
-
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.criterion.Projections;
-import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramPatientAttribute;
-import org.hisp.dhis.program.ProgramPatientAttributeStore;
-
-/**
- * @author Chau Thu Tran
- */
-public class HibernateProgramPatientAttributeStore
-    implements ProgramPatientAttributeStore
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private SessionFactory sessionFactory;
-
-    public void setSessionFactory( SessionFactory sessionFactory )
-    {
-        this.sessionFactory = sessionFactory;
-    }
-
-    // -------------------------------------------------------------------------
-    // Basic ProgramPatientAttribute
-    // -------------------------------------------------------------------------
-
-    public void save( ProgramPatientAttribute programPatientAttribute )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.save( programPatientAttribute );
-    }
-
-    public void update( ProgramPatientAttribute programPatientAttribute )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.update( programPatientAttribute );
-    }
-
-    public void delete( ProgramPatientAttribute programPatientAttribute )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.delete( programPatientAttribute );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramPatientAttribute> getAll()
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( ProgramPatientAttribute.class );
-
-        return criteria.list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramPatientAttribute> get( Program program )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( ProgramPatientAttribute.class );
-
-        return criteria.add( Restrictions.eq( "program", program ) ).list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramPatientAttribute> get( Program program, boolean compulsory )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( ProgramPatientAttribute.class );
-        criteria.add( Restrictions.eq( "program", program ) );
-        criteria.add( Restrictions.eq( "compulsory", compulsory ) );
-
-        return criteria.list();
-    }
-
-    public ProgramPatientAttribute get( Program program, PatientAttribute patientAttribute )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( ProgramPatientAttribute.class );
-        criteria.add( Restrictions.eq( "program", program ) );
-        criteria.add( Restrictions.eq( "patientAttribute", patientAttribute ) );
-
-        return (ProgramPatientAttribute) criteria.uniqueResult();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<PatientAttribute> getListPatientAttribute( Program program )
-    {
-        Session session = sessionFactory.getCurrentSession();
-        Criteria criteria = session.createCriteria( ProgramPatientAttribute.class );
-        criteria.add( Restrictions.eq( "program", program ) );
-        criteria.setProjection( Projections.property( "patientAttribute" ) );
-        return criteria.list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<PatientAttribute> getPatientAttributes()
-    {
-        Session session = sessionFactory.getCurrentSession();
-        Criteria criteria = session.createCriteria( ProgramPatientAttribute.class );
-        criteria.setProjection( Projections.property( "patientAttribute" ) );
-        return criteria.list();
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramPatientIdentifierTypeStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramPatientIdentifierTypeStore.java	2014-01-07 15:14:19 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramPatientIdentifierTypeStore.java	1970-01-01 00:00:00 +0000
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.program.hibernate;
-
-import java.util.Collection;
-
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.criterion.Projections;
-import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.patient.PatientIdentifierType;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramPatientIdentifierType;
-import org.hisp.dhis.program.ProgramPatientIdentifierTypeStore;
-
-/**
- * @author Chau Thu Tran
- * 
- * @version $ HibernateProgramPatientIdentifierTypeStore.java Jan 7, 2014 9:49:20 AM
- *          $
- */
-public class HibernateProgramPatientIdentifierTypeStore
-    implements ProgramPatientIdentifierTypeStore
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private SessionFactory sessionFactory;
-
-    public void setSessionFactory( SessionFactory sessionFactory )
-    {
-        this.sessionFactory = sessionFactory;
-    }
-
-    // -------------------------------------------------------------------------
-    // Basic ProgramPatientIdentifierType
-    // -------------------------------------------------------------------------
-
-    public void save( ProgramPatientIdentifierType programPatientIdentifierType )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.save( programPatientIdentifierType );
-    }
-
-    public void update( ProgramPatientIdentifierType programPatientIdentifierType )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.update( programPatientIdentifierType );
-    }
-
-    public void delete( ProgramPatientIdentifierType programPatientIdentifierType )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.delete( programPatientIdentifierType );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramPatientIdentifierType> getAll()
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( ProgramPatientIdentifierType.class );
-
-        return criteria.list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramPatientIdentifierType> get( Program program )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( ProgramPatientIdentifierType.class );
-
-        return criteria.add( Restrictions.eq( "program", program ) ).list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramPatientIdentifierType> get( Program program, boolean compulsory )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( ProgramPatientIdentifierType.class );
-        criteria.add( Restrictions.eq( "program", program ) );
-        criteria.add( Restrictions.eq( "compulsory", compulsory ) );
-
-        return criteria.list();
-    }
-
-    public ProgramPatientIdentifierType get( Program program, PatientIdentifierType patientIdentifierType )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( ProgramPatientIdentifierType.class );
-        criteria.add( Restrictions.eq( "program", program ) );
-        criteria.add( Restrictions.eq( "patientIdentifierType", patientIdentifierType ) );
-
-        return (ProgramPatientIdentifierType) criteria.uniqueResult();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<PatientIdentifierType> getListPatientIdentifierType( Program program )
-    {
-        Session session = sessionFactory.getCurrentSession();
-        Criteria criteria = session.createCriteria( ProgramPatientIdentifierType.class );
-        criteria.add( Restrictions.eq( "program", program ) );
-        criteria.setProjection( Projections.property( "patientIdentifierType" ) );
-        return criteria.list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<PatientIdentifierType> getPatientIdentifierTypes()
-    {
-        Session session = sessionFactory.getCurrentSession();
-        Criteria criteria = session.createCriteria( ProgramPatientIdentifierType.class );
-        criteria.setProjection( Projections.property( "patientIdentifierType" ) );
-        return criteria.list();
-    }
-}

=== 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-09 11:44:02 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2014-01-09 15:34:25 +0000
@@ -204,8 +204,6 @@
 		<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
-		<property name="programPatientAttributeService"
-			ref="org.hisp.dhis.program.ProgramPatientAttributeService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.program.ProgramStageService" class="org.hisp.dhis.program.DefaultProgramStageService">
@@ -264,6 +262,7 @@
 
 	<bean id="org.hisp.dhis.patient.PatientAttributeService" class="org.hisp.dhis.patient.DefaultPatientAttributeService">
 		<property name="patientAttributeStore" ref="org.hisp.dhis.patient.PatientAttributeStore" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 
 	<bean
@@ -389,30 +388,6 @@
 		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>
 
-	<!-- Program Patient Attribute -->
-
-	<bean id="org.hisp.dhis.program.ProgramPatientAttributeService"
-		class="org.hisp.dhis.program.DefaultProgramPatientAttributeService">
-		<property name="programPatientAttributeStore"
-			ref="org.hisp.dhis.program.ProgramPatientAttributeStore" />
-	</bean>
-
-	<bean id="org.hisp.dhis.program.ProgramPatientAttributeStore"
-		class="org.hisp.dhis.program.hibernate.HibernateProgramPatientAttributeStore">
-		<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">
@@ -524,18 +499,6 @@
         <property name="patientAuditService" ref="org.hisp.dhis.patient.PatientAuditService" />
     </bean>
     
-    <bean id="org.hisp.dhis.program.ProgramAttributeDeletionHandler"
-       class="org.hisp.dhis.program.ProgramAttributeDeletionHandler">
-        <property name="programAttributeService"
-            ref="org.hisp.dhis.program.ProgramPatientAttributeService" />
-    </bean>
-
-    <bean id="org.hisp.dhis.program.ProgramIdentifierTypeDeletionHandler"
-       class="org.hisp.dhis.program.ProgramIdentifierTypeDeletionHandler">
-        <property name="programIdentifierTypeService"
-            ref="org.hisp.dhis.program.ProgramPatientIdentifierTypeService" />
-    </bean>
-
 	<!-- DeletionManager -->
 
 	<bean
@@ -559,8 +522,6 @@
 					<ref local="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler" />
 					<ref local="org.hisp.dhis.program.ProgramValidationDeletionHandler" />
 					<ref local="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler" />
-					<ref local="org.hisp.dhis.program.ProgramAttributeDeletionHandler" />
-                    <ref local="org.hisp.dhis.program.ProgramIdentifierTypeDeletionHandler" />
 				</list>
 			</list>
 		</property>

=== 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-08 18:47:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2014-01-09 12:49:36 +0000
@@ -48,12 +48,12 @@
 
 		<property name="onlyEnrollOnce" />
 
-		<set name="programPatientIdentifierTypes" order-by="sort_order">
+		<set name="programPatientIdentifierTypes" cascade="all,delete-orphan" order-by="sort_order">
 			<key column="programid" />
 			<one-to-many class="org.hisp.dhis.program.ProgramPatientIdentifierType" />
 		</set>
 
-		<set name="programPatientAttributes" order-by="sort_order">
+		<set name="programPatientAttributes" cascade="all,delete-orphan" order-by="sort_order">
 			<key column="programid" />
 			<one-to-many class="org.hisp.dhis.program.ProgramPatientAttribute" />
 		</set>

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientAttribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientAttribute.hbm.xml	2014-01-07 16:46:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientAttribute.hbm.xml	2014-01-09 15:34:25 +0000
@@ -6,16 +6,16 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.program.ProgramPatientAttribute" table="program_attributes">
 
-    <composite-id>
-      <key-many-to-one name="program" class="org.hisp.dhis.program.Program" column="programid"
-        foreign-key="fk_programpatientattribute_programid" />
-      <key-many-to-one name="patientAttribute" class="org.hisp.dhis.patient.PatientAttribute" column="patientattributeid"
-        foreign-key="fk_program_attributeid" />
-    </composite-id>
-	
-	<property name="displayedInList"/>
+    <id name="id" column="programattributeid">
+        <generator class="native" />
+    </id>
+    
+    <many-to-one name="patientAttribute" class="org.hisp.dhis.patient.PatientAttribute" 
+        column="attributeid" foreign-key="fk_program_attributeid" />
 
-	<property name="sortOrder" column="sort_order" />
+    <property name="sortOrder" column="sort_order" />
+    
+	<property name="displayedInList" column="displayinlist" />
 	
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientIdentifierType.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientIdentifierType.hbm.xml	2014-01-09 11:38:47 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientIdentifierType.hbm.xml	2014-01-09 15:34:25 +0000
@@ -6,17 +6,16 @@
 <hibernate-mapping>
 	<class name="org.hisp.dhis.program.ProgramPatientIdentifierType" table="program_identifiertypes">
 
-		<composite-id>
-			<key-many-to-one name="program" class="org.hisp.dhis.program.Program"
-				column="programid" foreign-key="fk_programidentifierTypes_programid" />
-			<key-many-to-one name="patientIdentifierType"
-				class="org.hisp.dhis.patient.PatientIdentifierType" column="patientidentifiertypeid"
-				foreign-key="fk_program_patientidentifiertypeid" />
-		</composite-id>
-
-		<property name="displayedInList" />
-
-		<property name="sortOrder" column="sort_order" />
+    <id name="id" column="programidentifiertypeid">
+        <generator class="native" />
+    </id>
+    
+	<many-to-one name="patientIdentifierType" class="org.hisp.dhis.patient.PatientIdentifierType" 
+	   column="identifiertypeid" foreign-key="fk_program_identifiertypeid" />
+
+    <property name="sortOrder" column="sort_order" />
+
+	<property name="displayedInList" column="displayinlist" />
 
 	</class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonAttributeTypeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonAttributeTypeController.java	2014-01-07 08:22:52 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonAttributeTypeController.java	2014-01-09 15:34:25 +0000
@@ -38,7 +38,6 @@
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramPatientAttributeService;
 import org.hisp.dhis.program.ProgramService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -60,9 +59,6 @@
     @Autowired
     private ProgramService programService;
 
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
     @Override
     protected List<PatientAttribute> getEntityList( WebMetaData metaData, WebOptions options )
     {
@@ -83,8 +79,7 @@
 
             if ( program != null )
             {
-                entityList = new ArrayList<PatientAttribute>(
-                    programPatientAttributeService.getListPatientAttribute( program ) );
+                entityList = new ArrayList<PatientAttribute>( program.getAttributes() );
             }
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java	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/caseaggregation/GetParamsByProgramAction.java	2014-01-09 15:34:25 +0000
@@ -36,10 +36,8 @@
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramPatientAttributeService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStage;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -70,9 +68,6 @@
         this.attributeService = attributeService;
     }
 
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
     // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------
@@ -115,7 +110,7 @@
 
             for ( Program _program : programs )
             {
-                patientAttributes.remove( programPatientAttributeService.getListPatientAttribute( _program ) );
+                patientAttributes.removeAll( _program.getAttributes() );
             }
         }
 

=== 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 15:02:45 +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-09 15:34:25 +0000
@@ -40,12 +40,9 @@
 import org.hisp.dhis.patient.PatientRegistrationForm;
 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;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -103,12 +100,6 @@
         this.userSettingService = userSettingService;
     }
 
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // Getters & Setters
     // -------------------------------------------------------------------------
@@ -179,17 +170,18 @@
 
             identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
             attributes = patientAttributeService.getAllPatientAttributes();
-            for ( Program p : programs )
+            
+            for ( Program program : programs )
             {
-                identifierTypes.remove( programPatientIdentifierTypeService.getListPatientIdentifierType( p ) );
-                attributes.remove( programPatientAttributeService.getListPatientAttribute( p ) );
+                identifierTypes.removeAll( program.getIdentifierTypes()  );
+                attributes.removeAll( program.getAttributes() );
             }
         }
         else
         {
             program = programService.getProgram( programId );
-            identifierTypes = programPatientIdentifierTypeService.getListPatientIdentifierType( program );
-            attributes = programPatientAttributeService.getListPatientAttribute( program );
+            identifierTypes = program.getIdentifierTypes();
+            attributes = program.getAttributes();
             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/patientattribute/ShowPatientAttributeInListNoProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ShowPatientAttributeInListNoProgramAction.java	2014-01-08 16:13:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ShowPatientAttributeInListNoProgramAction.java	2014-01-09 15:34:25 +0000
@@ -109,7 +109,6 @@
         selectedPatientAttributes = new ArrayList<PatientAttribute>(
             patientAttributeService.getPatientAttributesDisplayed( true ) );
         Collections.sort( availablePatientAttributes, IdentifiableObjectNameComparator.INSTANCE );
-
         
         availablePatientIdentifierTypes = new ArrayList<PatientIdentifierType>(
             patientIdentifierTypeService.getPatientIdentifierTypeDisplayed( false ) );

=== 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 15:02:45 +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-09 15:34:25 +0000
@@ -35,12 +35,9 @@
 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;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -77,12 +74,6 @@
         this.userGroupService = userGroupService;
     }
 
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -150,10 +141,9 @@
 
         userGroups = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
 
-        attributes = new ArrayList<PatientAttribute>( programPatientAttributeService.getListPatientAttribute( program ) );
+        attributes = new ArrayList<PatientAttribute>( program.getAttributes() );
 
-        identifierTypes = new ArrayList<PatientIdentifierType>(
-            programPatientIdentifierTypeService.getListPatientIdentifierType( program ) );
+        identifierTypes = new ArrayList<PatientIdentifierType>( program.getIdentifierTypes() );
 
         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 15:02:45 +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-09 15:34:25 +0000
@@ -33,12 +33,9 @@
 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;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -64,12 +61,6 @@
         this.userGroupService = userGroupService;
     }
 
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -120,10 +111,9 @@
 
         userGroups = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
 
-        attributes = new ArrayList<PatientAttribute>( programPatientAttributeService.getListPatientAttribute( program ) );
+        attributes = program.getAttributes();
 
-        identifierTypes = new ArrayList<PatientIdentifierType>(
-            programPatientIdentifierTypeService.getListPatientIdentifierType( program ) );
+        identifierTypes = program.getIdentifierTypes();
         
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/ValidateProgramPatientReminderAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/ValidateProgramPatientReminderAction.java	2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/ValidateProgramPatientReminderAction.java	2014-01-09 15:34:25 +0000
@@ -30,8 +30,6 @@
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.patient.PatientReminder;
 import org.hisp.dhis.patient.PatientReminderService;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramService;
 
 import com.opensymphony.xwork2.Action;
 

=== 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 16:28:34 +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-09 15:34:25 +0000
@@ -41,15 +41,12 @@
 import org.hisp.dhis.program.ProgramInstance;
 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;
 
@@ -110,16 +107,6 @@
         this.relationshipTypeService = relationshipTypeService;
     }
 
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    public void setProgramPatientAttributeService( ProgramPatientAttributeService programPatientAttributeService )
-    {
-        this.programPatientAttributeService = programPatientAttributeService;
-    }
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -312,20 +299,21 @@
 
             if ( ids[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) )
             {
-                PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer
-                    .parseInt( ids[1] ) );
-                ProgramPatientIdentifierType programPatientIdentifierType = new ProgramPatientIdentifierType( program,
-                    identifierType, personDisplayNames.get( index ) , index + 1);
-                programPatientIdentifierTypeService.addProgramPatientIdentifierType( programPatientIdentifierType );
+                PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer.parseInt( ids[1] ) );
+                
+                ProgramPatientIdentifierType programPatientIdentifierType = new ProgramPatientIdentifierType( 
+                    identifierType, index + 1, personDisplayNames.get( index ) );
+                
+                program.getProgramPatientIdentifierTypes().add( programPatientIdentifierType );
             }
             else if ( ids[0].equals( Patient.PREFIX_PATIENT_ATTRIBUTE ) )
             {
-                PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( Integer
-                    .parseInt( ids[1] ) );
+                PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( Integer.parseInt( ids[1] ) );
 
-                ProgramPatientAttribute programPatientAttribute = new ProgramPatientAttribute( program,
-                    patientAttribute, personDisplayNames.get( index ), index + 1 );
-                programPatientAttributeService.addProgramPatientAttribute( programPatientAttribute );
+                ProgramPatientAttribute programPatientAttribute = new ProgramPatientAttribute( 
+                    patientAttribute, index + 1, personDisplayNames.get( index ) );
+                
+                program.getProgramPatientAttributes().add( programPatientAttribute );
             }
 
             index++;

=== 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 15:02:45 +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-09 15:34:25 +0000
@@ -31,7 +31,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
 
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
@@ -42,14 +41,11 @@
 import org.hisp.dhis.patient.PatientIdentifierType;
 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;
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupService;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -98,13 +94,7 @@
     {
         this.relationshipTypeService = relationshipTypeService;
     }
-
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
+    
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -211,12 +201,10 @@
         program = programService.getProgram( id );
 
         availableIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
-        availableIdentifierTypes.removeAll( new HashSet<PatientIdentifierType>( programPatientIdentifierTypeService
-            .getListPatientIdentifierType( program ) ) );
-
+        availableIdentifierTypes.removeAll( program.getIdentifierTypes() );
+        
         availableAttributes = patientAttributeService.getAllPatientAttributes();
-        availableAttributes.removeAll( new HashSet<PatientAttribute>( programPatientAttributeService
-            .getListPatientAttribute( program ) ) );
+        availableAttributes.removeAll( program.getAttributes() );
 
         programs = new ArrayList<Program>( programService.getAllPrograms() );
         programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );

=== 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 16:28:34 +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-09 15:34:25 +0000
@@ -29,9 +29,7 @@
  */
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientAttribute;
@@ -40,13 +38,10 @@
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
 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;
 
@@ -89,16 +84,6 @@
         this.relationshipTypeService = relationshipTypeService;
     }
 
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    public void setProgramPatientAttributeService( ProgramPatientAttributeService programPatientAttributeService )
-    {
-        this.programPatientAttributeService = programPatientAttributeService;
-    }
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -328,80 +313,35 @@
             RelationshipType relationshipType = relationshipTypeService.getRelationshipType( relationshipTypeId );
             program.setRelationshipType( relationshipType );
         }
+        
         program.setRelationshipFromA( relationshipFromA );
         program.setRelationshipText( relationshipText );
-
-        Set<ProgramPatientIdentifierType> programPatientIdentifierTypes = new HashSet<ProgramPatientIdentifierType>(
-            program.getProgramPatientIdentifierTypes() );
-
-        Set<ProgramPatientAttribute> programPatientAttributes = new HashSet<ProgramPatientAttribute>(
-            program.getProgramPatientAttributes() );
-
+        
+        program.getProgramPatientIdentifierTypes().clear();
+        program.getProgramPatientAttributes().clear();
+        
         int index = 0;
+        
         for ( String selectedPropertyId : selectedPropertyIds )
         {
             String[] ids = selectedPropertyId.split( "_" );
 
             if ( ids[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) )
             {
-                PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer
-                    .parseInt( ids[1] ) );
-
-                ProgramPatientIdentifierType programPatientIdentifierType = programPatientIdentifierTypeService.get(
-                    program, identifierType );
-
-                if ( programPatientIdentifierType == null )
-                {
-                    programPatientIdentifierType = new ProgramPatientIdentifierType( program, identifierType,
-                        personDisplayNames.get( index ), index + 1 );
-                    programPatientIdentifierTypeService.addProgramPatientIdentifierType( programPatientIdentifierType );
-                }
-                else
-                {
-                    programPatientIdentifierType.setDisplayedInList( personDisplayNames.get( index ) );
-                    programPatientIdentifierType.setSortOrder( index + 1 );
-                    programPatientIdentifierTypeService
-                        .updateProgramPatientIdentifierType( programPatientIdentifierType );
-
-                    programPatientIdentifierTypes.remove( programPatientIdentifierType );
-                }
+                PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer.parseInt( ids[1] ) );
+                ProgramPatientIdentifierType programPatientIdentifierType = new ProgramPatientIdentifierType( identifierType, index + 1, personDisplayNames.get( index ) );
+                program.getProgramPatientIdentifierTypes().add( programPatientIdentifierType );
             }
             else if ( ids[0].equals( Patient.PREFIX_PATIENT_ATTRIBUTE ) )
             {
-                PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( Integer
-                    .parseInt( ids[1] ) );
-
-                ProgramPatientAttribute programPatientAttribute = programPatientAttributeService.get( program,
-                    patientAttribute );
-
-                if ( programPatientAttribute == null )
-                {
-                    programPatientAttribute = new ProgramPatientAttribute( program, patientAttribute,
-                        personDisplayNames.get( index ) , index + 1);
-                    programPatientAttributeService.addProgramPatientAttribute( programPatientAttribute );
-                }
-                else
-                {
-                    programPatientAttribute.setDisplayedInList( personDisplayNames.get( index ) );
-                    programPatientAttribute.setSortOrder( index + 1 );
-                    programPatientAttributeService.updateProgramPatientAttribute( programPatientAttribute );
-
-                    programPatientAttributes.remove( programPatientAttribute );
-                }
+                PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( Integer.parseInt( ids[1] ) );
+                ProgramPatientAttribute programPatientAttribute = new ProgramPatientAttribute( patientAttribute, index + 1, personDisplayNames.get( index ) );
+                program.getProgramPatientAttributes().add( programPatientAttribute );
             }
+            
             index++;
         }
 
-        for ( ProgramPatientIdentifierType identifier : programPatientIdentifierTypes )
-        {
-            programPatientIdentifierTypeService.deleteProgramPatientIdentifierType( identifier );
-        }
-
-        for ( ProgramPatientAttribute attribute : programPatientAttributes )
-        {
-            programPatientAttributeService.deleteProgramPatientAttribute( attribute );
-        }
-
         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 15:02:45 +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-09 15:34:25 +0000
@@ -32,16 +32,13 @@
 import java.util.Collections;
 import java.util.List;
 
-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;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -70,12 +67,6 @@
         this.programService = programService;
     }
 
-    @Autowired
-    private ProgramPatientAttributeService programPatientAttributeService;
-
-    @Autowired
-    private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
-
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -138,11 +129,9 @@
 
         program = programService.getProgram( programId );
 
-        patientAttributes = new ArrayList<PatientAttribute>(
-            programPatientAttributeService.getListPatientAttribute( program ) );
+        patientAttributes = program.getAttributes();
 
-        patientIdentifierTypes = new ArrayList<PatientIdentifierType>(
-            programPatientIdentifierTypeService.getListPatientIdentifierType( program ) );
+        patientIdentifierTypes = program.getIdentifierTypes();
 
         Collections.sort( patientAttributes, IdentifiableObjectNameComparator.INSTANCE );
 

=== 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-08 15:08:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2014-01-09 15:34:25 +0000
@@ -197,8 +197,6 @@
 			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.GetProgramListAction"
@@ -268,8 +266,6 @@
 			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"