dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16667
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6393: (patient) Create progam-stage-instances automatically when adding a new stage for program which h...
------------------------------------------------------------
revno: 6393
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-03-27 15:52:53 +0700
message:
(patient) Create progam-stage-instances automatically when adding a new stage for program which have patients enrolled.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
--
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-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-03-27 08:30:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-03-27 08:52:53 +0000
@@ -289,4 +289,5 @@
level = Level
patient_identifier_and_attributes = Beneficiary identifier and attributes
please_fill_out_only_one_of_these_fields = Please fill out at only one of these fields.
-age_year = Age year
\ No newline at end of file
+age_year = Age year
+create = Create
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java 2011-11-07 02:53:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java 2012-03-27 08:52:53 +0000
@@ -28,16 +28,23 @@
*/
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
import java.util.List;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
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.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageDataElement;
import org.hisp.dhis.program.ProgramStageDataElementService;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.system.util.DateUtils;
import com.opensymphony.xwork2.Action;
@@ -81,6 +88,23 @@
this.programStageDataElementService = programStageDataElementService;
}
+
+
+
+ private ProgramInstanceService programInstanceService;
+
+ public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+ {
+ this.programInstanceService = programInstanceService;
+ }
+
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
// -------------------------------------------------------------------------
// Input/Output
// -------------------------------------------------------------------------
@@ -155,9 +179,9 @@
programStage.setDescription( description );
programStage.setStageInProgram( program.getProgramStages().size() + 1 );
programStage.setProgram( program );
-
- irregular = (irregular==null) ? false : irregular;
- programStage.setIrregular(irregular);
+
+ irregular = (irregular == null) ? false : irregular;
+ programStage.setIrregular( irregular );
minDaysFromStart = (minDaysFromStart == null) ? 0 : minDaysFromStart;
programStage.setMinDaysFromStart( minDaysFromStart );
@@ -172,6 +196,29 @@
programStageDataElementService.addProgramStageDataElement( programStageDataElement );
}
+ // ---------------------------------------------------------------------
+ // Create program-stage-instances for the available patients enrolled
+ // this program before
+ // ---------------------------------------------------------------------
+
+ Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( program, false );
+
+ for ( ProgramInstance programInstance : programInstances )
+ {
+ ProgramStageInstance programStageInstance = new ProgramStageInstance();
+ programStageInstance.setProgramInstance( programInstance );
+ programStageInstance.setProgramStage( programStage );
+ programStageInstance.setStageInProgram( programStage.getStageInProgram() );
+
+ Date dueDate = DateUtils.getDateAfterAddition( programInstance.getDateOfIncident(), programStage
+ .getMinDaysFromStart() );
+
+ programStageInstance.setDueDate( dueDate );
+
+ programStageInstanceService.addProgramStageInstance( programStageInstance );
+
+ }
+
return SUCCESS;
}
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2012-03-27 08:52:53 +0000
@@ -308,6 +308,8 @@
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
<property name="programStageDataElementService"
ref="org.hisp.dhis.program.ProgramStageDataElementService" />
+ <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+ <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
</bean>
<bean