dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24699
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12151: Allow to search person by sub-string matching.
------------------------------------------------------------
revno: 12151
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-09-19 12:24:04 +0700
message:
Allow to search person by sub-string matching.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.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/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueDeletionHandler.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
--
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/PatientDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java 2013-09-19 03:24:26 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java 2013-09-19 05:24:04 +0000
@@ -32,7 +32,6 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.system.deletion.DeletionHandler;
-import org.springframework.jdbc.core.JdbcTemplate;
public class PatientDeletionHandler
extends DeletionHandler
=== 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-09-18 03:49:35 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-09-19 05:24:04 +0000
@@ -467,6 +467,7 @@
String[] keys = searchKey.split( "_" );
String id = keys[1];
String value = "";
+
if ( keys.length >= 3 )
{
value = keys[2];
@@ -495,15 +496,21 @@
}
else if ( keys[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) )
{
- patientWhere += patientOperator + "( ( lower( " + statementBuilder.getPatientFullName() + " ) like '%"
- + id + "%' ) or lower(pi.identifier) like '%" + id + "%' ";
String[] keyValues = id.split( " " );
+ patientWhere += patientOperator + "(";
+ String opt = "";
+ for ( String v : keyValues )
+ {
+ patientWhere += opt + " lower( p.name ) like '%" + v
+ + "%' or lower(pi.identifier) like '%" + v + "%' ";
+ opt = "or";
+ }
+
if ( keyValues.length == 2 )
{
String otherId = keyValues[0] + " " + keyValues[1];
- patientWhere += " or lower( " + statementBuilder.getPatientFullName() + " ) like '%" + otherId
- + "%' ";
+ patientWhere += " or lower( p.name ) like '%" + otherId + "%' ";
}
patientWhere += ")";
patientOperator = " and ";
@@ -513,7 +520,17 @@
{
sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid="
+ id + " ) as " + Patient.PREFIX_PATIENT_ATTRIBUTE + "_" + id + ",";
- otherWhere += operator + "lower(" + Patient.PREFIX_PATIENT_ATTRIBUTE + "_" + id + ")='" + value + "'";
+
+ String[] keyValues = value.split( " " );
+ otherWhere += operator + "(";
+ String opt = "";
+ for ( String v : keyValues )
+ {
+ otherWhere += opt + " lower(" + Patient.PREFIX_PATIENT_ATTRIBUTE + "_" + id + ") like '%" + v + "%'";
+ opt = "or";
+ }
+ otherWhere += ")";
+
operator = " and ";
}
else if ( keys[0].equals( Patient.PREFIX_PROGRAM ) )
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueDeletionHandler.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueDeletionHandler.java 2013-09-19 05:24:04 +0000
@@ -32,7 +32,6 @@
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.system.deletion.DeletionHandler;
/**
@@ -53,14 +52,7 @@
{
this.patientAttributeValueService = patientAttributeValueService;
}
-
- private PatientService patientService;
-
- public void setPatientService( PatientService patientService )
- {
- this.patientService = patientService;
- }
-
+
// -------------------------------------------------------------------------
// DeletionHandler implementation
// -------------------------------------------------------------------------
@@ -92,11 +84,7 @@
{
for ( PatientAttributeValue attributeValue : attributeValues )
{
- Patient patient = attributeValue.getPatient();
patientAttributeValueService.deletePatientAttributeValue( attributeValue );
-
- patient.getAttributes().remove( patientAttribute );
- patientService.updatePatient( patient );
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-09-19 03:24:26 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-09-19 05:24:04 +0000
@@ -337,7 +337,6 @@
class="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler">
<property name="patientAttributeValueService"
ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
- <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
</bean>
<bean id="org.hisp.dhis.program.ProgramDeletionHandler" class="org.hisp.dhis.program.ProgramDeletionHandler">