← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2433: Add function "Display existing benificiaries while typing name field in Add Benificiary screen".

 

------------------------------------------------------------
revno: 2433
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-12-27 14:59:27 +0700
message:
  Add function "Display existing benificiaries while typing name field in Add Benificiary screen".
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientsByNameAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/resultSearchPatients.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java
  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/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.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-api/src/main/java/org/hisp/dhis/patient/Patient.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java	2010-12-02 08:57:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java	2010-12-27 07:59:27 +0000
@@ -60,6 +60,8 @@
     private String middleName;
 
     private String lastName;
+    
+    private String fullName;
 
     private String gender;
 
@@ -418,9 +420,14 @@
         setBirthDate( todayCalendar.getTime() );
     }
 
+    public void setFullName( String fullName )
+    {
+        this.fullName = fullName;
+    }
+
     public String getFullName()
     {
-        return firstName + " " + middleName + " " + lastName;
+        return fullName;
     }
 
     public String getBloodGroup()

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2010-11-25 22:22:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2010-12-27 07:59:27 +0000
@@ -90,9 +90,9 @@
     Collection<Patient> getPatientsByBirthDate( Date birthDate );
 
     /**
-     * Search Patient base on firstname/middlename/lastname/
+     * Search Patient base on fullName
      * 
-     * @param name firstName/middleName/lastName/
+     * @param name fullName
      * @return Patient List
      */
     Collection<Patient> getPatientsByNames( String name );
@@ -212,7 +212,7 @@
      * @param name
      * @return number of patients
      */
-    int countnGetPatientsByNames( String name );
+    int countGetPatientsByName( String name );
 
     int createPatient( Patient patient,Integer representativeId,
         Integer relationshipTypeId, List<PatientAttributeValue> patientAttributeValues );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2010-10-30 05:54:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2010-12-27 07:59:27 +0000
@@ -63,7 +63,7 @@
     
     int countListPatientByOrgunit(OrganisationUnit organisationUnit);
     
-    int countGetPatientsByNames( String name );
+    int countGetPatientsByName( String name );
     
     int countGetPatientsByOrgUnitProgram( OrganisationUnit organisationUnit, Program program );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2010-11-25 22:22:10 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2010-12-27 07:59:27 +0000
@@ -245,7 +245,7 @@
     @Override
     public Collection<Patient> getPatients( String searchText, int min, int max )
     {
-        int countPatientName = patientStore.countGetPatientsByNames( searchText );
+        int countPatientName = patientStore.countGetPatientsByName( searchText );
 
         Set<Patient> patients = new HashSet<Patient>();
 
@@ -416,14 +416,14 @@
     @Override
     public int countGetPatients( String searchText )
     {
-        return patientStore.countGetPatientsByNames( searchText )
+        return patientStore.countGetPatientsByName( searchText )
             + patientIdentifierService.countGetPatientsByIdentifier( searchText );
     }
 
     @Override
-    public int countnGetPatientsByNames( String name )
+    public int countGetPatientsByName( String name )
     {
-        return patientStore.countGetPatientsByNames( name );
+        return patientStore.countGetPatientsByName( name );
     }
 
     @Override

=== 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	2010-10-30 05:54:51 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2010-12-27 07:59:27 +0000
@@ -74,10 +74,13 @@
     @SuppressWarnings( "unchecked" )
     public Collection<Patient> getByNames( String name )
     {
-        return getCriteria(
-            Restrictions.disjunction().add( Restrictions.ilike( "firstName", "%" + name + "%" ) ).add(
-                Restrictions.ilike( "middleName", "%" + name + "%" ) ).add(
-                Restrictions.ilike( "lastName", "%" + name + "%" ) ) ).addOrder( Order.asc( "firstName" ) ).list();
+//        String hql = "From Patient p where lower( p.firstName + ' ' + p.middleName + ' ' + p.lastName ) like :name order by p.id";
+//
+//        return getQuery( hql ).setString( "name", "%" + name + "%" ).list();
+        
+         return getCriteria(
+            Restrictions.disjunction().add( Restrictions.ilike( "fullName", "%" + name + "%") ) ).addOrder(
+            Order.asc( "firstName" ) ).list();
     }
 
     @SuppressWarnings( "unchecked" )
@@ -137,16 +140,14 @@
     public Collection<Patient> getByOrgUnitProgram( OrganisationUnit organisationUnit, Program program, int min, int max )
     {
         return getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) ).createAlias( "programs",
-            "program" ).add( Restrictions.eq( "program.id", program.getId() ) ).addOrder(Order.asc("id")).setFirstResult( min ).setMaxResults(
-            max ).list();
+            "program" ).add( Restrictions.eq( "program.id", program.getId() ) ).addOrder( Order.asc( "id" ) )
+            .setFirstResult( min ).setMaxResults( max ).list();
     }
 
