← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3550: Load case-entry by ajax

 

------------------------------------------------------------
revno: 3550
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-10 14:25:28 +0700
message:
  Load case-entry by ajax
removed:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CustomDataEntryAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntryAction.java
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetSelectedOrgunitAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStagesAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseProgramStages.vm
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntrySelectAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientFormAction.java
  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/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/dataEntryForm.vm
  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-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseOrgUnit.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java	2011-05-01 09:07:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java	2011-05-10 07:25:28 +0000
@@ -64,30 +64,6 @@
     // Input / Output
     // -------------------------------------------------------------------------
 
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    public Integer getId()
-    {
-        return id;
-    }
-
-    private Integer programId;
-
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
-    public Integer getProgramId()
-    {
-        return programId;
-    }
-
     private Integer programStageId;
 
     public Integer getProgramStageId()

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CustomDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CustomDataEntryAction.java	2011-05-01 09:07:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CustomDataEntryAction.java	1970-01-01 00:00:00 +0000
@@ -1,365 +0,0 @@
-package org.hisp.dhis.caseentry.action.caseentry;
-
-/*
- * 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.
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hisp.dhis.caseentry.screen.DataEntryScreenManager;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataentryform.DataEntryForm;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.minmax.MinMaxDataElement;
-import org.hisp.dhis.minmax.MinMaxDataElementService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientIdentifier;
-import org.hisp.dhis.patient.PatientIdentifierService;
-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.ProgramStageInstance;
-import org.hisp.dhis.program.ProgramStageInstanceService;
-import org.hisp.dhis.program.ProgramStageService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Viet Nguyen
- */
-public class CustomDataEntryAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private PatientService patientService;
-
-    public void setPatientService( PatientService patientService )
-    {
-        this.patientService = patientService;
-    }
-
-    private ProgramInstanceService programInstanceService;
-
-    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
-    {
-        this.programInstanceService = programInstanceService;
-    }
-
-    private ProgramStageService programStageService;
-
-    public void setProgramStageService( ProgramStageService programStageService )
-    {
-        this.programStageService = programStageService;
-    }
-
-    private ProgramStageInstanceService programStageInstanceService;
-
-    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
-    {
-        this.programStageInstanceService = programStageInstanceService;
-    }
-
-    private PatientIdentifierService patientIdentifierService;
-
-    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
-    {
-        this.patientIdentifierService = patientIdentifierService;
-    }
-
-    private PatientDataValueService patientDataValueService;
-
-    public void setPatientDataValueService( PatientDataValueService patientDataValueService )
-    {
-        this.patientDataValueService = patientDataValueService;
-    }
-
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
-    private DataEntryScreenManager dataEntryScreenManager;
-
-    public void setDataEntryScreenManager( DataEntryScreenManager dataEntryScreenManager )
-    {
-        this.dataEntryScreenManager = dataEntryScreenManager;
-    }
-
-    private MinMaxDataElementService minMaxDataElementService;
-
-    public void setMinMaxDataElementService( MinMaxDataElementService minMaxDataElementService )
-    {
-        this.minMaxDataElementService = minMaxDataElementService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input / Output
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    public Integer getId()
-    {
-        return id;
-    }
-
-    private Integer programId;
-
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
-    public Integer getProgramId()
-    {
-        return programId;
-    }
-
-    private Integer programStageId;
-
-    public Integer getProgramStageId()
-    {
-        return programStageId;
-    }
-
-    public void setProgramStageId( Integer programStageId )
-    {
-        this.programStageId = programStageId;
-    }
-
-    private Patient patient;
-
-    public Patient getPatient()
-    {
-        return patient;
-    }
-
-    private PatientIdentifier patientIdentifier;
-
-    public PatientIdentifier getPatientIdentifier()
-    {
-        return patientIdentifier;
-    }
-
-    private Program program;
-
-    public Program getProgram()
-    {
-        return program;
-    }
-
-    private ProgramStage programStage;
-
-    public ProgramStage getProgramStage()
-    {
-        return programStage;
-    }
-
-    private Collection<DataElement> dataElements = new ArrayList<DataElement>();
-
-    public Collection<DataElement> getDataElements()
-    {
-        return dataElements;
-    }
-
-    private Map<Integer, Collection<DataElementCategoryOptionCombo>> optionMap = new HashMap<Integer, Collection<DataElementCategoryOptionCombo>>();
-
-    public Map<Integer, Collection<DataElementCategoryOptionCombo>> getOptionMap()
-    {
-        return optionMap;
-    }
-
-    private Map<Integer, PatientDataValue> patientDataValueMap;
-
-    public Map<Integer, PatientDataValue> getPatientDataValueMap()
-    {
-        return patientDataValueMap;
-    }
-
-    private OrganisationUnit organisationUnit;
-
-    public OrganisationUnit getOrganisationUnit()
-    {
-        return organisationUnit;
-    }
-
-    private DataEntryForm dataEntryForm;
-
-    public DataEntryForm getDataEntryForm()
-    {
-        return this.dataEntryForm;
-    }
-
-    private I18n i18n;
-
-    public void setI18n( I18n i18n )
-    {
-        this.i18n = i18n;
-    }
-
-    private boolean customDataEntryFormExists;
-
-    public boolean isCustomDataEntryFormExists()
-    {
-        return customDataEntryFormExists;
-    }
-
-    public void setCustomDataEntryFormExists( boolean customDataEntryFormExists )
-    {
-        this.customDataEntryFormExists = customDataEntryFormExists;
-    }
-
-    private String useDefaultForm;
-
-    public String getUseDefaultForm()
-    {
-        return useDefaultForm;
-    }
-
-    public void setUseDefaultForm( String useDefaultForm )
-    {
-        this.useDefaultForm = useDefaultForm;
-    }
-
-    public ProgramStageInstance programStageInstance;
-
-    public int getProgramStageInstanceId()
-    {
-        return programStageInstance.getId();
-    }
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private String customDataEntryFormCode = null;
-
-    public String getCustomDataEntryFormCode()
-    {
-        return this.customDataEntryFormCode;
-    }
-
-    private Collection<ProgramStageDataElement> programStageDataElements;
-
-    public Collection<ProgramStageDataElement> getProgramStageDataElements()
-    {
-        return programStageDataElements;
-    }
-
-    // -------------------------------------------------------------------------
-    // Implementation Action
-    // -------------------------------------------------------------------------
-
-    public String execute()
-        throws Exception
-    {
-        Collection<MinMaxDataElement> minMaxDataElements = minMaxDataElementService.getMinMaxDataElements(
-            organisationUnit, dataElements );
-
-        Map<Integer, MinMaxDataElement> minMaxMap = new HashMap<Integer, MinMaxDataElement>( minMaxDataElements.size() );
-
-        for ( MinMaxDataElement minMaxDataElement : minMaxDataElements )
-        {
-            minMaxMap.put( minMaxDataElement.getDataElement().getId(), minMaxDataElement );
-        }
-
-        organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
-        patient = patientService.getPatient( id );
-
-        patientIdentifier = patientIdentifierService.getPatientIdentifier( patient );
-
-        program = selectedStateManager.getSelectedProgram();
-
-        programStage = programStageService.getProgramStage( programStageId );
-
-        Collection<ProgramInstance> progamInstances = programInstanceService.getProgramInstances( patient, program,
-            false );
-
-        if ( progamInstances == null || progamInstances.size() == 0 )
-        {
-            return SUCCESS;
-        }
-
-        ProgramInstance programInstance = progamInstances.iterator().next();
-
-        if ( programInstance == null )
-        {
-            return SUCCESS;
-        }
-
-        programStageInstance = programStageInstanceService.getProgramStageInstance( programInstance, programStage );
-
-        if ( programStageInstance == null )
-        {
-            return SUCCESS;
-        }
-
-        Collection<PatientDataValue> patientDataValues = patientDataValueService
-            .getPatientDataValues( programStageInstance );
-
-        dataEntryForm = programStage.getDataEntryForm();
-        if ( dataEntryForm == null )
-        {
-            return SUCCESS;
-        }
-
-        boolean cdeFormExists = (dataEntryForm != null);
-
-        String disabled = "";
-
-        if ( cdeFormExists )
-        {
-            customDataEntryFormCode = dataEntryScreenManager.populateCustomDataEntryScreenForMultiDimensional(
-                dataEntryForm.getHtmlCode(), patientDataValues, minMaxMap, disabled, i18n,
-                programStage, programStageInstance, organisationUnit );
-        }
-
-        return SUCCESS;
-    }
-
-}

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntryAction.java	2011-05-01 09:07:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntryAction.java	1970-01-01 00:00:00 +0000
@@ -1,289 +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.caseentry.action.caseentry;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-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.ProgramStageDataElementService;
-import org.hisp.dhis.program.ProgramStageInstance;
-import org.hisp.dhis.program.ProgramStageInstanceService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Abyot Asalefew Gizaw
- * @version $Id$
- */
-public class DataEntryAction
-    implements Action
-{
-    Log log = LogFactory.getLog( CustomDataEntryAction.class );
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ProgramInstanceService programInstanceService;
-
-    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
-    {
-        this.programInstanceService = programInstanceService;
-    }
-
-    private ProgramStageInstanceService programStageInstanceService;
-
-    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
-    {
-        this.programStageInstanceService = programStageInstanceService;
-    }
-
-    private PatientDataValueService patientDataValueService;
-
-    public void setPatientDataValueService( PatientDataValueService patientDataValueService )
-    {
-        this.patientDataValueService = patientDataValueService;
-    }
-
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
-    private ProgramStageDataElementService programStageDataElementService;
-
-    public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService )
-    {
-        this.programStageDataElementService = programStageDataElementService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input/Output
-    // -------------------------------------------------------------------------
-    
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    public Integer getId()
-    {
-        return id;
-    }
-    
-    private Integer programId;
-
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
-    public Integer getProgramId()
-    {
-        return programId;
-    }
-
-    private Integer programStageId;
-
-    public Integer getProgramStageId()
-    {
-        return programStageId;
-    }
-
-    public void setProgramStageId( Integer programStageId )
-    {
-        this.programStageId = programStageId;
-    }
-
-    private Patient patient;
-
-    public Patient getPatient()
-    {
-        return patient;
-    }
-
-    private Program program;
-
-    public Program getProgram()
-    {
-        return program;
-    }
-
-    private ProgramStage programStage;
-
-    public ProgramStage getProgramStage()
-    {
-        return programStage;
-    }
-
-    private ProgramInstance programInstance;
-
-    public ProgramInstance getProgramInstance()
-    {
-        return programInstance;
-    }
-    
-    private int programStageInstanceId;
-    
-    public int getProgramStageInstanceId()
-    {
-        return programStageInstanceId;
-    }
-
-    private Collection<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>();
-
-    public Collection<ProgramStageDataElement> getProgramStageDataElements()
-    {
-        return programStageDataElements;
-    }
-
-    private Map<Integer, Collection<DataElementCategoryOptionCombo>> optionMap = new HashMap<Integer, Collection<DataElementCategoryOptionCombo>>();
-
-    public Map<Integer, Collection<DataElementCategoryOptionCombo>> getOptionMap()
-    {
-        return optionMap;
-    }
-
-    private Map<Integer, PatientDataValue> patientDataValueMap;
-
-    public Map<Integer, PatientDataValue> getPatientDataValueMap()
-    {
-        return patientDataValueMap;
-    }
-
-    private OrganisationUnit organisationUnit;
-
-    public OrganisationUnit getOrganisationUnit()
-    {
-        return organisationUnit;
-    }
-
-    private Map<Integer, String> colorMap = new HashMap<Integer, String>();
-
-    public Map<Integer, String> getColorMap()
-    {
-        return colorMap;
-    }
-
-    private String useDefaultForm;
-
-    public String getUseDefaultForm()
-    {
-        return useDefaultForm;
-    }
-
-    public void setUseDefaultForm( String useDefaultForm )
-    {
-        this.useDefaultForm = useDefaultForm;
-    }
-
-    private String useCustomForm;
-
-    public String getUseCustomForm()
-    {
-        return useCustomForm;
-    }
-
-    public void setUseCustomForm( String useCustomForm )
-    {
-        this.useCustomForm = useCustomForm;
-    }
-
-    // -------------------------------------------------------------------------
-    // Implementation Action
-    // -------------------------------------------------------------------------
-
-    public String execute()
-        throws Exception
-    {
-        organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
-        patient = selectedStateManager.getSelectedPatient();
-        
-        id = patient.getId();
-
-        program = selectedStateManager.getSelectedProgram();
-
-        programId = program.getId();
-
-        programStage = selectedStateManager.getSelectedProgramStage();
-
-        programStageId = programStage.getId();
-
-        programStageDataElements = programStage.getProgramStageDataElements();
-
-        Collection<DataElement> dataElements = programStageDataElementService.getListDataElement( programStage );
-
-        for ( DataElement dataElement : dataElements )
-        {
-            optionMap.put( dataElement.getId(), dataElement.getCategoryCombo().getOptionCombos() );
-        }
-
-        Collection<ProgramInstance> progamInstances = programInstanceService.getProgramInstances( patient, program, false );
-
-        programInstance = progamInstances.iterator().next();
-
-        colorMap = programStageInstanceService.colorProgramStageInstances( programInstance.getProgramStageInstances() );
-
-        ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(
-            programInstance, programStage );
-
-        programStageInstanceId = programStageInstance.getId();
-        
-        Collection<PatientDataValue> patientDataValues = patientDataValueService
-            .getPatientDataValues( programStageInstance );
-
-        patientDataValueMap = new HashMap<Integer, PatientDataValue>( patientDataValues.size() );
-
-        for ( PatientDataValue patientDataValue : patientDataValues )
-        {
-            patientDataValueMap.put( patientDataValue.getDataElement().getId(), patientDataValue );
-        }
-
-        return SUCCESS;
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntrySelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntrySelectAction.java	2011-03-31 01:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntrySelectAction.java	2011-05-10 07:25:28 +0000
@@ -27,8 +27,12 @@
 
 package org.hisp.dhis.caseentry.action.caseentry;
 
+import java.util.Collection;
+
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -39,8 +43,6 @@
 public class DataEntrySelectAction
     implements Action
 {
-    private static final String SEARCH_FORM = "searchform";
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -52,6 +54,13 @@
         this.selectionManager = selectionManager;
     }
 
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -63,6 +72,13 @@
         return organisationUnit;
     }
 
+    Collection<PatientAttribute> patientAttributes;
+
+    public Collection<PatientAttribute> getPatientAttributes()
+    {
+        return patientAttributes;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -72,11 +88,8 @@
     {
         organisationUnit = selectionManager.getSelectedOrganisationUnit();
 
-        if ( organisationUnit == null )
-        {
-            return SUCCESS;
-        }
+        patientAttributes = patientAttributeService.getAllPatientAttributes();
 
-        return SEARCH_FORM;
+        return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java	2011-05-01 09:07:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java	2011-05-10 07:25:28 +0000
@@ -28,21 +28,10 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
-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.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 org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageInstance;
-import org.hisp.dhis.program.ProgramStageInstanceService;
-import org.hisp.dhis.program.ProgramStageService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -53,21 +42,10 @@
 public class DataRecordingSelectAction
     implements Action
 {
-    private static final String DATAENTRY_FORM = "dataentryform";
-
-    private static final String CUSTOM_DATAENTRY_FORM = "customentryform";
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
     private PatientService patientService;
 
     public void setPatientService( PatientService patientService )
@@ -75,72 +53,15 @@
         this.patientService = patientService;
     }
 
-    private ProgramService programService;
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
-    private ProgramStageService programStageService;
-
-    public void setProgramStageService( ProgramStageService programStageService )
-    {
-        this.programStageService = programStageService;
-    }
-
-    private ProgramInstanceService programInstanceService;
-
-    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
-    {
-        this.programInstanceService = programInstanceService;
-    }
-
-    private ProgramStageInstanceService programStageInstanceService;
-
-    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
-    {
-        this.programStageInstanceService = programStageInstanceService;
-    }
-
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    public Integer getId()
-    {
-        return id;
-    }
-
-    private Integer programId;
-
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
-    public Integer getProgramId()
-    {
-        return programId;
-    }
-
-    private Integer programStageId;
-
-    public Integer getProgramStageId()
-    {
-        return programStageId;
-    }
-
-    public void setProgramStageId( Integer programStageId )
-    {
-        this.programStageId = programStageId;
+    private Integer patientId;
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
     }
 
     private Patient patient;
@@ -157,60 +78,6 @@
         return programs;
     }
 
-    private Collection<ProgramStage> programStages;
-
-    public Collection<ProgramStage> getProgramStages()
-    {
-        return programStages;
-    }
-
-    private OrganisationUnit organisationUnit;
-
-    public OrganisationUnit getOrganisationUnit()
-    {
-        return organisationUnit;
-    }
-
-    private ProgramInstance programInstance;
-
-    public ProgramInstance getProgramInstance()
-    {
-        return programInstance;
-    }
-
-    private ProgramStageInstance programStageInstance;
-
-    public ProgramStageInstance getProgramStageInstance()
-    {
-        return programStageInstance;
-    }
-
-    private Map<Integer, String> colorMap = new HashMap<Integer, String>();
-
-    public Map<Integer, String> getColorMap()
-    {
-        return colorMap;
-    }
-
-    private boolean customDataEntryFormExists;
-
-    public boolean getCustomDataEntryFormExists()
-    {
-        return customDataEntryFormExists;
-    }
-
-    private String useDefaultForm;
-
-    public String getUseDefaultForm()
-    {
-        return useDefaultForm;
-    }
-
-    public void setUseDefaultForm( String useDefaultForm )
-    {
-        this.useDefaultForm = useDefaultForm;
-    }
-
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -218,146 +85,13 @@
     public String execute()
         throws Exception
     {
-        // ---------------------------------------------------------------------
-        // Validate selected OrganisationUnit && Patient
-        // ---------------------------------------------------------------------
-    
-        organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-        
-        if ( organisationUnit == null || id == null )
-        {
-            programId = null;
-            programStageId = null;
-            
-            selectedStateManager.clearSelectedPatient();
-            selectedStateManager.clearSelectedProgram();
-            selectedStateManager.clearSelectedProgramStage();
-            
-            return SUCCESS;
-        }
-        
-        patient = patientService.getPatient( id );
-        
-        selectedStateManager.setSelectedPatient( patient );
-        
-        // ---------------------------------------------------------------------
-        // Load Enrolled Programs
-        // ---------------------------------------------------------------------
-        
+        patient = patientService.getPatient( patientId );
+
         for ( Program program : patient.getPrograms() )
         {
-            if ( program.getOrganisationUnits().contains( organisationUnit ) )
-            {
-                programs.add( program );
-            }
-        }
-        
-        // ---------------------------------------------------------------------
-        // Validate selected Program
-        // ---------------------------------------------------------------------
-
-        Program selectedProgram;
-        
-        if ( programId != null )
-        {
-            selectedProgram = programService.getProgram( programId );
-        }
-        else
-        {
-            selectedProgram = selectedStateManager.getSelectedProgram();
-        }
-
-        if ( selectedProgram != null && programs.contains( selectedProgram ) )
-        {
-            programId = selectedProgram.getId();
-            selectedStateManager.setSelectedProgram( selectedProgram );
-        }
-        else
-        {
-            programId = null;
-            programStageId = null;
-
-            selectedStateManager.clearSelectedProgram();
-            selectedStateManager.clearSelectedProgramStage();
-
-            return SUCCESS;
-        }
-        
-        // ---------------------------------------------------------------------
-        // Load the active program instance completed = false we need the
-        // corresponding stage execution date
-        // ---------------------------------------------------------------------
-
-        Collection<ProgramInstance> progamInstances = programInstanceService.getProgramInstances( patient,
-            selectedProgram, false );
-        
-        if ( progamInstances == null || progamInstances.iterator() == null || !progamInstances.iterator().hasNext() )
-            return SUCCESS;
-        
-        programInstance = progamInstances.iterator().next();
-        
-        colorMap = programStageInstanceService.colorProgramStageInstances( programInstance.getProgramStageInstances() );
-        
-        // ---------------------------------------------------------------------
-        // Load ProgramStages
-        // ---------------------------------------------------------------------
-
-        programStages = selectedProgram.getProgramStages();
-        
-        // ---------------------------------------------------------------------
-        // Validate selected ProgramStage
-        // ---------------------------------------------------------------------
-
-        ProgramStage selectedProgramStage;
-
-        if ( programStageId != null )
-        {
-            selectedProgramStage = programStageService.getProgramStage( programStageId );
-        }
-        else
-        {
-            selectedProgramStage = selectedStateManager.getSelectedProgramStage();
-        }
-
-        if ( selectedProgramStage != null && programStages.contains( selectedProgramStage ) )
-        {
-            programStageId = selectedProgramStage.getId();
-            selectedStateManager.setSelectedProgramStage( selectedProgramStage );
-        }
-
-        else
-        {
-            programStageId = null;
-            selectedStateManager.clearSelectedProgramStage();
-
-            return SUCCESS;
-        }
-        
-        // ---------------------------------------------------------------------
-        // Load the programStageInstance we need the corresponding execution
-        // date
-        // ---------------------------------------------------------------------
-
-        ProgramInstance programInstance = progamInstances.iterator().next();
-        
-        programStageInstance = programStageInstanceService.getProgramStageInstance( programInstance,
-            selectedProgramStage );
-        
-        // ---------------------------------------------------------------------
-        // Check if there is custom DataEntryForm
-        // ---------------------------------------------------------------------
-
-        if ( selectedProgramStage.getDataEntryForm() != null )
-        {
-            customDataEntryFormExists = true;
-        }
-
-        if ( customDataEntryFormExists && useDefaultForm == null )
-        {
-            return CUSTOM_DATAENTRY_FORM;
-        }
-        
-        return DATAENTRY_FORM;
-
+            programs.add( program );
+        }
+
+        return SUCCESS;
     }
 }

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetSelectedOrgunitAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetSelectedOrgunitAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetSelectedOrgunitAction.java	2011-05-10 07:25:28 +0000
@@ -0,0 +1,77 @@
+/*
+ * 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.caseentry.action.caseentry;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ GetSelectedOrgunitAction.java May 7, 2011 12:39:43 PM $
+ * 
+ */
+public class GetSelectedOrgunitAction
+implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitSelectionManager selectionManager;
+
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+    {
+        this.selectionManager = selectionManager;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/output
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnit organisationUnit;
+
+    public OrganisationUnit getOrganisationUnit()
+    {
+        return organisationUnit;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        organisationUnit = selectionManager.getSelectedOrganisationUnit();
+        
+        return SUCCESS;
+    }
+}
+

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java	2011-05-10 07:25:28 +0000
@@ -0,0 +1,276 @@
+/*
+ * 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.caseentry.action.caseentry;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hisp.dhis.caseentry.screen.DataEntryScreenManager;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.minmax.MinMaxDataElement;
+import org.hisp.dhis.minmax.MinMaxDataElementService;
+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.patientdatavalue.PatientDataValue;
+import org.hisp.dhis.patientdatavalue.PatientDataValueService;
+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.ProgramStageDataElementService;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.program.ProgramStageService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ LoadCustomDataEntryAction.java May 7, 2011 2:37:44 PM $
+ * 
+ */
+public class LoadDataEntryAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramStageService programStageService;
+
+    private ProgramInstanceService programInstanceService;
+
+    private DataEntryScreenManager dataEntryScreenManager;
+
+    private PatientDataValueService patientDataValueService;
+
+    private ProgramStageInstanceService programStageInstanceService;
+
+    private PatientService patientService;
+
+    private MinMaxDataElementService minMaxDataElementService;
+
+    private OrganisationUnitSelectionManager selectionManager;
+
+    private ProgramStageDataElementService programStageDataElementService;
+
+    // -------------------------------------------------------------------------
+    // Input && Output
+    // -------------------------------------------------------------------------
+
+    private Integer programStageId;
+
+    private Integer patientId;
+
+    private Boolean useDefaultForm;
+
+    private ProgramStageInstance programStageInstance;
+
+    private String customDataEntryFormCode;
+
+    private I18n i18n;
+
+    private Collection<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>();
+
+    private Map<Integer, PatientDataValue> patientDataValueMap;
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
+    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+    {
+        this.programStageInstanceService = programStageInstanceService;
+    }
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
+    public void setMinMaxDataElementService( MinMaxDataElementService minMaxDataElementService )
+    {
+        this.minMaxDataElementService = minMaxDataElementService;
+    }
+
+    public void setProgramStageService( ProgramStageService programStageService )
+    {
+        this.programStageService = programStageService;
+    }
+
+    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+    {
+        this.programInstanceService = programInstanceService;
+    }
+
+    public void setDataEntryScreenManager( DataEntryScreenManager dataEntryScreenManager )
+    {
+        this.dataEntryScreenManager = dataEntryScreenManager;
+    }
+
+    public void setPatientDataValueService( PatientDataValueService patientDataValueService )
+    {
+        this.patientDataValueService = patientDataValueService;
+    }
+
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+    {
+        this.selectionManager = selectionManager;
+    }
+
+    public ProgramStageInstance getProgramStageInstance()
+    {
+        return programStageInstance;
+    }
+
+    public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService )
+    {
+        this.programStageDataElementService = programStageDataElementService;
+    }
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
+    }
+
+    public void setI18n( I18n i18n )
+    {
+        this.i18n = i18n;
+    }
+
+    public void setProgramStageId( Integer programStageId )
+    {
+        this.programStageId = programStageId;
+    }
+
+    public void setUseDefaultForm( Boolean useDefaultForm )
+    {
+        this.useDefaultForm = useDefaultForm;
+    }
+
+    public String getCustomDataEntryFormCode()
+    {
+        return customDataEntryFormCode;
+    }
+
+    public Collection<ProgramStageDataElement> getProgramStageDataElements()
+    {
+        return programStageDataElements;
+    }
+
+    public Map<Integer, PatientDataValue> getPatientDataValueMap()
+    {
+        return patientDataValueMap;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        // ---------------------------------------------------------------------
+        // Get program-stage-instance
+        // ---------------------------------------------------------------------
+
+        Patient patient = patientService.getPatient( patientId );
+
+        ProgramStage programStage = programStageService.getProgramStage( programStageId );
+
+        ProgramInstance programInstance = programInstanceService.getProgramInstances( patient,
+            programStage.getProgram(), false ).iterator().next();
+
+        OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
+
+        programStageDataElements = programStage.getProgramStageDataElements();
+        
+        Collection<DataElement> dataElements = programStageDataElementService.getListDataElement( programStage );
+
+        programStageInstance = programStageInstanceService.getProgramStageInstance( programInstance, programStage );
+
+        if ( programStageInstance != null )
+        {
+            // ---------------------------------------------------------------------
+            // Get data values
+            // ---------------------------------------------------------------------
+
+            Collection<PatientDataValue> patientDataValues = patientDataValueService
+                .getPatientDataValues( programStageInstance );
+
+            patientDataValueMap = new HashMap<Integer, PatientDataValue>( patientDataValues.size() );
+
+            for ( PatientDataValue patientDataValue : patientDataValues )
+            {
+                patientDataValueMap.put( patientDataValue.getDataElement().getId(), patientDataValue );
+            }
+
+            // ---------------------------------------------------------------------
+            // Get min/max data-elements
+            // ---------------------------------------------------------------------
+
+            Collection<MinMaxDataElement> minMaxDataElements = minMaxDataElementService.getMinMaxDataElements(
+                organisationUnit, dataElements );
+
+            Map<Integer, MinMaxDataElement> minMaxMap = new HashMap<Integer, MinMaxDataElement>( minMaxDataElements
+                .size() );
+
+            for ( MinMaxDataElement minMaxDataElement : minMaxDataElements )
+            {
+                minMaxMap.put( minMaxDataElement.getDataElement().getId(), minMaxDataElement );
+            }
+
+            // ---------------------------------------------------------------------
+            // Get data-entry-form
+            // ---------------------------------------------------------------------
+
+            DataEntryForm dataEntryForm = programStage.getDataEntryForm();
+
+            if ( useDefaultForm != null && !useDefaultForm )
+            {
+                customDataEntryFormCode = dataEntryScreenManager.populateCustomDataEntryScreenForMultiDimensional(
+                    dataEntryForm.getHtmlCode(), patientDataValues, minMaxMap, "", i18n, programStage,
+                    programStageInstance, organisationUnit );
+            }
+
+            return SUCCESS;
+        }
+
+        // customDataEntryFormCode =
+        // programStage.getDataEntryForm().getHtmlCode();
+
+        return SUCCESS;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStagesAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStagesAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStagesAction.java	2011-05-10 07:25:28 +0000
@@ -0,0 +1,145 @@
+/*
+ * 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.caseentry.action.caseentry;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+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 org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ LoadProgramStagesAction.java May 7, 2011 2:31:47 PM $
+ * 
+ */
+public class LoadProgramStagesAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PatientService patientService;
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    private ProgramInstanceService programInstanceService;
+
+    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+    {
+        this.programInstanceService = programInstanceService;
+    }
+
+    private ProgramStageInstanceService programStageInstanceService;
+
+    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+    {
+        this.programStageInstanceService = programStageInstanceService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input && Output
+    // -------------------------------------------------------------------------
+
+    private Integer patientId;
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
+    }
+
+    private Integer programId;
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    private ProgramInstance programInstance;
+
+    public ProgramInstance getProgramInstance()
+    {
+        return programInstance;
+    }
+
+    private Set<ProgramStage> programStages = new HashSet<ProgramStage>();
+
+    public Set<ProgramStage> getProgramStages()
+    {
+        return programStages;
+    }
+
+    private Map<Integer, String> colorMap = new HashMap<Integer, String>();
+
+    public Map<Integer, String> getColorMap()
+    {
+        return colorMap;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        Patient patient = patientService.getPatient( patientId );
+
+        Program program = programService.getProgram( programId );
+
+        programInstance = programInstanceService.getProgramInstances( patient, program, false ).iterator().next();
+
+        colorMap = programStageInstanceService.colorProgramStageInstances( programInstance.getProgramStageInstances() );
+
+        programStages = program.getProgramStages();
+
+        return SUCCESS;
+    }
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java	2011-05-01 09:07:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java	2011-05-10 07:25:28 +0000
@@ -33,22 +33,23 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 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.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.program.ProgramStageService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -66,11 +67,25 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private PatientService patientService;
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
+    private ProgramStageService programStageService;
+
+    public void setProgramStageService( ProgramStageService programStageService )
+    {
+        this.programStageService = programStageService;
     }
 
     private ProgramInstanceService programInstanceService;
@@ -164,6 +179,27 @@
         this.optionComboId = optionComboId;
     }
 
