← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6406: (patient) Put Unenroll function into Enrollment form.

 

------------------------------------------------------------
revno: 6406
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-28 14:10:48 +0700
message:
  (patient) Put Unenroll function into Enrollment form.
removed:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentSelectAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programUnenrollmentSelectForm.vm
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/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/entry.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/patient.css


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2012-03-27 07:20:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2012-03-28 07:10:48 +0000
@@ -33,6 +33,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.hisp.dhis.caseentry.state.SelectedStateManager;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeGroup;
@@ -47,6 +49,8 @@
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramAttribute;
+import org.hisp.dhis.program.ProgramAttributeService;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramService;
@@ -81,6 +85,10 @@
 
     private PatientAttributeValueService patientAttributeValueService;
 
+    private ProgramAttributeService programAttributeService;
+
+    private SelectedStateManager selectedStateManager;
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -107,15 +115,34 @@
 
     private Map<Integer, String> patientAttributeValueMap = new HashMap<Integer, String>();
 
+    private Collection<ProgramAttribute> programAttributes;
+
+    private Boolean hasDataEntry;
+
     // -------------------------------------------------------------------------
     // Getters/Setters
     // -------------------------------------------------------------------------
 
+    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+    {
+        this.selectedStateManager = selectedStateManager;
+    }
+
     public void setPatientService( PatientService patientService )
     {
         this.patientService = patientService;
     }
 
+    public Collection<ProgramAttribute> getProgramAttributes()
+    {
+        return programAttributes;
+    }
+
+    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
     public Collection<PatientAttribute> getNoGroupAttributes()
     {
         return noGroupAttributes;
@@ -206,6 +233,11 @@
         return programStageInstances;
     }
 
+    public Boolean getHasDataEntry()
+    {
+        return hasDataEntry;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -213,6 +245,8 @@
     public String execute()
         throws Exception
     {
+        OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit();
+
         patient = patientService.getPatient( patientId );
 
         program = programService.getProgram( programId );
@@ -230,53 +264,90 @@
 
             programStageInstances = programInstance.getProgramStageInstances();
 
-            // ---------------------------------------------------------------------
-            // Load identifier types of the selected program
-            // ---------------------------------------------------------------------
-
-            identifierTypes = identifierTypeService.getPatientIdentifierTypes( program );
-            identiferMap = new HashMap<Integer, String>();
-
-            if ( identifierTypes != null && identifierTypes.size() > 0 )
-            {
-                Collection<PatientIdentifier> patientIdentifiers = patientIdentifierService.getPatientIdentifiers(
-                    identifierTypes, patient );
-
-                for ( PatientIdentifier identifier : patientIdentifiers )
-                {
-                    identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
-                }
-            }
-
-            // ---------------------------------------------------------------------
+            loadIdentifierTypes();
+
+            loadPatientAttributes();
+
+            // -----------------------------------------------------------------
             // Load patient-attributes of the selected program
-            // ---------------------------------------------------------------------
-
-            attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
-                .getPatientAttributeGroups( program ) );
-            Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
-
-            noGroupAttributes = patientAttributeService.getPatientAttributes( program, null );
-
-            Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
-                .getPatientAttributeValues( patient );
-
-            for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
-            {
-                if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute()
-                    .getValueType() ) )
-                {
-                    patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
-                        patientAttributeValue.getPatientAttributeOption().getName() );
-                }
-                else
-                {
-                    patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
-                        patientAttributeValue.getValue() );
-                }
-            }
+            // -----------------------------------------------------------------
+
+            programAttributes = programAttributeService.getAllProgramAttributes();
         }
-        
+
+        hasDataEntry = showDataEntry( orgunit, program, programInstance );
+
         return SUCCESS;
     }
+
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+
+    private void loadIdentifierTypes()
+    {
+        // ---------------------------------------------------------------------
+        // Load identifier types of the selected program
+        // ---------------------------------------------------------------------
+
+        identifierTypes = identifierTypeService.getPatientIdentifierTypes( program );
+        identiferMap = new HashMap<Integer, String>();
+
+        if ( identifierTypes != null && identifierTypes.size() > 0 )
+        {
+            Collection<PatientIdentifier> patientIdentifiers = patientIdentifierService.getPatientIdentifiers(
+                identifierTypes, patient );
+
+            for ( PatientIdentifier identifier : patientIdentifiers )
+            {
+                identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
+            }
+        }
+    }
+
+    private void loadPatientAttributes()
+    {
+        // ---------------------------------------------------------------------
+        // Load patient-attributes of the selected program
+        // ---------------------------------------------------------------------
+
+        attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
+            .getPatientAttributeGroups( program ) );
+        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
+
+        noGroupAttributes = patientAttributeService.getPatientAttributes( program, null );
+
+        Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
+            .getPatientAttributeValues( patient );
+
+        for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
+        {
+            if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute()
+                .getValueType() ) )
+            {
+                patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
+                    patientAttributeValue.getPatientAttributeOption().getName() );
+            }
+            else
+            {
+                patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
+                    patientAttributeValue.getValue() );
+            }
+        }
+    }
+
+    private boolean showDataEntry( OrganisationUnit orgunit, Program program, ProgramInstance programInstance )
+    {
+        if ( !program.getOrganisationUnits().contains( orgunit ) )
+        {
+            return false;
+        }
+        else if ( !program.getSingleEvent() && programInstance == null )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java	2012-03-26 06:36:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java	2012-03-28 07:10:48 +0000
@@ -28,12 +28,15 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 
+import org.hisp.dhis.caseentry.state.SelectedStateManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramService;
 
 import com.opensymphony.xwork2.Action;
@@ -63,11 +66,18 @@
         this.programService = programService;
     }
 
