← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5692: Don't save data-values in anonymous entry form.

 

------------------------------------------------------------
revno: 5692
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-01-11 13:17:35 +0700
message:
  Don't save data-values in anonymous entry form.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
  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/webapp/dhis-web-caseentry/dataEntryForm.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/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2012-01-11 05:31:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2012-01-11 06:17:35 +0000
@@ -539,7 +539,7 @@
                     // Add ProvidedByOtherFacility checkbox
                     // -----------------------------------------------------------
 
-                    appendCode = addProvidedByOtherFacilityCheckbox( appendCode, patientDataValue );
+                    appendCode = addProvidedByOtherFacilityCheckbox( appendCode, patientDataValue, programStage );
                 }
                 else
                 {
@@ -770,7 +770,7 @@
                     // Add ProvidedByOtherFacility checkbox
                     // -----------------------------------------------------------
 
-                    appendCode = addProvidedByOtherFacilityCheckbox( appendCode, patientDataValue );
+                    appendCode = addProvidedByOtherFacilityCheckbox( appendCode, patientDataValue, programStage );
                 }
 
                 // -----------------------------------------------------------
@@ -994,7 +994,7 @@
                     // Add ProvidedByOtherFacility checkbox
                     // -----------------------------------------------------------
 
-                    appendCode = addProvidedByOtherFacilityCheckbox( appendCode, patientDataValue );
+                    appendCode = addProvidedByOtherFacilityCheckbox( appendCode, patientDataValue, programStage );
                 }
 
                 // -----------------------------------------------------------
@@ -1223,7 +1223,7 @@
                     // Add ProvidedByOtherFacility checkbox
                     // ---------------------------------------------------------
 
-                    appendCode = addProvidedByOtherFacilityCheckbox( appendCode, patientDataValue );
+                    appendCode = addProvidedByOtherFacilityCheckbox( appendCode, patientDataValue, programStage );
                 }
 
                 // -------------------------------------------------------------
@@ -1336,9 +1336,9 @@
      * @param patientDataValue: currrent PatientDataValue
      * @return full html code after append the check box
      */
-    private String addProvidedByOtherFacilityCheckbox( String appendCode, PatientDataValue patientDataValue )
+    private String addProvidedByOtherFacilityCheckbox( String appendCode, PatientDataValue patientDataValue, ProgramStage programStage )
     {
-        appendCode += "<label for=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\" title=\"is provided by another Facility ?\" ></label><input name=\"providedByAnotherFacility\"  title=\"is provided by another Facility ?\"  id=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\"  type=\"checkbox\" ";
+        appendCode += "<label for=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\" title=\"is provided by another Facility ?\" ></label><input name=\"providedByAnotherFacility\"  title=\"is provided by another Facility ?\"  id=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\"  type=\"checkbox\" style=\"display:$DISPLAY;\" ";
 
         if ( patientDataValue != null && patientDataValue.isProvidedByAnotherFacility() )
         {
@@ -1346,6 +1346,9 @@
         }
         appendCode += "onChange=\"updateProvidingFacility( $DATAELEMENTID, this )\"  >";
 
+        String display = ( programStage.getProgram().getAnonymous() ) ? "none" : "block";  
+        appendCode = appendCode.replace( "$DISPLAY", display );
+        
         return appendCode;
 
     }

=== 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	2012-01-11 05:31:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-01-11 06:17:35 +0000
@@ -32,6 +32,7 @@
 import java.util.List;
 
 import org.hibernate.Query;
+import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.hibernate.HibernateGenericStore;
@@ -55,7 +56,7 @@
     {
         List<ProgramStageInstance> list = new ArrayList<ProgramStageInstance>( getCriteria(
             Restrictions.eq( "programInstance", programInstance ), Restrictions.eq( "programStage", programStage ) )
-            .list() );
+            .addOrder( Order.asc( "id" ) ).list() );
 
         return (list == null) ? null : list.get( list.size() - 1 );
     }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-01-11 05:31:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-01-11 06:17:35 +0000
@@ -40,7 +40,9 @@
 		   $customDataEntryFormCode
 
 			<script type="text/javascript"> 
-				initCustomCheckboxes();
+				#if( $!programStageInstance.programStage.program.anonymous == 'false' )
+					initCustomCheckboxes();
+				#end
 			</script>
 		</div>
 	#else
@@ -119,11 +121,11 @@
 						#end
 					</td>  
 					
+					
+					##providedByAnotherFacility 
+					#set( $id = $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' )
 					#if($programStageInstance.programInstance.program.anonymous == 'false') 					
-					
-					##providedByAnotherFacility                
 					<td>   
-						#set( $id = $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' )
 						#if ( $patientDataValue.value )        
 							#if( !$patientDataValue.providedByAnotherFacility )
 								$patientDataValue.organisationUnit.name
@@ -137,7 +139,9 @@
 						 #end                         
 					</td>
 					
-					#end					
+					#else
+						<input name="providedByAnotherFacility" id="$id" type="hidden">
+                    #end					
 				</tr>
 				#set( $tabIndex = $tabIndex + 1 )
 			#end