+    private Integer orgunitId;
+
+    public void setOrgunitId( Integer orgunitId )
+    {
+        this.orgunitId = orgunitId;
+    }
+
+    private Integer patientId;
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
+    }
+
+    private Integer programStageId;
+
+    public void setProgramStageId( Integer programStageId )
+    {
+        this.programStageId = programStageId;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -171,21 +207,27 @@
     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 );
+        // ---------------------------------------------------------------------
+        // Get program-stage-instance
+        // ---------------------------------------------------------------------
+
+        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgunitId );
+
+        Patient patient = patientService.getPatient( patientId );
+
+        ProgramStage programStage = programStageService.getProgramStage( programStageId );
+
+        Collection<ProgramInstance> progamInstances = programInstanceService.getProgramInstances( patient, programStage
+            .getProgram(), false );
 
         ProgramInstance programInstance = progamInstances.iterator().next();
 
         ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(
             programInstance, programStage );
+        
+        // ---------------------------------------------------------------------
+        // Save value
+        // ---------------------------------------------------------------------
 
         DataElement dataElement = dataElementService.getDataElement( dataElementId );
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java	2011-04-07 09:17:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java	2011-05-10 07:25:28 +0000
@@ -30,24 +30,21 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 
-import com.opensymphony.xwork2.Action;
-
 /**
  * @author Abyot Asalefew Gizaw
  * @version $Id$
  */
 public class SearchPatientAction
