← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6395: (patient) Add Advanced searching function into data entry form.

 

------------------------------------------------------------
revno: 6395
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-03-27 16:40:11 +0700
message:
  (patient) Add Advanced searching function into data entry form.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntrySelectAction.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/struts.xml
  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/form.js
  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/listPatient.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.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/caseentry/DataEntrySelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntrySelectAction.java	2011-05-10 07:25:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataEntrySelectAction.java	2012-03-27 09:40:11 +0000
@@ -33,6 +33,8 @@
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -61,6 +63,12 @@
         this.patientAttributeService = patientAttributeService;
     }
 
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -79,6 +87,14 @@
         return patientAttributes;
     }
 
+
+    private Collection<Program> programs;
+
+    public Collection<Program> getPrograms()
+    {
+        return programs;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -89,6 +105,8 @@
         organisationUnit = selectionManager.getSelectedOrganisationUnit();
 
         patientAttributes = patientAttributeService.getAllPatientAttributes();
+        
+        programs = programService.getAllPrograms();
 
         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	2012-03-27 07:20:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-03-27 09:40:11 +0000
@@ -25,6 +25,8 @@
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 		<property name="patientAttributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="programService"
+			ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.caseentry.ValidateSearchAction"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-03-27 09:40:11 +0000
@@ -46,7 +46,7 @@
 		</action>
 
 		<action name="searchPatient"
-			class="org.hisp.dhis.caseentry.action.caseentry.SearchPatientAction">
+			class="org.hisp.dhis.caseentry.action.patient.SearchPatientAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/listPatient.vm</param>
 		</action>

=== 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-03-27 04:22:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-03-27 09:40:11 +0000
@@ -41,6 +41,93 @@
 	}
 }
 
+// -----------------------------------------------------------------------------
+// Advanced search
+// -----------------------------------------------------------------------------
+
+function addAttributeOption()
+{
+	var rowId = 'advSearchBox' + jQuery('#advancedSearchTB select[name=searchingAttributeId]').length + 1;
+	var contend  = '<td>' + getInnerHTML('searchingAttributeIdTD') + '</td>';
+		contend += '<td>' + searchTextBox ;
+		contend += '<input type="button" value="-" onclick="removeAttributeOption(' + "'" + rowId + "'" + ');"></td>';
+		contend = '<tr id="' + rowId + '">' + contend + '</tr>';
+
+	jQuery('#advancedSearchTB > tbody:last').append( contend );
+}	
+
+function removeAttributeOption( rowId )
+{
+	jQuery( '#' + rowId ).remove();
+}		
+
+//------------------------------------------------------------------------------
+// Search patients by selected attribute
+//------------------------------------------------------------------------------
+
+function searchingAttributeOnChange( this_ )
+{	
+	var container = jQuery(this_).parent().parent().attr('id');
+	var attributeId = jQuery('#' + container+ ' [id=searchingAttributeId]').val(); 
+	var element = jQuery('#' + container+ ' [id=searchText]');
+	var valueType = jQuery('#' + container+ ' [id=searchingAttributeId] option:selected').attr('valueType');
+	
+	if( attributeId == '0' )
+	{
+		element.replaceWith( programComboBox );
+	}
+	else if ( valueType=='YES/NO' )
+	{
+		element.replaceWith( trueFalseBox );
+	}
+	else
+	{
+		element.replaceWith( searchTextBox );
+	}
+}
+//-----------------------------------------------------------------------------
+// Search Patient
+//-----------------------------------------------------------------------------
+
+function searchPatientsOnKeyUp( event )
+{
+	var key = getKeyCode( event );
+	
+	if ( key==13 )// Enter
+	{
+		searchPatients();
+	}
+}
+
+function getKeyCode(e)
+{
+	 if (window.event)
+		return window.event.keyCode;
+	 return (e)? e.which : null;
+}
+
+function searchAdvancedPatients()
+{
+	hideById( 'listPatientDiv' );
+	var searchTextFields = jQuery('[name=searchText]');
+	var flag = true;
+	jQuery( searchTextFields ).each( function( i, item )
+    {
+		if( jQuery( item ).val() == '' )
+		{
+			showWarningMessage( i18n_specify_search_criteria );
+			flag = false;
+		}
+	});
+	
+	if(!flag) return;
+	
+	contentDiv = 'listPatientDiv';
+	jQuery( "#loaderDiv" ).show();
+	searchPatient();
+	
+}
+
 // ----------------------------------------------------------------------------
 // Show patients
 // ----------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js	2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js	2012-03-27 09:40:11 +0000
