← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12460: properly append searchTexts parameter in patient search

 

------------------------------------------------------------
revno: 12460
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-10-07 11:50:01 +0200
message:
  properly append searchTexts parameter in patient search
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.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/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java	2013-10-05 05:15:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java	2013-10-07 09:50:01 +0000
@@ -28,13 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
@@ -46,9 +39,15 @@
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.user.CurrentUserService;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author Abyot Asalefew Gizaw
- * @version $Id$
  */
 public class SearchPatientAction
     extends ActionPagingSupport<Patient>

=== 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	2013-10-05 05:15:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-10-07 09:50:01 +0000
@@ -217,83 +217,89 @@
 }
 
 var followup = false;
-function getSearchParams()
-{
-	var params = "";
-	var programId = "";
-	if(getFieldValue('programIdAddPatient')!='')
-	{
-		params += "&programId=" + getFieldValue('programIdAddPatient');
-		params += "searchTexts=prg_" + getFieldValue('programIdAddPatient');
-	}
-	var programStageId = jQuery('#programStageAddPatient').val();
-	if( getFieldValue('searchByProgramStage') == "true" ){
-		var statusEvent = jQuery('#programStageAddPatientTR [id=statusEvent]').val();
-		var startDueDate = getFieldValue('startDueDate');
-		var orgunitid = getFieldValue('orgunitId');
-		if( byId('searchInAllFacility').checked ){
-			orgunitid = 0;
-		}
-		var endDueDate = getFieldValue('endDueDate');
-		params += '&searchTexts=stat_' + getFieldValue('programIdAddPatient') 
-			   + '_' + startDueDate + '_' + endDueDate
-			   + "_" + orgunitid
-			   + '_' + followup + '_' + statusEvent;
-	}
-	
-	var flag = false;
-	jQuery( '#advancedSearchTB tr' ).each( function( i, row ){
-		var dateOperator = "";
-		var p = "";
-		jQuery( this ).find(':input').each( function( idx, item ){
-			if(item.type!="button"){
-				if( idx == 0){
-					p = "&searchTexts=" + item.value;
-				}
-				else if( item.name == 'dateOperator'){
-					dateOperator = item.value;
-				}
-				else if( item.name == 'searchText'){
-					if( item.value!='')
-					{
-						p += "_";
-						if ( dateOperator.length >0 ) {
-							p += dateOperator + "'" +  item.value.toLowerCase() + "'";
-						}
-						else{
-							p += htmlEncode( item.value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, "") );
-						}
-					}
-					else {
-						p = "";
-					}
-				}
-			}
-		});
-		
-		var searchInAllFacility = byId('searchInAllFacility').checked;
-		if( getFieldValue('searchByProgramStage') == "false" && !searchInAllFacility ){
-			p += "_" + getFieldValue('orgunitId');
-		}
-		
-		params += p;
-	});
-		
-	params += '&listAll=false';
-	params += '&statusEnrollment=' + getFieldValue('statusEnrollment');
-	
-	params += '&facilityLB=';
-	if(byId('searchInAllFacility').checked){
-		params += getFieldValue('searchInAllFacility');
-	}
-	else if(byId('searchInUserOrgunits').checked){
-		params += getFieldValue('searchInUserOrgunits');
-	}
-	else if(byId('searchBelowOrgunit').checked){
-		params += getFieldValue('searchBelowOrgunit');
-	}
-	
-	return params;
+
+function getSearchParams() {
+    var params = "";
+    var programId = "";
+
+    if( getFieldValue('programIdAddPatient') != '' ) {
+        params += "&programId=" + getFieldValue('programIdAddPatient');
+        params += "&searchTexts=prg_" + getFieldValue('programIdAddPatient');
+    }
+
+    var programStageId = jQuery('#programStageAddPatient').val();
+
+    if( getFieldValue('searchByProgramStage') == "true" ) {
+        var statusEvent = jQuery('#programStageAddPatientTR [id=statusEvent]').val();
+        var startDueDate = getFieldValue('startDueDate');
+        var orgunitid = getFieldValue('orgunitId');
+
+        if( byId('searchInAllFacility').checked ) {
+            orgunitid = 0;
+        }
+
+        var endDueDate = getFieldValue('endDueDate');
+
+        params += '&searchTexts=stat_' + getFieldValue('programIdAddPatient')
+            + '_' + startDueDate + '_' + endDueDate
+            + "_" + orgunitid
+            + '_' + followup + '_' + statusEvent;
+    }
+
+    var flag = false;
+
+    jQuery('#advancedSearchTB tr').each(function( i, row ) {
+        var dateOperator = "";
+        var p = "";
+        jQuery(this).find(':input').each(function( idx, item ) {
+            if( item.type != "button" ) {
+                if( idx == 0 ) {
+                    p = "&searchTexts=" + item.value;
+                }
+                else if( item.name == 'dateOperator' ) {
+                    dateOperator = item.value;
+                }
+                else if( item.name == 'searchText' ) {
+                    if( item.value != '' ) {
+                        p += "_";
+                        if( dateOperator.length > 0 ) {
+                            p += dateOperator + "'" + item.value.toLowerCase() + "'";
+                        }
+                        else {
+                            p += htmlEncode(item.value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, ""));
+                        }
+                    }
+                    else {
+                        p = "";
+                    }
+                }
+            }
+        });
+
+        var searchInAllFacility = byId('searchInAllFacility').checked;
+
+        if( getFieldValue('searchByProgramStage') == "false" && !searchInAllFacility ) {
+            p += "_" + getFieldValue('orgunitId');
+        }
+
+        params += p;
+    });
+
+    params += '&listAll=false';
+    params += '&statusEnrollment=' + getFieldValue('statusEnrollment');
+
+    params += '&facilityLB=';
+    if( byId('searchInAllFacility').checked ) {
+        params += getFieldValue('searchInAllFacility');
+    }
+    else if( byId('searchInUserOrgunits').checked ) {
+        params += getFieldValue('searchInUserOrgunits');
+    }
+    else if( byId('searchBelowOrgunit').checked ) {
+        params += getFieldValue('searchBelowOrgunit');
+    }
+
+    return params;
 }
 
 // ----------------------------------------------------------------------------