← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11460: send sms, message, email to user group whenever completing programs

 

------------------------------------------------------------
revno: 11460
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-07-22 16:24:53 +0700
message:
  send sms,message,email to user group whenever completing programs
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-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.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/java/org/hisp/dhis/patient/action/programstage/GetProgramStageAction.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/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-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-19 06:04:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java	2013-07-22 09:24:53 +0000
@@ -105,14 +105,14 @@
     {
         this.format = format;
     }
-    
+
     private MessageService messageService;
 
     public void setMessageService( MessageService messageService )
     {
         this.messageService = messageService;
     }
-    
+
     // -------------------------------------------------------------------------
     // Input / Output
     // -------------------------------------------------------------------------
@@ -193,7 +193,6 @@
 
             programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
             programInstance.setEndDate( new Date() );
-
             sendSMSToCompletedProgram( programInstance );
 
             programInstanceService.updateProgramInstance( programInstance );
@@ -238,21 +237,7 @@
 
         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 );
+            String msg = getStringMsgFromTemplateMsg( reminder, programStageInstance, patient );
             try
             {
                 OutboundSms outboundSms = new OutboundSms();
@@ -279,7 +264,7 @@
         {
             String msg = getStringMsgFromTemplateMsg( reminder, programStageInstance, patient );
             String programStageName = programStageInstance.getProgramStage().getName();
-            messageService.sendMessage( programStageName, msg, null, reminder.getUserGroup().getMembers(),false, true );
+            messageService.sendMessage( programStageName, msg, null, reminder.getUserGroup().getMembers(), false, true );
         }
     }
 
@@ -307,26 +292,7 @@
 
         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 );
+            String msg = getStringMsgFromTemplateMsg( reminder, programInstance, patient );
 
             try
             {
@@ -349,6 +315,12 @@
                 e.printStackTrace();
             }
         }
+        else
+        {
+            String msg = getStringMsgFromTemplateMsg( reminder, programInstance, patient );
+            String programName = programInstance.getProgram().getName();
+            messageService.sendMessage( programName, msg, null, reminder.getUserGroup().getMembers(), false, true );
+        }
     }
 
     private Set<String> getPhonenumbers( PatientReminder reminder, Patient patient )
@@ -381,18 +353,6 @@
             }
             break;
         case PatientReminder.SEND_TO_USER_GROUP:
-            /*UserGroup userGroup = reminder.getUserGroup();
-            if ( userGroup != null && userGroup.getMembers().size() > 0 )
-            {
-                Set<User> receivers = new HashSet<User>( userGroup.getMembers() );
-                for ( User user : receivers )
-                {
-                    if( user.getPhoneNumber() != null && !user.getPhoneNumber().isEmpty() )
-                    {
-                        phoneNumbers.add( user.getPhoneNumber() );
-                    }
-                }
-            }*/
             phoneNumbers.clear();
             break;
         default:
@@ -404,8 +364,9 @@
         }
         return phoneNumbers;
     }
-    
-    public String getStringMsgFromTemplateMsg( PatientReminder reminder, ProgramStageInstance programStageInstance, Patient patient  )
+
+    public String getStringMsgFromTemplateMsg( PatientReminder reminder, ProgramStageInstance programStageInstance,
+        Patient patient )
     {
         String msg = reminder.getTemplateMessage();
 
@@ -422,7 +383,31 @@
         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 );
-        
+
+        return msg;
+    }
+
+    public String getStringMsgFromTemplateMsg( PatientReminder reminder, ProgramInstance programInstance,
+        Patient patient )
+    {
+        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 );
+
         return msg;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAction.java	2013-05-03 07:36:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/GetProgramAction.java	2013-07-22 09:24:53 +0000
@@ -70,7 +70,7 @@
     {
         this.selectionTreeManager = selectionTreeManager;
     }
-
+    
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -138,7 +138,7 @@
     {
         return availableOrgunitGroups;
     }