-    private OrganisationUnitSelectionManager selectionManager;
-
-    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
-    {
-        this.selectionManager = selectionManager;
+    private ProgramInstanceService programInstanceService;
+
+    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+    {
+        this.programInstanceService = programInstanceService;
+    }
+
+    private SelectedStateManager selectedStateManager;
+
+    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+    {
+        this.selectedStateManager = selectedStateManager;
     }
 
     // -------------------------------------------------------------------------
@@ -102,19 +112,37 @@
     public String execute()
         throws Exception
     {
+        OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit();
+
         patient = patientService.getPatient( id );
 
-        OrganisationUnit selectedOrgunit = selectionManager.getSelectedOrganisationUnit();
-
-        // Get none single-event programs
+        // Get all programs
         programs = programService.getPrograms( false );
 
-        // Check the selected orgunit has any single-event program or not
-        Collection<Program> programsbyOrgunit = programService.getPrograms( selectedOrgunit );
-
-        Collection<Program> singleEventPrograms = programService.getPrograms( true, false );
-
-        singleEventPrograms.retainAll( programsbyOrgunit );
+        // Except anonymous program
+        programs.removeAll( programService.getPrograms( true, true ) );
+
+        // Get single-event if patient no have any single event
+        // OR have un-completed single-event
+        Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient, true );
+
+        Collection<Program> completedPrograms = new HashSet<Program>();
+
+        for ( ProgramInstance programInstance : programInstances )
+        {
+            if ( programInstance.getProgram().getSingleEvent() )
+            {
+                completedPrograms.add( programInstance.getProgram() );
+            }
+        }
+System.out.println("\n\n completedPrograms : " + completedPrograms.iterator().next().getName() );
+        // Get single-event programs by the selected orgunit
+        Collection<Program> singleProgramsByOrgunit = programService.getPrograms( true, false, orgunit );
+System.out.println("\n\n singleProgramsByOrgunit : " + singleProgramsByOrgunit.iterator().next().getName() );
+        singleProgramsByOrgunit.remove( completedPrograms );
+System.out.println("\n\n singlePrograms 2 : " + singleProgramsByOrgunit.iterator().next().getName() );
+        programs.addAll( singleProgramsByOrgunit );
+System.out.println("\n\n programs : " + singleProgramsByOrgunit.iterator().next().getName() );
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentAction.java	2011-09-14 06:36:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentAction.java	2012-03-28 07:10:48 +0000
@@ -136,7 +136,6 @@
     public String execute()
         throws Exception
     {
-
         ProgramInstance programInstance = programInstanceService.getProgramInstance( programInstanceId );
 
         Patient patient = programInstance.getPatient();
@@ -144,18 +143,6 @@
         Program program = programInstance.getProgram();
 
         // ---------------------------------------------------------------------
-        // Update Information of programInstance
-        // ---------------------------------------------------------------------
-
-        programInstance.setEndDate( new Date() );
-        programInstance.setCompleted( true );
-
-        programInstanceService.updateProgramInstance( programInstance );
-
-        patient.getPrograms().remove( program );
-        patientService.updatePatient( patient );
-
-        // ---------------------------------------------------------------------
         // Save Program Attributes
         // ---------------------------------------------------------------------
 
@@ -168,14 +155,18 @@
         // ---------------------------------------------------------------------
         // End-user inputs attribute value for DEAD-attribute
         // ---------------------------------------------------------------------
-        
+
         boolean flag = false;
+        Date closedDate = new Date();
 
         if ( attributes != null && attributes.size() > 0 )
         {
             programInstance.getAttributes().clear();
 
+            // -----------------------------------------------------------------
             // Save other attributes
+            // -----------------------------------------------------------------
+
             for ( ProgramAttribute attribute : attributes )
             {
                 String value = request.getParameter( RemoveEnrollmentAction.PREFIX_ATTRIBUTE + attribute.getId() );
@@ -193,36 +184,37 @@
                         attributeValue.setProgramInstance( programInstance );
                         attributeValue.setProgramAttribute( attribute );
 
-                        // DEAD program-attribute
-                        if ( attribute.getName().equalsIgnoreCase( ProgramAttribute.DEAD_NAME )
-                            && attribute.getValueType().equalsIgnoreCase( ProgramAttribute.TYPE_BOOL ) )
-                        {
-                            attributeValue.setValue( value.trim() );
-                            patient.setIsDead( Boolean.parseBoolean( value.trim() ) );
-                            patientService.updatePatient( patient );
-                            flag = true;
-                        }
-                        else if ( ProgramAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
-                        {
-                            ProgramAttributeOption option = programAttributeOptionService.get( NumberUtils.toInt(
-                                value, 0 ) );
-                            if ( option != null )
-                            {
-                                attributeValue.setProgramAttributeOption( option );
-                                attributeValue.setValue( option.getName() );
-                            }
-                        }
-                        else
-                        {
-                            attributeValue.setValue( value.trim() );
-                        }
-
                         // CLOSED-DATE program-attribute
                         if ( attribute.getName().equalsIgnoreCase( ProgramAttribute.CLOSED_DATE )
                             && attribute.getValueType().equalsIgnoreCase( ProgramAttribute.TYPE_DATE ) && flag )
                         {
-                            patient.setDeathDate( format.parseDate( value.trim() ) );
-                            patientService.updatePatient( patient );
+                            attributeValue.setValue( value.trim() );
+
+                            closedDate = format.parseDate( value.trim() );
+                            patient.setDeathDate( closedDate );
+                            flag = true;
+                        }
+                        // IS-DEAD program-attribute
+                        else if ( attribute.getName().equalsIgnoreCase( ProgramAttribute.DEAD_NAME ) )
+                        {
+                            attributeValue.setValue( value.trim() );
+
+                            patient.setIsDead( Boolean.parseBoolean( value.trim() ) );
+                            flag = true;
+                        }
+                        else if ( ProgramAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
+                        {
+                            ProgramAttributeOption option = programAttributeOptionService.get( NumberUtils.toInt(
+                                value, 0 ) );
+                            if ( option != null )
+                            {
+                                attributeValue.setProgramAttributeOption( option );
+                                attributeValue.setValue( option.getName() );
+                            }
+                        }
+                        else
+                        {
+                            attributeValue.setValue( value.trim() );
                         }
 
                         programAttributeValueService.saveProgramAttributeValue( attributeValue );
@@ -250,9 +242,37 @@
             }
         }
 
+        // ---------------------------------------------------------------------
+        // Update Information of programInstance
+        // ---------------------------------------------------------------------
+
+        programInstance.setEndDate( closedDate );
+        programInstance.setCompleted( true );
+//        programInstanceService.updateProgramInstance( programInstance );
         programInstance.setAttributes( programAttributes );
-
         programInstanceService.updateProgramInstance( programInstance );
+        
+        patient.getPrograms().remove( program );
+        
+        // ---------------------------------------------------------------------
+        // Set Completed status all program-instaces of Death case
+        // ---------------------------------------------------------------------
+
+        if ( flag )
+        {
+            Collection<ProgramInstance> programInstancesByPatient = programInstanceService.getProgramInstances(
+                patient, false );
+
+            for ( ProgramInstance _programInstance : programInstancesByPatient )
+            {
+                patient.getPrograms().remove( _programInstance.getProgram() );
+                _programInstance.setEndDate( closedDate );
+                _programInstance.setCompleted( true );
+                programInstanceService.updateProgramInstance( _programInstance );
+            }
+        }
+        
+        patientService.updatePatient( patient );
 
         return SUCCESS;
     }

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentSelectAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentSelectAction.java	1970-01-01 00:00:00 +0000
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2004-2012, 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.patient;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramAttribute;
-import org.hisp.dhis.program.ProgramAttributeService;
-import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramInstanceService;
-import org.hisp.dhis.program.ProgramService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- * @version $ID : RemoveEnrollmentSelectAction.java Jan 11, 2011 10:00:55 AM $
- */
-public class RemoveEnrollmentSelectAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ProgramAttributeService programAttributeService;
-
-    private ProgramInstanceService programInstanceService;
-
-    private ProgramService programService;
-
-    private PatientService patientService;
-
-    // -------------------------------------------------------------------------
-    // Input/Output
-    // -------------------------------------------------------------------------
-
-    private Integer patientId;
-
-    private Collection<ProgramInstance> programInstances;
-
-    private Collection<ProgramAttribute> programAttributes;
-
-    private ProgramInstance programInstance;
-
-    private Patient patient;
-
-    // -------------------------------------------------------------------------
-    // Setter && Getter
-    // -------------------------------------------------------------------------
-
-    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
-    {
-        this.programAttributeService = programAttributeService;
-    }
-
-    public ProgramInstance getProgramInstance()
-    {
-        return programInstance;
-    }
-
-    public void setPatientService( PatientService patientService )
-    {
-        this.patientService = patientService;
-    }
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
-    public Patient getPatient()
-    {
-        return patient;
-    }
-
-    public void setPatientId( Integer patientId )
-    {
-        this.patientId = patientId;
-    }
-
-    public Collection<ProgramInstance> getProgramInstances()
-    {
-        return programInstances;
-    }
-
-    public Collection<ProgramAttribute> getProgramAttributes()
-    {
-        return programAttributes;
-    }
-
-    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
-    {
-        this.programInstanceService = programInstanceService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-        throws Exception
-    {
-        patient = patientService.getPatient( patientId );
-        
-        programAttributes = programAttributeService.getAllProgramAttributes();
-
-        // ---------------------------------------------------------------------
-        // Get programInstance
-        // ---------------------------------------------------------------------
-
-        programInstances = new ArrayList<ProgramInstance>();
-
-        Collection<Program> programs = programService.getAllPrograms();
-
-        for ( Program program : programs )
-        {
-            Collection<ProgramInstance> instances = programInstanceService
-                .getProgramInstances( patient, program, false );
-
-            if ( instances.iterator().hasNext() )
-            {
-                programInstances.add( instances.iterator().next() );
-            }
-        }
-        
-        return SUCCESS;
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java	2012-03-27 07:20:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java	2012-03-28 07:10:48 +0000
@@ -26,28 +26,12 @@
  */
 package org.hisp.dhis.caseentry.action.patient;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientAttributeGroup;
-import org.hisp.dhis.patient.PatientAttributeGroupService;
-import org.hisp.dhis.patient.PatientAttributeService;
-import org.hisp.dhis.patient.PatientIdentifier;
-import org.hisp.dhis.patient.PatientIdentifierService;
-import org.hisp.dhis.patient.PatientIdentifierType;
-import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
@@ -98,41 +82,6 @@
         this.programStageInstanceService = programStageInstanceService;
     }
 
-    public Collection<PatientIdentifierType> getIdentifierTypes()
-    {
-        return identifierTypes;
-    }
-
-    public Map<Integer, String> getIdentiferMap()
-    {
-        return identiferMap;
-    }
-
-    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
-    {
-        this.patientIdentifierService = patientIdentifierService;
-    }
-
-    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
-    {
-        this.identifierTypeService = identifierTypeService;
-    }
-
-    public void setProgramStageInstances( Collection<ProgramStageInstance> programStageInstances )
-    {
-        this.programStageInstances = programStageInstances;
-    }
-
-    private PatientIdentifierService patientIdentifierService;
-
-    private PatientIdentifierTypeService identifierTypeService;
-
-    private PatientAttributeService patientAttributeService;
-
-    private PatientAttributeGroupService patientAttributeGroupService;
-
-    private PatientAttributeValueService patientAttributeValueService;
-    
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -144,27 +93,13 @@
     // Input/Output
     // -------------------------------------------------------------------------
 
-    private Collection<PatientIdentifierType> identifierTypes;
-
-    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
-    {
-        this.patientAttributeService = patientAttributeService;
-    }
-
-    public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService )
-    {
-        this.patientAttributeGroupService = patientAttributeGroupService;
-    }
-
-    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
-    {
-        this.patientAttributeValueService = patientAttributeValueService;
-    }
-
-    private Map<Integer, String> identiferMap;
-
     private Integer patientId;
 
+    public Integer getPatientId()
+    {
+        return patientId;
+    }
+
     public void setPatientId( Integer patientId )
     {
         this.patientId = patientId;
@@ -177,6 +112,11 @@
         this.programId = programId;
     }
 
+    public Integer getProgramId()
+    {
+        return programId;
+    }
+
     private Patient patient;
 
     public Patient getPatient()
@@ -191,13 +131,6 @@
         return program;
     }
 
-    private ProgramInstance programInstance;
-
-    public ProgramInstance getProgramInstance()
-    {
-        return programInstance;
-    }
-
     private String enrollmentDate;
 
     public void setEnrollmentDate( String enrollmentDate )
@@ -212,34 +145,6 @@
         this.dateOfIncident = dateOfIncident;
     }
 
-    private Collection<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
-
-    public Collection<ProgramStageInstance> getProgramStageInstances()
-    {
-        return programStageInstances;
-    }
-
-    private Collection<PatientAttribute> noGroupAttributes;
-
-    public Collection<PatientAttribute> getNoGroupAttributes()
-    {
-        return noGroupAttributes;
-    }
-
-    private List<PatientAttributeGroup> attributeGroups;
-
-    public List<PatientAttributeGroup> getAttributeGroups()
-    {
-        return attributeGroups;
-    }
-
-    private Map<Integer, String> patientAttributeValueMap = new HashMap<Integer, String>();
-
-    public Map<Integer, String> getPatientAttributeValueMap()
-    {
-        return patientAttributeValueMap;
-    }
-
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -251,14 +156,16 @@
 
         program = programService.getProgram( programId );
 
-        if( dateOfIncident == null )
+        if ( dateOfIncident == null || dateOfIncident.isEmpty()  )
         {
             dateOfIncident = enrollmentDate;
         }
-        
+
         Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient, program,
             false );
 
