← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7036: (patient) Add before, equal, after operators for data of birth in searching function.

 

------------------------------------------------------------
revno: 7036
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-05-24 21:36:15 +0700
message:
  (patient) Add before, equal, after operators for data of birth in searching function.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java	2012-05-24 13:53:25 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java	2012-05-24 14:36:15 +0000
@@ -294,7 +294,7 @@
         else if ( patientAttributeId == -1 )
         {
             hql += " ( SELECT p" + index + " FROM Patient AS p" + index 
-                + " WHERE p" + index + ".birthDate='" + searchText+ "'";
+                + " WHERE p" + index + ".birthDate " + searchText;
             isSearchByAttribute = false; 
         }
         

=== 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-05-03 10:18:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-05-24 14:36:15 +0000
@@ -59,7 +59,7 @@
 function removeAttributeOption( rowId )
 {
 	jQuery( '#' + rowId ).remove();
-}		
+}	
 
 //------------------------------------------------------------------------------
 // Search patients by selected attribute
@@ -69,15 +69,19 @@
 {	
 	var container = jQuery(this_).parent().parent().attr('id');
 	var attributeId = jQuery('#' + container+ ' [id=searchingAttributeId]').val(); 
-	var element = jQuery('#' + container+ ' [id=searchText]');
+	var element = jQuery('#' + container + ' [id=searchText]');
 	var valueType = jQuery('#' + container+ ' [id=searchingAttributeId] option:selected').attr('valueType');
 	
 	if( attributeId == '-1' )
 	{
 		element.replaceWith( getDateField( container ) );
-		datePickerValid( 'searchDateField-' + container + ' [id=searchText]' );
+		datePickerValid( container + ' [id=searchText]' );
+		return;
 	}
-	else if( attributeId == '0' )
+	
+	$('#' + container+ ' [id=searchText]').datepicker("destroy");
+	$('#' + container+ ' [id=dateOperator]').replaceWith("");
+	if( attributeId == '0' )
 	{
 		element.replaceWith( programComboBox );
 	}
@@ -93,7 +97,8 @@
 
 function getDateField( container )
 {
-	var dateField = '<div id="searchDateField-' + container + '" > <input type="text" id="searchText" name="searchText" maxlength="30" style="width:18em" onkeyup="searchPatientsOnKeyUp( event );"></div>';
+	var dateField = '<select id="dateOperator" name="dateOperator" ><option value=">"> > </option><option value="="> = </option><option value="<"> < </option></select>';
+	dateField += '<input type="text" id="searchText" name="searchText" maxlength="30" style="width:18em" onkeyup="searchPatientsOnKeyUp( event );">';
 	return dateField;
 }
 	
@@ -164,6 +169,7 @@
 function getParamsForDiv( patientDiv)
 {
 	var params = '';
+	var dateOperator = '';
 	jQuery("#" + patientDiv + " :input").each(function()
 		{
 			var elementId = $(this).attr('id');
@@ -173,6 +179,10 @@
 				var checked = jQuery(this).attr('checked') ? true : false;
 				params += elementId + "=" + checked + "&";
 			}
+			else if( elementId =='dateOperator' )
+			{
+				dateOperator = jQuery(this).val();
+			}
 			else if( $(this).attr('type') != 'button' )
 			{
 				var value = "";
@@ -180,6 +190,11 @@
 				{
 					value = htmlEncode(jQuery(this).val());
 				}
+				if( dateOperator != '' )
+				{
+					value = dateOperator + "'" + value + "'";
+					dateOperator = "";
+				}
 				params += elementId + "="+ value + "&";
 			}
 		});