← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2412: Nested Search Engine for Patient module ( finished ) and add HierarchyOrgunit column into searche...

 

------------------------------------------------------------
revno: 2412
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2010-12-22 17:16:53 +0700
message:
  Nested Search Engine for Patient module ( finished ) and add HierarchyOrgunit column into searched list of patients .
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/state/SelectedStateManager.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  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/listPatient.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-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java	2010-12-22 07:59:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java	2010-12-22 10:16:53 +0000
@@ -39,7 +39,6 @@
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.patient.state.SelectedStateManager;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.relationship.Relationship;
@@ -52,13 +51,15 @@
 public class SearchPatientAction
     extends ActionPagingSupport<Patient>
 {
+    public static String LIST_ALL_PATIENT = "All";
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
 
     private OrganisationUnitSelectionManager selectionManager;
 
-    private SelectedStateManager selectedStateManager;
+    // private SelectedStateManager selectedStateManager;
 
     private PatientService patientService;
 
@@ -94,6 +95,8 @@
 
     private Map<Patient, String> mapPatientPatientAttr = new HashMap<Patient, String>();
 
+    private Map<Patient, String> mapPatientOrgunit = new HashMap<Patient, String>();
+
     // -------------------------------------------------------------------------
     // Getters/Setters
     // -------------------------------------------------------------------------
@@ -103,16 +106,16 @@
         this.selectionManager = selectionManager;
     }
 
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
     public void setPatientService( PatientService patientService )
     {
         this.patientService = patientService;
     }
 
