=== 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 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 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 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 getPatients( String searchText, int min, int max ) { - int countPatientName = patientStore.countGetPatientsByNames( searchText ); + int countPatientName = patientStore.countGetPatientsByName( searchText ); Set patients = new HashSet(); @@ -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 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 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 @@ + + === 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 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 getPatients() + { + return patients; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + String fullName = StringUtils.join( new String[] { firstName, middleName, lastName }, ' ' ); + + patients = new ArrayList( 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 @@ - + + + + + F_PATIENT_ADD - + + + /popup.vm + /dhis-web-maintenance-patient/resultSearchPatients.vm + F_PATIENT_ADD + +

$i18n.getString( "add_new_patient" )

- + + +
@@ -65,7 +67,7 @@ - + @@ -74,7 +76,10 @@ - + + + $i18n.getString( "similar_patients" ): (show/hide) +   $i18n.getString( "demographics" ) @@ -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" ) , "'")'; \ 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 = $('
').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 @@
  • $i18n.getString( "patient_attribute_group" )
  • $i18n.getString( "patient_identifier_type" )
  • $i18n.getString( "relationship_type" )
  • +
  • $i18n.getString( "orgunit_registration" )
  • $i18n.getString( "program" )
  • $i18n.getString( "program_attribute" )
  • $i18n.getString( "case_aggregation_mapping" )
  • === 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 @@ +$!patients.size() $i18n.getString('patients') +

    + +#if($!patients) + + + + + + + + + + #set($mark = false) + #foreach( $patient in $patients ) + + + + + + + + + #set($mark = !$mark) + #end + +#else + + + +#end +
    $i18n.getString('full_name')$i18n.getString( "age" )$i18n.getString( "gender" )$i18n.getString( "dob_type" )$i18n.getString( "date_of_birth" )$i18n.getString( "orgunit" )
    $!patient.getFullName()$!patient.getAge()$!patient.gender$!patient.dobType$!patient.birthDate$!patient.organisationUnit
    i18n_no_patients_found
    +