← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4828: Modify Enrollment Program form.

 

------------------------------------------------------------
revno: 4828
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-10-05 10:39:54 +0700
message:
  Modify Enrollment Program form.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.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/javascript/patient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.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-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java	2011-10-04 06:28:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java	2011-10-05 03:39:54 +0000
@@ -29,6 +29,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.program.Program;
@@ -61,6 +63,13 @@
         this.programService = programService;
     }
 
+    private OrganisationUnitSelectionManager selectionManager;
+
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+    {
+        this.selectionManager = selectionManager;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -86,6 +95,13 @@
         return programs;
     }
 
+    private Boolean registerEvent;
+
+    public Boolean getRegisterEvent()
+    {
+        return registerEvent;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -95,7 +111,19 @@
     {
         patient = patientService.getPatient( id );
 
-        programs = programService.getAllPrograms();
+        OrganisationUnit selectedOrgunit = selectionManager.getSelectedOrganisationUnit();
+
+        // Get none single-event programs
+        programs = programService.getPrograms( false );
+
+        // Check the selected orgunit has any single-event program or not
+        Collection<Program> programsbyOrgunit = programService.getPrograms( selectedOrgunit );
+
+        Collection<Program> singleEventPrograms = programService.getPrograms( true );
+
+        singleEventPrograms.retainAll( programsbyOrgunit );
+
+        registerEvent = (singleEventPrograms.size() > 0);
 
         return SUCCESS;
     }

=== 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	2011-10-04 06:28:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2011-10-05 03:39:54 +0000
@@ -553,6 +553,7 @@
 		scope="prototype">
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.ProgramEnrollmentAction"

=== 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	2011-10-04 06:28:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2011-10-05 03:39:54 +0000
@@ -432,4 +432,5 @@
 specify_search_criteria											= Please specify search criteria
 patient_profile													= Beneficiary profile
 other_details													= Other details
-register_event													= Register event
\ No newline at end of file
+register_event													= Register event
+enroll_to_program												= Enroll to program
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2011-10-04 06:28:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2011-10-05 03:39:54 +0000
@@ -471,7 +471,8 @@
 	if( programId == 0 )
 	{
 		disable('enrollBtn');
-		disable('registerEventBtn');
+		disable('enrollmentDate');
+		disable('dateOfIncident');
 		return;
 	}
 		
@@ -484,16 +485,6 @@
 		{
 			showById('programEnrollmentDiv');
 			
-			var registerEvent = getFieldValue('registerEvent');
-			if(registerEvent == 'true')
-			{
-				enable('registerEventBtn');
-			}
-			else
-			{
-				disable('registerEventBtn');
-			}
-			
 			var singleEvent = jQuery('#programId option:selected').attr('singleevent');
 			if(singleEvent=='true')
 			{
@@ -858,16 +849,41 @@
 		},
 		function()
 		{
-			hideById('enrollmentDiv');
-			showById('dataRecordingSelectDiv');
-			
-			var selectedProgramId = jQuery('#programEnrollmentSelectDiv select[name=programId]').val();
-			jQuery('#dataRecordingSelectDiv select[name=programId] option[value=' + selectedProgramId + ']').attr('selected', 'selected');
-			loadProgramStages();
-			showById('dataRecordingSelectDiv');
+			setInnerHTML('enrollmentDiv', "");
+			showById('dataRecordingSelectDiv');
+			
+			jQuery('#dataRecordingSelectDiv select[name=programId] option').each(function()
+			{
+				var singleEvent = jQuery(this).attr('singleevent');
+				if( singleEvent == 'false')
+				{
+					jQuery(this).remove();
+				}
+			});
+			
 			jQuery("#backBtnFromEntry").click(function() {
 					loadPatientList();
 			});
 			hideLoader();
 		});
 }
