dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19809
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8793: [mobile] fix enrollment date and auto generate program stage
------------------------------------------------------------
revno: 8793
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Wed 2012-10-31 19:11:00 +0700
message:
[mobile] fix enrollment date and auto generate program stage
modified:
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java 2012-10-03 07:23:08 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java 2012-10-31 12:11:00 +0000
@@ -420,16 +420,30 @@
for ( ProgramStage programStage : program.getProgramStages() )
{
- ProgramStageInstance programStageInstance = new ProgramStageInstance();
- programStageInstance.setProgramInstance( programInstance );
- programStageInstance.setProgramStage( programStage );
-
- Date dueDate = DateUtils.getDateAfterAddition( sdf.parseDateTime( incidentDate ).toDate(),
- programStage.getMinDaysFromStart() );
-
- programStageInstance.setDueDate( dueDate );
-
- programStageInstanceService.addProgramStageInstance( programStageInstance );
+ if ( programStage.getAutoGenerateEvent() )
+ {
+ ProgramStageInstance programStageInstance = new ProgramStageInstance();
+ programStageInstance.setProgramInstance( programInstance );
+ programStageInstance.setProgramStage( programStage );
+
+ Date dateCreatedEvent = sdf.parseDateTime( incidentDate ).toDate();
+ if ( program.getGeneratedByEnrollmentDate() )
+ {
+ dateCreatedEvent = sdf.parseDateTime( enrollmentDate ).toDate();
+ }
+
+ Date dueDate = DateUtils
+ .getDateAfterAddition( dateCreatedEvent, programStage.getMinDaysFromStart() );
+
+ programStageInstance.setDueDate( dueDate );
+
+ if ( program.isSingleEvent() )
+ {
+ programStageInstance.setExecutionDate( dueDate );
+ }
+
+ programStageInstanceService.addProgramStageInstance( programStageInstance );
+ }
}
}
else
@@ -441,12 +455,16 @@
for ( ProgramStageInstance programStageInstance : programInstance.getProgramStageInstances() )
{
- Date dueDate = DateUtils.getDateAfterAddition( sdf.parseDateTime( incidentDate ).toDate(),
- programStageInstance.getProgramStage().getMinDaysFromStart() );
-
- programStageInstance.setDueDate( dueDate );
-
- programStageInstanceService.updateProgramStageInstance( programStageInstance );
+ if ( !programStageInstance.isCompleted()
+ || programStageInstance.getStatus() != ProgramStageInstance.SKIPPED_STATUS )
+ {
+ Date dueDate = DateUtils.getDateAfterAddition( sdf.parseDateTime( incidentDate ).toDate(),
+ programStageInstance.getProgramStage().getMinDaysFromStart() );
+
+ programStageInstance.setDueDate( dueDate );
+
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+ }
}
}