=== 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 2011-01-20 05:20:01 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java 2011-02-24 06:02:31 +0000 @@ -42,6 +42,8 @@ import org.hisp.dhis.patient.state.SelectedStateManager; import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.relationship.Relationship; import org.hisp.dhis.relationship.RelationshipService; @@ -68,6 +70,8 @@ private RelationshipService relationshipService; + private ProgramService programService; + // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -80,6 +84,8 @@ private Integer sortPatientAttributeId; + private Integer programId; + // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- @@ -99,7 +105,11 @@ private PatientAttribute sortingPatientAttribute = null; private PatientAttribute searchingPatientAttribute = null; - + + private Collection programs; + + private Program program; + // ------------------------------------------------------------------------- // Getters/Setters // ------------------------------------------------------------------------- @@ -109,16 +119,36 @@ this.selectionManager = selectionManager; } + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + public void setPatientService( PatientService patientService ) { this.patientService = patientService; } + public Program getProgram() + { + return program; + } + + public void setProgram( Program program ) + { + this.program = program; + } + public Map getMapPatientOrgunit() { return mapPatientOrgunit; } - + + public Collection getPrograms() + { + return programs; + } + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) { this.patientAttributeService = patientAttributeService; @@ -154,6 +184,11 @@ return searchingAttributeId; } + public void setProgramId( Integer programId ) + { + this.programId = programId; + } + public void setSearchingAttributeId( Integer searchingAttributeId ) { this.searchingAttributeId = searchingAttributeId; @@ -214,22 +249,24 @@ OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); // --------------------------------------------------------------------- - // Get all of Patient-Attributes + // Get all of Patient-Attributes + // and programs by selected organisation unit // --------------------------------------------------------------------- patientAttributes = patientAttributeService.getAllPatientAttributes(); - - getParamsToSearch(); + programs = programService.getPrograms( organisationUnit ); + getParamsToSearch(); // --------------------------------------------------------------------- // Get all of patient into the selected organisation unit // --------------------------------------------------------------------- - + if ( listAll != null && listAll ) { selectedStateManager.clearSearchingAttributeId(); selectedStateManager.clearSortingAttributeId(); selectedStateManager.clearSearchText(); + selectedStateManager.clearSelectedProgram(); selectedStateManager.setListAll( listAll ); listAllPatient( organisationUnit, sortingPatientAttribute ); @@ -238,6 +275,31 @@ } // --------------------------------------------------------------------- + // Get patients by the selected program + // --------------------------------------------------------------------- + + if ( searchingAttributeId != null && searchingAttributeId == 0 && programId != null ) + { + program = programService.getProgram( programId ); + + if ( sortPatientAttributeId != null ) + { + selectedStateManager.setSortingAttributeId( sortPatientAttributeId ); + } + else + { + selectedStateManager.clearSortingAttributeId(); + } + + selectedStateManager.setSelectedProgram( program ); + selectedStateManager.setSearchingAttributeId( searchingAttributeId ); + + searchPatientByProgram( organisationUnit, program, sortingPatientAttribute ); + + return SUCCESS; + } + + // --------------------------------------------------------------------- // Get patients by searchingAttributeId and searchText // and sort result by sortingAttributeId // --------------------------------------------------------------------- @@ -246,11 +308,17 @@ { selectedStateManager.clearListAll(); selectedStateManager.setSearchingAttributeId( searchingAttributeId ); - - if( sortPatientAttributeId != null ) + + if ( sortPatientAttributeId != null ) { selectedStateManager.setSortingAttributeId( sortPatientAttributeId ); - }else + } + else + { + selectedStateManager.clearSortingAttributeId(); + } + + if ( programId != null ) { selectedStateManager.clearSortingAttributeId(); } @@ -261,53 +329,63 @@ return SUCCESS; } - + if ( searchingPatientAttribute == null && searchText != null ) { selectedStateManager.clearListAll(); - + selectedStateManager.clearSearchingAttributeId(); - - if( sortPatientAttributeId != null ) + + if ( sortPatientAttributeId != null ) { selectedStateManager.setSortingAttributeId( sortPatientAttributeId ); - }else + } + else + { + selectedStateManager.clearSortingAttributeId(); + } + + if ( programId != null ) { selectedStateManager.clearSortingAttributeId(); } - selectedStateManager.setSearchText( searchText ); - + searchPatientByAttribute( searchText, sortingPatientAttribute ); - + return SUCCESS; } - + // --------------------------------------------------------------------- // Search patients by values into section // --------------------------------------------------------------------- listAll = selectedStateManager.getListAll(); - - if ( listAll ) - { - listAllPatient( organisationUnit, sortingPatientAttribute ); - - return SUCCESS; - - } - searchingAttributeId = selectedStateManager.getSearchingAttributeId(); sortPatientAttributeId = selectedStateManager.getSortAttributeId(); searchText = selectedStateManager.getSearchText(); - + program = selectedStateManager.getSelectedProgram(); + getParamsToSearch(); + if ( listAll ) + { + listAllPatient( organisationUnit, sortingPatientAttribute ); + + return SUCCESS; + + } + + if ( searchingAttributeId != null && searchingAttributeId == 0 && program != null ) + { + searchPatientByProgram( organisationUnit, program, sortingPatientAttribute ); + return SUCCESS; + } + if ( searchingAttributeId != null && searchText != null ) { searchPatientByAttribute( searchText, sortingPatientAttribute ); - return SUCCESS; } @@ -316,7 +394,7 @@ searchPatientByAttribute( searchText, sortingPatientAttribute ); return SUCCESS; } - + return SUCCESS; } @@ -329,7 +407,7 @@ // --------------------------------------------------------------------- // Get sorting patient-attribute // --------------------------------------------------------------------- - + if ( sortPatientAttributeId != null ) { sortingPatientAttribute = patientAttributeService.getPatientAttribute( sortPatientAttributeId ); @@ -375,6 +453,35 @@ } } + private void searchPatientByProgram( OrganisationUnit organisationUnit, Program program, + PatientAttribute sortingPatientAttribute ) + { + total = patientService.countGetPatientsByOrgUnitProgram( organisationUnit, program ); + + this.paging = createPaging( total ); + + patients = new ArrayList( patientService.getPatients( organisationUnit, program, paging.getStartPos(), + paging.getPageSize() ) ); + + if ( patients != null && patients.size() > 0 ) + { + for ( Patient patient : patients ) + { + mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) ); + + // Get patient-attribute-values + if ( sortingPatientAttribute != null ) + { + PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( + patient, sortingPatientAttribute ); + String value = (attributeValue == null) ? "" : attributeValue.getValue(); + + mapPatientPatientAttr.put( patient, value ); + } + } + } + } + private void searchPatientByAttribute( PatientAttribute searchingPatientAttribute, String searchText, PatientAttribute sortingPatientAttribute ) { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java 2010-10-30 08:35:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java 2011-02-24 06:02:31 +0000 @@ -33,6 +33,8 @@ import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.patient.PatientAttribute; import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; import com.opensymphony.xwork2.Action; @@ -62,6 +64,13 @@ this.patientAttributeService = patientAttributeService; } + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + // ------------------------------------------------------------------------- // Input/output // ------------------------------------------------------------------------- @@ -73,17 +82,24 @@ return organisationUnit; } - Collection patientAttributes; + private Collection patientAttributes; public Collection getPatientAttributes() { return patientAttributes; } + private Collection programs; + + public Collection getPrograms() + { + return programs; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- - + public String execute() throws Exception { @@ -95,6 +111,8 @@ patientAttributes = patientAttributeService.getAllPatientAttributes(); + programs = programService.getPrograms( organisationUnit ); + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidateSearchPatientAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidateSearchPatientAction.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/ValidateSearchPatientAction.java 2011-02-24 06:02:31 +0000 @@ -61,6 +61,13 @@ this.searchText = searchText; } + private Integer programId; + + public void setProgramId( Integer programId ) + { + this.programId = programId; + } + // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- @@ -94,7 +101,7 @@ return INPUT; } - if ( searchText == null || searchText.trim().length() == 0 ) + if ( ( searchText == null || searchText.trim().length() == 0 ) && programId == null ) { message = i18n.getString( "specify_a_search_criteria" ); === 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 2011-01-11 10:06:47 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/state/SelectedStateManager.java 2011-02-24 06:02:31 +0000 @@ -66,9 +66,7 @@ ProgramStage getSelectedProgramStage(); void clearSelectedProgramStage(); - - - + // ------------------------------------------------------------------------- // for Searching patients - SearchingAttribute // ------------------------------------------------------------------------- === 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 2011-02-16 02:55:58 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-02-24 06:02:31 +0000 @@ -371,6 +371,8 @@ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" /> + +     - #if($!searchText) + #if($!program) + $i18n.getString( "list_patients_by_program") '$program.name' + #elseif($!searchText) $searchText #else $i18n.getString( "list_all_patients" ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.vm 2011-01-20 15:25:13 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.vm 2011-02-24 06:02:31 +0000 @@ -17,15 +17,26 @@ - + @@ -55,12 +66,15 @@ \ No newline at end of file
- + #foreach( $attribute in $patientAttributes ) #end * + + + + +