← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8588: Don't load single events which person cannot enroll into them in dashboard.

 

------------------------------------------------------------
revno: 8588
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-10-19 14:08:17 +0700
message:
  Don't load single events which person cannot enroll into them in dashboard.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js


--
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/patient/PatientDashboardAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2012-10-18 07:29:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2012-10-19 07:08:17 +0000
@@ -30,6 +30,7 @@
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 import org.hisp.dhis.caseentry.state.SelectedStateManager;
@@ -48,6 +49,7 @@
 import org.hisp.dhis.relationship.Relationship;
 import org.hisp.dhis.relationship.RelationshipService;
 import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.validation.ValidationCriteria;
 
 import com.opensymphony.xwork2.Action;
 
@@ -232,7 +234,18 @@
 
         singlePrograms = programService.getPrograms( Program.SINGLE_EVENT_WITH_REGISTRATION, orgunit );
 
-        singlePrograms.removeAll( patient.getPrograms() );
+        singlePrograms.removeAll( patient.getPrograms() );       
+        Iterator<Program> iter = singlePrograms.iterator();
+        while( iter.hasNext() )
+        {
+            Program program = iter.next();
+            ValidationCriteria criteria = program.isValid( patient );
+
+            if( criteria!= null)
+            {
+                iter.remove();
+            }
+        }
 
         // ---------------------------------------------------------------------
         // Patient-Audit

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-10-19 06:27:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-10-19 07:08:17 +0000
@@ -1208,50 +1208,6 @@
 	}
 }
 
-function saveEnrollment()
-{
-	var patientId = jQuery('#enrollmentDiv [id=patientId]').val();
-	var programId = jQuery('#enrollmentDiv [id=programId] option:selected').val();
-	var programName = jQuery('#enrollmentDiv [id=programId] option:selected').text();
-	var dateOfIncident = jQuery('#enrollmentDiv [id=dateOfIncidentField]').val();
-	var enrollmentDate = jQuery('#enrollmentDiv [id=enrollmentDateField]').val();
-	
-	jQuery.postJSON( "saveProgramEnrollment.action",
-		{
-			patientId: patientId,
-			programId: programId,
-			dateOfIncident: dateOfIncident,
-			enrollmentDate: enrollmentDate
-		}, 
-		function( json ) 
-		{    
-			var programInstanceId = json.programInstanceId;
-			var programStageInstanceId = json.activeProgramStageInstanceId;
-			var programStageName = json.activeProgramStageName;
-			var dueDate = json.dueDate;
-			var type = jQuery('#enrollmentDiv [id=programId] option:selected').attr('programType');
-			
-			var activedRow = "<tr id='tr1_" + programInstanceId 
-							+ "' type='" + type +"'"
-							+ " programStageInstanceId='" + programStageInstanceId + "'>"
-							+ " <td id='td_" + programInstanceId + "'>"
-							+ " <a href='javascript:loadActiveProgramStageRecords(" + programInstanceId + "," + programStageInstanceId + ")'>"
-							+ "<span id='infor_" + programInstanceId + "' class='selected bold'>" 
-							+ programName + " (" + enrollmentDate + ")</span></a></td>"
-							+ "</tr>";
-			
-			activedRow += "<tr id='tr2_" + programInstanceId +"'"+
-						+ " onclick='javascript:loadActiveProgramStageRecords(" + programInstanceId + "," + programStageInstanceId + ")' style='cursor:pointer;'>"
-						+ "<td colspan='2'><a>&#8226; " + programStageName + " (" + dueDate + ")</a></td></tr>";
-
-			jQuery('#activeTB' ).prepend(activedRow);
-			jQuery('#enrollmentDiv').dialog("close");
-			saveIdentifierAndAttribute( patientId, programId,'identifierAndAttributeDiv' );
-			loadActiveProgramStageRecords( programInstanceId );
-			showSuccessMessage(i18n_enrol_success);
-		});
-}
-
 function saveSingleEnrollment(patientId, programId)
 {
 	jQuery.postJSON( "saveProgramEnrollment.action",
@@ -1317,6 +1273,50 @@
     });
 }
 
+function saveEnrollment()
+{
+	var patientId = jQuery('#enrollmentDiv [id=patientId]').val();
+	var programId = jQuery('#enrollmentDiv [id=programId] option:selected').val();
+	var programName = jQuery('#enrollmentDiv [id=programId] option:selected').text();
+	var dateOfIncident = jQuery('#enrollmentDiv [id=dateOfIncidentField]').val();
+	var enrollmentDate = jQuery('#enrollmentDiv [id=enrollmentDateField]').val();
+	
+	jQuery.postJSON( "saveProgramEnrollment.action",
+		{
+			patientId: patientId,
+			programId: programId,
+			dateOfIncident: dateOfIncident,
+			enrollmentDate: enrollmentDate
+		}, 
+		function( json ) 
+		{    
+			var programInstanceId = json.programInstanceId;
+			var programStageInstanceId = json.activeProgramStageInstanceId;
+			var programStageName = json.activeProgramStageName;
+			var dueDate = json.dueDate;
+			var type = jQuery('#enrollmentDiv [id=programId] option:selected').attr('programType');
+			
+			var activedRow = "<tr id='tr1_" + programInstanceId 
+							+ "' type='" + type +"'"
+							+ " programStageInstanceId='" + programStageInstanceId + "'>"
+							+ " <td id='td_" + programInstanceId + "'>"
+							+ " <a href='javascript:loadActiveProgramStageRecords(" + programInstanceId + "," + programStageInstanceId + ")'>"
+							+ "<span id='infor_" + programInstanceId + "' class='selected bold'>" 
+							+ programName + " (" + enrollmentDate + ")</span></a></td>"
+							+ "</tr>";
+			
+			activedRow += "<tr id='tr2_" + programInstanceId +"'"+
+						+ " onclick='javascript:loadActiveProgramStageRecords(" + programInstanceId + "," + programStageInstanceId + ")' style='cursor:pointer;'>"
+						+ "<td colspan='2'><a>&#8226; " + programStageName + " (" + dueDate + ")</a></td></tr>";
+
+			jQuery('#activeTB' ).prepend(activedRow);
+			jQuery('#enrollmentDiv').dialog("close");
+			saveIdentifierAndAttribute( patientId, programId,'identifierAndAttributeDiv' );
+			loadActiveProgramStageRecords( programInstanceId );
+			showSuccessMessage(i18n_enrol_success);
+		});
+}
+
 function unenrollmentForm( programInstanceId )
 {	
 	$.ajax({