-    implements Action
+    extends ActionPagingSupport<Patient>
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -55,52 +52,48 @@
 
     private OrganisationUnitSelectionManager selectionManager;
 
+    private PatientService patientService;
+
+    private PatientAttributeService patientAttributeService;
+
+    private PatientAttributeValueService patientAttributeValueService;
+
+    // -------------------------------------------------------------------------
+    // Input/output
+    // -------------------------------------------------------------------------
+
+    private String searchText;
+
+    private boolean listAll;
+
+    private Integer searchingAttributeId;
+
+    private Collection<Patient> patients = new ArrayList<Patient>();
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
     public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
     {
         this.selectionManager = selectionManager;
     }
 
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
-    private PatientService patientService;
-
     public void setPatientService( PatientService patientService )
     {
         this.patientService = patientService;
     }
 
-    private PatientAttributeService patientAttributeService;
-
     public void setPatientAttributeService( PatientAttributeService patientAttributeService )
     {
         this.patientAttributeService = patientAttributeService;
     }
 
-    private PatientAttributeValueService patientAttributeValueService;
-
     public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
     {
         this.patientAttributeValueService = patientAttributeValueService;
     }
 
-    // -------------------------------------------------------------------------
-    // Input/output
-    // -------------------------------------------------------------------------
-
-    private OrganisationUnit organisationUnit;
-
-    public OrganisationUnit getOrganisationUnit()
-    {
-        return organisationUnit;
-    }
-
-    private String searchText;
-
     public void setSearchText( String searchText )
     {
         this.searchText = searchText;
@@ -111,18 +104,14 @@
         return searchText;
     }
 
-    private boolean listAll;
-
     public void setListAll( boolean listAll )
     {
         this.listAll = listAll;
     }
 
-    private Integer searchingAttributeId;
-
-    public Integer getSearchingAttributeId()
+    public Collection<Patient> getPatients()
     {
-        return searchingAttributeId;
+        return patients;
     }
 
     public void setSearchingAttributeId( Integer searchingAttributeId )
@@ -130,18 +119,11 @@
         this.searchingAttributeId = searchingAttributeId;
     }
 
-    private Collection<PatientAttribute> patientAttributes;
-
-    public Collection<PatientAttribute> getPatientAttributes()
-    {
-        return patientAttributes;
-    }
-
-    private Collection<Patient> patients = new ArrayList<Patient>();
-
-    public Collection<Patient> getPatients()
-    {
-        return patients;
+    private Integer total;
+
+    public Integer getTotal()
+    {
+        return total;
     }
 
     // -------------------------------------------------------------------------
@@ -151,90 +133,41 @@
     public String execute()
         throws Exception
     {
-        organisationUnit = selectionManager.getSelectedOrganisationUnit();
-
-        patientAttributes = patientAttributeService.getAllPatientAttributes();
-
-        if ( listAll )
-        {
-            selectedStateManager.setListAll( listAll );
-
-            selectedStateManager.clearSearchingAttributeId();
-            selectedStateManager.clearSearchTest();
-
-            patients = patientService.getPatients( organisationUnit );
-
-            searchText = "list_all_patients";
-
-            return SUCCESS;
-        }
-
-        if ( searchingAttributeId != null && searchText != null )
-        {
-            selectedStateManager.clearListAll();
-
-            selectedStateManager.setSearchingAttributeId( searchingAttributeId );
-            selectedStateManager.setSearchText( searchText );
-
-            PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( searchingAttributeId );
-
-            Collection<PatientAttributeValue> matching = patientAttributeValueService.searchPatientAttributeValue(
-                patientAttribute, searchText );
-
-            for ( PatientAttributeValue patientAttributeValue : matching )
-            {
-                patients.add( patientAttributeValue.getPatient() );
-            }
-
-            return SUCCESS;
-        }
-
-        if ( searchingAttributeId == null && searchText != null )
-        {
-            selectedStateManager.clearListAll();
-            selectedStateManager.clearSearchingAttributeId();
-
-            selectedStateManager.setSearchText( searchText );
-
-            patients = patientService.getPatientsByNames( searchText );
-
-            return SUCCESS;
-        }
-
-        listAll = selectedStateManager.getListAll();
-
-        if ( listAll )
-        {
-            patients = patientService.getPatients( organisationUnit );
-
-            searchText = "list_all_patients";
-
-            return SUCCESS;
-
-        }
-
-        searchingAttributeId = selectedStateManager.getSearchingAttributeId();
-        searchText = selectedStateManager.getSearchText();
-
-        if ( searchingAttributeId != null && searchText != null )
-        {
-
-            PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( searchingAttributeId );
-
-            Collection<PatientAttributeValue> matching = patientAttributeValueService.searchPatientAttributeValue(
-                patientAttribute, searchText );
-
-            for ( PatientAttributeValue patientAttributeValue : matching )
-            {
-                patients.add( patientAttributeValue.getPatient() );
-            }
-
-            return SUCCESS;
-        }
-
-        patients = patientService.getPatientsByNames( searchText );
+        OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
+
+        if ( listAll )
+        {
+            searchText = "list_all_patients";
+
+            total = patientService.countGetPatientsByOrgUnit( organisationUnit );
+            this.paging = createPaging( total );
+
+            patients = new ArrayList<Patient>( patientService.getPatients( organisationUnit, paging.getStartPos(),
+                paging.getPageSize() ) );
+
+            return SUCCESS;
+        }
+
+        if ( searchingAttributeId != null && searchText != null )
+        {
+            PatientAttribute searchingPatientAttribute = patientAttributeService
+                .getPatientAttribute( searchingAttributeId );
+
+            total = patientAttributeValueService.countSearchPatientAttributeValue( searchingPatientAttribute,
+                searchText );
+            this.paging = createPaging( total );
+
+            patients = patientAttributeValueService.searchPatients( searchingPatientAttribute, searchText, paging
+                .getStartPos(), paging.getPageSize() );
+
+            return SUCCESS;
+        }
+
+        total = patientService.countGetPatients( searchText );
+        this.paging = createPaging( total );
+
+        patients = patientService.getPatients( searchText, paging.getStartPos(), paging.getPageSize() );
 
         return SUCCESS;
-
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientFormAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientFormAction.java	2011-03-31 01:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientFormAction.java	2011-05-10 07:25:28 +0000
@@ -32,7 +32,6 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientAttributeService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -54,13 +53,6 @@
         this.selectionManager = selectionManager;
     }
 
-    private PatientAttributeService patientAttributeService;
-
-    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
-    {
-        this.patientAttributeService = patientAttributeService;
-    }
-
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -87,9 +79,7 @@
         throws Exception
     {
         organisationUnit = selectionManager.getSelectedOrganisationUnit();
-
-        patientAttributes = patientAttributeService.getAllPatientAttributes();
-
+        
         return SUCCESS;
     }
 }