+        ProgramInstance programInstance = null;
+
         if ( programInstances.iterator().hasNext() )
         {
             programInstance = programInstances.iterator().next();
@@ -291,11 +198,8 @@
                 programStageInstance.setDueDate( dueDate );
 
                 programStageInstanceService.addProgramStageInstance( programStageInstance );
-
-                programStageInstances.add( programStageInstance );
             }
         }
-
         else
         {
             programInstance.setEnrollmentDate( format.parseDate( enrollmentDate ) );
@@ -311,57 +215,9 @@
                 programStageInstance.setDueDate( dueDate );
 
                 programStageInstanceService.updateProgramStageInstance( programStageInstance );
-
-                programStageInstances.add( programStageInstance );
-            }
-        }
-
-     // ---------------------------------------------------------------------
-        // Load identifier types of the selected program
-        // ---------------------------------------------------------------------
-
-        identifierTypes = identifierTypeService.getPatientIdentifierTypes( program );
-        identiferMap = new HashMap<Integer, String>();
-
-        if ( identifierTypes != null && identifierTypes.size() > 0 )
-        {
-            Collection<PatientIdentifier> patientIdentifiers = patientIdentifierService.getPatientIdentifiers(
-                identifierTypes, patient );
-
-            for ( PatientIdentifier identifier : patientIdentifiers )
-            {
-                identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
-            }
-        }
-
-        // ---------------------------------------------------------------------
-        // Load patient-attributes of the selected program
-        // ---------------------------------------------------------------------
-
-        attributeGroups = new ArrayList<PatientAttributeGroup>( patientAttributeGroupService
-            .getPatientAttributeGroups( program ) );
-        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
-
-        noGroupAttributes = patientAttributeService.getPatientAttributes( program, null );
-
-        Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
-            .getPatientAttributeValues( patient );
-
-        for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
-        {
-            if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute()
-                .getValueType() ) )
-            {
-                patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
-                    patientAttributeValue.getPatientAttributeOption().getName() );
-            }
-            else
-            {
-                patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
-                    patientAttributeValue.getValue() );
-            }
-        }
-        
+            }
+        }
+
         return SUCCESS;
     }
 }

=== 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	2012-03-27 14:19:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-03-28 07:10:48 +0000
@@ -624,7 +624,8 @@
 		scope="prototype">
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+		<property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.ProgramEnrollmentAction"
@@ -638,6 +639,8 @@
 		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
 		<property name="patientAttributeGroupService" ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
 		<property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+		<property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+		<property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 	</bean>
 
 	<bean
@@ -648,11 +651,6 @@
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 		<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
-		<property name="identifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
-		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
-		<property name="patientAttributeGroupService" ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
-		<property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.SaveDueDateAction"
@@ -662,17 +660,6 @@
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
 
-	<bean
-		id="org.hisp.dhis.caseentry.action.patient.RemoveEnrollmentSelectAction"
-		class="org.hisp.dhis.caseentry.action.patient.RemoveEnrollmentSelectAction"
-		scope="prototype">
-		<property name="programAttributeService"
-			ref="org.hisp.dhis.program.ProgramAttributeService" />
-		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
-		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
-		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-	</bean>
-
 	<bean id="org.hisp.dhis.caseentry.action.patient.GetProgramInstanceAction"
 		class="org.hisp.dhis.caseentry.action.patient.GetProgramInstanceAction"
 		scope="prototype">

