dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21959
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10512: Add function to allow to define tamplete messages for program-instance and send them automaticall...
------------------------------------------------------------
revno: 10512
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-04-10 16:48:12 +0700
message:
Add function to allow to define tamplete messages for program-instance and send them automatically (DONE).
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/visitSchedule.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.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/webapp/dhis-web-caseentry/visitSchedule.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/visitSchedule.vm 2013-04-10 03:13:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/visitSchedule.vm 2013-04-10 09:48:12 +0000
@@ -40,6 +40,14 @@
</fieldset>
<br>
+<table>
+ #foreach($sms in $programInstance.outboundSms)
+ <tr id="tr${sms.id}" >
+ <td>- ( $format.formatDateTime($!sms.date) - $encoder.htmlEncode($sms.sender) )</td>
+ <td>$encoder.htmlEncode($sms.message)</td>
+ #end
+</table>
+
#if( $programStageInstances.size() > 0 )
<table class='mainPageTable listTable' id='progarmStageListDiv' name='progarmStageListDiv' >
<colgroup>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java 2013-04-10 08:45:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java 2013-04-10 09:48:12 +0000
@@ -29,15 +29,18 @@
import static org.hisp.dhis.sms.outbound.OutboundSms.DHIS_SYSTEM_SENDER;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
+import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.program.SchedulingProgramObject;
import org.hisp.dhis.sms.SmsServiceException;
import org.hisp.dhis.sms.outbound.OutboundSms;
import org.hisp.dhis.sms.outbound.OutboundSmsService;
-import org.springframework.jdbc.core.JdbcTemplate;
import com.opensymphony.xwork2.Action;
@@ -66,14 +69,7 @@
{
this.programInstanceService = programInstanceService;
}
-
- private JdbcTemplate jdbcTemplate;
-
- public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
- {
- this.jdbcTemplate = jdbcTemplate;
- }
-
+
private OutboundSmsService outboundSmsService;
public void setOutboundSmsService( OutboundSmsService outboundSmsService )
@@ -101,14 +97,17 @@
{
OutboundSms outboundSms = new OutboundSms( message, schedulingProgramObject.getPhoneNumber() );
outboundSms.setSender( DHIS_SYSTEM_SENDER );
- outboundSmsService.saveOutboundSms( outboundSms );
-
- String sql = "INSERT INTO programinstance_outboundsms"
- + "( programinstanceid, outboundsmsid, sort_order) VALUES " + "("
- + schedulingProgramObject.getProgramInstanceId() + ", " + outboundSms.getId() + ","
- + (System.currentTimeMillis() / 1000) + ") ";
-
- jdbcTemplate.execute( sql );
+ outboundSmsService.sendMessage( outboundSms, null );
+
+ ProgramInstance programInstance = programInstanceService.getProgramInstance( schedulingProgramObject.getProgramInstanceId() );
+ List<OutboundSms> messages = programInstance.getOutboundSms();
+ if( messages == null )
+ {
+ messages = new ArrayList<OutboundSms>();
+ }
+ messages.add( outboundSms );
+ programInstance.setOutboundSms( messages );
+ programInstanceService.updateProgramInstance( programInstance );
}
catch ( SmsServiceException e )
{
@@ -134,12 +133,15 @@
outboundSms.setSender( DHIS_SYSTEM_SENDER );
outboundSmsService.sendMessage( outboundSms, null );
- String sql = "INSERT INTO programstageinstance_outboundsms"
- + "( programstageinstanceid, outboundsmsid, sort_order) VALUES " + "("
- + schedulingProgramObject.getProgramStageInstanceId() + ", " + outboundSms.getId() + ","
- + (System.currentTimeMillis() / 1000) + ") ";
-
- jdbcTemplate.execute( sql );
+ ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( schedulingProgramObject.getProgramStageInstanceId() );
+ List<OutboundSms> messages = programStageInstance.getOutboundSms();
+ if( messages == null )
+ {
+ messages = new ArrayList<OutboundSms>();
+ }
+ messages.add( outboundSms );
+ programStageInstance.setOutboundSms( messages );
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
}
catch ( SmsServiceException e )
{
=== 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 2013-04-10 08:45:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-10 09:48:12 +0000
@@ -1048,7 +1048,6 @@
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="programInstanceService"
ref="org.hisp.dhis.program.ProgramInstanceService" />
- <property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="outboundSmsService"
ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
</bean>