dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18181
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7564: Add two operators for birthdate; fix bug when to search by birthdate.
------------------------------------------------------------
revno: 7564
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-07-10 21:05:24 +0700
message:
Add two operators for birthdate; fix bug when to search by birthdate.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java
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/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-api/src/main/java/org/hisp/dhis/patient/Patient.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2012-07-06 09:59:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2012-07-10 14:05:24 +0000
@@ -63,7 +63,7 @@
public static String PREFIX_FIXED_ATTRIBUTE = "fixedAttr";
public static String PREFIX_PATIENT_ATTRIBUTE = "attr";
public static String PREFIX_PROGRAM = "prg";
-
+ public static String FIXED_ATTR_BIRTH_DATE = "birthDate";
private Integer id;
=== 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 2012-07-10 07:16:10 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2012-07-10 14:05:24 +0000
@@ -210,7 +210,7 @@
fullName = fullName.toLowerCase();
String sql = "SELECT count(*) FROM patient where lower( " + statementBuilder.getPatientFullName() + ") "
+ "like '%" + fullName + "%' ";
-
+
return jdbcTemplate.queryForInt( sql );
}
@@ -320,7 +320,15 @@
if ( keys[0].equals( Patient.PREFIX_FIXED_ATTRIBUTE ) )
{
- patientWhere += patientOperator + " lower(p." + id + ")='" + value + "'";
+ patientWhere += patientOperator;
+ if ( id.equals( Patient.FIXED_ATTR_BIRTH_DATE ) )
+ {
+ patientWhere += " p." + id + value;
+ }
+ else
+ {
+ patientWhere += " lower(p." + id + ")='" + value + "'";
+ }
patientOperator = " and ";
}
else if ( keys[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) )
=== 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 2012-07-10 07:46:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2012-07-10 14:05:24 +0000
@@ -128,8 +128,8 @@
function getDateField( container )
{
- var dateField = '<select id="dateOperator" style="width:30px;" name="dateOperator" ><option value=">"> > </option><option value="="> = </option><option value="<"> < </option></select>';
- dateField += '<input type="text" id="searchText_' + container + '" name="searchText" style="width:210px;">';
+ var dateField = '<select id="dateOperator" style="width:40px;" name="dateOperator" ><option value="="> = </option><option value="<"> < </option><option value="<="> <= </option><option value=">"> > </option><option value=">="> >= </option></select>';
+ dateField += '<input type="text" id="searchText_' + container + '" name="searchText" style="width:200px;">';
return dateField;
}
@@ -191,12 +191,22 @@
if(flag){
jQuery( '#advancedSearchTB tbody tr' ).each( function( i, row ){
+ var dateOperator = "";
jQuery( this ).find(':input').each( function( idx, item ){
if( idx == 0){
params += "searchTexts=" + item.value;
}
- else if( idx == 1){
- params += "_" + htmlEncode( item.value.toLowerCase() );
+ else if( item.name == 'dateOperator'){
+ dateOperator = item.value;
+ }
+ else if( item.name == 'searchText'){
+ params += "_";
+ if ( dateOperator.length >0 ) {
+ params += dateOperator + "'" + item.value.toLowerCase() + "'";
+ }
+ else{
+ params += htmlEncode( item.value.toLowerCase() );
+ }
}
})
});