← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3681: Load Multi-dataentry by ajax.

 

------------------------------------------------------------
revno: 3681
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-05-20 16:23:01 +0700
message:
  Load Multi-dataentry by ajax.
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramsByOrgunitAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responsePrograms.vm
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.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/MultiDataEntrySelectAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.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/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.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/multiDataEntrySelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.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/GetDataRecordsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java	2011-05-06 11:10:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java	2011-05-20 09:23:01 +0000
@@ -147,20 +147,6 @@
         return total;
     }
 
-    private OrganisationUnit organisationUnit;
-
-    public OrganisationUnit getOrganisationUnit()
-    {
-        return organisationUnit;
-    }
-
-    private Program program;
-
-    public Program getProgram()
-    {
-        return program;
-    }
-
     private Collection<ProgramInstance> programInstances = new ArrayList<ProgramInstance>();
 
     public Collection<ProgramInstance> getProgramInstances()
@@ -203,25 +189,18 @@
         return patientListByOrgUnit;
     }
 
-    List<Program> programs;
-
-    public List<Program> getPrograms()
-    {
-        return programs;
-    }
-
-    private Collection<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
-
-    public Collection<PatientAttribute> getPatientAttributes()
-    {
-        return patientAttributes;
-    }
-
-    private PatientAttribute sortingAttribute;
-
-    public PatientAttribute getSortingAttribute()
-    {
-        return sortingAttribute;
+    private PatientAttribute sortPatientAttribute;
+
+    public PatientAttribute getSortPatientAttribute()
+    {
+        return sortPatientAttribute;
+    }
+
+    private Program program;
+
+    public Program getProgram()
+    {
+        return program;
     }
 
     // -------------------------------------------------------------------------
@@ -231,26 +210,11 @@
     public String execute()
         throws Exception
     {
-        // ---------------------------------------------------------------------
-        // Patient Attribute List
-        // ---------------------------------------------------------------------
-
-        patientAttributes = patientAttributeService.getAllPatientAttributes();
-
-        organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
-        programs = new ArrayList<Program>( programService.getPrograms( organisationUnit ) );
-
-        if ( programId == 0 )
-        {
-            selectedStateManager.clearSelectedProgram();
-
-            return SUCCESS;
-        }
+        OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
 
         program = programService.getProgram( programId );
 
-        selectedStateManager.setSelectedProgram( program );
+        sortPatientAttribute = patientAttributeService.getPatientAttribute( sortPatientAttributeId );
 
         // ---------------------------------------------------------------------
         // Program instances for the selected program
@@ -283,7 +247,7 @@
                     programInstances.add( programInstance );
 
                     PatientAttributeValue patientAttributeValue = patientAttributeValueService
-                        .getPatientAttributeValue( patient, sortingAttribute );
+                        .getPatientAttributeValue( patient, sortPatientAttribute );
 
                     patinetAttributeValueMap.put( patient, patientAttributeValue );
 
@@ -303,9 +267,7 @@
 
         if ( sortPatientAttributeId != null )
         {
-            sortingAttribute = patientAttributeService.getPatientAttribute( sortPatientAttributeId );
-
-            patientListByOrgUnit = patientService.sortPatientsByAttribute( patientListByOrgUnit, sortingAttribute );
+            patientListByOrgUnit = patientService.sortPatientsByAttribute( patientListByOrgUnit, sortPatientAttribute );
         }
 
         colorMap = programStageInstanceService.colorProgramStageInstances( programStageInstances );

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramsByOrgunitAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramsByOrgunitAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramsByOrgunitAction.java	2011-05-20 09:23:01 +0000
@@ -0,0 +1,97 @@
+/*
+ * 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 org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ GetProgramsByOrgunitAction.java May 20, 2011 11:31:41 AM $
+ * 
+ */
+public class GetProgramsByOrgunitAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitSelectionManager selectionManager;
+
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+    {
+        this.selectionManager = selectionManager;
+    }
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/output
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnit organisationUnit;
+
+    public OrganisationUnit getOrganisationUnit()
+    {
+        return organisationUnit;
+    }
+
+    private Collection<Program> programs = new ArrayList<Program>();
+
+    public Collection<Program> getPrograms()
+    {
+        return programs;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        organisationUnit = selectionManager.getSelectedOrganisationUnit();
+
+        programs = programService.getPrograms( organisationUnit );
+
+        return SUCCESS;
+    }
+}

=== modified 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	2011-05-20 03:35:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java	2011-05-20 09:23:01 +0000
@@ -33,11 +33,8 @@
 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.dataentryform.DataEntryFormService;
 import org.hisp.dhis.i18n.I18n;
-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;
@@ -48,7 +45,6 @@
 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;
@@ -79,14 +75,8 @@
 
     private PatientService patientService;
 
-    // private MinMaxDataElementService minMaxDataElementService;
-
     private OrganisationUnitSelectionManager selectionManager;
 
-    private ProgramStageDataElementService programStageDataElementService;
-
-    private DataEntryFormService dataEntryFormService;
-
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -158,16 +148,6 @@
         return programStageInstance;
     }
 
