dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18413
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7755: (mobile) made getPatientsForMobile work correctly when filtering by OU
------------------------------------------------------------
revno: 7755
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-07-30 10:32:34 +0200
message:
(mobile) made getPatientsForMobile work correctly when filtering by OU
modified:
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/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/FindBeneficiarytAction.java
--
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/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2012-07-06 09:59:36 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2012-07-30 08:32:34 +0000
@@ -27,17 +27,10 @@
package org.hisp.dhis.patient;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import org.apache.commons.lang.StringUtils;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
import org.hisp.dhis.program.Program;
@@ -47,6 +40,9 @@
import org.hisp.dhis.relationship.RelationshipTypeService;
import org.springframework.transaction.annotation.Transactional;
+import java.lang.reflect.Type;
+import java.util.*;
+
/**
* @author Abyot Asalefew Gizaw
* @version $Id$
@@ -108,6 +104,13 @@
this.relationshipTypeService = relationshipTypeService;
}
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
// -------------------------------------------------------------------------
// Implementation methods
// -------------------------------------------------------------------------
@@ -120,7 +123,7 @@
@Override
public int createPatient( Patient patient, Integer representativeId, Integer relationshipTypeId,
- List<PatientAttributeValue> patientAttributeValues )
+ List<PatientAttributeValue> patientAttributeValues )
{
int patientid = savePatient( patient );
@@ -188,7 +191,7 @@
@Override
public Collection<Patient> getPatients( String firstName, String middleName, String lastName, Date birthdate,
- String gender )
+ String gender )
{
return patientStore.get( firstName, middleName, lastName, birthdate, gender );
}
@@ -249,29 +252,26 @@
@Override
public Collection<Patient> getPatientsForMobile( String searchText, int orgUnitId )
{
- int countPatientName = patientStore.countGetPatientsByName( searchText );
- int countPatientIndentifier = patientIdentifierService.countGetPatientsByIdentifier( searchText );
-
Set<Patient> patients = new HashSet<Patient>();
- patients.addAll( patientIdentifierService.getPatientsByIdentifier( searchText, 0, countPatientIndentifier ) );
-
- Collection<Patient> patientByName = getPatientsByNames( searchText, 0, countPatientName );
-
+ patients.addAll( patientIdentifierService.getPatientsByIdentifier( searchText, 0, Integer.MAX_VALUE ) );
+ patients.addAll( getPatientsByNames( searchText, 0, Integer.MAX_VALUE ) );
+
+ // if an orgunit has been selected, filter out every patient that has a different ou
if ( orgUnitId != 0 )
{
Set<Patient> toRemoveList = new HashSet<Patient>();
- for ( Patient patient : patientByName )
+
+ for ( Patient patient : patients )
{
if ( patient.getOrganisationUnit().getId() != orgUnitId )
{
toRemoveList.add( patient );
}
}
- patientByName.removeAll( toRemoveList );
+
+ patients.removeAll( toRemoveList );
}
- patients.addAll( patientByName );
-
return patients;
}
@@ -283,7 +283,7 @@
@Override
public Collection<Patient> getPatients( OrganisationUnit organisationUnit, PatientAttribute patientAttribute,
- Integer min, Integer max )
+ Integer min, Integer max )
{
List<Patient> patientList = new ArrayList<Patient>( patientStore.getByOrgUnit( organisationUnit, min, max ) );
@@ -299,7 +299,7 @@
@Override
public Collection<Patient> getPatients( OrganisationUnit organisationUnit, String searchText, Integer min,
- Integer max )
+ Integer max )
{
Collection<Patient> patients = new ArrayList<Patient>();
@@ -410,8 +410,8 @@
@Override
public void updatePatient( Patient patient, Integer representativeId, Integer relationshipTypeId,
- List<PatientAttributeValue> valuesForSave, List<PatientAttributeValue> valuesForUpdate,
- Collection<PatientAttributeValue> valuesForDelete )
+ List<PatientAttributeValue> valuesForSave, List<PatientAttributeValue> valuesForUpdate,
+ Collection<PatientAttributeValue> valuesForDelete )
{
patientStore.update( patient );
@@ -504,8 +504,7 @@
}
return value;
- }
- catch ( Exception ex )
+ } catch ( Exception ex )
{
ex.printStackTrace();
}
@@ -527,7 +526,7 @@
{
return patientStore.search( searchKeys, orgunit, min, max );
}
-
+
public int countSearchPatients( List<String> searchKeys, OrganisationUnit orgunit )
{
return patientStore.countSearch( searchKeys, orgunit );
=== 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 2012-07-26 11:26:41 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-07-30 08:32:34 +0000
@@ -238,6 +238,8 @@
ref="org.hisp.dhis.relationship.RelationshipTypeService" />
<property name="relationshipService"
ref="org.hisp.dhis.relationship.RelationshipService" />
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
</bean>
<bean id="org.hisp.dhis.patient.PatientIdentifierService" class="org.hisp.dhis.patient.DefaultPatientIdentifierService">
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/FindBeneficiarytAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/FindBeneficiarytAction.java 2012-06-11 10:11:21 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/FindBeneficiarytAction.java 2012-07-30 08:32:34 +0000
@@ -26,10 +26,11 @@
*/
package org.hisp.dhis.light.namebaseddataentry.action;
-import java.util.Collection;
+import com.opensymphony.xwork2.Action;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientService;
-import com.opensymphony.xwork2.Action;
+
+import java.util.Collection;
public class FindBeneficiarytAction
implements Action
@@ -146,6 +147,7 @@
}
patients = patientService.getPatientsForMobile( keyword, organisationUnitId );
+
if ( patients.size() == 1 )
{
Patient patient = patients.iterator().next();