← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12437: Improve advanced-search patient function (WIP).

 

------------------------------------------------------------
revno: 12437
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-10-05 12:15:03 +0700
message:
  Improve advanced-search patient function (WIP).
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
  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/UpdatePatientAction.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/anonymousRegistration.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm
  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/patient.js
  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/responseDataElements.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-10-03 04:59:39 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-10-05 05:15:03 +0000
@@ -833,7 +833,7 @@
         {
             sql += statementBuilder.limitRecord( min, max );
         }
-
+        
         return sql;
     }
 

=== 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-02 11:24:32 +0000
+++ 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
@@ -36,6 +36,7 @@
 import java.util.Map;
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.patient.Patient;
@@ -52,6 +53,12 @@
 public class SearchPatientAction
     extends ActionPagingSupport<Patient>
 {
+    private final String SEARCH_IN_ALL_ORGUNITS = "searchInAllOrgunits";
+
+    private final String SEARCH_IN_USER_ORGUNITS = "searchInUserOrgunits";
+
+    private final String SEARCH_IN_BELOW_SELECTED_ORGUNIT = "searchInBelowSelectedOrgunit";
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -64,6 +71,8 @@
 
     private CurrentUserService currentUserService;
 
+    private OrganisationUnitService organisationUnitService;
+
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -72,9 +81,7 @@
 
     private Integer statusEnrollment;
 
-    private Boolean searchBySelectedOrgunit;
-
-    private Boolean searchByUserOrgunits;
+    private String facilityLB;
 
     private boolean listAll;
 
@@ -84,6 +91,11 @@
     // Getters && Setters
     // -------------------------------------------------------------------------
 
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
     public void setCurrentUserService( CurrentUserService currentUserService )
     {
         this.currentUserService = currentUserService;
@@ -94,26 +106,21 @@
         this.statusEnrollment = statusEnrollment;
     }
 
+    public void setFacilityLB( String facilityLB )
+    {
+        this.facilityLB = facilityLB;
+    }
+
     public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
     {
         this.selectionManager = selectionManager;
     }
 
-    public void setSearchByUserOrgunits( Boolean searchByUserOrgunits )
-    {
-        this.searchByUserOrgunits = searchByUserOrgunits;
-    }
-
     public void setProgramService( ProgramService programService )
     {
         this.programService = programService;
     }
 
-    public void setSearchBySelectedOrgunit( Boolean searchBySelectedOrgunit )
-    {
-        this.searchBySelectedOrgunit = searchBySelectedOrgunit;
-    }
-
     public void setPatientService( PatientService patientService )
     {
         this.patientService = patientService;
@@ -153,11 +160,11 @@
         return mapPatientOrgunit;
     }
 
-    private List<Integer> programIds;
+    private Integer programId;
 
-    public void setProgramIds( List<Integer> programIds )
+    public void setProgramId( Integer programId )
     {
-        this.programIds = programIds;
+        this.programId = programId;
     }
 
     private List<PatientIdentifierType> identifierTypes = new ArrayList<PatientIdentifierType>();
@@ -167,6 +174,13 @@
         return identifierTypes;
     }
 