+
+function enableEnrollmentField()
+{
+	var status = jQuery('#programId').attr('disabled');
+	
+	if( status )
+	{
+		jQuery('#enrollBtn').attr('value',i18n_enroll);
+		jQuery("#enrollBtn").click(function() {
+			validateProgramEnrollment();
+		});
+		enable('programId');
+		enable('enrollmentDate');
+		enable('dateOfIncident');
+	}
+	else
+	{
+		jQuery('#enrollBtn').attr('value',i18n_update);
+	}
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm	2011-10-04 06:28:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm	2011-10-05 03:39:54 +0000
@@ -32,7 +32,7 @@
 		<tr>
 			<td style="width:180px"><label for="programId">$i18n.getString( "program" )</label></td>
 			<td>
-				<select id="programId" name="programId" style='width:30.3em' onchange="showProgramEnrollmentForm('$patient.id', this.value);" style="min-width:200px" #if( $programs.size() == 0 ) disabled="disabled"#end>
+				<select id="programId" name="programId" style='width:30.3em' onchange="showProgramEnrollmentForm('$patient.id', this.value);" style="min-width:200px" disabled="disabled" >
 					<option value="0">[$i18n.getString( "select" )]</option>
 					#foreach( $program in $programs )
 						<option value="$program.id" singleevent='$program.singleEvent'>$encoder.htmlEncode( $program.name )</option>
@@ -45,12 +45,12 @@
 			
 		<tr>
 			<td><label for="enrollmentDate">$i18n.getString( "date_of_enrollment" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-			<td colspan='2' align='left'><input type="text" id="enrollmentDate" name="enrollmentDate" style='width:30em'> <i>( <span id='enrollmentDateDescription'></span> )</i></td>
+			<td colspan='2' align='left'><input type="text" id="enrollmentDate" name="enrollmentDate" style='width:30em' disabled="disabled" > <i>( <span id='enrollmentDateDescription'></span> )</i></td>
 			</tr>
 		
 		<tr>
 			<td><label for="dateOfIncident">$i18n.getString( "date_of_incident" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-			<td colspan='2'><input type="text" id="dateOfIncident" name="dateOfIncident" style='width:30em'><i>( <span id='dateOfIncidentDescription'></span> )</i></td>
+			<td colspan='2'><input type="text" id="dateOfIncident" name="dateOfIncident" style='width:30em' disabled="disabled" ><i>( <span id='dateOfIncidentDescription'></span> )</i></td>
 		</tr>
 		<tr>
 			<td></td>
@@ -61,8 +61,8 @@
 		<tr>
 			<td></td>
 			<td style="width:180px" colspan='2'>
-				<input type="button" id='enrollBtn' name='enrollBtn' value="$i18n.getString( 'enroll' )" onclick='validateProgramEnrollment();' disabled="disabled" style='width:10em'/>
-				<input type="button" id='registerEventBtn' value="$i18n.getString( 'register_event' )" onclick="showSelectedDataRecoding('$patient.id')" disabled="disabled" style='width:10em'/>
+				<input type="button" id='enrollBtn' name='enrollBtn' value="$i18n.getString( 'enroll_to_program' )" style='width:10em' onclick="enableEnrollmentField();" />
+				<input type="button" value="$i18n.getString( 'register_event' )" onclick="showSelectedDataRecoding('$patient.id')" #if($registerEvent=='false') disabled="disabled" #end style='width:10em'/>
 				<input type="button" value="$i18n.getString( "back_to_search" )" onclick="loadPatientList();" style="width:10em">
 			</td>                                        
 		</tr>
@@ -72,6 +72,8 @@
 <div id='programEnrollmentDiv' style='display:none;'></div>
 
 <script>
+	var i18n_enroll = '$encoder.jsEscape( $i18n.getString( "enroll" ) , "'")';
+	
 	jQuery('#programEnrollmentSelectDiv').ready(
 			function()
 			{
@@ -79,4 +81,5 @@
                 datePickerValid( 'dateOfIncident' );
 			}
 	);
+	
 </script>