← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10354: Fix bugs in Assign userroles to program; display section entry form for single event with registr...

 

------------------------------------------------------------
revno: 10354
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-03-20 20:45:53 +0700
message:
  Fix bugs in Assign userroles to program; display section entry form for single event with registration; Round off values of aggregate result in tabular report; small fix for program enrollment validation.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleDataEntryForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUserrole.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-03-15 13:36:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-03-20 13:45:53 +0000
@@ -675,7 +675,7 @@
             sql = getAggregateReportSQL8( programStage, orgunitIds, facilityLB, filterSQL, deGroupBy, periods
                 .iterator().next(), aggregateType, limit, useCompletedEvents, format );
         }
-        
+
         if ( !sql.isEmpty() )
         {
             SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
@@ -685,11 +685,11 @@
                 || position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_ORGUNIT
                 || (position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_PERIOD && deGroupBy == null) )
             {
-                pivotTable( grid, rowSet, i18n );
+                pivotTable( grid, rowSet, i18n, format );
             }
             else
             {
-                fillDataInGrid( grid, rowSet, i18n );
+                fillDataInGrid( grid, rowSet, i18n, format );
             }
         }
 
@@ -1021,7 +1021,7 @@
         sql += where; // filters
         sql = sql.substring( 0, sql.length() - 1 ) + " "; // Remove last comma
         sql += (min != null && max != null) ? statementBuilder.limitRecord( min, max ) : "";
-        
+
         return sql;
     }
 
@@ -1861,10 +1861,10 @@
                     String operator = (filterValue.substring( 0, index ));
                     String value = filterValue.substring( index + 1, filterValue.length() );
                     filter += "AND (SELECT ";
-                    if( dataElement.getType().equals( DataElement.VALUE_TYPE_INT ) )
+                    if ( dataElement.getType().equals( DataElement.VALUE_TYPE_INT ) )
                     {
-                        filter += "cast(value as " + statementBuilder.getDoubleColumnType()+ ") ";
-                        
+                        filter += "cast(value as " + statementBuilder.getDoubleColumnType() + ") ";
+
                     }
                     else
                     {
@@ -1988,7 +1988,7 @@
         return orgunitIds;
     }
 
-    private void fillDataInGrid( Grid grid, SqlRowSet rs, I18n i18n )
+    private void fillDataInGrid( Grid grid, SqlRowSet rs, I18n i18n, I18nFormat format )
     {
         int cols = rs.getMetaData().getColumnCount();
         int dataCols = 0;
@@ -2028,29 +2028,14 @@
                     double value = rs.getDouble( i );
                     sumRow[i] += value;
                     total += value;
-
-                    if ( value == (int) value )
-                    {
-                        grid.addValue( (int) value );
-                    }
-                    else
-                    {
-                        grid.addValue( value );
-                    }
+                    grid.addValue( format.formatValue( value ) );
                 }
             }
 
             // total
             if ( dataCols > 1 )
             {
-                if ( total == (int) total )
-                {
-                    grid.addValue( (int) total );
-                }
-                else
-                {
-                    grid.addValue( total );
-                }
+                grid.addValue( format.formatValue( total ));
             }
         }
 
@@ -2062,31 +2047,18 @@
             int total = 0;
             for ( int i = cols - dataCols + 1; i <= cols; i++ )
             {
-                if ( sumRow[i] == (int) sumRow[i] )
-                {
-                    grid.addValue( (int) sumRow[i] );
-                }
-                else
-                {
-                    grid.addValue( sumRow[i] );
-                }
+                    grid.addValue( format.formatValue(sumRow[i] ));
+                
                 total += sumRow[i];
             }
             if ( cols > cols - dataCols + 1 )
             {
-                if ( total == (int) total )
-                {
-                    grid.addValue( (int) total );
-                }
-                else
-                {
-                    grid.addValue( total );
-                }
+                grid.addValue( format.formatValue( total ));
             }
         }
     }
 
