dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15474
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5619: Remove available patients from the relationship list when searching in Add new relationship form.
------------------------------------------------------------
revno: 5619
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-27 14:35:54 +0700
message:
Remove available patients from the relationship list when searching in Add new relationship form.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java
dhis-2/dhis-web/dhis-web-caseentry/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-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java 2011-09-14 06:36:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java 2011-12-27 07:35:54 +0000
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientAttribute;
@@ -36,6 +37,8 @@
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
+import org.hisp.dhis.relationship.Relationship;
+import org.hisp.dhis.relationship.RelationshipService;
import com.opensymphony.xwork2.Action;
@@ -72,6 +75,13 @@
this.patientAttributeValueService = patientAttributeValueService;
}
+ private RelationshipService relationshipService;
+
+ public void setRelationshipService( RelationshipService relationshipService )
+ {
+ this.relationshipService = relationshipService;
+ }
+
// -------------------------------------------------------------------------
// Input/Output
// -------------------------------------------------------------------------
@@ -122,8 +132,6 @@
public String execute()
throws Exception
{
- Patient patient = patientService.getPatient( patientId );
-
if ( searchText != null && searchText.length() > 0 )
searchText = searchText.trim();
@@ -135,9 +143,9 @@
searchText = keys[0] + " " + keys[1];
}
- if ( searchingAttributeId != null && searchText != null )
+ if ( searchText != null && !searchText.isEmpty() )
{
- if ( searchText.length() > 0 )
+ if ( searchingAttributeId != null )
{
PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( searchingAttributeId );
@@ -149,22 +157,30 @@
patients.add( patientAttributeValue.getPatient() );
}
- patients.remove( patient );
-
- return SUCCESS;
}
-
- }
-
- if ( searchText != null )
- {
- if ( searchText.length() > 0 )
+ else
{
patients = patientService.getPatientsByNames( searchText );
-
- patients.remove( patient );
-
- return SUCCESS;
+ }
+ }
+ if ( patients != null && !patients.isEmpty() )
+ {
+ Patient patient = patientService.getPatient( patientId );
+
+ patients.remove( patient );
+
+ Collection<Relationship> relationships = relationshipService.getRelationshipsForPatient( patient );
+
+ if ( relationships != null )
+ {
+ Iterator<Relationship> iter = relationships.iterator();
+
+ while ( iter.hasNext() )
+ {
+ Relationship relationship = iter.next();
+ patients.remove( relationship.getPatientA() );
+ patients.remove( relationship.getPatientB() );
+ }
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2011-12-16 06:45:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2011-12-27 07:35:54 +0000
@@ -734,6 +734,8 @@
ref="org.hisp.dhis.patient.PatientAttributeService" />
<property name="patientAttributeValueService"
ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+ <property name="relationshipService"
+ ref="org.hisp.dhis.relationship.RelationshipService" />
</bean>
<bean