dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13333
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4247: Advanced search by fullname and validate for search text field ( Patient module ).
------------------------------------------------------------
revno: 4247
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-08-03 09:51:23 +0700
message:
Advanced search by fullname and validate for search text field ( Patient module ).
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java
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/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/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/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java 2011-08-02 09:12:51 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java 2011-08-03 02:51:23 +0000
@@ -205,6 +205,7 @@
private String createHQL( Integer patientAttributeId, String searchText, int index, int noCondition )
{
String hql = "";
+ searchText = searchText.trim();
boolean isSearchByAttribute = true;
// ---------------------------------------------------------------------
@@ -212,12 +213,40 @@
// ---------------------------------------------------------------------
if ( patientAttributeId == null )
{
+// hql += " ( SELECT p" + index + " FROM Patient as p" + index + " JOIN p" + index
+// + ".identifiers as identifier" + index + " " + "WHERE lower(identifier" + index
+// + ".identifier) LIKE lower('%" + searchText + "%') " + "OR lower(p" + index
+// + ".firstName) LIKE lower('%" + searchText + "%') " + "OR lower(p" + index
+// + ".middleName) LIKE lower('%" + searchText + "%') " + "OR lower(p" + index
+// + ".lastName) LIKE lower('%" + searchText + "%') ";
+ int startIndex = searchText.indexOf( ' ' );
+ int endIndex = searchText.lastIndexOf( ' ' );
+
+ String firstName = searchText.toString();
+ String middleName = "";
+ String lastName = "";
+
+ if ( searchText.indexOf( ' ' ) != -1 )
+ {
+ firstName = searchText.substring( 0, startIndex );
+ if ( startIndex == endIndex )
+ {
+ middleName = "";
+ lastName = searchText.substring( startIndex + 1, searchText.length() );
+ }
+ else
+ {
+ middleName = searchText.substring( startIndex + 1, endIndex );
+ lastName = searchText.substring( endIndex + 1, searchText.length() );
+ }
+ }
+
hql += " ( SELECT p" + index + " FROM Patient as p" + index + " JOIN p" + index
+ ".identifiers as identifier" + index + " " + "WHERE lower(identifier" + index
- + ".identifier) LIKE lower('%" + searchText + "%') " + "OR lower(p" + index
- + ".firstName) LIKE lower('%" + searchText + "%') " + "OR lower(p" + index
- + ".middleName) LIKE lower('%" + searchText + "%') " + "OR lower(p" + index
- + ".lastName) LIKE lower('%" + searchText + "%') ";
+ + ".identifier) LIKE lower('%" + searchText + "%') " + "OR (lower(p" + index
+ + ".firstName) LIKE lower('%" + firstName + "%') " + "AND lower(p" + index
+ + ".middleName) = lower('" + middleName + "') " + "AND lower(p" + index
+ + ".lastName) LIKE lower('%" + lastName + "%')) ";
isSearchByAttribute = false;
}
=== 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 2011-08-01 02:39:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-08-03 02:51:23 +0000
@@ -175,7 +175,7 @@
selected_members = Selected Members
house_hold_members_management = Household Members Management
house_hold_details = HouseHold Details
-specify_a_search_criteria = Please specify your search criteria
+specify_search_criteria = Please specify your search criteria
no_matching_found = No matching found
updating_house_hold_failed = Updating Household Failed
adding_house_hold_failed = Adding Household Failed
=== 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 2011-08-02 09:12:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js 2011-08-03 02:51:23 +0000
@@ -121,12 +121,15 @@
function searchPatients()
{
hideById( 'listPatientDiv' );
-
- if( getFieldValue('searchText') == '' )
- {
- showWarningMessage( i18n_specify_a_search_criteria );
- return;
- }
+ var searchTextFields = jQuery('[name=searchText]');
+ $( searchTextFields ).each( function( i, item )
+ {
+ if( jQuery( item ).val() == '' )
+ {
+ showWarningMessage( i18n_specify_search_criteria );
+ return;
+ }
+ });
contentDiv = 'listPatientDiv';
$( "#loaderDiv" ).show();
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/selectPatient.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/selectPatient.vm 2011-08-02 09:12:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/selectPatient.vm 2011-08-03 02:51:23 +0000
@@ -63,7 +63,7 @@
var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ) , "'")';
var i18n_can_not_register_patient_for_orgunit = '$encoder.jsEscape( $i18n.getString( "can_not_register_patient_for_orgunit" ), "'")';
var i18n_please_select_village = '[' + '$encoder.jsEscape( $i18n.getString( "please_select_village" ), "'")' + ']';
- var i18n_specify_a_search_criteria = '$encoder.jsEscape( $i18n.getString( "specify_a_search_criteria" ) , "'")';
+ var i18n_specify_search_criteria = '$encoder.jsEscape( $i18n.getString( "specify_search_criteria" ) , "'")';
var i18n_select_program = '[' + '$encoder.jsEscape( $i18n.getString( "select_program" ), "'")' + ']';
var i18n_save_success = '$encoder.jsEscape( $i18n.getString( "save_success" ) , "'")';
var i18n_list_all_patient = '$encoder.jsEscape( $i18n.getString( "list_all_patient" ) , "'")';