← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2013: Add function Handling unrollement of beneficary and program.

 

------------------------------------------------------------
revno: 2013
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2010-11-09 09:09:53 +0700
message:
  Add function Handling unrollement of beneficary and program.
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttribute.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOption.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOptionService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOptionStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValue.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramAttributeOptionService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramAttributeService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramAttributeOptionStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramAttributeStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/DefaultProgramAttributeValueService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/hibernate/
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/hibernate/HibernateProgramAttributeValueStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramAttribute.hbm.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramAttributeOption.hbm.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/programattributevalue/
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/programattributevalue/hibernate/
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/programattributevalue/hibernate/ProgramAttributeValue.hbm.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAttributeListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/RemoveProgramAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ValidateProgramAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramAttributeForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programAttribute.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttributeList.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseProgramAttribute.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramAttributeForm.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeOption.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValue.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstance.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/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ProgramEnrollmentSelectAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SaveProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ShowAddPatientFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programEnrollmentForm.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeOption.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeOption.java	2010-02-22 09:19:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeOption.java	2010-11-09 02:09:53 +0000
@@ -33,7 +33,7 @@
  *
  * @version $Id$
  */
-public class PatientAttributeOption  implements Serializable
+public class PatientAttributeOption implements Serializable
 {
     private int id;
     

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java	2010-02-22 09:19:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java	2010-11-09 02:09:53 +0000
@@ -34,7 +34,6 @@
  */
 public interface PatientAttributeService
 {
-
     String ID = PatientAttributeService.class.getName();
 
     int savePatientAttribute( PatientAttribute patientAttribute );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValue.java	2010-02-22 09:19:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValue.java	2010-11-09 02:09:53 +0000
@@ -41,13 +41,13 @@
 {
 
     public static final String UNKNOWN = " ";
-    
+
     private PatientAttribute patientAttribute;
 
     private Patient patient;
 
     private String value;
-    
+
     private PatientAttributeOption patientAttributeOption;
 
     // -------------------------------------------------------------------------
@@ -96,7 +96,7 @@
         final PatientAttributeValue other = (PatientAttributeValue) o;
 
         return patientAttribute.equals( other.getPatientAttribute() ) && patient.equals( other.getPatient() );
-            
+
     }
 
     @Override
@@ -107,7 +107,7 @@
 
         result = result * prime + patientAttribute.hashCode();
         result = result * prime + patient.hashCode();
-        
+
         return result;
     }
 
@@ -145,12 +145,13 @@
         this.value = value;
     }
 
-	public PatientAttributeOption getPatientAttributeOption() {
-		return patientAttributeOption;
-	}
+    public PatientAttributeOption getPatientAttributeOption()
+    {
+        return patientAttributeOption;
+    }
 
-	public void setPatientAttributeOption(
-			PatientAttributeOption patientAttributeOption) {
-		this.patientAttributeOption = patientAttributeOption;
-	}
+    public void setPatientAttributeOption( PatientAttributeOption patientAttributeOption )
+    {
+        this.patientAttributeOption = patientAttributeOption;
+    }
 }

=== 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	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2010-11-09 02:09:53 +0000
@@ -36,7 +36,6 @@
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.validation.ValidationCriteria;
 
