← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5688: Don't save data-values in anonymous entry form ( Patient module).

 

------------------------------------------------------------
revno: 5688
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-01-11 12:01:23 +0700
message:
  Don't save data-values in anonymous entry form ( Patient module).
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageDataElementSortOrderComparator.java
  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/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.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-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageDataElementSortOrderComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageDataElementSortOrderComparator.java	2012-01-11 03:37:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageDataElementSortOrderComparator.java	2012-01-11 05:01:23 +0000
@@ -34,25 +34,14 @@
 public class ProgramStageDataElementSortOrderComparator
     implements Comparator<ProgramStageDataElement>
 {
-
     @Override
-    public int compare( ProgramStageDataElement programStageDataElement0,
-        ProgramStageDataElement programStageDataElement1 )
+    public int compare( ProgramStageDataElement object0, ProgramStageDataElement object1 )
     {
-        if ( programStageDataElement0.getDataElement().getSortOrder() == null
-            || programStageDataElement0.getDataElement().getSortOrder() == 0 )
-        {
-            return programStageDataElement0.getDataElement().getName()
-                .compareTo( programStageDataElement1.getDataElement().getName() );
-        }
-        if ( programStageDataElement1.getDataElement().getSortOrder() == null
-            || programStageDataElement1.getDataElement().getSortOrder() == 0 )
-        {
-            return programStageDataElement0.getDataElement().getName()
-                .compareTo( programStageDataElement1.getDataElement().getName() );
-        }
-        return programStageDataElement0.getDataElement().getSortOrder()
-            - programStageDataElement1.getDataElement().getSortOrder();
+        if ( object0.getDataElement().getSortOrder() == null ) 
+        {
+            return object1.getDataElement().getSortOrder() != null ? -1 : 0;
+        }
+        
+        return object0.getDataElement().getSortOrder().compareTo( object1.getDataElement().getSortOrder() );
     }
-
 }

=== 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	2011-10-07 03:12:16 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2012-01-11 05:01:23 +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,16 +1336,20 @@
      * @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() )
         {
             appendCode += " checked=\"checked\" ";
         }
         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-06 04:56:54 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-01-11 05:01:23 +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/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java	2012-01-11 05:01:23 +0000
@@ -129,6 +129,7 @@
             programStageInstance.setStageInProgram( programInstance.getProgramStageInstances().size() + 1 );
             programStageInstance.setDueDate( date );
             programStageInstance.setExecutionDate( date );
+            programStageInstance.setCompleted( false );
 
             programStageInstanceService.addProgramStageInstance( programStageInstance );
             

=== 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 03:37:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-01-11 05:01:23 +0000
@@ -40,7 +40,9 @@
 		   $customDataEntryFormCode
 
 			<script type="text/javascript"> 
-				initCustomCheckboxes();
+				#if( $!programStageInstance.programStage.program.anonymous == 'false' )
+					initCustomCheckboxes();
+				#end
 			</script>
 		</div>
 	#else
@@ -50,12 +52,16 @@
 				<col id="noCol">
 				<col id="deCol">    
 				<col id="entryCol">
+				#if( $programStageInstance.programInstance.program.anonymous == 'false' )
 				<col id="facilityCol">       
+				#end
 				<tr>
 					<th>$i18n.getString( "nr" )</th>
 					<th>$i18n.getString( "data_element" )</th>                   
 					<th>$i18n.getString( "entry" )</th>
-					<th>$i18n.getString( "provided_elsewhere" )</th>             
+					#if( $programStageInstance.programInstance.program.anonymous == 'false' )
+					<th>$i18n.getString( "provided_elsewhere" )</th>   
+					#end
 				</tr>
 			#set( $dataElementRowCount = 0 )
 			#set( $mark = 0 )
@@ -114,9 +120,11 @@
 							#end
 						#end
 					</td>   
-					##providedByAnotherFacility                
+					
+					#set( $id = $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' )
+					##providedByAnotherFacility   
+					#if( $programStageInstance.programInstance.program.anonymous == 'false' )
 					<td>   
-						#set( $id = $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' )
 						#if ( $patientDataValue.value )        
 							#if( !$patientDataValue.providedByAnotherFacility )
 								$patientDataValue.organisationUnit.name
@@ -130,6 +138,9 @@
 						 #end                         
 					</td>    
 				</tr>
+				#else
+					<input name="providedByAnotherFacility" id="$id" type="hidden">
+				#end
 				#set( $tabIndex = $tabIndex + 1 )
 			#end
 			</table>