=== 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	2012-03-27 14:19:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-03-28 07:10:48 +0000
@@ -287,8 +287,14 @@
 some_data_element_not_exist = Some data element is not exist
 orgunit_hiererachy_included_on = Organisation unit hiererachy included on
 level = Level
-patient_identifier_and_attributes = Beneficiary identifier and attributes
 please_fill_out_only_one_of_these_fields = Please fill out at only one of these fields.
 age_year = Age year
 create = Create
-migration_patient = Migration patient
\ No newline at end of file
+migration_patient = Migration Beneficiary
+patient_info = Beneficiary Information
+program_enrolled_for = Program Enrolled for
+identifier_and_attribute = Identifier/Attribute
+unenrollment = Un-Enrollment
+modify_due_date_or_visit_date = Modify Due/Visit dates
+data_entry_screen = Data entry Screen
+unenrol_success = Beneficiary un-enrolled successfully
\ 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	2012-03-27 14:19:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-03-28 07:10:48 +0000
@@ -543,18 +543,10 @@
 
 		<action name="saveProgramEnrollment"
 			class="org.hisp.dhis.caseentry.action.patient.SaveProgramEnrollmentAction">
-			<result name="success" type="velocity">/content.vm</result>
-			<param name="page">/dhis-web-caseentry/programEnrollmentForm.vm</param>
+			<result name="success" type="redirect">enrollmentform.action?programId=${programId}&amp;patientId=${patientId}</result>
 			<param name="requiredAuthorities">F_PROGRAM_ENROLLMENT</param>
 		</action>
 
-		<action name="showProgramUnEnrollmentForm"
-			class="org.hisp.dhis.caseentry.action.patient.RemoveEnrollmentSelectAction">
-			<result name="success" type="velocity">/content.vm</result>
-			<param name="page">/dhis-web-caseentry/programUnenrollmentSelectForm.vm</param>
-			<param name="requiredAuthorities">F_PROGRAM_UNENROLLMENT</param>
-		</action>
-
 		<action name="getProgramInstance"
 			class="org.hisp.dhis.caseentry.action.patient.GetProgramInstanceAction">
 			<result name="success" type="velocity-json">

=== 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	2012-03-27 08:30:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm	2012-03-28 07:10:48 +0000
@@ -14,11 +14,7 @@
 		</tr>
 		<tr>
 			<td class="bold">$i18n.getString( "date_of_birth" ):</td>
-			<td>$format.formatDate( $patient.birthDate )<td>
-		</tr>
-		<tr>
-			<td class="bold">$i18n.getString( "age" ):</td>
-			<td>$encoder.htmlEncode( $patient.getAge() )</td>
+			<td>$format.formatDate( $patient.birthDate ) $patient.getAge()<td>
 		</tr>
 		</table>
 	</tr>
@@ -44,7 +40,7 @@
 		<tr>
 			<td>
 				<table>
-				   <tr>
+				   <tr id='programIdTR'>
 						<td class='text-column'><label for="programId">$i18n.getString( "program" )</label></td>
 						<td>
 							<select id="programId" name="programId" class="criteria" onchange="loadProgramStages();" #if( $programs.size() == 0 ) disabled="disabled" #end>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-03-27 08:30:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-03-28 07:10:48 +0000
@@ -34,7 +34,7 @@
 			
 			var singleEvent = jQuery('#dataRecordingSelectDiv [name=programId] option:selected').attr('singleevent');
 				
-			if(singleEvent=='true')
+			if(singleEvent=='true' || json.programStages.length == 1)
 			{
 				byId('programStageId').selectedIndex = 1;
 				jQuery('#programStageIdTR').attr('class','hidden');
@@ -628,7 +628,7 @@
 					
 					jQuery("#dataEntryFormDiv").find(".ui-button").each(function()
 					{
-						jQuery(this).attr('disabled', 'disabled');
+						jQuery(this).autocomplete( "option", "disabled" );
 					});
 					
 					disable('validationBtn');

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-03-27 14:19:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-03-28 07:10:48 +0000
@@ -399,7 +399,7 @@
 		{
 			id:patientId
 		}, function()
-		{
+		{	
 			showById('enrollmentDiv');
 			
 			jQuery('#loaderDiv').hide();
@@ -410,19 +410,10 @@
 {				
 	if( programId == 0 )
 	{
-		disable('enrollBtn');
-		disable('enrollmentDate');
-		disable('dateOfIncident');
-		
 		jQuery('#enrollBtn').attr('value',i18n_enroll_to_program);
-		
-		setFieldValue( 'enrollmentDate', '' );
-		setFieldValue( 'dateOfIncident', '' );
-		setInnerHTML('enrollmentDateDescription', '');
-		setInnerHTML('dateOfIncidentDescription', '');
-		
+		hideEnrolmentField();
+
 		hideById('programEnrollmentDiv');
-		hideEnrolmentField();
 		
 		return;
 	}
@@ -437,33 +428,25 @@
 			showById('programEnrollmentDiv');
 			showEnrolmentField();
 			
-			var singleEvent = jQuery('#programId option:selected').attr('singleevent');
+			var singleEvent = jQuery('#enrollmentDiv [name=programId] option:selected').attr('singleevent');
+			
 			if(singleEvent=='true')
 			{
-				disable('enrollBtn');
-				disable('enrollmentDate');
-				disable('dateOfIncident');
-				setInnerHTML('enrollmentDateDescription', '');
-				setInnerHTML('dateOfIncidentDescription', '');
-			}
-			else
-			{
-				enable('enrollBtn');
-				enable('enrollmentDate');
-				enable('dateOfIncident');
-				showById('enrollmentDateTD');
-				showById('dateOfIncidentTD');
-			}
-			
-			var hideDateOfIncident = jQuery('#programEnrollmentSelectDiv [name=programId] option:selected').attr('hidedateofincident');
-				
-			if( hideDateOfIncident=='true')
-			{
-				hideById( 'dateOfIncidentTR');
-			}
-			else
-			{
-				showById( 'dateOfIncidentTR');
+				hideEnrolmentField();
+			}
+			else
+			{
+				showEnrolmentField();
+				var hideDateOfIncident = jQuery('#programEnrollmentSelectDiv [name=programId] option:selected').attr('hidedateofincident');
+					
+				if( hideDateOfIncident=='true')
+				{
+					hideById( 'dateOfIncidentTR');
+				}
+				else
+				{
+					showById( 'dateOfIncidentTR');
+				}
 			}
 			
 			jQuery('#loaderDiv').hide();
@@ -549,12 +532,6 @@
 		}, 
 		function( json ) 
 		{   
-			setFieldValue( 'enrollmentDate', json.dateOfIncident );
-			setFieldValue( 'dateOfIncident', json.enrollmentDate );
-			setFieldValue( 'dateOfEnrollmentDescription', json.dateOfEnrollmentDescription );
-			setFieldValue( 'dateOfIncidentDescription', json.dateOfIncidentDescription );
-			disable( 'enrollmentDate' );
-			disable( 'dateOfIncident' );
 			showById( 'unenrollmentFormDiv' );
 			jQuery( "#loaderDiv" ).hide();
 		});
@@ -568,20 +545,16 @@
 		return;
 	}
 		
-	jQuery('#loaderDiv').show();
 	$.ajax({
 		type: "POST",
 		url: 'removeEnrollment.action',
 		data: getParamsForDiv('enrollmentDiv'),
 		success: function( json ) 
 		{
-			var list = byId( 'programInstanceId' );
-			list.remove( list.selectedIndex );
-			if( list.value == 0 )
-			{
-				hideById( 'unenrollmentFormDiv' );
-			}
-			jQuery('#loaderDiv').hide();
+			showSuccessMessage( i18n_unenrol_success );
+			hideEnrolmentField( 'enrollmentDateTR' );
+			jQuery('#enrollmentDiv [name=programId]').val('0');
+			hideById( 'programEnrollmentDiv' );
 		}
     });
 }
