dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23267
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11306: Send sms when a program of person is completed.
------------------------------------------------------------
revno: 11306
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-07-02 21:26:44 +0700
message:
Send sms when a program of person 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/HibernateProgramInstanceStore.java
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/patient/SetProgramInstanceStatusAction.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/program/AddProgramAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.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/addProgramForm.vm
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/program.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/updateProgramForm.vm
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-07-02 12:24:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientReminder.java 2013-07-02 14:26:44 +0000
@@ -73,6 +73,8 @@
public static final int SEND_WHEN_TO_EMROLLEMENT = 1;
public static final int SEND_WHEN_TO_C0MPLETED_EVENT = 2;
+
+ public static final int SEND_WHEN_TO_C0MPLETED_PROGRAM = 3;
private int id;
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2013-06-17 05:28:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2013-07-02 14:26:44 +0000
@@ -287,7 +287,7 @@
+ " and prm.templatemessage is not NULL and prm.templatemessage != '' "
+ " and pg.type=1 and prm.daysallowedsendmessage is not null "
+ " and ( DATE(now()) - DATE(pi." + dateToCompare + ") ) = prm.daysallowedsendmessage "
- + " and prm.dateToCompare='" + dateToCompare + "' and prm.sendto = "
+ + " and prm.whenToSend is null and prm.dateToCompare='" + dateToCompare + "' and prm.sendto = "
+ PatientReminder.SEND_TO_PATIENT;
}
@@ -313,7 +313,7 @@
+ " ) ) = prm.daysallowedsendmessage "
+ " and prm.dateToCompare='"
+ dateToCompare
- + "' and prm.sendto = " + PatientReminder.SEND_TO_HEALTH_WORKER;
+ + "' and prm.whenToSend is null and prm.sendto = " + PatientReminder.SEND_TO_HEALTH_WORKER;
}
private String sendMessageToOrgunitRegisteredSql( String dateToCompare )
@@ -336,7 +336,7 @@
+ " ) ) = prm.daysallowedsendmessage "
+ " and prm.dateToCompare='"
+ dateToCompare
- + "' and prm.sendto = " + PatientReminder.SEND_TO_ORGUGNIT_REGISTERED;
+ + "' and prm.whenToSend is null and prm.sendto = " + PatientReminder.SEND_TO_ORGUGNIT_REGISTERED;
}
private String sendMessageToUsersSql( String dateToCompare )
=== 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-07-02 12:24:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java 2013-07-02 14:26:44 +0000
@@ -157,12 +157,12 @@
programStageInstance.setCompletedDate( date );
programStageInstance.setCompletedUser( currentUserService.getCurrentUsername() );
- programStageInstanceService.updateProgramStageInstance( programStageInstance );
-
// Send message when to completed the event
sendSMSToCompletedEvent( programStageInstance );
-
+
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+
// ---------------------------------------------------------------------
// Check Completed status for all of ProgramStageInstance of
// ProgramInstance
@@ -186,6 +186,8 @@
programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
programInstance.setEndDate( new Date() );
+ sendSMSToCompletedProgram( programInstance );
+
programInstanceService.updateProgramInstance( programInstance );
Program program = programInstance.getProgram();
@@ -223,12 +225,131 @@
if ( reminder != null )
{
- sendMessage( reminder, programStageInstance, patient );
- }
- }
- }
-
- private void sendMessage( PatientReminder reminder, ProgramStageInstance programStageInstance, Patient patient )
+ sendEventMessage( reminder, programStageInstance, patient );
+ }
+ }
+ }
+
+ private void sendEventMessage( PatientReminder reminder, ProgramStageInstance programStageInstance, Patient patient )
+ {
+ Set<String> phoneNumbers = getPhonenumbers( reminder, patient );
+
+ 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 );
+ }
+ catch ( SmsServiceException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private void sendSMSToCompletedProgram( ProgramInstance programInstance )
+ {
+ Patient patient = programInstance.getPatient();
+
+ if ( patient != null )
+ {
+ Collection<PatientReminder> reminders = programInstance.getProgram().getPatientReminders();
+ PatientReminder reminder = null;
+ for ( PatientReminder rm : reminders )
+ {
+ if ( rm.getWhenToSend() == PatientReminder.SEND_WHEN_TO_C0MPLETED_EVENT )
+ {
+ reminder = rm;
+ break;
+ }
+ }
+
+ if ( reminder != null )
+ {
+ sendProgramMessage( reminder, programInstance, patient );
+ }
+ }
+ }
+
+ private void sendProgramMessage( PatientReminder reminder, ProgramInstance programInstance, Patient patient )
+ {
+ Set<String> phoneNumbers = getPhonenumbers( reminder, patient );
+
+ if ( phoneNumbers.size() > 0 )
+ {
+
+ String msg = reminder.getTemplateMessage();
+
+ String patientName = patient.getFirstName();
+ String organisationunitName = patient.getOrganisationUnit().getName();
+ String programName = programInstance.getProgram().getName();
+ String daysSinceEnrollementDate = DateUtils.daysBetween( new Date(), programInstance.getEnrollmentDate() )
+ + "";
+ String daysSinceIncidentDate = DateUtils.daysBetween( new Date(), programInstance.getDateOfIncident() )
+ + "";
+ String incidentDate = format.formatDate( programInstance.getDateOfIncident() );
+ String erollmentDate = format.formatDate( programInstance.getEnrollmentDate() );
+
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_PATIENT_NAME, patientName );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_PROGRAM_NAME, programName );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_ORGUNIT_NAME, organisationunitName );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_INCIDENT_DATE, incidentDate );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_ENROLLMENT_DATE, erollmentDate );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_ENROLLMENT_DATE, daysSinceEnrollementDate );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_INCIDENT_DATE, daysSinceIncidentDate );
+
+ try
+ {
+ OutboundSms outboundSms = new OutboundSms();
+ outboundSms.setMessage( msg );
+ outboundSms.setRecipients( phoneNumbers );
+ outboundSms.setSender( currentUserService.getCurrentUsername() );
+ outboundSmsService.sendMessage( outboundSms, null );
+
+ List<OutboundSms> outboundSmsList = programInstance.getOutboundSms();
+ if ( outboundSmsList == null )
+ {
+ outboundSmsList = new ArrayList<OutboundSms>();
+ }
+ outboundSmsList.add( outboundSms );
+ programInstance.setOutboundSms( outboundSmsList );
+ }
+ catch ( SmsServiceException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private Set<String> getPhonenumbers( PatientReminder reminder, Patient patient )
{
Set<String> phoneNumbers = new HashSet<String>();
@@ -245,57 +366,26 @@
}
break;
case PatientReminder.SEND_TO_HEALTH_WORKER:
- phoneNumbers.add( patient.getHealthWorker().getPhoneNumber() );
+ if ( patient.getHealthWorker() != null && patient.getHealthWorker().getPhoneNumber() != null )
+ {
+ phoneNumbers.add( patient.getHealthWorker().getPhoneNumber() );
+ }
break;
case PatientReminder.SEND_TO_ORGUGNIT_REGISTERED:
- phoneNumbers.add( patient.getOrganisationUnit().getPhoneNumber() );
+ if ( patient.getOrganisationUnit().getPhoneNumber() != null
+ && !patient.getOrganisationUnit().getPhoneNumber().isEmpty() )
+ {
+ phoneNumbers.add( patient.getOrganisationUnit().getPhoneNumber() );
+ }
break;
default:
- phoneNumbers.add( patient.getPhoneNumber() );
+ if ( patient.getPhoneNumber() != null && !patient.getPhoneNumber().isEmpty() )
+ {
+ 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();
- }
- }
+ return phoneNumbers;
}
-
-
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SetProgramInstanceStatusAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SetProgramInstanceStatusAction.java 2013-04-10 03:13:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SetProgramInstanceStatusAction.java 2013-07-02 14:26:44 +0000
@@ -31,8 +31,13 @@
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;
@@ -40,6 +45,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;
@@ -56,10 +67,46 @@
private PatientService patientService;
+ public void setPatientService( PatientService patientService )
+ {
+ this.patientService = patientService;
+ }
+
private ProgramInstanceService programInstanceService;
+ public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+ {
+ this.programInstanceService = programInstanceService;
+ }
+
private ProgramStageInstanceService programStageInstanceService;
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ 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
// -------------------------------------------------------------------------
@@ -74,21 +121,6 @@
// Getters && Setters
// -------------------------------------------------------------------------
- public void setPatientService( PatientService patientService )
- {
- this.patientService = patientService;
- }
-
- public void setProgramInstanceService( ProgramInstanceService programInstanceService )
- {
- this.programInstanceService = programInstanceService;
- }
-
- public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
- {
- this.programStageInstanceService = programStageInstanceService;
- }
-
public Collection<Program> getPrograms()
{
return programs;
@@ -120,20 +152,22 @@
if ( status == ProgramInstance.STATUS_COMPLETED )
{
+ sendSMSToCompletedProgram( programInstance );
+
programInstance.setEndDate( new Date() );
-
if ( !program.getOnlyEnrollOnce() )
{
patient.getPrograms().remove( program );
patientService.updatePatient( patient );
}
}
- if ( status == ProgramInstance.STATUS_CANCELLED )
+
+ else if ( status == ProgramInstance.STATUS_CANCELLED )
{
Calendar today = Calendar.getInstance();
PeriodType.clearTimeOfDay( today );
Date currentDate = today.getTime();
-
+
programInstance.setEndDate( currentDate );
for ( ProgramStageInstance programStageInstance : programInstance.getProgramStageInstances() )
@@ -168,4 +202,110 @@
return SUCCESS;
}
+
+ private void sendSMSToCompletedProgram( ProgramInstance programInstance )
+ {
+ Patient patient = programInstance.getPatient();
+
+ if ( patient != null )
+ {
+ Collection<PatientReminder> reminders = programInstance.getProgram().getPatientReminders();
+ PatientReminder reminder = null;
+ for ( PatientReminder rm : reminders )
+ {
+ if ( rm.getWhenToSend() == PatientReminder.SEND_WHEN_TO_C0MPLETED_PROGRAM )
+ {
+ reminder = rm;
+ break;
+ }
+ }
+
+ if ( reminder != null )
+ {
+ sendProgramMessage( reminder, programInstance, patient );
+ }
+ }
+ }
+
+ private void sendProgramMessage( PatientReminder reminder, ProgramInstance programInstance, 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:
+ if ( patient.getHealthWorker() != null && patient.getHealthWorker().getPhoneNumber() != null )
+ {
+ phoneNumbers.add( patient.getHealthWorker().getPhoneNumber() );
+ }
+ break;
+ case PatientReminder.SEND_TO_ORGUGNIT_REGISTERED:
+ if ( patient.getOrganisationUnit().getPhoneNumber() != null
+ && !patient.getOrganisationUnit().getPhoneNumber().isEmpty() )
+ {
+ phoneNumbers.add( patient.getOrganisationUnit().getPhoneNumber() );
+ }
+ break;
+ default:
+ if ( patient.getPhoneNumber() != null && !patient.getPhoneNumber().isEmpty() )
+ {
+ phoneNumbers.add( patient.getPhoneNumber() );
+ }
+ break;
+ }
+
+ if ( phoneNumbers.size() > 0 )
+ {
+ String msg = reminder.getTemplateMessage();
+
+ String patientName = patient.getFirstName();
+ String organisationunitName = patient.getOrganisationUnit().getName();
+ String programName = programInstance.getProgram().getName();
+ String daysSinceEnrollementDate = DateUtils.daysBetween( new Date(), programInstance.getEnrollmentDate() )
+ + "";
+ String daysSinceIncidentDate = DateUtils.daysBetween( new Date(), programInstance.getDateOfIncident() )
+ + "";
+ String incidentDate = format.formatDate( programInstance.getDateOfIncident() );
+ String erollmentDate = format.formatDate( programInstance.getEnrollmentDate() );
+
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_PATIENT_NAME, patientName );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_PROGRAM_NAME, programName );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_ORGUNIT_NAME, organisationunitName );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_INCIDENT_DATE, incidentDate );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_ENROLLMENT_DATE, erollmentDate );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_ENROLLMENT_DATE, daysSinceEnrollementDate );
+ msg = msg.replace( PatientReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_INCIDENT_DATE, daysSinceIncidentDate );
+
+ try
+ {
+ OutboundSms outboundSms = new OutboundSms();
+ outboundSms.setMessage( msg );
+ outboundSms.setRecipients( phoneNumbers );
+ outboundSms.setSender( currentUserService.getCurrentUsername() );
+ outboundSmsService.sendMessage( outboundSms, null );
+ List<OutboundSms> outboundSmsList = programInstance.getOutboundSms();
+ if ( outboundSmsList == null )
+ {
+ outboundSmsList = new ArrayList<OutboundSms>();
+ }
+ outboundSmsList.add( outboundSms );
+ programInstance.setOutboundSms( outboundSmsList );
+ }
+ 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-07-02 12:24:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-07-02 14:26:44 +0000
@@ -694,6 +694,8 @@
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ <property name="outboundSmsService" ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
</bean>
<bean id="org.hisp.dhis.caseentry.action.patient.GetProgramAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java 2013-06-14 15:52:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java 2013-07-02 14:26:44 +0000
@@ -98,6 +98,13 @@
this.patientAttributeService = patientAttributeService;
}
+ private List<Integer> whenToSend = new ArrayList<Integer>();
+
+ public void setWhenToSend( List<Integer> whenToSend )
+ {
+ this.whenToSend = whenToSend;
+ }
+
// -------------------------------------------------------------------------
// Input/Output
// -------------------------------------------------------------------------
@@ -324,6 +331,7 @@
templateMessages.get( i ) );
reminder.setDateToCompare( datesToCompare.get( i ) );
reminder.setSendTo( sendTo.get( i ) );
+ reminder.setWhenToSend( whenToSend.get( i ) );
patientReminders.add( reminder );
}
program.setPatientReminders( patientReminders );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java 2013-06-14 15:52:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java 2013-07-02 14:26:44 +0000
@@ -238,6 +238,13 @@
this.displayOnAllOrgunit = displayOnAllOrgunit;
}
+ private List<Integer> whenToSend = new ArrayList<Integer>();
+
+ public void setWhenToSend( List<Integer> whenToSend )
+ {
+ this.whenToSend = whenToSend;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -317,6 +324,7 @@
templateMessages.get( i ) );
reminder.setDateToCompare( datesToCompare.get( i ) );
reminder.setSendTo( sendTo.get( i ) );
+ reminder.setWhenToSend( whenToSend.get( i ) );
patientReminders.add( reminder );
}
program.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 12:24:02 +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 14:26:44 +0000
@@ -418,4 +418,7 @@
date_in_future = Date in future
age_years = Age(years)
send_when_to = Send when to
-complete_event = Complete event
\ No newline at end of file
+complete_event = Complete event
+send_to = Send to
+complete_program = Complete program
+from_the_day_set = From the day set
\ 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/addProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2013-06-14 15:52:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2013-07-02 14:26:44 +0000
@@ -34,6 +34,9 @@
var sendTo = jQuery( "#sendTo" );
sendTo.empty();
+ var whenToSend = jQuery( "#whenToSend" );
+ whenToSend.empty();
+
jQuery(".daysAllowedSendMessage").each( function( i, item ){
daysAllowedSendMessages.append( "<option value='" + item.value + "' selected='true'>" + item.value +"</option>" );
});
@@ -50,6 +53,10 @@
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>" );
+ });
+
var selectedPropertyIds = jQuery( "#selectedPropertyIds" );
selectedPropertyIds.empty();
var personDisplayNames = jQuery( "#personDisplayNames" );
@@ -79,7 +86,8 @@
<select id='templateMessages' name="templateMessages" multiple="multiple" class="hidden"></select>
<select id='datesToCompare' name="datesToCompare" 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>
<tr>
@@ -290,4 +298,8 @@
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_send_when_to = '$encoder.jsEscape( $i18n.getString( "send_when_to" ) , "'")';
+ var i18n_from_the_day_set = '$encoder.jsEscape( $i18n.getString( "from_the_day_set" ) , "'")';
+ var i18n_complete_program = '$encoder.jsEscape( $i18n.getString( "complete_program" ) , "'")';
+ var i18n_program_enrollment = '$encoder.jsEscape( $i18n.getString( "program_enrollment" ) , "'")';
</script>
=== 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-07-02 12:24:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2013-07-02 14:26:44 +0000
@@ -185,7 +185,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_send_when_to = '$encoder.jsEscape( $i18n.getString( "send_when_to" ) , "'")';
var i18n_from_the_day_set = '$encoder.jsEscape( $i18n.getString( "from_the_day_set" ) , "'")';
var i18n_complete_event = '$encoder.jsEscape( $i18n.getString( "complete_event" ) , "'")';
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js 2013-06-14 15:52:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js 2013-07-02 14:26:44 +0000
@@ -267,6 +267,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_send_when_to + '</label></td>'
+ + '<td>'
+ + '<select id="whenToSend' + rowId + '" name="whenToSend' + rowId + '" class="whenToSend" >'
+ + '<option value="">' + i18n_from_the_day_set + '</option>'
+ + '<option value="3">' + i18n_complete_program + '</option>'
+ + '</select>'
+ + '</td>'
+ + '</tr>'
+ + '<tr name="tr' + rowId + '">'
+ '<td><label>' + i18n_date_to_compare + '</label></td>'
+ '<td>'
+ '<select class="dateToCompare">'
=== 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-07-02 12:24:02 +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 14:26:44 +0000
@@ -278,7 +278,7 @@
+ '<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><label>' + i18n_send_when_to + '</label></td>'
+ '<td>'
+ '<select id="whenToSend' + rowId + '" name="whenToSend' + rowId + '" class="whenToSend" >'
+ '<option value="">' + i18n_from_the_day_set + '</option>'
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2013-06-14 15:52:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2013-07-02 14:26:44 +0000
@@ -34,6 +34,9 @@
var sendTo = jQuery( "#sendTo" );
sendTo.empty();
+ var whenToSend = jQuery( "#whenToSend" );
+ whenToSend.empty();
+
jQuery(".daysAllowedSendMessage").each( function( i, item ){
daysAllowedSendMessages.append( "<option value='" + item.value + "' selected='true'>" + item.value +"</option>" );
});
@@ -50,6 +53,10 @@
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>" );
+ });
+
var selectedPropertyIds = jQuery( "#selectedPropertyIds" );
selectedPropertyIds.empty();
var personDisplayNames = jQuery( "#personDisplayNames" );
@@ -77,7 +84,8 @@
<select id='templateMessages' name="templateMessages" multiple="multiple" class="hidden"></select>
<select id='datesToCompare' name="datesToCompare" 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>
+
<input type="hidden" id="id" name="id" value="$program.id">
<table id="detailsList">
<thead>
@@ -282,7 +290,16 @@
</td>
</tr>
<tr name="tr$index">
- <td><label>$i18n.getString( "date_to_compare")</label></td>
+ <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="3" #if($!reminder.whenToSend==3) selected #end >$i18n.getString("complete_program")</option>
+ </select>
+ </td>
+ </tr>
+ <tr name="tr$index">
+ <td><label>$i18n.getString( "date_to_compare")</label></td>
<td>
<select class="dateToCompare"/>
<option value="dateofincident">$i18n.getString( "incident_date" )</option>
@@ -365,5 +382,10 @@
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_send_when_to = '$encoder.jsEscape( $i18n.getString( "send_when_to" ) , "'")';
+ var i18n_from_the_day_set = '$encoder.jsEscape( $i18n.getString( "from_the_day_set" ) , "'")';
+ var i18n_complete_program = '$encoder.jsEscape( $i18n.getString( "complete_program" ) , "'")';
+ var i18n_program_enrollment = '$encoder.jsEscape( $i18n.getString( "program_enrollment" ) , "'")';
+
programOnChange();
</script>
=== 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-07-02 12:24:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2013-07-02 14:26:44 +0000
@@ -257,7 +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_send_when_to = '$encoder.jsEscape( $i18n.getString( "send_when_to" ) , "'")';
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