+    public Map<Patient, String> getMapPatientOrgunit()
+    {
+        return mapPatientOrgunit;
+    }
+
     public void setPatientAttributeService( PatientAttributeService patientAttributeService )
     {
         this.patientAttributeService = patientAttributeService;
@@ -211,43 +214,34 @@
         // ---------------------------------------------------------------------
 
         PatientAttribute sortingPatientAttribute = null;
-        if ( sortPatientAttributeId == null )
-        {
-            selectedStateManager.clearSortingAttributeId();
-
-        }
-        else
+        
+        if ( sortPatientAttributeId != null )
         {
             sortingPatientAttribute = patientAttributeService.getPatientAttribute( sortPatientAttributeId );
-            selectedStateManager.setSortingAttributeId( sortPatientAttributeId );
         }
-
+        
         // ---------------------------------------------------------------------
         // Get and searching patient-attribute
         // ---------------------------------------------------------------------
-
+       
         PatientAttribute searchingPatientAttribute = null;
-        if ( searchingAttributeId == null )
-        {
-            selectedStateManager.clearSearchingAttributeId();
-        }
-        else
+        if ( searchingAttributeId != null )
         {
             searchingPatientAttribute = patientAttributeService.getPatientAttribute( searchingAttributeId );
-            selectedStateManager.setSearchingAttributeId( searchingAttributeId );
         }
-
+        
         // ---------------------------------------------------------------------
         // Get all of patient into the selected organisation unit
         // ---------------------------------------------------------------------
-
-        if ( listAll )
+        
+        if ( listAll || ( searchText != null && searchText.equalsIgnoreCase( LIST_ALL_PATIENT ) ) )
         {
-            searchText = SelectedStateManager.LIST_ALL_PATIENT;
-
+            searchText = LIST_ALL_PATIENT;
+            
             OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
-
+            
             listAllPatient( organisationUnit, sortingPatientAttribute );
+            
         }
 
         // ---------------------------------------------------------------------
@@ -259,8 +253,10 @@
         {
             searchPatientByAttribute( searchingPatientAttribute, searchText, sortingPatientAttribute );
         }
-
-        selectedStateManager.setSearchText( searchText );
+        else if ( searchingPatientAttribute == null && searchText != null )
+        {
+            searchPatientByAttribute( searchText, sortingPatientAttribute );
+        }
         
         return SUCCESS;
 
@@ -276,11 +272,11 @@
     private void listAllPatient( OrganisationUnit organisationUnit, PatientAttribute sortingPatientAttribute )
     {
         // Get patients by the selected organisation - unit
-        
+
         total = patientService.countGetPatientsByOrgUnit( organisationUnit );
-        
+
         this.paging = createPaging( total );
-        
+
         patients = new ArrayList<Patient>( patientService.getPatients( organisationUnit, paging.getStartPos(), paging
             .getPageSize() ) );
 
@@ -306,11 +302,6 @@
     private void searchPatientByAttribute( PatientAttribute searchingPatientAttribute, String searchText,
         PatientAttribute sortingPatientAttribute )
     {
-        selectedStateManager.clearListAll();
-
-        selectedStateManager.setSearchingAttributeId( searchingAttributeId );
-        selectedStateManager.setSearchText( searchText );
-
         total = patientAttributeValueService.countSearchPatientAttributeValue( searchingPatientAttribute, searchText );
         this.paging = createPaging( total );
 
@@ -327,17 +318,77 @@
             for ( Patient patient : patients )
             {
                 mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
-                if ( sortingPatientAttribute != null )
-                {
-                    PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue(
-                        patient, sortingPatientAttribute );
-                    String value = (attributeValue == null) ? "" : attributeValue.getValue();
-
-                    mapPatientPatientAttr.put( patient, value );
-                }
-            }
-        }
-
-    }
-    
+
+                // -------------------------------------------------------------
+                // Get hierarchy organisation unit
+                // -------------------------------------------------------------
+
+                mapPatientOrgunit.put( patient, getHierarchyOrgunit( patient.getOrganisationUnit() ) );
+
+                // -------------------------------------------------------------
+                // Sort patients
+                // -------------------------------------------------------------
+
+                if ( sortingPatientAttribute != null )
+                {
+                    PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue(
+                        patient, sortingPatientAttribute );
+                    String value = (attributeValue == null) ? "" : attributeValue.getValue();
+
+                    mapPatientPatientAttr.put( patient, value );
+                }
+            }
+        }
+
+    }
+
+    private void searchPatientByAttribute( String searchText, PatientAttribute sortingPatientAttribute )
+    {
+        total = patientService.countGetPatients( searchText );
+        this.paging = createPaging( total );
+        patients = patientService.getPatients( searchText, paging.getStartPos(), paging.getPageSize() );
+
+        if ( patients != null && patients.size() > 0 )
+        {
+            if ( sortPatientAttributeId != null && sortingPatientAttribute != null )
+            {
+                patients = patientService.sortPatientsByAttribute( patients, sortingPatientAttribute );
+            }
+            for ( Patient patient : patients )
+            {
+                // -------------------------------------------------------------
+                // Get hierarchy organisation unit
+                // -------------------------------------------------------------
+
+                mapPatientOrgunit.put( patient, getHierarchyOrgunit( patient.getOrganisationUnit() ) );
+
+                // -------------------------------------------------------------
+                // Sort patients
+                // -------------------------------------------------------------
+
+                if ( sortingPatientAttribute != null )
+                {
+                    PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue(
+                        patient, sortingPatientAttribute );
+                    String value = (attributeValue == null) ? "" : attributeValue.getValue();
+
+                    mapPatientPatientAttr.put( patient, value );
+                }
+            }
+        }
+    }
+
+    private String getHierarchyOrgunit( OrganisationUnit orgunit )
+    {
+        String hierarchyOrgunit = orgunit.getName();
+        
+        while ( orgunit.getParent() != null )
+        {
+            hierarchyOrgunit = orgunit.getParent().getName() + " / " + hierarchyOrgunit;
+        
+            orgunit = orgunit.getParent();
+        }
+        
+        return hierarchyOrgunit;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/state/SelectedStateManager.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/state/SelectedStateManager.java	2010-12-22 07:59:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/state/SelectedStateManager.java	2010-12-22 10:16:53 +0000
@@ -38,7 +38,7 @@
  */
 public interface SelectedStateManager
 {
-    public static String LIST_ALL_PATIENT = "All";
+    
     
     OrganisationUnit getSelectedOrganisationUnit();
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2010-11-25 22:22:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2010-12-22 10:16:53 +0000
@@ -384,8 +384,6 @@
 		scope="prototype">
 		<property name="selectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		<property name="selectedStateManager"
-			ref="org.hisp.dhis.patient.state.SelectedStateManager" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />

=== 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	2010-12-09 06:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2010-12-22 10:16:53 +0000
@@ -455,4 +455,4 @@
 not_enough_madatory_attribute = Not enough data for the mandatory attribute(s)
 get_data_error = Get data error
 common_info = Common information
- 
\ No newline at end of file
+hierachy_orgunit = Hierachy Organisation Unit
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm	2010-12-08 03:16:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm	2010-12-22 10:16:53 +0000
@@ -62,7 +62,11 @@
           <tr>
             <th>#</th>
             #if($mapPatientPatientAttr.size()!=0)
-                <th>$patientAttribute.name</th>
+                <th id="patientAttributeName"></th>
+				<script>
+					var selectedAttr = byId("sortPatientAttributeId");
+					byId('patientAttributeName').innerHTML = selectedAttr.options[selectedAttr.selectedIndex].text;
+				</script>
             #end
             <th>$i18n.getString( "first_name" )</th>
             <th>$i18n.getString( "middle_name" )</th>
@@ -70,7 +74,10 @@
             <th>$i18n.getString( "gender" )</th>
             <th>$i18n.getString( "date_of_birth" )</th> 
             <th>$i18n.getString( "age" )</th>
-            <th colspan="7" style="text-align:center">$i18n.getString( "operations" )</th>
+			#if($mapPatientOrgunit.size()!=0)
+			<th>$i18n.getString( "hierachy_orgunit" )</th>
+			#end
+            <th colspan="8" style="text-align:center">$i18n.getString( "operations" )</th>
           </tr>
           
           <tbody id="list">	
@@ -80,10 +87,10 @@
           	<td>
                     #set( $nr = ( ( $paging.getCurrentPage() - 1  ) * $paging.pageSize ) + $velocityCount )
                     $nr
-		</td>
-                #if($mapPatientPatientAttr.size()!=0)
+			</td>
+                #if($!mapPatientPatientAttr.size()!=0)
                     <td>
-                        $mapPatientPatientAttr.get($patient)
+                        $!mapPatientPatientAttr.get($patient)
                     </td>
                 #end
                 
@@ -105,7 +112,9 @@
 		<td>            
                     $!patient.getAge()
         </td>
-				
+        <td>
+					$!mapPatientOrgunit.get($patient)
+        </td>
 		<td style="text-align:center"#alternate( $mark )>
                   <a href="showProgramEnrollmentForm.action?id=$patient.id" title="$i18n.getString( "manage_program_enrollment" )"><img src="../images/enroll.png" alt="$i18n.getString( "manage_program_enrollment" )"></a>                  
                 </td>