+    private OrganisationUnit organisationUnit;
+
+    public OrganisationUnit getOrganisationUnit()
+    {
+        return organisationUnit;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -174,10 +188,10 @@
     public String execute()
         throws Exception
     {
+        organisationUnit = selectionManager.getSelectedOrganisationUnit();
+
         Collection<OrganisationUnit> orgunits = new HashSet<OrganisationUnit>();
 
-        OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
-
         // List all patients
         if ( listAll )
         {
@@ -190,16 +204,24 @@
         // search patients
         else if ( searchTexts.size() > 0 )
         {
-            if ( searchByUserOrgunits )
+            // selected orgunit
+            if ( facilityLB == null )
+            {
+                orgunits.add( organisationUnit );
+            }
+            else if ( facilityLB.equals( SEARCH_IN_USER_ORGUNITS ) )
             {
                 Collection<OrganisationUnit> userOrgunits = currentUserService.getCurrentUser().getOrganisationUnits();
                 orgunits.addAll( userOrgunits );
             }
-            else if ( searchBySelectedOrgunit )
+            else if ( facilityLB.equals( SEARCH_IN_BELOW_SELECTED_ORGUNIT ) )
             {
-                orgunits.add( organisationUnit );
+                Collection<Integer> orgunitIds = organisationUnitService.getOrganisationUnitHierarchy().getChildren(
+                    organisationUnit.getId() );
+
+                orgunits.addAll( organisationUnitService.getOrganisationUnits( orgunitIds ) );
             }
-            else
+            else if ( facilityLB.equals( SEARCH_IN_ALL_ORGUNITS ) )
             {
                 orgunits = null;
             }
@@ -209,7 +231,7 @@
             patients = patientService.searchPatients( searchTexts, orgunits, null, null, statusEnrollment,
                 paging.getStartPos(), paging.getPageSize() );
 
-            if ( !searchBySelectedOrgunit || searchByUserOrgunits )
+            if ( facilityLB != null )
             {
                 for ( Patient patient : patients )
                 {
@@ -217,13 +239,10 @@
                 }
             }
 
-            if ( programIds != null )
+            if ( programId != null )
             {
-                for ( Integer programId : programIds )
-                {
-                    Program progam = programService.getProgram( programId );
-                    identifierTypes.addAll( progam.getPatientIdentifierTypes() );
-                }
+                Program progam = programService.getProgram( programId );
+                identifierTypes.addAll( progam.getPatientIdentifierTypes() );
             }
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java	2013-10-02 11:21:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java	2013-10-05 05:15:03 +0000
@@ -314,17 +314,13 @@
                             if ( option != null )
                             {
                                 attributeValue.setPatientAttributeOption( option );
-                                attributeValue.setValue( option.getName() );
                             }
                             else
                             {
                                 // This option was deleted ???
                             }
                         }
-                        else
-                        {
-                            attributeValue.setValue( value.trim() );
-                        }
+                        attributeValue.setValue( value.trim() );
                         valuesForUpdate.add( attributeValue );
                         valuesForDelete.remove( attributeValue );
                     }

=== 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	2013-09-27 11:13:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-10-05 05:15:03 +0000
@@ -31,6 +31,7 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 	</bean>
 
 	<bean

=== 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	2013-10-04 13:06:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-10-05 05:15:03 +0000
@@ -698,5 +698,16 @@
 both = both
 column = Column
 row = Row
+<<<<<<< TREE
+show = Show
+the_following_persons_found_in = The following persons found in
+for_infor = for
+enrollments_in = enrollments in 
+program_infor = program
+change = Change
+select_orgunit_for_search = Select organisation unit for search
+select_other_orgunit = Select other organisation unit
+clear_and_close = Clear and Close
+search_all_below_selected_orgunit = Search all below selected organisation unit
 show = Show
 please_wait_loading=Loading.. please wait
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2013-10-04 13:06:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2013-10-05 05:15:03 +0000
@@ -232,8 +232,6 @@
     var i18n_offline_notification = '$encoder.jsEscape( $i18n.getString( "offline_notification" ) , "'")';
     var i18n_operation_not_available_offline = '$encoder.jsEscape( $i18n.getString( "operation_not_available_offline" ) , "'")';
 
-    var i18n_please_wait_loading = '$encoder.jsEscape( $i18n.getString( "please_wait_loading" ) , "'")';
-
 	isAjax = true;
 	contentDiv = '';
 	var unSave = false;

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2013-10-02 03:09:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2013-10-05 05:15:03 +0000
@@ -209,4 +209,7 @@
 quarters_last_year: '$encoder.jsEscape($i18n.getString( 'quarters_last_year' ) , "'")',
 quarters_this_year: '$encoder.jsEscape($i18n.getString( 'quarters_this_year' ) , "'")',
 last_6_bimonths: '$encoder.jsEscape($i18n.getString( 'last_6_bimonths' ) , "'")',
+female: '$encoder.jsEscape($i18n.getString( 'female' ) , "'")',
+male: '$encoder.jsEscape($i18n.getString( 'male' ) , "'")',
+transgender: '$encoder.jsEscape($i18n.getString( 'transgender' ) , "'")',
 };
\ No newline at end of file

=== 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-02 11:24:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-10-05 05:15:03 +0000
@@ -102,11 +102,7 @@
 	
 	$( '#searchText_' + container ).datepicker("destroy");
 	$('#' + container + ' [id=dateOperator]').replaceWith("");
-	if( attributeId == 'prg' )
-	{
-		element.replaceWith( programComboBox );
-	}
-	else if ( attributeId=='fixedAttr_gender' )
+	if ( attributeId=='fixedAttr_gender' )
 	{
 		element.replaceWith( getGenderSelector() );
 	}
@@ -224,10 +220,10 @@
 function getSearchParams()
 {
 	var params = "";
-	var programIds = "";
+	var programId = "";
 	if(getFieldValue('programIdAddPatient')!='')
 	{
-		programIds += "&programIds=" + getFieldValue('programIdAddPatient');
+		params += "&programId=" + getFieldValue('programIdAddPatient');
 		params += "searchTexts=prg_" + getFieldValue('programIdAddPatient');
 	}
 	var programStageId = jQuery('#programStageAddPatient').val();
@@ -246,7 +242,6 @@
 	}
 	
 	var flag = false;
-	var addProgramId = false;
 	jQuery( '#advancedSearchTB tr' ).each( function( i, row ){
 		var dateOperator = "";
 		var p = "";
@@ -254,10 +249,6 @@
 			if(item.type!="button"){
 				if( idx == 0){
 					p = "&searchTexts=" + item.value;
-					if(item.value=='prg' || item.value=='pi_enrollmentDate'){
-						flag = true;
-						addProgramId = true;
-					}
 				}
 				else if( item.name == 'dateOperator'){
 					dateOperator = item.value;
@@ -272,11 +263,6 @@
 						else{
 							p += htmlEncode( item.value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, "") );
 						}
-						
-						if( flag ){
-							programIds += item.value;
-							flag = false;
-						}
 					}
 					else {
 						p = "";
@@ -290,27 +276,22 @@
 			p += "_" + getFieldValue('orgunitId');
 		}
 		
-		if( addProgramId ){
-			p += "_" + getFieldValue('programIdAddPatient');
-		}
-		
 		params += p;
 	});
 		
 	params += '&listAll=false';
-	
-	var searchByUserOrgunits = byId('searchByUserOrgunits').checked ? true : false;
-	params += '&searchByUserOrgunits=' + searchByUserOrgunits;
 	params += '&statusEnrollment=' + getFieldValue('statusEnrollment');
-	if( getFieldValue('searchByProgramStage') == "false"){
-		var searchInAllFacility = byId('searchInAllFacility').checked;
-		params += '&searchBySelectedOrgunit=' + !searchInAllFacility;
-	}
-	else
-	{
-		params += '&searchBySelectedOrgunit=false';
-	}
-	params += programIds;
+	
+	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;
 }