-    public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService )
-    {
-        this.programStageDataElementService = programStageDataElementService;
-    }
-
-    public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
-    {
-        this.dataEntryFormService = dataEntryFormService;
-    }
-
     public void setPatientId( Integer patientId )
     {
         this.patientId = patientId;
@@ -225,8 +205,6 @@
 
         programStageDataElements = programStage.getProgramStageDataElements();
 
-        Collection<DataElement> dataElements = programStageDataElementService.getListDataElement( programStage );
-
         programStageInstance = programStageInstanceService.getProgramStageInstance( programInstance, programStage );
 
         if ( programStageInstance != null )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/MultiDataEntrySelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/MultiDataEntrySelectAction.java	2011-05-01 09:07:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/MultiDataEntrySelectAction.java	2011-05-20 09:23:01 +0000
@@ -119,51 +119,15 @@
 
         organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
 
-        if ( organisationUnit == null )
-        {
-            programId = null;
-
-            selectedStateManager.clearSelectedProgram();
-
-            return SUCCESS;
-        }
-
         // ---------------------------------------------------------------------
         // Load assigned Programs
         // ---------------------------------------------------------------------
 
-        programs = programService.getPrograms( organisationUnit );
-
-        // ---------------------------------------------------------------------
-        // 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;
-
-            selectedStateManager.clearSelectedProgram();
-
-            return SUCCESS;
-        }
-
+        if( organisationUnit != null )
+        {
+            programs = programService.getPrograms( organisationUnit );
+        }
+        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.java	2011-05-20 03:35:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.java	2011-05-20 09:23:01 +0000
@@ -38,8 +38,6 @@
 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;
@@ -48,6 +46,7 @@
 import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceService;
 
@@ -94,13 +93,6 @@
         this.dataEntryScreenManager = dataEntryScreenManager;
     }
 
-//    private MinMaxDataElementService minMaxDataElementService;
-//
-//    public void setMinMaxDataElementService( MinMaxDataElementService minMaxDataElementService )
-//    {
-//        this.minMaxDataElementService = minMaxDataElementService;
-//    }
-
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -235,7 +227,13 @@
     {
            return programStageInstance.getId();
     }
+    
+    private Collection<ProgramStageDataElement> programStageDataElements;
 
