dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24311
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11893: Send DHIS Message to user group when program stage complete
------------------------------------------------------------
revno: 11893
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Wed 2013-09-04 03:48:27 +0700
message:
Send DHIS Message to user group when program stage complete
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java
dhis-2/dhis-web/dhis-web-caseentry/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/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java 2013-09-03 20:48:27 +0000
@@ -33,7 +33,9 @@
import java.util.Date;
import java.util.List;
import java.util.Set;
+
import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.message.MessageService;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientReminder;
import org.hisp.dhis.patient.PatientService;
@@ -41,6 +43,7 @@
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.sms.outbound.OutboundSms;
@@ -93,10 +96,22 @@
this.format = format;
}
+ private MessageService messageService;
+
+ public MessageService getMessageService()
+ {
+ return messageService;
+ }
+
// -------------------------------------------------------------------------
// Input / Output
// -------------------------------------------------------------------------
+ public void setMessageService( MessageService messageService )
+ {
+ this.messageService = messageService;
+ }
+
private Integer programStageId;
public Integer getProgramStageId()
@@ -146,7 +161,7 @@
programStageInstance.setCompletedUser( currentUserService.getCurrentUsername() );
// Send message when to completed the event
-
+
List<OutboundSms> psiOutboundSms = programStageInstance.getOutboundSms();
if ( psiOutboundSms == null )
{
@@ -158,6 +173,20 @@
programStageInstanceService.updateProgramStageInstance( programStageInstance );
+ // Send DHIS message to user group
+ ProgramStage stage = programStageInstance.getProgramStage();
+ Set<PatientReminder> patientReminders = stage.getPatientReminders();
+
+ for ( PatientReminder patientReminder : patientReminders )
+ {
+ if ( patientReminder.getUserGroup() != null
+ && patientReminder.getWhenToSend() == PatientReminder.SEND_WHEN_TO_C0MPLETED_EVENT )
+ {
+ messageService.sendMessage( stage.getName(), patientReminder.getTemplateMessage(), null,
+ patientReminder.getUserGroup().getMembers(), null, false, true );
+ }
+ }
+
// ---------------------------------------------------------------------
// Check Completed status for all of ProgramStageInstance of
// ProgramInstance
=== 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 2013-08-29 09:34:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-09-03 20:48:27 +0000
@@ -122,6 +122,7 @@
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ <property name="messageService" ref="org.hisp.dhis.message.MessageService" />
</bean>
<bean