@@ -505,9 +486,9 @@
 }
 
 function enableBtn(){
+	var programIdAddPatient = getFieldValue('programIdAddPatient');
 	if(registration==undefined || !registration)
 	{
-		var programIdAddPatient = getFieldValue('programIdAddPatient');
 		if( programIdAddPatient!='' ){
 			enable('listPatientBtn');
 			enable('addPatientBtn');
@@ -516,6 +497,7 @@
 			jQuery('#advanced-search :input').each( function( idx, item ){
 				enable(this.id);
 			});
+			
 		}
 		else
 		{
@@ -528,6 +510,12 @@
 			});
 		}
 	}
+	else if(programIdAddPatient!=''){
+		showById('enrollmentSelectTR');
+	}
+	else{
+		hideById('enrollmentSelectTR');
+	}
 }
 
 function enableRadioButton( programId )
@@ -2356,10 +2344,23 @@
 	$('.idxPhoneNumber' + idx).remove();
 }
 
+// --------------------------------------------------------------------------
+// Advanced-search person
+// --------------------------------------------------------------------------
+
 function searchByIdsOnclick()
 {
 	var value = getFieldValue('searchPatientByIds');
-	jQuery("#advSearchBox0").find('input[id=searchText]').val(value);
+	
+	if(jQuery("#advSearchBox0").find('input[id=searchObjectId]').val()=='iden'
+		&& jQuery("#advSearchBox0").find('input[id=searchText]').val()=='' ){
+		jQuery("#advSearchBox0").find('input[id=searchText]').val(value);
+	}
+	else
+	{
+		addAttributeOption();
+		jQuery("input[id=searchText]").last().val(value);
+	}
 	jQuery("#searchPatientBtn").click();
 }
 
@@ -2373,3 +2374,16 @@
 		showById('searchByIdTR');
 	}
 }
+
+function clearAndCloseSearch()
+{
+	jQuery('#advancedSearchTB tr').each( function()
+	{
+		if(jQuery(this).id==undefined){
+			jQuery(this).remove();
+		}
+	});
+	addAttributeOption();
+	hideById('advanced-search');
+}
+

=== 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	2013-09-23 09:00:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2013-10-05 05:15:03 +0000
@@ -16,6 +16,9 @@
 	enable('addPatientBtn');
 	enable('advancedSearchBtn');
 	enable('searchObjectId');
+	setInnerHTML('patientDashboard','');
+	setInnerHTML('editPatientDiv','');
+	
 	setFieldValue("orgunitName", orgUnitNames[0]);
 	
 	clearListById('programIdAddPatient');