+    public Collection<ProgramStageDataElement> getProgramStageDataElements()
+    {
+        return programStageDataElements;
+    }
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -243,20 +241,6 @@
     public String execute()
         throws Exception
     {
-//        // ---------------------------------------------------------------------
-//        // Get the min/max values
-//        // ---------------------------------------------------------------------
-//
-//        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 Orgunit & Program, ProgramStage 
         // ---------------------------------------------------------------------
@@ -267,6 +251,8 @@
         
         programStage = programStageInstance.getProgramStage();
         
+        programStageDataElements = programStage.getProgramStageDataElements();
+        
         program = programStage.getProgram();
         
         patient = programStageInstance.getProgramInstance().getPatient();

=== 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-05-20 03:35:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2011-05-20 09:23:01 +0000
@@ -169,10 +169,6 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="selectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		<property name="programStageDataElementService"
-			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
-		<property name="dataEntryFormService"
-			ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
 	</bean>
 	
 	<bean
@@ -197,6 +193,14 @@
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
 
+	<bean id="org.hisp.dhis.caseentry.action.caseentry.GetProgramsByOrgunitAction"
+		class="org.hisp.dhis.caseentry.action.caseentry.GetProgramsByOrgunitAction"
+		scope="prototype">
+		<property name="selectionManager"
+			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+	</bean>
+	
 	<bean id="org.hisp.dhis.caseentry.action.caseentry.GetDataRecordsAction"
 		class="org.hisp.dhis.caseentry.action.caseentry.GetDataRecordsAction"
 		scope="prototype">

=== 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-05-20 03:35:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-05-20 09:23:01 +0000
@@ -59,14 +59,13 @@
     
     <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>
+      <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">
@@ -111,20 +110,25 @@
       <result name="success" type="velocity">/main.vm</result>     
       <param name="page">/dhis-web-caseentry/multiDataEntrySelect.vm</param>
       <param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>      
-      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js, ../dhis-web-commons/javascripts/date.js</param>      
+      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js, javascript/dataEntry.js</param>      
+    </action>  
+    
+    <action name="getPrograms" class="org.hisp.dhis.caseentry.action.caseentry.GetProgramsByOrgunitAction">
+      <result name="success" type="velocity-json">/dhis-web-caseentry/responsePrograms.vm</result>  
     </action>  
 
 	<action name="getDataRecords" class="org.hisp.dhis.caseentry.action.caseentry.GetDataRecordsAction">
-      <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/dataentryRecords.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,../dhis-web-commons/paging/paging.css</param>     
+      <param name="javascripts">javascript/customcheckbox/prettyCheckboxes.js</param> 
+      <param name="stylesheets">style/patient.css,javascript/customcheckbox/prettyCheckboxes.css
+      		,../dhis-web-commons/paging/paging.css</param>     
     </action>
 	
 	<action name="viewProgramStageRecords" class="org.hisp.dhis.caseentry.action.caseentry.ProgramStageCustomDataEntryAction">
-      <result name="success" type="velocity">/dhis-web-caseentry/programStageDataEntryForm.vm</result>      
+      <result name="success" type="velocity">/content.vm</result>
+      <param name="page">/dhis-web-caseentry/programStageDataEntryForm.vm</param>
+      <param name="javascripts">javascript/dataEntry.js,../dhis-web-commons/javascripts/date.js</param> 
     </action>
 
     <action name="completeProgramStageDataEntry" class="org.hisp.dhis.caseentry.action.caseentry.CompleteDataEntryAction">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.vm	2011-03-24 17:27:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.vm	2011-05-20 09:23:01 +0000
@@ -1,29 +1,16 @@
-<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/multiDataEntrySelect.vm" )
-
 <table class="mainPageTable">
     <tr>
         <td style="vertical-align:top">    
         <table class="listTable">
-            <col>
-			#if( $sortPatientAttributeId )
+            #if( $sortPatientAttribute )
 				<col>
 			#end
             #foreach( $programStage in $program.programStages )
                 <col>
             #end       
             <tr>
-				#if( $sortPatientAttributeId )
-					<th style="text-align:center">$encoder.htmlEncode( $sortingAttribute.name )</th>
+				#if( $sortPatientAttribute )
+					<th style="text-align:center">$encoder.htmlEncode( $sortPatientAttribute.name )</th>
 				#end
                 <th style="text-align:center">$i18n.getString( "full_name" )</th>
                 #foreach( $programStage in $program.programStages )
@@ -36,7 +23,7 @@
                 #foreach( $patient in $patientListByOrgUnit )
 					#set( $programInstance = $programInstanceMap.get( $patient ) )
                     <tr #alternate( $mark )>
-						#if( $sortPatientAttributeId )
+						#if( $sortPatientAttribute )
 							#set( $patientAttributeValue = $patinetAttributeValueMap.get( $patient ) )
 							<td>$!patientAttributeValue.value</td>
 						#end

=== 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-05-20 03:35:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js	2011-05-20 09:23:01 +0000
@@ -197,25 +197,6 @@
 	showById( 'customEntryScreenContainer' );
 }
 
