dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23263
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11305: Send sms when an event is completed.
------------------------------------------------------------
revno: 11305
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-07-02 19:24:02 +0700
message:
Send sms when an event is completed.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientReminder.java
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/resources/org/hisp/dhis/patient/hibernate/PatientReminder.hbm.xml
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
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/UpdateProgramStageAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm
--
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-api/src/main/java/org/hisp/dhis/patient/PatientReminder.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientReminder.java 2013-06-14 15:52:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientReminder.java 2013-07-02 12:24:02 +0000
@@ -33,135 +33,134 @@
* @author Chau Thu Tran
* @version PatientReminder.java 1:07:58 PM Sep 18, 2012 $
*/
-public class PatientReminder
- implements Serializable
-{
- private static final long serialVersionUID = 3101502417481903219L;
-
- public static final String DUE_DATE_TO_COMPARE = "duedate";
-
- public static final String ENROLLEMENT_DATE_TO_COMPARE = "enrollmentdate";
-
- public static final String INCIDENT_DATE_TO_COMPARE = "dateofincident";
-
- public static final String TEMPLATE_MESSSAGE_PATIENT_NAME = "{patient-name}";
-
- public static final String TEMPLATE_MESSSAGE_PROGRAM_NAME = "{program-name}";
-
- public static final String TEMPLATE_MESSSAGE_PROGAM_STAGE_NAME = "{program-stage-name}";
-
- public static final String TEMPLATE_MESSSAGE_DUE_DATE = "{due-date}";
-
- public static final String TEMPLATE_MESSSAGE_ORGUNIT_NAME = "{orgunit-name}";
-
- public static final String TEMPLATE_MESSSAGE_DAYS_SINCE_DUE_DATE = "{days-since-due-date}";
-
- public static final String TEMPLATE_MESSSAGE_INCIDENT_DATE = "{incident-date}";
-
- public static final String TEMPLATE_MESSSAGE_ENROLLMENT_DATE = "{enrollement-date}";
-
- public static final String TEMPLATE_MESSSAGE_DAYS_SINCE_ENROLLMENT_DATE = "{days-since-enrollment-date}";
-
- public static final String TEMPLATE_MESSSAGE_DAYS_SINCE_INCIDENT_DATE = "{days-since-incident-date}";
-
- public static final int SEND_TO_PATIENT = 1;
-
- public static final int SEND_TO_HEALTH_WORKER = 2;
-
- public static final int SEND_TO_ORGUGNIT_REGISTERED = 3;
-
- public static final int SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED = 4;
-
- private int id;
-
- private String name;
-
- private Integer daysAllowedSendMessage;
-
- private String templateMessage;
-
- private String dateToCompare;
-
- private Integer sendTo;
-
- // -------------------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------------------
-
- public PatientReminder()
- {
-
- }
-
- public PatientReminder( String name, Integer daysAllowedSendMessage, String templateMessage )
- {
- this.name = name;
- this.daysAllowedSendMessage = daysAllowedSendMessage;
- this.templateMessage = templateMessage;
- }
-
- // -------------------------------------------------------------------------
- // Getter && Setter
- // -------------------------------------------------------------------------
-
- public int getId()
- {
- return id;
- }
-
- public void setId( int id )
- {
- this.id = id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public Integer getDaysAllowedSendMessage()
- {
- return daysAllowedSendMessage;
- }
-
- public void setDaysAllowedSendMessage( Integer daysAllowedSendMessage )
- {
- this.daysAllowedSendMessage = daysAllowedSendMessage;
- }
-
- public String getTemplateMessage()
- {
- return templateMessage;
- }
-
- public void setTemplateMessage( String templateMessage )
- {
- this.templateMessage = templateMessage;
- }
-
- public String getDateToCompare()
- {
- return dateToCompare;
- }
-
- public void setDateToCompare( String dateToCompare )
- {
- this.dateToCompare = dateToCompare;
- }
-
- public Integer getSendTo()
- {
- return sendTo;
- }
-
- public void setSendTo( Integer sendTo )
- {
- this.sendTo = sendTo;
- }
+public class PatientReminder implements Serializable {
+ private static final long serialVersionUID = 3101502417481903219L;
+
+ public static final String DUE_DATE_TO_COMPARE = "duedate";
+
+ public static final String ENROLLEMENT_DATE_TO_COMPARE = "enrollmentdate";
+
+ public static final String INCIDENT_DATE_TO_COMPARE = "dateofincident";
+
+ public static final String TEMPLATE_MESSSAGE_PATIENT_NAME = "{patient-name}";
+
+ public static final String TEMPLATE_MESSSAGE_PROGRAM_NAME = "{program-name}";
+
+ public static final String TEMPLATE_MESSSAGE_PROGAM_STAGE_NAME = "{program-stage-name}";
+
+ public static final String TEMPLATE_MESSSAGE_DUE_DATE = "{due-date}";
+
+ public static final String TEMPLATE_MESSSAGE_ORGUNIT_NAME = "{orgunit-name}";
+
+ public static final String TEMPLATE_MESSSAGE_DAYS_SINCE_DUE_DATE = "{days-since-due-date}";
+
+ public static final String TEMPLATE_MESSSAGE_INCIDENT_DATE = "{incident-date}";
+
+ public static final String TEMPLATE_MESSSAGE_ENROLLMENT_DATE = "{enrollement-date}";
+
+ public static final String TEMPLATE_MESSSAGE_DAYS_SINCE_ENROLLMENT_DATE = "{days-since-enrollment-date}";
+
+ public static final String TEMPLATE_MESSSAGE_DAYS_SINCE_INCIDENT_DATE = "{days-since-incident-date}";
+
+ public static final int SEND_TO_PATIENT = 1;
+
+ public static final int SEND_TO_HEALTH_WORKER = 2;
+
+ public static final int SEND_TO_ORGUGNIT_REGISTERED = 3;
+
+ public static final int SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED = 4;
+
+ public static final int SEND_WHEN_TO_EMROLLEMENT = 1;
+
+ public static final int SEND_WHEN_TO_C0MPLETED_EVENT = 2;
+
+ private int id;
+
+ private String name;
+
+ private Integer daysAllowedSendMessage;
+
+ private String templateMessage;
+
+ private String dateToCompare;
+
+ private Integer sendTo;
+
+ private Integer whenToSend;
+
+ // -------------------------------------------------------------------------
+ // Constructors
+ // -------------------------------------------------------------------------
+
+ public PatientReminder(String name, Integer daysAllowedSendMessage,
+ String templateMessage) {
+ this.name = name;
+ this.daysAllowedSendMessage = daysAllowedSendMessage;
+ this.templateMessage = templateMessage;
+ }
+
+ // -------------------------------------------------------------------------
+ // Getter && Setter
+ // -------------------------------------------------------------------------
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getDaysAllowedSendMessage() {
+ return daysAllowedSendMessage;
+ }
+
+ public void setDaysAllowedSendMessage(Integer daysAllowedSendMessage) {
+ this.daysAllowedSendMessage = daysAllowedSendMessage;
+ }
+
+ public String getTemplateMessage() {
+ return templateMessage;
+ }
+
+ public void setTemplateMessage(String templateMessage) {
+ this.templateMessage = templateMessage;
+ }
+
+ public String getDateToCompare() {
+ return dateToCompare;
+ }
+
+ public void setDateToCompare(String dateToCompare) {
+ this.dateToCompare = dateToCompare;
+ }
+
+ public Integer getSendTo() {
+ return sendTo;
+ }
+
+ public void setSendTo(Integer sendTo) {
+ this.sendTo = sendTo;
+ }
+
+ public Integer getWhenToSend() {
+ return whenToSend;
+ }
+
+ public void setWhenToSend(Integer whenToSend) {
+ this.whenToSend = whenToSend;
+ }
+
+ public PatientReminder() {
+
+ }
}
=== 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 2013-06-14 15:52:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-07-02 12:24:02 +0000
@@ -2399,7 +2399,7 @@
+ " and pg.type=1 and prm.daysallowedsendmessage is not null "
+ " and psi.executiondate is null "
+ " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage "
- + " and prm.sendto = " + PatientReminder.SEND_TO_PATIENT;
+ + " and prm.whentosend is null and prm.sendto = " + PatientReminder.SEND_TO_PATIENT;
}
private String sendMessageToHealthWorkerSql()
@@ -2430,7 +2430,7 @@
+ " and pg.type=1 and prm.daysallowedsendmessage is not null "
+ " and psi.executiondate is null "
+ " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage "
- + " and prm.sendto = " + PatientReminder.SEND_TO_HEALTH_WORKER;
+ + " and prm.whentosend is null and prm.sendto = " + PatientReminder.SEND_TO_HEALTH_WORKER;
}
private String sendMessageToOrgunitRegisteredSql()
@@ -2459,7 +2459,7 @@
+ " and pg.type=1 and prm.daysallowedsendmessage is not null "
+ " and psi.executiondate is null "
+ " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage "
- + " and prm.sendto = " + + PatientReminder.SEND_TO_ORGUGNIT_REGISTERED;
+ + " and prm.whentosend is null and prm.sendto = " + + PatientReminder.SEND_TO_ORGUGNIT_REGISTERED;
}
private String sendMessageToUsersSql()
@@ -2490,6 +2490,6 @@
+ " and pg.type=1 and prm.daysallowedsendmessage is not null "
+ " and psi.executiondate is null "
+ " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage "
- + " and prm.sendto = " + PatientReminder.SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED;
+ + " and prm.whentosend is null and prm.sendto = " + PatientReminder.SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientReminder.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientReminder.hbm.xml 2013-06-14 15:52:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientReminder.hbm.xml 2013-07-02 12:24:02 +0000
@@ -19,6 +19,8 @@
<property name="dateToCompare" />
<property name="sendTo" />
+
+ <property name="whenToSend" />
</class>
</hibernate-mapping>
=== 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-04-18 15:23:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java 2013-07-02 12:24:02 +0000
@@ -26,11 +26,17 @@
*/
package org.hisp.dhis.caseentry.action.caseentry;
+import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Collection;
import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientReminder;
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.program.Program;
@@ -38,7 +44,12 @@
import org.hisp.dhis.program.ProgramInstanceService;
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.sms.SmsServiceException;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsService;
+import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
import com.opensymphony.xwork2.Action;
@@ -80,6 +91,20 @@
this.currentUserService = currentUserService;
}
+ private OutboundSmsService outboundSmsService;
+
+ public void setOutboundSmsService( OutboundSmsService outboundSmsService )
+ {
+ this.outboundSmsService = outboundSmsService;
+ }
+
+ private I18nFormat format;
+
+ public void setFormat( I18nFormat format )
+ {
+ this.format = format;
+ }
+
// -------------------------------------------------------------------------
// Input / Output
// -------------------------------------------------------------------------
@@ -134,10 +159,14 @@
programStageInstanceService.updateProgramStageInstance( programStageInstance );
- // ----------------------------------------------------------------------
+ // Send message when to completed the event
+
+ sendSMSToCompletedEvent( programStageInstance );
+
+ // ---------------------------------------------------------------------
// Check Completed status for all of ProgramStageInstance of
// ProgramInstance
- // ----------------------------------------------------------------------
+ // ---------------------------------------------------------------------
if ( !programStageInstance.getProgramInstance().getProgram().getType()
.equals( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) )
@@ -170,4 +199,103 @@
return "programcompleted";
}
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private void sendSMSToCompletedEvent( ProgramStageInstance programStageInstance )
+ {
+ Patient patient = programStageInstance.getProgramInstance().getPatient();
+
+ if ( patient != null )
+ {
+ Collection<PatientReminder> reminders = programStageInstance.getProgramStage().getPatientReminders();
+ PatientReminder reminder = null;
+ for ( PatientReminder rm : reminders )
+ {
+ if ( rm.getWhenToSend() == PatientReminder.SEND_WHEN_TO_C0MPLETED_EVENT )
+ {
+ reminder = rm;
+ break;
+ }
+ }
+
+ if ( reminder != null )
+ {
+ sendMessage( reminder, programStageInstance, patient );
+ }
+ }
+ }
+
+ private void sendMessage( PatientReminder reminder, ProgramStageInstance programStageInstance, Patient patient )
+ {
+ Set<String> phoneNumbers = new HashSet<String>();
+
+ switch ( reminder.getSendTo() )
+ {
+ case PatientReminder.SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED:
+ Collection<User> users = patient.getOrganisationUnit().getUsers();
+ for ( User user : users )
+ {
+ if ( user.getPhoneNumber() != null && !user.getPhoneNumber().isEmpty() )
+ {
+ phoneNumbers.add( user.getPhoneNumber() );
+ }
+ }
+ break;
+ case PatientReminder.SEND_TO_HEALTH_WORKER:
+ phoneNumbers.add( patient.getHealthWorker().getPhoneNumber() );
+ break;
+ case PatientReminder.SEND_TO_ORGUGNIT_REGISTERED:
+ phoneNumbers.add( patient.getOrganisationUnit().getPhoneNumber() );
+ break;
+ default:
+ phoneNumbers.add( patient.getPhoneNumber() );
+ break;
+ }
+
+ if ( phoneNumbers.size() > 0 )
+ {
+
+ String msg = reminder.getTemplateMessage();
+
+ String patientName = patient.getFirstName();
+ String organisationunitName = patient.getOrganisationUnit().getName();
+ String programName = programStageInstance.getProgramInstance().getProgram().getName();
+ String programStageName = programStageInstance.getProgramStage().getName();
+ String daysSinceDueDate = DateUtils.daysBetween( new Date(), programStageInstance.getDueDate() ) + "";
+ String dueDate = format.formatDate( programStageInstance.getDueDate() );
+
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_PATIENT_NAME, patientName );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_PROGRAM_NAME, programName );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_PROGAM_STAGE_NAME, programStageName );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_DUE_DATE, dueDate );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_ORGUNIT_NAME, organisationunitName );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_DUE_DATE, daysSinceDueDate );
+ try
+ {
+ OutboundSms outboundSms = new OutboundSms();
+ outboundSms.setMessage( msg );
+ outboundSms.setRecipients( phoneNumbers );
+ outboundSms.setSender( currentUserService.getCurrentUsername() );
+ outboundSmsService.sendMessage( outboundSms, null );
+
+ List<OutboundSms> outboundSmsList = programStageInstance.getOutboundSms();
+ if ( outboundSmsList == null )
+ {
+ outboundSmsList = new ArrayList<OutboundSms>();
+ }
+ outboundSmsList.add( outboundSms );
+ programStageInstance.setOutboundSms( outboundSmsList );
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+ }
+ catch ( SmsServiceException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
}
=== 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-06-07 08:28:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-07-02 12:24:02 +0000
@@ -119,6 +119,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="outboundSmsService" ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
</bean>
<bean
=== 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 2013-06-21 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java 2013-07-02 12:24:02 +0000
@@ -183,6 +183,13 @@
{
this.sendTo = sendTo;
}
+
+ private List<Integer> whenToSend = new ArrayList<Integer>();
+
+ public void setWhenToSend( List<Integer> whenToSend )
+ {
+ this.whenToSend = whenToSend;
+ }
private Boolean autoGenerateEvent;
@@ -262,6 +269,7 @@
templateMessages.get( i ) );
reminder.setDateToCompare( PatientReminder.DUE_DATE_TO_COMPARE );
reminder.setSendTo( sendTo.get( i ) );
+ reminder.setWhenToSend( whenToSend.get( i ) );
patientReminders.add( reminder );
}
programStage.setPatientReminders( patientReminders );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java 2013-06-21 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java 2013-07-02 12:24:02 +0000
@@ -219,6 +219,13 @@
this.allowDateInFutures = allowDateInFutures;
}
+ private List<Integer> whenToSend = new ArrayList<Integer>();
+
+ public void setWhenToSend( List<Integer> whenToSend )
+ {
+ this.whenToSend = whenToSend;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -253,6 +260,7 @@
templateMessages.get( i ) );
reminder.setDateToCompare( PatientReminder.DUE_DATE_TO_COMPARE );
reminder.setSendTo( sendTo.get( i ) );
+ reminder.setWhenToSend( whenToSend.get( i ) );
patientReminders.add( reminder );
}
programStage.setPatientReminders( patientReminders );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-07-02 03:54:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-07-02 12:24:02 +0000
@@ -416,4 +416,6 @@
orgunit_registered = Organisation unit registered
all_users_in_orgunit_registered = All users in organisation unit registered
date_in_future = Date in future
-age_years = Age(years)
\ No newline at end of file
+age_years = Age(years)
+send_when_to = Send when to
+complete_event = Complete event
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2013-06-21 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2013-07-02 12:24:02 +0000
@@ -10,6 +10,7 @@
<select id='daysAllowedSendMessages' name="daysAllowedSendMessages" multiple="multiple" class="hidden"></select>
<select id='templateMessages' name="templateMessages" multiple="multiple" class="hidden"></select>
<select id='sendTo' name="sendTo" multiple="multiple" class="hidden"></select>
+ <select id='whenToSend' name="whenToSend" multiple="multiple" class="hidden"></select>
<table>
<thead>
@@ -184,6 +185,9 @@
var i18n_health_worker = '$encoder.jsEscape( $i18n.getString( "health_worker" ) , "'")';
var i18n_orgunit_registered = '$encoder.jsEscape( $i18n.getString( "orgunit_registered" ) , "'")';
var i18n_all_users_in_orgunit_registered = '$encoder.jsEscape( $i18n.getString( "all_users_in_orgunit_registered" ) , "'")';
+ var i18n_when_to_send = '$encoder.jsEscape( $i18n.getString( "when_to_send" ) , "'")';
+ var i18n_from_the_day_set = '$encoder.jsEscape( $i18n.getString( "from_the_day_set" ) , "'")';
+ var i18n_complete_event = '$encoder.jsEscape( $i18n.getString( "complete_event" ) , "'")';
var programStageList = new Array();
#foreach($programStage in $program.programStages)
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js 2013-06-21 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js 2013-07-02 12:24:02 +0000
@@ -43,6 +43,9 @@
var sendTo = jQuery( "#sendTo" );
sendTo.empty();
+ var whenToSend = jQuery( "#whenToSend" );
+ whenToSend.empty();
+
jQuery("#selectedList").find("tr").each( function( i, item ){
selectedDataElementsValidator.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" );
@@ -72,6 +75,9 @@
jQuery(".sendTo").each( function( i, item ){
sendTo.append( "<option value='" + item.value + "' selected='true'>" + item.value +"</option>" );
});
+ jQuery(".whenToSend").each( function( i, item ){
+ whenToSend.append( "<option value='" + item.value + "' selected='true'>" + item.value +"</option>" );
+ });
});
jQuery("#availableList").dhisAjaxSelect({
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js 2013-06-21 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js 2013-07-02 12:24:02 +0000
@@ -8,7 +8,7 @@
{
var programId = document.getElementById('id').value;
- if( programId == "null" || programId == "" )
+ if( programId == "null" || programId == "" )
{
showWarningMessage( i18n_please_select_program );
}
@@ -278,6 +278,15 @@
+ '<td colspan="2">' + i18n_reminder + ' ' + rowId + '<a href="javascript:removeTemplateMessageForm('+ rowId +')"> ( '+ i18n_remove_reminder + ' )</a></td>'
+ '</tr>'
+ '<tr name="tr' + rowId + '">'
+ + '<td><label>' + i18n_when_to_send + '</label></td>'
+ + '<td>'
+ + '<select id="whenToSend' + rowId + '" name="whenToSend' + rowId + '" class="whenToSend" >'
+ + '<option value="">' + i18n_from_the_day_set + '</option>'
+ + '<option value="2">' + i18n_complete_event + '</option>'
+ + '</select>'
+ + '</td>'
+ + '</tr>'
+ + '<tr name="tr' + rowId + '">'
+ '<td><label>' + i18n_days_before_after_due_date + '</label></td>'
+ '<td><input type="text" id="daysAllowedSendMessage' + rowId + '" name="daysAllowedSendMessage' + rowId + '" class="daysAllowedSendMessage {validate:{required:true,number:true}}"/></td>'
+ '</tr>'
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js 2013-06-21 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js 2013-07-02 12:24:02 +0000
@@ -43,6 +43,9 @@
var sendTo = jQuery( "#sendTo" );
sendTo.empty();
+ var whenToSend = jQuery( "#whenToSend" );
+ whenToSend.empty();
+
jQuery("#selectedList").find("tr").each( function( i, item ){
selectedDataElementsValidator.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" );
@@ -72,6 +75,9 @@
jQuery(".sendTo").each( function( i, item ){
sendTo.append( "<option value='" + item.value + "' selected='true'>" + item.value +"</option>" );
});
+ jQuery(".whenToSend").each( function( i, item ){
+ whenToSend.append( "<option value='" + item.value + "' selected='true'>" + item.value +"</option>" );
+ });
});
checkValueIsExist( "name", "validateProgramStage.action", {id:getFieldValue('programId'), programStageId:getFieldValue('id')});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2013-06-21 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2013-07-02 12:24:02 +0000
@@ -4,13 +4,14 @@
<h4>$programStage.program.displayName</h4>
-<form id="updateProgramStageForm" name="updateProgramStageForm" action="updateProgramStage.action" method="post">
+<form id="updateProgramStageForm" name="updateProgramStageForm" action="updateProgramStage.action" method="get">
<input type="hidden" id="id" name="id" value="$programStage.id"/>
<input type="hidden" id="programId" name="programId" value="$programStage.program.id"/>
<select id='daysAllowedSendMessages' name="daysAllowedSendMessages" multiple="multiple" class="hidden"></select>
<select id='templateMessages' name="templateMessages" multiple="multiple" class="hidden"></select>
<select id='sendTo' name="sendTo" multiple="multiple" class="hidden"></select>
-
+ <select id='whenToSend' name="whenToSend" multiple="multiple" class="hidden"></select>
+
<table id="detailsList">
<thead>
<tr><th colspan="2">$i18n.getString( "program_stage_details" )</th></tr>
@@ -176,6 +177,15 @@
</td>
</tr>
<tr name="tr$index">
+ <td><label>$i18n.getString( "send_when_to" )</label></td>
+ <td>
+ <select type="text" id="whenToSend$index" name="whenToSend$index" class="whenToSend">
+ <option value="" >$i18n.getString("from_the_day_set")</option>
+ <option value="2" #if($!reminder.whenToSend==2) selected #end >$i18n.getString("complete_event")</option>
+ </select>
+ </td>
+ </tr>
+ <tr name="tr$index">
<td><label>$i18n.getString( "days_before_after_due_date" )</label></td>
<td><input type="text" id="daysAllowedSendMessage$index" name="daysAllowedSendMessage$index" class="daysAllowedSendMessage {validate:{required:true,number:true}}" value="$!reminder.daysAllowedSendMessage"/></td>
</tr>
@@ -247,4 +257,7 @@
var i18n_health_worker = '$encoder.jsEscape( $i18n.getString( "health_worker" ) , "'")';
var i18n_orgunit_registered = '$encoder.jsEscape( $i18n.getString( "orgunit_registered" ) , "'")';
var i18n_all_users_in_orgunit_registered = '$encoder.jsEscape( $i18n.getString( "all_users_in_orgunit_registered" ) , "'")';
+ var i18n_when_to_send = '$encoder.jsEscape( $i18n.getString( "when_to_send" ) , "'")';
+ var i18n_from_the_day_set = '$encoder.jsEscape( $i18n.getString( "from_the_day_set" ) , "'")';
+ var i18n_complete_event = '$encoder.jsEscape( $i18n.getString( "complete_event" ) , "'")';
</script>
\ No newline at end of file