@@ -807,6 +780,8 @@
 
 function hideEnrolmentField()
 {
+	setFieldValue( 'enrollmentDate', '' );
+	setFieldValue( 'dateOfIncident', '' );
 	hideById('enrollmentDateTR');
 	hideById('dateOfIncidentTR');
 	hideById('enrollBtn');
@@ -821,8 +796,8 @@
 
 function savePatientIdentifier( identifierTypeId, field )
 {
+	field.style.backgroundColor = COLOR_WHITE;
 	field.blur();
-	field.style.backgroundColor = COLOR_WHITE;
 	if( validateValue( "iden" + identifierTypeId ) )
 	{
 		var patientId = getFieldValue("patientId");
@@ -839,8 +814,8 @@
 
 function savePatientAttrValue( patientAttributeId, field )
 {
+	field.style.backgroundColor = COLOR_WHITE;
 	field.blur();
-	field.style.backgroundColor = COLOR_WHITE;
 	if( validateValue( "attr" + patientAttributeId ) )
 	{
 		var patientId = getFieldValue("patientId");
@@ -1011,10 +986,10 @@
 			jQuery('#dataRecordingSelectDiv [id=backBtnFromEntry]').hide();
 			showById('dataRecordingSelectDiv');
 			
-			//var programId = jQuery('#programEnrollmentSelectDiv [id=programId] option:selected').val();
-			//var programName = jQuery('#programEnrollmentSelectDiv [id=programId] option:selected').text();
-			//$('#dataRecordingSelectDiv [id=programId]').find('option').remove().end().append('<option value="' + programId + '">' + programName + '</option>').val('whatever');
-
+			var programId = jQuery('#programEnrollmentSelectDiv [id=programId] option:selected').val();
+			$('#dataRecordingSelectDiv [id=programId]').val( programId );
+			$('#dataRecordingSelectDiv [id=programIdTR]').hide();
+			
 			loadProgramStages();
 			hideLoader();
 			hideById('contentDiv');

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2012-03-27 07:20:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2012-03-28 07:10:48 +0000
@@ -44,7 +44,7 @@
 	<td class='text-column'><label for="birthDate">$i18n.getString( "date_of_birth" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 	<td class="input-column">		
 		<input type="text" id="birthDate" name="birthDate" style='width:168px' />
-		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$i18n.getString( "verified" ) <input type='checkbox' id='verified' name='verified' onchange='verifiedOnchange();' value='true' checked >
+		$i18n.getString( "verified" ) <input type='checkbox' id='verified' name='verified' onchange='verifiedOnchange();' value='true' checked >
 		$i18n.getString( "age_year" ) <input type="text" id="age" name="age" class="{validate:{number:true}}"  style="width:50px" disabled />
 	</td>
    <td></td>
@@ -93,7 +93,7 @@
 	<tr><td colspan="2">&nbsp;</td></tr>	
 	<tr><th colspan="2" class="heading-column">$i18n.getString( "patient_identifiers" )</th></tr>
 	#foreach ($identifierType in $identifierTypes)
-		#if( $identifierType.program )
+		#if( $identifierType && $identifierType.program )
 		#else
 		<tr>
 			<td class='text-column'><label>$identifierType.name #if($identifierType.mandatory == true )<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>       
@@ -109,7 +109,7 @@
 	<tr><td>&nbsp;</td></tr>
 	<tr><th colspan="2" class="heading-column">$attributeGroup.name</th></tr>
 	#foreach($attribute in $attributeGroup.attributes )
-		#if( $attribute.program )
+		#if( $!attribute && $attribute.program )
 		#else
 		<tr>
 			<td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>
@@ -147,7 +147,7 @@
 #if ( $noGroupAttributes && $noGroupAttributes.size() > 0) 	
 	<tr><th colspan="2" class="heading-column">$i18n.getString( "other_details" )</th></tr>
 	#foreach($attribute in $noGroupAttributes )
-		#if( $attribute.program )
+		#if( $!attribute && $attribute.program )
 		#else
 		<tr>
 			<td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2012-03-27 14:19:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2012-03-28 07:10:48 +0000
@@ -92,7 +92,6 @@
 				
 				<td>
 				  <a href="javascript:showProgramEnrollmentSelectForm( '$patient.id' )" title='$i18n.getString( "program_enrollment_management" )'><img src="../images/enroll.png" alt='$i18n.getString( "program_enrollment" )'></a>                  
-				  <a href="javascript:showUnenrollmentSelectForm('$patient.id')" title='$i18n.getString( "program_unenrollment_management" )'><img src="../images/unenroll.png" alt='$i18n.getString( "program_unenrollment_management" )'></a>
 				  <a href="javascript:showUpdatePatientForm( '$patient.id' )" title='$i18n.getString( "edit_profile" )'><img src="../images/edit.png" alt='$i18n.getString( "edit_profile" )'></a>
 				  <a href="javascript:setFieldValue( 'isShowPatientList', false ); showRelationshipList('$patient.id')" title='$i18n.getString( "manage_relationship" )'><img src="../images/relationship.png" alt='$i18n.getString( "manage_relationship" )'></a>
 				  <a href="javascript:getPatientLocation( '$patient.id' ); " title='$i18n.getString( "migration_patient" )'><img src="../icons/dataentry.png" alt='$i18n.getString( "migration_patient" )' style='width:25px; height:25px'></a>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2012-03-27 10:33:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2012-03-28 07:10:48 +0000
@@ -1,46 +1,46 @@
-
+#if( $programInstance || $hasDataEntry=='true')
+<input type='hidden' id='programInstanceId' name='programInstanceId' value='$programInstance.id' />
 <div id="tabs">
 	<ul>
-		<li><a href="#tab-1">$i18n.getString("patient_identifier_and_attributes")</a></li>
-		<li><a href="#tab-2">$i18n.getString("name_based_data_entry")</a></li>
-		<li><a href="#tab-3">$i18n.getString("program_stage")</a></li>
+		<li><a href="#tab-1">$i18n.getString("identifier_and_attribute")</a></li>
+		<li><a href="#tab-2">$i18n.getString("modify_due_date_or_visit_date")</a></li>
+		<li><a href="#tab-3">$i18n.getString("data_entry_screen")</a></li>
+		<li><a href="#tab-4">$i18n.getString("unenrollment")</a></li>
 	</ul>
 	
 	
 	
 	<!-- Enroll program TAB -->
 	<div id="tab-1">
-	
 		<form id='programEnrollmentInforForm' name='programEnrollmentInforForm' action='#' method="POST" >
 			<!-- IDENTIFIERS -->
-			#if( $identifierTypes.size() > 0 || $noGroupAttributes.size() > 0 || $attributeGroups.size() > 0 )
+			#if( $identifierTypes || $noGroupAttributes || $attributeGroups )
 				<table class='mainPageTable' id='enrollmentInforDiv' name='enrollmentInforDiv' >
 					<col id="stageCol">    
 					<col id="entryCol">    
 					#if( $identifierTypes.size() > 0 )
 					<tr>
-						<th colspan='2'>$i18n.getString( "patient_identifier" )</th> 
+						<th colspan='2'>$i18n.getString( "identifier" )</th> 
 					</tr>
 					#end
 					
-					#set( $tabIndex = 1 )
 					#set( $mark = false )
 					#foreach ($identifierType in $identifierTypes)
 						#set( $identifier = $identiferMap.get( $identifierType.id ) )
 						<tr #alternate( $mark )>
 							<td class='text-column'><label>$identifierType.name #if($identifierType.mandatory == true )<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>       
-								<td class="input-column">
-								<input type="text" id="iden$identifierType.id" name="iden$identifierType.id" value='$!identifier' class="{validate:{required:$identifierType.mandatory, #if($!identifierType.noChars) maxlength:$identifierType.noChars, #end #if($identifierType.type=='number') number:true #elseif($!identifierType.type=='letter') lettersonly:true #end }}" onchange='savePatientIdentifier( $identifierType.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" /></td>
+							<td class="input-column">
+								<input type="text" id="iden$identifierType.id" name="iden$identifierType.id" value='$!identifier' class="{validate:{required:$identifierType.mandatory, #if($!identifierType.noChars) maxlength:$identifierType.noChars, #end #if($identifierType.type=='number') number:true #elseif($!identifierType.type=='letter') lettersonly:true #end }}" onchange='savePatientIdentifier( $identifierType.id, this);' />
+							</td>
 						</tr>
-						#set( $tabIndex = $tabIndex + 1 )
 						#set( $mark = !$mark  )
 					#end
 
 				<!-- ATTRIBUTES IN GROUPS -->
-				#set( $mark = false )
+				<tr><td>&nbsp;</td></tr>	
 				#foreach ($attributeGroup in $attributeGroups )
-					<tr><td>&nbsp;</td></tr>	
 					<tr><th colspan="2" class="heading-column">$attributeGroup.name</th></tr>
+					#set( $mark = false )
 					#foreach($attribute in $attributeGroup.attributes)
 						#if( $!attribute.program )
 							#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
@@ -48,31 +48,30 @@
 								<td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
 								<td class="input-column" >
 									#if( $attribute.valueType == "YES/NO" )
-										<select id="attr$attribute.id" name="attr$attribute.id" onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >              
+										<select id="attr$attribute.id" name="attr$attribute.id" onchange='savePatientAttrValue( $attribute.id, this);' >              
 											<option value="">[$i18n.getString( "please_select" )]</option>
 											<option value="true" #if( $attributeValue=='true') selected="selected" #end>$i18n.getString( "yes" )</option>
 											<option value="false" #if( $attributeValue=='false') selected="selected" #end>$i18n.getString( "no" )</option>
 										</select>                
 									#elseif( $attribute.valueType == "DATE" )
-										<input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class=' #validate( "default"  $attribute.mandatory )'  onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
+										<input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class=' #validate( "default"  $attribute.mandatory )'  onchange='savePatientAttrValue( $attribute.id, this);' >
 										<script type="text/javascript">
 											datePickerValid( 'attr$attribute.id' );
 										</script>                 
 									#elseif( $attribute.valueType == "COMBO" )
-										<select  id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
+										<select  id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' >
 											 <option value="">[$i18n.getString( "please_select" )]</option>
 										#foreach ($option in $attribute.attributeOptions )
 											<option value="$option.id" #if($attributeValue == $option.name) selected="selected" #end>$option.name</option>
 										#end
 										</select>
 									#else 
-										<input type="text"  id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}"  onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" > 
+										<input type="text"  id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}"  onchange='savePatientAttrValue( $attribute.id, this);' > 
 									#end
 								</td>		
 							</tr>
+							#set( $mark = !$mark  )
 						#end
-						#set( $tabIndex = $tabIndex + 1 )
-						#set( $mark = !$mark  )
 					#end
 				#end
 				<tr><td>&nbsp;</td></tr>
@@ -89,47 +88,40 @@
 								<td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
 								<td class="input-column" >
 									#if( $attribute.valueType == "YES/NO" )
-										<select id="attr$attribute.id"  name="attr$attribute.id" onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex">              
+										<select id="attr$attribute.id"  name="attr$attribute.id" onchange='savePatientAttrValue( $attribute.id, this);' >              
 											<option value="">[$i18n.getString( "please_select" )]</option>
 											<option value="true" #if( $attributeValue ) selected="selected" #end>$i18n.getString( "yes" )</option>
 											<option value="false" #if( !$attributeValue ) selected="selected" #end>$i18n.getString( "no" )</option>
 										</select>                
 									#elseif( $attribute.valueType == "DATE" )
-										<input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class=' #validate( "default"  $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex">
+										<input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class=' #validate( "default"  $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' >
 										<script type="text/javascript">
 											datePickerValid( 'attr$attribute.id' );
 										</script>                    
 									#elseif( $attribute.valueType == "COMBO" )
-										<select  id="attr$attribute.id"  name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex">
+										<select  id="attr$attribute.id"  name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' >
 											 <option value="">[$i18n.getString( "please_select" )]</option>
 										#foreach ($option in $attribute.attributeOptions )
 											<option value="$option.id" #if($attributeValue == $option.name) selected="selected" #end>$option.name</option>
 										#end
 										</select>
 									#else
-										<input type="text"  id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" onchange='savePatientAttrValue( $attribute.id, this);' onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
+										<input type="text"  id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" onchange='savePatientAttrValue( $attribute.id, this);' >
 									#end
 								</td>		
 							</tr>
+							#set( $mark = !$mark  )
 						#end
-						#set( $tabIndex = $tabIndex + 1 )
-						#set( $mark = !$mark  )
 					#end
 				#end
 			</table>
 			#end
+			<input type='submit' class='hidden'> 
 		</form>
 	</div>
 
+	<!-- Program-stage-instance TAB -->
 	<div id="tab-2">
-		<div id='dataRecordingSelectDiv' class='hidden'></div>
-		<div id='dataEntryFormDiv' class='hidden'></div>
-	</div>
-
-
-<!-- Program-stage-instance TAB -->
-	<div id="tab-3">
-
 		#if( $programStageInstances.size() > 0 )
 			<table class='mainPageTable' id='progarmStageListDiv' name='progarmStageListDiv' >
 				<col id="noCol">
@@ -143,7 +135,6 @@
 				
 			#set( $rowCount = 0 )
 			#set( $mark = false )
-			#set( $tabIndex = 1 )
 			#foreach( $programStageInstance in $programStageInstances )
 				#set( $rowCount = $rowCount + 1 )   
 				<tr #alternate( $mark ) >
@@ -159,37 +150,102 @@
 					##entry
 					#set( $duedateId = "value_"+$programStageInstance.id+"_date" )        
 					<td class='input-column '>        
-						<input type="text" id="$duedateId" name="entryfield" value="$!format.formatDate( $programStageInstance.dueDate )" onchange="saveDueDate( $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" tabindex="$tabIndex" >
+						<input type="text" id="$duedateId" name="entryfield" value="$!format.formatDate( $programStageInstance.dueDate )" onchange="saveDueDate( $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" />
 						<script type="text/javascript">
 							datePicker( '$duedateId' );
 						</script> 
 					</td>      
 				</tr>
-				#set( $tabIndex = $tabIndex + 1 )
 				#set( $mark = !$mark  )
 			#end
 			</table>
 		#end
-		<input type='submit' value='sfda' class='hidden'>
-	</div>
-</div>
+	</div>
+
+	<div id="tab-3">
+		<div id='dataRecordingSelectDiv' class='hidden'></div>
+		<div id='dataEntryFormDiv' class='hidden'></div>
+	</div>
+
+	<div id="tab-4">
+		<table>
+			#foreach($attribute in $programAttributes)
+			<tr>
+				<td class='text-column'>$attribute.name</td>
+				<td class="input-column">
+					#if( $attribute.valueType == "YES/NO" )
+						<select id="attr$attribute.id" name="attr$attribute.id" > 
+							<option value="">[$i18n.getString( "please_select" )]</option>
+							<option value="true">$i18n.getString( "yes" )</option>
+							<option value="false">$i18n.getString( "no" )</option>
+						</select>                     
+					#elseif( $attribute.valueType == "DATE" )
+						<input type="text" id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )'>
+						<script type="text/javascript">
+							var attributeId = 'attr' + '$attribute.id'
+							datePickerValid( attributeId );
+						</script>                       
+					#elseif( $attribute.valueType == "COMBO" )
+						<select id="attr$attribute.id" name="attr$attribute.id" >
+							<option value="">[$i18n.getString( "please_select" )]</option>
+							#foreach ($option in $attribute.attributeOptions )
+								<option value="$option.id" >$option.name</option>
+							#end
+						</select>
+					#else 
+						<input type="text" id="attr$attribute.id" name="attr$attribute.id" >
+					#end
+					
+					#if($!programAttribute.description) <i>($!programAttribute.description)</i> #end
+				</td>		
+			</tr>
+			#end
+			
+			<tr>
+				<td></td>
+				<td></td>                            
+			</tr>
+		
+			<tr>
+				<td>
+					<input type="button" class='button' value='$i18n.getString( "unenroll" )' onclick="javascript:unenrollmentForm( getFieldValue('programInstanceId') );" >
+				</td>                                        
+			</tr>
+		</table>
+	</div>
+	
+</div>	
+
+#end
 
 <script type="text/javascript">
 	
-	jQuery(document).ready(	function(){
+	jQuery("#programEnrollmentInforForm").ready(	function(){
 		validation( 'programEnrollmentInforForm', function(form){
 			return false;
 		});	
 	});
 		
-	jQuery("#tabs").tabs();
-	$( "#tabs" ).tabs( "option", "selected", 0 );
-	$('#tabs').bind('tabsselect', function(event, ui) {
-		if( ui.index == 1 )
-		{
+	#if( $programInstance || $hasDataEntry == 'true')
+		$('#tabs').tabs();
+			
+		#if( $identifierTypes || $noGroupAttributes || $attributeGroups )
+			$( "#tabs" ).tabs( "option", "selected", 1 );
+			$( "#tabs" ).tabs( "option", "disabled", [0] );
+		#end
+		
+		#if( $programInstance )
+		#else
+			$( "#tabs" ).tabs( "option", "selected", 2 );
+			$( "#tabs" ).tabs( "option", "disabled", [0,1,3] );
+		#end
+		
+		#if( $hasDataEntry == 'true' )
 			showSelectedDataRecoding( getFieldValue('patientId') );
-		}
-	});
+		#else
+			$( "#tabs" ).tabs( "option", "disabled", [2] );
+		#end
+	#end
 	
 	byId('enrollBtn').value = i18n_update;
 	setInnerHTML('enrollmentDateDescription', "$!program.dateOfEnrollmentDescription" );
@@ -203,4 +259,3 @@
 		jQuery('#enrollBtn').attr( 'value',i18n_update );
 	}	
 </script>
-

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm	2012-03-27 14:19:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm	2012-03-28 07:10:48 +0000
@@ -1,38 +1,39 @@
-<h3>$i18n.getString( "patient_registered" )</h3>
+<h3>$i18n.getString( "patient_info" )</h3>
 
 <div>
-
-	<table>
-		<tr>
-			<td class='bold text-column'>$i18n.getString( "full_name" ):</td>
-			<td>$encoder.htmlEncode( $patient.getFullName() )</td>
-		</tr>
-		<tr>
-			<td class='bold text-column'>$i18n.getString( "gender" ):</td>
-			<td>$i18n.getString( $patient.gender )</td>
-		</tr>    
-		<tr>
-			<td class='bold text-column'>$i18n.getString( "date_of_birth" ):</td>
-			<td>$format.formatDate( $patient.birthDate )</td>
-		</tr>
-		<tr>
-			<td class='bold text-column'>$i18n.getString( "age" ):</td>
-			<td>$encoder.htmlEncode( $patient.getAge() )</td>
-		</tr>
-		<tr>
-			<td>&nbsp;</td>
-		</tr>
-		<tr>
-			<td colspan='2'>
-				<input type="button" class='button' value="$i18n.getString( 'back_to_registration' )" onclick="loadPatientList();" >
-			</td>
-		</tr>
-	</table>
-<hr/>
-	<form id='programEnrollmentSelectDiv' name='programEnrollmentSelectDiv' method='POST'>
+	
+		<table>
+			<tr>
+				<td class='bold text-column'>$i18n.getString( "full_name" ):</td>
+				<td>$encoder.htmlEncode( $patient.getFullName() )</td>
+			</tr>
+			<tr>
+				<td class='bold text-column'>$i18n.getString( "gender" ):</td>
+				<td>$i18n.getString( $patient.gender )</td>
+			</tr>
+			<tr>
+				<td class='bold text-column'>$i18n.getString( "date_of_birth" ):</td>
+				<td>$format.formatDate( $patient.birthDate ) $patient.getAge()</td>
+			</tr>
+			<tr>
+				<td>&nbsp;</td>
+			</tr>
+			<tr>
+				<td colspan='2'>
+					<input type="button" class='button' value="$i18n.getString( 'back_to_registration' )" onclick="loadPatientList();" >
+				</td>
+			</tr>
+		</table>
+	
+	
+	<p></p>
+	
+	<fieldset>
+		<legend><strong>$i18n.getString( "program_enrolled_for" )</strong></legend>
+		<form id='programEnrollmentSelectDiv' name='programEnrollmentSelectDiv' method='POST'>
 			<input type="hidden" id="patientId" name="patientId" value="$patient.id">    
 
-			<table>    
+			<table>  
 				<tr>
 					<td class='text-column'><label for="programId">$i18n.getString( "program" )</label></td>
 					<td class='input-column'>
@@ -48,12 +49,12 @@
 				</tr>   
 				<tr id='enrollmentDateTR' class='hidden'>
 					<td class='text-column'><label for="enrollmentDate"><span id='enrollmentDateDescription'></span><em title="$i18n.getString( "required" )" class="required"> * </em></label></td>
-                    <td colspan='2' class='input-column'><input type="text" id="enrollmentDate" name="enrollmentDate" disabled="disabled" class="{validate:{required:true}}"></td>
+                    <td colspan='2' class='input-column'><input type="text" id="enrollmentDate" name="enrollmentDate" ></td>
 				</tr>
 				
-				<tr id='dateOfIncidentTR' style='display:none'>
+				<tr id='dateOfIncidentTR' class='hidden'>
 					<td class='text-column'><label for="dateOfIncident"><span id='dateOfIncidentDescription'></span><em title="$i18n.getString( "required" )" class="required"> * </em></label></td>
-					<td colspan='2' class='input-column'><input type="text" id="dateOfIncident" name="dateOfIncident" disabled="disabled" class="{validate:{required:true}}"></td>
+					<td colspan='2' class='input-column'><input type="text" id="dateOfIncident" name="dateOfIncident" ></td>
 				</tr>
 			
 				<tr>
@@ -72,9 +73,12 @@
                 	<td colspan='3'><span id='message'></span></td>
                 </tr>
 			</table>
-			</form>
-			
-			<div id='programEnrollmentDiv' class='hidden'></div>
+		</form>
+		
+		<p></p>
+	
+		<div id='programEnrollmentDiv' class='hidden'></div>
+	</fieldset>
 	
 </div>
 

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programUnenrollmentSelectForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programUnenrollmentSelectForm.vm	2012-02-01 09:10:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programUnenrollmentSelectForm.vm	1970-01-01 00:00:00 +0000
@@ -1,159 +0,0 @@
-
-<script>
-	//-----------------------------------------------------------------------
-	//init jQuery validation for programEnrollmentForm
-	//-----------------------------------------------------------------------
-	jQuery(document).ready(
-			function()
-			{
-				jQuery("#programUnenrollmentForm").validate({
-					 meta:"validate"
-					,errorElement:"td"
-					,submitHandler: function(form)
-									{
-										validateProgramEnrollment();
-									}
-				});
-
-                datePickerValid( 'enrollmentDate' );
-                datePickerValid( 'dateOfIncident' );
-			}
-	);
-
-</script>
-
-<h3>$i18n.getString( "program_unenrollment" )</h3>
-
-<table>
-    <tr>
-        <td class="bold text-column">$i18n.getString( "full_name" ):</td>
-        <td>$encoder.htmlEncode( $patient.getFullName() )</td>
-    </tr>
-    <tr>
-        <td class="bold text-column">$i18n.getString( "gender" ):</td>
-        <td>$i18n.getString( $patient.gender )</td>
-    </tr>    
-    <tr>
-        <td class="bold text-column">$i18n.getString( "date_of_birth" ):</td>
-        <td>$format.formatDate( $patient.birthDate )</td>
-    </tr>
-    <tr>
-        <td class="bold text-column">$i18n.getString( "age" ):</td>
-        <td>$encoder.htmlEncode( $patient.getAge() )</td>
-    <tr>
-		<td>&nbsp;</td>
-	</tr>
-	<tr>
-		<td colspan='2'>
-			<input type="button" value="$i18n.getString( 'back_to_registration' )" onclick="onClickBackBtn();" >
-		</td>
-	</tr>
-</table>
-
-<hr style="clear:both">
-
-<form id="programEnrollmentForm" name="programEnrollmentForm" method="post">
-
-<input type="hidden" id="patientId" name="patientId" value="$patient.id">    
-
-<table>    
-    <tr>
-        <td class="text-column" style='width:110px'><label for="programId">$i18n.getString( "program" )</label></td>
-        <td class="input-column">
-            <select id="programInstanceId" name="programInstanceId" onchange="showUnenrollmentForm( this.value )" >
-                <option value="0">[$i18n.getString( "select" )]</option>
-                #foreach( $instance in $programInstances )
-                    <option value="$instance.id" >$encoder.htmlEncode( $instance.program.name )</option>
-                #end
-            </select>
-        </td>
-    </tr>   
-        
-</table>
-
-<div id='unenrollmentFormDiv' class='hidden'>
-	
-	<table>
-		<tr>
-			<td class='text-column'><label for="enrollmentDate">$i18n.getString( "date_of_enrollment" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-			<td class="input-column"><input type="text" id="enrollmentDate" name="enrollmentDate" value="$!format.formatDate( $programInstance.enrollmentDate )"> <i id='dateOfEnrollmentDescription'></i></td>
-		</tr>
-		
-		<tr>
-			<td class='text-column'><label for="dateOfIncident">$i18n.getString( "date_of_incident" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-			<td class="input-column"><input type="text" id="dateOfIncident" name="dateOfIncident" value="$!format.formatDate( $programInstance.dateOfIncident )"><i id='dateOfIncidentDescription'></i></td>
-		</tr>
-		<tr>
-			<td></td>
-			<td></td>                           
-		</tr>
-
-		<tr>
-			<td colspan='2'></td>	
-		<tr>
-	
-		<!-- ------------------------------------------------------------ -->
-		<!--                   Show Program - Attributes                  -->
-		<!-- ------------------------------------------------------------ -->
-		<tr>
-			<th colspan='2'>$i18n.getString('reason')</th>
-		<tr>
-		#foreach($attribute in $programAttributes)
-		<tr>
-			<td class='text-column'>$attribute.name</td>
-			<td class="input-column">
-				#if( $attribute.valueType == "YES/NO" )
-					<select id="attr$attribute.id" name="attr$attribute.id" > 
-						<option value="">[$i18n.getString( "please_select" )]</option>
-						<option value="true">$i18n.getString( "yes" )</option>
-						<option value="false">$i18n.getString( "no" )</option>
-					</select>                     
-				#elseif( $attribute.valueType == "DATE" )
-					<input type="text" id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )'>
-					<script type="text/javascript">
-						var attributeId = 'attr' + '$attribute.id'
-						datePickerValid( attributeId );
-					</script>                       
-				#elseif( $attribute.valueType == "COMBO" )
-					<select id="attr$attribute.id" name="attr$attribute.id" >
-						<option value="">[$i18n.getString( "please_select" )]</option>
-						#foreach ($option in $attribute.attributeOptions )
-							<option value="$option.id" >$option.name</option>
-						#end
-					</select>
-				#else 
-					<input type="text" id="attr$attribute.id" name="attr$attribute.id" >
-				#end
-				
-				#if($!programAttribute.description) <i>($!programAttribute.description)</i> #end
-			</td>		
-		</tr>
-		#end
-		
-		<tr>
-			<td></td>
-			<td></td>                            
-		</tr>
-	
-	</table>
-
-
-	<table>
-		<tr>
-			<td>
-				<input type="button" class='button' value='$i18n.getString( "unenroll" )' onclick="javascript:unenrollmentForm( getFieldValue('programInstanceId') );" >
-			</td>                                        
-		</tr>
-	</table>
-</div>
-
-</form>
-
-<script type="text/javascript">    
-    var i18n_program_enrollment_failed = '$encoder.jsEscape( $i18n.getString( "program_enrollment_failed" ) , "'")';
-    var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
-    var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
-    var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")'; 
-	var i18n_date_invalid = '$encoder.jsEscape( $i18n.getString( "date_invalid" ) , "'")';
-	var i18n_date_less_incident = '$encoder.jsEscape( $i18n.getString( "date_less_incident" ) , "'")';
-</script>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2012-03-27 14:19:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2012-03-28 07:10:48 +0000
@@ -62,6 +62,7 @@
 	var i18n_save_success = '$encoder.jsEscape( $i18n.getString( "save_success" ) , "'")';
 	var i18n_list_all_patient = '$encoder.jsEscape( $i18n.getString( "list_all_patient" ) , "'")';
 	var i18n_enrol_success = '$encoder.jsEscape( $i18n.getString( "enrol_success" ) , "'")';
+	var i18n_unenrol_success = '$encoder.jsEscape( $i18n.getString( "unenrol_success" ) , "'")';
 	var i18n_list_patients_by_program = '$encoder.jsEscape( $i18n.getString( "list_patients_by_program" ) , "'" )';
 	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_patient" ) , "'" )';
 	var i18n_adding_patient_failed = '$encoder.jsEscape( $i18n.getString( "adding_patient_failed" ), "'")';

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/patient.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/patient.css	2012-03-27 04:22:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/patient.css	2012-03-28 07:10:48 +0000
@@ -73,3 +73,8 @@
 {
 	width: 130px;
 }
+
+fieldset
+{
+	border: 1px solid #3f5d8e;
+}