-//--------------------------------------------------------------------------------------------
-// Show multi data-entry-form
-//--------------------------------------------------------------------------------------------
-
-function viewPrgramStageRecords( programStageInstanceId ) 
-{
-	var url = 'viewProgramStageRecords.action?programStageInstanceId=' + programStageInstanceId;
-	$('#contentDataRecord').dialog('destroy').remove();
-    $('<div id="contentDataRecord">' ).load(url).dialog({
-        title: 'ProgramStage',
-		maximize: true, 
-		closable: true,
-		modal:true,
-		overlay:{background:'#000000', opacity:0.1},
-		width: 800,
-        height: 400
-    });
-}
-
 //-----------------------------------------------------------------------------
 // Search Patient
 //-----------------------------------------------------------------------------
@@ -867,7 +848,7 @@
 			params += '&orgunitId=' + getFieldValue('orgunitId');
 			params += '&patientId=' + getFieldValue('patientId');
 			params += '&programStageId=' + getFieldValue('programStageId');
-			
+
         var request = new Request();
         request.setCallbackSuccess( handleResponse );
         request.setCallbackError( handleHttpError );
@@ -977,7 +958,7 @@
 				params += '&orgunitId=' + getFieldValue('orgunitId');
 				params += '&patientId=' + getFieldValue('patientId');
 				params += '&programStageId=' + getFieldValue('programStageId');
-				
+			
 			request.sendAsPost( params );
             request.send( 'saveValue.action' );
         }
@@ -989,7 +970,7 @@
 				params += '&orgunitId=' + getFieldValue('orgunitId');
 				params += '&patientId=' + getFieldValue('patientId');
 				params += '&programStageId=' + getFieldValue('programStageId');
-			
+				
 			request.sendAsPost( params );
             request.send( 'saveValue.action' );
         }
@@ -1254,7 +1235,16 @@
 
 function selectDefaultForm()
 {
-    jQuery('#selectRecordingForm').submit();
+    if( byId('useDefaultForm').checked  )
+	{
+		hideById('customEntryScreenContainer');
+		showById('defaultEntryScreenContainer');
+	}
+	else
+	{
+		hideById('defaultEntryScreenContainer');
+		showById('customEntryScreenContainer');
+	}
 }
 
 function saveValueWithOptionComboId( this_ )
@@ -1484,4 +1474,84 @@
 	window.open( 'validateProgram.action?orgunitId=' + getFieldValue('orgunitId') 
 							+ '&patientId=' + getFieldValue('patientId') 
 							+ '&programStageId=' + getFieldValue('programStageId') );
