=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-06-24 14:29:16 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-07-03 09:39:00 +0000 @@ -94,4 +94,6 @@ Collection organisationUnits, int level, Date startDate, Date endDate ); List getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n ); + + void removeEmptyEvents( ProgramStage programStage ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2012-06-24 14:29:16 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2012-07-03 09:39:00 +0000 @@ -80,4 +80,6 @@ int getTabularReportCount( ProgramStage programStage, List columns, Collection organisationUnits, int level, int maxLevel, Date startDate, Date endDate ); + + void removeEmptyEvents( ProgramStage programStage ); } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-06-24 14:29:16 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-07-03 09:39:00 +0000 @@ -285,4 +285,9 @@ return grids; } + + public void removeEmptyEvents( ProgramStage programStage ) + { + programStageInstanceStore.removeEmptyEvents(programStage); + } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-07-02 10:42:51 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-07-03 09:39:00 +0000 @@ -83,7 +83,7 @@ { this.statementBuilder = statementBuilder; } - + // ------------------------------------------------------------------------- // Implemented methods // ------------------------------------------------------------------------- @@ -239,6 +239,14 @@ return jdbcTemplate.queryForInt( sql ); } + + public void removeEmptyEvents( ProgramStage programStage ) + { + String sql = "delete from programstageinstance where programstageid=" + programStage.getId() + " and programstageinstanceid not in " + + "(select pdv.programstageinstanceid from patientdatavalue pdv )"; + + jdbcTemplate.execute( sql ); + } // ------------------------------------------------------------------------- // Supportive methods === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RemoveEmptyEventsAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RemoveEmptyEventsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RemoveEmptyEventsAction.java 2012-07-03 09:39:00 +0000 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.caseentry.action.caseentry; + +import org.hisp.dhis.program.ProgramStage; +import org.hisp.dhis.program.ProgramStageInstanceService; +import org.hisp.dhis.program.ProgramStageService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version RemoveEmptyEventsAction.java Jul 3, 2012 $ + */ +public class RemoveEmptyEventsAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramStageService programStageService; + + public void setProgramStageService( ProgramStageService programStageService ) + { + this.programStageService = programStageService; + } + + private ProgramStageInstanceService programStageInstanceService; + + public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) + { + this.programStageInstanceService = programStageInstanceService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer programStageId; + + public void setProgramStageId( Integer programStageId ) + { + this.programStageId = programStageId; + } + + // ------------------------------------------------------------------------- + // Implementation Action + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + ProgramStage programStage = programStageService.getProgramStage( programStageId ); + + programStageInstanceService.removeEmptyEvents( programStage ); + + return SUCCESS; + } + +} === 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 2012-06-27 09:28:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-07-03 09:39:00 +0000 @@ -436,6 +436,14 @@ scope="prototype"> + + + + + === 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 2012-06-27 09:28:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-07-03 09:39:00 +0000 @@ -169,6 +169,13 @@ F_NAME_BASED_DATA_ENTRY + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + F_PATIENT_REMOVE_EMPTY_EVENTS + + - + @@ -49,6 +49,9 @@ + + + @@ -145,6 +148,7 @@ var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")'; var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")'; var i18n_no_compulsary_data_elements = '$encoder.jsEscape( $i18n.getString( "no_compulsary_data_elements" ) , "'")'; + var i18n_remove_success = '$encoder.jsEscape( $i18n.getString( "remove_success" ) , "'")'; isAjax = true; contentDiv = ''; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2012-06-28 04:30:28 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2012-07-03 09:39:00 +0000 @@ -349,3 +349,19 @@ { doComplete( true ); } + +function removeEmptyEvents() +{ + jQuery.getJSON( "removeEmptyEvents.action", + { + programStageId: jQuery('#selectDiv [id=programId] option:selected').attr('programStageId') + }, + function( json ) + { + if(json.response=='success') + { + showSuccessMessage( i18n_remove_success ); + validateSearchEvents( true ) + } + }); +} \ No newline at end of file