← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11446: send SMS to usergroup after complete program stage

 

------------------------------------------------------------
revno: 11446
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-07-19 13:04:09 +0700
message:
  send SMS to usergroup after complete program stage
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientReminder.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientReminder.hbm.xml
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.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/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/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/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.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/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/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/javascript/updateProgramStageForm.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 14:26:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientReminder.java	2013-07-19 06:04:09 +0000
@@ -29,6 +29,8 @@
 
 import java.io.Serializable;
 
+import org.hisp.dhis.user.UserGroup;
+
 /**
  * @author Chau Thu Tran
  * @version PatientReminder.java 1:07:58 PM Sep 18, 2012 $
@@ -70,6 +72,8 @@
 
 	public static final int SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED = 4;
 
+	public static final int SEND_TO_USER_GROUP = 5;
+
 	public static final int SEND_WHEN_TO_EMROLLEMENT = 1;
 
 	public static final int SEND_WHEN_TO_C0MPLETED_EVENT = 2;
@@ -89,6 +93,8 @@
 	private Integer sendTo;
 
 	private Integer whenToSend;
+	
+	private UserGroup userGroup;
 
 	// -------------------------------------------------------------------------
 	// Constructors
@@ -165,4 +171,12 @@
 
 	}
 
+        public UserGroup getUserGroup() {
+                return userGroup;
+        }
+
+        public void setUserGroup( UserGroup userGroup ) {
+                this.userGroup = userGroup;
+        }
+
 }

=== 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-07-02 12:24:02 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientReminder.hbm.xml	2013-07-19 06:04:09 +0000
@@ -21,6 +21,7 @@
  	<property name="sendTo" />
  	
  	<property name="whenToSend" />
- 
+ 	
+ 	<many-to-one name="userGroup" class="org.hisp.dhis.user.UserGroup" column="usergroupid" foreign-key="fk_patientreminder_usergroup"/>
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java	2013-07-16 11:33:35 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java	2013-07-19 06:04:09 +0000
@@ -402,7 +402,7 @@
         {
             Set<User> receivers = new HashSet<User>( userGroup.getMembers() );
 
-            UserCredentials anonymousUser = userService.getUserCredentialsByUsername( "system" );
+            UserCredentials anonymousUser = userService.getUserCredentialsByUsername( "c" );
 
             MessageConversation conversation = new MessageConversation( command.getName(), anonymousUser.getUser() );
 

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java	2013-07-16 06:53:26 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java	2013-07-19 06:04:09 +0000
@@ -27,6 +27,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.io.IOException;
+import java.lang.Character.UnicodeBlock;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.sms.SmsServiceException;
@@ -45,19 +52,12 @@
 import org.smslib.GatewayException;
 import org.smslib.IInboundMessageNotification;
 import org.smslib.IOutboundMessageNotification;
+import org.smslib.Message.MessageEncodings;
 import org.smslib.OutboundMessage;
 import org.smslib.SMSLibException;
 import org.smslib.Service;
-import org.smslib.Message.MessageEncodings;
 import org.smslib.Service.ServiceStatus;
 
-import java.io.IOException;
-import java.lang.Character.UnicodeBlock;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 public class SmsLibService
     implements OutboundSmsTransportService
 {
@@ -172,7 +172,7 @@
         try
         {
             log.info( "Sending message " + sms );
-
+            
             if ( gatewayId == null || gatewayId.isEmpty() )
             {
                 sent = getService().sendMessage( outboundMessage );

=== 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-12 02:46:16 +0000
+++ 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
@@ -35,6 +35,7 @@
 import java.util.Set;
 
 import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.message.MessageService;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientReminder;
 import org.hisp.dhis.patient.PatientService;
@@ -104,7 +105,14 @@
     {
         this.format = format;
     }
+    
+    private MessageService messageService;
 
+    public void setMessageService( MessageService messageService )
+    {
+        this.messageService = messageService;
+    }
+    
     // -------------------------------------------------------------------------
     // Input / Output
     // -------------------------------------------------------------------------
@@ -230,7 +238,6 @@
 
         if ( phoneNumbers.size() > 0 )
         {
-
             String msg = reminder.getTemplateMessage();
 
             String patientName = patient.getFirstName();
@@ -267,6 +274,13 @@
                 e.printStackTrace();
             }
         }
+        // send to user group
+        else
+        {
+            String msg = getStringMsgFromTemplateMsg( reminder, programStageInstance, patient );
+            String programStageName = programStageInstance.getProgramStage().getName();
+            messageService.sendMessage( programStageName, msg, null, reminder.getUserGroup().getMembers(),false, true );
+        }
     }
 
     private void sendSMSToCompletedProgram( ProgramInstance programInstance )
@@ -278,7 +292,7 @@
             Collection<PatientReminder> reminders = programInstance.getProgram().getPatientReminders();
             for ( PatientReminder rm : reminders )
             {
-                if ( rm != null && rm.getWhenToSend() == PatientReminder.SEND_WHEN_TO_C0MPLETED_EVENT )
+                if ( rm != null && rm.getWhenToSend() == PatientReminder.SEND_WHEN_TO_C0MPLETED_PROGRAM )
                 {
                     sendProgramMessage( rm, programInstance, patient );
                     break;
@@ -366,6 +380,21 @@
                 phoneNumbers.add( patient.getOrganisationUnit().getPhoneNumber() );
             }
             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:
             if ( patient.getPhoneNumber() != null && !patient.getPhoneNumber().isEmpty() )
             {
@@ -375,5 +404,26 @@
         }
         return phoneNumbers;
     }
+    
+    public String getStringMsgFromTemplateMsg( PatientReminder reminder, ProgramStageInstance programStageInstance, Patient patient  )
+    {
+        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 );
+        
+        return msg;
+    }
 
 }

=== 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-15 08:04:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-07-19 06:04:09 +0000
@@ -122,6 +122,7 @@
 		<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" />
+		<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
 	</bean>
 
 	<bean

=== 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	2012-09-22 12:23:40 +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-19 06:04:09 +0000
@@ -73,7 +73,7 @@
     {
         this.patientAttributeService = patientAttributeService;
     }
-
+    
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -169,7 +169,7 @@
             availableIdentifierTypes.removeAll( new HashSet<PatientIdentifierType>( program.getPatientIdentifierTypes() ) );
             availableAttributes.removeAll(  new HashSet<PatientAttribute>( program.getPatientAttributes() ) );
         }
-
+        
         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-16 04:31:27 +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-19 06:04:09 +0000
@@ -237,7 +237,7 @@
     {
         this.whenToSend = whenToSend;
     }
-
+    
     private Boolean useBirthDateAsIncidentDate;
 
     public void setUseBirthDateAsIncidentDate( Boolean useBirthDateAsIncidentDate )

=== 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	2011-09-01 09:17:33 +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-19 06:04:09 +0000
@@ -27,11 +27,15 @@
 
 package org.hisp.dhis.patient.action.programstage;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -53,6 +57,13 @@
     {
         this.programStageService = programStageService;
     }
+    
+    private UserGroupService userGroupService;
+    
+    public void setUserGroupService( UserGroupService userGroupService )
+    {
+        this.userGroupService = userGroupService;
+    }
 
     // -------------------------------------------------------------------------
     // Input/Output
@@ -83,7 +94,19 @@
     {
         return programStageDataElements;
     }
-
+    
+    private List<UserGroup> userGroups;
+
+    public List<UserGroup> getUserGroups()
+    {
+        return userGroups;
+    }
+
+    public void setUserGroups( List<UserGroup> userGroups )
+    {
+        this.userGroups = userGroups;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -94,6 +117,8 @@
         programStage = programStageService.getProgramStage( id );
 
         programStageDataElements = programStage.getProgramStageDataElements();
+        
+        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/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-07-09 08:28:54 +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-19 06:04:09 +0000
@@ -39,6 +39,8 @@
 import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageDataElementService;
 import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -74,7 +76,14 @@
     {
         this.programStageDataElementService = programStageDataElementService;
     }
-
+    
+    private UserGroupService userGroupService;
+    
+    public void setUserGroupService( UserGroupService userGroupService )
+    {
+        this.userGroupService = userGroupService;
+    }
+    
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -225,6 +234,13 @@
     {
         this.whenToSend = whenToSend;
     }
+    
+    private List<Integer> userGroup = new ArrayList<Integer>();
+    
+    public void setUserGroup( List<Integer> userGroup )
+    {
+        this.userGroup = userGroup;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -256,6 +272,7 @@
         programStage.setValidCompleteOnly( validCompleteOnly );
         programStage.setCaptureCoordinates( captureCoordinates );
 
+        // SMS Reminder
         Set<PatientReminder> patientReminders = new HashSet<PatientReminder>();
         for ( int i = 0; i < this.daysAllowedSendMessages.size(); i++ )
         {
@@ -264,6 +281,8 @@
             reminder.setDateToCompare( PatientReminder.DUE_DATE_TO_COMPARE );
             reminder.setSendTo( sendTo.get( i ) );
             reminder.setWhenToSend( whenToSend.get( i ) );
+            UserGroup selectedUserGroup = userGroupService.getUserGroup( userGroup.get( i ) );
+            reminder.setUserGroup( selectedUserGroup );
             patientReminders.add( reminder );
         }
         programStage.setPatientReminders( patientReminders );

=== 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-03 15:40:29 +0000
+++ 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
@@ -300,6 +300,7 @@
 		class="org.hisp.dhis.patient.action.programstage.GetProgramStageAction"
 		scope="prototype">
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+		<property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
 	</bean>
 
 	<bean
@@ -325,6 +326,8 @@
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
 		<property name="programStageDataElementService"
 			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
+		<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/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-18 03:16:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2013-07-19 06:04:09 +0000
@@ -421,6 +421,8 @@
 complete_event = Complete event
 send_to = Send to
 complete_program = Complete program
+complete_program_stage = Complete program stage
+user_group = User group
 from_the_day_set = From the day set
 orgunit_count = Organisation unit count
 default_registration_form = Default registration form

=== 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-18 03:16:06 +0000
+++ 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
@@ -274,7 +274,7 @@
 				+ 	'<td>'
 				+ 		'<select id="whenToSend' + rowId + '" name="whenToSend' + rowId + '" class="whenToSend" onchange="whenToSendOnChange(' + rowId + ')" >'
 				+ 			'<option value="">' + i18n_from_the_day_set + '</option>'
-				+ 			'<option value="3">' + i18n_complete_program + '</option>'
+				+ 			'<option value="2">' + i18n_complete_program + '</option>'
 				+ 		'</select>'
 				+	'</td>'
 				+ '</tr>'

=== 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-18 03:16:06 +0000
+++ 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
@@ -298,10 +298,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>'
+				+	java
+				+	'</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/updateProgramStageForm.js'
--- 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
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js	2013-07-19 06:04:09 +0000
@@ -44,7 +44,10 @@
 		sendTo.empty();
 		
 		var whenToSend = jQuery( "#whenToSend" );
-		whenToSend.empty();		
+		whenToSend.empty();
+		
+		var userGroup = jQuery( "#userGroup" );
+		userGroup.empty();
 		
 		jQuery("#selectedList").find("tr").each( function( i, item ){ 
 			
@@ -78,6 +81,9 @@
 		jQuery(".whenToSend").each( function( i, item ){ 
 			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>" );
+		});
 	});
 	
 	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/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm	2013-07-16 04:31:27 +0000
+++ 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
@@ -1,4 +1,4 @@
-<script>
+<script>	
 	jQuery( document ).ready( function()
 {
 	validation( 'updateProgramForm', function( form ){ 
@@ -35,7 +35,7 @@
 		sendTo.empty();
 		
 		var whenToSend = jQuery( "#whenToSend" );
-		whenToSend.empty();		
+		whenToSend.empty();
 		
 		jQuery(".daysAllowedSendMessage").each( function( i, item ){ 
 			daysAllowedSendMessages.append( "<option value='" + item.value + "' selected='true'>" + item.value +"</option>" );
@@ -70,9 +70,8 @@
 				var checked = displayed.attr('checked') ? true : false;
 				personDisplayNames.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
 			});
-		}
+		};
 	});
-	
 	checkValueIsExist( "name", "validateProgram.action",{id:getFieldValue('id')} );	
 });
 </script>
@@ -85,7 +84,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>
-	
+
   <input type="hidden" id="id" name="id" value="$program.id">
   <table id="detailsList">
     <thead>
@@ -300,7 +299,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="3" #if($!reminder.whenToSend==3) selected #end >$i18n.getString("complete_program")</option>
+							<option value="2" #if($!reminder.whenToSend==3) selected #end >$i18n.getString("complete_program")</option>
 						</select>
 					</td>
 				</tr>
@@ -369,7 +368,6 @@
       </tr>
   </table>
 </form>
-
 <script>
 	var i18n_reminder = '$encoder.jsEscape( $i18n.getString( "reminder" ) , "'")';   
 	var i18n_remove_reminder = '$encoder.jsEscape( $i18n.getString( "remove_reminder" ) , "'")';   
@@ -394,6 +392,7 @@
 	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" ) , "'")';
-
+	var i18n_complete_program_stage = '$encoder.jsEscape( $i18n.getString( "complete_program_stage" ) , "'")';
+	
 	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-16 04:31:27 +0000
+++ 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
@@ -1,3 +1,10 @@
+<script>
+var java ="<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>";
+#end
+java +="</select>";
+</script>
 <script type="text/javascript" src="javascript/updateProgramStageForm.js"></script>
 
 <h3>$i18n.getString( "edit_program_stage" )</h3>
@@ -11,6 +18,7 @@
 	<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>
+	<select id='userGroup' name="userGroup" multiple="multiple" class="hidden"></select>
 	
 	<table id="detailsList">
 		<thead>
@@ -199,6 +207,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>
@@ -262,4 +281,6 @@
 	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" ) , "'")';
+	var i18n_program_stage_name = '$encoder.jsEscape( $i18n.getString( "program_stage_name" ) , "'" )';
+	var i18n_user_group = '$encoder.jsEscape( $i18n.getString( "user_group" ) , "'")';
 </script>
\ No newline at end of file