dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16707
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6417: (patient) Create program-stage-instance when selecting new stage in data entry form.
------------------------------------------------------------
revno: 6417
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-28 19:29:54 +0700
message:
(patient) Create program-stage-instance when selecting new stage in data entry form.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.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-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-03-10 05:06:47 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-03-28 12:29:54 +0000
@@ -90,7 +90,7 @@
Restrictions.eq( "programInstance", programInstance ), Restrictions.eq( "programStage", programStage ) )
.addOrder( Order.asc( "id" ) ).list() );
- return (list == null) ? null : list.get( list.size() - 1 );
+ return (list == null || list.size() == 0) ? null : list.get( list.size() - 1 );
}
@SuppressWarnings( "unchecked" )
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java 2012-03-15 09:25:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java 2012-03-28 12:29:54 +0000
@@ -184,10 +184,28 @@
programStageInstance.setProvidedByAnotherFacility( false );
programStageInstanceService.addProgramStageInstance( programStageInstance );
-
- selectedStateManager.setSelectedProgramInstance( programInstance );
- selectedStateManager.setSelectedProgramStageInstance( programStageInstance );
- }
+ selectedStateManager.setSelectedProgramInstance( programInstance );
+ }
+ else if ( !programStage.getProgram().getSingleEvent() && !programStage.getProgram().getAnonymous() )
+ {
+ ProgramInstance programInstance = programInstanceService.getProgramInstances( patient, program ).iterator().next();
+
+ // Add a new program-stage-instance
+ programStageInstance = new ProgramStageInstance();
+ programStageInstance.setProgramInstance( programInstance );
+ programStageInstance.setProgramStage( programStage );
+ programStageInstance.setStageInProgram( programStage.getStageInProgram() );
+ programStageInstance.setDueDate( dateValue );
+ programStageInstance.setExecutionDate( dateValue );
+ programStageInstance.setStoredBy( storedBy );
+ programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
+ programStageInstance.setProvidedByAnotherFacility( false );
+
+ programStageInstanceService.addProgramStageInstance( programStageInstance );
+ selectedStateManager.setSelectedProgramInstance( programInstance );
+ }
+
+ selectedStateManager.setSelectedProgramStageInstance( programStageInstance );
}
else
{