-    private void pivotTable( Grid grid, SqlRowSet rowSet, I18n i18n )
+    private void pivotTable( Grid grid, SqlRowSet rowSet, I18n i18n, I18nFormat format )
     {
         try
         {
@@ -2120,14 +2092,7 @@
                 // Add total value of the column
                 if ( cols > 2 )
                 {
-                    if ( total == (int) total )
-                    {
-                        column.add( (int) total );
-                    }
-                    else
-                    {
-                        column.add( total );
-                    }
+                    grid.addValue( format.formatValue( total ));
                 }
 
                 columnValues.put( index, column );
@@ -2176,26 +2141,13 @@
                             total += (Long) columnValues.get( i ).get( j );
                         }
                     }
-                    if ( total == (int) total )
-                    {
-                        column.add( (int) total );
-                    }
-                    else
-                    {
-                        column.add( total );
-                    }
+                       column.add( format.formatValue( total ) );
+                    
                     allTotal += total;
                 }
                 if ( cols > 2 )
                 {
-                    if ( allTotal == (int) allTotal )
-                    {
-                        column.add( (int) allTotal );
-                    }
-                    else
-                    {
-                        column.add( allTotal );
-                    }
+                        column.add(format.formatValue(allTotal ));
                 }
                 grid.addColumn( column );
             }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientProgramEnrollmentAction.java	2012-12-27 05:20:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientProgramEnrollmentAction.java	2013-03-20 13:45:53 +0000
@@ -28,7 +28,6 @@
 package org.hisp.dhis.caseentry.action.patient;
 
 import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.program.Program;
@@ -62,13 +61,6 @@
         this.programService = programService;
     }
 
-    private I18nFormat format;
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -116,29 +108,10 @@
 
         if ( criteria != null )
         {
-            message = i18n.getString( "patient_could_not_be_enrolled_due_to_following_enrollment_criteria" ) + ": " + i18n.getString( criteria.getProperty() );
-            
-            switch ( criteria.getOperator() )
-            {
-            case ValidationCriteria.OPERATOR_EQUAL_TO:
-                message += " = ";
-                break;
-            case ValidationCriteria.OPERATOR_GREATER_THAN:
-                message += " > ";
-                break;
-            default:
-                message += " < ";
-                break;
-            }
+            message = i18n.getString( "patient_could_not_be_enrolled_due_to_following_enrollment_criteria" ) + ": ";
 
-            if ( criteria.getProperty() == "birthDate" )
-            {
-                message += " " + format.formatValue( criteria.getValue() );
-            }
-            else
-            {
-                message += " " + criteria.getValue().toString();
-            }
+            message += (criteria.getDescription() != null && !criteria.getDescription().isEmpty()) ? criteria
+                .getDescription() : criteria.getDisplayName();
 
             return INPUT;
         }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleDataEntryForm.vm	2013-02-18 09:50:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleDataEntryForm.vm	2013-03-20 13:45:53 +0000
@@ -1,6 +1,150 @@
+#set( $sections = $programStage.programStageSections )
+#set( $program = $programStage.program )
+
 #if( $customDataEntryFormCode )
 	$customDataEntryFormCode