@@ -156,8 +159,9 @@
 				listAll:false,
 				searchByUserOrgunits: false,
 				searchBySelectedOrgunit: true,
-				programIds: getFieldValue('programIdAddPatient'),
-				searchTexts: 'prg_' + getFieldValue('programIdAddPatient')
+				programId: getFieldValue('programIdAddPatient'),
+				searchTexts: 'prg_' + getFieldValue('programIdAddPatient'),
+				statusEnrollment: getFieldValue('statusEnrollment')
 			},
 			function(){
 				setTableStyles();
@@ -333,7 +337,9 @@
 	hideById('dataRecordingSelectDiv');
 	hideById('dataEntryFormDiv');
 	hideById('migrationPatientDiv');
-	
+	setInnerHTML('patientDashboard','');
+	setInnerHTML('editPatientDiv','');
+
 	showById('mainLinkLbl');
 	showById('selectDiv');
 	showById('searchDiv');

=== 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	2013-09-23 03:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2013-10-05 05:15:03 +0000
@@ -1,21 +1,25 @@
 <table>
 	<tr>
-		<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" )
-		#end
+		<td class='text-column'>
+			$i18n.getString( "the_following_persons_found_in" ) $organisationUnit.name <span id='enrollmentInfor'></span> 
+			<script>
+				setInnerHTML('orgunitForSearch',"$organisationUnit.name");
+				var i18n_for = '$encoder.jsEscape( $i18n.getString( "for_infor" ), "'")';
+				var i18n_enrollments_in = '$encoder.jsEscape( $i18n.getString( "enrollments_in" ), "'")';
+				var i18n_program = '$encoder.jsEscape( $i18n.getString( "program_infor" ), "'")';
+				if( getFieldValue('programIdAddPatient') != "" )
+				{
+					var status = jQuery('#statusEnrollment option:selected').text();
+					var programName = jQuery('#programIdAddPatient option:selected').text();
+					var title = i18n_for + " " + status + " " + i18n_enrollments_in  + " " + programName + " " + i18n_program;
+					setInnerHTML('enrollmentInfor', title);
+				}
+			</script>
+			<input type="button" style='width:130px' value='$i18n.getString( "change" )' onclick="advancedSearchOnclick();" >
 		</td>
 	</tr>
 	<tr>
-		<td class='text-column' >$i18n.getString( "total_result" )</td>
-		<td>&nbsp;</td>
-		<td>&nbsp;</td>
-		<td>$!total</td>
+		<td class='text-column' >$i18n.getString( "total_result" ): $!total</td>
 	</tr>
 </table>
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm	2013-10-03 14:11:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm	2013-10-05 05:15:03 +0000
@@ -33,18 +33,18 @@
 						 #end
 		},
 		#end
-		
-		#foreach( $psDataElement in $psDataElements )
-		{
-			"id": "$psDataElement.dataElement.uid",
-			"name": "$encoder.xmlEncode(${psDataElement.dataElement.getFormNameFallback()} )",
-			"valueType": #if( $psDataElement.dataElement.optionSet )
-							"list_$psDataElement.dataElement.optionSet.uid"
-						 #else
-							"${psDataElement.dataElement.type}"
-						 #end
-		}#if( $velocityCount < $psDataElements.size() ),#end
-		#end
+	#end
+	
+	#foreach( $psDataElement in $psDataElements )
+	{
+		"id": "$psDataElement.dataElement.uid",
+		"name": "$encoder.xmlEncode(${psDataElement.dataElement.getFormNameFallback()} )",
+		"valueType": #if( $psDataElement.dataElement.optionSet )
+						"list_$psDataElement.dataElement.optionSet.uid"
+					 #else
+						"${psDataElement.dataElement.type}"
+					 #end
+	}#if( $velocityCount < $psDataElements.size() ),#end
 	#end
   ]
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2013-10-02 11:24:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2013-10-05 05:15:03 +0000
@@ -67,7 +67,7 @@
 			<input type='checkbox' id='followup' name='followup' />
 		</td>
 	</tr>
-	<tr id='searchByIdTR'>
+	<tr id='searchByIdTR' class='hidden'>
 		<td colspan='2' ><input type='text' id='searchPatientByIds' name='searchPatientByIds' onchange='searchByIdsOnclick();' style='width:350px;' placeholder='$i18n.getString("search_by_name_identifier")' /></td>
 		<td><input type='button' value='$i18n.getString("search")' onclick='searchByIdsOnclick();' ></td>
 	</tr>
@@ -75,19 +75,31 @@
 </table>
 <div id='advanced-search' name='advanced-search' class='hidden advanced-search'>
 	<table>	
