=== 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 2011-04-28 07:10:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-01-04 04:55:19 +0000 @@ -55,6 +55,8 @@ Collection getProgramStageInstances( ProgramStage programStage ); Collection getProgramStageInstances( Collection programInstances ); + + List getProgramStageInstances( ProgramInstance programInstance, int min, int max ); Collection getProgramStageInstances( Date dueDate ); === 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 2011-04-28 07:10:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2012-01-04 04:55:19 +0000 @@ -67,4 +67,6 @@ public List get(OrganisationUnit unit, Date after, Date before, Boolean completed); List getProgramStageInstances( Patient patient, Boolean completed); + + List getProgramStageInstances( ProgramInstance programInstance, int min, int max ); } === 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 2011-04-28 07:10:33 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-01-04 04:55:19 +0000 @@ -169,4 +169,9 @@ { return programStageInstanceStore.getProgramStageInstances( patient, completed ); } + + public List getProgramStageInstances( ProgramInstance programInstance, int min, int max ) + { + return programStageInstanceStore.getProgramStageInstances( programInstance, min, max ); + } } === 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 2011-10-27 05:51:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-01-04 04:55:19 +0000 @@ -32,6 +32,7 @@ import java.util.List; import org.hibernate.Query; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.hisp.dhis.hibernate.HibernateGenericStore; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -143,4 +144,12 @@ return getQuery( hql ).setEntity( "patient", patient ).setBoolean( "completed", completed ).list(); } + + @SuppressWarnings( "unchecked" ) + public List getProgramStageInstances( ProgramInstance programInstance, int min, int max ) + { + return getCriteria( Restrictions.eq( "programInstance.id", programInstance.getId() ) ) + .addOrder(Order.desc("id")).setFirstResult( min ) + .setMaxResults( max ).list(); + } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java 2012-01-04 04:55:19 +0000 @@ -33,9 +33,6 @@ import org.hisp.dhis.hibernate.HibernateGenericStore; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.program.Program; -import org.hisp.dhis.program.ProgramAttribute; -import org.hisp.dhis.program.ProgramAttributeOption; -import org.hisp.dhis.program.ProgramAttributeOptionStore; import org.hisp.dhis.program.ProgramStore; /** === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetEventsByProgramAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetEventsByProgramAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetEventsByProgramAction.java 2012-01-04 04:55:19 +0000 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2004-2012, 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 java.util.Collection; + +import org.hisp.dhis.paging.ActionPagingSupport; +import org.hisp.dhis.program.ProgramInstance; +import org.hisp.dhis.program.ProgramInstanceService; +import org.hisp.dhis.program.ProgramStageInstance; +import org.hisp.dhis.program.ProgramStageInstanceService; + +/** + * @author Chau Thu Tran + * + * @version $Id: GetEventsByProgramAction.java Jan 03, 2012 13:58:34 AM $ + */ + +public class GetEventsByProgramAction + extends ActionPagingSupport +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramInstanceService programInstanceService; + + public void setProgramInstanceService( ProgramInstanceService programInstanceService ) + { + this.programInstanceService = programInstanceService; + } + + private ProgramStageInstanceService programStageInstanceService; + + public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) + { + this.programStageInstanceService = programStageInstanceService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer programInstanceId; + + public void setProgramInstanceId( Integer programInstanceId ) + { + this.programInstanceId = programInstanceId; + } + + private Collection programStageInstances; + + public Collection getProgramStageInstances() + { + return programStageInstances; + } + + private Integer total; + + public Integer getTotal() + { + return total; + } + + // ------------------------------------------------------------------------- + // Implementation Action + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + ProgramInstance programInstance = programInstanceService.getProgramInstance( programInstanceId ); + + total = programInstance.getProgramStageInstances().size(); + + this.paging = createPaging( total ); + + programStageInstances = programStageInstanceService.getProgramStageInstances( programInstance, paging + .getStartPos(), paging.getPageSize() ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.java 2011-12-29 09:03:09 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.java 2012-01-04 04:55:19 +0000 @@ -248,14 +248,17 @@ programStage = programStageInstance.getProgramStage(); programStageDataElements = new ArrayList( programStage.getProgramStageDataElements() ); - + Collections.sort( programStageDataElements, new ProgramStageDataElementSortOrderComparator() ); program = programStage.getProgram(); patient = programStageInstance.getProgramInstance().getPatient(); - patientIdentifier = patientIdentifierService.getPatientIdentifier( patient ); + if ( patient != null ) + { + patientIdentifier = patientIdentifierService.getPatientIdentifier( patient ); + } selectedStateManager.setSelectedProgramStageInstance( programStageInstance ); === 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-12-27 07:35:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-01-04 04:55:19 +0000 @@ -398,6 +398,14 @@ ref="org.hisp.dhis.program.ProgramStageInstanceService" /> + + + + + + + /content.vm + /dhis-web-caseentry/historyAnonymousEvents.vm + javascript/anonymousRegistration.js + + ../dhis-web-caseentry/style/patient.css, + ../dhis-web-commons/paging/paging.css + + + + /content.vm + /dhis-web-caseentry/dataEntryForm.vm + + +
@@ -36,6 +37,7 @@ #parse( "dhis-web-commons/loader/loader.vm" )
+
\ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2011-12-28 06:21:57 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-01-04 04:55:19 +0000 @@ -120,13 +120,13 @@ #if ( $patientDataValue.value ) #if( !$patientDataValue.providedByAnotherFacility ) $patientDataValue.organisationUnit.name - + #else $i18n.getString("other_facility") - + #end #else - + #end === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/historyAnonymousEvents.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/historyAnonymousEvents.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/historyAnonymousEvents.vm 2012-01-04 04:55:19 +0000 @@ -0,0 +1,18 @@ +

$i18n.getString('history_events')

+ + #foreach( $programStageInstance in $programStageInstances) + + + + #end + + +
+ #parse( "/dhis-web-commons/paging/paging.vm" ) +
+ +
+ + $format.formatDate( $programStageInstance.executionDate ) + +
\ No newline at end of file === 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 2011-12-21 09:42:40 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2012-01-04 04:55:19 +0000 @@ -8,6 +8,7 @@ disable('createEventBtn'); disable('deleteCurrentEventBtn'); + disable('showEventBtn'); $.postJSON( 'loadAnonymousPrograms.action',{} , function( json ) @@ -55,6 +56,7 @@ var programId = getFieldValue('programId'); if( programId == '' ) { + disable('showEventBtn'); return; } @@ -66,6 +68,7 @@ }, function( json ) { + enable('showEventBtn'); setFieldValue( 'programStageId', json.programStages[0].id ); setFieldValue( 'selectedProgramId', programId ); @@ -75,13 +78,10 @@ } else { - enable( 'executionDate' ); enable('createEventBtn'); disable('deleteCurrentEventBtn'); disable('completeBtn'); - disable('validationBtn'); - hideById('loaderDiv'); } @@ -104,7 +104,6 @@ enable('createEventBtn'); disable('deleteCurrentEventBtn'); disable('completeBtn'); - disable('validationBtn'); enable( 'executionDate' ); $('#executionDate').bind('change'); } @@ -116,14 +115,12 @@ enable('createEventBtn'); enable('deleteCurrentEventBtn'); disable('completeBtn'); - disable('validationBtn'); } else { disable('createEventBtn'); enable('deleteCurrentEventBtn'); enable('completeBtn'); - enable('validationBtn'); enable( 'executionDate' ); jQuery('#executionDate').bind('change'); } @@ -197,4 +194,32 @@ } }); } +} + +isAjax = true; +function showHistoryEvents() +{ + contentDiv = 'dataEntryFormDiv'; + $( '#dataEntryFormDiv' ).load( "getEventsByProgram.action", + { + programInstanceId: jQuery('select[id=programId] option:selected').attr('programInstanceId') + },function( ) + { + }); +} + + +function viewRecords( programStageInstanceId ) +{ + $('#viewEventDiv' ) + .load( 'viewAnonymousEvents.action?programStageInstanceId=' + programStageInstanceId ) + .dialog({ + title: i18n_event_information, + maximize: true, + closable: true, + modal:true, + overlay:{background:'#000000', opacity:0.1}, + width: 800, + height: 400 + }); } \ No newline at end of file