+#elseif( $sections && $sections.size() > 0 )
+	
+	<tr>
+		<th colspan='2'>$programStage.program.displayName</th>
+	</tr>
+	<!-- Identifiers/Attributes belong to the selected single program -->
+	#set($program = $programStage.program)
+	#parse( "/dhis-web-caseentry/identifierAndAttributeForm.vm" )
+	
+	</table>
+	
+<div id="entryForm">
+
+<!-- SECTIONS -->
+
+#foreach( $section in $sections )
+	<table class="formSection" width='80%'>
+		<tr>
+		  <td class='entryScreen'>
+			<div class="cent"><h3>$encoder.htmlEncode( $section.displayName )</h3></div>
+		  </td>
+		</tr>
+		<tr>
+			<td width='100%'>
+				<div id='div_$section.id' class='entryScreen'>
+					<table width='100%'>
+						<colgroup>
+							<col id="deCol">
+							<col id="entryCol">
+							#if( $programStage.program.displayProvidedOtherFacility=='true')
+							<col width="5%" />
+							#end
+						</colgroup>
+					
+						<thead>
+						<tr>
+							<td>
+								<input type="text" class="sectionFilter" placeholder="$encoder.jsEscape( $i18n.getString( "filter_in_section" ) , "'")" onkeyup="filterInSection($(this));" >
+							</td>                   
+							<th>$i18n.getString( "value" )</th>
+							#if( $programStage.program.displayProvidedOtherFacility=='true')
+							<th>$i18n.getString( "provided_elsewhere" )</th>
+							#end
+						</tr>
+						</thead>
+						#set( $dataElementRowCount = 0 )
+						#set( $mark = true )
+						#set( $tabIndex = 1 )
+						#foreach( $programStageDataElement in $section.programStageDataElements )
+									#set( $dataElementRowCount = $dataElementRowCount + 1 )    
+									#set( $mark = !$mark )
+									#set( $patientDataValue = false )
+									#set( $key = $programStageDataElement.dataElement.id )
+									#set( $patientDataValue = $patientDataValueMap.get( $key ) )    
+									<tr #alternate( $mark )>
+										##data element name
+										<td id="$key-cell" class='text-column' align='center'>
+											<span id="$key-dataelement">${encoder.htmlEncode( $programStageDataElement.dataElement.getFormNameFallback() )}</span>
+												#if ( $programStageDataElement.compulsory )
+													<em title="$i18n.getString( "required" )" class="required">*</em>
+												#end        
+											</span>
+											##type        
+											<span id="value[$programStageDataElement.dataElement.id].type" class="hidden">$encoder.htmlEncode( $programStageDataElement.dataElement.type )</span></td>       
+										</td>        
+										##entry        
+										<td class='input-column'>   
+											#set( $id = $programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val' )
+											#if( $!programStageDataElement.dataElement.optionSet )
+												#set($hasOptionSet = 'true')
+											#else
+												#set($hasOptionSet = 'false')
+											#end
+											
+											#set($type=$programStageDataElement.dataElement.getDetailedNumberType())
+											#set($validate = '')
+											#if( $type=='number' ) 
+												#set($validate="number:true") 
+											#elseif( $type=='positiveNumber' )
+												#set($validate="positive_integer:true") 
+											#elseif( $type=='negativeNumber' )
+												#set($validate="negative_integer:true")
+											#elseif( $type=='int' )
+												#set($validate="integer:true")
+											#end
+			
+											#if($programStageDataElement.compulsory=='true')
+												#if($validate != '')
+													#set($validate=$validate + ",")
+												#end
+												#set($validate=$validate + "required:true")
+											#end
+												
+											#if( $programStageDataElement.dataElement.textType == "longText" )
+												<textarea name="entryfield" type="text" id="$id" maxlength=255 class="{validate:{$validate}}" >$!encoder.htmlEncode( $patientDataValue.value )</textarea>
+											#elseif( $programStageDataElement.dataElement.type == "bool" )
+												<select name="entryfield" id="$id" class="{validate:{$validate}}" >
+													<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 == "trueOnly" )
+												<input name="entryfield" type="checkbox" id="$id" class="{validate:{$validate}}" >
+											#elseif( $programStageDataElement.dataElement.type == "date" )
+												<input name="entryfield" class='datefield' type="text" id="$id" name="entryfield" value="$!encoder.htmlEncode( $patientDataValue.value )"class="{validate:{$validate}}">
+												<script type="text/javascript">
+													datePicker( $programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val', false, false);
+												</script> 
+											#elseif($hasOptionSet=='true')
+												<input name="entryfield" options='$hasOptionSet' id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" class="option {validate:{$validate}}" />
+											#elseif($programStageDataElement.dataElement.type=='username')
+												<input name="entryfield" username='true' class="auto-field optionset" dataElementId='$programStageDataElement.dataElement.id' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" />
+											#else
+												<input name="entryfield" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" class="{validate:{$validate}}" />
+											#end
+											</td>
+											
+										<td>
+										#if( $programStage.program.displayProvidedOtherFacility=='true' )
+											#set( $id = $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' )
+											#if( $programStageDataElement.allowProvidedElsewhere == 'true')
+												<input class='provided-elsewhere' name="$id" id="$id" type="checkbox" title="$i18n.getString('provided_elsewhere') ?"/>
+											#else
+												<input class='provided-elsewhere' name="$id" id="$id" type="hidden" value="false";>
+											#end
+										#end
+										</td>
+								</tr>
+							#set( $tabIndex = $tabIndex + 1 )
+							#end
+						</table>
+					</div>
+				</td>
+		  </tr>
+	</table>
+#end
+</tbody>
+
+</div>
 #else
+<!-- DEFAULT -->
+
 <tbody id="entryForm">
 	<tr>
 		<th colspan='2'>$programStage.program.displayName</th>
@@ -31,7 +175,7 @@
 		</td>        
 		##entry        
 		<td class='input-column'>   
-			#set( $id = "DE_" + $programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val' )
+			#set( $id = $programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val' )
 			#if( $!programStageDataElement.dataElement.optionSet )
 				#set($hasOptionSet = 'true')
 			#else
@@ -68,17 +212,19 @@
 			#elseif( $programStageDataElement.dataElement.type == "trueOnly" )
 				<input name="entryfield" type="checkbox" id="$id" class="{validate:{$validate}}" >
 			#elseif( $programStageDataElement.dataElement.type == "date" )
-				<input name="entryfield" type="text" id="$id" name="entryfield" value="$!encoder.htmlEncode( $patientDataValue.value )"class="{validate:{$validate}}">
+				<input name="entryfield" class='datefield' type="text" id="$id" name="entryfield" value="$!encoder.htmlEncode( $patientDataValue.value )"class="{validate:{$validate}}">
 				<script type="text/javascript">
-					datePicker("DE_" +  $programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val', false);
+					datePicker( $programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val', false, false);
 				</script> 
 			#elseif($hasOptionSet=='true')
 				<input name="entryfield" options='$hasOptionSet' id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" class="option {validate:{$validate}}" />
+			#elseif($programStageDataElement.dataElement.type=='username')
+				<input name="entryfield" username='true' class="auto-field optionset" dataElementId='$programStageDataElement.dataElement.id' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" />
 			#else
 				<input name="entryfield" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" class="{validate:{$validate}}" />
 			#end
 			#if( $programStage.program.displayProvidedOtherFacility=='true' )
-				#set( $id = "DE_" + $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' )
+				#set( $id = $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' )
 				#if( $programStageDataElement.allowProvidedElsewhere == 'true')
 					<input class='provided-elsewhere' name="$id" id="$id" type="checkbox" title="$i18n.getString('provided_elsewhere') ?"/>
 				#else

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css	2013-03-18 07:22:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css	2013-03-20 13:45:53 +0000
@@ -41,7 +41,7 @@
 
 input.option
 {
-    width: 235px;
+    width: 240px;
 }
 
 select 
@@ -192,10 +192,9 @@
 
 input.optionset[type="text"]
 {
-	width:230px; 
+	width:240px; 
 }
 
-
 input.datefield[type="text"]
 {
 	width:240px; 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUserrole.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUserrole.vm	2013-02-20 15:10:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUserrole.vm	2013-03-20 13:45:53 +0000
@@ -2,7 +2,7 @@
 
 <h4>$program.displayName</h4>
 
-<form name="userRole" action="defineProgramUserrole.action" method="POST" onsubmit="selectAllById( 'selectedList' );">
+<form name="userRole" action="defineProgramUserrole.action" method="POST" onsubmit="selectAllById( 'userRoleIds' );">
 <input type="hidden" name="id" value="$program.id"/>
 <table>
 	<tr>