=== 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 { + 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 mapPatientPatientAttr = new HashMap(); + private Map mapPatientOrgunit = new HashMap(); + // ------------------------------------------------------------------------- // 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 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( 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"> - === 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 @@ # #if($mapPatientPatientAttr.size()!=0) - $patientAttribute.name + + #end $i18n.getString( "first_name" ) $i18n.getString( "middle_name" ) @@ -70,7 +74,10 @@ $i18n.getString( "gender" ) $i18n.getString( "date_of_birth" ) $i18n.getString( "age" ) - $i18n.getString( "operations" ) + #if($mapPatientOrgunit.size()!=0) + $i18n.getString( "hierachy_orgunit" ) + #end + $i18n.getString( "operations" ) @@ -80,10 +87,10 @@ #set( $nr = ( ( $paging.getCurrentPage() - 1 ) * $paging.pageSize ) + $velocityCount ) $nr - - #if($mapPatientPatientAttr.size()!=0) + + #if($!mapPatientPatientAttr.size()!=0) - $mapPatientPatientAttr.get($patient) + $!mapPatientPatientAttr.get($patient) #end @@ -105,7 +112,9 @@ $!patient.getAge() - + + $!mapPatientOrgunit.get($patient) + $i18n.getString(