=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java 2010-10-30 10:56:31 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java 2011-07-15 08:07:54 +0000 @@ -26,6 +26,7 @@ */ package org.hisp.dhis.program; +import java.util.Date; import java.util.Collection; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -71,5 +72,12 @@ Collection getProgramInstances( Program program, OrganisationUnit organisationUnit, int min, int max ); + Collection getProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate ); + + Collection getProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate, + int min, int max ); + int countProgramInstances( Program program, OrganisationUnit organisationUnit ); + + int countProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java 2010-10-30 10:56:31 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java 2011-07-15 08:07:54 +0000 @@ -26,6 +26,7 @@ */ package org.hisp.dhis.program; +import java.util.Date; import java.util.Collection; import org.hisp.dhis.common.GenericStore; @@ -40,28 +41,35 @@ extends GenericStore { String ID = ProgramInstanceStore.class.getName(); - + Collection get( boolean completed ); - + Collection get( Program program ); - + Collection get( Collection programs ); - + Collection get( Program program, boolean completed ); - + Collection get( Collection programs, boolean completed ); - + Collection get( Patient patient ); - + Collection get( Patient patient, boolean completed ); - + Collection get( Patient patient, Program program ); - + Collection get( Patient patient, Program program, boolean completed ); - + Collection get( Program program, OrganisationUnit organisationUnit ); - + Collection get( Program program, OrganisationUnit organisationUnit, int min, int max ); + + Collection get( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate ); + + Collection get( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate, + int min, int max ); + + int count( Program program, OrganisationUnit organisationUnit ); - int count(Program program, OrganisationUnit organisationUnit ); + int count( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate ); } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2011-03-31 01:55:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2011-07-15 08:07:54 +0000 @@ -26,6 +26,7 @@ */ package org.hisp.dhis.program; +import java.util.Date; import java.util.Collection; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -136,8 +137,25 @@ return programInstanceStore.get( program, organisationUnit, min, max ); } + public Collection getProgramInstances( Program program, OrganisationUnit organisationUnit, + Date startDate, Date endDate ) + { + return programInstanceStore.get( program, organisationUnit, startDate, endDate ); + } + + public Collection getProgramInstances( Program program, OrganisationUnit organisationUnit, + Date startDate, Date endDate, int min, int max ) + { + return programInstanceStore.get( program, organisationUnit, startDate, endDate, min, max ); + } + public int countProgramInstances( Program program, OrganisationUnit organisationUnit ) { return programInstanceStore.count( program, organisationUnit ); } + + public int countProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate ) + { + return programInstanceStore.count( program, organisationUnit, startDate, endDate ); + } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2011-03-31 01:55:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2011-07-15 08:07:54 +0000 @@ -27,6 +27,7 @@ package org.hisp.dhis.program.hibernate; +import java.util.Date; import java.util.Collection; import org.hibernate.criterion.Order; @@ -117,11 +118,49 @@ .addOrder( Order.asc( "patient.id" ) ).setFirstResult( min ).setMaxResults( max ).list(); } + @SuppressWarnings( "unchecked" ) + public Collection get( Program program, OrganisationUnit organisationUnit, Date startDate, + Date endDate ) + { + return getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ), Restrictions.ge( "enrollmentDate", startDate ), + Restrictions.le( "enrollmentDate", endDate ) ) + .createAlias( "patient", "patient" ) + .add(Restrictions.eq( "patient.organisationUnit", organisationUnit ) ) + .addOrder( Order.asc( "patient.id" ) ).list(); + } + + @SuppressWarnings( "unchecked" ) + public Collection get( Program program, OrganisationUnit organisationUnit, Date startDate, + Date endDate, int min, int max ) + { + return getCriteria( Restrictions.eq( "program", program ), + Restrictions.isNull( "endDate" ), + Restrictions.ge( "enrollmentDate", startDate ), + Restrictions.le( "enrollmentDate", endDate ) ) + .createAlias( "patient", "patient" ) + .add(Restrictions.eq( "patient.organisationUnit", organisationUnit ) ) + .addOrder( Order.asc( "patient.id" ) ).setFirstResult( min ).setMaxResults( max ).list(); + } + public int count( Program program, OrganisationUnit organisationUnit ) { - Number rs = (Number) getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) ) + Number rs = (Number) getCriteria( Restrictions.eq( "program", program ), + Restrictions.isNull( "endDate" ) ) .createAlias( "patient", "patient" ).add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) ) .setProjection( Projections.rowCount() ).uniqueResult(); return rs != null ? rs.intValue() : 0; } + + public int count( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate ) + { + Number rs = (Number) getCriteria( Restrictions.eq( "program", program ), + Restrictions.isNull( "endDate" ), + Restrictions.ge( "enrollmentDate", startDate ), + Restrictions.le( "enrollmentDate", endDate ) ) + .createAlias( "patient", "patient" ) + .add(Restrictions.eq( "patient.organisationUnit", organisationUnit ) ) + .setProjection( Projections.rowCount() ).uniqueResult(); + + return rs != null ? rs.intValue() : 0; + } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java 2011-05-06 11:10:34 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java 2011-07-15 08:07:54 +0000 @@ -29,12 +29,13 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.HashMap; import java.util.Map; -import org.hisp.dhis.caseentry.state.SelectedStateManager; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.paging.ActionPagingSupport; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramInstance; @@ -63,11 +64,11 @@ // Dependencies // ------------------------------------------------------------------------- - private SelectedStateManager selectedStateManager; + private OrganisationUnitSelectionManager selectionManager; - public void setSelectedStateManager( SelectedStateManager selectedStateManager ) + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) { - this.selectedStateManager = selectedStateManager; + this.selectionManager = selectionManager; } private ProgramService programService; @@ -102,32 +103,11 @@ // Input/output // ------------------------------------------------------------------------- - private OrganisationUnit organisationUnit; - - public OrganisationUnit getOrganisationUnit() - { - return organisationUnit; - } - - private Program program; - - public Program getProgram() - { - return program; - } - - private Collection programs = new ArrayList(); - - public Collection getPrograms() - { - return programs; - } - private Integer programId; - public Integer getProgramId() + public void setProgramId( Integer programId ) { - return programId; + this.programId = programId; } private String startDate; @@ -137,11 +117,6 @@ this.startDate = startDate; } - public String getStartDate() - { - return startDate; - } - private String endDate; public void setEndDate( String endDate ) @@ -149,9 +124,11 @@ this.endDate = endDate; } - public String getEndDate() + private OrganisationUnit organisationUnit; + + public OrganisationUnit getOrganisationUnit() { - return endDate; + return organisationUnit; } Collection programInstances = new ArrayList(); @@ -168,6 +145,13 @@ return colorMap; } + private Program program; + + public Program getProgram() + { + return program; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -175,42 +159,29 @@ public String execute() throws Exception { - organisationUnit = selectedStateManager.getSelectedOrganisationUnit(); - - program = selectedStateManager.getSelectedProgram(); - - programId = program.getId(); - - programs = programService.getPrograms( organisationUnit ); + organisationUnit = selectionManager.getSelectedOrganisationUnit(); + + program = programService.getProgram( programId ); + + Date sDate = format.parseDate( startDate ); + + Date eDate = format.parseDate( endDate ); // --------------------------------------------------------------------- // Program instances for the selected program // --------------------------------------------------------------------- - int total = programInstanceService.countProgramInstances( program, organisationUnit ); + int total = programInstanceService.countProgramInstances( program, organisationUnit, sDate, eDate ); this.paging = createPaging( total ); - Collection selectedProgramInstances = programInstanceService.getProgramInstances( program, - organisationUnit, paging.getStartPos(), paging.getPageSize() ); + programInstances = programInstanceService.getProgramInstances( program, organisationUnit, sDate, eDate, paging + .getStartPos(), paging.getPageSize() ); Collection programStageInstances = new ArrayList(); - for ( ProgramInstance programInstance : selectedProgramInstances ) + for ( ProgramInstance programInstance : programInstances ) { - if ( !programInstance.isCompleted() ) - { - programInstances.add( programInstance ); - } - else - { - if ( programInstance.getEnrollmentDate().before( format.parseDate( endDate ) ) - && programInstance.getEnrollmentDate().after( format.parseDate( startDate ) ) ) - { - programInstances.add( programInstance ); - } - } - programStageInstances.addAll( programInstance.getProgramStageInstances() ); } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ReportSelectAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ReportSelectAction.java 2011-05-12 09:40:29 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ReportSelectAction.java 2011-07-15 08:07:54 +0000 @@ -27,13 +27,7 @@ package org.hisp.dhis.caseentry.action.report; -import java.util.ArrayList; -import java.util.Collection; - -import org.hisp.dhis.caseentry.state.SelectedStateManager; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.program.Program; -import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import com.opensymphony.xwork2.Action; @@ -47,49 +41,12 @@ // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- - - private SelectedStateManager selectedStateManager; - - public void setSelectedStateManager( SelectedStateManager selectedStateManager ) - { - this.selectedStateManager = selectedStateManager; - } - - private ProgramService programService; - - public void setProgramService( ProgramService programService ) - { - this.programService = programService; - } - - // ------------------------------------------------------------------------- - // Input/output - // ------------------------------------------------------------------------- - - private OrganisationUnit organisationUnit; - - public OrganisationUnit getOrganisationUnit() - { - return organisationUnit; - } - - private Integer programId; - - public void setProgramId( Integer programId ) - { - this.programId = programId; - } - - public Integer getProgramId() - { - return programId; - } - - private Collection programs = new ArrayList(); - - public Collection getPrograms() - { - return programs; + + private OrganisationUnitSelectionManager selectionManager; + + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) + { + this.selectionManager = selectionManager; } // ------------------------------------------------------------------------- @@ -97,58 +54,9 @@ // ------------------------------------------------------------------------- public String execute() - throws Exception { - // --------------------------------------------------------------------- - // Validate selected OrganisationUnit - // --------------------------------------------------------------------- - - organisationUnit = selectedStateManager.getSelectedOrganisationUnit(); - - if ( organisationUnit == null ) - { - programId = null; - - selectedStateManager.clearSelectedProgram(); - - return SUCCESS; - } - - // --------------------------------------------------------------------- - // Load assigned Programs - // --------------------------------------------------------------------- - - programs = programService.getPrograms( organisationUnit ); - - // --------------------------------------------------------------------- - // Validate selected Program - // --------------------------------------------------------------------- - - Program selectedProgram; - - if ( programId != null ) - { - selectedProgram = programService.getProgram( programId ); - } - else - { - selectedProgram = selectedStateManager.getSelectedProgram(); - } - - if ( selectedProgram != null && programs.contains( selectedProgram ) ) - { - programId = selectedProgram.getId(); - selectedStateManager.setSelectedProgram( selectedProgram ); - } - else - { - programId = null; - - selectedStateManager.clearSelectedProgram(); - - return SUCCESS; - } - + selectionManager.clearSelectedOrganisationUnits(); + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateReportParametersAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateReportParametersAction.java 2011-03-31 01:49:21 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateReportParametersAction.java 2011-07-15 08:07:54 +0000 @@ -29,7 +29,6 @@ import java.util.Date; -import org.hisp.dhis.caseentry.state.SelectedStateManager; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.i18n.I18nFormat; @@ -45,14 +44,7 @@ // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- - - private SelectedStateManager selectedStateManager; - - public void setSelectedStateManager( SelectedStateManager selectedStateManager ) - { - this.selectedStateManager = selectedStateManager; - } - + private I18nFormat format; public void setFormat( I18nFormat format ) @@ -103,20 +95,6 @@ public String execute() throws Exception { - if ( selectedStateManager.getSelectedOrganisationUnit() == null ) - { - message = i18n.getString( "please_select_a_reporting_unit" ); - - return INPUT; - } - - if ( selectedStateManager.getSelectedProgram() == null ) - { - message = i18n.getString( "please_select_a_program" ); - - return INPUT; - } - if ( startDate == null ) { message = i18n.getString( "please_choose_a_valid_start_date" ); === 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-07-14 09:31:24 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2011-07-15 08:07:54 +0000 @@ -175,22 +175,20 @@ - + - - + - - + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-06-14 16:13:36 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-07-15 08:07:54 +0000 @@ -308,4 +308,5 @@ validation = Validation program_validation_description = Program Validation Description please_select_village = Please select village -select_sorting_attribute = Select a specfied attribute / ALL \ No newline at end of file +select_sorting_attribute = Select a specfied attribute / ALL +no_result = No result \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2011-07-15 03:35:57 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2011-07-15 08:07:54 +0000 @@ -153,6 +153,14 @@ + + + /main.vm + /dhis-web-caseentry/reportSelect.vm + /dhis-web-caseentry/reportsMenu.vm + ../dhis-web-commons/ouwt/ouwt.js,javascript/report.js + + /main.vm @@ -169,10 +177,9 @@ - /content.vm /dhis-web-caseentry/report.vm - ../dhis-web-commons/ouwt/ouwt.js,javascript/report.js + javascript/report.js ../dhis-web-commons/paging/paging.css === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js 2011-05-23 06:10:58 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js 2011-07-15 08:07:54 +0000 @@ -2,7 +2,40 @@ function organisationUnitSelected( orgUnits ) { - window.location.href = 'reportSelect.action'; + showLoader(); + jQuery.postJSON( "getPrograms.action", + { + }, + function( json ) + { + setFieldValue( 'orgunitname', json.organisationUnit ); + + clearListById('programId'); + if( json.programs.length == 0) + { + disable('programId'); + disable('startDate'); + disable('endDate'); + disable('endDate'); + disable('generateBtn'); + } + else + { + addOptionById( 'programId', "0", i18n_select ); + + for ( var i in json.programs ) + { + addOptionById( 'programId', json.programs[i].id, json.programs[i].name ); + } + enable('programId'); + enable('startDate'); + enable('endDate'); + enable('endDate'); + enable('generateBtn'); + } + + hideLoader(); + }); } selection.setListenerFunction( organisationUnitSelected ); @@ -47,8 +80,9 @@ jQuery( "#contentDiv" ).load( "generateReport.action", { - 'startDate': getFieldValue( 'startDate' ), - '&endDate': getFieldValue( 'endDate' ) + programId: getFieldValue( 'programId' ), + startDate: getFieldValue( 'startDate' ), + endDate: getFieldValue( 'endDate' ) }, function() { unLockScreen();hideById( 'message' );showById( 'contentDiv' );}); } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm 2011-05-12 09:40:29 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm 2011-07-15 08:07:54 +0000 @@ -1,3 +1,6 @@ +#if( $programInstance.size() == 0 ) + $i18n.getString('no_result') +#else
@@ -41,7 +44,7 @@
- +#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportSelect.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportSelect.vm 2011-05-12 09:40:29 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportSelect.vm 2011-07-15 08:07:54 +0000 @@ -1,56 +1,55 @@ - -

$i18n.getString( "report_management" )

- + - + - + - +
-
- +
- +

- +

+#parse( "dhis-web-commons/loader/loader.vm" ) +
- \ No newline at end of file + + +