← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3491: Validations for program-stages.

 

------------------------------------------------------------
revno: 3491
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-04-29 14:41:04 +0700
message:
  Validations for program-stages.
removed:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidation.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementValidationService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementValidationStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElementValidation.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateValueAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowValidationDEAssociationsFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramStageDEValidationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramStageDEValidationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageDataElementValidation.vm
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidation.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramValidationStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramValidationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramValidationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateProgramValidationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramValidationForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseProgramValidation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramValidationForm.vm
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js
  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/menu.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.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
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidation.java	2010-05-12 02:15:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidation.java	1970-01-01 00:00:00 +0000
@@ -1,141 +0,0 @@
-/*
- * 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 ProgramStageValidation.java May 6, 2010 9:34:10 AM
- */
-public class ProgramStageDataElementValidation implements Serializable
-{
-    public static final int OPERATOR_LESS_THAN = -1;
-
-    public static final int OPERATOR_EQUAL_TO = 0;
-
-    public static final int OPERATOR_GREATER_THAN = 1;
-
-    // -------------------------------------------------------------------------
-    // Fields
-    // -------------------------------------------------------------------------
-
-    private int id;
-
-    private String description;
-
-    private ProgramStageDataElement leftProgramStageDataElement;
-
-    private int operator;
-
-    private ProgramStageDataElement rightProgramStageDataElement;
-
-    // -------------------------------------------------------------------------
-    // equals && hashCode
-    // -------------------------------------------------------------------------
-
-    @Override
-    public int hashCode()
-    {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + id;
-        return result;
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        if ( this == obj )
-            return true;
-        if ( obj == null )
-            return false;
-        if ( getClass() != obj.getClass() )
-            return false;
-        ProgramStageDataElementValidation other = (ProgramStageDataElementValidation) obj;
-        if ( id != other.id )
-            return false;
-        return true;
-    }
-
-    // -------------------------------------------------------------------------
-    // getters && Setters
-    // -------------------------------------------------------------------------
-
-    public int getId()
-    {
-        return id;
-    }
-
-    public void setId( int id )
-    {
-        this.id = id;
-    }
-
-    public String getDescription()
-    {
-        return description;
-    }
-    
-    public void setDescription( String description )
-    {
-        this.description = description;
-    }
-
-    public int getOperator()
-    {
-        return operator;
-    }
-
-    public void setOperator( int operator )
-    {
-        this.operator = operator;
-    }
-
-    public ProgramStageDataElement getLeftProgramStageDataElement()
-    {
-        return leftProgramStageDataElement;
-    }
-
-    public void setLeftProgramStageDataElement( ProgramStageDataElement leftProgramStageDataElement )
-    {
-        this.leftProgramStageDataElement = leftProgramStageDataElement;
-    }
-
-    public ProgramStageDataElement getRightProgramStageDataElement()
-    {
-        return rightProgramStageDataElement;
-    }
-
-    public void setRightProgramStageDataElement( ProgramStageDataElement rightProgramStageDataElement )
-    {
-        this.rightProgramStageDataElement = rightProgramStageDataElement;
-    }
-
-}

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationService.java	2010-10-22 06:43:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationService.java	1970-01-01 00:00:00 +0000
@@ -1,60 +0,0 @@
-/*
- * 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 ProgramStageDataElementValidationService.java May 6, 2010 10:08:04
- *          AM
- */
-public interface ProgramStageDataElementValidationService
-{
-    String ID = ProgramStageDataElementValidationService.class.getName();
-
-    // -------------------------------------------------------------------------
-    // ProgramStage - DataElement validation
-    // -------------------------------------------------------------------------
-
-    int saveProgramStageDataElementValidation( ProgramStageDataElementValidation validation );
-
-    void deleteProgramStageDataElementValidation( ProgramStageDataElementValidation validation );
-
-    void updateProgramStageDataElementValidation( ProgramStageDataElementValidation validation );
-
-    ProgramStageDataElementValidation getProgramStageDataElementValidation( int id );
-
-    Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations( Program program );
-
-    Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations( ProgramStageDataElement element );
-
-    Collection<ProgramStageDataElementValidation> getAllProgramStageDataElementValidations();
-    
-    Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations( ProgramStage programStage );
-}

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationStore.java	2010-10-22 06:43:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementValidationStore.java	1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
-/*
- * 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.GenericStore;
-
-/**
- * @author Chau Thu Tran
- * @version ProgramStageDataElementValidationStore.java May 7, 2010 10:08:04 AM
- */
-public interface ProgramStageDataElementValidationStore
-    extends GenericStore<ProgramStageDataElementValidation>
-{
-    String ID = ProgramStageDataElementValidationStore.class.getName();
-
-    // -------------------------------------------------------------------------
-    // ProgramStage - DataElement validation
-    // -------------------------------------------------------------------------
-
-    Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations( Program program );
-
-    Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations( ProgramStageDataElement element );
-    
-    Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations( ProgramStage programStage );
-}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidation.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidation.java	2011-04-29 07:41:04 +0000
@@ -0,0 +1,180 @@
+/*
+ * 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 $ ProgramValidation.java Apr 28, 2011 10:27:29 AM $
+ */
+public class ProgramValidation
+implements Serializable
+{
+    public static final String SEPARATOR_ID = "\\.";
+
+    public static final String SEPARATOR_OBJECT = ":";
+
+    public static String OBJECT_PROGRAM_STAGE_DATAELEMENT = "DE";
+
+    // -------------------------------------------------------------------------
+    // Fields
+    // -------------------------------------------------------------------------
+
+    private int id;
+
+    private String description;
+
+    private String leftSide;
+
+    private String rightSide;
+
+    private Program program;
+
+    // -------------------------------------------------------------------------
+    // Constructor
+    // -------------------------------------------------------------------------
+
+    public ProgramValidation()
+    {
+
+    }
+
+    public ProgramValidation( String description, String leftSide, String rightSide, Program program )
+    {
+        this.description = description;
+        this.leftSide = leftSide;
+        this.rightSide = rightSide;
+        this.program = program;
+    }
+
+    // -------------------------------------------------------------------------
+    // hashCode() and equals()
+    // -------------------------------------------------------------------------
+
+    public int getId()
+    {
+        return id;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((leftSide == null) ? 0 : leftSide.hashCode());
+        result = prime * result + ((program == null) ? 0 : program.hashCode());
+        result = prime * result + ((rightSide == null) ? 0 : rightSide.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;
+        ProgramValidation other = (ProgramValidation) obj;
+        if ( leftSide == null )
+        {
+            if ( other.leftSide != null )
+                return false;
+        }
+        else if ( !leftSide.equals( other.leftSide ) )
+            return false;
+        if ( program == null )
+        {
+            if ( other.program != null )
+                return false;
+        }
+        else if ( !program.equals( other.program ) )
+            return false;
+        if ( rightSide == null )
+        {
+            if ( other.rightSide != null )
+                return false;
+        }
+        else if ( !rightSide.equals( other.rightSide ) )
+            return false;
+        return true;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    public String getLeftSide()
+    {
+        return leftSide;
+    }
+
+    public void setLeftSide( String leftSide )
+    {
+        this.leftSide = leftSide;
+    }
+
+    public String getRightSide()
+    {
+        return rightSide;
+    }
+
+    public void setRightSide( String rightSide )
+    {
+        this.rightSide = rightSide;
+    }
+
+    public Program getProgram()
+    {
+        return program;
+    }
+
+    public void setProgram( Program program )
+    {
+        this.program = program;
+    }
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationService.java	2011-04-29 07:41:04 +0000
@@ -0,0 +1,53 @@
+/*
+ * 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 $ ProgramValidationService.java Apr 28, 2011 10:32:20 AM $
+ */
+public interface ProgramValidationService
+{
+    String ID = ProgramValidationService.class.getName();
+
+    int addProgramValidation( ProgramValidation programValidation );
+
+    void deleteProgramValidation( ProgramValidation programValidation );
+
+    void updateProgramValidation( ProgramValidation programValidation );
+
+    ProgramValidation getProgramValidation( int id );
+
+    Collection<ProgramValidation> getAllProgramValidation();
+
+    Collection<ProgramValidation> getProgramValidation( Program program );
+
+    boolean runValidation( ProgramValidation validation, ProgramInstance programInstance );
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramValidationStore.java	2011-04-29 07:41:04 +0000
@@ -0,0 +1,43 @@
+/*
+ * 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.GenericStore;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ ProgramValidationStore.java Apr 28, 2011 10:33:44 AM $
+ */
+public interface ProgramValidationStore
+    extends GenericStore<ProgramValidation>
+{
+    String ID = ProgramValidation.class.getName();
+
+    Collection<ProgramValidation> get( Program program );
+}

=== 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	2011-04-22 08:01:29 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2011-04-29 07:41:04 +0000
@@ -34,6 +34,8 @@
 import org.amplecode.quick.StatementManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.system.startup.AbstractStartupRoutine;
 import org.springframework.transaction.annotation.Transactional;
@@ -59,6 +61,13 @@
         this.statementManager = statementManager;
     }
 
+    private DataElementCategoryService categoryService;
+
+    public void setCategoryService( DataElementCategoryService categoryService )
+    {
+        this.categoryService = categoryService;
+    }
+
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -69,16 +78,16 @@
     {
         updatePatientOrgunitAssociation();
 
-        updateDOBType();
+        executeSql( "UPDATE patient SET dobType='A' WHERE birthdateestimated=true" );
+
+        executeSql( "ALTER TABLE patient drop column birthdateestimated" );
+
+        executeSql( "DELETE FROM validationcriteria where property='birthdateestimated'" );
 
         executeSql( "UPDATE patientattribute SET mandatory = false WHERE mandatory is NULL" );
-        
+
         executeSql( "UPDATE program SET version = 1 WHERE version is NULL" );
 
-        updateDataSetMobileAttribute();
-
-        updateDataSetVersionAttribute();
-
         executeSql( "UPDATE patientidentifiertype SET type='" + PatientIdentifierType.VALUE_TYPE_TEXT
             + "' WHERE type IS NULL" );
 
@@ -89,6 +98,13 @@
         executeSql( "UPDATE patient SET isdead=false WHERE isdead IS NULL" );
 
         executeSql( "UPDATE patient SET hasPatients=false WHERE hasPatients IS NULL" );
+
+        executeSql( "UPDATE dataset SET mobile = false WHERE mobile is null" );
+
+        executeSql( "UPDATE dataset SET version = 1 WHERE version is null" );
+        
+        updateSingleProgramValidation();
+
     }
 
     // -------------------------------------------------------------------------
@@ -130,53 +146,53 @@
         }
     }
 
-    private void updateDOBType()
-    {
-        StatementHolder holder = statementManager.getHolder();
-
-        try
-        {
-            executeSql( "UPDATE patient SET dobType='A' WHERE birthdateestimated=true" );
-
-            executeSql( "ALTER TABLE patient drop column birthdateestimated" );
-
-            executeSql( "DELETE FROM validationcriteria where property='birthdateestimated'" );
-        }
-        catch ( Exception ex )
-        {
-            log.error( ex );
-        }
-        finally
-        {
-            holder.close();
-        }
-    }
-
-    private void updateDataSetMobileAttribute()
-    {
-        StatementHolder holder = statementManager.getHolder();
-
-        try
-        {
-            executeSql( "UPDATE dataset SET mobile = false WHERE mobile is null" );
-        }
-        catch ( Exception ex )
-        {
-            log.error( ex );
-        }
-        finally
-        {
-            holder.close();
-        }
-    }
-
-    private void updateDataSetVersionAttribute()
-    {
-        StatementHolder holder = statementManager.getHolder();
-
-        try
-        {
-            executeSql( "UPDATE dataset SET version = 1 WHERE version is null" );
+    private void updateSingleProgramValidation()
+    {
+        StatementHolder holder = statementManager.getHolder();
+        
+        int optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo().getId();
+        
+        try
+        {
+            Statement statement = holder.getStatement();
+
+            ResultSet isUpdated = statement
+                .executeQuery( "SELECT * FROM INFORMATION_SCHEMA.COLUMNS " +
+                                "WHERE TABLE_NAME = 'programstage_dataelement_validation'" );
+
+            if ( isUpdated.next() )
+            {
+                ResultSet rsCount = statement.executeQuery( "SELECT max(programvalidationid) FROM programvalidation" );
+                rsCount.next();
+
+                int max = rsCount.getInt( 1 ) + 1;
+
+                ResultSet resultSet = statement
+                .executeQuery( "SELECT pdv.description, pdv.leftprogramstageid, pdv.leftdataelementid, "+
+                                      "pdv.rightprogramstageid, pdv.rightdataelementid, " +
+                                      "pdv.operator, ps.programid "+
+                                "FROM programstage_dataelement_validation pdv "+
+                                "INNER JOIN programstage_dataelements pd "+
+                                       "ON (pdv.leftprogramstageid=pd.dataelementid AND "+
+                                           "pdv.leftdataelementid=pd.programstageid) "+
+                                "INNER JOIN programstage ps "+
+                                        "ON pd.programstageid=ps.programstageid" );
+
+                while ( resultSet.next() )
+                {
+                    max++;
+                    String leftSide = "[" + resultSet.getString( 2 ) + "." + resultSet.getString( 3 ) + "." + optionCombo + "]";
+                    String rightSide = "[" + resultSet.getString( 4 ) + "." + resultSet.getString( 5 ) + "." + optionCombo + "]";
+                    String operator = resultSet.getInt( 6 ) > 0 ? ">" : ( resultSet.getInt( 6 ) < 0 ) ? "<" : "==";
+                    
+                    String fomular = leftSide + operator + rightSide;
+         
+                    executeSql( "INSERT INTO programvalidation (programvalidationid, description,leftSide, rightSide, programid )" +
+                                "VALUES ( " + max + ",'" + resultSet.getString( 1 )  + "', '" + fomular  + "', '1==1', " + resultSet.getInt( 7 )  + ")" );
+                }
+                
+                executeSql( "DROP TABLE programstage_dataelement_validation" );
+            }
         }
         catch ( Exception ex )
         {

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java	2011-04-29 07:41:04 +0000
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.program;
+
+import java.util.Collection;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author Viet Nguyen
+ * 
+ * @version $Id$
+ */
+@Transactional
+public class DefaultProgramStageDataElementService
+    implements ProgramStageDataElementService
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramStageDataElementStore programStageDataElementStore;
+
+    public void setProgramStageDataElementStore( ProgramStageDataElementStore programStageDataElementStore )
+    {
+        this.programStageDataElementStore = programStageDataElementStore;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation methods
+    // -------------------------------------------------------------------------
+
+    public void addProgramStageDataElement( ProgramStageDataElement programStageDataElement )
+    {
+        programStageDataElementStore.saveOrUpdate( programStageDataElement );
+    }
+
+    public void deleteProgramStageDataElement( ProgramStageDataElement programStageDataElement )
+    {
+        programStageDataElementStore.delete( programStageDataElement );
+    }
+
+    public Collection<ProgramStageDataElement> getAllProgramStageDataElements()
+    {
+        return programStageDataElementStore.getAll();
+    }
+
+    public Collection<ProgramStageDataElement> get( ProgramStage programStage )
+    {
+        return programStageDataElementStore.get( programStage );
+    }
+
+    public ProgramStageDataElement get( ProgramStage programStage, DataElement dataElement )
+    {
+        return programStageDataElementStore.get( programStage, dataElement );
+    }
+
+    public void updateProgramStageDataElement( ProgramStageDataElement programStageDataElement )
+    {
+        programStageDataElementStore.update( programStageDataElement );
+    }
+
+    public Collection<DataElement> getListDataElement( ProgramStage programStage )
+    {
+        return programStageDataElementStore.getListDataElement( programStage );
+    }
+
+}

=== removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementService.java	1970-01-01 00:00:00 +0000
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2004-2009, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.hisp.dhis.program;
-
-import java.util.Collection;
-
-import org.hisp.dhis.dataelement.DataElement;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * @author Viet Nguyen
- * 
- * @version $Id$
- */
-@Transactional
-public class DefaultProgramStageDataElementService
-    implements ProgramStageDataElementService
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ProgramStageDataElementStore programStageDataElementStore;
-
-    public void setProgramStageDataElementStore( ProgramStageDataElementStore programStageDataElementStore )
-    {
-        this.programStageDataElementStore = programStageDataElementStore;
-    }
-
-    // -------------------------------------------------------------------------
-    // Implementation methods
-    // -------------------------------------------------------------------------
-
-    public void addProgramStageDataElement( ProgramStageDataElement programStageDataElement )
-    {
-        programStageDataElementStore.saveOrUpdate( programStageDataElement );
-    }
-
-    public void deleteProgramStageDataElement( ProgramStageDataElement programStageDataElement )
-    {
-        programStageDataElementStore.delete( programStageDataElement );
-    }
-
-    public Collection<ProgramStageDataElement> getAllProgramStageDataElements()
-    {
-        return programStageDataElementStore.getAll();
-    }
-
-    public Collection<ProgramStageDataElement> get( ProgramStage programStage )
-    {
-        return programStageDataElementStore.get( programStage );
-    }
-
-    public ProgramStageDataElement get( ProgramStage programStage, DataElement dataElement )
-    {
-        return programStageDataElementStore.get( programStage, dataElement );
-    }
-
-    public void updateProgramStageDataElement( ProgramStageDataElement programStageDataElement )
-    {
-        programStageDataElementStore.update( programStageDataElement );
-    }
-
-    public Collection<DataElement> getListDataElement( ProgramStage programStage )
-    {
-        return programStageDataElementStore.getListDataElement( programStage );
-    }
-
-}

=== removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementValidationService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementValidationService.java	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageDataElementValidationService.java	1970-01-01 00:00:00 +0000
@@ -1,101 +0,0 @@
-/*
- * 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 DefaultProgramStageDataElementValidationService.java May 6, 2010
- *          10:18:00 AM
- */
-
-@Transactional
-public class DefaultProgramStageDataElementValidationService
-    implements ProgramStageDataElementValidationService
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ProgramStageDataElementValidationStore validationStore;
-
-    public void setValidationStore( ProgramStageDataElementValidationStore validationStore )
-    {
-        this.validationStore = validationStore;
-    }
-
-    // -------------------------------------------------------------------------
-    // Implementation methods
-    // -------------------------------------------------------------------------
-
-    public int saveProgramStageDataElementValidation( ProgramStageDataElementValidation validation )
-    {
-        return validationStore.save( validation );
-    }
-
-    public void updateProgramStageDataElementValidation( ProgramStageDataElementValidation validation )
-    {
-        validationStore.update( validation );
-    }
-
-    public void deleteProgramStageDataElementValidation( ProgramStageDataElementValidation validation )
-    {
-        validationStore.delete( validation );
-    }
-
-    public Collection<ProgramStageDataElementValidation> getAllProgramStageDataElementValidations()
-    {
-        return validationStore.getAll();
-    }
-
-    public ProgramStageDataElementValidation getProgramStageDataElementValidation( int id )
-    {
-        return validationStore.get( id );
-    }
-
-    public Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations( Program program )
-    {
-        return validationStore.getProgramStageDataElementValidations( program );
-    }
-
-    public Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations(
-        ProgramStageDataElement element )
-    {
-        return validationStore.getProgramStageDataElementValidations( element );
-    }
-
-    public Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations(
-        ProgramStage programStage )
-    {
-        return validationStore.getProgramStageDataElementValidations( programStage );
-    }
-
-}

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2011-04-29 07:41:04 +0000
@@ -0,0 +1,197 @@
+/*
+ * 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 static org.hisp.dhis.program.ProgramValidation.OBJECT_PROGRAM_STAGE_DATAELEMENT;
+import static org.hisp.dhis.program.ProgramValidation.SEPARATOR_ID;
+import static org.hisp.dhis.program.ProgramValidation.SEPARATOR_OBJECT;
+
+import java.util.Collection;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.patientdatavalue.PatientDataValue;
+import org.hisp.dhis.patientdatavalue.PatientDataValueService;
+import org.nfunk.jep.JEP;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ DefaultProgramValidationService.java Apr 28, 2011 10:36:50 AM $
+ */
+@Transactional
+public class DefaultProgramValidationService
+implements ProgramValidationService
+{
+    private ProgramValidationStore validationStore;
+
+    private ProgramStageService programStageService;
+
+    private DataElementService dataElementService;
+
+    private ProgramStageInstanceService stageInstanceService;
+
+    private PatientDataValueService valueService;
+
+    // -------------------------------------------------------------------------
+    // Setters
+    // -------------------------------------------------------------------------
+
+    public void setValidationStore( ProgramValidationStore validationStore )
+    {
+        this.validationStore = validationStore;
+    }
+
+    public void setProgramStageService( ProgramStageService programStageService )
+    {
+        this.programStageService = programStageService;
+    }
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    public void setStageInstanceService( ProgramStageInstanceService stageInstanceService )
+    {
+        this.stageInstanceService = stageInstanceService;
+    }
+
+    public void setValueService( PatientDataValueService valueService )
+    {
+        this.valueService = valueService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation methods
+    // -------------------------------------------------------------------------
+    @Override
+    public int addProgramValidation( ProgramValidation programValidation )
+    {
+        return validationStore.save( programValidation );
+    }
+
+    @Override
+    public void updateProgramValidation( ProgramValidation programValidation )
+    {
+        validationStore.update( programValidation );
+    }
+
+    @Override
+    public void deleteProgramValidation( ProgramValidation programValidation )
+    {
+        validationStore.delete( programValidation );
+    }
+
+    @Override
+    public Collection<ProgramValidation> getAllProgramValidation()
+    {
+        return validationStore.getAll();
+    }
+
+    @Override
+    public ProgramValidation getProgramValidation( int id )
+    {
+        return validationStore.get( id );
+    }
+
+    @Override
+    public boolean runValidation( ProgramValidation validation, ProgramInstance programInstance )
+    {
+        // ---------------------------------------------------------------------
+        // parse left-expressions
+        // ---------------------------------------------------------------------
+
+        boolean resultLeft = runExpression( validation.getLeftSide(), programInstance );
+
+        // ---------------------------------------------------------------------
+        // parse right-expressions
+        // ---------------------------------------------------------------------
+
+        boolean resultRight = runExpression( validation.getRightSide(), programInstance );
+        
+        return (resultLeft == resultRight);
+
+    }
+
+    public Collection<ProgramValidation> getProgramValidation( Program program )
+    {
+        return validationStore.get( program );
+    }
+
+    private boolean runExpression( String expression, ProgramInstance programInstance )
+    {
+        final String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+["
+                    + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
+        
+        StringBuffer description = new StringBuffer();
+
+        Pattern pattern = Pattern.compile( regExp );
+
+        Matcher matcher = pattern.matcher( expression );
+
+        while ( matcher.find() )
+        {
+            String match = matcher.group();
+            match = match.replaceAll( "[\\[\\]]", "" );
+
+            String[] info = match.split( SEPARATOR_OBJECT );
+            String[] ids = info[1].split( SEPARATOR_ID );
+
+            int programStageId = Integer.parseInt( ids[0] );
+            ProgramStage programStage = programStageService.getProgramStage( programStageId );
+
+            int dataElementId = Integer.parseInt( ids[1] );
+            DataElement dataElement = dataElementService.getDataElement( dataElementId );
+            
+            ProgramStageInstance stageInstance = stageInstanceService.getProgramStageInstance( programInstance,
+                programStage );
+
+            PatientDataValue dataValue = valueService.getPatientDataValue( stageInstance, dataElement, programInstance
+                .getPatient().getOrganisationUnit() );
+
+            if ( dataValue == null )
+            {
+                return true;
+            }
+
+            matcher.appendReplacement( description, dataValue.getValue() );
+        }
+
+        matcher.appendTail( description );
+
+        final JEP parser = new JEP();
+
+        parser.parseExpression( description.toString() );
+
+        return ( parser.getValue() == 1.0 );
+    }
+    
+}

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java	2011-04-29 07:41:04 +0000
@@ -51,14 +51,6 @@
         this.programStageDEService = programStageDEService;
     }
 
-    ProgramStageDataElementValidationService programStageDEValidationService;
-
-    public void setProgramStageDEValidationService(
-        ProgramStageDataElementValidationService programStageDEValidationService )
-    {
-        this.programStageDEValidationService = programStageDEValidationService;
-    }
-
     // -------------------------------------------------------------------------
     // Implementation methods
     // -------------------------------------------------------------------------
@@ -73,18 +65,6 @@
     public void deleteProgram( Program program )
     {
         // ---------------------------------------------------------------------
-        // Delete Program Stage data element validations
-        // ---------------------------------------------------------------------
-
-        Collection<ProgramStageDataElementValidation> validations = programStageDEValidationService
-            .getProgramStageDataElementValidations( program );
-
-        for ( ProgramStageDataElementValidation validation : validations )
-        {
-            programStageDEValidationService.deleteProgramStageDataElementValidation( validation );
-        }
-
-        // ---------------------------------------------------------------------
         // Delete Program Stage data elements
         // ---------------------------------------------------------------------
 
@@ -108,18 +88,6 @@
     public void deleteProgramStage( ProgramStage programStage )
     {
         // ---------------------------------------------------------------------
-        // Delete Program Stage data element validations
-        // ---------------------------------------------------------------------
-
-        Collection<ProgramStageDataElementValidation> validations = programStageDEValidationService
-            .getProgramStageDataElementValidations( programStage );
-
-        for ( ProgramStageDataElementValidation validation : validations )
-        {
-            programStageDEValidationService.deleteProgramStageDataElementValidation( validation );
-        }
-
-        // ---------------------------------------------------------------------
         // Delete Program Stage data elements
         // ---------------------------------------------------------------------
 

=== removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementValidationStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementValidationStore.java	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementValidationStore.java	1970-01-01 00:00:00 +0000
@@ -1,95 +0,0 @@
-/*
- * 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.Query;
-import org.hibernate.Session;
-import org.hisp.dhis.hibernate.HibernateGenericStore;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageDataElement;
-import org.hisp.dhis.program.ProgramStageDataElementValidation;
-import org.hisp.dhis.program.ProgramStageDataElementValidationStore;
-
-/**
- * @author Chau Thu Tran
- * @version HibernateProgramStageDataElementValidationStore.java May 10, 2010
- *          11:06:20 AM
- */
-public class HibernateProgramStageDataElementValidationStore
-    extends HibernateGenericStore<ProgramStageDataElementValidation>
-    implements ProgramStageDataElementValidationStore
-{
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations( Program program )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Query query = session
-            .createQuery( "from ProgramStageDataElementValidation c where c.leftProgramStageDataElement.programStage.program.id = :program" );
-
-        query.setInteger( "program", program.getId() );
-
-        return query.list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations(
-        ProgramStageDataElement element )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Query query = session
-            .createQuery( "from ProgramStageDataElementValidation c where "
-                + "( c.leftProgramStageDataElement.programStage.id = :programStageId and c.leftProgramStageDataElement.dataElement.id = :dataElementId ) or "
-                + "( c.rightProgramStageDataElement.programStage.id = :programStageId and c.rightProgramStageDataElement.dataElement.id = :dataElementId )" );
-
-        query.setInteger( "programStageId", element.getProgramStage().getId() );
-        query.setInteger( "dataElementId", element.getDataElement().getId() );
-
-        return query.list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramStageDataElementValidation> getProgramStageDataElementValidations(
-        ProgramStage programStage )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Query query = session
-            .createQuery( "from ProgramStageDataElementValidation c where "
-                + "c.leftProgramStageDataElement.programStage.id = :programStageId or "
-                + "c.rightProgramStageDataElement.programStage.id = :programStageId" );
-
-        query.setInteger( "programStageId", programStage.getId() );
-
-        return query.list();
-    }
-}

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramValidationStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramValidationStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramValidationStore.java	2011-04-29 07:41:04 +0000
@@ -0,0 +1,52 @@
+/*
+ * 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.Program;
+import org.hisp.dhis.program.ProgramValidation;
+import org.hisp.dhis.program.ProgramValidationStore;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ HibernateProgramValidationStore.java Apr 28, 2011 10:43:09 AM $
+ */
+public class HibernateProgramValidationStore
+    extends HibernateGenericStore<ProgramValidation>
+    implements ProgramValidationStore
+{
+    @SuppressWarnings( "unchecked" )
+    public Collection<ProgramValidation> get( Program program )
+    {
+        return getCriteria( Restrictions.eq( "program", program ) ).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	2011-01-20 04:05:32 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2011-04-29 07:41:04 +0000
@@ -48,6 +48,12 @@
 		<property name="clazz" value="org.hisp.dhis.program.Program" />
 		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>
+	
+	<bean id="org.hisp.dhis.program.ProgramValidationStore"
+		class="org.hisp.dhis.program.hibernate.HibernateProgramValidationStore">
+		<property name="clazz" value="org.hisp.dhis.program.ProgramValidation" />
+		<property name="sessionFactory" ref="sessionFactory" />
+	</bean>
 
 	<bean id="org.hisp.dhis.patient.PatientStore" class="org.hisp.dhis.patient.hibernate.HibernatePatientStore">
 		<property name="clazz" value="org.hisp.dhis.patient.Patient" />
@@ -103,12 +109,6 @@
      <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    
-   <bean id="org.hisp.dhis.program.ProgramStageDataElementValidationStore"
-	 class="org.hisp.dhis.program.hibernate.HibernateProgramStageDataElementValidationStore">
-	 <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" />
@@ -156,12 +156,6 @@
         <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />     	     	
     </bean>
     
-    <bean id="org.hisp.dhis.program.ProgramStageDataElementService"
-    class="org.hisp.dhis.program.DefaultProgramStageDataElementService">
-      <property name="programStageDataElementStore"
-        ref="org.hisp.dhis.program.ProgramStageDataElementStore"/>
-    </bean>
-	
 	<bean id="org.hisp.dhis.program.nextvisit.NextVisitGenerator"
 		class="org.hisp.dhis.program.nextvisit.DefaultNextVisitGenerator">
 		<property name="patientDataValueService"
@@ -197,6 +191,20 @@
 	<bean id="org.hisp.dhis.program.ProgramService" class="org.hisp.dhis.program.DefaultProgramService">
 		<property name="programStore" ref="org.hisp.dhis.program.ProgramStore" />
 	</bean>
+	
+	<bean id="org.hisp.dhis.program.ProgramValidationService"
+		class="org.hisp.dhis.program.DefaultProgramValidationService">
+		<property name="validationStore"
+			ref="org.hisp.dhis.program.ProgramValidationStore" />
+		<property name="programStageService"
+			ref="org.hisp.dhis.program.ProgramStageService" />
+		<property name="dataElementService"
+			ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="stageInstanceService"
+			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+		<property name="valueService"
+			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+	</bean>
 
 	<bean id="org.hisp.dhis.patient.PatientService" class="org.hisp.dhis.patient.DefaultPatientService">
 		<property name="patientStore" ref="org.hisp.dhis.patient.PatientStore" />
@@ -253,10 +261,10 @@
 			ref="org.hisp.dhis.patient.PatientAttributeGroupStore" />
 	</bean>
 	
-	<bean id="org.hisp.dhis.program.ProgramStageDataElementValidationService"
-		class="org.hisp.dhis.program.DefaultProgramStageDataElementValidationService">
-		<property name="validationStore"
-	  		ref="org.hisp.dhis.program.ProgramStageDataElementValidationStore" />
+	<bean id="org.hisp.dhis.program.ProgramStageDataElementService"
+		class="org.hisp.dhis.program.DefaultProgramStageDataElementService">
+		<property name="programStageDataElementStore"
+	  		ref="org.hisp.dhis.program.ProgramStageDataElementStore" />
   	</bean>
   
   	<bean id="org.hisp.dhis.program.ProgramAttributeService" class="org.hisp.dhis.program.DefaultProgramAttributeService">
@@ -301,7 +309,6 @@
 		class="org.hisp.dhis.program.ProgramInstanceDeletionHandler">
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService"/>
 		<property name="patientDataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService"/>
-		<property name="programStageDEService" ref="org.hisp.dhis.program.ProgramStageDataElementService"/>
 		<property name="programAttributeValueService" ref="org.hisp.dhis.programattributevalue.ProgramAttributeValueService"/>
 	</bean>
 	
@@ -336,7 +343,6 @@
 	<bean id="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler" 
 		class="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler">
 		<property name="programStageDEService" ref="org.hisp.dhis.program.ProgramStageDataElementService"/>
-		<property name="programStageDEValidationService" ref="org.hisp.dhis.program.ProgramStageDataElementValidationService"/>
 	</bean>
 	
 	<!-- Startup -->
@@ -346,6 +352,7 @@
 		<property name="name" value="PatientTableAlteror" />
 		<property name="runlevel" value="4" />
 		<property name="skipInTests" value="true" />
+		<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
 	</bean>
 	
 	<bean id="org.hisp.dhis.patient.startup.ProgramAttributePopulator" class="org.hisp.dhis.patient.startup.ProgramAttributePopulator">

=== removed file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElementValidation.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElementValidation.hbm.xml	2011-04-12 13:44:50 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElementValidation.hbm.xml	1970-01-01 00:00:00 +0000
@@ -1,30 +0,0 @@
-<?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.ProgramStageDataElementValidation" table="programstage_dataelement_validation">
-
-    <id name="id" column="programstagedevalidationid">
-      <generator class="native" />
-    </id>
-
-    <property name="description" />
-
-    <many-to-one name="leftProgramStageDataElement" class="org.hisp.dhis.program.ProgramStageDataElement"
-      lazy="false" cascade="save-update">
-      <column name="leftdataelementid" />
-      <column name="leftprogramstageid" />
-    </many-to-one>
-
-    <many-to-one name="rightProgramStageDataElement" class="org.hisp.dhis.program.ProgramStageDataElement"
-      lazy="false" cascade="save-update">
-      <column name="rightdataelementid" />
-      <column name="rightprogramstageid" />
-    </many-to-one>
-
-    <property name="operator" not-null="true" />
-
-  </class>
-</hibernate-mapping>

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramValidation.hbm.xml	2011-04-29 07:41:04 +0000
@@ -0,0 +1,24 @@
+<?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.ProgramValidation"
+		table="programvalidation">
+
+		<id name="id" column="programvalidationid">
+			<generator class="native" />
+		</id>
+
+		<property name="description" type="text" />
+
+		<property name="leftSide" />
+
+		<property name="rightSide" type="text" not-null="true" />
+
+		<many-to-one name="program" class="org.hisp.dhis.program.Program"
+			column="programid" not-null="true" foreign-key="fk_programvalidation_programid" />
+
+	</class>
+</hibernate-mapping>

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java	2011-04-29 07:41:04 +0000
@@ -0,0 +1,284 @@
+/*
+ * 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.caseentry.action.caseentry;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.hisp.dhis.caseentry.state.SelectedStateManager;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patientdatavalue.PatientDataValue;
+import org.hisp.dhis.patientdatavalue.PatientDataValueService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageDataElement;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.program.ProgramValidation;
+import org.hisp.dhis.program.ProgramValidationService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ ValidateProgramInstanceAction.java Apr 28, 2011 10:56:10 AM $
+ */
+public class ValidateProgramInstanceAction
+    implements Action
+{
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private SelectedStateManager selectedStateManager;
+
+    private ProgramInstanceService programInstanceService;
+
+    private ProgramStageInstanceService programStageInstanceService;
+
+    private PatientDataValueService patientDataValueService;
+
+    private ProgramValidationService programValidationService;
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private I18nFormat format;
+
+    private I18n i18n;
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private Map<DataElement, String> resultDEMultiStages;
+
+    private List<ProgramValidation> programValidations;
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
+    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+    {
+        this.selectedStateManager = selectedStateManager;
+    }
+
+    public List<ProgramValidation> getProgramValidations()
+    {
+        return programValidations;
+    }
+
+    public void setProgramValidationService( ProgramValidationService programValidationService )
+    {
+        this.programValidationService = programValidationService;
+    }
+    
+    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+    {
+        this.programStageInstanceService = programStageInstanceService;
+    }
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
+    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+    {
+        this.programInstanceService = programInstanceService;
+    }
+
+    public void setPatientDataValueService( PatientDataValueService patientDataValueService )
+    {
+        this.patientDataValueService = patientDataValueService;
+    }
+
+    public Map<DataElement, String> getResultDEMultiStages()
+    {
+        return resultDEMultiStages;
+    }
+
+    public void setI18n( I18n i18n )
+    {
+        this.i18n = i18n;
+    }
+
+    public SelectedStateManager getSelectedStateManager()
+    {
+        return selectedStateManager;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        resultDEMultiStages = new HashMap<DataElement, String>();
+
+        programValidations = new ArrayList<ProgramValidation>();
+
+        // ---------------------------------------------------------------------
+        // Get selected objects
+        // ---------------------------------------------------------------------
+
+        OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+
+        Patient patient = selectedStateManager.getSelectedPatient();
+
+        Program program = selectedStateManager.getSelectedProgram();
+
+        ProgramStage programStage = selectedStateManager.getSelectedProgramStage();
+
+        Collection<ProgramInstance> progamInstances = programInstanceService.getProgramInstances( patient, program,
+            false );
+
+        ProgramInstance programInstance = progamInstances.iterator().next();
+
+        ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(
+            programInstance, programStage );
+
+        // ---------------------------------------------------------------------
+        // Get selected objects
+        // ---------------------------------------------------------------------
+        Set<ProgramStageDataElement> dataElements = programStage.getProgramStageDataElements();
+
+        for ( ProgramStageDataElement psDataElement : dataElements )
+        {
+            DataElement dataElement = psDataElement.getDataElement();
+            
+            // resultDEMultiStages
+            checkDataElementInMultiStage( programStageInstance, organisationUnit, dataElement );
+
+        }
+        // end Check validation for dataElement into the Stage
+
+        // ---------------------------------------------------------------------
+        // Check validations for dataelement into multi-stages
+        // ---------------------------------------------------------------------
+
+        runProgramValidation( programValidationService.getProgramValidation( programInstance.getProgram() ), programInstance );
+
+        return SUCCESS;
+    }
+
+    // -------------------------------------------------------------------------
+    // Support method
+    // -------------------------------------------------------------------------
+
+    /**
+     * ------------------------------------------------------------------------
+     * // Check value of the dataElment into previous . // If the value exists,
+     * allow users to enter data of // the dataElement into the
+     * programStageInstance // Else, disable Input-field of the dataElement
+     * ------------------------------------------------------------------------
+     **/
+
+    private void checkDataElementInMultiStage( ProgramStageInstance programStageInstance,
+        OrganisationUnit organisationUnit, DataElement dataElement )
+    {
+        ProgramInstance programInstance = programStageInstance.getProgramInstance();
+        List<ProgramStage> stages = new ArrayList<ProgramStage>( programInstance.getProgram().getProgramStages() );
+
+        int index = stages.indexOf( programStageInstance.getProgramStage() );
+
+        if ( index != -1 && index != 0 )
+        {
+            ProgramStage prevStage = stages.get( index - 1 );
+            ProgramStageInstance prevStageInstance = programStageInstanceService.getProgramStageInstance(
+                programInstance, prevStage );
+            PatientDataValue prevValue = patientDataValueService.getPatientDataValue( prevStageInstance, dataElement,
+                organisationUnit );
+
+            if ( prevValue == null )
+            {
+                String message = i18n.getString( "selected" ) + " " + i18n.getString( "program_stage" ) + " "
+                    + i18n.getString( "should" ) + " " + i18n.getString( "data_value" ) + " "
+                    + i18n.getString( "is_null" );
+
+                resultDEMultiStages.put( dataElement, message );
+            }
+        }
+
+    }
+
+    private void runProgramValidation( Collection<ProgramValidation> validations, ProgramInstance programInstance )
+        throws Exception
+    {
+        if ( validations != null )
+        {
+
+            for ( ProgramValidation validation : validations )
+            {
+                boolean valid = programValidationService.runValidation( validation, programInstance );
+
+                if ( !valid )
+                {
+                    programValidations.add( validation );
+                }
+            }
+        }
+
+    }
+
+    private Object getObject( String type, String value )
+        throws Exception
+    {
+        if ( type.equals( DataElement.VALUE_TYPE_INT ) )
+        {
+            return Integer.valueOf( value );
+        }
+        else if ( type.equals( DataElement.VALUE_TYPE_BOOL ) )
+        {
+            return Boolean.valueOf( value );
+        }
+        else if ( type.equals( DataElement.VALUE_TYPE_DATE ) )
+        {
+            return format.parseDate( value.trim() );
+        }
+
+        return value;
+
+    }
+
+}

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateValueAction.java	2011-04-06 03:19:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateValueAction.java	1970-01-01 00:00:00 +0000
@@ -1,328 +0,0 @@
-/*
- * 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.caseentry.action.caseentry;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.patientdatavalue.PatientDataValue;
-import org.hisp.dhis.patientdatavalue.PatientDataValueService;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramInstanceService;
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageDataElement;
-import org.hisp.dhis.program.ProgramStageDataElementValidation;
-import org.hisp.dhis.program.ProgramStageDataElementValidationService;
-import org.hisp.dhis.program.ProgramStageInstance;
-import org.hisp.dhis.program.ProgramStageInstanceService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- * @version ValidateValueAction.java May 11, 2010 2:13:52 PM
- */
-public class ValidateValueAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private SelectedStateManager selectedStateManager;
-
-    private DataElementService dataElementService;
-
-    private ProgramInstanceService programInstanceService;
-
-    private ProgramStageInstanceService programStageInstanceService;
-
-    private ProgramStageDataElementValidationService validationService;
-
-    private PatientDataValueService patientDataValueService;
-
-    private PatientService patientService;
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private boolean providedByAnotherFacility;
-
-    private String value;
-
-    private int dataElementId;
-
-    private int statusCode;
-
-    private I18nFormat format;
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private List<ProgramStageDataElementValidation> resultValidation;
-
-    // -------------------------------------------------------------------------
-    // Getters && Setters
-    // -------------------------------------------------------------------------
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
-    public void setValidationService( ProgramStageDataElementValidationService validationService )
-    {
-        this.validationService = validationService;
-    }
-
-    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
-    {
-        this.programStageInstanceService = programStageInstanceService;
-    }
-
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
-    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
-    {
-        this.programInstanceService = programInstanceService;
-    }
-
-    public void setPatientDataValueService( PatientDataValueService patientDataValueService )
-    {
-        this.patientDataValueService = patientDataValueService;
-    }
-
-    public void setPatientService( PatientService patientService )
-    {
-        this.patientService = patientService;
-    }
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
-    public int getDataElementId()
-    {
-        return dataElementId;
-    }
-
-    public int getStatusCode()
-    {
-        return statusCode;
-    }
-
-    public void setStatusCode( int statusCode )
-    {
-        this.statusCode = statusCode;
-    }
-
-    public void setValue( String value )
-    {
-        this.value = value;
-    }
-
-    public void setProvidedByAnotherFacility( boolean providedByAnotherFacility )
-    {
-        this.providedByAnotherFacility = providedByAnotherFacility;
-    }
-
-    public void setDataElementId( int dataElementId )
-    {
-        this.dataElementId = dataElementId;
-    }
-
-    public SelectedStateManager getSelectedStateManager()
-    {
-        return selectedStateManager;
-    }
-
-    public ProgramStageDataElementValidationService getValidationService()
-    {
-        return validationService;
-    }
-
-    public boolean isProvidedByAnotherFacility()
-    {
-        return providedByAnotherFacility;
-    }
-
-    public String getValue()
-    {
-        return value;
-    }
-
-    public List<ProgramStageDataElementValidation> getResultValidation()
-    {
-        return resultValidation;
-    }
-
-    public void setResultValidation( List<ProgramStageDataElementValidation> resultValidation )
-    {
-        this.resultValidation = resultValidation;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-        throws Exception
-    {
-        OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
-        Patient patient = selectedStateManager.getSelectedPatient();
-
-        Program program = selectedStateManager.getSelectedProgram();
-
-        ProgramStage programStage = selectedStateManager.getSelectedProgramStage();
-
-        Collection<ProgramInstance> progamInstances = programInstanceService.getProgramInstances( patient, program,
-            false );
-
-        ProgramInstance programInstance = progamInstances.iterator().next();
-
-        DataElement dataElement = dataElementService.getDataElement( dataElementId );
-
-        // Check validation for dataElement into the Stage
-
-        ProgramStageDataElement element = new ProgramStageDataElement( programStage, dataElement, false );
-
-        Collection<ProgramStageDataElementValidation> validations = validationService
-            .getProgramStageDataElementValidations( element );
-
-        resultValidation = validation( validations, organisationUnit, programInstance, value, programStage, dataElement );
-
-        if ( resultValidation.size() > 0 )
-        {
-            statusCode = 1;
-
-            return INPUT;
-        }
-
-        return SUCCESS;
-    }
-
-    // -------------------------------------------------------------------------
-    // Support methods
-    // -------------------------------------------------------------------------
-
-    @SuppressWarnings( "unchecked" )
-    private List<ProgramStageDataElementValidation> validation(
-        Collection<ProgramStageDataElementValidation> validations, OrganisationUnit organisationUnit,
-        ProgramInstance programInstance, String value, ProgramStage programStage, DataElement dataElement )
-        throws Exception
-    {
-        List<ProgramStageDataElementValidation> result = new ArrayList<ProgramStageDataElementValidation>();
-
-        if ( validations != null )
-        {
-
-            for ( ProgramStageDataElementValidation validation : validations )
-            {
-                // Get left-side
-                ProgramStageDataElement leftSide = validation.getLeftProgramStageDataElement();
-                // Get right-side
-                ProgramStageDataElement rightSide = validation.getRightProgramStageDataElement();
-
-                // Get stageInstance to compare
-                ProgramStageInstance comparerogramStageInstance = null;
-
-                int i = 2;
-                if ( leftSide.getProgramStage().equals( programStage )
-                    && leftSide.getDataElement().equals( dataElement ) )
-                {
-                    // get left-side value
-                    Object objectValue = patientService.getObjectValue( leftSide.getDataElement().getType(), value, format );
-
-                    // get program-stage of right-side
-                    comparerogramStageInstance = programStageInstanceService.getProgramStageInstance( programInstance,
-                        rightSide.getProgramStage() );
-
-                    // Get value into right-right to compare;
-                    PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue(
-                        comparerogramStageInstance, rightSide.getDataElement(), organisationUnit );
-
-                    if ( patientDataValue != null )
-                    {
-                        String dbValue = patientDataValue.getValue();
-                        Object compareValue = patientService.getObjectValue( rightSide.getDataElement().getType(),
-                            dbValue, format );
-
-                        i = ((Comparable<Object>) objectValue).compareTo( (Comparable<Object>) compareValue );
-                    }
-
-                }
-                else
-                {
-                    // get right-side value
-                    Object objectValue = patientService.getObjectValue( rightSide.getDataElement().getType(), value, format );
-
-                    comparerogramStageInstance = programStageInstanceService.getProgramStageInstance( programInstance,
-                        leftSide.getProgramStage() );
-
-                    // Get value to compare;
-                    PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue(
-                        comparerogramStageInstance, leftSide.getDataElement(), organisationUnit );
-                    if ( patientDataValue != null )
-                    {
-                        String dbValue = patientDataValue.getValue();
-                        Object compareValue = patientService.getObjectValue( leftSide.getDataElement().getType(),
-                            dbValue, format );
-
-                        i = ((Comparable<Object>) compareValue).compareTo( (Comparable<Object>) objectValue );
-                    }
-                }
-
-                if ( i != validation.getOperator() && i != 2 )
-                {
-                    result.add( validation );
-                }
-
-            }
-        }
-
-        return result;
-    }
-
-}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2011-04-01 03:00:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2011-04-29 07:41:04 +0000
@@ -190,22 +190,6 @@
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 	</bean>
 
-	<bean id="org.hisp.dhis.caseentry.action.caseentry.ValidateValueAction"
-		class="org.hisp.dhis.caseentry.action.caseentry.ValidateValueAction"
-		scope="prototype">
-		<property name="selectedStateManager"
-			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
-		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
-		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
-		<property name="programStageInstanceService"
-			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
-		<property name="patientDataValueService"
-			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
-		<property name="validationService"
-			ref="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
-		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
-	</bean>
-
 	<!-- Multi DataEntry -->
 
 	<bean
@@ -407,4 +391,18 @@
 			ref="org.hisp.dhis.caseentry.state.PeriodGenericManager" />
 	</bean>
 	
+	<bean id="org.hisp.dhis.caseentry.action.caseentry.ValidateProgramInstanceAction"
+		class="org.hisp.dhis.caseentry.action.caseentry.ValidateProgramInstanceAction"
+		scope="prototype">
+		<property name="selectedStateManager"
+			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+		<property name="programStageInstanceService"
+			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+		<property name="patientDataValueService"
+			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+		<property name="programValidationService"
+			ref="org.hisp.dhis.program.ProgramValidationService" />
+	</bean>
+	
 </beans>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2011-04-06 07:55:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2011-04-29 07:41:04 +0000
@@ -296,3 +296,14 @@
 program_stage_lack_data_elements 								= The program stage lack data elements 
 multiple_dataentry												= Multiple Data Entry
 intro_multiple_dataentry 										= Enter data for beneficiaries by selecting a program.
+in																= In
+is_null															= is null
+data_value														= datavalue
+successful_validation											= The data entry screen successfully passed validation
+unsuccessful_validation											= The data entry screen has validation errors, please correct these before proceeding
+the_following_values_violates_rules 							= The following values violates validation rules
+the_following_dataelements_are_in_multi_stages					= The following	dataelements are in multi-program stages
+validation_result												= Validation Result
+should															= should
+validation														= Validation
+program_validation_description									= Program Validation Description
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-03-24 03:34:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-04-29 07:41:04 +0000
@@ -90,19 +90,15 @@
     </action>
     
     <!-- save value -->
-    <action name="saveValue" class="org.hisp.dhis.caseentry.action.caseentry.ValidateValueAction">
-      <result name="success" type="chain">saveValueChain</result>
-      <result name="input" type="velocity-xml">/dhis-web-caseentry/status.vm</result>
-      <param name="onExceptionReturn">plainTextError</param>      
-    </action> 
     
-    <action name="saveValueChain" class="org.hisp.dhis.caseentry.action.caseentry.SaveValueAction">
+    <action name="saveValue" class="org.hisp.dhis.caseentry.action.caseentry.SaveValueAction">
       <result name="success" type="velocity">status.vm</result>
       <result name="input" type="velocity-xml">/dhis-web-caseentry/responseInput.vm</result>
       <param name="onExceptionReturn">plainTextError</param>      
     </action>
     
     <!-- save data-value -->
+    
     <action name="saveDateValue" class="org.hisp.dhis.caseentry.action.caseentry.ValidateValueAction">
       <result name="success" type="chain">saveDateValueChain</result>
       <result name="input" type="velocity-xml">/dhis-web-caseentry/status.vm</result>
@@ -258,5 +254,10 @@
 		<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonPeriods.vm</result>
 	</action>
 		  
+	<action name="validateProgram" class="org.hisp.dhis.caseentry.action.caseentry.ValidateProgramInstanceAction">
+      <result name="success" type="velocity">/popup.vm</result>
+      <param name="page">/dhis-web-caseentry/validationResult.vm</param>
+    </action>
+    
   </package>
 </struts>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm	2011-04-05 04:29:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm	2011-04-29 07:41:04 +0000
@@ -82,7 +82,12 @@
         #end
     </tr>   
 	<tr>
-		<td><input type="button" id="completeBtn" value="$i18n.getString('complete')" onClick="doComplete()"></td>
+		<td>
+			<input type="button" id="completeBtn" value="$i18n.getString('complete')" onClick="doComplete()" style="width:12em">
+		</td>
+		<td>
+			<input type="button" id="validationBtn" value="$i18n.getString('validation')" onClick="window.open( 'validateProgram.action', '_blank', 'width=800, height=400, scrollbars=yes, resizable=yes' );" style="width:12em">
+		</td>
 	</tr>
 </table>
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js	2011-04-05 04:29:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js	2011-04-29 07:41:04 +0000
@@ -1172,9 +1172,11 @@
         jQuery("#startMsg").hide();
         jQuery("#entryFormContainer").show();
         jQuery("#completeBtn").removeAttr('disabled');
+		jQuery("#validationBtn").removeAttr('disabled');
     }else {
         jQuery("#entryFormContainer").hide();
         jQuery("#completeBtn").attr('disabled', 'disabled');
+		jQuery("#validationBtn").attr('disabled', 'disabled');
         jQuery("#startMsg").show();
     }
 }

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowValidationDEAssociationsFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowValidationDEAssociationsFormAction.java	2011-03-31 01:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowValidationDEAssociationsFormAction.java	1970-01-01 00:00:00 +0000
@@ -1,121 +0,0 @@
-/*
- * 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.Program;
-import org.hisp.dhis.program.ProgramService;
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageDataElementValidation;
-import org.hisp.dhis.program.ProgramStageDataElementValidationService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- * @version ShowValidationDEAssociationsFormAction.java May 5, 2010 9:35:09 AM
- */
-public class ShowValidationDEAssociationsFormAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ProgramService programService;
-
-    private ProgramStageDataElementValidationService programStageDEValidationService;
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private Program program;
-
-    private Collection<ProgramStage> stages;
-    
-    private Collection<ProgramStageDataElementValidation> validations;
-
-    // -------------------------------------------------------------------------
-    // Getters && Setters
-    // -------------------------------------------------------------------------
-
-    public Program getProgram()
-    {
-        return program;
-    }
-
-    public Collection<ProgramStageDataElementValidation> getValidations()
-    {
-        return validations;
-    }
-
-    public void setProgramStageDEValidationService( ProgramStageDataElementValidationService programStageDEValidationService )
-    {
-        this.programStageDEValidationService = programStageDEValidationService;
-    }
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
-    public Collection<ProgramStage> getStages()
-    {
-        return stages;
-    }
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-        throws Exception
-    {
-        program = programService.getProgram( id );
-
-        stages = program.getProgramStages();
-
-        validations = programStageDEValidationService.getProgramStageDataElementValidations( program );
-
-        return SUCCESS;
-    }
-}

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramStageDEValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramStageDEValidationAction.java	2011-04-26 09:00:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramStageDEValidationAction.java	1970-01-01 00:00:00 +0000
@@ -1,201 +0,0 @@
-/*
- * 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.validation;
-
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageDataElement;
-import org.hisp.dhis.program.ProgramStageDataElementService;
-import org.hisp.dhis.program.ProgramStageDataElementValidation;
-import org.hisp.dhis.program.ProgramStageDataElementValidationService;
-import org.hisp.dhis.program.ProgramStageService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- * @version AddProgramStageDataElementValidation.java May 6, 2010 1:28:06 PM
- */
-public class AddProgramStageDEValidationAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ProgramStageDataElementValidationService validationService;
-
-    private ProgramStageService programStageService;
-
-    private DataElementService dataElementService;
-
-    private ProgramStageDataElementService programStageDataElementService;
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private String description;
-
-    private Integer leftProgramStageId;
-
-    private Integer leftDataElementId;
-
-    private int operator;
-
-    private Integer rightProgramStageId;
-
-    private Integer rightDataElementId;
-
-    private ProgramStageDataElementValidation validation;
-
-    // -------------------------------------------------------------------------
-    // Setters
-    // -------------------------------------------------------------------------
-
-    public void setValidationService( ProgramStageDataElementValidationService validationService )
-    {
-        this.validationService = validationService;
-    }
-
-    public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService )
-    {
-        this.programStageDataElementService = programStageDataElementService;
-    }
-
-    public void setProgramStageService( ProgramStageService programStageService )
-    {
-        this.programStageService = programStageService;
-    }
-
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
-    public void setDescription( String description )
-    {
-        this.description = description;
-    }
-
-    public void setLeftProgramStageId( Integer leftProgramStageId )
-    {
-        this.leftProgramStageId = leftProgramStageId;
-    }
-
-    public void setLeftDataElementId( Integer leftDataElementId )
-    {
-        this.leftDataElementId = leftDataElementId;
-    }
-
-    public void setRightProgramStageId( Integer rightProgramStageId )
-    {
-        this.rightProgramStageId = rightProgramStageId;
-    }
-
-    public void setRightDataElementId( Integer rightDataElementId )
-    {
-        this.rightDataElementId = rightDataElementId;
-    }
-
-    public void setOperator( int operator )
-    {
-        this.operator = operator;
-    }
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    public ProgramStageDataElementValidation getValidation()
-    {
-        return validation;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action Implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-        throws Exception
-    {
-        validation = new ProgramStageDataElementValidation();
-
-        validation.setDescription( description );
-
-        // ---------------------------------------------------------------------
-        // leftProgramStageDataElement
-        // ---------------------------------------------------------------------
-
-        ProgramStage programStage = programStageService.getProgramStage( leftProgramStageId );
-
-        DataElement dataElement = dataElementService.getDataElement( leftDataElementId );
-
-        ProgramStageDataElement leftProgramStageDataElement = programStageDataElementService.get( programStage,
-            dataElement );
-
-        if ( leftProgramStageDataElement == null )
-        {
-            leftProgramStageDataElement = new ProgramStageDataElement( programStage, dataElement, false );
-        }
-
-        validation.setLeftProgramStageDataElement( leftProgramStageDataElement );
-
-        // ---------------------------------------------------------------------
-        // rightProgramStageDataElement
-        // ---------------------------------------------------------------------
-
-        programStage = programStageService.getProgramStage( rightProgramStageId );
-
-        dataElement = dataElementService.getDataElement( rightDataElementId );
-
-        ProgramStageDataElement rightProgramStageDataElement = programStageDataElementService.get( programStage,
-            dataElement );
-
-        if ( rightProgramStageDataElement == null )
-        {
-            rightProgramStageDataElement = new ProgramStageDataElement( programStage, dataElement, false );
-        }
-
-        validation.setRightProgramStageDataElement( rightProgramStageDataElement );
-
-        // ---------------------------------------------------------------------
-        // Operator
-        // ---------------------------------------------------------------------
-
-        validation.setOperator( operator );
-
-        int id = validationService.saveProgramStageDataElementValidation( validation );
-
-        validation = validationService.getProgramStageDataElementValidation( id );
-
-        return SUCCESS;
-    }
-}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramValidationAction.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/validation/AddProgramValidationAction.java	2011-04-29 07:41:04 +0000
@@ -0,0 +1,125 @@
+/*
+ * 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.validation;
+
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramValidation;
+import org.hisp.dhis.program.ProgramValidationService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ AddProgramValidationAction.java Apr 28, 2011 11:15:06 AM $
+ */
+public class AddProgramValidationAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramValidationService programValidationService;
+
+    private ProgramService programService;
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private String description;
+
+    private String leftSide;
+
+    private String rightSide;
+
+    private Integer programId;
+
+    // -------------------------------------------------------------------------
+    // Setters
+    // -------------------------------------------------------------------------
+    
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    public void setProgramValidationService( ProgramValidationService programValidationService )
+    {
+        this.programValidationService = programValidationService;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    public void setLeftSide( String leftSide )
+    {
+        this.leftSide = leftSide;
+    }
+
+    public void setRightSide( String rightSide )
+    {
+        this.rightSide = rightSide;
+    }
+
+    public Integer getProgramId()
+    {
+        return programId;
+    }
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        ProgramValidation validation = new ProgramValidation();
+
+        validation.setDescription( description );
+        validation.setLeftSide( leftSide );
+        validation.setRightSide( rightSide );
+
+        Program program = programService.getProgram( programId );
+        validation.setProgram( program );
+
+        programValidationService.addProgramValidation( validation );
+
+        return SUCCESS;
+    }
+
+}

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationAction.java	2010-05-12 02:15:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationAction.java	1970-01-01 00:00:00 +0000
@@ -1,87 +0,0 @@
-/*
- * 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.validation;
-
-import org.hisp.dhis.program.ProgramStageDataElementValidation;
-import org.hisp.dhis.program.ProgramStageDataElementValidationService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- * @version AddProgramStageDataElementValidation.java May 6, 2010 1:28:06 PM
- */
-public class GetProgramStageDEValidationAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependency
-    // -------------------------------------------------------------------------
-
-    private ProgramStageDataElementValidationService validationService;
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private int id;
-
-    private ProgramStageDataElementValidation validation;
-
-    // -------------------------------------------------------------------------
-    // Setters
-    // -------------------------------------------------------------------------
-
-    public void setValidationService( ProgramStageDataElementValidationService validationService )
-    {
-        this.validationService = validationService;
-    }
-
-    public ProgramStageDataElementValidation getValidation()
-    {
-        return validation;
-    }
-
-    public void setId( int id )
-    {
-        this.id = id;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action Implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-        throws Exception
-    {
-        validation = validationService.getProgramStageDataElementValidation( id );
-
-        return SUCCESS;
-    }
-}

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationListAction.java	2011-03-31 01:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramStageDEValidationListAction.java	1970-01-01 00:00:00 +0000
@@ -1,83 +0,0 @@
-/*
- * 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.validation;
-
-import java.util.Collection;
-
-import org.hisp.dhis.program.ProgramStageDataElementValidation;
-import org.hisp.dhis.program.ProgramStageDataElementValidationService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- * @version GetProgramStageDEValidationListAction.java May 6, 2010 1:28:06 PM
- */
-public class GetProgramStageDEValidationListAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependency
-    // -------------------------------------------------------------------------
-
-    private ProgramStageDataElementValidationService programStageDataElementValidationService;
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private Collection<ProgramStageDataElementValidation> validations;
-
-    // -------------------------------------------------------------------------
-    // Getter && Setter
-    // -------------------------------------------------------------------------
-
-    public void setProgramStageDataElementValidationService(
-        ProgramStageDataElementValidationService programStageDataElementValidationService )
-    {
-        this.programStageDataElementValidationService = programStageDataElementValidationService;
-    }
-
-    public Collection<ProgramStageDataElementValidation> getValidations()
-    {
-        return validations;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action Implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-        throws Exception
-    {
-        validations = programStageDataElementValidationService.getAllProgramStageDataElementValidations();
-
-        return SUCCESS;
-    }
-}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationAction.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/validation/GetProgramValidationAction.java	2011-04-29 07:41:04 +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.patient.action.validation;
+
+import org.hisp.dhis.program.ProgramValidation;
+import org.hisp.dhis.program.ProgramValidationService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ GetProgramValidationAction.java Apr 28, 2011 11:17:58 AM $
+ */
+public class GetProgramValidationAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramValidationService programValidationService;
+
+    // -------------------------------------------------------------------------
+    // Input && Output
+    // -------------------------------------------------------------------------
+
+    private Integer validationId;
+
+    private ProgramValidation validation;
+
+    // -------------------------------------------------------------------------
+    // Getter && Setter
+    // -------------------------------------------------------------------------
+
+    public void setProgramValidationService( ProgramValidationService programValidationService )
+    {
+        this.programValidationService = programValidationService;
+    }
+
+    public void setValidationId( Integer validationId )
+    {
+        this.validationId = validationId;
+    }
+
+    public ProgramValidation getValidation()
+    {
+        return validation;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        validation = programValidationService.getProgramValidation( validationId );
+
+        return SUCCESS;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/GetProgramValidationListAction.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/validation/GetProgramValidationListAction.java	2011-04-29 07:41:04 +0000
@@ -0,0 +1,107 @@
+/*
+ * 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.validation;
+
+import java.util.Collection;
+
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramValidation;
+import org.hisp.dhis.program.ProgramValidationService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ GetProgramValidationListAction.java Apr 28, 2011 11:19:56 AM $
+ */
+public class GetProgramValidationListAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramValidationService programValidationService;
+
+    private ProgramService programService;
+
+    // -------------------------------------------------------------------------
+    // Input && Output
+    // -------------------------------------------------------------------------
+
+    private Integer programId;
+
+    private Collection<ProgramValidation> validations;
+
+    // -------------------------------------------------------------------------
+    // Getter && Setter
+    // -------------------------------------------------------------------------
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    public Collection<ProgramValidation> getValidations()
+    {
+        return validations;
+    }
+
+    public void setProgramValidationService( ProgramValidationService programValidationService )
+    {
+        this.programValidationService = programValidationService;
+    }
+
+    public Integer getProgramId()
+    {
+        return programId;
+    }
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        Program program = programService.getProgram( programId );
+
+        validations = programValidationService.getProgramValidation( program );
+
+        return SUCCESS;
+    }
+
+}

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramStageDEValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramStageDEValidationAction.java	2010-05-12 02:15:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramStageDEValidationAction.java	1970-01-01 00:00:00 +0000
@@ -1,82 +0,0 @@
-/*
- * 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.validation;
-
-import org.hisp.dhis.program.ProgramStageDataElementValidation;
-import org.hisp.dhis.program.ProgramStageDataElementValidationService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- * @version AddProgramStageDataElementValidation.java May 6, 2010 1:28:06 PM
- */
-public class RemoveProgramStageDEValidationAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependency
-    // -------------------------------------------------------------------------
-
-    private ProgramStageDataElementValidationService validationService;
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private int id;
-
-    // -------------------------------------------------------------------------
-    // Setters
-    // -------------------------------------------------------------------------
-
-    public void setValidationService( ProgramStageDataElementValidationService validationService )
-    {
-        this.validationService = validationService;
-    }
-
-    public void setId( int id )
-    {
-        this.id = id;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action Implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-        throws Exception
-    {
-        ProgramStageDataElementValidation validation = validationService.getProgramStageDataElementValidation( id );
-        
-        validationService.deleteProgramStageDataElementValidation( validation );
-
-        return SUCCESS;
-    }
-}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/RemoveProgramValidationAction.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/validation/RemoveProgramValidationAction.java	2011-04-29 07:41:04 +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.validation;
+
+import org.hisp.dhis.program.ProgramValidation;
+import org.hisp.dhis.program.ProgramValidationService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ RemoveProgramValidationAction.java Apr 28, 2011 11:22:14 AM $
+ */
+public class RemoveProgramValidationAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramValidationService programValidationService;
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    // -------------------------------------------------------------------------
+    // Setters
+    // -------------------------------------------------------------------------
+
+    public void setProgramValidationService( ProgramValidationService programValidationService )
+    {
+        this.programValidationService = programValidationService;
+    }
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        ProgramValidation validation = programValidationService.getProgramValidation( id );
+
+        programValidationService.deleteProgramValidation( validation );
+
+        return SUCCESS;
+    }
+    
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateProgramValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/UpdateProgramValidationAction.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/validation/UpdateProgramValidationAction.java	2011-04-29 07:41:04 +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.patient.action.validation;
+
+import org.hisp.dhis.program.ProgramValidation;
+import org.hisp.dhis.program.ProgramValidationService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ UpdateProgramValidationAction.java Apr 28, 2011 11:24:43 AM $
+ */
+public class UpdateProgramValidationAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramValidationService programValidationService;
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    private String description;
+
+    private String leftSide;
+
+    private String rightSide;
+
+    private Integer programId;
+
+    // -------------------------------------------------------------------------
+    // Setters
+    // -------------------------------------------------------------------------
+
+    public void setProgramValidationService( ProgramValidationService programValidationService )
+    {
+        this.programValidationService = programValidationService;
+    }
+
+    public Integer getProgramId()
+    {
+        return programId;
+    }
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    public void setLeftSide( String leftSide )
+    {
+        this.leftSide = leftSide;
+    }
+
+    public void setRightSide( String rightSide )
+    {
+        this.rightSide = rightSide;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        ProgramValidation validation = programValidationService.getProgramValidation( id );
+
+        programId = validation.getProgram().getId();
+
+        validation.setDescription( description );
+        validation.setLeftSide( leftSide );
+        validation.setRightSide( rightSide );
+        programValidationService.updateProgramValidation( validation );
+
+        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	2011-04-26 02:06:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2011-04-29 07:41:04 +0000
@@ -720,18 +720,7 @@
 			ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
-
-	<!-- Program_ValidationDE Association  -->
-
-	<bean
-		id="org.hisp.dhis.patient.action.program.ShowValidationDEAssociationsFormAction"
-		class="org.hisp.dhis.patient.action.program.ShowValidationDEAssociationsFormAction"
-		scope="prototype">
-		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="programStageDEValidationService"
-			ref="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
-	</bean>
-
+	
 	<!-- ProgramStage -->
 
 	<bean id="org.hisp.dhis.patient.action.programstage.AddProgramStageAction"
@@ -1201,53 +1190,59 @@
 		</property>
 	</bean>
 
-	<!-- Validation - ProgramStageDataElementValidation -->
-
-	<bean
-		id="org.hisp.dhis.patient.action.validation.AddProgramStageDEValidationAction"
-		class="org.hisp.dhis.patient.action.validation.AddProgramStageDEValidationAction"
-		scope="prototype">
-		<property name="validationService">
-			<ref bean="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
-		</property>
-		<property name="programStageService">
-			<ref bean="org.hisp.dhis.program.ProgramStageService" />
-		</property>
-		<property name="dataElementService">
-			<ref bean="org.hisp.dhis.dataelement.DataElementService" />
-		</property>
-		<property name="programStageDataElementService">
-			<ref bean="org.hisp.dhis.program.ProgramStageDataElementService" />
-		</property>
-	</bean>
-
-	<bean
-		id="org.hisp.dhis.patient.action.validation.GetProgramStageDEValidationAction"
-		class="org.hisp.dhis.patient.action.validation.GetProgramStageDEValidationAction"
-		scope="prototype">
-		<property name="validationService">
-			<ref bean="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
-		</property>
-	</bean>
-
-	<bean
-		id="org.hisp.dhis.patient.action.validation.GetProgramStageDEValidationListAction"
-		class="org.hisp.dhis.patient.action.validation.GetProgramStageDEValidationListAction"
-		scope="prototype">
-		<property name="validationService">
-			<ref bean="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
-		</property>
-	</bean>
-
-	<bean
-		id="org.hisp.dhis.patient.action.validation.RemoveProgramStageDEValidationAction"
-		class="org.hisp.dhis.patient.action.validation.RemoveProgramStageDEValidationAction"
-		scope="prototype">
-		<property name="validationService">
-			<ref bean="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
-		</property>
-	</bean>
-
+	<!-- Program Validation -->
+
+	<bean
+		id="org.hisp.dhis.patient.action.validation.AddProgramValidationAction"
+		class="org.hisp.dhis.patient.action.validation.AddProgramValidationAction"
+		scope="prototype">
+		<property name="programValidationService">
+			<ref bean="org.hisp.dhis.program.ProgramValidationService" />
+		</property>
+		<property name="programService">
+			<ref bean="org.hisp.dhis.program.ProgramService" />
+		</property>
+	</bean>
+	
+	<bean
+		id="org.hisp.dhis.patient.action.validation.GetProgramValidationAction"
+		class="org.hisp.dhis.patient.action.validation.GetProgramValidationAction"
+		scope="prototype">
+		<property name="programValidationService">
+			<ref bean="org.hisp.dhis.program.ProgramValidationService" />
+		</property>
+	</bean>
+	
+	<bean
+		id="org.hisp.dhis.patient.action.validation.GetProgramValidationListAction"
+		class="org.hisp.dhis.patient.action.validation.GetProgramValidationListAction"
+		scope="prototype">
+		<property name="programValidationService">
+			<ref bean="org.hisp.dhis.program.ProgramValidationService" />
+		</property>
+		<property name="programService">
+			<ref bean="org.hisp.dhis.program.ProgramService" />
+		</property>
+	</bean>
+	
+	<bean
+		id="org.hisp.dhis.patient.action.validation.RemoveProgramValidationAction"
+		class="org.hisp.dhis.patient.action.validation.RemoveProgramValidationAction"
+		scope="prototype">
+		<property name="programValidationService">
+			<ref bean="org.hisp.dhis.program.ProgramValidationService" />
+		</property>
+	</bean>
+	
+	<bean
+		id="org.hisp.dhis.patient.action.validation.UpdateProgramValidationAction"
+		class="org.hisp.dhis.patient.action.validation.UpdateProgramValidationAction"
+		scope="prototype">
+		<property name="programValidationService">
+			<ref bean="org.hisp.dhis.program.ProgramValidationService" />
+		</property>
+	</bean>
+	
 	<!-- Configuration -->
 
 	<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	2011-04-28 19:47:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2011-04-29 07:41:04 +0000
@@ -459,3 +459,11 @@
 manage_program_unenrollment = Manage Program Un-Enrollment
 patient_registration = Beneficiary Registration
 fill_fields_in_programstage_dataelement_validation = Fill all fields in validation form. 
+define_single_dataelement_validation = Define Single Dataelement Validation
+add_program_validation = Add Proram Validation
+update_program_validation = Update Proram Validation
+program_validation_details = Program Validation Details 
+define_program_validation = Define Proram Validation
+add_new_single_validation = Add New Single Validation
+add_new_multi_validation = Add New Multi Validation
+ 
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2011-04-28 09:19:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2011-04-29 07:41:04 +0000
@@ -742,19 +742,6 @@
 			<result name="success" type="redirect">program.action</result>
 			<param name="requiredAuthorities">F_PROGRAM_UPDATE</param>
 		</action>
-	
-		<!-- Program_ValidationDE Association -->
-
-		<action name="defineValidationDEAssociationsForm"
-			class="org.hisp.dhis.patient.action.program.ShowValidationDEAssociationsFormAction">
-			<result name="success" type="velocity">/main.vm</result>
-			<param name="page">/dhis-web-maintenance-patient/validationDEAssociations.vm</param>
-			<param name="javascripts">
-				javascript/program.js
-				,javascript/programStageDEValidation.js
-			</param>
-			<param name="requiredAuthorities">F_PROGRAM_UPDATE</param>
-		</action>
 		
 		<!-- ProgramStage -->
 
@@ -1166,27 +1153,59 @@
 				validationCriteria.action</result>
 			<param name="requiredAuthorities">F_PROGRAM_UPDATE</param>
 		</action>
-
-		<!-- Validation - ProgramStageDataElementValidation -->
-
-		<action name="programStageDEValidation"
-			class="org.hisp.dhis.patient.action.validation.GetProgramStageDEValidationListAction">
-			<result name="success" type="velocity">/main.vm</result>
-			<param name="page">/dhis-web-maintenance-patient/programStageDataElementValidation.vm</param>
-			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
-			<param name="javascripts">javascript/programStageDEValidation.js</param>
-		</action>
-
-		<action name="addProgramStageDEValidation"
-			class="org.hisp.dhis.patient.action.validation.AddProgramStageDEValidationAction">
-			<result name="success" type="velocity">
-				/dhis-web-maintenance-patient/loadValidationDEAssociation.vm</result>
-		</action>
-
-		<action name="removeProgramStageDEValidation"
-			class="org.hisp.dhis.patient.action.validation.RemoveProgramStageDEValidationAction">
-			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+		
+		<!-- Program Validation -->
+		
+		<action name="programValidation"
+			class="org.hisp.dhis.patient.action.validation.GetProgramValidationListAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/programValidationList.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
+			<param name="javascripts">javascript/programValidation.js</param>
+			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
+		</action>
+		
+		<action name="showAddProgramValidationForm"
+			class="org.hisp.dhis.patient.action.program.GetProgramAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/addProgramValidationForm.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
+			<param name="javascripts">javascript/programValidation.js</param>
+			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
+		</action>
+		
+		<action name="addProgramValidation"
+			class="org.hisp.dhis.patient.action.validation.AddProgramValidationAction">
+			<result name="success" type="redirect">programValidation.action?programId=${programId}</result>
+			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
+		</action>
+		
+		<action name="showUpdateProgramValidationForm"
+			class="org.hisp.dhis.patient.action.validation.GetProgramValidationAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/updateProgramValidationForm.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
+			<param name="javascripts">javascript/programValidation.js</param>
+			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
+		</action>
+		
+		<action name="updateProgramValidation"
+			class="org.hisp.dhis.patient.action.validation.UpdateProgramValidationAction">
+			<result name="success" type="redirect">programValidation.action?programId=${programId}</result>
+			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
+		</action>
+		
+		<action name="removeProgramValidation"
+			class="org.hisp.dhis.patient.action.validation.RemoveProgramValidationAction">
+			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
+		</action>
+		
+		<action name="getProgramValidation"
+			class="org.hisp.dhis.patient.action.validation.GetProgramValidationAction">
+			<result name="success" type="velocity-xml">
+				/dhis-web-maintenance-patient/responseProgramValidation.vm</result>
+			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<!-- Configuration -->

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramValidationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramValidationForm.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/addProgramValidationForm.vm	2011-04-29 07:41:04 +0000
@@ -0,0 +1,85 @@
+<h3>$i18n.getString( "add_program_validation" )</h3>
+
+<form id='programValidationForm' name='programValidationForm' method='post' action='addProgramValidation.action'>
+
+<input type='hidden' id='programId' name='programId' value='$program.id'>
+<table>
+	
+	<thead>
+      <tr>
+        <th colspan="2">$i18n.getString( "program_validation_details" )</th>
+      </tr>
+    </thead>
+    <tbody>
+	
+	<tr>
+		<td width="20em" colspan='2'>
+			<label>$i18n.getString('description')</label>
+		</td>
+	</tr>
+	<tr>
+		<td colspan='2'>			
+			<input type="text" id='description' name='description' style="width:100%" class="{validate:{required:true,minlength:4}}">
+		</td>
+	</tr>
+	<tr>
+		<td width="20em">
+			<label>$i18n.getString('left_side')</label>
+			
+			<br>
+			<select style="width:30.2em" id='leftStage' name='leftStage' onchange="getLeftPrgramStageDataElements();">
+				<option value=''>[$i18n.getString( "please_select" )]</option>
+				#foreach($stage in $program.programStages)
+				<option value='$stage.id'>$stage.name</option>
+				#end
+			</select>
+			<br>
+			<select style="width:30.2em" id='leftSideDE' name='leftSideDE' size='7' ondblclick="insertDataElement(this, 'leftSide');" >
+			</select>
+			<br>
+			<textarea rows='5' style="width:30em" id='leftSide' name='leftSide' class="{validate:{required:true,minlength:4}}"></textarea>
+			
+		</td>
+		<td width="20em">
+			<div id='rightSideDiv'>
+			
+				<label>$i18n.getString('right_side')</label>
+				
+				<br>
+				<select style="width:30.2em" id='rightStage' name='rightStage' onchange="getRightPrgramStageDataElements();">
+					<option value=''>[$i18n.getString( "please_select" )]</option>
+					#foreach($stage in $program.programStages)
+					<option value='$stage.id'>$stage.name</option>
+					#end
+				</select>
+				<br>
+				<select style="width:30.2em" id='rightSideDE' name='rightSideDE' size='7' ondblclick="insertDataElement(this, 'rightSide');">
+				</select>
+				<br>
+				<textarea rows='5' style="width:30em" id='rightSide' name='rightSide' class="{validate:{required:true,minlength:4}}"></textarea>
+		
+			</div>
+			
+		</td>
+	</tr>
+	<tr>
+		<td>
+			</td>
+		<td>			
+			</td>
+	</tr>
+	
+	<tr>
+		<td>
+			<input type='submit' value="$i18n.getString( "add" )" style="width:10em">
+			<input type='button' value="$i18n.getString( "cancel" )" style="width:10em" onclick="window.location.href='programValidation.action?programId=$program.id'">
+		</td>
+		<td></td>
+	</tr>
+	
+</table>
+
+<script>
+	getLeftPrgramStageDataElements();
+	getRightPrgramStageDataElements();
+</script>

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js	2011-04-26 09:00:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js	1970-01-01 00:00:00 +0000
@@ -1,61 +0,0 @@
-//-----------------------------------------------------------------------------
-// Add Programstage - DataElement Validation
-//-----------------------------------------------------------------------------
-
-function validateProgramStageDEValidation()
-{
-	var description = byId( 'description' ).value;
-	var leftProgramStageId = getFieldValue( 'leftProgramStageId' );
-	var	leftDataElementId = getFieldValue( 'leftDataElementId' );
-	var	operator = getFieldValue( 'operator' );
-	var	rightProgramStageId = getFieldValue( 'rightProgramStageId' );
-	var	rightDataElementId = getFieldValue( 'rightDataElementId' );
-	
-	if( isEmpty(description) || isEmpty(leftProgramStageId) ||
-		isEmpty(leftDataElementId) ||isEmpty(operator) ||
-		isEmpty(rightProgramStageId) ||isEmpty(rightDataElementId) )
-	{
-		setMessage(i18n_fill_fields_in_programstage_dataelement_validation);
-		return;
-	}
-	addProgramStageDEValidation();
-}
-
-function isEmpty(value){
-	return (value == '') ? true: false;
-}
-
-//-----------------------------------------------------------------------------
-// Add Programstage - DataElement Validation
-//-----------------------------------------------------------------------------
-
-function addProgramStageDEValidation()
-{
-	jQuery.post( "addProgramStageDEValidation.action",
-		{
-			'programId': getFieldValue( 'programId' ),
-			'description': getFieldValue( 'description' ),
-			'leftProgramStageId': getFieldValue( 'leftProgramStageId' ),
-			'leftDataElementId': getFieldValue( 'leftDataElementId' ),
-			'operator': getFieldValue( 'operator' ),
-			'rightProgramStageId': getFieldValue( 'rightProgramStageId' ),
-			'rightDataElementId': getFieldValue( 'rightDataElementId' )
-		},
-		function(data){
-			jQuery( "table.listTable tbody#list tr:last" ).after( data );
-			jQuery( "table.listTable tbody tr" ).removeClass( "listRow listAlternateRow" );
-			jQuery( "table.listTable tbody tr:odd" ).addClass( "listAlternateRow" );
-			jQuery( "table.listTable tbody tr:even" ).addClass( "listRow" );
-			jQuery( "table.listTable tbody" ).trigger("update");
-		}
-	);
-}
-
-// -----------------------------------------------------------------------------
-// Remove Criteria
-// -----------------------------------------------------------------------------
-
-function removeProgramStageDEValidation( id, name )
-{
-	removeItem( id, name, i18n_confirm_delete, 'removeProgramStageDEValidation.action' );
-}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.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/programValidation.js	2011-04-29 07:41:04 +0000
@@ -0,0 +1,165 @@
+
+jQuery(document).ready(	function(){
+	validation( 'programValidationForm', function( form ){			
+		form.submit();
+	});
+	
+	var isSingle = eval(jQuery.getUrlVars('value')['single']);
+	
+	if( isSingle || getFieldValue('rightSide') == '1==1')
+	{
+		hideById('rightSideDiv');
+		setFieldValue('rightSide','1==1');
+	}
+});
+
+// -----------------------------------------------------------------------------
+// View details
+// -----------------------------------------------------------------------------
+
+function showProgramValidationDetails ( programValidationId )
+{
+    var request = new Request();
+    request.setResponseTypeXML( 'programValdiation' );
+    request.setCallbackSuccess( programValdiationReceived );
+    request.send( 'getProgramValidation.action?validationId=' + programValidationId );
+}
+
+function programValdiationReceived( programValidationElement )
+{
+	setInnerHTML( 'idField', getElementValue( programValidationElement, 'id' ) );
+	setInnerHTML( 'descriptionField', getElementValue( programValidationElement, 'description' ) );	
+    setInnerHTML( 'leftSideField', getElementValue( programValidationElement, 'leftSide' ) );
+	setInnerHTML( 'rightSideField', getElementValue( programValidationElement, 'rightSide' ) );
+	setInnerHTML( 'programField', getElementValue( programValidationElement, 'program' ) );
+    
+    showDetails();
+}
+
+// -----------------------------------------------------------------------------
+// Remove ProgramValidation
+// -----------------------------------------------------------------------------
+
+function removeProgramValidation( programValidationId, name )
+{
+	removeItem( programValidationId, name, i18n_confirm_delete, 'removeProgramValidation.action' );	
+}
+
+//-----------------------------------------------------------------
+// Insert items data-element
+//-----------------------------------------------------------------
+
+function insertDataElement( element, target )
+{
+	byId(target).value += " " + element.options[element.selectedIndex].value + " ";
+}
+
+
+//------------------------------------------------------------------------------
+// Get DataElements of Program-Stage into left-side
+//------------------------------------------------------------------------------
+
+function getLeftPrgramStageDataElements()
+{
+  var programStage = document.getElementById( 'leftStage' );
+  var psId = programStage.options[ programStage.selectedIndex ].value;
+  if( psId == '')
+  {
+	return;
+  }
+  
+  var requestString = 'getPSDataElements.action?psId=' + psId;
+
+  var request = new Request();
+  request.setResponseTypeXML( 'leftSideDE' );
+  request.setCallbackSuccess( getLeftPrgramStageDataElementsCompleted );
+
+  request.send( requestString );	
+}
+
+function getLeftPrgramStageDataElementsCompleted( dataelementElement )
+{
+  var programstageDE = document.getElementById( 'leftSideDE' );
+  
+  clearList( programstageDE );
+  	
+  var programstageDEList = dataelementElement.getElementsByTagName( 'dataelement' );
+ 
+  for ( var i = 0; i < programstageDEList.length; i++ )
+  {
+    var id = programstageDEList[ i ].getElementsByTagName("id")[0].firstChild.nodeValue;
+    var name = programstageDEList[ i ].getElementsByTagName("name")[0].firstChild.nodeValue;
+	var type = programstageDEList[ i ].getElementsByTagName("type")[0].firstChild.nodeValue;
+
+    var option = document.createElement("option");
+    option.value = id;
+    option.text = name;
+    option.title = name;
+    jQuery(option).attr({data:"{type:'"+type+"'}"});
+    programstageDE.add(option, null);       	
+  }	    
+}
+
+//------------------------------------------------------------------------------
+// Get DataElements of Program-Stage into right-side
+//------------------------------------------------------------------------------
+
+function getRightPrgramStageDataElements()
+{
+  var programStage = document.getElementById( 'rightStage' );
+  var psId = programStage.options[ programStage.selectedIndex ].value;
+  if( psId == '')
+  {
+	return;
+  }
+  
+  var requestString = 'getPSDataElements.action?psId=' + psId;
+
+  var request = new Request();
+  request.setResponseTypeXML( 'rightSideDE' );
+  request.setCallbackSuccess( getRightPrgramStageDataElementsCompleted );
+
+  request.send( requestString );	
+}
+
+function getRightPrgramStageDataElementsCompleted( dataelementElement )
+{
+  var programstageDE = document.getElementById( 'rightSideDE' );
+  
+  clearList( programstageDE );
+  	
+  var programstageDEList = dataelementElement.getElementsByTagName( 'dataelement' );
+ 
+  for ( var i = 0; i < programstageDEList.length; i++ )
+  {
+    var id = programstageDEList[ i ].getElementsByTagName("id")[0].firstChild.nodeValue;
+    var name = programstageDEList[ i ].getElementsByTagName("name")[0].firstChild.nodeValue;
+	var type = programstageDEList[ i ].getElementsByTagName("type")[0].firstChild.nodeValue;
+
+    var option = document.createElement("option");
+    option.value = id;
+    option.text = name;
+    option.title = name;
+    jQuery(option).attr({data:"{type:'"+type+"'}"});
+    programstageDE.add(option, null);       	
+  }	    
+}
+
+
+$.extend({
+  getUrlVars: function(){
+    var vars = [], hash;
+    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
+    for(var i = 0; i < hashes.length; i++)
+    {
+      hash = hashes[i].split('=');
+      vars.push(hash[0]);
+      vars[hash[0]] = hash[1];
+    }
+    return vars;
+  },
+  getUrlVar: function(name){
+    return $.getUrlVars()[name];
+  }
+});
+

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm	2011-04-26 09:00:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm	1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
-<tr id="tr${validation.id}">
-  <td>$validation.description</td>
-  <td>[$validation.leftProgramStageDataElement.programStage.name.$validation.leftProgramStageDataElement.dataElement.name] 
-	#if($validation.operator == '-1') <
-	#elseif($validation.operator == '0') =
-	#else >
-	#end
-  [$validation.rightProgramStageDataElement.programStage.name.$validation.rightProgramStageDataElement.dataElement.name]</td>
-  <td>                  
-	<a href="javascript:removeProgramStageDEValidation( '$validation.id', '$encoder.htmlEncode( $validation.description )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></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	2011-04-28 09:19:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2011-04-29 07:41:04 +0000
@@ -5,10 +5,10 @@
 	<li><a href="patientAttributeGroup.action">$i18n.getString( "patient_attribute_group" )</a></li>
 	<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="defineOrgunitRegistrationForm.action">$i18n.getString( "patient_orgunit_registration" )</a></li>
+	<li><a href="defineOrgunitRegistrationForm.action">$i18n.getString( "patient_registration" )</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="caseAggregation.action">$i18n.getString( "beneficiary_aggregation_query_builder" )</a></li>
+	<li><a href="caseAggregation.action">$i18n.getString( "beneficiary_aggregation" )</a></li>
 	<li><a href="validationCriteria.action">$i18n.getString( "validation_criteria" )</a></li>
 	<li><a href="patientMobileSetting.action">$i18n.getString( "patient_mobile_setting" )</a></li>
 </ul>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm	2011-03-30 05:11:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm	2011-04-29 07:41:04 +0000
@@ -24,7 +24,7 @@
 					
 					<td style="text-align:center">
 					  <a href="defineProgramAssociationsForm.action?id=$program.id" title="$i18n.getString( "define_associations" )"><img src="../images/assign.png" alt="$i18n.getString( "define_associations" )"></a>
-					  <a href="defineValidationDEAssociationsForm.action?id=$program.id" title="$i18n.getString( "validationDE_associations" )"><img src="../images/assign_b.png" alt="$i18n.getString( "validationDE_associations" )"></a>
+					  <a href="programValidation.action?programId=$program.id" title="$i18n.getString( "define_program_validation" )"><img src="../images/assign_b.png" alt="$i18n.getString( "define_program_validation" )"></a>
 					  <a href="showUpdateProgramForm.action?id=$program.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
 					  <a href="programStage.action?id=$program.id" title="$i18n.getString( "view_stage_management" )"><img src="../images/add_section.png" alt="$i18n.getString( "view_stage_management" )"></a>
 					  <a href="javascript:removeProgram( '$program.id', '$encoder.jsEncode( $program.name )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageDataElementValidation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageDataElementValidation.vm	2011-01-20 15:25:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageDataElementValidation.vm	1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
-<h3>$i18n.getString( "programstage_dataelement_validation" )</h3>
-
-<table width=100%>
-	<tr>
-		<td>
-			$i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:300px"/>
-		</td>
-		<td align='right'>			
-			<input type="button" value="$i18n.getString( "add" )" onclick="window.location.href='showAddValidationCriteriaForm.action'" style="width:10em">
-		</td>
-	</tr>
-</table>
-
-<table width="100%" border="0" class="listTable">
-	<thead>
-    <tr>
-      <th>$i18n.getString('description')</th>
-      <th>$i18n.getString('validation')</th>
-      <th style="width:5em ">$i18n.getString('operator')</th>
-    </tr>
-	</thead>	
-	<tbody id="list">
-	#foreach($validation in $validations)
-    <tr id="tr${validation.id}">
-      <td>$validation.description</td>
-      <td>$validation.leftProgramStageDataElement.dataElement.name 
-		#if($validation.operator == '-1') <
-		#elseif($criteria.operator == '0') =
-		#else >
-		#end
-	  $validation.$validation.leftProgramStageDataElement.dataElement.name</td>
-      <td>                  
-	  	<a href="showUpdateValidationCriteriaForm.action?id=$validation.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
-        <a href="javascript:removeCriteria( '$validation.id', '$encoder.jsEncode( $validation.getName() )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
-	  </td>
-    </tr>
-	#end
-	</tbody>
-</table>
-
-<script>
-	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_validation_criteria" ) , "'" )';
-</script>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.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/programValidationList.vm	2011-04-29 07:41:04 +0000
@@ -0,0 +1,71 @@
+<h3>$i18n.getString( "define_program_validation" )</h3>
+
+<table class="mainPageTable">
+	<tr>
+		<td style="vertical-align:top">
+			<table class="listTable">
+			  <col>          
+			  <col width="60"> 
+			  <tr>
+				<td></td>
+				<td colspan="2">
+					<input type="button" value="$i18n.getString( "add_new_single_validation" )" onclick="window.location.href='showAddProgramValidationForm.action?id=$programId&single=true'" style="width:200px">
+					<input type="button" value="$i18n.getString( "add_new_multi_validation" )" onclick="window.location.href='showAddProgramValidationForm.action?id=$programId&single=false'" style="width:200px">
+					<input type="button" value="$i18n.getString( "cancel" )" onclick="window.location.href='program.action'" style="width:200px">
+				</td>
+			  </tr>
+			  <tr>            
+				<th>$i18n.getString( "description" )</th>
+				<th colspan='2'>$i18n.getString( "operations" )</th>
+			  </tr>
+
+			  <tbody id="list">
+				#foreach( $validation in $validations )
+				  <tr id="tr${validation.id}">
+					
+					<td>$validation.description</td>
+					<td colspan='2'>
+					  <a href="showUpdateProgramValidationForm.action?validationId=$validation.id&id=$programId" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
+					  <a href="javascript:removeProgramValidation( '$validation.id', '$encoder.jsEncode( $validation.description )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
+					  <a href="javascript:showProgramValidationDetails( $validation.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="descriptionField"></span></p>
+				<p><label>$i18n.getString( "description" ):</label><br><span id="leftSideField"></span></p>
+				<p><label>$i18n.getString( "value_type" ):</label><br><span id="rightSideField"></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>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseProgramValidation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseProgramValidation.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/responseProgramValidation.vm	2011-04-29 07:41:04 +0000
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation>
+	<id>$validation.id</id>
+	<description>$encoder.htmlEncode($validation.description)</description>
+	<leftSide>$encoder.htmlEncode($validation.leftSide)</leftSide>
+	<rightSide>$encoder.htmlEncode($validation.rightSide)</rightSide>
+	<program>$encoder.htmlEncode($validation.rightSide.name)</program>
+</validation>
\ 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/updateProgramValidationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramValidationForm.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/updateProgramValidationForm.vm	2011-04-29 07:41:04 +0000
@@ -0,0 +1,77 @@
+<h3>$i18n.getString( "update_program_validation" )</h3>
+
+<form id='programValidationForm' name='programValidationForm' method='post' action='updateProgramValidation.action'>
+
+<input type='hidden' id='id' name='id' value='$validation.id'>
+<table>
+	
+	<thead>
+      <tr>
+        <th colspan="2">$i18n.getString( "program_validation_details" )</th>
+      </tr>
+    </thead>
+    <tbody>
+	
+	<tr>
+		<td width="20em" colspan='2'>
+			<label>$i18n.getString('description')</label>
+		</td>
+	</tr>
+	<tr>
+		<td colspan='2'>			
+			<input type="text" id='description' name='description' style="width:100%" value='$validation.description'>
+		</td>
+	</tr>
+	<tr>
+		<td width="20em">
+			
+			<label>$i18n.getString('left_side')</label>
+			<br>
+			<select style="width:30.2em" id='leftStage' name='leftStage' onchange="getLeftPrgramStageDataElements();">
+				<option value=''>[$i18n.getString( "please_select" )]</option>
+				#foreach($stage in $validation.program.programStages)
+				<option value='$stage.id'>$stage.name</option>
+				#end
+			</select>
+			<br>
+			<select style="width:30.2em" id='leftSideDE' name='leftSideDE' size='7' ondblclick="insertDataElement(this, 'leftSide');">
+			</select>
+			<br>
+			<textarea rows='5' style="width:30em" id='leftSide' name='leftSide'>$validation.leftSide</textarea>
+	
+		</td>
+		<td width="20em">
+			<div id='rightSideDiv'>
+				
+				<label>$i18n.getString('right_side')</label>
+				<br>
+				<select style="width:30.2em" id='rightStage' name='rightStage' onchange="getRightPrgramStageDataElements();">
+					<option value=''>[$i18n.getString( "please_select" )]</option>
+					#foreach($stage in $validation.program.programStages)
+					<option value='$stage.id'>$stage.name</option>
+					#end
+				</select>
+				<br>
+				<select style="width:30.2em" id='rightSideDE' name='rightSideDE' size='7' ondblclick="insertDataElement(this, 'rightSide');">
+				</select>
+				<br>
+				<textarea rows='5' style="width:30em" id='rightSide' name='rightSide'>$validation.rightSide</textarea>
+			
+			</div>
+		</td>
+	</tr>
+	
+	<tr>
+		<td>
+			<input type='submit' value="$i18n.getString( "update" )" style="width:10em">
+			<input type='button' value="$i18n.getString( "cancel" )" style="width:10em" onclick="window.location.href='programValidation.action?programId=$validation.program.id'">
+		</td>
+		<td></td>
+	</tr>
+	
+</table>
+
+<script>
+	getLeftPrgramStageDataElements();
+	getRightPrgramStageDataElements();
+</script>
\ No newline at end of file