@@ -144,3 +144,18 @@
 			hideById('contentDiv');
 		});
 }
+
+function searchPatient()
+{
+	$.ajax({
+		url: 'searchPatient.action',
+		type:"POST",
+		data: getParamsForDiv('searchPatientDiv'),
+		success: function( html ){
+				statusSearching = 1;
+				setInnerHTML( 'contentDiv', html );
+				showById('contentDiv');
+				jQuery( "#loaderDiv" ).hide();
+			}
+		});
+}
\ 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	2012-03-27 08:30:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-03-27 09:40:11 +0000
@@ -40,31 +40,6 @@
 
 selection.setListenerFunction( organisationUnitSelected );
 
-//------------------------------------------------------------------------------
-// Search patients by selected attribute
-//------------------------------------------------------------------------------
-
-function searchingAttributeOnChange( this_ )
-{	
-	var container = jQuery(this_).parent().parent().attr('id');
-	var attributeId = jQuery('#' + container+ ' [id=searchingAttributeId]').val(); 
-	var element = jQuery('#' + container+ ' [id=searchText]');
-	var valueType = jQuery('#' + container+ ' [id=searchingAttributeId] option:selected').attr('valueType');
-	
-	if( attributeId == '0' )
-	{
-		element.replaceWith( programComboBox );
-	}
-	else if ( valueType=='YES/NO' )
-	{
-		element.replaceWith( trueFalseBox );
-	}
-	else
-	{
-		element.replaceWith( searchTextBox );
-	}
-}
-
 // -----------------------------------------------------------------------------
 // Remove patient
 // -----------------------------------------------------------------------------
@@ -74,58 +49,6 @@
 	removeItem( patientId, fullName, i18n_confirm_delete, 'removePatient.action' );
 }
 
-//-----------------------------------------------------------------------------
-// Search Patient
-//-----------------------------------------------------------------------------
-
-function searchPatientsOnKeyUp( event )
-{
-	var key = getKeyCode( event );
-	
-	if ( key==13 )// Enter
-	{
-		searchPatients();
-	}
-}
-
-function getKeyCode(e)
-{
-	 if (window.event)
-		return window.event.keyCode;
-	 return (e)? e.which : null;
-}
-
-function searchPatients()
-{
-	hideById( 'listPatientDiv' );
-	var searchTextFields = jQuery('[name=searchText]');
-	var flag = true;
-	jQuery( searchTextFields ).each( function( i, item )
-    {
-		if( jQuery( item ).val() == '' )
-		{
-			showWarningMessage( i18n_specify_search_criteria );
-			flag = false;
-		}
-	});
-	
-	if(!flag) return;
-	
-	contentDiv = 'listPatientDiv';
-	jQuery( "#loaderDiv" ).show();
-	$.ajax({
-		url: 'searchRegistrationPatient.action',
-		type:"POST",
-		data: getParamsForDiv('searchPatientDiv'),
-		success: function( html ){
-				statusSearching = 1;
-				setInnerHTML( 'listPatientDiv', html );
-				showById('listPatientDiv');
-				jQuery( "#loaderDiv" ).hide();
-			}
-		});
-}
-
 function sortPatients()
 {
 	hideById( 'listPatientDiv' );
@@ -865,26 +788,6 @@
 	});
 }
 
