=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-10-03 04:59:39 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-10-05 05:15:03 +0000 @@ -833,7 +833,7 @@ { sql += statementBuilder.limitRecord( min, max ); } - + return sql; } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java 2013-10-02 11:24:32 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java 2013-10-05 05:15:03 +0000 @@ -36,6 +36,7 @@ import java.util.Map; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.paging.ActionPagingSupport; import org.hisp.dhis.patient.Patient; @@ -52,6 +53,12 @@ public class SearchPatientAction extends ActionPagingSupport { + private final String SEARCH_IN_ALL_ORGUNITS = "searchInAllOrgunits"; + + private final String SEARCH_IN_USER_ORGUNITS = "searchInUserOrgunits"; + + private final String SEARCH_IN_BELOW_SELECTED_ORGUNIT = "searchInBelowSelectedOrgunit"; + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -64,6 +71,8 @@ private CurrentUserService currentUserService; + private OrganisationUnitService organisationUnitService; + // ------------------------------------------------------------------------- // Input/output // ------------------------------------------------------------------------- @@ -72,9 +81,7 @@ private Integer statusEnrollment; - private Boolean searchBySelectedOrgunit; - - private Boolean searchByUserOrgunits; + private String facilityLB; private boolean listAll; @@ -84,6 +91,11 @@ // Getters && Setters // ------------------------------------------------------------------------- + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + public void setCurrentUserService( CurrentUserService currentUserService ) { this.currentUserService = currentUserService; @@ -94,26 +106,21 @@ this.statusEnrollment = statusEnrollment; } + public void setFacilityLB( String facilityLB ) + { + this.facilityLB = facilityLB; + } + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) { this.selectionManager = selectionManager; } - public void setSearchByUserOrgunits( Boolean searchByUserOrgunits ) - { - this.searchByUserOrgunits = searchByUserOrgunits; - } - public void setProgramService( ProgramService programService ) { this.programService = programService; } - public void setSearchBySelectedOrgunit( Boolean searchBySelectedOrgunit ) - { - this.searchBySelectedOrgunit = searchBySelectedOrgunit; - } - public void setPatientService( PatientService patientService ) { this.patientService = patientService; @@ -153,11 +160,11 @@ return mapPatientOrgunit; } - private List programIds; + private Integer programId; - public void setProgramIds( List programIds ) + public void setProgramId( Integer programId ) { - this.programIds = programIds; + this.programId = programId; } private List identifierTypes = new ArrayList(); @@ -167,6 +174,13 @@ return identifierTypes; } + private OrganisationUnit organisationUnit; + + public OrganisationUnit getOrganisationUnit() + { + return organisationUnit; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -174,10 +188,10 @@ public String execute() throws Exception { + organisationUnit = selectionManager.getSelectedOrganisationUnit(); + Collection orgunits = new HashSet(); - OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); - // List all patients if ( listAll ) { @@ -190,16 +204,24 @@ // search patients else if ( searchTexts.size() > 0 ) { - if ( searchByUserOrgunits ) + // selected orgunit + if ( facilityLB == null ) + { + orgunits.add( organisationUnit ); + } + else if ( facilityLB.equals( SEARCH_IN_USER_ORGUNITS ) ) { Collection userOrgunits = currentUserService.getCurrentUser().getOrganisationUnits(); orgunits.addAll( userOrgunits ); } - else if ( searchBySelectedOrgunit ) + else if ( facilityLB.equals( SEARCH_IN_BELOW_SELECTED_ORGUNIT ) ) { - orgunits.add( organisationUnit ); + Collection orgunitIds = organisationUnitService.getOrganisationUnitHierarchy().getChildren( + organisationUnit.getId() ); + + orgunits.addAll( organisationUnitService.getOrganisationUnits( orgunitIds ) ); } - else + else if ( facilityLB.equals( SEARCH_IN_ALL_ORGUNITS ) ) { orgunits = null; } @@ -209,7 +231,7 @@ patients = patientService.searchPatients( searchTexts, orgunits, null, null, statusEnrollment, paging.getStartPos(), paging.getPageSize() ); - if ( !searchBySelectedOrgunit || searchByUserOrgunits ) + if ( facilityLB != null ) { for ( Patient patient : patients ) { @@ -217,13 +239,10 @@ } } - if ( programIds != null ) + if ( programId != null ) { - for ( Integer programId : programIds ) - { - Program progam = programService.getProgram( programId ); - identifierTypes.addAll( progam.getPatientIdentifierTypes() ); - } + Program progam = programService.getProgram( programId ); + identifierTypes.addAll( progam.getPatientIdentifierTypes() ); } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java 2013-10-02 11:21:46 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java 2013-10-05 05:15:03 +0000 @@ -314,17 +314,13 @@ if ( option != null ) { attributeValue.setPatientAttributeOption( option ); - attributeValue.setValue( option.getName() ); } else { // This option was deleted ??? } } - else - { - attributeValue.setValue( value.trim() ); - } + attributeValue.setValue( value.trim() ); valuesForUpdate.add( attributeValue ); valuesForDelete.remove( attributeValue ); } === 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 2013-09-27 11:13:20 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-10-05 05:15:03 +0000 @@ -31,6 +31,7 @@ + - $i18n.getString( "search_result_matching_the_search_criteria" ): -   -   - - #if($!listAll) - $i18n.getString( "list_all_patients" ) - #else - $i18n.getString( "search_patients" ) - #end + + $i18n.getString( "the_following_persons_found_in" ) $organisationUnit.name + + - $i18n.getString( "total_result" ) -   -   - $!total + $i18n.getString( "total_result" ): $!total === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm 2013-10-03 14:11:59 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm 2013-10-05 05:15:03 +0000 @@ -33,18 +33,18 @@ #end }, #end - - #foreach( $psDataElement in $psDataElements ) - { - "id": "$psDataElement.dataElement.uid", - "name": "$encoder.xmlEncode(${psDataElement.dataElement.getFormNameFallback()} )", - "valueType": #if( $psDataElement.dataElement.optionSet ) - "list_$psDataElement.dataElement.optionSet.uid" - #else - "${psDataElement.dataElement.type}" - #end - }#if( $velocityCount < $psDataElements.size() ),#end - #end + #end + + #foreach( $psDataElement in $psDataElements ) + { + "id": "$psDataElement.dataElement.uid", + "name": "$encoder.xmlEncode(${psDataElement.dataElement.getFormNameFallback()} )", + "valueType": #if( $psDataElement.dataElement.optionSet ) + "list_$psDataElement.dataElement.optionSet.uid" + #else + "${psDataElement.dataElement.type}" + #end + }#if( $velocityCount < $psDataElements.size() ),#end #end ] } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2013-10-02 11:24:32 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2013-10-05 05:15:03 +0000 @@ -67,7 +67,7 @@ - + @@ -75,19 +75,31 @@