=== modified 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	2011-05-01 09:07:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ValidateProgramInstanceAction.java	2011-05-10 07:25:28 +0000
@@ -38,7 +38,9 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 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;
@@ -48,6 +50,7 @@
 import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.program.ProgramStageService;
 import org.hisp.dhis.program.ProgramValidation;
 import org.hisp.dhis.program.ProgramValidationService;
 
@@ -74,10 +77,21 @@
 
     private ProgramValidationService programValidationService;
 
+    private OrganisationUnitService orgunitService;
+
+    private PatientService patientService;
+    
+    private ProgramStageService programStageService;
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
 
+    private Integer orgunitId;
+
+    private Integer patientId;
+
+    private Integer programStageId;
+    
     private I18n i18n;
 
     // -------------------------------------------------------------------------
@@ -97,6 +111,36 @@
         this.selectedStateManager = selectedStateManager;
     }
 
+    public void setOrgunitService( OrganisationUnitService orgunitService )
+    {
+        this.orgunitService = orgunitService;
+    }
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
+    public void setProgramStageService( ProgramStageService programStageService )
+    {
+        this.programStageService = programStageService;
+    }
+
+    public void setOrgunitId( Integer orgunitId )
+    {
+        this.orgunitId = orgunitId;
+    }
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
+    }
+
+    public void setProgramStageId( Integer programStageId )
+    {
+        this.programStageId = programStageId;
+    }
+
     public List<ProgramValidation> getProgramValidations()
     {
         return programValidations;
@@ -106,7 +150,7 @@
     {
         this.programValidationService = programValidationService;
     }
-    
+
     public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
     {
         this.programStageInstanceService = programStageInstanceService;
@@ -136,7 +180,8 @@
     {
         return selectedStateManager;
     }
-    
+
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -153,15 +198,16 @@
         // 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 );
+        OrganisationUnit organisationUnit = orgunitService.getOrganisationUnit( orgunitId );
+
+        Patient patient = patientService.getPatient( patientId );
+
+        ProgramStage programStage = programStageService.getProgramStage( programStageId );
+
+        Program program = programStage.getProgram();
+
+        Collection<ProgramInstance> progamInstances = programInstanceService.getProgramInstances( patient, program,
+            false );
 
         ProgramInstance programInstance = progamInstances.iterator().next();
 
@@ -171,13 +217,13 @@
         // ---------------------------------------------------------------------
         // Get selected objects
         // ---------------------------------------------------------------------
-        
+
         Set<ProgramStageDataElement> dataElements = programStage.getProgramStageDataElements();
 
         for ( ProgramStageDataElement psDataElement : dataElements )
         {
             DataElement dataElement = psDataElement.getDataElement();
-            
+
             checkDataElementInMultiStage( programStageInstance, organisationUnit, dataElement );
         }
 
@@ -185,7 +231,8 @@
         // Check validations for dataelement into multi-stages
         // ---------------------------------------------------------------------
 
-        runProgramValidation( programValidationService.getProgramValidation( programInstance.getProgram() ), programInstance );
+        runProgramValidation( programValidationService.getProgramValidation( programInstance.getProgram() ),
+            programInstance );
 
         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	2011-04-29 07:41:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2011-05-10 07:25:28 +0000
@@ -33,16 +33,24 @@
 		scope="prototype">
 		<property name="selectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
 
-	<bean
+	<!-- <bean
 		id="org.hisp.dhis.caseentry.action.caseentry.SearchPatientFormAction"
 		class="org.hisp.dhis.caseentry.action.caseentry.SearchPatientFormAction"
 		scope="prototype">
 		<property name="selectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		<property name="patientAttributeService"
-			ref="org.hisp.dhis.patient.PatientAttributeService" />
+	</bean> -->
+	
+	<bean
+		id="org.hisp.dhis.caseentry.action.caseentry.GetSelectedOrgunitAction"
+		class="org.hisp.dhis.caseentry.action.caseentry.GetSelectedOrgunitAction"
+		scope="prototype">
+		<property name="selectionManager"
+			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.caseentry.ValidateSearchAction"
@@ -57,8 +65,6 @@
 		scope="prototype">
 		<property name="selectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		<property name="selectedStateManager"
-			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
@@ -70,14 +76,7 @@
 		id="org.hisp.dhis.caseentry.action.caseentry.DataRecordingSelectAction"
 		class="org.hisp.dhis.caseentry.action.caseentry.DataRecordingSelectAction"
 		scope="prototype">
-		<property name="selectedStateManager"
-			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
-		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
-		<property name="programStageInstanceService"
-			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
 
 	<bean
@@ -88,25 +87,15 @@
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
 
-	<bean id="org.hisp.dhis.caseentry.action.caseentry.DataEntryAction"
-		class="org.hisp.dhis.caseentry.action.caseentry.DataEntryAction"
-		scope="prototype">
-		<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="selectedStateManager"
-			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
-		<property name="programStageDataElementService"
-			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
-	</bean>
-
 	<bean id="org.hisp.dhis.caseentry.action.caseentry.SaveValueAction"
 		class="org.hisp.dhis.caseentry.action.caseentry.SaveValueAction"
 		scope="prototype">
-		<property name="selectedStateManager"
-			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+		<property name="organisationUnitService"
+			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<property name="patientService"
+			ref="org.hisp.dhis.patient.PatientService" />
+		<property name="programStageService"
+			ref="org.hisp.dhis.program.ProgramStageService" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="dataElementCategoryService"
 			ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
@@ -160,27 +149,36 @@
 		<property name="programStageDataElementService"
 			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 	</bean>
+	
+	<bean id="org.hisp.dhis.caseentry.action.caseentry.LoadProgramStagesAction"
+		class="org.hisp.dhis.caseentry.action.caseentry.LoadProgramStagesAction"
+		scope="prototype">
+		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+		<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" />
+	</bean>
 
-	<bean id="org.hisp.dhis.caseentry.action.caseentry.CustomDataEntryAction"
-		class="org.hisp.dhis.caseentry.action.caseentry.CustomDataEntryAction"
+	<bean id="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction"
+		class="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction"
 		scope="prototype">
-		<property name="minMaxDataElementService"
-			ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 		<property name="dataEntryScreenManager"
 			ref="org.hisp.dhis.caseentry.screen.DataEntryScreenManager" />
-		<property name="selectedStateManager"
-			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 		<property name="patientDataValueService"
 			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
-		<property name="patientIdentifierService"
-			ref="org.hisp.dhis.patient.PatientIdentifierService" />
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
-		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+			<property name="minMaxDataElementService"
+			ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
+		<property name="selectionManager"
+			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+		<property name="programStageDataElementService"
+			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 	</bean>
-
+	
 	<bean
 		id="org.hisp.dhis.caseentry.action.caseentry.CompleteDataEntryAction"
 		class="org.hisp.dhis.caseentry.action.caseentry.CompleteDataEntryAction"
@@ -403,6 +401,12 @@
 			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
 		<property name="programValidationService"
 			ref="org.hisp.dhis.program.ProgramValidationService" />
+		<property name="orgunitService"
+			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<property name="patientService"
+			ref="org.hisp.dhis.patient.PatientService" />
+		<property name="programStageService"
+			ref="org.hisp.dhis.program.ProgramStageService" />
 	</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-29 07:41:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2011-05-10 07:25:28 +0000
@@ -306,4 +306,5 @@
 validation_result												= Validation Result
 should															= should
 validation														= Validation
-program_validation_description									= Program Validation Description
\ No newline at end of file
+program_validation_description									= Program Validation Description
+please_select_village											= Please select village
\ 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-04-29 07:41:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-05-10 07:25:28 +0000
@@ -21,19 +21,14 @@
     
     <action name="dataEntrySelect" class="org.hisp.dhis.caseentry.action.caseentry.DataEntrySelectAction">
       <interceptor-ref name="organisationUnitTreeStack"/>
-      <result name="searchform" type="chain">searchform</result>
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-caseentry/select.vm</param>
       <param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>   
       <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/dataEntry.js, ../dhis-web-commons/javascripts/date.js</param>      
-    </action>   
+    </action>
     
-    <action name="searchform" class="org.hisp.dhis.caseentry.action.caseentry.SearchPatientFormAction">
-      <interceptor-ref name="organisationUnitTreeStack"/>
-      <result name="success" type="velocity">/main.vm</result>
-      <param name="page">/dhis-web-caseentry/search.vm</param>
-      <param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>      
-      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/dataEntry.js, ../dhis-web-commons/javascripts/date.js</param>            
+    <action name="searchform" class="org.hisp.dhis.caseentry.action.caseentry.GetSelectedOrgunitAction">
+     <result name="success" type="velocity-xml">/dhis-web-caseentry/responseOrgUnit.vm</result>
     </action>   
     
     <action name="validateSearch"
@@ -45,35 +40,39 @@
     </action>
     
     <action name="searchPatient" class="org.hisp.dhis.caseentry.action.caseentry.SearchPatientAction">
-      <interceptor-ref name="organisationUnitTreeStack"/>
-      <result name="success" type="velocity">/main.vm</result>
+      <result name="success" type="velocity">/content.vm</result>
       <param name="page">/dhis-web-caseentry/listPatient.vm</param>
-      <param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>    
-      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/dataEntry.js, ../dhis-web-commons/javascripts/date.js</param>            
+      <param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>     
+      <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>     
     </action>
     
     <action name="listAllPatients" class="org.hisp.dhis.caseentry.action.caseentry.SearchPatientAction">
-      <interceptor-ref name="organisationUnitTreeStack"/>
-      <result name="success" type="velocity">/main.vm</result>
+      <result name="success" type="velocity">/content.vm</result>
       <param name="listAll">true</param>
       <param name="page">/dhis-web-caseentry/listPatient.vm</param>
-      <param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>      
-      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/dataEntry.js, ../dhis-web-commons/javascripts/date.js</param>            
+      <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
     </action>   
     
     <action name="selectDataRecording" class="org.hisp.dhis.caseentry.action.caseentry.DataRecordingSelectAction">
-      <interceptor-ref name="organisationUnitTreeStack"/>
-      <result name="dataentryform" type="chain">dataentryform</result>
-      <result name="customentryform" type="chain">customentryform</result>
-      <result name="success" type="velocity">/main.vm</result>
+      <result name="success" type="velocity">/content.vm</result>
       <param name="page">/dhis-web-caseentry/dataRecordingSelect.vm</param>
-      <param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>      
-      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/dataEntry.js, ../dhis-web-commons/javascripts/date.js</param>
-      <param name="stylesheets">style/patient.css</param>            
-    </action>    
+      <param name="stylesheets">style/patient.css</param>
+    </action>
+    
+    <action name="loadProgramStages" class="org.hisp.dhis.caseentry.action.caseentry.LoadProgramStagesAction">
+      <result name="success" type="velocity-json">/dhis-web-caseentry/responseProgramStages.vm</result>
+      <param name="stylesheets">style/patient.css</param>
+    </action>
+    
+    <action name="dataentryform" class="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction">
+      <result name="success" type="velocity">/content.vm</result>
+      <param name="page">/dhis-web-caseentry/dataEntryForm.vm</param>
+      <param name="javascripts">javascript/customcheckbox/prettyCheckboxes.js</param>
+      <param name="stylesheets">style/patient.css,javascript/customcheckbox/prettyCheckboxes.css</param>
+    </action>
     
     <action name="completeDataEntry" class="org.hisp.dhis.caseentry.action.caseentry.CompleteDataEntryAction">
-        <result name="success" type="chain">selectDataRecording</result>
+        <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
     </action>
     
     <action name="saveExecutionDate" class="org.hisp.dhis.caseentry.action.caseentry.SaveExecutionDateAction">
@@ -81,14 +80,6 @@
       <param name="onExceptionReturn">plainTextError</param>      
     </action>  
     
-    <action name="dataentryform" class="org.hisp.dhis.caseentry.action.caseentry.DataEntryAction">
-      <result name="success" type="velocity">/main.vm</result>
-      <param name="page">/dhis-web-caseentry/dataEntryForm.vm</param>
-      <param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>      
-      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/dataEntry.js, ../dhis-web-commons/javascripts/date.js</param>
-      <param name="stylesheets">style/patient.css</param>
-    </action>
-    
     <!-- save value -->
     
     <action name="saveValue" class="org.hisp.dhis.caseentry.action.caseentry.SaveValueAction">
@@ -120,16 +111,9 @@
       <result name="success" type="velocity-xml">/dhis-web-caseentry/responsePatient.vm</result>
       <param name="onExceptionReturn">plainTextError</param>      
     </action>    
-    
-    <action name="customentryform" class="org.hisp.dhis.caseentry.action.caseentry.CustomDataEntryAction">
-      <result name="success" type="velocity">/main.vm</result>
-      <param name="page">/dhis-web-caseentry/dataEntryForm.vm</param>
-       <param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>    
-      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/dataEntry.js,javascript/customcheckbox/prettyCheckboxes.js, ../dhis-web-commons/javascripts/date.js</param>
-      <param name="stylesheets">style/patient.css,javascript/customcheckbox/prettyCheckboxes.css</param>
-    </action>
 
 	<!-- Multi DataEntry -->
+	
     <action name="multipledataEntrySelect" class="org.hisp.dhis.caseentry.action.caseentry.MultiDataEntrySelectAction">
       <interceptor-ref name="organisationUnitTreeStack"/>  
       <result name="success" type="velocity">/main.vm</result>     

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2011-03-31 05:38:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2011-05-10 07:25:28 +0000
@@ -1,138 +1,117 @@
-<script type="text/javascript">  
-    var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
-	var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
-	var i18n_value_must_positive_number = '$encoder.jsEscape( $i18n.getString( "value_must_positive_number" ) , "'")';
-	var i18n_value_must_negative_number = '$encoder.jsEscape( $i18n.getString( "value_must_negative_number" ) , "'")';
-    var i18n_invalid_date =   '$encoder.jsEscape( $i18n.getString( "invalid_date" ) , "'")' + ".\n " 
-							+ '$encoder.jsEscape( $i18n.getString( "format_date" ) , "'")' + " '" 
-							+ dateFormat.replace('yy', 'yyyy') + " '" ; 
-    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_complete_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_confirm_message" ) , "'")';
-    var i18n_error_required_field = '$encoder.jsEscape( $i18n.getString( "error_required_field" ) , "'")';
-	var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
-	var i18n_date_less_incident_date = '$encoder.jsEscape( $i18n.getString( "date_less_incident_date" ) , "'")';
-</script>
-
-#parse( "/dhis-web-caseentry/dataRecordingSelect.vm" )
 
 <div id="dragDiv">
 	<table id="listInfo">
-		<tr><td style="text-align:left"><strong>$i18n.getString("org_unit_name") :</strong></td> <td id="orgUnitName" style="text-align:right"></td></tr>
+		<tr><td style="text-align:left"><strong>$i18n.getString("org_unit_name") :</strong></td> <td id="orgUnitNameField" style="text-align:right"></td></tr>
 		<tr><td style="text-align:left"><strong>$i18n.getString("program_stage_name") :</strong></td> <td  id="programStageName" style="text-align:right"></td></tr>
 		<tr><td style="text-align:left"><strong>$i18n.getString("datae_element_name") :</strong></td> <td id="dataelementName" style="text-align:right"></td></tr>
 	</table>
 </div>
 
-<span id="startMsg" style="font-style:italic; color:blue"> $i18n.getString( "report_date_warning" )
-</span>
-
-<div id="entryFormContainer" >
-
-#if ( $!customDataEntryFormCode  && !$useDefaultForm )
+
+
+
 <div id="customEntryScreenContainer">
-	    #if( $customDataEntryFormCode ) 
-	       $customDataEntryFormCode
-	    #else <span style="font-style:italic; color:blue"> $i18n.getString( "no_custom_data_entry_exist" )
-	    #end
-</span> 
-</div>
-<script>
+	#if( $customDataEntryFormCode ) 
+	   $customDataEntryFormCode
+	#else <span style="font-style:italic; color:blue"> $i18n.getString( "no_custom_data_entry_exist" )</span>
+	#end
+</div>
+
+<div id="defaultEntryScreenContainer">
+	<table class="mainPageTable">
+		<col id="noCol">
+		<col id="deCol">    
+		<col id="entryCol">
+		<col id="facilityCol">       
+		<tr>
+			<th>$i18n.getString( "nr" )</th>
+			<th>$i18n.getString( "data_element" )</th>                   
+			<th>$i18n.getString( "entry" )</th>
+			<th>$i18n.getString( "facility_provided_data" )</th>             
+		</tr>
+		#set( $dataElementRowCount = 0 )
+		#set( $mark = 0 )
+		#set( $tabIndex = 1 )
+		#foreach( $programStageDataElement in $programStageDataElements )
+			#set( $dataElementRowCount = $dataElementRowCount + 1 )    
+			#if( $mark == 1 )
+				#set( $mark = 0 )
+			#else
+				#set( $mark = 1 )
+			#end    
+			#set( $patientDataValue = false )
+			#set( $patientDataValue = $patientDataValueMap.get( $programStageDataElement.dataElement.id ) )    
+			<tr #if( $mark == 0 ) style="background-color:#dddddd" #end>
+				##dataElementRowCount
+				<td style="text-align:right">$dataElementRowCount</td>        
+				##data element name
+				<td>
+					<span id="value[$programStageDataElement.dataElement.id].name" title="$!encoder.htmlEncode( $programStageDataElement.dataElement.description )">
+						$encoder.htmlEncode( $programStageDataElement.dataElement.name ) 
+						#if ( $programStageDataElement.compulsory )
+							<em title="$i18n.getString( "required" )" class="required">*</em>
+						#end        
+					</span>
+				</td>        
+				##type        
+				<td style="display:none"><span id="value[$programStageDataElement.dataElement.id].type" style="display:none">$encoder.htmlEncode( $programStageDataElement.dataElement.getDetailedNumberType() )</span></td>       
+				##entry        
+				<td>        
+					#if( $programStageDataElement.dataElement.type == "bool" )
+						<select name="entryselect" #if($programStageInstance.completed) disabled="disabled" #end data="{compulsory: $programStageDataElement.compulsory }" id="value[$programStageDataElement.dataElement.id].boolean" onchange="saveChoice( $programStageDataElement.dataElement.id, this )"  tabindex="$tabIndex">              
+							<option value="">[$i18n.getString( "select_value" )]</option>
+							<option value="true" #if( $patientDataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
+							<option value="false" #if( $patientDataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>
+						</select>                              
+					#elseif( $programStageDataElement.dataElement.type == "string" && $programStageDataElement.dataElement.isMultiDimensional() )
+						#set( $optionValues = $optionMap.get( $programStageDataElement.dataElement.id ) )
+						<select name="entryselect" data="{compulsory: $programStageDataElement.compulsory }" #if($programStageInstance.completed) disabled="disabled" #end id="value[$programStageDataElement.dataElement.id].value" onchange="saveChoice( $programStageDataElement.dataElement.id, this )" tabindex="$tabIndex">              
+							<option value="">[$i18n.getString( "no_value" )]</option>
+							#foreach( $optionValue in $optionValues )
+								<option value="$optionValue.id" #if( $patientDataValue.value == $optionValue.id ) selected="selected" #end>$encoder.htmlEncode( $optionValue.name )</option>
+							#end
+						</select>
+					#elseif( $programStageDataElement.dataElement.type == "date" ) 
+						<input type="text" data="{compulsory: $programStageDataElement.compulsory }" #if($programStageInstance.completed) disabled="disabled" #end id="value[$programStageDataElement.dataElement.id].date" name="entryfield" value="$!encoder.htmlEncode($patientDataValue.value)" onchange="saveDateValue( $programStageDataElement.dataElement.id, '$encoder.jsEncode( $programStageDataElement.dataElement.name )' )" tabindex="$tabIndex" >
+							<script type="text/javascript">
+								datePicker('value\\[$programStageDataElement.dataElement.id\\]\\.date', false);
+							</script>  					
+					#else
+						<input name="entryfield" data="{compulsory: $programStageDataElement.compulsory }" #if($programStageInstance.completed) disabled="disabled" #end id="value[$programStageDataElement.dataElement.id].value" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onchange="saveValue( $programStageDataElement.dataElement.id, '$encoder.jsEncode( $programStageDataElement.dataElement.name )' )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
+					#end
+				</td>   
+				##providedByAnotherFacility                
+				<td>     
+					#if ( $patientDataValue.value )        
+						#if( !$patientDataValue.providedByAnotherFacility )
+							$patientDataValue.organisationUnit.name
+							<input  name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="hidden" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
+						#else
+							$i18n.getString("other_facility")
+							<input  name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="hidden" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
+						#end
+					 #else
+						<input name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="checkbox" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
+					 #end                         
+				</td>    
+			</tr>
+			#set( $tabIndex = $tabIndex + 1 )
+		#end
+	</table>
+
+</div>
+
+<script type="text/javascript">  
+	
+	setFieldValue('orgUnitNameField', getFieldValue('orgunitName') );
+	setFieldValue('programStageName', '$programStageInstance.programStage.name' );
+	setFieldValue('programStageInstanceId', '$programStageInstance.id' );
+	setFieldValue('programStageInstanceName', '$programStageInstance.name' );
+	setFieldValue('incidentDate', '$!format.formatDate($programStageInstance.programInstance.dateOfIncident)' );
+	setFieldValue('dueDate', '$!format.formatDate( $programStageInstance.dueDate )' );
+	setFieldValue('executionDate', '$!format.formatDate( $programStageInstance.executionDate )' );
+	
 	initCustomCheckboxes();
 	DRAG_DIV.init();
-</script>
-#else
-
-<table class="mainPageTable">
-    <col id="noCol">
-    <col id="deCol">    
-    <col id="entryCol">
-    <col id="facilityCol">       
-    <tr>
-        <th>$i18n.getString( "nr" )</th>
-        <th>$i18n.getString( "data_element" )</th>                   
-        <th>$i18n.getString( "entry" )</th>
-        <th>$i18n.getString( "facility_provided_data" )</th>             
-    </tr>
-#set( $dataElementRowCount = 0 )
-#set( $mark = 0 )
-#set( $tabIndex = 1 )
-#foreach( $programStageDataElement in $programStageDataElements )
-    #set( $dataElementRowCount = $dataElementRowCount + 1 )    
-    #if( $mark == 1 )
-        #set( $mark = 0 )
-    #else
-        #set( $mark = 1 )
-    #end    
-    #set( $patientDataValue = false )
-    #set( $patientDataValue = $patientDataValueMap.get( $programStageDataElement.dataElement.id ) )    
-    <tr #if( $mark == 0 ) style="background-color:#dddddd" #end>
-        ##dataElementRowCount
-        <td style="text-align:right">$dataElementRowCount</td>        
-        ##data element name
-        <td>
-            <span id="value[$programStageDataElement.dataElement.id].name" title="$!encoder.htmlEncode( $programStageDataElement.dataElement.description )">
-                $encoder.htmlEncode( $programStageDataElement.dataElement.name ) 
-                #if ( $programStageDataElement.compulsory )
-                	<em title="$i18n.getString( "required" )" class="required">*</em>
-                #end        
-            </span>
-        </td>        
-        ##type        
-        <td style="display:none"><span id="value[$programStageDataElement.dataElement.id].type" style="display:none">$encoder.htmlEncode( $programStageDataElement.dataElement.getDetailedNumberType() )</span></td>       
-        ##entry        
-        <td>        
-            #if( $programStageDataElement.dataElement.type == "bool" )
-                <select name="entryselect" #if($programStageInstance.completed) disabled="disabled" #end data="{compulsory: $programStageDataElement.compulsory }" id="value[$programStageDataElement.dataElement.id].boolean" onchange="saveChoice( $programStageDataElement.dataElement.id, this )"  tabindex="$tabIndex">              
-                    <option value="">[$i18n.getString( "select_value" )]</option>
-                    <option value="true" #if( $patientDataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
-                    <option value="false" #if( $patientDataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>
-                </select>                              
-            #elseif( $programStageDataElement.dataElement.type == "string" && $programStageDataElement.dataElement.isMultiDimensional() )
-                #set( $optionValues = $optionMap.get( $programStageDataElement.dataElement.id ) )
-                <select name="entryselect" data="{compulsory: $programStageDataElement.compulsory }" #if($programStageInstance.completed) disabled="disabled" #end id="value[$programStageDataElement.dataElement.id].value" onchange="saveChoice( $programStageDataElement.dataElement.id, this )" tabindex="$tabIndex">              
-                    <option value="">[$i18n.getString( "no_value" )]</option>
-                    #foreach( $optionValue in $optionValues )
-                        <option value="$optionValue.id" #if( $patientDataValue.value == $optionValue.id ) selected="selected" #end>$encoder.htmlEncode( $optionValue.name )</option>
-                    #end
-                </select>
-            #elseif( $programStageDataElement.dataElement.type == "date" ) 
-                <input type="text" data="{compulsory: $programStageDataElement.compulsory }" #if($programStageInstance.completed) disabled="disabled" #end id="value[$programStageDataElement.dataElement.id].date" name="entryfield" value="$!encoder.htmlEncode($patientDataValue.value)" onchange="saveDateValue( $programStageDataElement.dataElement.id, '$encoder.jsEncode( $programStageDataElement.dataElement.name )' )" tabindex="$tabIndex" >
-                    <script type="text/javascript">
-						datePicker('value\\[$programStageDataElement.dataElement.id\\]\\.date', false);
-                    </script>  					
-            #else
-                <input name="entryfield" data="{compulsory: $programStageDataElement.compulsory }" #if($programStageInstance.completed) disabled="disabled" #end id="value[$programStageDataElement.dataElement.id].value" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onchange="saveValue( $programStageDataElement.dataElement.id, '$encoder.jsEncode( $programStageDataElement.dataElement.name )' )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
-            #end
-        </td>   
-        ##providedByAnotherFacility                
-        <td>     
-        	#if ( $patientDataValue.value )        
-	            #if( !$patientDataValue.providedByAnotherFacility )
-	            	$patientDataValue.organisationUnit.name
-	            	<input  name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="hidden" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
-	            #else
-	            	$i18n.getString("other_facility")
-	            	<input  name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="hidden" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
-	            #end
-	         #else
-	           	<input name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="checkbox" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
-	         #end                         
-        </td>    
-    </tr>
-    #set( $tabIndex = $tabIndex + 1 )
-#end
-</table>
-#end
-
-</div>
-<div id="completeDataEntryFormContainer">
-<form id="completeDataEntryForm" name="completeDataEntry" method="post" action="completeDataEntry.action"> 
-	<input type="hidden" name="id" value="$id"/>
-	<input type="hidden" name="programId" value="$programId"/>
-	<input type="hidden" name="programStageId" value="$programStageId"/>
-	<input type="hidden" name="programStageInstanceId" value="$programStageInstanceId"/>
-</form>
-</div>
-</div>
+	
+</script>
\ No newline at end of file

=== 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-29 07:41:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm	2011-05-10 07:25:28 +0000
@@ -1,10 +1,7 @@
 <div>
-    <input type="button" value="$i18n.getString( "back_to_search" )" onclick="window.location.href='searchPatient.action'" style="width:10em">
+    <input type="button" value="$i18n.getString( 'back_to_search' )" onclick="javascript:showSearchForm();" style="width:10em">
 </div>
    
-<input type="hidden" id="id" name="id" value="$patient.id">        
-<form id="selectRecordingForm" name="selectRecordingForm" method="post" action="selectDataRecording.action?id=$patient.id">
-
 <table class="mainPageTable"> 
     <tr>            
         <td>
@@ -14,38 +11,18 @@
             <strong>$i18n.getString( "age" ):</strong>$encoder.htmlEncode( $patient.getAge() )
         </td>
         <td style="vertical-align:top">
-            #if( $programInstance )
-                <div id="currentSelection" style="float:right">
-                    <h4>$i18n.getString( "program_stages_history_plan" )</h4>
-                    <table>                        
-                        #foreach( $stageInstance in $programInstance.programStageInstances )
-                            <tr>
-                                <td>
-                                    <strong>$encoder.htmlEncode( $stageInstance.programStage.name ):</strong>
-                                </td>
-                                <td style="text-align:center" bgcolor="$colorMap.get( $stageInstance.id )">                                                           
-                                    #if( $stageInstance.completed )
-                                        $i18n.getString( "completed_on" )$format.formatDate( $stageInstance.executionDate )
-                                    #else
-                                        $i18n.getString( "scheduled_for" )$format.formatDate( $stageInstance.dueDate )
-                                    #end
-                               </td>
-                            </tr>                            
-                        #end
-                    </table>     
-                </div>
-            #end
+			<div id="currentSelection" style="float:right"></div>
         </td>
     </tr>                    
 </table>
 
 <hr style="clear:both">
 
-<table>    
+<table> 
    <tr>
         <td><label for="programId">$i18n.getString( "program" )</label></td>
         <td>
-            <select id="programId" name="programId" style="min-width:350px" onchange="document.getElementById( 'selectRecordingForm' ).submit();" #if( $programs.size() == 0 ) disabled="disabled" #end>
+            <select id="programId" name="programId" style="min-width:350px" onchange="loadProgramStages();" #if( $programs.size() == 0 ) disabled="disabled" #end>
                 <option value="0">[$i18n.getString( "select" )]</option>
                 #foreach( $program in $programs )
                     <option value="$program.id" #if( $programId && $program.id == $programId ) selected="selected" #end>$encoder.htmlEncode( $program.name )</option>
@@ -57,49 +34,48 @@
     <tr>
         <td><label for="programStageId">$i18n.getString( "program_stage" )</label></td>
         <td>
-            <select id="programStageId" name="programStageId" style="min-width:350px" onchange="document.getElementById( 'selectRecordingForm' ).submit();" #if( $programStages.size() == 0 ) disabled="disabled" #end>
-                <option value="0">[$i18n.getString( "select" )]</option>
-                #foreach( $programStage in $programStages )
-                    <option value="$programStage.id" #if( $programStageId && $programStage.id == $programStageId ) selected="selected" #end>$encoder.htmlEncode( $programStage.name )</option>
-                #end
+            <select id="programStageId" name="programStageId" style="min-width:350px" onchange="javascript:loadDataEntry();" >
             </select>
         </td>
-        #if( $programStageInstance )
-			<input type='hidden' id='incidentDate' name='incidentDate' value='$!format.formatDate($programStageInstance.programInstance.dateOfIncident)'/>
-			<td>&nbsp;</td>
-            <td><label for="dueDate">$i18n.getString( "due_date" ) </label></td>
-            <td>
-            	<input type="text" id="dueDate" name="dueDate" value="$!format.formatDate( $programStageInstance.dueDate )" disabled="disabled"/>
-            </td>
-            <td>&nbsp;</td>
-            <td><label for="executionDate">$i18n.getString( "report_date" ) </label></td>
-            <td>
-            	<input type="text" id="executionDate" name="executionDate" value="$!format.formatDate( $programStageInstance.executionDate )" onchange="saveExecutionDate( $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" />
-            </td>
-			<script type="text/javascript">
-				datePickerValid('executionDate', false);
-            </script>
-        #end
+		<td>&nbsp;</td>
+		<td>
+			<label for="dueDate">$i18n.getString( "due_date" ) </label>
+		</td>
+		<td>
+			<input type="text" id="dueDate" name="dueDate" disabled="disabled"/>
+		</td>
+		<td>&nbsp;</td>
+		<td>
+			<label for="executionDate">$i18n.getString( "report_date" ) </label>
+		</td>
+		<td>
+			<input type="text" id="executionDate" name="executionDate" onchange="saveExecutionDate( getFieldValue('programStageInstanceId'), getFieldValue('programStageInstanceName') );" disabled="disabled"/>
+		</td>
+		<script type="text/javascript">
+			datePickerValid('executionDate', false);
+		</script>
     </tr>   
 	<tr>
 		<td>
-			<input type="button" id="completeBtn" value="$i18n.getString('complete')" onClick="doComplete()" style="width:12em">
+			<input type="button" id="completeBtn" value="$i18n.getString('complete')" onClick="doComplete()" style="width:12em" disabled="disabled" >
 		</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">
+			<input type="button" id="validationBtn" value="$i18n.getString('validation')" onClick="javascript: runValidation();", '_blank', 'width=800, height=400, scrollbars=yes, resizable=yes' );" style="width:12em " disabled="disabled" >
 		</td>
 	</tr>
 </table>
-
-<div id="actions" style="float:right">
-	<input type="checkbox" id="useDefaultForm" name="useDefaultForm"
-		#if( $useDefaultForm  ) 
-			checked="checked" 
-		#end 
-		onchange="selectDefaultForm();"/>
+<p align='right'>
+	<input type="checkbox" id="useDefaultForm" name="useDefaultForm" value="true" onclick="selectUseDefaultDataEntryForm();" disabled="disabled" />
 	<label>$i18n.getString( "use_default_form" )</label><br>	
-</div>
-
-</form>
+	
+	<input type="checkbox" id="useCustomForm" name="useCustomForm" checked onclick="selectUseCustomDataEntryForm();" disabled="disabled" />
+	<label>$i18n.getString( "use_custom_form" )</label><br>	
+</p>
 
 <hr style="clear:both">
+
+<span id="startMsg" style="font-style:italic; color:blue"> </span>
+
+<script type="text/javascript">  
+	setFieldValue('patientId', '$patient.id');
+</script>

=== 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-29 07:41:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js	2011-05-10 07:25:28 +0000
@@ -1,3 +1,209 @@
+
+function organisationUnitSelected( orgUnits )
+{
+	showLoader();
+	setInnerHTML( 'contentDiv', '' );
+	hideById('dataEntryFormDiv');
+	hideById('dataRecordingSelectDiv');
+	showById('searchPatientDiv');
+			
+	jQuery.post("searchform.action",
+		{
+		},
+		function (data)
+		{
+			enable('listPatientBtn');
+			enable('searchingAttributeId');
+			enable('searchBtn');
+			jQuery('#searchText').removeAttr( 'readonly' );
+			
+			setFieldValue( 'orgunitName', data.getElementsByTagName( "name" )[0].firstChild.nodeValue );
+			
+			hideLoader();
+		},'xml');
+}
+
+selection.setListenerFunction( organisationUnitSelected );
+
+//--------------------------------------------------------------------------------------------
+// Show search-form
+//--------------------------------------------------------------------------------------------
+
+function showSearchForm()
+{
+	hideById('dataRecordingSelectDiv');
+	hideById('dataEntryFormDiv');
+	showById('searchPatientDiv');
+	showById('contentDiv');
+}
+
+//--------------------------------------------------------------------------------------------
+// Show all patients in select orgunit
+//--------------------------------------------------------------------------------------------
+
+isAjax = true;
+function listAllPatient()
+{
+	jQuery('#contentDiv').load( 'listAllPatients.action',
+		function()
+		{
+			hideById('dataRecordingSelectDiv');
+			hideById('dataEntryFormDiv');
+			showById('searchPatientDiv');
+			hideLoader();
+		});
+}
+
+//--------------------------------------------------------------------------------------------
+// Show selected data-recording
+//--------------------------------------------------------------------------------------------
+
+function showSelectedDataRecoding( patientId )
+{
+	showLoader();
+	hideById('searchPatientDiv');
+	hideById('dataEntryFormDiv');
+	jQuery('#dataRecordingSelectDiv').load( 'selectDataRecording.action', 
+		{
+			patientId: patientId
+		},
+		function()
+		{
+			showById('dataRecordingSelectDiv');
+			hideLoader();
+			hideById('contentDiv');
+		});
+}
+
+//--------------------------------------------------------------------------------------------
+// Load program-stages by the selected program
+//--------------------------------------------------------------------------------------------
+
+function loadProgramStages()
+{
+	if ( getFieldValue('programId') )
+	{
+		
+	}
+	jQuery.postJSON( "loadProgramStages.action",
+		{
+			patientId: getFieldValue('patientId'),
+			programId: getFieldValue('programId')
+		}, 
+		function( json ) 
+		{    
+			addOptionById( 'programStageId', "0", i18n_select );
+			for ( i in json.programStages ) 
+			{
+				addOptionById( 'programStageId', json.programStages[i].id, json.programStages[i].name );
+			} 
+			
+			// show history / plan
+			var history = '<h4>' + i18n_program_stages_history_plan + '</h4>';
+			history += '<table>'
+			for ( i in json.programStageInstances ) 
+			{
+				history += '<tr>';
+                history += '<td>';
+                history += '<strong>' + json.programStageInstances[i].name + '</strong>';
+				history += '</td>';
+                history += '<td style="text-align:center" bgcolor=' + json.programStageInstances[i].colorMap + '>'                                                         
+                history += json.programStageInstances[i].infor;
+                history += '</td>';
+                history += '</tr>';
+			}
+			history += '</table>';
+			setInnerHTML( 'currentSelection', history ); 
+	});
+}
+
+//--------------------------------------------------------------------------------------------
+// Load data-entry-form
+//--------------------------------------------------------------------------------------------
+
+function loadDataEntry()
+{
+	if( getFieldValue('programStageId') == '0' )
+	{
+		disable('listPatientBtn');
+		disable('searchingAttributeId');
+		jQuery('#searchText').removeAttr( 'readonly' );
+		disable('searchBtn');
+			
+		return;
+	}
+	
+	showLoader();
+	jQuery('#dataEntryFormDiv').load("dataentryform.action",
+		{
+			programStageId:getFieldValue('programStageId'),
+			patientId: getFieldValue('patientId'),
+			useDefaultForm: jQuery('#useDefaultForm').find("checked").value
+		}, 
+		function( data ) 
+		{
+			enable('listPatientBtn');
+			enable('searchingAttributeId');
+			jQuery('#searchText').removeAttr( 'readonly' );
+			enable('searchBtn');
+		
+			hideById('searchPatientDiv');
+			
+			showById('dataRecordingSelectDiv');
+			if ( getFieldValue('executionDate') =='' )
+			{
+				hideById('dataEntryFormDiv');
+				setInnerHTML('startMsg', i18n_report_date_warning);
+			}
+			else
+			{
+				showById('dataEntryFormDiv');
+				setInnerHTML('startMsg', '');
+			}
+			
+			enable('dueDate');
+			enable('executionDate');
+			enable('validationBtn');
+			enable('completeBtn');
+			
+			enable('useDefaultForm');
+			enable('useCustomForm');
+			
+			if( byId('useCustomForm').checked )
+			{
+				selectUseCustomDataEntryForm();
+			}else
+			{
+				selectUseDefaultDataEntryForm();
+			}
+			
+			hideLoader();
+			hideById('contentDiv');
+		});
+}
+
+//--------------------------------------------------------------------------------------------
+// Checkbox useDefaultForm is checked
+//--------------------------------------------------------------------------------------------
+
+function selectUseDefaultDataEntryForm()
+{
+	byId('useCustomForm').checked = false;
+	hideById( 'customEntryScreenContainer' );
+	showById( 'defaultEntryScreenContainer' );
+}
+
+function selectUseCustomDataEntryForm()
+{
+	byId('useDefaultForm').checked = false;
+	hideById( 'defaultEntryScreenContainer' );
+	showById( 'customEntryScreenContainer' );
+}
+
+//--------------------------------------------------------------------------------------------
+// Show multi data-entry-form
+//--------------------------------------------------------------------------------------------
+
 function viewPrgramStageRecords( programStageInstanceId ) 
 {
 	var url = 'viewProgramStageRecords.action?programStageInstanceId=' + programStageInstanceId;
@@ -13,28 +219,17 @@
     });
 }
 