-// -----------------------------------------------------------------------------
-// Advanced search
-// -----------------------------------------------------------------------------
-
-function addAttributeOption()
-{
-	var rowId = 'advSearchBox' + jQuery('#advancedSearchTB select[name=searchingAttributeId]').length + 1;
-	var contend  = '<td>' + getInnerHTML('searchingAttributeIdTD') + '</td>';
-		contend += '<td>' + searchTextBox ;
-		contend += '<input type="button" value="-" onclick="removeAttributeOption(' + "'" + rowId + "'" + ');"></td>';
-		contend = '<tr id="' + rowId + '">' + contend + '</tr>';
-
-	jQuery('#advancedSearchTB > tbody:last').append( contend );
-}	
-
-function removeAttributeOption( rowId )
-{
-	jQuery( '#' + rowId ).remove();
-}		
-
 function showRepresentativeInfo( patientId)
 {
 	jQuery('#representativeInfo' ).dialog({
@@ -1111,3 +1014,18 @@
 			hideById('contentDiv');
 		});
 }
+
+function searchPatient()
+{
+	$.ajax({
+		url: 'searchRegistrationPatient.action',
+		type:"POST",
+		data: getParamsForDiv('searchPatientDiv'),
+		success: function( html ){
+				statusSearching = 1;
+				setInnerHTML( 'listPatientDiv', html );
+				showById('listPatientDiv');
+				jQuery( "#loaderDiv" ).hide();
+			}
+		});
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm	2012-03-23 05:58:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm	2012-03-27 09:40:11 +0000
@@ -1,11 +1,23 @@
-
 <table>
 	<tr>
-		<td>$i18n.getString( "search_result_matching_the_search_criteria" ):</td>
-		<td>&nbsp;</td>
-		<td>&nbsp;</td>
-		<td>$i18n.getString( $searchText )</td>
+		<td class='text-column' >$i18n.getString( "search_result_matching_the_search_criteria" ):</td>
+		<td>&nbsp;</td>
+		<td>&nbsp;</td>
+		<td>
+		#if($!listAll)
+			$i18n.getString( "list_all_patients" )
+		#else
+			$i18n.getString( "search_patients_by_attributes" )
+		#end
+		</td>
 	</tr>	
+	
+	<tr>
+		<td class='text-column' >$i18n.getString( "total_result" )</td>
+		<td>&nbsp;</td>
+		<td>&nbsp;</td>
+		<td>$!total</td>
+	</tr>
 </table>
 
 <br>
@@ -71,7 +83,7 @@
     	#end
     	</tbody>
 		<tr>
-		<td colspan="6">
+		<td colspan="7">
 			<p></p>
 			<div class="paging-container">
 				#parse( "/dhis-web-commons/paging/paging.vm" )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2012-03-27 08:30:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2012-03-27 09:40:11 +0000
@@ -1,5 +1,4 @@
 <table>
-	
 	<tr>
 		<td class='text-column' >$i18n.getString( "search_result_matching_the_search_criteria" ):</td>
 		<td>&nbsp;</td>
@@ -20,6 +19,7 @@
 		<td>$!total</td>
 	</tr>
 </table>
+
 #if( $patients.size() > 0 )
 <table class="mainPageTable">
 	<tr>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm	2012-03-27 08:30:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm	2012-03-27 09:40:11 +0000
@@ -15,26 +15,33 @@
 		</tr> 
 	</table>
 
-	<table> 
-		<tr>           
-			<td>
-			  <select id="searchingAttributeId" name="searchingAttributeId" style="min-width:300px"  #if($organisationUnit) #else disabled #end>
-				<option value="">$i18n.getString( "search_by_name_identifier" )</option>
-					#foreach( $attribute in $patientAttributes )
-						<option value="$attribute.id" #if( $searchingAttributeId && $attribute.id == $searchingAttributeId ) selected="selected" #end>$encoder.htmlEncode( $attribute.name )</option>
-					#end
-			  </select> 
-			  <em title="$i18n.getString( "required" )" class="required">*</em></label>
-			</td>       
-			<td>
-				<input type="text" id="searchText" name="searchText" maxlength="30" style="width:20em" #if($organisationUnit) #else readonly #end onkeyup='javascript: searchPatientsOnKeyUp(event)' />
-			</td>        
-			<td>
-				<input type="button" id='searchBtn' value="$i18n.getString( 'search' )" onclick='validateSearch();' #if($organisationUnit) #else disabled #end/>
-			</td>        
-		</tr>    
-		<tr></tr>        
-	</table>
+		
+	<div id='searchPatientDiv'>
+		<table id='advancedSearchTB'>	
+			<tbody>
+				<tr id='advSearchBox0'>	       
+					<td id='searchingAttributeIdTD'>
+					  <select id="searchingAttributeId" name="searchingAttributeId" style="width:20.2em"  #if( $patientAttributes.size() == 0 ) disabled="disabled" #end onchange="searchingAttributeOnChange(this)">
+						<option value="">$i18n.getString( "search_by_name_identifier" )</option>
+						<option value="0">$i18n.getString( "search_by_program" )</option>
+							#foreach( $attribute in $patientAttributes )
+								<option value="$attribute.id" valueType='$attribute.valueType'>$encoder.htmlEncode( $attribute.name )</option>
+							#end
+					  </select> 
+					  <em title="$i18n.getString( "required" )" class="required">*</em></label>
+					</td>		
+					<td>
+						<input type="text" id="searchText" name="searchText" maxlength="30" style="width:20em" value="$!searchText" onkeyup='searchPatientsOnKeyUp( event );'>
+						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+					</td>	
+					<td></td>
+					<td><input type="button" value='+' onclick='addAttributeOption();'>
+						<input type="button" value='$i18n.getString( "search" )' onclick='searchAdvancedPatients();'>
+					</td>
+				</tr>
+			</tbody>
+		</table>
+	</div>
 </div>
 <span id='message'></span>
 <div id='contentDiv'></div>
@@ -69,6 +76,21 @@
     var i18n_scheduled_for = '$encoder.jsEscape( $i18n.getString( "scheduled_for" ) , "'")';
 	var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'")';
 	var i18n_create_new_encounter = '$encoder.jsEscape( $i18n.getString( "create_new_encounter" ) , "'")';
+	var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")';
+	var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")';
 	
 	selection.setListenerFunction( organisationUnitSelected );
+	
+	
+	var searchTextBox = '<input type="text" id="searchText" name="searchText" maxlength="30" style="width:20em" onkeyup="searchPatientsOnKeyUp( event );">';
+	var trueFalseBox  = '<select id="searchText" name="searchText" style="width:20.2em" >';
+		trueFalseBox += '<option value="true">' + i18n_yes + '</option>';
+		trueFalseBox += '<option value="false">' + i18n_no + '</option>';
+		trueFalseBox += '</select>';
+	var programComboBox = '<select id="searchText" name="searchText" style="width:20.2em" >';
+	#foreach ( $program in $programs ) 
+		programComboBox += '<option value="$program.id">$program.name</option>';
+	#end
+	programComboBox += '</select>';
+	
 </script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2012-03-08 08:56:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2012-03-27 09:40:11 +0000
@@ -34,7 +34,7 @@
 				</td>	
 				<td></td>
 				<td><input type="button" value='+' onclick='addAttributeOption();'>
-					<input type="button" value='$i18n.getString( "search" )' onclick='searchPatients();'>
+					<input type="button" value='$i18n.getString( "search" )' onclick='searchAdvancedPatients();'>
 				</td>
 				<td>&nbsp;</td>
 				<td><input type="button" value='$i18n.getString( "add_new" )' onclick="showAddPatientForm();"></td>