← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7273: Don't save null-value for compulsary data-elements in Tabular report.

 

------------------------------------------------------------
revno: 7273
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-06-12 10:38:24 +0700
message:
  Don't save null-value for compulsary data-elements in Tabular report.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.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/webapp/dhis-web-caseentry/app/app.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java	2012-06-12 03:38:24 +0000
@@ -33,11 +33,10 @@
 import java.util.Set;
 
 import org.hisp.dhis.common.BaseIdentifiableObject;
-import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientIdentifierType;
-import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.user.User;
 
 /**
@@ -71,15 +70,13 @@
 
     private Date endDate;
 
-    private ProgramStage programStage;
-
     private List<PatientIdentifierType> identifiers = new ArrayList<PatientIdentifierType>();
 
     private List<PatientAttribute> attributes = new ArrayList<PatientAttribute>();
 
     private List<String> fixedAttributes = new ArrayList<String>();
 
-    private List<DataElement> dataElements = new ArrayList<DataElement>();
+    private List<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>();
 
     private Set<OrganisationUnit> organisationUnits;
 
@@ -128,16 +125,6 @@
         this.endDate = endDate;
     }
 
-    public ProgramStage getProgramStage()
-    {
-        return programStage;
-    }
-
-    public void setProgramStage( ProgramStage programStage )
-    {
-        this.programStage = programStage;
-    }
-
     public Set<OrganisationUnit> getOrganisationUnits()
     {
         return organisationUnits;
@@ -178,14 +165,14 @@
         this.fixedAttributes = fixedAttributes;
     }
 
-    public List<DataElement> getDataElements()
+    public List<ProgramStageDataElement> getProgramStageDataElements()
     {
-        return dataElements;
+        return programStageDataElements;
     }
 
-    public void setDataElements( List<DataElement> dataElements )
+    public void setProgramStageDataElements( List<ProgramStageDataElement> programStageDataElements )
     {
-        this.dataElements = dataElements;
+        this.programStageDataElements = programStageDataElements;
     }
 
     public int getLevel()

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-06-12 03:38:24 +0000
@@ -115,7 +115,8 @@
         executeSql( "UPDATE patientdatavalue SET providedElsewhere=false WHERE providedElsewhere is null" );
         executeSql( "ALTER TABLE programstageinstance DROP COLUMN providedbyanotherfacility" );
 
-        updateTabularReportTable();
+        updateMultiOrgunitTabularReportTable();
+        updateProgramStageTabularReportTable();
     }
 
     // -------------------------------------------------------------------------
@@ -125,7 +126,7 @@
     private void updateProgramStageInstanceOrgunit()
     {
         StatementHolder holder = statementManager.getHolder();
-
+        
         try
         {
             Statement statement = holder.getStatement();
@@ -218,7 +219,7 @@
         }
     }
 
-    private void updateTabularReportTable()
+    private void updateMultiOrgunitTabularReportTable()
     {
         try
         {
@@ -233,15 +234,41 @@
             {
                 executeSql( " INSERT INTO patienttabularreport_organisationUnits ( patienttabularreportid, organisationunitid ) VALUES ( " + resultSet.getInt( 1 ) + ", " + resultSet.getInt( 2 ) + ")" );
             }
-            
             executeSql( "ALTER TABLE patienttabularreport DROP COLUMN organisationunitid" );
         }
         catch ( Exception e )
         {
-            e.printStackTrace();
-        }
-    }
-
+           
+        }
+    }
+
+    private void updateProgramStageTabularReportTable()
+    {
+        try
+        {
+            StatementHolder holder = statementManager.getHolder();
+
+            Statement statement = holder.getStatement();
+
+            ResultSet resultSet = statement
+                .executeQuery( "SELECT pd.patienttabularreportid, tr.programstageid, pd.elt, sort_order "
+                                + " FROM patienttabularreport_dataelements pd inner join patienttabularreport  tr"
+                                + " on pd.patienttabularreportid=tr.patienttabularreportid"
+                                + " order by pd.patienttabularreportid" );
+
+            while ( resultSet.next() )
+            {
+                executeSql( "INSERT INTO patienttabularreport_programstagedataelements ( patienttabularreportid, programstageid, dataelementid, sort_order ) VALUES ( " + resultSet.getInt( 1 ) + ", " + resultSet.getInt( 2 ) + ", " + resultSet.getInt( 3 ) + ", " + resultSet.getInt( 4 ) + ")" );
+            }
+            executeSql( "ALTER TABLE patienttabularreport DROP COLUMN programstageid" );
+            executeSql( "DROP TABLE patienttabularreport_dataelements" );
+        }
+        catch ( Exception e )
+        {
+           
+        }
+    }
+    
     private int executeSql( String sql )
     {
         try

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml	2012-06-12 03:38:24 +0000
@@ -18,10 +18,7 @@
 		<property name="startDate" />
 
 		<property name="endDate" />
-
-		<many-to-one name="programStage" class="org.hisp.dhis.program.ProgramStage"
-			column="programstageid" foreign-key="fk_patienttabularreport_programstageid" />
-
+		
 		<list name="identifiers"
 			table="patienttabularreport_identifiers">
 			<key column="patienttabularreportid" />
@@ -42,13 +39,16 @@
 			<list-index column="sort_order" />
 			<element type="text" column="fixedAttribute" />
 		</list>
-
-		<list name="dataElements"
-			table="patienttabularreport_dataelements">
+    
+		<list name="programStageDataElements"
+			table="patienttabularreport_programstagedataelements">
 			<key column="patienttabularreportid" />
 			<list-index column="sort_order" base="0" />
-			<many-to-many class="org.hisp.dhis.dataelement.DataElement"
-				foreign-key="patienttabularreport_dataelementid" />
+			<many-to-many class="org.hisp.dhis.program.ProgramStageDataElement"
+				foreign-key="patienttabularreport_programstagedataelementid" >
+				  <column name="programstageid" />
+       			  <column name="dataelementid" />
+			</many-to-many>
 		</list>
 		
 	 	<set name="organisationUnits" table="patienttabularreport_organisationUnits">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularReportAction.java	2012-05-09 08:30:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularReportAction.java	2012-06-12 03:38:24 +0000
@@ -29,6 +29,7 @@
 
 import org.hisp.dhis.patientreport.PatientTabularReport;
 import org.hisp.dhis.patientreport.PatientTabularReportService;
+import org.hisp.dhis.program.ProgramStage;
 
 import com.opensymphony.xwork2.Action;
 
@@ -69,6 +70,13 @@
         return tabularReport;
     }
 
+    private ProgramStage programStage;
+
+    public ProgramStage getProgramStage()
+    {
+        return programStage;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -78,8 +86,13 @@
         throws Exception
     {
         tabularReport = tabularReportService.getPatientTabularReport( id );
-        
+
+        if ( tabularReport.getProgramStageDataElements() != null
+            && tabularReport.getProgramStageDataElements().size() > 0 )
+        {
+            programStage = tabularReport.getProgramStageDataElements().get( 0 ).getProgramStage();
+        }
+
         return SUCCESS;
     }
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.java	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.java	2012-06-12 03:38:24 +0000
@@ -50,6 +50,8 @@
 import org.hisp.dhis.patientreport.PatientTabularReport;
 import org.hisp.dhis.patientreport.PatientTabularReportService;
 import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageDataElement;
+import org.hisp.dhis.program.ProgramStageDataElementService;
 import org.hisp.dhis.program.ProgramStageService;
 import org.hisp.dhis.user.CurrentUserService;
 
@@ -116,6 +118,13 @@
         this.currentUserService = currentUserService;
     }
 
+    private ProgramStageDataElementService programStageDataElementService;
+
+    public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService )
+    {
+        this.programStageDataElementService = programStageDataElementService;
+    }
+
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -213,7 +222,6 @@
         PatientTabularReport tabularReport = new PatientTabularReport( name );
         tabularReport.setStartDate( format.parseDate( startDate ) );
         tabularReport.setEndDate( format.parseDate( endDate ) );
-        tabularReport.setProgramStage( programStage );
         tabularReport.setOrganisationUnits( orgunits );
         tabularReport.setLevel( level );
         tabularReport.setFacilityLB( facilityLB );
@@ -228,7 +236,7 @@
 
         List<PatientAttribute> attributes = new ArrayList<PatientAttribute>();
 
-        List<DataElement> dataElements = new ArrayList<DataElement>();
+        List<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>();
         List<String> fixedAttributes = new ArrayList<String>();
 
         for ( String searchingValue : searchingValues )
@@ -254,14 +262,14 @@
             {
                 int objectId = Integer.parseInt( infor[1] );
                 DataElement dataElement = dataElementService.getDataElement( objectId );
-                dataElements.add( dataElement );
+                programStageDataElements.add( programStageDataElementService.get( programStage, dataElement ) );
             }
         }
 
         tabularReport.setFixedAttributes( fixedAttributes );
         tabularReport.setIdentifiers( identifiers );
         tabularReport.setAttributes( attributes );
-        tabularReport.setDataElements( dataElements );
+        tabularReport.setProgramStageDataElements( programStageDataElements );
 
         tabularReportService.saveOrUpdate( tabularReport );
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-06-12 03:38:24 +0000
@@ -892,6 +892,8 @@
 			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		<property name="patientAttributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="programStageDataElementService"
+			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 	</bean>
 	
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-06-12 03:38:24 +0000
@@ -355,4 +355,5 @@
 on = On
 clear_filter = Clear filter
 events = Events
-orgunit_groups = Groups
\ No newline at end of file
+orgunit_groups = Groups
+not_empty = The value must be not empty.
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-06-11 08:53:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-06-12 03:38:24 +0000
@@ -528,7 +528,7 @@
 							TR.store.dataelement.selected.removeAll();
 							if (f.dataElements) {
 								for (var i = 0; i < f.dataElements.length; i++) {
-									TR.cmp.params.dataelement.objects.push({id: f.dataElements[i].id, name: TR.util.string.getEncodedString(f.dataElements[i].name), valueType:f.dataElements[i].valueType });
+									TR.cmp.params.dataelement.objects.push({id: f.dataElements[i].id, name: TR.util.string.getEncodedString(f.dataElements[i].name), compulsory: f.dataElements[i].compulsory, valueType:f.dataElements[i].valueType });
 								}
 								TR.store.dataelement.selected.add(TR.cmp.params.dataelement.objects);
 								
@@ -652,7 +652,7 @@
 		}),
 		dataelement: {
             available: Ext.create('Ext.data.Store', {
-                fields: ['id', 'name', 'valueType'],
+                fields: ['id', 'name', 'compulsory', 'valueType'],
                 proxy: {
                     type: 'ajax',
                     url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.dataelements_get,
@@ -672,7 +672,7 @@
 				}
             }),
             selected: Ext.create('Ext.data.Store', {
-                fields: ['id', 'name', 'valueType'],
+                fields: ['id', 'name', 'compulsory', 'valueType'],
                 data: []
             })
         },
@@ -1169,6 +1169,8 @@
 				menuDisabled: true
 			};
 			
+			// report date
+			
 			cols[++index] = {
 				header: TR.value.columns[index].name, 
 				dataIndex: 'col' + index,
@@ -1223,7 +1225,7 @@
 			// Data element columns
 			
 			TR.cmp.params.dataelement.selected.store.each( function(r) {
-				cols[++index] = TR.datatable.createColumn( r.data.valueType, r.data.id, cols, index );
+				cols[++index] = TR.datatable.createColumn( r.data.valueType, r.data.id, r.data.compulsory, cols, index );
 			});
 			
 			cols[++index]={
@@ -1400,19 +1402,9 @@
 						
 						var oldValue = e.originalValue;
 						var newValue = editor.editors.items[0].field.rawValue;
-						if( newValue != oldValue)
-						{
-							// filter
-							if( e.rowIdx==0 ){
-								TR.exe.execute();
-							}
-							// save data-value of data element
-							else{
-								var psiId = TR.store.datatable.getAt(e.rowIdx).data['id'];
-								var deId = e.column.name.split('_')[1];
-								TR.value.save( psiId, deId, newValue);
-							}
-						}
+						var psiId = TR.store.datatable.getAt(e.rowIdx).data['id'];
+						var deId = e.column.name.split('_')[1];
+						TR.value.save( psiId, deId, newValue);
 					},
 					canceledit: function( grid, eOpts ){
 						if( e.rowIdx == 0 ){
@@ -1422,12 +1414,26 @@
 					},
 					validateedit: function( editor, e, eOpts )
 					{
+						var newValue = editor.editors.items[0].field.rawValue;
+						if( e.column.compulsory && newValue =='' )
+						{
+							TR.util.notification.error( TR.i18n.not_empty, TR.i18n.not_empty );
+							return false;
+						}
+						
+						var oldValue = e.originalValue;
+						if( newValue == oldValue)
+						{
+							return false;
+						}
+						
 						return true;
 					}
 				}
 			});
+			
 		},
-		createColumn: function( type, id, cols, index )
+		createColumn: function( type, id, compulsory, cols, index )
 		{
 			if( type.toLowerCase() == 'date' )
 			{
@@ -1440,6 +1446,7 @@
 					sortable: false,
 					draggable: true,
 					isEditAllowed: true,
+					compulsory: compulsory,
 					renderer: Ext.util.Format.dateRenderer( TR.i18n.format_date ),
 					filter: {
 						type:TR.value.covertValueType( type ),
@@ -1473,6 +1480,7 @@
 				sortable: false,
 				draggable: true,
 				isEditAllowed: true,
+				compulsory: compulsory,
 				filter: {
 					type:TR.value.covertValueType( type ),
 					options: TR.value.columns[index].suggested

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2012-06-12 03:38:24 +0000
@@ -81,5 +81,6 @@
 after:'$encoder.jsEscape($i18n.getString( 'after' ) , "'")',
 on:'$encoder.jsEscape($i18n.getString( 'on' ) , "'")',
 orgunit_groups:'$encoder.jsEscape($i18n.getString( 'orgunit_groups' ) , "'")',
-none: '[' + '$encoder.jsEscape($i18n.getString( 'none' ) , "'")' + ']'
+none:'[' + '$encoder.jsEscape($i18n.getString( 'none' ) , "'")' + ']',
+not_empty:'$encoder.jsEscape($i18n.getString( 'not_empty' ) , "'")'
 };
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm	2012-06-12 03:38:24 +0000
@@ -12,7 +12,6 @@
 		"$!{rootNode.id}",
 		"$!encoder.jsonEncode(${rootNode.name})"
 	],
-	
 	"programs": [
 		#foreach( $program in $programs )
 		  {
@@ -22,7 +21,6 @@
 		  }#if( $velocityCount < $programs.size() ),#end
 		#end
 	],
-	
 	"orgunitGroups": [
 		#foreach( $orgunitGroup in $orgunitGroups )
 		  {
@@ -31,7 +29,6 @@
 		  }#if($velocityCount < $orgunitGroups.size()),#end
 		#end
 	],
-	
 	"levels": [
 		#foreach( $level in $levels )
 		  {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm	2012-06-12 03:38:24 +0000
@@ -2,16 +2,16 @@
 	"id": "${tabularReport.id}",
 	"name": "$!encoder.jsonEncode( ${tabularReport.name} )",
 	"lastUpdated": "$!format.formatDate( ${tabularReport.lastUpdated} )",
-	"programId": "${tabularReport.programStage.program.id}",
+	"programId": "${programStage.program.id}",
 	"singleEvent": 
-		#if($tabularReport.programStage.program.programStages.size() == 1 )
+		#if($programStage.program.programStages.size() == 1 )
 			"true",
 		#else
 			"false",
 		#end
-	"type": "${tabularReport.programStage.program.type}",
-	"programStageId": "${tabularReport.programStage.id}",
-	"programStageName": "${tabularReport.programStage.name}",
+	"type": "${programStage.program.type}",
+	"programStageId": "${programStage.id}",
+	"programStageName": "${programStage.name}",
 	"startDate": "$!format.formatDate( $tabularReport.startDate )",
 	"endDate": "$!format.formatDate( ${tabularReport.endDate} )",
 	"level": "${tabularReport.level}",
@@ -60,16 +60,17 @@
 		#end
 	],
 	"dataElements": [
-		#set( $size = ${tabularReport.dataElements.size()} )
-		#set( $dataElements = ${tabularReport.dataElements} )
-		#foreach( ${dataElement} in $!{dataElements} )
+		#set( $size = ${tabularReport.programStageDataElements.size()} )
+		#set( $programStageDataElements = ${tabularReport.programStageDataElements} )
+		#foreach( ${programStageDataElement} in $!{programStageDataElements} )
 			{
-				"id": "de_${dataElement.id}",
-				"name": "${dataElement.name}",
-				"valueType": #if( $dataElement.optionSet )
+				"id": "de_${programStageDataElement.dataElement.id}",
+				"name": "${programStageDataElement.dataElement.name}",
+				"compulsory": "${programStageDataElement.compulsory}",
+				"valueType": #if( $programStageDataElement.dataElement.optionSet )
 								"list"
 							 #else
-								"${dataElement.type}"
+								"${programStageDataElement.dataElement.type}"
 							 #end
 			}
 			#if( $velocityCount < $size ),#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm	2012-06-12 03:38:24 +0000
@@ -4,6 +4,7 @@
   {
     "id": "de_$!{psDataElement.dataElement.id}",
     "name": "$encoder.xmlEncode(${psDataElement.dataElement.displayName} )",
+	"compulsory": "${psDataElement.compulsory}",
 	"valueType": #if( $psDataElement.dataElement.optionSet )
 					"list"
 				 #else