-
-function organisationUnitSelected( orgUnits )
-{
-    window.location.href = 'dataEntrySelect.action';
-}
-
-selection.setListenerFunction( organisationUnitSelected );
-
 //-----------------------------------------------------------------------------
-//Search Patient
+// Search Patient
 //-----------------------------------------------------------------------------
 
 function validateSearch()
 {	
-	
-    var url = 'validateSearch.action?' +
-    'searchText=' + getFieldValue( 'searchText' );
-	
     var request = new Request();
     request.setResponseTypeXML( 'message' );
     request.setCallbackSuccess( searchValidationCompleted );
-    request.send( url );
+	request.sendAsPost('searchText=' + getFieldValue( 'searchText' ));
+    request.send( 'validateSearch.action' );
 
     return false;
 }
@@ -46,8 +241,19 @@
 	
     if ( type == 'success' )
     {
-        var form = document.getElementById( 'searchForm' );
-        form.submit();
+		showLoader();
+		hideById('dataEntryFormDiv');
+		hideById('dataRecordingSelectDiv');
+		$('#contentDiv').load( 'searchPatient.action', 
+			{
+				searchingAttributeId: getFieldValue('searchingAttributeId'), 
+				searchText: getFieldValue('searchText')
+			},
+			function()
+			{
+				showById('searchPatientDiv');
+				hideLoader();
+			});
     }
     else if ( type == 'error' )
     {
@@ -55,13 +261,12 @@
     }
     else if ( type == 'input' )
     {
-        document.getElementById( 'message' ).innerHTML = message;
-        document.getElementById( 'message' ).style.display = 'block';
+        setMessage( message );
     }
 }
 
 //-----------------------------------------------------------------------------