-
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -152,7 +152,7 @@
         availableOrgunitGroups.removeAll( program.getOrganisationUnitGroups() );
 
         selectionTreeManager.setSelectedOrganisationUnits( program.getOrganisationUnits() );
-
+        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java	2013-07-19 06:04:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java	2013-07-22 09:24:53 +0000
@@ -27,6 +27,7 @@
 
 package org.hisp.dhis.patient.action.program;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
@@ -39,6 +40,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;
 
@@ -74,6 +77,13 @@
         this.patientAttributeService = patientAttributeService;
     }
     
+    private UserGroupService userGroupService;
+    
+    public void setUserGroupService( UserGroupService userGroupService )
+    {
+        this.userGroupService = userGroupService;
+    }
+    
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -148,6 +158,13 @@
     {
         return availableAttributes;
     }
+    
+    private List<UserGroup> userGroups;
+
+    public List<UserGroup> getUserGroups()
+    {
+        return userGroups;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -170,6 +187,8 @@
             availableAttributes.removeAll(  new HashSet<PatientAttribute>( 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/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-07-19 06:04:09 +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-22 09:24:53 +0000
@@ -40,6 +40,8 @@
 import org.hisp.dhis.patient.PatientReminder;
 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;
 
@@ -74,6 +76,13 @@
     {
         this.patientAttributeService = patientAttributeService;
     }
+    
+    private UserGroupService userGroupService;
+    
+    public void setUserGroupService( UserGroupService userGroupService )
+    {
+        this.userGroupService = userGroupService;
+    }
 
     // -------------------------------------------------------------------------
     // Input/Output
@@ -251,6 +260,13 @@
     {
         this.useBirthDateAsEnrollmentDate = useBirthDateAsEnrollmentDate;
     }
+    
+    private List<Integer> userGroup = new ArrayList<Integer>();
+    
+    public void setUserGroup( List<Integer> userGroup )
+    {
+        this.userGroup = userGroup;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -334,6 +350,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/programstage/GetProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageAction.java	2013-07-19 06:04:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageAction.java	2013-07-22 09:24:53 +0000
@@ -118,7 +118,7 @@
 
         programStageDataElements = programStage.getProgramStageDataElements();
         
-        userGroups = new ArrayList<UserGroup>(userGroupService.getAllUserGroups());
+        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-19 06:04:09 +0000
+++ 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
@@ -229,9 +229,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.UpdateProgramAction"
 		class="org.hisp.dhis.patient.action.program.UpdateProgramAction"
 		scope="prototype">
@@ -240,6 +239,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.ValidateProgramAction"

=== 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-07-19 06:04:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js	2013-07-22 09:24:53 +0000
@@ -299,10 +299,17 @@
 				+ 			'<option value="2">' + i18n_health_worker + '</option>'
 				+ 			'<option value="3">' + i18n_orgunit_registered + '</option>'
 				+ 			'<option value="4">' + i18n_all_users_in_orgunit_registered + '</option>'
+				+ 			'<option value="5">' + i18n_user_group + '</option>'
 				+ 		'</select>'
 				+	'</td>'
 				+ '/<tr>'
 				+ '<tr name="tr' + rowId + '">'
+				+ 	'<td><label>' + i18n_user_group + '</label></td>'
+				+ 	'<td>'
+				+	program_SMS_reminder_form
+				+	'</td>'
+				+ '/<tr>'
+				+ '<tr name="tr' + rowId + '">'
 				+	'<td>' + i18n_params + '</td>'
 				+	'<td>'
 				+		'<select multiple size="4" id="params' + rowId +'" name="params" ondblclick="insertParams(this.value, ' + rowId + ');">'

=== 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-19 06:04:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js	2013-07-22 09:24:53 +0000
@@ -305,7 +305,7 @@
 				+ '<tr name="tr' + rowId + '">'
 				+ 	'<td><label>' + i18n_user_group + '</label></td>'
 				+ 	'<td>'
-				+	java
+				+	program_stage_SMS_reminder_form
 				+	'</td>'
 				+ '/<tr>'
 				+ '<tr name="tr' + rowId + '">'

=== 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-07-19 06:04:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm	2013-07-22 09:24:53 +0000
@@ -1,4 +1,9 @@
-<script>	
+<script>
+	var program_SMS_reminder_form ="<select type='text' id='userGroup$index' name='userGroup$index' class='userGroup'>";
+	#foreach( $group in $userGroups )
+		program_SMS_reminder_form += "<option value='$group.id'>$i18n.getString($group.name)</option>";
+	#end
+	program_SMS_reminder_form +="</select>";	
 	jQuery( document ).ready( function()
 {
 	validation( 'updateProgramForm', function( form ){ 
@@ -37,6 +42,9 @@
 		var whenToSend = jQuery( "#whenToSend" );
 		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>" );
 		});
@@ -57,6 +65,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" );
@@ -84,6 +96,7 @@
   <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>
 
   <input type="hidden" id="id" name="id" value="$program.id">
   <table id="detailsList">
@@ -299,7 +312,7 @@
 					<td>
 						<select type="text" id="whenToSend$index" name="whenToSend$index" class="whenToSend" onchange='whenToSendOnChange($index)'>
 							<option value="" >$i18n.getString("from_the_day_set")</option>
-							<option value="2" #if($!reminder.whenToSend==3) selected #end >$i18n.getString("complete_program")</option>
+							<option value="3" #if($!reminder.whenToSend==3) selected #end >$i18n.getString("complete_program")</option>
 						</select>
 					</td>
 				</tr>
@@ -326,6 +339,17 @@
 							<option value="2" #if($!reminder.sendTo==2) selected #end >$i18n.getString("health_worker")</option>
 							<option value="3" #if($!reminder.sendTo==3) selected #end >$i18n.getString("orgunit_registered")</option>
 							<option value="4" #if($!reminder.sendTo==4) selected #end >$i18n.getString("all_users_in_orgunit_registered")</option>
+							<option value="5" #if($!reminder.sendTo==5) selected #end >$i18n.getString("user_group")</option>
+						</select>
+					</td>
+				</tr>
+				<tr name="tr$index">
+					<td><label>$i18n.getString( "user_group" )</label></td>
+					<td>
+						<select type="text" id="userGroup$index" name="userGroup$index" class="userGroup">
+						#foreach($eachGroup in $userGroups)
+							<option value="$eachGroup.id" #if($!reminder.userGroup.id==$eachGroup.id) selected #end>$i18n.getString($eachGroup.name)</option>
+						#end	
 						</select>
 					</td>
 				</tr>
@@ -393,6 +417,7 @@
 	var i18n_complete_program = '$encoder.jsEscape( $i18n.getString( "complete_program" ) , "'")';
 	var i18n_program_enrollment = '$encoder.jsEscape( $i18n.getString( "program_enrollment" ) , "'")';
 	var i18n_complete_program_stage = '$encoder.jsEscape( $i18n.getString( "complete_program_stage" ) , "'")';
+	var i18n_user_group = '$encoder.jsEscape( $i18n.getString( "user_group" ) , "'")';
 	
 	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-19 06:04:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm	2013-07-22 09:24:53 +0000
@@ -1,9 +1,9 @@
 <script>
-var java ="<select type='text' id='userGroup$index' name='userGroup$index' class='userGroup'>";
+var program_stage_SMS_reminder_form ="<select type='text' id='userGroup$index' name='userGroup$index' class='userGroup'>";
 #foreach( $group in $userGroups )
-	java += "<option value='$group.id'>$i18n.getString($group.name)</option>";
+	program_stage_SMS_reminder_form += "<option value='$group.id'>$i18n.getString($group.name)</option>";
 #end
-java +="</select>";
+program_stage_SMS_reminder_form +="</select>";
 </script>
 <script type="text/javascript" src="javascript/updateProgramStageForm.js"></script>