+		<tr>
+			<td colspan='3'>
+				$i18n.getString('select_orgunit_for_search'): <span id='orgunitForSearch'>$!organisationUnit.name</span>
+				<input type='button' id='selectOtherOrgunitBtn' value='$i18n.getString("select_other_orgunit")' />
+				<input type='button' id='clearAndCloseSearchBtn' value='$i18n.getString("clear_and_close")' onclick='clearAndCloseSearch();'/>
+			</td>
+		</tr>
 		<tr id='searchBySelectedUnitTD'>
 			 #if( $auth.hasAccess( "dhis-web-caseentry", "searchAllFacilities" ) )
 				<td>
 					$i18n.getString('search_in_all_facilities') 
-					<input type='checkbox' id='searchInAllFacility' name='searchInAllFacility' />&nbsp;&nbsp;&nbsp;
+					<input type='checkbox' id='searchInAllFacility' name='searchInAllFacility' value='searchInAllOrgunits' />&nbsp;&nbsp;&nbsp;
 				</td>
 			 #else
-					 <input type='checkbox' class='hidden' id='searchInAllFacility' name='searchInAllFacility' />
+					 <input type='checkbox' class='hidden' id='searchInAllFacility' name='searchInAllFacility' value='searchInAllOrgunits' />
 			 #end
 			 
 			<td>
 				$i18n.getString('search_by_user_orgunits') 
-				<input type='checkbox' id='searchByUserOrgunits' name='searchByUserOrgunits' />&nbsp;&nbsp;&nbsp;
+				<input type='checkbox' id='searchInUserOrgunits' name='searchInUserOrgunits' value='searchInUserOrgunits' />&nbsp;&nbsp;&nbsp;
+			</td>
+			
+			<td>
+				$i18n.getString('search_all_below_selected_orgunit') 
+				<input type='checkbox' id='searchBelowOrgunit' name='searchBelowOrgunit' value='searchInBelowSelectedOrgunit' />&nbsp;&nbsp;&nbsp;
 			</td>
 		
 		</tr>
@@ -113,11 +125,6 @@
 			  <select class='search-field' id="searchObjectId" name="searchObjectId" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end onchange="searchObjectOnChange(this)">
 				#if( $auth.hasAccess( "dhis-web-caseentry", "accessPatientAttributes" ) )
 					<option value="iden">$i18n.getString( "search_by_name_identifier" )</option>
-				#end
-				
-				<option value="prg">$i18n.getString( "search_by_program" )</option>
-				
-				#if( $auth.hasAccess( "dhis-web-caseentry", "accessPatientAttributes" ) )
 					<option value="fixedAttr_registrationDate">$i18n.getString( "registration_date" )</option>
 					<option value="fixedAttr_birthDate">$i18n.getString( "date_of_birth" )</option>
 					<option value="fixedAttr_age">$i18n.getString( "age_year" )</option>
@@ -151,10 +158,6 @@
 				  <select class='search-field' id="searchObjectId" name="searchObjectId" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end onchange="searchObjectOnChange(this)">
 					#if( $auth.hasAccess( "dhis-web-caseentry", "accessPatientAttributes" ) )
 						<option value="iden">$i18n.getString( "search_by_name_identifier" )</option>
-					#end
-					<option value="prg">$i18n.getString( "search_by_program" )</option>
-					
-					#if( $auth.hasAccess( "dhis-web-caseentry", "accessPatientAttributes" ) )
 						<option value="fixedAttr_registrationDate">$i18n.getString( "registration_date" )</option>
 						<option value="fixedAttr_birthDate">$i18n.getString( "date_of_birth" )</option>
 						<option value="fixedAttr_age">$i18n.getString( "age_year" )</option>
@@ -193,9 +196,4 @@
 	datePicker( 'endDueDate', true );
 	
 	var searchTextBox = '<input type="text" id="searchText" name="searchText" onkeyup="searchPatientsOnKeyUp( event );" style="width:202px;">';
-	var programComboBox = '<select class="search-field" id="searchText" name="searchText" style="width:205px;">';
-	#foreach ( $program in $programs ) 
-		programComboBox += '<option value="$program.id">$program.displayName</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	2013-10-02 11:24:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2013-10-05 05:15:03 +0000
@@ -1,7 +1,7 @@
 <script>
-jQuery(document).ready(	function(){
+	jQuery(document).ready(	function(){
 		jQuery('#criteriaBtnTD').attr('rowspan', 2);
-		showById('enrollmentSelectTR');
+		showById('searchByIdTR');
 	});
 </script>