← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13361: Repace fixed attributes to dynamic attributes in Validation Criteria.

 

------------------------------------------------------------
revno: 13361
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-12-21 05:53:53 +0700
message:
  Repace fixed attributes to dynamic attributes in Validation Criteria.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationCriteria.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaStoreTest.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddValidationCriteriaAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetValidationCriteriaAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateValidationCriteriaAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addValidationCriteria.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/validationcriteria.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateValidationCriteria.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/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2013-12-18 16:24:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2013-12-20 22:53:53 +0000
@@ -28,13 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import org.apache.commons.lang.StringUtils;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.view.DetailedView;
@@ -47,19 +45,22 @@
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientReminder;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.relationship.RelationshipType;
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.validation.ValidationCriteria;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 
 /**
  * @author Abyot Asalefew
  */
-@JacksonXmlRootElement(localName = "program", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "program", namespace = DxfNamespaces.DXF_2_0 )
 public class Program
     extends BaseIdentifiableObject
 {
@@ -199,20 +200,29 @@
         return null;
     }
 
-    @SuppressWarnings("unchecked")
     public ValidationCriteria isValid( Patient patient )
     {
         try
         {
             for ( ValidationCriteria criteria : patientValidationCriteria )
             {
-                Object propertyValue = getValueFromPatient( StringUtils.capitalize( criteria.getProperty() ), patient );
+                String value = "";
+                for ( PatientAttributeValue attributeValue : patient.getAttributeValues() )
+                {
+                    if ( attributeValue.getPatientAttribute().getUid().equals( criteria.getProperty() ) )
+                    {System.out.println("\n\n ===== \n attribute : " + attributeValue.getPatientAttribute().getDisplayName());
+                        value = attributeValue.getValue();
+                        break;
+                    }
+                }
 
-                if ( propertyValue != null )
+                if ( !value.isEmpty() )
                 {
                     // Compare property value with compare value
-
-                    int i = ((Comparable<Object>) propertyValue).compareTo( criteria.getValue() );
+System.out.println("\n\n value : " + value );
+System.out.println("\n\n criteria.getValue() : " + criteria.getValue() );
+System.out.println("\n\n operator : " + value.compareTo( criteria.getValue() ) );
+                    int i = value.compareTo( criteria.getValue() );
 
                     // Return validation criteria if criteria is not met
 
@@ -238,8 +248,8 @@
     // -------------------------------------------------------------------------
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getDescription()
     {
         return description;
@@ -251,8 +261,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Integer getVersion()
     {
         return version;
@@ -263,11 +273,11 @@
         this.version = version;
     }
 
-    @JsonProperty(value = "organisationUnits")
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class, ExportView.class })
-    @JacksonXmlElementWrapper(localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( value = "organisationUnits" )
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 )
     public Set<OrganisationUnit> getOrganisationUnits()
     {
         return organisationUnits;
@@ -278,10 +288,10 @@
         this.organisationUnits = organisationUnits;
     }
 
-    @JsonProperty(value = "programInstances")
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "programInstances", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "programInstance", namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( value = "programInstances" )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "programInstances", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "programInstance", namespace = DxfNamespaces.DXF_2_0 )
     public Set<ProgramInstance> getProgramInstances()
     {
         return programInstances;
@@ -292,11 +302,11 @@
         this.programInstances = programInstances;
     }
 
-    @JsonProperty(value = "programStages")
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "programStages", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "programStage", namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( value = "programStages" )
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "programStages", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "programStage", namespace = DxfNamespaces.DXF_2_0 )
     public Set<ProgramStage> getProgramStages()
     {
         return programStages;
@@ -308,8 +318,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getDateOfEnrollmentDescription()
     {
         return dateOfEnrollmentDescription;
@@ -321,8 +331,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getDateOfIncidentDescription()
     {
         return dateOfIncidentDescription;
@@ -334,14 +344,14 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getKind()
     {
         return TYPE_LOOKUP.get( type );
     }
 
     @JsonProperty
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Integer getType()
     {
         return type;
@@ -352,11 +362,11 @@
         this.type = type;
     }
 
-    @JsonProperty(value = "validationCriterias")
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "validationCriterias", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "validationCriteria", namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( value = "validationCriterias" )
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "validationCriterias", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "validationCriteria", namespace = DxfNamespaces.DXF_2_0 )
     public Set<ValidationCriteria> getPatientValidationCriteria()
     {
         return patientValidationCriteria;
@@ -367,10 +377,10 @@
         this.patientValidationCriteria = patientValidationCriteria;
     }
 
-    @JsonProperty(value = "identifierTypes")
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "identifierTypes", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "identifierType", namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( value = "identifierTypes" )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "identifierTypes", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "identifierType", namespace = DxfNamespaces.DXF_2_0 )
     public List<PatientIdentifierType> getPatientIdentifierTypes()
     {
         return patientIdentifierTypes;
@@ -381,10 +391,10 @@
         this.patientIdentifierTypes = patientIdentifierTypes;
     }
 
-    @JsonProperty(value = "attributes")
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "attributes", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "attribute", namespace = DxfNamespaces.DXF_2_0)
+    @JsonProperty( value = "attributes" )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "attributes", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "attribute", namespace = DxfNamespaces.DXF_2_0 )
     public List<PatientAttribute> getPatientAttributes()
     {
         return patientAttributes;
@@ -396,8 +406,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getDisplayIncidentDate()
     {
         return displayIncidentDate;
@@ -409,8 +419,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     private Object getValueFromPatient( String property, Patient patient )
         throws Exception
     {
@@ -418,8 +428,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getIgnoreOverdueEvents()
     {
         return ignoreOverdueEvents;
@@ -431,26 +441,26 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public boolean isSingleEvent()
     {
         return type != null && (SINGLE_EVENT_WITH_REGISTRATION == type || SINGLE_EVENT_WITHOUT_REGISTRATION == type);
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public boolean isRegistration()
     {
         return type != null && (SINGLE_EVENT_WITH_REGISTRATION == type || MULTIPLE_EVENTS_WITH_REGISTRATION == type);
     }
 
     @JsonProperty
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "userRoles", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "userRole", namespace = DxfNamespaces.DXF_2_0)
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "userRoles", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "userRole", namespace = DxfNamespaces.DXF_2_0 )
     public Set<UserAuthorityGroup> getUserRoles()
     {
         return userRoles;
@@ -462,8 +472,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getOnlyEnrollOnce()
     {
         return onlyEnrollOnce;
@@ -475,8 +485,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Set<PatientReminder> getPatientReminders()
     {
         return patientReminders;
@@ -488,10 +498,10 @@
     }
 
     @JsonProperty
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlElementWrapper(localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0)
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0 )
     public Set<OrganisationUnitGroup> getOrganisationUnitGroups()
     {
         return organisationUnitGroups;
@@ -503,8 +513,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getDisplayOnAllOrgunit()
     {
         return displayOnAllOrgunit;
@@ -516,8 +526,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getUseBirthDateAsIncidentDate()
     {
         return useBirthDateAsIncidentDate;
@@ -529,8 +539,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getUseBirthDateAsEnrollmentDate()
     {
         return useBirthDateAsEnrollmentDate;
@@ -542,8 +552,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getSelectEnrollmentDatesInFuture()
     {
         return selectEnrollmentDatesInFuture;
@@ -555,8 +565,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getSelectIncidentDatesInFuture()
     {
         return selectIncidentDatesInFuture;
@@ -568,8 +578,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getRelationshipText()
     {
         return relationshipText;
@@ -581,8 +591,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public RelationshipType getRelationshipType()
     {
         return relationshipType;
@@ -594,8 +604,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Program getRelatedProgram()
     {
         return relatedProgram;
@@ -607,8 +617,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getRelationshipFromA()
     {
         return relationshipFromA;
@@ -620,8 +630,8 @@
     }
 
     @JsonProperty
-    @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class })
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Boolean getDataEntryMethod()
     {
         return dataEntryMethod;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationCriteria.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationCriteria.java	2013-11-14 09:36:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationCriteria.java	2013-12-20 22:53:53 +0000
@@ -62,7 +62,7 @@
 
     private int operator;
 
-    private Object value;
+    private String value;
 
     // -------------------------------------------------------------------------
     // Constructor method
@@ -118,12 +118,12 @@
     @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public Object getValue()
+    public String getValue()
     {
         return value;
     }
 
-    public void setValue( Object value )
+    public void setValue( String value )
     {
         this.value = value;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java	2013-12-19 18:12:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java	2013-12-20 22:53:53 +0000
@@ -51,9 +51,9 @@
 
     private String propertyB;
 
-    private Object valueA;
+    private String valueA;
 
-    private Object valueB;
+    private String valueB;
 
     private ValidationCriteria validationCriteriaA;
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaStoreTest.java	2013-12-16 04:27:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaStoreTest.java	2013-12-20 22:53:53 +0000
@@ -53,9 +53,9 @@
 
     private String propertyB;
 
-    private Object valueA;
+    private String valueA;
 
-    private Object valueB;
+    private String valueB;
 
     // -------------------------------------------------------------------------
     // Fixture

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-12-18 06:05:41 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-12-20 22:53:53 +0000
@@ -70,6 +70,7 @@
 import org.hisp.dhis.system.grid.GridUtils;
 import org.hisp.dhis.system.util.SqlHelper;
 import org.hisp.dhis.system.util.TextUtils;
+import org.hisp.dhis.validation.ValidationCriteria;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.jdbc.support.rowset.SqlRowSet;
 import org.springframework.transaction.annotation.Transactional;
@@ -424,15 +425,15 @@
             }
         }
 
-        // if ( program != null )
-        // {
-        // ValidationCriteria validationCriteria = program.isValid( patient );
-        //
-        // if ( validationCriteria != null )
-        // {
-        // return PatientService.ERROR_ENROLLMENT;
-        // }
-        // }
+        if ( program != null )
+        {
+            ValidationCriteria validationCriteria = program.isValid( patient );
+
+            if ( validationCriteria != null )
+            {
+                return PatientService.ERROR_ENROLLMENT;
+            }
+        }
 
         return PatientService.ERROR_NONE;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2013-12-19 07:14:12 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2013-12-20 22:53:53 +0000
@@ -507,8 +507,10 @@
                     + CaseAggregationCondition.SEPARATOR_OBJECT + max + "]";
                 updateFixedAttributeInCaseAggregate( source, target );
 
-                // Update custom entry form
+                // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "gender", uid );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" ) + " and property='gender' ");
 
                 // ---------------------------------------------------------------------
                 // Death date
@@ -527,8 +529,11 @@
                 executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid,"
                     + max + ",deathDate from patient where deathDate is not null" );
 
-                // Update custom entry form
+                // Update custom entry form && Validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "deathDate", uid );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" ) + " and property='deathDate' ");
+
 
                 // ---------------------------------------------------------------------
                 // registrationDate
@@ -548,8 +553,10 @@
                 executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid,"
                     + max + ",registrationDate from patient where registrationDate is not null" );
 
-                // Update custom entry form
+                // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "registrationDate", uid );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" ) + " and property='registrationDate' ");
 
                 // ---------------------------------------------------------------------
                 // isDead
@@ -568,8 +575,11 @@
                 executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid,"
                     + max + ",isDead from patient where isDead is not null" );
 
-                // Update custom entry form
+                // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "isDead", uid );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" ) + " and property='isDead' ");
+
 
                 // ---------------------------------------------------------------------
                 // underAge
@@ -588,8 +598,10 @@
                 executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid,"
                     + max + ",isDead from patient where underAge=true" );
 
-                // Update custom entry form
+                // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "underAge", uid );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" ) + " and property='underAge' ");
 
                 // ---------------------------------------------------------------------
                 // DobType
@@ -632,8 +644,10 @@
                     + CaseAggregationCondition.SEPARATOR_OBJECT + max + "]";
                 updateFixedAttributeInCaseAggregate( source, target );
 
-                // Update custom entry form
+                // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "dobType", uid );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" ) + " and property='dobType' ");
 
                 // -------------------------------------------------------------
                 // Birthdate
@@ -652,9 +666,11 @@
                 executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid,"
                     + max + ",birthdate from patient where birthdate is not null and dobType in ('D','V') " );
 
-                // Update custom entry form
+                // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "birthDate", uid );
-                
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" ) + " and property='birthDate' ");
+
                 // -------------------------------------------------------------
                 // Age
                 // -------------------------------------------------------------
@@ -672,8 +688,10 @@
                 executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid,"
                     + max + ",birthdate from patient where birthdate is not null and dobType='A' " );
 
-                // Update custom entry form
+                // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "age", uid );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" ) + " and property='age' ");
 
                 // -------------------------------------------------------------
                 // Phone number
@@ -694,7 +712,7 @@
 
                 // Update custom entry form
                 removeFixedAttributeInCustomRegistrationForm( "phoneNumber", uid );
-
+                
                 // -------------------------------------------------------------
                 // Update Case Aggregate Query Builder
                 // -------------------------------------------------------------
@@ -704,7 +722,6 @@
                     + CaseAggregationCondition.SEPARATOR_OBJECT + max + ".age]";
                 updateFixedAttributeInCaseAggregate( source, target );
 
-
                 executeSql( "ALTER TABLE patient DROP COLUMN gender" );
                 executeSql( "ALTER TABLE patient DROP COLUMN deathDate" );
                 executeSql( "ALTER TABLE patient DROP COLUMN registrationDate" );
@@ -765,7 +782,7 @@
             {
                 String htmlCode = resultSet.getString( "htmlcode" );
                 htmlCode = htmlCode.replaceAll( "fixedattributeid=\"" + property + "\"", "attributeid=\"" + uid + "\"" );
-                
+
                 executeSql( "UPDATE dataentryform SET htmlcode='" + htmlCode + "' WHERE dataentryformid="
                     + resultSet.getInt( "dataentryformid" ) );
             }

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2013-12-19 18:12:57 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2013-12-20 22:53:53 +0000
@@ -1151,7 +1151,7 @@
      * @return ValidationCriteria
      */
     public static ValidationCriteria createValidationCriteria( char uniqueCharacter, String property, int operator,
-        Object value )
+        String value )
     {
         ValidationCriteria validationCriteria = new ValidationCriteria();
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java	2013-12-19 04:00:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java	2013-12-20 22:53:53 +0000
@@ -213,24 +213,20 @@
                     attributeValue = new PatientAttributeValue();
                     attributeValue.setPatient( patient );
                     attributeValue.setPatientAttribute( attribute );
+                    attributeValue.setValue( value.trim() );
 
                     if ( attribute.getValueType().equals( PatientAttribute.TYPE_AGE ) )
                     {
                         value = format.formatDate( PatientAttribute.getDateFromAge( Integer.parseInt( value ) ) );
                     }
-                    attributeValue.setValue( value );
 
                     if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
                     {
-                        PatientAttributeOption option = patientAttributeOptionService
-                            .get( NumberUtils.toInt( value, 0 ) );
+                        PatientAttributeOption option = patientAttributeOptionService.get( Integer.parseInt( value ) );
                         if ( option != null )
                         {
                             attributeValue.setPatientAttributeOption( option );
-                        }
-                        else
-                        {
-                            // Someone deleted this option ...
+                            attributeValue.setValue( option.getName() );
                         }
                     }
                     patientAttributeValues.add( attributeValue );
@@ -242,8 +238,7 @@
         // Save patient
         // -------------------------------------------------------------------------
 
-       patientService.createPatient( patient, representativeId, relationshipTypeId,
-            patientAttributeValues );
+        patientService.createPatient( patient, representativeId, relationshipTypeId, patientAttributeValues );
 
         // -------------------------------------------------------------------------
         // Create relationship

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java	2013-12-19 18:12:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java	2013-12-20 22:53:53 +0000
@@ -212,6 +212,21 @@
                         attributeValue = new PatientAttributeValue();
                         attributeValue.setPatient( patient );
                         attributeValue.setPatientAttribute( attribute );
+                        attributeValue.setValue( value.trim() );
+                        if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
+                        {
+                            PatientAttributeOption option = patientAttributeOptionService
+                                .get( Integer.parseInt( value ) );
+                            if ( option != null )
+                            {
+                                attributeValue.setPatientAttributeOption( option );
+                                attributeValue.setValue( option.getName() );
+                            }
+                        }
+                        valuesForSave.add( attributeValue );
+                    }
+                    else
+                    {
                         if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
                         {
                             PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt(
@@ -219,35 +234,14 @@
                             if ( option != null )
                             {
                                 attributeValue.setPatientAttributeOption( option );
-                            }
-                            else
-                            {
-                                // This option was deleted ???
-                            }
-                            attributeValue.setValue( value );
+                                attributeValue.setValue( option.getName() );
+                            }
                         }
                         else
                         {
                             attributeValue.setValue( value.trim() );
                         }
-                        valuesForSave.add( attributeValue );
-                    }
-                    else
-                    {
-                        if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
-                        {
-                            PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt(
-                                value, 0 ) );
-                            if ( option != null )
-                            {
-                                attributeValue.setPatientAttributeOption( option );
-                            }
-                            else
-                            {
-                                // This option was deleted ???
-                            }
-                        }
-                        attributeValue.setValue( value.trim() );
+
                         valuesForUpdate.add( attributeValue );
                         valuesForDelete.remove( attributeValue );
                     }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-12-19 06:41:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-12-20 22:53:53 +0000
@@ -1231,7 +1231,6 @@
 		url: 'validatePatientProgramEnrollment.action',
 		data: getParamsForDiv('programEnrollmentSelectDiv'),
 		success: function(json) {
-			hideById('message');
 			var type = json.response;
 
             if( type == 'success' ) {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2013-12-18 08:01:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2013-12-20 22:53:53 +0000
@@ -216,7 +216,7 @@
 	
 	this.update = function()
 	{
-		if( !this.validate() ) return;
+		if( !this.validate(getFieldValue('programIdAddPatient')) ) return;
 		
 		var params = 'programId=' + getFieldValue('programIdAddPatient') 
 		+ '&' + getParamsForDiv('editPatientDiv');

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm	2013-11-25 08:18:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm	2013-12-20 22:53:53 +0000
@@ -72,6 +72,7 @@
 			<td colspan='3'><span id='message'></span></td>
 		</tr>
 	</table>
+	<span id='message'></span>
 </form>
 
 #end

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddValidationCriteriaAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddValidationCriteriaAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddValidationCriteriaAction.java	2013-12-20 22:53:53 +0000
@@ -28,8 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.validation.ValidationCriteria;
 import org.hisp.dhis.validation.ValidationCriteriaService;
 
@@ -48,10 +46,6 @@
 
     private ValidationCriteriaService validationCriteriaService;
 
-    private PatientService patientService;
-
-    private I18nFormat format;
-
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
@@ -75,16 +69,6 @@
         this.validationCriteriaService = validationCriteriaService;
     }
 
-    public void setPatientService( PatientService patientService )
-    {
-        this.patientService = patientService;
-    }
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
     public void setName( String name )
     {
         this.name = name;
@@ -124,7 +108,7 @@
         criteria.setDescription( description );
         criteria.setProperty( property );
         criteria.setOperator( operator );
-        criteria.setValue( patientService.getObjectValue( property, value, format ) );
+        criteria.setValue( value );
 
         validationCriteriaService.saveValidationCriteria( criteria );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetValidationCriteriaAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetValidationCriteriaAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetValidationCriteriaAction.java	2013-12-20 22:53:53 +0000
@@ -28,7 +28,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.validation.ValidationCriteria;
 import org.hisp.dhis.validation.ValidationCriteriaService;
 
@@ -52,12 +59,21 @@
         this.validationCriteriaService = validationCriteriaService;
     }
 
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
 
     private int id;
 
+    private List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
+
     private ValidationCriteria validationCriteria;
 
     private I18nFormat format;
@@ -86,6 +102,11 @@
         return validationCriteria;
     }
 
+    public List<PatientAttribute> getPatientAttributes()
+    {
+        return patientAttributes;
+    }
+
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -96,6 +117,10 @@
     {
         validationCriteria = validationCriteriaService.getValidationCriteria( id );
 
+        patientAttributes = new ArrayList<PatientAttribute>( patientAttributeService.getAllPatientAttributes() );
+
+        Collections.sort( patientAttributes, IdentifiableObjectNameComparator.INSTANCE );
+
         return SUCCESS;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateValidationCriteriaAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateValidationCriteriaAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateValidationCriteriaAction.java	2013-12-20 22:53:53 +0000
@@ -48,9 +48,10 @@
 
     private ValidationCriteriaService validationCriteriaService;
 
-    private PatientService patientService;
-
-    private I18nFormat format;
+    public void setValidationCriteriaService( ValidationCriteriaService validationCriteriaService )
+    {
+        this.validationCriteriaService = validationCriteriaService;
+    }
 
     // -------------------------------------------------------------------------
     // Input
@@ -72,21 +73,6 @@
     // Setters
     // -------------------------------------------------------------------------
 
-    public void setValidationCriteriaService( ValidationCriteriaService validationCriteriaService )
-    {
-        this.validationCriteriaService = validationCriteriaService;
-    }
-
-    public void setPatientService( PatientService patientService )
-    {
-        this.patientService = patientService;
-    }
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
     public void setName( String name )
     {
         this.name = name;
@@ -131,11 +117,10 @@
         criteria.setDescription( description );
         criteria.setProperty( property );
         criteria.setOperator( operator );
-        criteria.setValue( patientService.getObjectValue( property, value, format ) );
+        criteria.setValue( value );
 
         validationCriteriaService.updateValidationCriteria( criteria );
 
         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	2013-12-01 22:32:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2013-12-20 22:53:53 +0000
@@ -918,7 +918,6 @@
     <property name="validationCriteriaService">
       <ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
     </property>
-    <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
   </bean>
 
   <bean
@@ -952,6 +951,9 @@
     <property name="validationCriteriaService">
       <ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
     </property>
+    <property name="patientAttributeService">
+      <ref bean="org.hisp.dhis.patient.PatientAttributeService" />
+    </property>
   </bean>
 
   <bean
@@ -979,7 +981,6 @@
     <property name="validationCriteriaService">
       <ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
     </property>
-    <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
   </bean>
 
   <bean

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2013-10-08 08:47:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2013-12-20 22:53:53 +0000
@@ -924,7 +924,7 @@
 			<param name="javascripts">javascript/validationcriteria.js</param>
 		</action>
 
-		<action name="showAddValidationCriteriaForm" class="org.hisp.dhis.patient.action.NoAction">
+		<action name="showAddValidationCriteriaForm" class="org.hisp.dhis.patient.action.patientattribute.GetPatientAttributeListAction">
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/addValidationCriteria.vm</param>
 			<param name="javascripts">javascript/validationcriteria.js</param>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addValidationCriteria.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addValidationCriteria.vm	2013-12-17 01:29:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addValidationCriteria.vm	2013-12-20 22:53:53 +0000
@@ -1,4 +1,7 @@
 <script type="text/javascript" src="javascript/addValidationCriteria.js"></script>																
+<script type="text/javascript">
+	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_patient_attribute" ) , "'" )';
+</script>
 
 <h3>$i18n.getString( "create_validation_criteria" )</h3>
 <form id="validationCriteriaForm" action="addValidationCriteria.action" method="post" class="inputForm">
@@ -18,61 +21,26 @@
 		<table>
 			<tr>
 				<td>
-				<!-- Property -->
-					<select id='property' name='property' style='width: 16em' onChange="showDivValue();">
+					<select id='property' name='property' style='width:16em' onChange="showDivValue();">
 						<option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
-						<option value="gender">$i18n.getString( "gender" )</option>
-						<option value="dobType">$i18n.getString( "dob_type" )</option>
-						<option value="birthDate">$i18n.getString( "date_of_birth" )</option>
-						<option value="integerValueOfAge">$i18n.getString( "age" )</option>
+						#foreach($patientAttribute in $patientAttributes)
+							#set($opt="")
+							#foreach($option in $patientAttribute.attributeOptions)
+								#set($opt=$opt + ';' + $option.name )
+							#end 
+						<option value="$patientAttribute.uid" opt="$opt">$patientAttribute.displayName</option>
+						#end
 					</select>
-
-					<!-- Operator -->
+				</td>
+				<td>
 					<select id='operator' name='operator' style='width: 7em'>
-						<option value='-1'>$i18n.getString('operator_less_then')</option>
-						<option value='0'>$i18n.getString('operator_equal_to')</option>
-						<option value='1'>$i18n.getString('operator_greater_then')</option>
+						<option value='-1' #if( "$validationCriteria.operator"=='-1') selected #end>$i18n.getString('operator_less_then')</option>
+						<option value='0'  #if( "$validationCriteria.operator"=='0') selected #end>$i18n.getString('operator_equal_to')</option>
+						<option value='1'  #if( "$validationCriteria.operator"=='1') selected #end>$i18n.getString('operator_greater_then')</option>
 					</select>
 				</td>
-			   <td>
-				<!-- Displayed when no criteria is selected -->
-				<input type="text" style="width:16em" id='emptyCriteria'>
-				
-				<!-- gender -->
-				<div id="genderDiv" style="display:none">
-					<select id='genderValue' name='genderValue' onChange="fillValue(this.value);" style="width: 16em">
-						<option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
-						<option value="M" >$i18n.getString( "male" )</option>
-						<option value="F">$i18n.getString( "female" )</option>
-						<option value="T">$i18n.getString( "transgender" )</option>
-					</select>
-				</div>
-				
-				<!-- dobType -->
-				<div id="dobTypeDiv" style="display:none ">
-					<select type="text" id='dobTypeValue' name='dobTypeValue' onChange="fillValue(this.value);" style="width: 16em">
-						<option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
-						<option value="V" >$i18n.getString( "verified" )</option>
-						<option value="D" >$i18n.getString( "declared" )</option>
-						<option value="A" >$i18n.getString( "approximated" )</option>
-					</select>
-				</div>
-				
-				<!-- age -->
-				<div id="integerValueOfAgeDiv" style="display:none ">
-					<input type="text" id='integerValueOfAgeValue' name='integerValueOfAgeValue' onChange="fillValue(this.value);"  class="{validate:{digits:true,rangelength:[1,2]}}" style="width: 16em"/>
-				</div>
-				
-				<!-- birthDate -->
-				<div id="birthDateDiv" style="display:none ">
-					<input type="text" id="birthDateValue" name="birthDateValue" onChange="fillValue(this.value);" style="width:215px"/>			
-					<script type="text/javascript">
-						datePickerValid( 'birthDateValue' );
-					</script> 
-				</div>
-				
-				<!-- value -->
-				<input type="hidden" id="value" name="value" class="{validate:{required:true,rangelength:[1,160]}}"/>
+				<td id='valueTD'>
+					<input id='value' name='value' class="{validate:{required:true}}" style="width:200px;"/>
 				</td>
 			</tr>
 		</table>
@@ -86,4 +54,5 @@
 		</td>
     </tr>
   </table>
-</form>
\ No newline at end of file
+</form>
+

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/validationcriteria.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/validationcriteria.js	2013-12-17 01:29:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/validationcriteria.js	2013-12-20 22:53:53 +0000
@@ -51,33 +51,25 @@
 // ----------------------------------------------------------------------------------------
 // Show div to Add or Update Validation-Criteria
 // ----------------------------------------------------------------------------------------
+
 function showDivValue() {
-
-  var propertyName = byId('property').value;
-  hideDiv();
-  if( propertyName != '' ) {
-    hideById('emptyCriteria');
-
-    var div = byId(propertyName + 'Div');
-    div.style.display = 'block';
-    if( propertyName == 'gender' ||
-      propertyName == 'dobType' ) {
-
-      byId('operator').selectedIndex = 1;
-      disable('operator');
-    }
-    else {
-      enable('operator');
-    }
-  }
-}
-
-function hideDiv() {
-  hideById('genderDiv');
-  hideById('integerValueOfAgeDiv');
-  hideById('birthDateDiv');
-  hideById('dobTypeDiv');
-  showById('emptyCriteria');
+  var value = getFieldValue('value');
+  var property = jQuery('#property option:selected');
+  var propertyName = property.val();
+  if( propertyName != '' && property.attr('opt')!='') {
+	var opts = property.attr('opt').split(";");
+	var selectField = "<select id='value' name='value' class=\"{validate:{required:true}}\" style=\"width:200px;\">";
+	for(var i=1;i<opts.length;i++){
+		selectField += "<option value=\"" + opts[i] + "\" >" + opts[i] + "</option>";
+	}
+	selectField += "</select>";
+	setInnerHTML('valueTD', selectField);
+  }
+  else
+  {
+	var inputField = "<input id='value' name='value' class=\"{validate:{required:true}}\" style=\"width:200px;\"/>";
+  }
+  setFieldValue('value', value);
 }
 
 function fillValue( value ) {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateValidationCriteria.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateValidationCriteria.vm	2013-12-17 01:29:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateValidationCriteria.vm	2013-12-20 22:53:53 +0000
@@ -22,57 +22,35 @@
 				<table>
 					<tr>
 						<td>
-							<select id='property' name='property' style='width: 16em' onChange="showDivValue();">
-								<option value="">[$i18n.getString( "please_select" )]</option>
-								<option value="gender" #if("$validationCriteria.property" == "gender") selected #end>$i18n.getString( "gender" )</option>
-								<option value="birthDate" #if("$validationCriteria.property" == "birthDate") selected #end>$i18n.getString( "date_of_birth" )</option>
-								<option value="dobType" #if("$validationCriteria.property" == "dobType") selected #end>$i18n.getString( "dob_type" )</option>
-								<option value="integerValueOfAge" #if("$validationCriteria.property" == "integerValueOfAge") selected #end>$i18n.getString( "age" )</option>
+							<select id='property' name='property' style='width:16em' onChange="showDivValue();">
+								<option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
+								#set($attribute = '')
+								#foreach($patientAttribute in $patientAttributes)
+									#set($opt="")
+									#foreach($option in $patientAttribute.attributeOptions)
+										#set($opt=$opt + ';' + $option.name )
+									#end 
+								<option value="$patientAttribute.uid" opt="$opt" #if($validationCriteria.property==$patientAttribute.uid) #set($attribute = $patientAttribute) selected #end>$patientAttribute.displayName</option>
+								#end
 							</select>
-								<select id='operator' name='operator' style='width: 7em'>
+						</td>
+						<td>
+							<select id='operator' name='operator' style='width: 7em'>
 								<option value='-1' #if( "$validationCriteria.operator"=='-1') selected #end>$i18n.getString('operator_less_then')</option>
 								<option value='0'  #if( "$validationCriteria.operator"=='0') selected #end>$i18n.getString('operator_equal_to')</option>
 								<option value='1'  #if( "$validationCriteria.operator"=='1') selected #end>$i18n.getString('operator_greater_then')</option>
 							</select>
-							</td>
-
-							<td>
-							
-							<!-- Displayed when no criteria is selected -->
-							<input type="text" style="width:16em" id='emptyCriteria'>
-				
-							<!-- gender -->
-							<div id="genderDiv" style="display:none">
-								<select id='genderValue' name='genderValue' onChange="fillValue(this.value);" style="width: 16em">
-									<option value="">[$i18n.getString( "please_select" )]</option>
-									<option value="M">$i18n.getString( "male" )</option>
-									<option value="F">$i18n.getString( "female" )</option>
-									<option value="T">$i18n.getString( "transgender" )</option>
-								</select>
-							</div>
-
-							<!-- dobType -->
-							<div id="dobTypeDiv" style="display:none ">
-								<select type="text" id='dobTypeValue' name='dobTypeValue' onChange="fillValue(this.value);" style="width: 16em">
-									<option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
-									<option value="V" >$i18n.getString( "verified" )</option>
-									<option value="D" >$i18n.getString( "declared" )</option>
-									<option value="A" >$i18n.getString( "approximated" )</option>
-								</select>
-							</div>
-
-							<!-- age -->
-							<div id="integerValueOfAgeDiv" style="display:none ">
-								<input type="text" id='integerValueOfAgeValue' name='integerValueOfAgeValue' onChange="fillValue(this.value);" class="{validate:{digits:true,rangelength:[1,2]}}" style="width: 15.5em"/>
-							</div>
-
-							<!-- birthDate -->
-							<div id="birthDateDiv" style="display:none ">
-								<input type="text" id="birthDateValue" name="birthDateValue" onChange="fillValue(this.value);"style="width:215px"/>
-								<script type="text/javascript">datePickerValid( 'birthDateValue' );</script> 
-							</div>
-
-							<input type='hidden' id='value' name='value' value="$validationCriteria.value" class="{validate:{required:true}}"/>
+						</td>
+						<td id='valueTD'>
+							#if($attribute.attributeOptions)
+								<select id='value' name='value' class="{validate:{required:true}}" style="width:200px;">
+									#foreach($option in $attribute.attributeOptions)
+									<option value="$option.name" #if($validationCriteria.value==$option.name) selected #end>$option.name</option>
+									#end
+								</select>
+							#else
+								<input id='value' name='value' class="{validate:{required:true}}" style="width:200px;"/>
+							#end
 						</td>
 					</tr>
 				</table>
@@ -87,25 +65,3 @@
 		</tr>
 	</table>
 </form>
-
-<script language="javascript">
-	
-	var name = '$validationCriteria.property';
-	var divName = name+ "Div";
-	byId(divName).style.display = 'block';
-	
-	if(divName == 'birthDateDiv'){
-		var year = eval('$validationCriteria.value.getYear()') + 1900;
-		var month = eval('$validationCriteria.value.getMonth()' ) + 1;
-		month = ( month < 10 ) ? ( '0' + month ) : month;
-		var date = '$validationCriteria.value.getDate()';
-		date = ( date < 10 ) ? ( '0' + date ) : date;
-		
-		byId(name + "Value").value = year + '-' + month + '-' + date;
-	}else{
-		byId(name + "Value").value = '$validationCriteria.value';
-	}
-	byId('value').value = byId(name + "Value").value;
-	showDivValue();
-	
-</script>
\ No newline at end of file