-    public int countGetPatientsByNames( String name )
+    public int countGetPatientsByName( String name )
     {
         Number rs = (Number) getCriteria(
-            Restrictions.disjunction().add( Restrictions.ilike( "firstName", "%" + name + "%" ) ).add(
-                Restrictions.ilike( "middleName", "%" + name + "%" ) ).add(
-                Restrictions.ilike( "lastName", "%" + name + "%" ) ) ).setProjection( Projections.rowCount() )
+            Restrictions.ilike( "fullName", "%" + name + "%") ).setProjection( Projections.rowCount() )
             .uniqueResult();
 
         return rs != null ? rs.intValue() : 0;
@@ -170,7 +171,7 @@
         Number rs = (Number) getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) ).createAlias(
             "programs", "program" ).add( Restrictions.eq( "program.id", program.getId() ) ).setProjection(
             Projections.rowCount() ).uniqueResult();
-        
+
         return rs != null ? rs.intValue() : 0;
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml	2010-12-27 07:59:27 +0000
@@ -15,6 +15,8 @@
 		<property name="middleName" column="middlename" length="50" />
 
 		<property name="lastName" column="lastname" length="50" />
+		
+		<property name="fullName" formula="concat(firstname, ' ', middleName,' ', lastname)"/>
 
 		<property name="birthDate" column="birthdate" not-null="true"/>
 		

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java	2010-11-12 16:01:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java	2010-12-27 07:59:27 +0000
@@ -91,6 +91,7 @@
     // -------------------------------------------------------------------------
     // Input - name
     // -------------------------------------------------------------------------
+    
     private String firstName;
 
     private String middleName;

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientsByNameAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientsByNameAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientsByNameAction.java	2010-12-27 07:59:27 +0000
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.patient.action.patient;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ID : GetPatientsByNameAction.java Dec 23, 2010 9:14:34 AM $
+ */
+public class GetPatientsByNameAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PatientService patientService;
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private String firstName;
+
+    private String middleName;
+
+    private String lastName;
+
+    private List<Patient> patients;
+
+    // -------------------------------------------------------------------------
+    // Getter && Setter
+    // -------------------------------------------------------------------------
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
+    public void setFirstName( String firstName )
+    {
+        this.firstName = firstName;
+    }
+
+    public void setMiddleName( String middleName )
+    {
+        this.middleName = middleName;
+    }
+
+    public void setLastName( String lastName )
+    {
+        this.lastName = lastName;
+    }
+
+    public List<Patient> getPatients()
+    {
+        return patients;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        String fullName = StringUtils.join( new String[] { firstName, middleName, lastName }, ' ' );
+        
+        patients = new ArrayList<Patient>( patientService.getPatients( fullName ) );
+
+        return SUCCESS;
+    }
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java	2010-12-22 10:16:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java	2010-12-27 07:59:27 +0000
@@ -263,9 +263,6 @@
     }
 
     // -------------------------------------------------------------------------
-
-    // -------------------------------------------------------------------------
-    // Support methods
     // Support methods
     // -------------------------------------------------------------------------
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java	2010-12-27 03:17:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java	2010-12-27 07:59:27 +0000
@@ -67,13 +67,6 @@
     {
         this.description = description;
     }
