=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2012-10-03 06:04:22 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2012-10-09 03:53:11 +0000 @@ -32,6 +32,8 @@ import java.util.HashSet; import java.util.Set; +import org.hisp.dhis.caseentry.state.SelectedStateManager; +import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patient.PatientAudit; import org.hisp.dhis.patient.PatientAuditService; @@ -39,8 +41,10 @@ import org.hisp.dhis.patient.PatientService; import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; +import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramInstanceService; +import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.relationship.Relationship; import org.hisp.dhis.relationship.RelationshipService; import org.hisp.dhis.user.CurrentUserService; @@ -71,6 +75,10 @@ private CurrentUserService currentUserService; + private ProgramService programService; + + private SelectedStateManager selectedStateManager; + // ------------------------------------------------------------------------- // Input && Output // ------------------------------------------------------------------------- @@ -91,6 +99,8 @@ private Collection patientAudits; + private Collection singlePrograms; + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -100,6 +110,21 @@ this.patientAuditService = patientAuditService; } + public void setSelectedStateManager( SelectedStateManager selectedStateManager ) + { + this.selectedStateManager = selectedStateManager; + } + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + public Collection getSinglePrograms() + { + return singlePrograms; + } + public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) { this.patientAttributeValueService = patientAttributeValueService; @@ -199,6 +224,20 @@ } } + // --------------------------------------------------------------------- + // Check single-event with registration + // --------------------------------------------------------------------- + + OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit(); + + singlePrograms = programService.getPrograms( Program.SINGLE_EVENT_WITH_REGISTRATION, orgunit ); + + singlePrograms.removeAll( patient.getPrograms() ); + + // --------------------------------------------------------------------- + // Patient-Audit + // --------------------------------------------------------------------- + patientAudits = patientAuditService.getPatientAudits( patient ); long millisInDay = 60 * 60 * 24 * 1000; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java 2012-09-04 10:10:05 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java 2012-10-09 03:53:11 +0000 @@ -116,36 +116,10 @@ patient = patientService.getPatient( id ); // Get all programs - programs = programService.getPrograms( Program.MULTIPLE_EVENTS_WITH_REGISTRATION ); - - // Get single-event programs by the selected orgunit - Collection singleProgramsByOrgunit = programService.getPrograms( - Program.SINGLE_EVENT_WITH_REGISTRATION, orgunit ); - programs.addAll( singleProgramsByOrgunit ); - + programs = programService.getPrograms( Program.MULTIPLE_EVENTS_WITH_REGISTRATION ); // Except anonymous program programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) ); - // Get single-event if patient no have any single event - // OR have un-completed single-event - Collection programInstances = programInstanceService.getProgramInstances( patient, false ); - - for ( ProgramInstance programInstance : programInstances ) - { - programs.remove( programInstance.getProgram() ); - } - - // Remove single-event with registation programs which patient completed - Collection completedProgramInstances = programInstanceService.getProgramInstances( patient, true ); - - for ( ProgramInstance programInstance : completedProgramInstances ) - { - if ( programInstance.getProgram().isSingleEvent() ) - { - programs.remove( programInstance.getProgram() ); - } - } - return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java 2012-09-25 05:18:34 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java 2012-10-09 03:53:11 +0000 @@ -163,7 +163,7 @@ { programInstance = programInstances.iterator().next(); } - + if ( programInstance == null ) { programInstance = new ProgramInstance(); @@ -179,10 +179,16 @@ patientService.updatePatient( patient ); Date dateCreatedEvent = format.parseDate( dateOfIncident ); - if( program.getGeneratedByEnrollmentDate()) + if ( program.getGeneratedByEnrollmentDate() ) { dateCreatedEvent = format.parseDate( enrollmentDate ); } + + if( program.isRegistration() && program.isSingleEvent()) + { + + } + boolean isFirstStage = false; for ( ProgramStage programStage : program.getProgramStages() ) { @@ -191,11 +197,15 @@ ProgramStageInstance programStageInstance = new ProgramStageInstance(); programStageInstance.setProgramInstance( programInstance ); programStageInstance.setProgramStage( programStage ); - Date dueDate = DateUtils.getDateAfterAddition( dateCreatedEvent, - programStage.getMinDaysFromStart() ); + Date dueDate = DateUtils + .getDateAfterAddition( dateCreatedEvent, programStage.getMinDaysFromStart() ); programStageInstance.setDueDate( dueDate ); + if( program.isSingleEvent()) + { + programStageInstance.setExecutionDate( dueDate ); + } programStageInstanceService.addProgramStageInstance( programStageInstance ); if ( !isFirstStage ) @@ -215,12 +225,16 @@ for ( ProgramStageInstance programStageInstance : programInstance.getProgramStageInstances() ) { - Date dueDate = DateUtils.getDateAfterAddition( format.parseDate( dateOfIncident ), programStageInstance - .getProgramStage().getMinDaysFromStart() ); - - programStageInstance.setDueDate( dueDate ); - - programStageInstanceService.updateProgramStageInstance( programStageInstance ); + if ( !programStageInstance.isCompleted() + || programStageInstance.getStatus() != ProgramStageInstance.SKIPPED_STATUS ) + { + Date dueDate = DateUtils.getDateAfterAddition( format.parseDate( dateOfIncident ), + programStageInstance.getProgramStage().getMinDaysFromStart() ); + + programStageInstance.setDueDate( dueDate ); + + programStageInstanceService.updateProgramStageInstance( programStageInstance ); + } } } === 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 2012-10-07 03:09:51 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java 2012-10-09 03:53:11 +0000 @@ -43,7 +43,6 @@ import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramInstanceService; import org.hisp.dhis.program.ProgramService; -import org.hisp.dhis.system.util.ConversionUtils; /** * @author Abyot Asalefew Gizaw === 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-10-06 15:55:56 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-10-09 03:53:11 +0000 @@ -996,6 +996,8 @@ + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2012-10-09 02:31:56 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2012-10-09 03:53:11 +0000 @@ -1253,6 +1253,43 @@ }); } +function saveSingleEnrollment(patientId, programId) +{ + jQuery.postJSON( "saveProgramEnrollment.action", + { + patientId: patientId, + programId: programId, + dateOfIncident: getCurrentDate(), + enrollmentDate: getCurrentDate() + }, + function( json ) + { + var programInstanceId = json.programInstanceId; + var programStageInstanceId = json.activeProgramStageInstanceId; + var programStageName = json.activeProgramStageName; + var programInfor = getInnerHTML('infor_' + programId); + var dueDate = json.dueDate; + var type = jQuery('#enrollmentDiv [id=programId] option:selected').attr('programType'); + + var activedRow = "" + + " " + + " " + + "" + + programInfor + "" + + ""; + + jQuery('#tr_' + programId ).remove(); + + jQuery('#activeTB' ).append(activedRow); + jQuery('#enrollmentDiv').dialog("close"); + saveIdentifierAndAttribute( patientId, programId,'identifierAndAttributeDiv' ); + loadActiveProgramStageRecords( programInstanceId ); + showSuccessMessage(i18n_enrol_success); + }); +} + // ---------------------------------------------------------------- // Program enrollmment && unenrollment // ---------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm 2012-10-05 08:12:39 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm 2012-10-09 03:53:11 +0000 @@ -120,11 +120,13 @@ $programInstance.program.name ($format.formatDate($programInstance.enrollmentDate)) + #if($programInstance.program.type==1) >> $programStageInstance.programStage.name ($format.formatDate($programStageInstance.dueDate)) + #end #set($flag = 'true') #end #end @@ -136,10 +138,22 @@ $programInstance.program.name ($format.formatDate($programInstance.enrollmentDate)) + #end + #end + #foreach($program in $singlePrograms) + + + + + + - #end #end