dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23650
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11521: send SMS to user group in add program form
------------------------------------------------------------
revno: 11521
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-07-26 09:37:52 +0700
message:
send SMS to user group in add program form
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java
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/ShowAddProgramFormAction.java
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/webapp/dhis-web-maintenance-patient/addProgramForm.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-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-07-02 14:26:44 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2013-07-26 02:37:52 +0000
@@ -364,4 +364,36 @@
+ PatientReminder.SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED;
}
+ private String sendMessageToUserGroupsSql()
+ {
+ return "select pi.programinstanceid, uif.phonenumber,prm.templatemessage, p.firstname, p.middlename, p.lastname, org.name as orgunitName ,"
+ + " pg.name as programName, ps.name as programStageName, psi.duedate, "
+ + "(DATE(now()) - DATE(psi.duedate) ) as days_since_due_date "
+ + " from patient p INNER JOIN programinstance pi "
+ + " ON p.patientid=pi.patientid "
+ + " INNER JOIN programstageinstance psi "
+ + " ON psi.programinstanceid=pi.programinstanceid "
+ + " INNER JOIN program pg "
+ + " ON pg.programid=pi.programid "
+ + " INNER JOIN programstage ps "
+ + " ON ps.programstageid=psi.programstageid "
+ + " INNER JOIN patientreminder prm "
+ + " ON prm.programstageid = ps.programstageid "
+ + " INNER JOIN organisationunit org "
+ + " ON org.organisationunitid = p.organisationunitid "
+ + " INNER JOIN usergroupmembers ugm "
+ + " ON ugm.usergroupid = prm.usergroupid "
+ + " INNER JOIN userinfo uif "
+ + " ON uif.userinfoid = ugm.userid "
+ + " WHERE pi.status= "
+ + ProgramInstance.STATUS_ACTIVE
+ + " and uif.phonenumber is not NULL and uif.phonenumber != '' "
+ + " and prm.templatemessage is not NULL and prm.templatemessage != '' "
+ + " and pg.type=1 and prm.daysallowedsendmessage is not null "
+ + " and psi.executiondate is not null "
+ + " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage "
+ + " and prm.whentosend is null "
+ //+ " and prm.whentosend = " + PatientReminder.SEND_WHEN_TO_EMROLLEMENT
+ + " and prm.sendto = " + PatientReminder.SEND_TO_USER_GROUP;
+ }
}
=== 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-07-25 02:32:32 +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-26 02:37:52 +0000
@@ -45,6 +45,8 @@
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupService;
import com.opensymphony.xwork2.Action;
@@ -98,11 +100,11 @@
this.patientAttributeService = patientAttributeService;
}
- private List<Integer> whenToSend = new ArrayList<Integer>();
-
- public void setWhenToSend( List<Integer> whenToSend )
+ private UserGroupService userGroupService;
+
+ public void setUserGroupService( UserGroupService userGroupService )
{
- this.whenToSend = whenToSend;
+ this.userGroupService = userGroupService;
}
// -------------------------------------------------------------------------
@@ -255,6 +257,20 @@
{
this.useBirthDateAsEnrollmentDate = useBirthDateAsEnrollmentDate;
}
+
+ private List<Integer> userGroup = new ArrayList<Integer>();
+
+ public void setUserGroup( List<Integer> userGroup )
+ {
+ this.userGroup = userGroup;
+ }
+
+ private List<Integer> whenToSend = new ArrayList<Integer>();
+
+ public void setWhenToSend( List<Integer> whenToSend )
+ {
+ this.whenToSend = whenToSend;
+ }
private Boolean selectEnrollmentDatesInFuture;
@@ -262,7 +278,6 @@
{
this.selectEnrollmentDatesInFuture = selectEnrollmentDatesInFuture;
}
-
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -350,6 +365,8 @@
reminder.setDateToCompare( datesToCompare.get( i ) );
reminder.setSendTo( sendTo.get( i ) );
reminder.setWhenToSend( whenToSend.get( i ) );
+ UserGroup selectedUserGroup = userGroupService.getUserGroup( userGroup.get( i ) );
+ reminder.setUserGroup( selectedUserGroup );
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/ShowAddProgramFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java 2012-09-05 14:30:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java 2013-07-26 02:37:52 +0000
@@ -27,7 +27,9 @@
package org.hisp.dhis.patient.action.program;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.hisp.dhis.patient.PatientAttribute;
import org.hisp.dhis.patient.PatientAttributeService;
@@ -35,6 +37,8 @@
import org.hisp.dhis.patient.PatientIdentifierTypeService;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupService;
import com.opensymphony.xwork2.Action;
@@ -69,7 +73,13 @@
{
this.patientAttributeService = patientAttributeService;
}
-
+
+ private UserGroupService userGroupService;
+
+ public void setUserGroupService( UserGroupService userGroupService )
+ {
+ this.userGroupService = userGroupService;
+ }
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -87,6 +97,13 @@
{
return availableAttributes;
}
+
+ private List<UserGroup> userGroups;
+
+ public List<UserGroup> getUserGroups()
+ {
+ return userGroups;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -106,6 +123,8 @@
availableAttributes.removeAll( program.getPatientAttributes() );
}
+ userGroups = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
+
return SUCCESS;
}
}
=== 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-07-22 09:24:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-07-26 02:37:52 +0000
@@ -179,6 +179,8 @@
ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
<property name="patientAttributeService"
ref="org.hisp.dhis.patient.PatientAttributeService" />
+ <property name="userGroupService"
+ ref="org.hisp.dhis.user.UserGroupService" />
</bean>
<bean id="org.hisp.dhis.patient.action.program.GetProgramListAction"
@@ -218,6 +220,7 @@
ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
<property name="patientAttributeService"
ref="org.hisp.dhis.patient.PatientAttributeService" />
+ <property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
</bean>
<bean
=== 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-07-25 02:43:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2013-07-26 02:37:52 +0000
@@ -41,7 +41,10 @@
sendTo.empty();
var whenToSend = jQuery( "#whenToSend" );
- whenToSend.empty();
+ whenToSend.empty();
+
+ var userGroup = jQuery( "#userGroup" );
+ userGroup.empty();
jQuery(".daysAllowedSendMessage").each( function( i, item ){
daysAllowedSendMessages.append( "<option value='" + item.value + "' selected='true'>" + item.value +"</option>" );
@@ -63,6 +66,10 @@
whenToSend.append( "<option value='" + item.value + "' selected='true'>" + item.value +"</option>" );
});
+ jQuery(".userGroup").each( function( i, item ){
+ userGroup.append( "<option value='" + item.value + "' selected='true'>" + item.value +"</option>" );
+ });
+
var selectedPropertyIds = jQuery( "#selectedPropertyIds" );
selectedPropertyIds.empty();
var personDisplayNames = jQuery( "#personDisplayNames" );
@@ -87,12 +94,12 @@
<h3>$i18n.getString( "create_new_program" )</h3>
<form id="addProgramForm" name="addProgramForm" action="addProgram.action" method="get" >
-
-<select id='daysAllowedSendMessages' name="daysAllowedSendMessages" multiple="multiple" class="hidden"></select>
-<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>
+ <select id='daysAllowedSendMessages' name="daysAllowedSendMessages" multiple="multiple" class="hidden"></select>
+ <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>
+ <select id='userGroup' name="userGroup" multiple="multiple" class="hidden"></select>
<table>
<thead>
@@ -309,5 +316,4 @@
var i18n_complete_program = '$encoder.jsEscape( $i18n.getString( "complete_program" ) , "'")';
var i18n_program_enrollment = '$encoder.jsEscape( $i18n.getString( "program_enrollment" ) , "'")';
var i18n_user_group = '$encoder.jsEscape( $i18n.getString( "user_group" ) , "'")';
-
</script>