-
 /**
  * @author Abyot Asalefew
  * @version $Id$
@@ -70,8 +69,8 @@
 
     private Set<ValidationCriteria> patientValidationCriteria = new HashSet<ValidationCriteria>();
 
-    private Integer minDaysAllowedInputData;    
-    
+    private Integer minDaysAllowedInputData;
+
     private Integer maxDaysAllowedInputData;
     
     // -------------------------------------------------------------------------
@@ -266,10 +265,10 @@
         {
             for ( ValidationCriteria criteria : patientValidationCriteria )
             {
-                Object propertyValue = getValueFromPatient(StringUtils.capitalize(criteria.getProperty()), patient);
-               
+                Object propertyValue = getValueFromPatient( StringUtils.capitalize( criteria.getProperty() ), patient );
+
                 // Compare property value with compare value
-                
+
                 int i = ((Comparable) propertyValue).compareTo( (Comparable) criteria.getValue() );
 
                 // Return validation criteria if criteria is not met
@@ -289,9 +288,10 @@
             throw new RuntimeException( ex );
         }
     }
-    
-    
-    private Object getValueFromPatient( String property, Patient patient ) throws Exception {
-    	return Patient.class.getMethod( "get" + property ).invoke( patient ); 
+
+    private Object getValueFromPatient( String property, Patient patient )
+        throws Exception
+    {
+        return Patient.class.getMethod( "get" + property ).invoke( patient );
     }
 }

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttribute.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttribute.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2004-2010, 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.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Chau Thu Tran
+ * @version $Id ProgramAttribute.java 2010-10-30 19:30:09Z $
+ */
+public class ProgramAttribute
+    implements Serializable
+{
+    public static final String TYPE_DATE = "DATE";
+
+    public static final String TYPE_STRING = "TEXT";
+
+    public static final String TYPE_INT = "NUMBER";
+
+    public static final String TYPE_BOOL = "YES/NO";
+
+    public static final String TYPE_COMBO = "COMBO";
+
+    public final char REASON_IS_DEAD = 'd';
+
+    private Integer id;
+
+    private String name;
+
+    private String description;
+
+    private String valueType;
+
+    private Set<ProgramAttributeOption> attributeOptions;
+
+    // private String causeDeath;
+
+    // -------------------------------------------------------------------------
+    // Constructors
+    // -------------------------------------------------------------------------
+
+    public ProgramAttribute()
+    {
+    }
+
+    // -------------------------------------------------------------------------
+    // Logic
+    // -------------------------------------------------------------------------
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+            return true;
+        if ( obj == null )
+            return false;
+        if ( getClass() != obj.getClass() )
+            return false;
+        ProgramAttribute other = (ProgramAttribute) obj;
+        if ( name == null )
+        {
+            if ( other.name != null )
+                return false;
+        }
+        else if ( !name.equals( other.name ) )
+            return false;
+        return true;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters and setters
+    // -------------------------------------------------------------------------
+
+    public Integer getId()
+    {
+        return id;
+    }
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    public String getValueType()
+    {
+        return valueType;
+    }
+
+    public void setValueType( String valueType )
+    {
+        this.valueType = valueType;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    public Set<ProgramAttributeOption> getAttributeOptions()
+    {
+        return attributeOptions;
+    }
+
+    public void setAttributeOptions( Set<ProgramAttributeOption> attributeOptions )
+    {
+        this.attributeOptions = attributeOptions;
+    }
+
+    public void addAttributeOptions( ProgramAttributeOption option )
+    {
+        if ( attributeOptions == null )
+            attributeOptions = new HashSet<ProgramAttributeOption>();
+        attributeOptions.add( option );
+    }
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOption.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOption.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOption.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2004-2010, 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.io.Serializable;
+
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version ProgramAttributeOption.java Nov 1, 2010 2:57:37 PM
+ */
+public class ProgramAttributeOption implements Serializable
+{
+    private int id;
+
+    private String name;
+
+    private ProgramAttribute programAttribute;
+
+    // -------------------------------------------------------------------------
+    // Constructors
+    // -------------------------------------------------------------------------
+
+    public ProgramAttributeOption()
+    {
+    }
+
+    // -------------------------------------------------------------------------
+    // hashCode, equals and toString
+    // -------------------------------------------------------------------------
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+            return true;
+        if ( obj == null )
+            return false;
+        if ( getClass() != obj.getClass() )
+            return false;
+        ProgramAttributeOption other = (ProgramAttributeOption) obj;
+        if ( name == null )
+        {
+            if ( other.name != null )
+                return false;
+        }
+        else if ( !name.equals( other.name ) )
+            return false;
+        return true;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters and setters
+    // -------------------------------------------------------------------------
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public ProgramAttribute getProgramAttribute()
+    {
+        return programAttribute;
+    }
+
+    public void setProgramAttribute( ProgramAttribute programAttribute )
+    {
+        this.programAttribute = programAttribute;
+    }
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOptionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOptionService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOptionService.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004-2010, 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.hisp.dhis.patient.PatientAttributeOption;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version ProgramAttributeOptionService.java Nov 1, 2010 3:02:01 PM 
+ */
+public interface ProgramAttributeOptionService
+{
+    int addProgramAttributeOption( ProgramAttributeOption option );
+
+    void updateProgramAttributeOption( ProgramAttributeOption option );
+
+    void deleteProgramAttributeOption( ProgramAttributeOption option );
+
+    ProgramAttributeOption get( ProgramAttribute programAttribute, String name );
+    
+    ProgramAttributeOption get( int id );
+    
+    Collection<ProgramAttributeOption> get( ProgramAttribute programAttribute );
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOptionStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOptionStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeOptionStore.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2004-2010, 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.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.patient.PatientAttributeOption;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version ProgramAttributeOptionStore.java Nov 1, 2010 3:03:28 PM
+ */
+public interface ProgramAttributeOptionStore extends GenericIdentifiableObjectStore<ProgramAttributeOption>
+{
+    String ID = ProgramAttributeOption.class.getName();
+
+    ProgramAttributeOption get( ProgramAttribute patientAttribute, String name );
+
+    Collection<ProgramAttributeOption> get( ProgramAttribute programAttribute );
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeService.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004-2010, 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;
+
+/**
+ * @author Chau Thu Tran
+ * @version $Id ProgramAttributeService.java 2010-10-30 19:50:04Z $
+ */
+public interface ProgramAttributeService
+{
+    String ID = ProgramAttributeService.class.getName();
+
+    int saveProgramAttribute( ProgramAttribute programAttribute );
+
+    void deleteProgramAttribute( ProgramAttribute programAttribute );
+
+    void updateProgramAttribute( ProgramAttribute programAttribute );
+
+    ProgramAttribute getProgramAttribute( int id );
+
+    ProgramAttribute getProgramAttributeByName( String name );
+
+    Collection<ProgramAttribute> getAllProgramAttributes();
+
+    Collection<ProgramAttribute> getProgramAttributeByValueType( String valueType );
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramAttributeStore.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2004-2010, 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.common.GenericIdentifiableObjectStore;
+
+/**
+ * @author Chau Thu Tran
+ * @version $Id ProgramAttributeStore.java 2010-10-30 19:55:21Z $
+ */
+public interface ProgramAttributeStore
+    extends GenericIdentifiableObjectStore<ProgramAttribute>
+{
+    String ID = ProgramAttributeStore.class.getName();
+
+    Collection<ProgramAttribute> getByValueType( String valueType );
+
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstance.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstance.java	2009-11-13 15:59:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstance.java	2010-11-09 02:09:53 +0000
@@ -56,6 +56,8 @@
 
     private Set<ProgramStageInstance> programStageInstances = new HashSet<ProgramStageInstance>();
 
+    private Set<ProgramAttribute> attributes = new HashSet<ProgramAttribute>();
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -246,6 +248,16 @@
         this.programStageInstances = programStageInstances;
     }
 
+    public Set<ProgramAttribute> getAttributes()
+    {
+        return attributes;
+    }
+
+    public void setAttributes( Set<ProgramAttribute> attributes )
+    {
+        this.attributes = attributes;
+    }
+    
     // -------------------------------------------------------------------------
     // Convenience method
     // -------------------------------------------------------------------------

=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValue.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValue.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2004-2010, 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.programattributevalue;
+
+import java.io.Serializable;
+
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeOption;
+import org.hisp.dhis.program.ProgramInstance;
+
+/**
+ * @author Chau Thu Tran
+ * @version $Id ProgramAttributeValue.java 2010-10-30 19:32:09Z $
+ */
+public class ProgramAttributeValue
+    implements Serializable
+{
+    private ProgramAttribute programAttribute;
+
+    private ProgramInstance programInstance;
+
+    private String value;
+
+    private ProgramAttributeOption programAttributeOption;
+
+    // -------------------------------------------------------------------------
+    // Constructors
+    // -------------------------------------------------------------------------
+
+    public ProgramAttributeValue()
+    {
+
+    }
+
+    // -------------------------------------------------------------------------
+    // Logic
+    // -------------------------------------------------------------------------
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((programAttribute == null) ? 0 : programAttribute.hashCode());
+        result = prime * result + ((programInstance == null) ? 0 : programInstance.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+            return true;
+        if ( obj == null )
+            return false;
+        if ( getClass() != obj.getClass() )
+            return false;
+        ProgramAttributeValue other = (ProgramAttributeValue) obj;
+        if ( programAttribute == null )
+        {
+            if ( other.programAttribute != null )
+                return false;
+        }
+        else if ( !programAttribute.equals( other.programAttribute ) )
+            return false;
+        if ( programInstance == null )
+        {
+            if ( other.programInstance != null )
+                return false;
+        }
+        else if ( !programInstance.equals( other.programInstance ) )
+            return false;
+        return true;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters and setters
+    // -------------------------------------------------------------------------
+
+    public ProgramAttribute getProgramAttribute()
+    {
+        return programAttribute;
+    }
+
+    public ProgramAttributeOption getProgramAttributeOption()
+    {
+        return programAttributeOption;
+    }
+
+    public void setProgramAttributeOption( ProgramAttributeOption programAttributeOption )
+    {
+        this.programAttributeOption = programAttributeOption;
+    }
+
+    public void setProgramAttribute( ProgramAttribute programAttribute )
+    {
+        this.programAttribute = programAttribute;
+    }
+
+    public ProgramInstance getProgramInstance()
+    {
+        return programInstance;
+    }
+
+    public void setProgramInstance( ProgramInstance programInstance )
+    {
+        this.programInstance = programInstance;
+    }
+
+    public String getValue()
+    {
+        return value;
+    }
+
+    public void setValue( String value )
+    {
+        this.value = value;
+    }
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueService.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2004-2010, 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.programattributevalue;
+
+import java.util.Collection;
+
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramInstance;
+
+/**
+ * @author Chau Thu Tran
+ * @version $Id ProgramAttributeValueService.java 2010-10-30 19:57:20Z $
+ */
+public interface ProgramAttributeValueService
+{
+    String ID = ProgramAttributeValueService.class.getName();
+
+    void saveProgramAttributeValue( ProgramAttributeValue programAttributeValue );
+
+    void updateProgramAttributeValue( ProgramAttributeValue programAttributeValue );
+
+    void deleteProgramAttributeValue( ProgramAttributeValue programAttributeValue );
+    
+    void deleteProgramAttributeValues( ProgramAttribute programAttribute );
+    
+    void deleteProgramAttributeValues( ProgramInstance programInstance );
+    
+    ProgramAttributeValue getProgramAttributeValue( ProgramInstance programInstance, ProgramAttribute programAttribute );
+
+    Collection<ProgramAttributeValue> getAllProgramAttributeValues();
+    
+    
+    Collection<ProgramAttributeValue> getProgramAttributeValues( ProgramInstance progranInstance );
+
+    Collection<ProgramAttributeValue> getProgramAttributeValues( ProgramAttribute programAttribute );
+    
+    Collection<ProgramAttributeValue> searchProgramAttributeValues( ProgramAttribute programAttribute, String searchText );   
+    
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueStore.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2004-2010, 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.programattributevalue;
+
+import java.util.Collection;
+
+import org.hisp.dhis.common.GenericStore;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramInstance;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version ProgramAttributeValueStore.java Oct 30, 2010 11:06:16 PM
+ */
+public interface ProgramAttributeValueStore
+    extends GenericStore<ProgramAttributeValue>
+{
+
+    void saveVoid( ProgramAttributeValue programAttributeValue );
+
+    int delete( ProgramAttribute programAttribute );
+    
+    int delete( ProgramInstance programInstance );
+    
+    ProgramAttributeValue get( ProgramInstance programInstance, ProgramAttribute programAttribute );
+    
+    Collection<ProgramAttributeValue> get( ProgramInstance progranInstance );
+
+    Collection<ProgramAttributeValue> get( ProgramAttribute programAttribute );
+    
+    Collection<ProgramAttributeValue> search( ProgramAttribute programAttribute, String searchText );   
+    
+}

=== 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	2010-10-30 05:54:51 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2010-11-09 02:09:53 +0000
@@ -121,7 +121,6 @@
     public int createPatient( Patient patient, Integer representativeId, Integer relationshipTypeId,
         List<PatientAttributeValue> patientAttributeValues )
     {
-
         int patientid = savePatient( patient );
 
         for ( PatientAttributeValue pav : patientAttributeValues )

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramAttributeOptionService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramAttributeOptionService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramAttributeOptionService.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2004-2010, 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.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version DefaultProgramAttributeOptionService.java Nov 1, 2010 3:04:33 PM
+ */
+
+@Transactional
+public class DefaultProgramAttributeOptionService
+    implements ProgramAttributeOptionService
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramAttributeOptionStore programAttributeOptionStore;
+
+    public void setProgramAttributeOptionStore( ProgramAttributeOptionStore programAttributeOptionStore )
+    {
+        this.programAttributeOptionStore = programAttributeOptionStore;
+    }
+
+    // -------------------------------------------------------------------------
+    // ProgramAttribute implementation
+    // -------------------------------------------------------------------------
+
+    public int addProgramAttributeOption( ProgramAttributeOption option )
+    {
+        return programAttributeOptionStore.save( option );
+    }
+
+    public void deleteProgramAttributeOption( ProgramAttributeOption option )
+    {
+        programAttributeOptionStore.delete( option );
+    }
+
+    public void updateProgramAttributeOption( ProgramAttributeOption option )
+    {
+        programAttributeOptionStore.update( option );
+    }
+
+    public ProgramAttributeOption get( ProgramAttribute programAttribute, String name )
+    {
+        return programAttributeOptionStore.get( programAttribute, name );
+    }
+
+    public ProgramAttributeOption get( int id )
+    {
+        return programAttributeOptionStore.get( id );
+    }
+
+    public Collection<ProgramAttributeOption> get( ProgramAttribute programAttribute )
+    {
+        return programAttributeOptionStore.get( programAttribute );
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramAttributeService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramAttributeService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramAttributeService.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2004-2010, 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.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version DefaultProgramAttributeService.java Oct 30, 2010 11:18:15 PM
+ */
+
+@Transactional
+public class DefaultProgramAttributeService
+    implements ProgramAttributeService
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private ProgramAttributeStore programAttributeStore;
+
+    public void setProgramAttributeStore( ProgramAttributeStore programAttributeStore )
+    {
+        this.programAttributeStore = programAttributeStore;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation methods
+    // -------------------------------------------------------------------------
+
+    public int saveProgramAttribute( ProgramAttribute programAttribute )
+    {
+        return programAttributeStore.save( programAttribute );
+    }
+
+    public void deleteProgramAttribute( ProgramAttribute programAttribute )
+    {
+        programAttributeStore.delete( programAttribute );
+    }
+
+    public void updateProgramAttribute( ProgramAttribute programAttribute )
+    {
+        programAttributeStore.update( programAttribute );
+    }
+
+    public ProgramAttribute getProgramAttribute( int id )
+    {
+        return programAttributeStore.get( id );
+    }
+
+    public ProgramAttribute getProgramAttributeByName( String name )
+    {
+        return programAttributeStore.getByName( name );
+    }
+
+    public Collection<ProgramAttribute> getAllProgramAttributes()
+    {
+        return programAttributeStore.getAll();
+    }
+
+    public Collection<ProgramAttribute> getProgramAttributeByValueType( String valueType )
+    {
+        return programAttributeStore.getByValueType( valueType );
+    }
+    
+}

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramAttributeOptionStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramAttributeOptionStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramAttributeOptionStore.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2004-2010, 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.criterion.Restrictions;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeOption;
+import org.hisp.dhis.program.ProgramAttributeOptionStore;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version HibernateProgramAttributeOptionStore.java Nov 1, 2010 3:07:17 PM
+ */
+public class HibernateProgramAttributeOptionStore
+    extends HibernateGenericStore<ProgramAttributeOption>
+    implements ProgramAttributeOptionStore
+{
+
+    public ProgramAttributeOption get( ProgramAttribute programAttribute, String name )
+    {
+        return (ProgramAttributeOption) getCriteria( Restrictions.eq( "name", name ),
+            Restrictions.eq( "programAttribute", programAttribute ) ).uniqueResult();
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public Collection<ProgramAttributeOption> get( ProgramAttribute programAttribute )
+    {
+        return getCriteria( Restrictions.eq( "programAttribute", programAttribute ) ).list();
+    }
+
+}

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramAttributeStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramAttributeStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramAttributeStore.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2004-2010, 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.criterion.Restrictions;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeStore;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version HibernateProgramAttributeStore.java Oct 30, 2010 11:41:58 PM
+ */
+public class HibernateProgramAttributeStore
+    extends HibernateGenericStore<ProgramAttribute>
+    implements ProgramAttributeStore
+{
+    @SuppressWarnings("unchecked")
+    public Collection<ProgramAttribute> getByValueType( String valueType )
+    {
+        return getCriteria( Restrictions.eq( "valueType", valueType ) ).list();
+    }
+}

=== added directory 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue'
=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/DefaultProgramAttributeValueService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/DefaultProgramAttributeValueService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/DefaultProgramAttributeValueService.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2004-2010, 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.programattributevalue;
+
+import java.util.Collection;
+
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramInstance;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version DefaultProgramAttributeValue.java Oct 31, 2010 6:09:03 PM
+ */
+
+@Transactional
+public class DefaultProgramAttributeValueService
+    implements ProgramAttributeValueService
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private ProgramAttributeValueStore programAttributeValueStore;
+
+    public void setProgramAttributeValueStore( ProgramAttributeValueStore programAttributeValueStore )
+    {
+        this.programAttributeValueStore = programAttributeValueStore;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation methods
+    // -------------------------------------------------------------------------
+
+    public void saveProgramAttributeValue( ProgramAttributeValue programAttributeValue )
+    {
+        if ( programAttributeValue.getValue() != null )
+        {
+            programAttributeValueStore.saveVoid( programAttributeValue );
+        }
+    }
+
+    public void updateProgramAttributeValue( ProgramAttributeValue programAttributeValue )
+    {
+        programAttributeValueStore.update( programAttributeValue );
+    }
+
+    public void deleteProgramAttributeValue( ProgramAttributeValue programAttributeValue )
+    {
+        programAttributeValueStore.delete( programAttributeValue );
+    }
+
+    public void deleteProgramAttributeValues( ProgramAttribute programAttribute )
+    {
+        programAttributeValueStore.delete( programAttribute );
+    }
+
+    public void deleteProgramAttributeValues( ProgramInstance programInstance )
+    {
+        programAttributeValueStore.delete( programInstance );
+    }
+
+    public ProgramAttributeValue getProgramAttributeValue( ProgramInstance programInstance,
+        ProgramAttribute programAttribute )
+    {
+        return programAttributeValueStore.get( programInstance, programAttribute );
+    }
+
+    public Collection<ProgramAttributeValue> getAllProgramAttributeValues()
+    {
+        return programAttributeValueStore.getAll();
+    }
+
+    public Collection<ProgramAttributeValue> getProgramAttributeValues( ProgramInstance progranInstance )
+    {
+        return programAttributeValueStore.get( progranInstance );
+    }
+
+    public Collection<ProgramAttributeValue> getProgramAttributeValues( ProgramAttribute programAttribute )
+    {
+        return programAttributeValueStore.get( programAttribute );
+    }
+
+    public Collection<ProgramAttributeValue> searchProgramAttributeValues( ProgramAttribute programAttribute,
+        String searchText )
+    {
+        return programAttributeValueStore.search( programAttribute, searchText );
+    }
+
+}

=== added directory 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/hibernate'
=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/hibernate/HibernateProgramAttributeValueStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/hibernate/HibernateProgramAttributeValueStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/hibernate/HibernateProgramAttributeValueStore.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2004-2010, 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.programattributevalue.hibernate;
+
+import java.util.Collection;
+
+import org.hibernate.Query;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.programattributevalue.ProgramAttributeValue;
+import org.hisp.dhis.programattributevalue.ProgramAttributeValueStore;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version HibernateProgramAttributeValueStore.java Oct 31, 2010 11:20:19 PM
+ */
+public class HibernateProgramAttributeValueStore
+    extends HibernateGenericStore<ProgramAttributeValue>
+    implements ProgramAttributeValueStore
+{
+    public void saveVoid( ProgramAttributeValue programAttributeValue )
+    {
+        sessionFactory.getCurrentSession().save( programAttributeValue );
+    }
+
+    public int delete( ProgramAttribute programAttribute ){
+        
+        Query query = getQuery( "delete from ProgramAttributeValue where programAttribute = :programAttribute" );
+        query.setEntity( "programAttribute", programAttribute );
+        
+        return query.executeUpdate();
+    }
+
+    public int delete( ProgramInstance programInstance ){
+        Query query = getQuery( "delete from ProgramAttributeValue where programInstance = :programInstance" );
+        query.setEntity( "programInstance", programInstance );
+        
+        return query.executeUpdate();
+    }
+
+    public ProgramAttributeValue get( ProgramInstance programInstance, ProgramAttribute programAttribute ){
+        return (ProgramAttributeValue) getCriteria( Restrictions.eq( "programInstance", programInstance ),
+            Restrictions.eq( "programAttribute", programAttribute ) ).uniqueResult();
+    }
+    
+    public Collection<ProgramAttributeValue> get( ProgramInstance progranInstance ){
+        return getCriteria( Restrictions.eq( "progranInstance", progranInstance ) ).list();
+    }
+
+    public Collection<ProgramAttributeValue> get( ProgramAttribute programAttribute ){
+        return getCriteria( Restrictions.eq( "programAttribute", programAttribute ) ).list();
+    }
+
+    public Collection<ProgramAttributeValue> search( ProgramAttribute programAttribute, String searchText ){
+        return getCriteria( Restrictions.eq( "programAttribute", programAttribute ),
+            Restrictions.ilike( "value", "%" + searchText + "%" ) ).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	2010-10-29 12:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2010-11-09 02:09:53 +0000
@@ -9,7 +9,9 @@
 	<!-- Store definitions -->
 	
 	<bean id="org.hisp.dhis.caseaggregation.CaseAggregationMappingStore"
-    class="org.hisp.dhis.caseaggregation.hibernate.HibernateCaseAggregationMappingStore"/>
+    class="org.hisp.dhis.caseaggregation.hibernate.HibernateCaseAggregationMappingStore">
+    	<property name="sessionFactory" ref="sessionFactory" />
+    </bean>
 	
 	<bean id="org.hisp.dhis.relationship.RelationshipStore"
 		class="org.hisp.dhis.relationship.hibernate.HibernateRelationshipStore">
@@ -102,7 +104,25 @@
 	 <property name="clazz" value="org.hisp.dhis.program.ProgramStageDataElementValidation" />
 	 <property name="sessionFactory" ref="sessionFactory" />
    </bean>
-
+   
+   <bean id="org.hisp.dhis.program.ProgramAttributeStore"
+		class="org.hisp.dhis.program.hibernate.HibernateProgramAttributeStore">
+		<property name="clazz" value="org.hisp.dhis.program.ProgramAttribute" />
+		<property name="sessionFactory" ref="sessionFactory" />
+	</bean>
+
+	<bean id="org.hisp.dhis.programattributevalue.ProgramAttributeValueStore"
+		class="org.hisp.dhis.programattributevalue.hibernate.HibernateProgramAttributeValueStore">
+		<property name="clazz" value="org.hisp.dhis.programattributevalue.ProgramAttributeValue" />
+		<property name="sessionFactory" ref="sessionFactory" />
+	</bean>
+
+  	<bean id="org.hisp.dhis.program.ProgramAttributeOptionStore"
+    class="org.hisp.dhis.program.hibernate.HibernateProgramAttributeOptionStore">
+     <property name="clazz" value="org.hisp.dhis.program.ProgramAttributeOption"/>
+     <property name="sessionFactory" ref="sessionFactory"/>
+   </bean>
+   
 	<!-- Service definitions -->
 	
 	<bean id="org.hisp.dhis.activityplan.ActivityPlanService"
@@ -226,6 +246,23 @@
 	  		ref="org.hisp.dhis.program.ProgramStageDataElementValidationStore" />
   	</bean>
   
+  	<bean id="org.hisp.dhis.program.ProgramAttributeService" class="org.hisp.dhis.program.DefaultProgramAttributeService">
+		<property name="programAttributeStore" ref="org.hisp.dhis.program.ProgramAttributeStore" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.programattributevalue.ProgramAttributeValueService"
+		class="org.hisp.dhis.programattributevalue.DefaultProgramAttributeValueService">
+		<property name="programAttributeValueStore"
+			ref="org.hisp.dhis.programattributevalue.ProgramAttributeValueStore" />
+	</bean>
+  
+    <bean id="org.hisp.dhis.program.ProgramAttributeOptionService"
+     class="org.hisp.dhis.program.DefaultProgramAttributeOptionService">
+     <property name="programAttributeOptionStore"
+      ref="org.hisp.dhis.program.ProgramAttributeOptionStore"/>
+   </bean>
+  
 	<!-- Aggregation engine -->
 
 	<bean

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramAttribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramAttribute.hbm.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramAttribute.hbm.xml	2010-11-09 02:09:53 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>
+
+<hibernate-mapping>
+  <class name="org.hisp.dhis.program.ProgramAttribute" table="programattribute">
+    
+    <id name="id" column="programattributeid">
+      <generator class="native"/>
+    </id>   
+    
+    <property name="name" not-null="true" unique="true"/>
+    
+    <property name="description"/>  
+    
+    <property name="valueType" not-null="true" />
+  
+  	<set name="attributeOptions" lazy="false" cascade="all">
+      <key column="programattributeid"/>      
+      <one-to-many class="org.hisp.dhis.program.ProgramAttributeOption" />
+    </set>
+    
+  </class>
+</hibernate-mapping>

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramAttributeOption.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramAttributeOption.hbm.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramAttributeOption.hbm.xml	2010-11-09 02:09:53 +0000
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>
+
+<hibernate-mapping>
+  <class name="org.hisp.dhis.program.ProgramAttributeOption" table="programattributeoption">    
+    <id name="id" column="programattributeoptionid">
+      <generator class="native"/>
+    </id>   
+    
+    <property name="name" not-null="true"  length="160"/>
+    
+    <many-to-one name="programAttribute" column="programattributeid" 
+    	class="org.hisp.dhis.program.ProgramAttribute"
+   		foreign-key="fk_programattributeoption_programattributeid" lazy="false" insert="true" />
+	
+  </class>
+</hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml	2009-10-28 19:47:26 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml	2010-11-09 02:09:53 +0000
@@ -29,5 +29,11 @@
       <one-to-many class="org.hisp.dhis.program.ProgramStageInstance"/>
     </set>    	
 	
+	<set name="attributes" table="programinstance_attributes">
+		<key column="programinstanceid" />
+		<many-to-many class="org.hisp.dhis.program.ProgramAttribute"
+			column="programattributeid" foreign-key="fk_program_programattributeid" />
+	</set>
+		
   </class>
 </hibernate-mapping>

=== added directory 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/programattributevalue'
=== added directory 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/programattributevalue/hibernate'
=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/programattributevalue/hibernate/ProgramAttributeValue.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/programattributevalue/hibernate/ProgramAttributeValue.hbm.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/programattributevalue/hibernate/ProgramAttributeValue.hbm.xml	2010-11-09 02:09:53 +0000
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC 
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>
+
+<hibernate-mapping>
+    <class name="org.hisp.dhis.programattributevalue.ProgramAttributeValue" table="programattributevalue">
+    
+      <composite-id>
+        <key-many-to-one name="programAttribute" class="org.hisp.dhis.program.ProgramAttribute"
+          column="programattributeid" foreign-key="fk_programattributevalue_programattributeid"/>      
+        <key-many-to-one name="programInstance" class="org.hisp.dhis.program.ProgramInstance"
+          column="programinstanceid" foreign-key="fk_programattributevalue_programinstanceid"/>
+      </composite-id>     
+	  
+      <property name="value"/>
+      
+      <many-to-one name="programAttributeOption"
+		class="org.hisp.dhis.program.ProgramAttributeOption" column="programattributeoptionid"
+		foreign-key="fk_programAttributeValue_programAttributeOption" />       
+        
+  </class>
+</hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java	2010-08-20 07:54:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java	2010-11-09 02:09:53 +0000
@@ -187,7 +187,7 @@
             programInstance, programStage );
 
         DataElement dataElement = dataElementService.getDataElement( dataElementId );
-
+System.out.println("\n\n ==== save value : " + value );
         if ( value != null && value.trim().length() == 0 )
         {
             value = null;

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2010-11-05 07:31:24 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2010-11-09 02:09:53 +0000
@@ -118,6 +118,7 @@
 OnChange				= On-change
 Survey					= Survey
 Relative				= Relative
+FinancialApril			= Financial-April
 
 format.Daily.startDate		= yyyy-MM-dd
 format.Daily.endDate		=
@@ -139,6 +140,8 @@
 format.Survey.endDate		=
 format.Relative.startDate	= yyyy-MM-dd '- '
 format.Relative.endDate		= yyyy-MM-dd
+format.FinancialApril.startDate	= dd MMM yyyy 'to '
+format.FinancialApril.endDate= dd MMM yyyy
 
 #-- Months and weeks ----------------------------------------------------------#
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ProgramEnrollmentSelectAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ProgramEnrollmentSelectAction.java	2009-11-25 08:30:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ProgramEnrollmentSelectAction.java	2010-11-09 02:09:53 +0000
@@ -33,6 +33,8 @@
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.patient.state.SelectedStateManager;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeService;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramService;
 
@@ -72,6 +74,13 @@
         this.programService = programService;
     }
 
+    private ProgramAttributeService programAttributeService;
+
+    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -117,7 +126,7 @@
     public Collection<Program> getPrograms()
     {
         return programs;
-    }   
+    }
 
     private ProgramInstance programInstance;
 
@@ -131,6 +140,13 @@
         this.programInstance = programInstance;
     }
 
+    private Collection<ProgramAttribute> attributes;
+
+    public Collection<ProgramAttribute> getAttributes()
+    {
+        return attributes;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -201,6 +217,12 @@
             return SUCCESS;
         }
 
+        // ---------------------------------------------------------------------
+        // Load Program Attribute
+        // ---------------------------------------------------------------------
+
+        attributes = programAttributeService.getAllProgramAttributes();
+
         return PROGRAM_ENROLLMENT_FORM;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentAction.java	2009-10-27 09:52:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentAction.java	2010-11-09 02:09:53 +0000
@@ -29,14 +29,32 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
-
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.patient.state.SelectedStateManager;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttributeOptionService;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeOption;
+import org.hisp.dhis.program.ProgramAttributeOptionService;
+import org.hisp.dhis.program.ProgramAttributeService;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.programattributevalue.ProgramAttributeValue;
+import org.hisp.dhis.programattributevalue.ProgramAttributeValueService;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.log4j.Level;
+import org.apache.struts2.ServletActionContext;
 
 import com.opensymphony.xwork2.Action;
 
@@ -47,10 +65,12 @@
 public class RemoveEnrollmentAction
     implements Action
 {
+    public static final String PREFIX_ATTRIBUTE = "attr";
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-    
+
     private PatientService patientService;
 
     public void setPatientService( PatientService patientService )
@@ -77,7 +97,28 @@
     public void setSelectedStateManager( SelectedStateManager selectedStateManager )
     {
         this.selectedStateManager = selectedStateManager;
-    }   
+    }
+
+    private ProgramAttributeService programAttributeService;
+
+    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
+    private ProgramAttributeOptionService programAttributeOptionService;
+
+    public void setProgramAttributeOptionService( ProgramAttributeOptionService programAttributeOptionService )
+    {
+        this.programAttributeOptionService = programAttributeOptionService;
+    }
+
+    private ProgramAttributeValueService programAttributeValueService;
+
+    public void setProgramAttributeValueService( ProgramAttributeValueService programAttributeValueService )
+    {
+        this.programAttributeValueService = programAttributeValueService;
+    }
 
     // -------------------------------------------------------------------------
     // Input/Output
@@ -100,15 +141,15 @@
     public Patient getPatient()
     {
         return patient;
-    }   
-   
+    }
+
     public void setPatient( Patient patient )
     {
         this.patient = patient;
     }
 
     private ProgramInstance programInstance;
-    
+
     public ProgramInstance getProgramInstance()
     {
         return programInstance;
@@ -136,14 +177,14 @@
     public void setProgramInstanceId( Integer programInstanceId )
     {
         this.programInstanceId = programInstanceId;
-    }    
+    }
 
     private Collection<Program> programs = new ArrayList<Program>();
 
     public Collection<Program> getPrograms()
     {
         return programs;
-    }    
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -152,32 +193,116 @@
     public String execute()
         throws Exception
     {
-
         patient = selectedStateManager.getSelectedPatient();
 
-        Program program = selectedStateManager.getSelectedProgram();       
+        Program program = selectedStateManager.getSelectedProgram();
 
         programs = programService.getAllPrograms();
-        
-        Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient, program, false );
-        
-        if( programInstances.iterator().hasNext() )
+
+        Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient, program,
+            false );
+
+        if ( programInstances.iterator().hasNext() )
         {
             programInstance = programInstances.iterator().next();
         }
-        
+
         if ( programInstance != null )
-        {           
-            programInstance.setEndDate( new Date() );            
+        {
+            programInstance.setEndDate( new Date() );
             programInstance.setCompleted( true );
 
-            programInstanceService.updateProgramInstance( programInstance );            
-            
+            programInstanceService.updateProgramInstance( programInstance );
+
             patient.getPrograms().remove( program );
             patientService.updatePatient( patient );
-            
+
             selectedStateManager.clearSelectedProgram();
-        }      
+        }
+
+        // --------------------------------------------------------------------------------------------------------
+        // Save Program Attributes
+        // -----------------------------------------------------------------------------------------------------
+
+        HttpServletRequest request = ServletActionContext.getRequest();
+        System.out.println( "\n\n ++++++++++++ request : " + request );
+
+        Collection<ProgramAttribute> attributes = programAttributeService.getAllProgramAttributes();
+
+        Set<ProgramAttribute> programAttributes = new HashSet<ProgramAttribute>();
+
+        if ( attributes != null && attributes.size() > 0 )
+        {
+            programInstance.getAttributes().clear();
+
+            // Save other attributes
+            for ( ProgramAttribute attribute : attributes )
+            {
+                String value = request.getParameter( RemoveEnrollmentAction.PREFIX_ATTRIBUTE + attribute.getId() );
+                System.out.println( "\n\n ++++++++++++ attr : " + RemoveEnrollmentAction.PREFIX_ATTRIBUTE
+                    + attribute.getId() );
+                System.out.println( "\n\n value : " + value );
+
+                if ( StringUtils.isNotBlank( value ) )
+                {
+                    programAttributes.add( attribute );
+
+                    ProgramAttributeValue attributeValue = programAttributeValueService.getProgramAttributeValue(
+                        programInstance, attribute );
+
+                    // attributeValue is not exist
+                    if ( attributeValue == null )
+                    {
+                        attributeValue = new ProgramAttributeValue();
+                        attributeValue.setProgramInstance( programInstance );
+                        attributeValue.setProgramAttribute( attribute );
+                        
+                        if ( ProgramAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
+                        {
+                            ProgramAttributeOption option = programAttributeOptionService.get( NumberUtils.toInt( value, 0 ) );
+                            if ( option != null )
+                            {
+                                attributeValue.setProgramAttributeOption( option );
+                                attributeValue.setValue( option.getName() );
+                            }
+                        }
+                        else
+                        {
+                            attributeValue.setValue( value.trim() );
+                        }
+
+                        // save values
+                        programAttributeValueService.saveProgramAttributeValue( attributeValue );
+                        
+                    }
+                    // attributeValue is exist
+                    else
+                    {
+                        if ( ProgramAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
+                        {
+                            ProgramAttributeOption option = programAttributeOptionService.get( NumberUtils.toInt(
+                                value, 0 ) );
+                            if ( option != null )
+                            {
+                                attributeValue.setProgramAttributeOption( option );
+                                attributeValue.setValue( option.getName() );
+                            }
+                        }
+                        else
+                        {
+                            attributeValue.setValue( value.trim() );
+                        }
+                    }
+
+                    // update values
+                    programAttributeValueService.updateProgramAttributeValue( attributeValue );
+                }
+            }
+        }
+
+        programInstance.setAttributes( programAttributes );
+
+        programInstanceService.updateProgramInstance( programInstance );
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SaveProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SaveProgramEnrollmentAction.java	2010-05-17 02:59:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SaveProgramEnrollmentAction.java	2010-11-09 02:09:53 +0000
@@ -30,12 +30,13 @@
 import java.util.Collection;
 import java.util.Date;
 
-import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.patient.state.SelectedStateManager;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeService;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramService;
@@ -92,6 +93,13 @@
         this.selectedStateManager = selectedStateManager;
     }
 
+    private ProgramAttributeService programAttributeService;
+
+    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -188,11 +196,11 @@
         return message;
     }
 
-    private I18n i18n;
+    private Collection<ProgramAttribute> attributes;
 
-    public void setI18n( I18n i18n )
+    public Collection<ProgramAttribute> getAttributes()
     {
-        this.i18n = i18n;
+        return attributes;
     }
 
     // -------------------------------------------------------------------------
@@ -260,7 +268,6 @@
 
             for ( ProgramStageInstance programStageInstance : programInstance.getProgramStageInstances() )
             {
-
                 Date dueDate = DateUtils.getDateAfterAddition( format.parseDate( dateOfIncident ), programStageInstance
                     .getProgramStage().getMinDaysFromStart() );
 
@@ -271,7 +278,9 @@
                 programStageInstances.add( programStageInstance );
             }
         }
-
+        
+        attributes = programAttributeService.getAllProgramAttributes();
+        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ShowAddPatientFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ShowAddPatientFormAction.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ShowAddPatientFormAction.java	2010-11-09 02:09:53 +0000
@@ -27,8 +27,11 @@
 
 package org.hisp.dhis.patient.action.patient;
 
+import java.text.SimpleDateFormat;
 import java.util.Collection;
+import java.util.Date;
 
+import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeGroup;
@@ -39,10 +42,6 @@
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
 
 import com.opensymphony.xwork2.Action;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
 
 /**
  * @author Abyot Asalefew Gizaw
@@ -61,13 +60,6 @@
     {
         this.selectionManager = selectionManager;
     }
-
-    private PatientIdentifierService patientIdentifierService;
-
-    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
-    {
-        this.patientIdentifierService = patientIdentifierService;
-    }
     
     private PatientAttributeService patientAttributeService;
     

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAttributeAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAttributeAction.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.program;
+
+import java.util.List;
+
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeOption;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeOption;
+import org.hisp.dhis.program.ProgramAttributeOptionService;
+import org.hisp.dhis.program.ProgramAttributeService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version AddProgramAttributeAction.java Oct 31, 2010 11:48:29 PM
+ */
+public class AddProgramAttributeAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private ProgramAttributeService programAttributeService;
+
+    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private String name;
+
+    private String description;
+
+    private String valueType;
+
+    private List<String> attrOptions;
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    public void setValueType( String valueType )
+    {
+        this.valueType = valueType;
+    }
+
+    public void setAttrOptions( List<String> attrOptions )
+    {
+        this.attrOptions = attrOptions;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        ProgramAttribute programAttribute = new ProgramAttribute();
+
+        programAttribute.setName( name );
+        programAttribute.setDescription( description );
+        programAttribute.setValueType( valueType );
+
+        if( ProgramAttribute.TYPE_COMBO.equalsIgnoreCase( valueType ) )
+        {
+            ProgramAttributeOption opt  = null;
+            for( String optionName : attrOptions )
+            {
+                opt = new ProgramAttributeOption();
+                opt.setName( optionName );
+                opt.setProgramAttribute( programAttribute );
+                programAttribute.addAttributeOptions( opt );
+//                programAttributeOptionService.addProgramAttributeOption( opt );
+            }
+        }
+
+        programAttributeService.saveProgramAttribute( programAttribute );
+        
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAttributeAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAttributeAction.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.program;
+
+import java.util.Date;
+
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version AddProgramAttributeAction.java Oct 31, 2010 11:48:29 PM
+ */
+public class GetProgramAttributeAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private ProgramAttributeService programAttributeService;
+
+    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    private ProgramAttribute programAttribute;
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    public ProgramAttribute getProgramAttribute()
+    {
+        return programAttribute;
+    }
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        programAttribute = programAttributeService.getProgramAttribute( id );
+        
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAttributeListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAttributeListAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAttributeListAction.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.program;
+
+import java.util.Collection;
+
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version GetProgramAttributeListAction.java Nov 1, 2010 12:06:33 AM
+ */
+public class GetProgramAttributeListAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private ProgramAttributeService programAttributeService;
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private Collection<ProgramAttribute> programAttributes;
+
+    // -------------------------------------------------------------------------
+    // Getter
+    // -------------------------------------------------------------------------
+    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
+    public Collection<ProgramAttribute> getProgramAttributes()
+    {
+        return programAttributes;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        programAttributes = programAttributeService.getAllProgramAttributes();
+        
+        return SUCCESS;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/RemoveProgramAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/RemoveProgramAttributeAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/RemoveProgramAttributeAction.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.program;
+
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version AddProgramAttributeAction.java Oct 31, 2010 11:48:29 PM
+ */
+public class RemoveProgramAttributeAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private ProgramAttributeService programAttributeService;
+
+    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+    
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        ProgramAttribute programAttribute = programAttributeService.getProgramAttribute( id );
+
+        programAttributeService.deleteProgramAttribute( programAttribute );
+
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAttributeAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAttributeAction.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.program;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeOption;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeOption;
+import org.hisp.dhis.program.ProgramAttributeOptionService;
+import org.hisp.dhis.program.ProgramAttributeService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version AddProgramAttributeAction.java Oct 31, 2010 11:48:29 PM
+ */
+public class UpdateProgramAttributeAction
+    implements Action
+{
+    public static final String PREFIX_ATTRIBUTE_OPTION = "attrOption";
+
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private ProgramAttributeService programAttributeService;
+
+    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
+    private ProgramAttributeOptionService programAttributeOptionService;
+
+    public void setProgramAttributeOptionService( ProgramAttributeOptionService programAttributeOptionService )
+    {
+        this.programAttributeOptionService = programAttributeOptionService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    private String name;
+
+    private String description;
+
+    private String valueType;
+
+    private List<String> attrOptions;
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    public void setValueType( String valueType )
+    {
+        this.valueType = valueType;
+    }
+
+    public void setAttrOptions( List<String> attrOptions )
+    {
+        this.attrOptions = attrOptions;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        ProgramAttribute programAttribute = programAttributeService.getProgramAttribute( id );
+
+        programAttribute.setName( name );
+        programAttribute.setDescription( description );
+        programAttribute.setValueType( valueType );
+        
+        HttpServletRequest request = ServletActionContext.getRequest();
+        
+        Collection<ProgramAttributeOption> attributeOptions = programAttributeOptionService.get( programAttribute );
+        
+        if ( attributeOptions != null && attributeOptions.size() > 0 )
+        {
+            String value = null;
+            for( ProgramAttributeOption option : attributeOptions )
+            {
+                value = request.getParameter( PREFIX_ATTRIBUTE_OPTION + option.getId() );
+                if ( StringUtils.isNotBlank( value ) )
+                {
+                    option.setName( value.trim() );
+                    programAttributeOptionService.updateProgramAttributeOption( option );
+                }
+            }
+        }
+        
+        if( attrOptions != null )
+        {
+            ProgramAttributeOption opt  = null;
+            for( String optionName : attrOptions )
+            {
+                opt = programAttributeOptionService.get( programAttribute, optionName );
+                if( opt == null )
+                {
+                    opt = new ProgramAttributeOption();
+                    opt.setName( optionName );
+                    opt.setProgramAttribute( programAttribute );
+                    programAttribute.addAttributeOptions( opt );
+                }
+            }
+        }
+        
+        programAttributeService.updateProgramAttribute( programAttribute );
+        
+        
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ValidateProgramAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ValidateProgramAttributeAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ValidateProgramAttributeAction.java	2010-11-09 02:09:53 +0000
@@ -0,0 +1,113 @@
+package org.hisp.dhis.patient.action.program;
+
+/*
+
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version ValidateProgramAttributeAction.java Nov 01, 2010 11:48:29 AM
+ */
+
+public class ValidateProgramAttributeAction
+    implements Action
+{
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramAttributeService programAttributeService;
+
+    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    private String name;
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    private String message;
+
+    public String getMessage()
+    {
+        return message;
+    }
+
+    private I18n i18n;
+
+    public void setI18n( I18n i18n )
+    {
+        this.i18n = i18n;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        name = name.trim();
+
+        ProgramAttribute match = programAttributeService.getProgramAttributeByName( name );
+
+        if ( match != null && (id == null || !match.getId().equals( id )) )
+        {
+            System.out.println( "\n match.id : " + match.getId() );
+            message = i18n.getString( "duplicate_names" );
+
+            return ERROR;
+        }
+
+        message = i18n.getString( "everything_is_ok" );
+
+        return SUCCESS;
+
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2010-11-09 02:09:53 +0000
@@ -457,8 +457,6 @@
 		scope="prototype">
 		<property name="selectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		<property name="patientIdentifierService"
-			ref="org.hisp.dhis.patient.PatientIdentifierService" />
 		<property name="patientAttributeService">
 			<ref bean="org.hisp.dhis.patient.PatientAttributeService" />
 		</property>
@@ -517,6 +515,7 @@
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="selectedStateManager"
 			ref="org.hisp.dhis.patient.state.SelectedStateManager" />
+		<property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.patient.action.patient.ProgramEnrollmentAction"
@@ -539,6 +538,9 @@
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="selectedStateManager"
 			ref="org.hisp.dhis.patient.state.SelectedStateManager" />
+		<property name="programAttributeService">
+			<ref bean="org.hisp.dhis.program.ProgramAttributeService" />
+		</property>
 	</bean>
 
 	<bean id="org.hisp.dhis.patient.action.patient.SaveDueDateAction"
@@ -555,6 +557,12 @@
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 		<property name="selectedStateManager"
 			ref="org.hisp.dhis.patient.state.SelectedStateManager" />
+		<property name="programAttributeService"
+			ref="org.hisp.dhis.program.ProgramAttributeService" />
+		<property name="programAttributeOptionService"
+			ref="org.hisp.dhis.program.ProgramAttributeOptionService" />
+		<property name="programAttributeValueService"
+			ref="org.hisp.dhis.programattributevalue.ProgramAttributeValueService" />
 	</bean>
 
 	<bean
@@ -610,6 +618,40 @@
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 
+	<!-- Program Attribute -->
+
+	<bean id="org.hisp.dhis.patient.action.program.GetProgramAttributeListAction"
+		class="org.hisp.dhis.patient.action.program.GetProgramAttributeListAction" scope="prototype">
+		<property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+	</bean>
+	
+	<bean id="org.hisp.dhis.patient.action.program.GetProgramAttributeAction"
+		class="org.hisp.dhis.patient.action.program.GetProgramAttributeAction" scope="prototype">
+		<property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+	</bean>
+	
+	<bean id="org.hisp.dhis.patient.action.program.AddProgramAttributeAction"
+		class="org.hisp.dhis.patient.action.program.AddProgramAttributeAction" scope="prototype">
+		<property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+	</bean>
+	
+	<bean id="org.hisp.dhis.patient.action.program.UpdateProgramAttributeAction"
+		class="org.hisp.dhis.patient.action.program.UpdateProgramAttributeAction" scope="prototype">
+		<property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+		<property name="programAttributeOptionService" ref="org.hisp.dhis.program.ProgramAttributeOptionService" />
+	</bean>
+	
+	<bean id="org.hisp.dhis.patient.action.program.RemoveProgramAttributeAction"
+		class="org.hisp.dhis.patient.action.program.RemoveProgramAttributeAction" scope="prototype">
+		<property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.patient.action.program.ValidateProgramAttributeAction"
+		class="org.hisp.dhis.patient.action.program.ValidateProgramAttributeAction"
+		scope="prototype">
+		<property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+	</bean>
+	
 	<!-- Program_OrganisationUnit Association -->
 	
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2010-11-09 02:09:53 +0000
@@ -414,4 +414,10 @@
 letter = Letter
 date_of_incident_invalid = Date of incident is invalid.
 no_min_days_allowed_input_data = Number of min days allowed to input data
-no_max_days_allowed_input_data = Number of max days allowed to input data
\ No newline at end of file
+no_max_days_allowed_input_data = Number of max days allowed to input data
+program_attribute = Program Attribute
+intro_program_attribute = Create, modify and view Program attributes.
+program_attribute_management = Program Attribute Management
+add_new_program_attribute = Add New Program Attribute
+update_new_program_attribute = Update New Program Attribute
+program_infor = Program information

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2010-10-30 05:54:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2010-11-09 02:09:53 +0000
@@ -615,6 +615,78 @@
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
+		<!-- Program Attribute -->
+
+		<action name="programAttribute"
+			class="org.hisp.dhis.patient.action.program.GetProgramAttributeListAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/programAttributeList.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
+			<param name="javascripts">javascript/programAttribute.js</param>
+		</action>
+		
+		<action name="getProgramAttribute"
+			class="org.hisp.dhis.patient.action.program.GetProgramAttributeAction">
+			<result name="success" type="velocity-xml">
+				/dhis-web-maintenance-patient/responseProgramAttribute.vm</result>
+			<param name="onExceptionReturn">plainTextError</param>
+		</action>
+		
+		<action name="removeProgramAttribute"
+			class="org.hisp.dhis.patient.action.program.RemoveProgramAttributeAction">
+			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+			<param name="requiredAuthorities">F_PROGRAM_ATTRIBUTE_DELETE</param>
+		</action>
+
+		<action name="addProgramAttribute"
+			class="org.hisp.dhis.patient.action.program.AddProgramAttributeAction">
+			<result name="success" type="redirect">programAttribute.action
+			</result>
+			<param name="requiredAuthorities">F_PROGRAM_ATTRIBUTE_ADD</param>
+		</action>
+
+		<action name="updateProgramAttribute"
+			class="org.hisp.dhis.patient.action.program.UpdateProgramAttributeAction">
+			<result name="success" type="redirect">programAttribute.action
+			</result>
+			<param name="requiredAuthorities">F_PROGRAM_ATTRIBUTE_UPDATE</param>
+		</action>
+
+		<action name="validateProgramAttribute"
+			class="org.hisp.dhis.patient.action.program.ValidateProgramAttributeAction">
+			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+	  		<result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
+      		<result name="input" type="velocity-json">/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+			<param name="onExceptionReturn">plainTextError</param>
+		</action>
+		
+		<action name="showAddProgramAttributeForm"
+			class="org.hisp.dhis.patient.action.NoAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/addProgramAttributeForm.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
+			<param name="javascripts">javascript/programAttribute.js</param>
+			<param name="requiredAuthorities">F_PROGRAM_ATTRIBUTE_ADD</param>
+		</action>
+
+		<action name="showUpdateProgramAttributeForm"
+			class="org.hisp.dhis.patient.action.program.GetProgramAttributeAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/updateProgramAttributeForm.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
+			<param name="javascripts">javascript/programAttribute.js</param>
+			<param name="requiredAuthorities">F_PROGRAM_ATTRIBUTE_UPDATE</param>
+		</action>
+		
+		
+		<action name="validateProgramAttribute"
+			class="org.hisp.dhis.patient.action.program.ValidateProgramAttributeAction">
+			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+	  		<result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
+      		<result name="input" type="velocity-json">/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+			<param name="onExceptionReturn">plainTextError</param>
+		</action>
+		
 		<!-- Program_OrganisationUnit Association -->
 		
 		<action name="defineProgramAssociationsForm"

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramAttributeForm.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramAttributeForm.vm	2010-11-09 02:09:53 +0000
@@ -0,0 +1,81 @@
+<script>
+	var i18n_remove_option = '$encoder.jsEscape( $i18n.getString( "remove_option" ) , "'") ';
+	var i18n_field_is_required = '$encoder.jsEscape( $i18n.getString( "field_is_required" ) , "'") ';
+	var i18n_at_least_2_option = '$encoder.jsEscape( $i18n.getString( "at_least_2_option" ) , "'") ';
+
+	var isSubmit = true;
+	jQuery(document).ready(	function(){
+			
+			validation( 'addProgramAttributeForm', function(form){
+				if( isSubmit && ATTRIBUTE_OPTION.checkOnSubmit() ) {
+					form.submit();
+				}
+			}, function(){
+				isSubmit = true;
+				jQuery.each($('#addProgramAttributeForm').serializeArray(), function(i, field) {
+					if( field.value == ""){
+						setInnerHTML("attrMessage", i18n_field_is_required);
+						isSubmit = false;
+					}
+				});
+			}); 
+			
+		
+		jQuery("#attributeComboRow").hide();
+			
+		checkValueIsExist( "name", "validateProgramAttribute.action");
+	});		
+</script>
+
+																		
+<h3>$i18n.getString( "add_new_program_attribute" )</h3>
+<form id="addProgramAttributeForm" action="addProgramAttribute.action" method="post" >
+
+<table id="attrTable"> 
+	<thead>
+      <tr>
+        <th colspan="2">$i18n.getString( "program_attribute_details" )</th>
+      </tr>
+    </thead>
+    <tbody>
+	
+    <tr>
+        <td width="20em"><label>$i18n.getString( "name" )</label></td>
+        <td><input type="text" id="name" name="name" style="width:30em"></td>
+        <td></td>
+    </tr>   
+    
+    <tr>
+        <td width="20em" ><label>$i18n.getString( "description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+        <td><input type="text" id="description" name="description" style="width:30em" class="{validate:{required:true,minlength:2}}"></td>
+        <td></td>
+    </tr>
+    
+    <tr>
+        <td width="20em"><label for="valueType">$i18n.getString( "value_type" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+        <td>
+            <select id="valueType" name="valueType" style="min-width:30.5em" onchange="ATTRIBUTE_OPTION.selectValueType(this);">
+                <option value="NUMBER" selected="selected">$i18n.getString( "number" )</option>
+                <option value="TEXT">$i18n.getString( "text" )</option>
+                <option value="YES/NO">$i18n.getString( "yes_no" )</option>
+                <option value="DATE">$i18n.getString( "date" )</option>
+                <option value="COMBO">$i18n.getString( "attribute_combo_type" )</option>
+            </select>
+        </td>
+        <td></td>
+    </tr>  
+    <tr id="attributeComboRow"> 
+    	<td width="20em"><label>$i18n.getString( "attribute_options" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+    	<td ><table id="attrOptionContainer"></table><a href="#" style="text-decoration: none;margin-top: 0.5em"  onclick="ATTRIBUTE_OPTION.addOption()">[ $i18n.getString( "add_more_option" ) ]</a>
+		</td>
+    	<td><span id="attrMessage"  name="attrMessage" style="color:red;"></span></td>
+    </tr>
+     </tbody>
+</table>
+
+<p>
+    <input type="submit" value="$i18n.getString( "add" )" style="width:10em">
+    <input type="button" value="$i18n.getString( "cancel" )" onclick="window.location.href='programAttribute.action'" style="width:10em">
+</p>
+
+</form>   

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm	2010-06-19 15:32:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm	2010-11-09 02:09:53 +0000
@@ -8,6 +8,7 @@
     #introListImgItem( "patientIdentifierType.action" "patient_identifier_type" "patient" )
     #introListImgItem( "relationshipType.action" "relationship_type" "patient" )
     #introListImgItem( "program.action" "program" "program" )
+	#introListImgItem( "programAttribute.action" "program_attribute" "program" )
     #introListImgItem( "caseaggregationMapForm.action" "case_aggregation_mapping" "caseaggregationmapping" )
 	#introListImgItem( "validationCriteria.action" "validation_criteria" "validationcriteria" )
 </ul>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js	2010-11-09 02:09:53 +0000
@@ -661,3 +661,8 @@
 		n_result = n_docel;
 	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
 }
+
+function removeEnrollment(){
+	byId('programEnrollmentForm').action = "removeEnrollment.action";
+	byId('programEnrollmentForm').submit();
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programAttribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programAttribute.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programAttribute.js	2010-11-09 02:09:53 +0000
@@ -0,0 +1,104 @@
+// -----------------------------------------------------------------------------
+// View details
+// -----------------------------------------------------------------------------
+
+function showProgramAttributeDetails( programAttributeId )
+{
+    var request = new Request();
+    request.setResponseTypeXML( 'programAttribute' );
+    request.setCallbackSuccess( programAttributeReceived );
+    request.send( 'getProgramAttribute.action?id=' + programAttributeId );
+}
+
+function programAttributeReceived( programAttributeElement )
+{
+	setInnerHTML( 'idField', getElementValue( programAttributeElement, 'id' ) );
+	setInnerHTML( 'nameField', getElementValue( programAttributeElement, 'name' ) );	
+    setInnerHTML( 'descriptionField', getElementValue( programAttributeElement, 'description' ) );
+    
+    var valueTypeMap = { 'NUMBER':i18n_number, 'BOOL':i18n_yes_no, 'TEXT':i18n_text, 'DATE':i18n_date, 'COMBO':i18n_combo };
+    var valueType = getElementValue( programAttributeElement, 'valueType' );    
+	
+    setInnerHTML( 'valueTypeField', valueTypeMap[valueType] );    
+   
+    showDetails();
+}
+
+// -----------------------------------------------------------------------------
+// Remove Program Attribute
+// -----------------------------------------------------------------------------
+function removeProgramAttribute( programAttributeId, name )
+{
+	removeItem( programAttributeId, name, i18n_confirm_delete, 'removeProgramAttribute.action' );	
+}
+
+ATTRIBUTE_OPTION = 
+{
+	selectValueType : function (this_)
+	{
+		if ( jQuery(this_).val() == "COMBO" )
+		{
+			jQuery("#attributeComboRow").show();
+			if( jQuery("#attrOptionContainer").find("input").length ==0 ) 
+			{
+				ATTRIBUTE_OPTION.addOption();
+				ATTRIBUTE_OPTION.addOption();
+			}
+		}else {
+			jQuery("#attributeComboRow").hide();
+		}
+	},
+	checkOnSubmit : function ()
+	{
+		if( jQuery("#valueType").val() != "COMBO" ) 
+		{
+			jQuery("#attrOptionContainer").children().remove();
+			return true;
+		}else {
+			$("input","#attrOptionContainer").each(function(){ 
+				if( !jQuery(this).val() )
+					jQuery(this).remove();
+			});
+			if( $("input","#attrOptionContainer").length < 2)
+			{
+				alert(i18n_at_least_2_option);
+				return false;
+			}else return true;
+		}
+	},
+	addOption : function ()
+	{
+		jQuery("#attrOptionContainer").append(ATTRIBUTE_OPTION.createInput());
+	},
+	remove : function (this_, optionId)
+	{
+		
+		if( jQuery(this_).siblings("input").attr("name") != "attrOptions")
+		{
+			jQuery.get("removeProgramAttributeOption.action?id="+optionId,function(data){
+				var type  = jQuery(data).find("message").attr("type");
+				alert(type);
+				if( type == "success")
+				{
+					alert("success");
+					jQuery(this_).parent().parent().remove();
+					alert(jQuery(data).text());
+				}else 
+				{
+					alert(jQuery(data).text());
+				}
+			});
+		}else
+		{
+			jQuery(this_).parent().parent().remove();
+		}
+	},
+	removeInAddForm : function(this_)
+	{
+		jQuery(this_).parent().parent().remove();
+	},
+	createInput : function ()
+	{
+		return "<tr><td><input type='text' name='attrOptions' style='width:28em'/><a href='#' style='text-decoration: none; margin-left:0.5em;' title='"+i18n_remove_option+"'  onClick='ATTRIBUTE_OPTION.remove(this,null)'>[ - ]</a></td></tr>";
+	}
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2010-06-19 15:32:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2010-11-09 02:09:53 +0000
@@ -6,6 +6,7 @@
 	<li><a href="patientIdentifierType.action">$i18n.getString( "patient_identifier_type" )</a></li>
 	<li><a href="relationshipType.action">$i18n.getString( "relationship_type" )</a></li>
 	<li><a href="program.action">$i18n.getString( "program" )</a></li>
+	<li><a href="programAttribute.action">$i18n.getString( "program_attribute" )</a></li>
 	<li><a href="caseaggregationMapForm.action">$i18n.getString( "case_aggregation_mapping" )</a></li>
 	<li><a href="validationCriteria.action">$i18n.getString( "validation_criteria" )</a></li>
 </ul>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttributeList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttributeList.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttributeList.vm	2010-11-09 02:09:53 +0000
@@ -0,0 +1,76 @@
+<h3>$i18n.getString( "program_attribute_management" )</h3>
+<table class="mainPageTable">
+	<tr>
+		<td style="vertical-align:top">
+			<table class="listTable">
+			  <col>          
+			  <col width="20">
+			  <col width="20">
+			  <col width="20">     
+			  <tr>
+				<td></td>
+				<td colspan="4" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddProgramAttributeForm.action'" style="width:70px"></td>
+			  </tr>
+			  <tr>            
+				<th>$i18n.getString( "name" )</th>
+				<th colspan="4">$i18n.getString( "operations" )</th>
+			  </tr>
+
+			  <tbody id="list">
+				#foreach( $programAttribute in $programAttributes )
+				  <tr id="tr${programAttribute.id}">
+				  
+					<td>$programAttribute.name</td>                
+					
+					<td style="text-align:center">
+					  <a href="showUpdateProgramAttributeForm.action?id=$programAttribute.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
+					</td>
+					
+					<td style="text-align:center">
+					  <a href="javascript:removeProgramAttribute( '$programAttribute.id', '$encoder.jsEncode( $programAttribute.name )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
+					</td>            
+					
+					<td style="text-align:center">
+					  <a href="javascript:showProgramAttributeDetails( $programAttribute.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( "show_details" )"></a>
+					</td>
+					
+				  </tr>
+				#end
+
+			  </tbody>
+
+			</table>
+		</td>
+		<td style="width:20em; padding-left:2em; vertical-align:top">
+
+			<div id="detailsArea" style="display:none">
+				<div style="float:right">
+					<a href="javascript:hideDetails()" title="$i18n.getString( "hide_details" )"><img src="../images/close.png" alt="$i18n.getString( "hide_details" )"></a>
+				</div>				
+				<p><label>$i18n.getString( "id" ):</label><br><span id="idField"></span></p>
+				<p><label>$i18n.getString( "name" ):</label><br><span id="nameField"></span></p>
+				<p><label>$i18n.getString( "description" ):</label><br><span id="descriptionField"></span></p>
+				<p><label>$i18n.getString( "value_type" ):</label><br><span id="valueTypeField"></span></p>
+			</div>
+
+		</td>
+  </tr>
+</table>
+
+
+<script type="text/javascript">
+	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_patient_attribute" ) , "'" )';
+	var i18n_adding_patient_atttibute_failed = '$encoder.jsEscape( $i18n.getString( "adding_patient_attribute_failed" ), "'")';
+	var i18n_updating_house_hold_failed = '$encoder.jsEscape( $i18n.getString( "updating_patient_attribute_failed" ), "'")';	
+	var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ), "'")';	
+    var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")';
+    var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")';
+    var i18n_number = '$encoder.jsEscape( $i18n.getString( "number" ) , "'")';
+    var i18n_yes_no = '$encoder.jsEscape( $i18n.getString( "yes_no" ) , "'")';
+    var i18n_text = '$encoder.jsEscape( $i18n.getString( "text" ) , "'")';
+    var i18n_date = '$encoder.jsEscape( $i18n.getString( "date" ) , "'")';
+    var i18n_combo = '$encoder.jsEscape( $i18n.getString( "combo" ) , "'")';
+	var i18n_processing = '$encoder.jsEscape( $i18n.getString( "processing" ) , "'")';
+	var i18n_done = '$encoder.jsEscape( $i18n.getString( "done" ) , "'")';
+</script>
+</script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programEnrollmentForm.vm	2010-07-16 10:26:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programEnrollmentForm.vm	2010-11-09 02:09:53 +0000
@@ -26,36 +26,70 @@
 
 <form id="programEnrollmentForm" name="programEnrollmentForm" method="post" action="saveProgramEnrollment.action" onsubmit="return validateProgramEnrollment()">
 
-<table>
+<table width="100%">
     <tr>
         <td style="width:180px"><label for="enrollmentDate" #if($selectedProgram) title="$!selectedProgram.dateOfEnrollmentDescription" #end>$i18n.getString( "date_of_enrollment" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-        <td><input type="text" id="enrollmentDate" name="enrollmentDate" #if( $programInstance ) value="$!format.formatDate( $programInstance.enrollmentDate )" #end>
-        <td>   <i>( $!selectedProgram.dateOfEnrollmentDescription )</i></td>                        
+        <td><input type="text" id="enrollmentDate" name="enrollmentDate" #if( $programInstance ) value="$!format.formatDate( $programInstance.enrollmentDate )" #end> <i>( $!selectedProgram.dateOfEnrollmentDescription )</i></td>
     </tr>
     
     <tr>
         <td style="width:180px"><label for="dateOfIncident" #if($selectedProgram) title="$!selectedProgram.dateOfIncidentDescription" #end>$i18n.getString( "date_of_incident" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-        <td><input type="text" id="dateOfIncident" name="dateOfIncident" #if( $programInstance ) value="$!format.formatDate( $programInstance.dateOfIncident )" #end>
-        <td>  <i>( $!selectedProgram.dateOfIncidentDescription )</i></td>                         
-    </tr>
-    <tr>
+        <td><input type="text" id="dateOfIncident" name="dateOfIncident" #if( $programInstance ) value="$!format.formatDate( $programInstance.dateOfIncident )" #end><i>( $!selectedProgram.dateOfIncidentDescription )</i></td>
+    </tr>
+#if($!programInstance.enrollmentDate) 
+	<tr>
+		<td colspan='3'><h2>$i18n.getString('patient_info')<br><hr/></h2></td>	
+	<tr>
+	#foreach($attribute in $attributes)
+	<tr>
+        <td>$attribute.name</td>
+		<td class="input-column">
+			#if( $attribute.valueType == "YES/NO" )
+				<select id="attr$attribute.id"  name="attr$attribute.id" style="width:100"> 
+					<option value="">[$i18n.getString( "please_select" )]</option>
+					<option value="true">$i18n.getString( "yes" )</option>
+					<option value="false" selected="selected">$i18n.getString( "no" )</option>
+				</select>                
+			#elseif( $attribute.valueType == "DATE" )
+				<input type="text" id="attr$attribute.id"  name="attr$attribute.id">
+				<script type="text/javascript">
+					datePickerValid( 'attr$attribute.id' );
+				</script>                    
+			#elseif( $attribute.valueType == "COMBO" )
+				<select  id="attr$attribute.id"  name="attr$attribute.id">
+					<option value="">[$i18n.getString( "please_select" )]</option>
+					#foreach ($option in $attribute.attributeOptions )
+						<option value="$option.id" >$option.name</option>
+					#end
+				</select>
+			#else 
+				<input type="text"  id="attr$attribute.id"  name="attr$attribute.id">
+			#end
+			
+			#if($!programAttribute.description) <i>($!programAttribute.description)</i> #end
+		</td>		
+    </tr>
+	#end
+	<tr>
         <td></td>
         <td></td>   
         <td></td>                             
     </tr>
-    
-    <tr>
-        <td style="width:180px">
-        	<input type="submit" #if( $programInstance ) value="$i18n.getString( "update" )#else value="$i18n.getString( "enroll" ) #end">
-            <input type="button" value="$i18n.getString( "unenroll" )" onclick="window.location.href='removeEnrollment.action'" #if( !$programInstance ) disabled="disabled" #end>
-        </td>                                        
-    </tr>
-</table>
-
-
+	
+</table>
+<hr/>
+#end
+
+<table>
+	<tr>
+		<td style="width:180px">
+			<input type="submit" #if( $programInstance ) value="$i18n.getString( "update" )#else value="$i18n.getString( "enroll" 	) #end">
+			<input type="button" value="$i18n.getString( "unenroll" )" onclick="javascript: removeEnrollment();" #if( !$programInstance ) disabled="disabled" #end>
+		</td>                                        
+	</tr>
+</table>
 
 #if( $programInstance )
-
 <table class="mainPageTable">
     <col id="noCol">
     <col id="stageCol">    

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseProgramAttribute.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseProgramAttribute.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseProgramAttribute.vm	2010-11-09 02:09:53 +0000
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<programAttribute>
+  <id>$programAttribute.id</id>
+  <name>$encoder.xmlEncode( $programAttribute.name )</name>
+  <description>$encoder.xmlEncode( $programAttribute.description )</description>
+  <valueType>$encoder.xmlEncode( $programAttribute.valueType )</valueType>     
+</programAttribute>
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramAttributeForm.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramAttributeForm.vm	2010-11-09 02:09:53 +0000
@@ -0,0 +1,95 @@
+<script>
+	var i18n_remove_option = '$encoder.jsEscape( $i18n.getString( "remove_option" ) , "'") ';
+	var i18n_field_is_required = '$encoder.jsEscape( $i18n.getString( "field_is_required" ) , "'") ';
+	var i18n_at_least_2_option = '$encoder.jsEscape( $i18n.getString( "at_least_2_option" ) , "'") ';
+	var isSubmit = true;
+	jQuery(document).ready(	function(){
+			
+			validation( 'updateProgramAttributeForm', function(form){
+				if( isSubmit && ATTRIBUTE_OPTION.checkOnSubmit() ) {
+					form.submit();
+				}
+			}, function(){
+				isSubmit = true;
+				jQuery.each($('#updateProgramAttributeForm').serializeArray(), function(i, field) {
+					if( field.value == ""){
+						setInnerHTML("attrMessage", i18n_field_is_required);
+						isSubmit = false;
+					}
+				});
+			}); 
+			
+		checkValueIsExist( "name", "validateProgramAttribute.action", {id:getFieldValue('id')});
+	});		
+</script>
+
+																		
+<h3>$i18n.getString( "update_new_program_attribute" )</h3>
+<form id="updateProgramAttributeForm" action="updateProgramAttribute.action" method="post" >
+<input type="hidden" id="id" name='id' value='$programAttribute.id'>
+<table id="attrTable"> 
+	<thead>
+      <tr>
+        <th colspan="2">$i18n.getString( "program_attribute_details" )</th>
+      </tr>
+    </thead>
+    <tbody>
+	
+    <tr>
+        <td width="20em"><label>$i18n.getString( "name" )</label></td>
+        <td><input type="text" id="name" name="name" value='$programAttribute.name' style="width:30em"></td>
+        <td></td>
+    </tr>   
+    
+    <tr>
+        <td width="20em" ><label>$i18n.getString( "description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+        <td><input type="text" id="description" name="description" value='$programAttribute.description' style="width:30em" class="{validate:{required:true,minlength:2}}"></td>
+        <td></td>
+    </tr>
+    
+    <tr>
+        <td>$i18n.getString( "value_type" ) <em title="$i18n.getString( "required" )" class="required">*</em></td>
+        <td>
+            <select id="valueType" name="valueType" style="min-width:30.5em" onchange="ATTRIBUTE_OPTION.selectValueType(this);">
+                <option value="NUMBER" #if( $programAttribute.valueType == 'NUMBER' ) selected="selected" #end>$i18n.getString( "number" )</option>
+                <option value="TEXT" #if( $programAttribute.valueType == 'TEXT' ) selected="selected" #end>$i18n.getString( "text" )</option>
+                <option value="YES/NO" #if( $programAttribute.valueType == 'YES/NO' ) selected="selected" #end>$i18n.getString( "yes_no" )</option>
+                <option value="DATE" #if( $programAttribute.valueType == 'DATE' ) selected="selected" #end>$i18n.getString( "date" )</option>
+                <option value="COMBO" #if( $programAttribute.valueType == 'COMBO' ) selected="selected" ; #end>$i18n.getString( "attribute_combo_type" )</option>
+            </select>
+        </td>
+      </tr>
+      <tr id="attributeComboRow"> 
+    	<td width="20em"><label>$i18n.getString( "attribute_options" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+    	<td >
+    		<table id="attrOptionContainer">
+    			 #foreach($option in $programAttribute.attributeOptions) 
+    			 	<tr><td>
+    			 		<input type='text' id='attrOption$option.id' name='attrOption$option.id' value="$option.name" style="width:28em;"/><a href='#' style='text-decoration: none; margin-left:0.5em;' title='$i18n.getString( "remove_option" )'  onClick='ATTRIBUTE_OPTION.remove(this,$option.id)'>[ - ]</a>
+   			 		</td>
+					</tr>
+    			 #end
+    		</table><a href="#" style="text-decoration: none;margin-top: 0.5em"  onclick="ATTRIBUTE_OPTION.addOption()">[ $i18n.getString( "add_more_option" ) ]</a></td>
+    	<td><span id="attrMessage"  name="attrMessage" style="color:red;"></span></td>
+      </tr>
+      <tr>
+        <td colspan="3" style="height:15px"></td>
+      </tr>
+     </tbody>
+</table>
+
+<p>
+    <input type="submit" value="$i18n.getString( "update" )" style="width:10em">
+    <input type="button" value="$i18n.getString( "cancel" )" onclick="window.location.href='programAttribute.action'" style="width:10em">
+</p>
+
+</form>   
+
+<script>
+	if ( jQuery("valueType	").val() == "COMBO" )
+	{
+		jQuery("#attributeComboRow").hide();
+	}else{
+		jQuery("#attributeComboRow").show();
+	}
+</script>