-//View details
+// View details
 //-----------------------------------------------------------------------------
 
 function showPatientDetails( patientId )
@@ -109,8 +314,6 @@
 	
 	setInnerHTML( 'identifierField', identifierText );
 	
-	
-	
 	// ----------------------------------------------------------------------------
 	// Get attribute
     // ----------------------------------------------------------------------------
@@ -197,6 +400,7 @@
         if ( code == 0 )
         {
             markValue( resultColor );
+			showById('dataEntryFormDiv');
         }
         else
         {
@@ -209,6 +413,7 @@
             {
                 markValue( resultColor );
             }
+			hideById('dataEntryFormDiv');
         }
     }
 
@@ -396,7 +601,6 @@
 
 function updateProvidingFacilityCustom( programStageId, dataElementId, checkedBox )
 {
-    //	checkedBox.style.backgroundColor = '#ffffcc';
     var providedByAnotherFacility = checkedBox.checked;
     var checkBoxSaver = new CustomCheckBoxSaver( programStageId, dataElementId, providedByAnotherFacility, '#ccffcc' );
     checkBoxSaver.save();
@@ -652,11 +856,19 @@
 	
     this.save = function()
     {
+		var params = 'dataElementId=' + dataElementId;
+			params += '&value=' + value;
+			params += '&providedByAnotherFacility=' + providedByAnotherFacility;
+			params += '&orgunitId=' + getFieldValue('orgunitId');
+			params += '&patientId=' + getFieldValue('patientId');
+			params += '&programStageId=' + getFieldValue('programStageId');
+			
         var request = new Request();
         request.setCallbackSuccess( handleResponse );
         request.setCallbackError( handleHttpError );
         request.setResponseTypeXML( 'status' );
-        request.send( 'saveValue.action?dataElementId=' + dataElementId + '&value=' + value + '&providedByAnotherFacility=' + providedByAnotherFacility );
+		request.sendAsPost( params );
+        request.send( 'saveValue.action');
     };
  
     function handleResponse( rootElement )
@@ -753,11 +965,28 @@
 		
         if( optionComboId )
         {
-            request.send( 'saveValue.action?dataElementId=' + dataElementId + '&optionComboId=' + optionComboId + '&value=' + value + '&providedByAnotherFacility=' + providedByAnotherFacility );
+			var params = 'dataElementId=' + dataElementId;
+				params += '&optionComboId=' + optionComboId;
+				params += '&value=' + value;
+				params += '&providedByAnotherFacility=' + providedByAnotherFacility;
+				params += '&orgunitId=' + getFieldValue('orgunitId');
+				params += '&patientId=' + getFieldValue('patientId');
+				params += '&programStageId=' + getFieldValue('programStageId');
+				
+			request.sendAsPost( params );
+            request.send( 'saveValue.action' );
         }
         else
-        {
-            request.send( 'saveValue.action?dataElementId=' + dataElementId + '&value=' + value + '&providedByAnotherFacility=' + providedByAnotherFacility );
+        {	
+			var params = 'dataElementId=' + dataElementId;
+				params += '&value=' + value;
+				params += '&providedByAnotherFacility=' + providedByAnotherFacility;
+				params += '&orgunitId=' + getFieldValue('orgunitId');
+				params += '&patientId=' + getFieldValue('patientId');
+				params += '&programStageId=' + getFieldValue('programStageId');
+			
+			request.sendAsPost( params );
+            request.send( 'saveValue.action' );
         }
 		
 		
@@ -933,8 +1162,6 @@
     {
         // No more fields after this:
         return false;
-    // First field:
-    //return inputs[0];
     }
     else
     {
@@ -945,6 +1172,7 @@
 //------------------------------------------------------
 // Save value for dataElement of type date in entryscreen
 //------------------------------------------------------
+
 function saveDate( dataElementId , dataElementName )
 {
     var providedByAnotherFacility ;
@@ -1076,11 +1304,9 @@
 	
         jQuery("#customEntryScreenContainer td").hover(
             function(){
-                //				jQuery(this).siblings("td").removeClass("focusCell");
                 var childrens = jQuery(this).children("input[name='entryfield'],select[name='entryselect']");
                 
 				if( jQuery(childrens[0]).is(":disabled")) {
-                    //					jQuery(this).addClass("focusCell");
                     DRAG_DIV.showData(jQuery(childrens[0]).metadata({
                         "type":"attr",
                         "name":"data"
@@ -1090,29 +1316,22 @@
 				
             },
             function(){
-            //				if( currentFocus )
-            //				{
-            //					jQuery(currentFocus).focus();
-            //				}
-            //				jQuery(this).removeClass("focusCell");
             }
             );
 		
         jQuery("input[name='entryfield'],select[name='entryselect']").each(function(){
             jQuery(this).focus(function(){
                 currentFocus = this;
-                //			jQuery(this).addClass("focusCell");
                 DRAG_DIV.showData(jQuery(this).metadata({
                     "type":"attr",
                     "name":"data"
                 }));
             });
             jQuery(this).blur(function(){
-                //			jQuery(this).removeClass("focusCell");
+               
                 });
             jQuery(this).hover(
                 function(){
-                    //					jQuery(this).addClass("focusCell");
                     DRAG_DIV.showData(jQuery(this).metadata({
                         "type":"attr",
                         "name":"data"
@@ -1120,15 +1339,12 @@
                 },
                 function()
                 {
-                    //					jQuery(this).removeClass("focusCell");
                     if(currentFocus){
-                        //						jQuery(currentFocus).addClass("focusCell");
                         DRAG_DIV.showData(jQuery(currentFocus).metadata({
                             "type":"attr",
                             "name":"data"
                         }));
                     }
-                //					jQuery(this).parent("td:first").removeClass("focusCell");
                 }
                 );
             jQuery(this).addClass("inputText");
@@ -1191,7 +1407,7 @@
 function doComplete()
 {
     var flag = false;
-    jQuery("#entryFormContainer input[name='entryfield'],select[name='entryselect']").each(function(){
+    jQuery("#dataEntryFormDiv input[name='entryfield'],select[name='entryselect']").each(function(){
         jQuery(this).parent().removeClass("errorCell");
         if( jQuery(this).metadata({
             "type":"attr",
@@ -1208,7 +1424,29 @@
         return;
     }else {
         if( confirm(i18n_complete_confirm_message) )
-            jQuery("#completeDataEntryForm").submit();
+		{
+			$.postJSON( "completeDataEntry.action",
+				{
+					programStageInstanceId: getFieldValue('programStageInstanceId')
+				},
+				function (data)
+				{
+					jQuery("#dataEntryFormDiv :input").each(function()
+					{
+						jQuery(this).attr('disabled', 'disabled');
+					});
+					jQuery("#dataEntryFormDiv").find(".ui-datepicker-trigger").each(function()
+					{
+						jQuery(this).attr('style', 'display:none');
+					});
+					jQuery("#dataEntryFormDiv").find(".holder").each(function()
+					{
+						jQuery(this).attr('style', 'display:none');
+					});
+					
+					hideLoader();
+				},'xml');
+		}
     }
 }
 
@@ -1220,8 +1458,6 @@
             jQuery(this).click(function(){
                 var table = jQuery(this).next("table:first");
                 if( table.hasClass("sectionClose")){
-                    //					jQuery(".sectionOpen").removeClass("sectionOpen").addClass("sectionClose");
-                    //					jQuery(".togglePanel.open").removeClass("open").addClass("close");
                     table.removeClass("sectionClose").addClass("sectionOpen");
                     jQuery(this).removeClass("close").addClass("open");
                     window.scroll(0,jQuery(this).position().top);
@@ -1233,3 +1469,14 @@
         });
     },
 }
+
+//------------------------------------------------------
+// Run validation
+//------------------------------------------------------
+
+function runValidation()
+{
+	window.open( 'validateProgram.action?orgunitId=' + getFieldValue('orgunitId') 
+							+ '&patientId=' + getFieldValue('patientId') 
+							+ '&programStageId=' + getFieldValue('programStageId') );
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm	2011-03-18 12:26:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm	2011-05-10 07:25:28 +0000
@@ -1,14 +1,3 @@
-<script type="text/javascript">
-	var i18n_id = '$encoder.jsEscape( $i18n.getString( "id" ), "'")';
-	var i18n_full_name = '$encoder.jsEscape( $i18n.getString( "full_name" ), "'")';
-	var i18n_gender = '$encoder.jsEscape( $i18n.getString( "gender" ), "'")';
-	var i18n_dob_type = '$encoder.jsEscape( $i18n.getString( "dob_type" ), "'")';
-	var i18n_date_of_birth = '$encoder.jsEscape( $i18n.getString( "date_of_birth" ), "'")';
-	var i18n_blood_group = '$encoder.jsEscape( $i18n.getString( "blood_group" ), "'")';
-	var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ), "'")';
-</script>
-
-#parse( "/dhis-web-caseentry/search.vm" )
 
 <table>
 	<tr>
@@ -38,9 +27,8 @@
 		  	<td></td>
 		  	<td></td>
 		  	<td></td>  		  	
-		  	<td colspan="2" style="text-align:right">  			
-				<input type="button" value="$i18n.getString( "cancel" )" onclick="window.location.href='dataEntrySelect.action'" style="width:60px">
-			</td>
+		  	<td></td>
+			<td></td>
           <tr>
             <th>$i18n.getString( "first_name" )</th>
             <th>$i18n.getString( "middle_name" )</th>
@@ -75,7 +63,7 @@
                     $encoder.htmlEncode( $patient.getAge() )
                 </td>				
 				<td style="text-align:center"#alternate( $mark )>
-                  <a href="selectDataRecording.action?id=$patient.id" title="$i18n.getString( "data_entry" )"><img src="images/data_entry.png" alt="$i18n.getString( "data_entry" )"></a>                  
+                  <a href="javascript:showSelectedDataRecoding('$patient.id');" title="$i18n.getString( "data_entry" )"><img src="images/data_entry.png" alt="$i18n.getString( "data_entry" )"></a>                  
                 </td>
                 <td style="text-align:center"#alternate( $mark )>
                   <a href="javascript:showPatientDetails( $patient.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( "show_details" )"></a>
@@ -88,7 +76,15 @@
 			#end
     	#end
     	</tbody>
-    
+		<tr>
+		<td colspan="8">
+			<p></p>
+			<div class="paging-container">
+					#parse( "/dhis-web-commons/paging/paging.vm" )
+			</div>
+		</td>
+		<td></td>
+	  </tr>
 	  </table>
     </td>
     <td style="width:20em; padding-left:2em; vertical-align:top">
@@ -104,5 +100,7 @@
     </td>
   </tr>
 </table>
+
+
    
 <span id="message"></span>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseOrgUnit.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseOrgUnit.vm	2010-02-22 09:19:15 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseOrgUnit.vm	2011-05-10 07:25:28 +0000
@@ -1,8 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<orgunits>
-	<orgunit>
-		<id>$!orgUnit.id</id>
-		<name>$encoder.xmlEncode( $!orgUnit.shortName )</name>
-		<level>$!orgUnitLevel</level>
-	</orgunit>
-</orgunits>
\ No newline at end of file
+<organisationUnit>
+	<id>$!organisationUnit.id</id>
+	<name>$encoder.xmlEncode( $!organisationUnit.name )</name>
+</organisationUnit>
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseProgramStages.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseProgramStages.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseProgramStages.vm	2011-05-10 07:25:28 +0000
@@ -0,0 +1,24 @@
+#set( $size = $programStages.size() )
+{ 
+	"programStages": [
+		#foreach( $programStage in $programStages )
+		  {
+			"id":  ${programStage.id} ,
+			"name": "$!encoder.jsonEncode( ${programStage.name} )"
+		  }#if( $velocityCount < $size ),#end
+		#end],
+		
+	#set( $size = $programStages.size() )
+	"programStageInstances": [
+		#foreach( $programStageInstance in $programInstance.programStageInstances )
+		  {
+			"name": "$programStageInstance.programStage.name",
+			"colorMap": "$colorMap.get( $programStageInstance.id )",
+			"infor": #if( $programStageInstance.completed )
+						"$i18n.getString( 'completed_on' )$format.formatDate( $programStageInstance.executionDate )"
+					#else
+						"$i18n.getString( 'scheduled_for' )$format.formatDate( $programStageInstance.dueDate )"
+					#end
+		  }#if( $velocityCount < $programInstance.programStageInstances.size() ),#end
+		#end]
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm	2011-03-24 17:27:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm	2011-05-10 07:25:28 +0000
@@ -1,16 +1,82 @@
 <h3>$i18n.getString( "name_based_data_entry" )</h3>
 
-<form id="selectForm" name="selectForm" method="post" action="select.action">
-<table>
+<div id='searchPatientDiv' #if($organisationUnit) #else disabled #end>
+	<table>    
+		<tr>
+			<td><label>$i18n.getString( "registering_unit" )</label></td>
+			<td>
+				<input type="text" id='orgunitName' readonly="readonly" #if( $organisationUnit ) value="$encoder.htmlEncode( $organisationUnit.name )" #else value="[$i18n.getString( "please_select_village" )]" #end style="min-width:350px">
+			</td>
+			<td>&nbsp;</td>
+			<td>
+				<input type="button" id='listPatientBtn' value="$i18n.getString( "list_all_patients" )" onclick="javascript:listAllPatient();" #if($organisationUnit) #else disabled #end>
+			</td>        
+		</tr>        
+	</table>
+
+	<hr style="clear:both">
+
+	<table> 
+		<tr>           
+			<td>
+			  <select id="searchingAttributeId" name="searchingAttributeId" style="min-width:300px"  #if( $patientAttributes.size() == 0 ) disabled="disabled" #end #if($organisationUnit) #else disabled #end>
+				<option value="">$i18n.getString( "search_by_name_identifier" )</option>
+					#foreach( $attribute in $patientAttributes )
+						<option value="$attribute.id" #if( $searchingAttributeId && $attribute.id == $searchingAttributeId ) selected="selected" #end>$encoder.htmlEncode( $attribute.name )</option>
+					#end
+			  </select> 
+			  <em title="$i18n.getString( "required" )" class="required">*</em></label>
+			</td>       
+			<td>
+				<input type="text" id="searchText" name="searchText" maxlength="30" style="width:20em" #if($organisationUnit) #else readonly #end/>
+			</td>        
+			<td>
+				<input type="button" id='searchBtn' value="$i18n.getString( 'search' )" onclick='validateSearch();' #if($organisationUnit) #else disabled #end/>
+			</td>        
+		</tr>    
+		<tr></tr>        
+	</table>
+</div>
+<span id='message'></span>
+<div id='contentDiv'></div>
+<div id='dataRecordingSelectDiv'></div>
+<div id='dataEntryFormDiv'></div>
+
+<input type='hidden' id='orgunitId' >
+<input type='hidden' id='patientId' name='patientId' >
+<input type="hidden" id="programStageInstanceId" name="programStageInstanceId" />
+
+#parse( "dhis-web-commons/loader/loader.vm" )
+
+<script type="text/javascript">
+	var i18n_id = '$encoder.jsEscape( $i18n.getString( "id" ), "'")';
+	var i18n_full_name = '$encoder.jsEscape( $i18n.getString( "full_name" ), "'")';
+	var i18n_gender = '$encoder.jsEscape( $i18n.getString( "gender" ), "'")';
+	var i18n_dob_type = '$encoder.jsEscape( $i18n.getString( "dob_type" ), "'")';
+	var i18n_date_of_birth = '$encoder.jsEscape( $i18n.getString( "date_of_birth" ), "'")';
+	var i18n_blood_group = '$encoder.jsEscape( $i18n.getString( "blood_group" ), "'")';
+	var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ), "'")';
+	var i18n_select = '[' + '$encoder.jsEscape( $i18n.getString( "select" ), "'")' + ']';
+	var i18n_report_date_warning = '$encoder.jsEscape( $i18n.getString( "report_date_warning" ) , "'")';
+	var i18n_program_stages_history_plan = '$encoder.jsEscape( $i18n.getString( "program_stages_history_plan" ) , "'")';
 	
-	<tr>
-		<td><label>$i18n.getString( "registering_unit" )</label></td>
-		<td>
-			<input type="text" readonly="readonly" #if( $organisationUnit ) value="$encoder.htmlEncode( $organisationUnit.name )" #else value="[$i18n.getString( "select" )]" #end style="min-width:350px">
-		</td>
-	</tr>
-		
-</table>
-</form>
-
-<hr style="clear:both">
+	var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
+	var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
+	var i18n_value_must_positive_number = '$encoder.jsEscape( $i18n.getString( "value_must_positive_number" ) , "'")';
+	var i18n_value_must_negative_number = '$encoder.jsEscape( $i18n.getString( "value_must_negative_number" ) , "'")';
+    var i18n_invalid_date =   '$encoder.jsEscape( $i18n.getString( "invalid_date" ) , "'")' + ".\n " 
+							+ '$encoder.jsEscape( $i18n.getString( "format_date" ) , "'")' + " '" 
+							+ dateFormat.replace('yy', 'yyyy') + " '" ; 
+    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_complete_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_confirm_message" ) , "'")';
+    var i18n_error_required_field = '$encoder.jsEscape( $i18n.getString( "error_required_field" ) , "'")';
+	var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
+	var i18n_date_less_incident_date = '$encoder.jsEscape( $i18n.getString( "date_less_incident_date" ) , "'")';
+	alert();
+	setFieldValue('orgunitId', '$!organisationUnit.id');
+	setFieldValue('orgunitName', "$encoder.jsEscape($!organisationUnit.name)");
+</script>
+
+