-}
\ No newline at end of file
+}
+
+
+//------------------------------------------------------
+// Multi Data-entry
+//------------------------------------------------------
+
+function multiDataEntryOrgunitSelected( orgUnits )
+{
+	jQuery.postJSON( "getPrograms.action",
+	{
+	}, 
+	function( json ) 
+	{    
+		enable('programId');
+		enable('patientAttributeId');
+		
+		clearListById('programId');
+		if(json.programs.length == 0)
+		{
+			disable('programId');
+			disable('patientAttributeId');
+		}
+		else
+		{
+			addOptionById( 'programId', "0", i18n_select );
+			
+			for ( var i in json.programs ) 
+			{
+				addOptionById( 'programId', json.programs[i].id, json.programs[i].name );
+			} 
+		}	
+		setFieldValue( 'orgunitName', json.organisationUnit ); 
+		setFieldValue( 'orgunitId', json.organisationUnitId ); 
+	});
+}
+
+function selectProgram()
+{
+	if( getFieldValue('programId') == 0 )
+	{
+		hideById('listPatient');
+		return;
+	}
+	
+	jQuery('#listPatient').load("getDataRecords.action",
+		{
+			programId:getFieldValue('programId'),
+			sortPatientAttributeId: getFieldValue('patientAttributeId')
+		}, 
+		function( )
+		{
+			showById("listPatient");
+		});
+}
+
+function selectPatientAttribute()
+{
+	var programLB = document.getElementById('programId');
+	var selPrgroamId = programLB.options[programLB.selectedIndex].value;
+
+	var patientAttributeLB = document.getElementById('patientAttributeId');
+	var patientAttributeId = patientAttributeLB.options[patientAttributeLB.selectedIndex].value;
+
+	window.location.href='getDataRecords.action?programId='+selPrgroamId+'&sortPatientAttributeId='+patientAttributeId;
+}
+
+function viewPrgramStageRecords( programStageInstanceId ) 
+{
+	var url = 'viewProgramStageRecords.action?programStageInstanceId=' + programStageInstanceId;
+	$('#contentDataRecord').dialog('destroy').remove();
+    $('<div id="contentDataRecord">' ).load(url).dialog({
+        title: 'ProgramStage',
+		maximize: true, 
+		closable: true,
+		modal:true,
+		overlay:{background:'#000000', opacity:0.1},
+		width: 800,
+        height: 400
+    });
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm	2011-03-24 17:27:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm	2011-05-20 09:23:01 +0000
@@ -1,30 +1,7 @@
 <script type="text/javascript">
 	jQuery(document).ready(function() {
-		selection.setListenerFunction( organisationUnitSelected );
+		selection.setListenerFunction( multiDataEntryOrgunitSelected );
 	});
-
-	function organisationUnitSelected( orgUnits )
-	{
-		window.location.href = 'multipledataEntrySelect.action';
-	}
-
-	function selectProgram()
-	{
-		var programLB = document.getElementById('programId');
-		var selPrgroamId = programLB.options[programLB.selectedIndex].value;
-		window.location.href='getDataRecords.action?programId='+selPrgroamId;
-	}
-	
-    function selectPatientAttribute()
-    {
-	    var programLB = document.getElementById('programId');
-        var selPrgroamId = programLB.options[programLB.selectedIndex].value;
-	
-        var patientAttributeLB = document.getElementById('patientAttributeId');
-        var patientAttributeId = patientAttributeLB.options[patientAttributeLB.selectedIndex].value;
-    
-	    window.location.href='getDataRecords.action?programId='+selPrgroamId+'&sortPatientAttributeId='+patientAttributeId;
-    }
 </script>
 
 <h3>$i18n.getString( "" )</h3>
@@ -34,7 +11,7 @@
 		<tr>
 			<td><label>$i18n.getString( "reporting_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">
+				<input type="text" readonly="readonly" id='orgunitName' name='orgunitName' #if( $organisationUnit ) value="$encoder.htmlEncode( $organisationUnit.name )" #else value="[$i18n.getString( "select" )]" #end style="min-width:350px">
 			</td>
 			<td>&nbsp;</td>
 			<td>&nbsp;</td>
@@ -52,7 +29,7 @@
             </td>
 			<td align="right"><label>$i18n.getString( "sort_by" )</label></td>
 			<td>
-				<select id="patientAttributeId" name="patientAttributeId" style="min-width:350px" onchange="javascript:selectPatientAttribute()" #if( $programs.size() == 0 ) disabled="disabled" #end>
+				<select id="patientAttributeId" name="patientAttributeId" style="min-width:350px" onchange="javascript:selectProgram();" #if( $programs.size() == 0 ) disabled="disabled" #end>
                     <option value="0">[$i18n.getString( "select" )]</option>
                     #foreach( $patientAttribute in $patientAttributes )
                         <option value="$patientAttribute.id" #if( $sortPatientAttributeId && $patientAttribute.id == $sortPatientAttributeId ) selected="selected" #end>$encoder.htmlEncode( $patientAttribute.name )</option>
@@ -62,5 +39,32 @@
         </tr>
     </table>   
 </form>
-
 <hr style="clear:both">
+
+#parse( "dhis-web-commons/loader/loader.vm" )
+<input type='hidden' id='orgunitId' value='$organisationUnit.id'>
+<div id='listPatient'></div>
+
+<script>
+	var i18n_select = '[' + '$encoder.jsEscape( $i18n.getString( "select" ) , "'")' + ']';
+	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" ) , "'")'; 
+    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" ) , "'")';
+	
+	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>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.vm	2011-03-24 17:27:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.vm	2011-05-20 09:23:01 +0000
@@ -1,22 +1,8 @@
-<script type="text/javascript" src="javascript/dataEntry.js"></script>
-<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" ) , "'")'; 
-    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>
-
-<form id="selectRecordingForm" name="selectRecordingForm" method="post" action="selectDataRecording.action">
-
-<input type="hidden" id="id" name="id" value="$patient.id">
+<form id="dataEntryFormDiv" name="dataEntryFormDiv" method="post" action="selectDataRecording.action">
+
+<input type="hidden" id="patientId" name="patientId" value="$patient.id">
+<input type="hidden" id="programStageId" name="programStageId" value="$programStageInstance.programStage.id">
+<input type="hidden" id="programStageInstanceId" name="programStageInstanceId" value="$programStageInstance.id">
 
 <table class="mainPageTable"> 
     <tr>            
@@ -58,7 +44,9 @@
     </tr>   
     <tr>
 		<td>&nbsp;</td>
-		<td><input type="button" id="completeBtn" value="$i18n.getString('complete')" onClick="doComplete()"></td>
+		<td><input type="button" id="completeBtn" value="$i18n.getString('complete')" onClick="doComplete()" #if($programStageInstance.executionDate) #else disabled #end>
+			<input type="button" id="validationBtn" value="$i18n.getString('validation')" onClick="javascript: runValidation();" style="width:12em " #if($programStageInstance.executionDate) #else disabled #end>
+		</td>
 		<td>&nbsp;</td>
 		<td>
 			<div id="actions" style="float:left">
@@ -85,120 +73,117 @@
     </table>
 </div>
 
-<span id="startMsg" style="font-style:italic; color:blue"> $i18n.getString( "report_date_warning" )
+<span id="startMsg" style="font-style:italic; color:blue"> 
+	#if( $programStageInstance.executionDate ) #else $i18n.getString( "report_date_warning" ) #end
 </span>
 
 <div id="entryFormContainer" >
 
-#if ( $customDataEntryFormExists  )
-<div id="customEntryScreenContainer">
-        #if( $customDataEntryFormCode ) 
-           $customDataEntryFormCode
-        #else <span style="font-style:italic; color:blue"> $i18n.getString( "no_custom_data_entry_exist" )
-        #end
-</span>
+	<div id="customEntryScreenContainer">
+			#if( $customDataEntryFormCode ) 
+			   $customDataEntryFormCode
+			#else <span style="font-style:italic; color:blue"> $i18n.getString( "no_custom_data_entry_exist" )</span>
+			#end
+	</div>
+
+	<div id='defaultEntryScreenContainer' style='display:none;'>
+		<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');
+							</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>
+</div>
+
+	<div id="completeDataEntryFormContainer">
+		<form id="completeDataEntryForm" name="completeDataEntry" method="post" action="completeProgramStageDataEntry.action"> 
+			<input type="hidden" name="id" value="$patient.id"/>
+			<input type="hidden" name="programId" value="$program.id"/>
+			<input type="hidden" name="programStageId" value="$programStage.id"/>
+			<input type="hidden" name="programStageInstanceId" value="$programStageInstance.id"/>
+		</form>
+
+	</div>
 </div>
 
 <script type="text/javascript">
     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');
-                    </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="completeProgramStageDataEntry.action"> 
-    <input type="hidden" name="id" value="$patient.id"/>
-    <input type="hidden" name="programId" value="$program.id"/>
-    <input type="hidden" name="programStageId" value="$programStage.id"/>
-    <input type="hidden" name="programStageInstanceId" value="$programStageInstance.id"/>
-</form>
-
-</div>
-</div>

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responsePrograms.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responsePrograms.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responsePrograms.vm	2011-05-20 09:23:01 +0000
@@ -0,0 +1,12 @@
+#set( $size = $programs.size() )
+{ 
+	"organisationUnit": "$!encoder.jsonEncode( ${organisationUnit.name} )",
+	"organisationUnitId": "${organisationUnit.id}",
+	"programs": [
+		#foreach( $program in $programs )
+		  {
+			"id":  ${program.id} ,
+			"name": "$!encoder.jsonEncode( ${program.name} )"
+		  }#if( $velocityCount < $size ),#end
+		#end]
+}
\ No newline at end of file