-    
-    private Integer version;
-
-    public void setVersion( Integer version )
-    {
-        this.version = version;
-    }
 
     /**
      * Description of Date of Enrollment This description is differ from each

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2010-12-22 10:16:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2010-12-27 07:59:27 +0000
@@ -509,7 +509,13 @@
 		<property name="patientIdentifierTypeService"
 			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 	</bean>
-
+	
+	<bean id="org.hisp.dhis.patient.action.patient.GetPatientsByNameAction"
+		class="org.hisp.dhis.patient.action.patient.GetPatientsByNameAction"
+		scope="prototype">
+		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+	</bean>
+	
 	<!-- Patient-Program Enrollment -->
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2010-12-22 10:16:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2010-12-27 07:59:27 +0000
@@ -455,4 +455,7 @@
 not_enough_madatory_attribute = Not enough data for the mandatory attribute(s)
 get_data_error = Get data error
 common_info = Common information
-hierachy_orgunit = Hierachy Organisation Unit
\ No newline at end of file
+hierachy_orgunit = Hierachy Organisation Unit
+no_patients_found = No Patients Found
+similar_patients = Similar patients
+orgunit = Organisation Unit
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2010-12-10 04:02:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2010-12-27 07:59:27 +0000
@@ -474,7 +474,14 @@
 			</result>
 			<param name="requiredAuthorities">F_PATIENT_ADD</param>
 		</action>
-
+		
+		<action name="getPatientsByName"
+			class="org.hisp.dhis.patient.action.patient.GetPatientsByNameAction">
+			<result name="success" type="velocity">/popup.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/resultSearchPatients.vm</param>
+			<param name="requiredAuthorities">F_PATIENT_ADD</param>
+		</action>
+		
 		<!-- Patient-Program Enrollment -->
 
 		<action name="showProgramEnrollmentForm"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm	2010-12-10 05:57:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm	2010-12-27 07:59:27 +0000
@@ -52,7 +52,9 @@
 </script>
 
 <h3>$i18n.getString( "add_new_patient" )</h3>	
-																			
+
+<span id='searchResults' style='display:none' class="thickbox"></span>
+	
 <form id="addPatientForm" name="addPatientForm" action="addPatient.action" method="post">
 <input type="hidden" id="representativeId" name="representativeId"/> 
 <input type="hidden" id="relationshipTypeId" name="relationshipTypeId"/>
@@ -65,7 +67,7 @@
 	</tr>
 	<tr>
 		<td><label for="firstName">$i18n.getString( "first_name" )</label></td>
-		<td class="input-column" ><input type="text" id="firstName" name="firstName"  maxlength="30" class="required_group {validate:{required_group:true, unicodechars:true, rangelength:[2,30]}}" ></td>
+		<td class="input-column" ><input type="text" id="firstName" name="firstName"  maxlength="30" class="required_group {validate:{required_group:true, unicodechars:true, rangelength:[2,30]}}" onkeyup="startSearch(event)"></td>
 	</tr>
 	<tr>
 		<td><label for="middleName">$i18n.getString( "middle_name" ) </label></td>
@@ -74,7 +76,10 @@
 	<tr>
 		<td><label for="lastName">$i18n.getString( "last_name" )</label></td>
 		<td class="input-column"><input type="text" id="lastName" name="lastName" maxlength="30" class="required_group {validate:{required_group:true, unicodechars:true, rangelength:[2,30]}}"></td>
-	</tr>	
+	</tr>
+	<tr>
+        <td id="similarPatients" style="display:none" colspan='2'> $i18n.getString( "similar_patients" ): <span id="patientCount"></span> <a href="javascript:showSearchPatients();">(show/hide)</a></td>
+    </tr>
 	<tr><td>&nbsp;</td></tr>	
 	<tr>
 		<th colspan="2" class="heading-column">$i18n.getString( "demographics" )</th>
@@ -300,4 +305,5 @@
 	var i18n_child_representative = '$encoder.jsEscape( $i18n.getString( "child_representative" ) , "'")';
 	var checkedDuplicate = false;
     var i18n_oucode_must_have_9_digits = '$encoder.jsEscape( $i18n.getString( "oucode_must_be_valid" ) , "'")';
+	var i18n_no_patients_found = '$encoder.jsEscape( $i18n.getString( "no_patients_found" ) , "'")';
 </script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js	2010-12-08 03:16:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js	2010-12-27 07:59:27 +0000
@@ -696,3 +696,44 @@
 	byId('programEnrollmentForm').action = "removeEnrollment.action";
 	byId('programEnrollmentForm').submit();
 }
+
+// ----------------------------------------------------------------------------
+// Search patients by name
+// ----------------------------------------------------------------------------
+
+function startSearch()
+{	
+	var firstName = getFieldValue('firstName');
+	var middleName = getFieldValue('middleName');
+	var lastName = getFieldValue('lastName');
+	
+	var fullName = firstName + middleName + lastName; 
+	if( fullName.length < 3 ){
+		$("#similarPatients").hide();
+		return;
+	}
+	
+	$.post("getPatientsByName.action",
+		{
+			firstName: firstName,
+			middleName: middleName,
+			lastName: lastName
+		},
+		function (html)
+		{
+			jQuery("#similarPatients").show();
+			var patientCount = $('<div/>').html(html).find('#matchCount');
+			jQuery('#patientCount').html( patientCount );
+			jQuery('#searchResults').html( html );
+		},'html');
+}
+
+// ----------------------------------------------------------------------------
+// Show patients
+// ----------------------------------------------------------------------------
+
+function showSearchPatients(){
+	// tb_show(i18n_child_representative,'getPatientsByName.action?firstName='+ firstName +'&middleName=' + middleName + '&lastName=' + lastName +'&height=450&width=600',null);
+	tb_show( i18n_child_representative, "#TB_inline?height=350&width=580&inlineId=searchResults",null);
+	
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2010-11-25 22:22:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2010-12-27 07:59:27 +0000
@@ -5,6 +5,7 @@
 	<li><a href="patientAttributeGroup.action">$i18n.getString( "patient_attribute_group" )</a></li>
 	<li><a href="patientIdentifierType.action">$i18n.getString( "patient_identifier_type" )</a></li>
 	<li><a href="relationshipType.action">$i18n.getString( "relationship_type" )</a></li>
+	<li><a href="patient.action">$i18n.getString( "orgunit_registration" )</a></li>
 	<li><a href="program.action">$i18n.getString( "program" )</a></li>
 	<li><a href="programAttribute.action">$i18n.getString( "program_attribute" )</a></li>
 	<li><a href="caseAggregation.action">$i18n.getString( "case_aggregation_mapping" )</a></li>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/resultSearchPatients.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/resultSearchPatients.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/resultSearchPatients.vm	2010-12-27 07:59:27 +0000
@@ -0,0 +1,33 @@
+<span id="matchCount"><strong>$!patients.size() $i18n.getString('patients')</strong></span>
+<p></p>
+<table width='100%' id='searchTable' name='searchTable'>
+#if($!patients)
+	<thread><tr #alternate( true )>
+		<th><strong>$i18n.getString('full_name')</strong></th>
+		<th><strong>$i18n.getString( "age" )</strong></th>
+		<th><strong>$i18n.getString( "gender" )</strong></th>
+		<th><strong>$i18n.getString( "dob_type" )</strong></th>
+		<th><strong>$i18n.getString( "date_of_birth" )</strong></th>
+		<th><strong>$i18n.getString( "orgunit" )</strong></th>
+	</tr></thread>
+	<tbody>
+		#set($mark = false)
+		#foreach( $patient  in $patients )
+			<tr id="tr${patient.id}" #alternate($mark) onclick='window.location.href="showUpdatePatientForm.action?id=$patient.id"' style="cursor:pointer">
+				<td>$!patient.getFullName()</td>
+				<td>$!patient.getAge()</td>
+				<td>$!patient.gender</td>
+				<td>$!patient.dobType</td>
+				<td>$!patient.birthDate</td>
+				<td>$!patient.organisationUnit</td>
+			</tr>
+		#set($mark = !$mark)
+		#end
+	</tbody>
+#else
+	<tr>
+		<td colspan='5'><strong>i18n_no_patients_found</strong></td>
+	</tr>
+#end
+</table>
+