← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7920: Add function to search patients by status of events in SMS Reminder ans sent SMS for patients in ...

 

------------------------------------------------------------
revno: 7920
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-08-16 20:46:23 +0700
message:
  Add function to search patients by status of events in SMS Reminder ans sent SMS for patients in result list.
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/GetGatewayAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsToListAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sendSmsForm.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
  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/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsPatientRecords.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderList.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties


--
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/PatientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2012-07-06 09:59:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2012-08-16 13:46:23 +0000
@@ -206,4 +206,9 @@
     Collection<Patient> searchPatients( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max );
     
     int countSearchPatients( List<String> searchKeys, OrganisationUnit orgunit );
+    
+    Collection<String> getPatientPhoneNumbers( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max );
+
+    Collection<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max );
+
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2012-07-06 09:59:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2012-08-16 13:46:23 +0000
@@ -69,4 +69,9 @@
     Collection<Patient> search( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max );
     
     int countSearch( List<String> searchKeys, OrganisationUnit orgunit );
+    
+    Collection<String> getPatientPhoneNumbers( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max );
+
+    Collection<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min,
+        Integer max );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-07-03 09:39:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-08-16 13:46:23 +0000
@@ -37,6 +37,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patientreport.TabularReportColumn;
+import org.hisp.dhis.sms.outbound.OutboundSms;
 
 /**
  * @author Abyot Asalefew
@@ -96,4 +97,6 @@
     List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n );
     
     void removeEmptyEvents( ProgramStage programStage );
+
+    void updateProgramStageInstances( Collection<Integer> programStageInstances, OutboundSms outboundSms );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-07-03 09:39:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-08-16 13:46:23 +0000
@@ -37,6 +37,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patientreport.TabularReportColumn;
+import org.hisp.dhis.sms.outbound.OutboundSms;
 
 /**
  * @author Abyot Asalefew
@@ -82,4 +83,6 @@
         Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate );
     
     void removeEmptyEvents( ProgramStage programStage );
+
+    void update( Collection<Integer> programStageInstanceIds, OutboundSms outboundSms );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2012-08-01 20:02:29 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2012-08-16 13:46:23 +0000
@@ -523,4 +523,16 @@
     {
         return patientStore.countSearch( searchKeys, orgunit );
     }
+    
+    public Collection<String> getPatientPhoneNumbers( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max )
+    {
+        return patientStore.getPatientPhoneNumbers( searchKeys, orgunit, min, max );
+    }
+    
+    public Collection<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max )
+    {
+        return patientStore.getProgramStageInstances( searchKeys, orgunit, min, max );
+    }
+    
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-08-16 06:20:33 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-08-16 13:46:23 +0000
@@ -263,6 +263,59 @@
         }
         return patients;
     }
+    
+    @Override
+    public Collection<String> getPatientPhoneNumbers( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max )
+    {
+        String sql = searchPatientSql( false, searchKeys, orgunit, min, max );
+
+        Collection<String> phoneNumbers = new HashSet<String>();
+        
+        try
+        {
+            phoneNumbers = jdbcTemplate.query( sql, new RowMapper<String>()
+            {
+                public String mapRow( ResultSet rs, int rowNum )
+                    throws SQLException
+                {
+                    String phoneNumber = rs.getString( "phonenumber" );
+                    return ( phoneNumber==null || phoneNumber.isEmpty()) ? "0" : phoneNumber;
+                }
+            } );
+        }
+        catch ( Exception ex )
+        {
+            ex.printStackTrace();
+        }
+        return phoneNumbers;
+    }
+    
+    @Override
+    public Collection<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max )
+    {
+        String sql = searchPatientSql( false, searchKeys, orgunit, min, max );
+
+        Collection<Integer> programStageInstanceIds = new HashSet<Integer>();
+        
+        try
+        {
+            programStageInstanceIds = jdbcTemplate.query( sql, new RowMapper<Integer>()
+            {
+                public Integer mapRow( ResultSet rs, int rowNum )
+                    throws SQLException
+                {
+                    return rs.getInt( "programstageinstanceid" );
+                }
+            } );
+        }
+        catch ( Exception ex )
+        {
+            ex.printStackTrace();
+        }
+        
+        return programStageInstanceIds;
+    }
+
 
     public int countSearch( List<String> searchKeys, OrganisationUnit orgunit )
     {
@@ -348,7 +401,7 @@
             }
             else if ( keys[0].equals( Patient.PREFIX_PROGRAM_STAGE ) )
             {
-                sql += "(select COUNT(psi.programstageinstanceid) from programstageinstance psi ";
+                sql += "(select psi.programstageinstanceid from programstageinstance psi ";
                 sql += "left join programinstance pgi on (psi.programinstanceid=pgi.programinstanceid) ";
                 sql += "where pgi.patientid=p.patientid and psi.programstageid=" + id + " and ";
 
@@ -371,9 +424,8 @@
                     break;
                 }
 
-                sql += " ) as " + Patient.PREFIX_PROGRAM_STAGE + "_" + id + ",";
-
-                otherWhere += operator + Patient.PREFIX_PROGRAM_STAGE + "_" + id + ">0";
+                sql += " limit 1 ) as programstageinstanceid,";
+                otherWhere += operator + " programstageinstanceid is not null";
                 operator = " and ";
             }
         }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-07-03 09:39:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-08-16 13:46:23 +0000
@@ -46,6 +46,7 @@
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.hisp.dhis.patientreport.TabularReportColumn;
+import org.hisp.dhis.sms.outbound.OutboundSms;
 import org.hisp.dhis.system.grid.ListGrid;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -290,4 +291,11 @@
     {
     	programStageInstanceStore.removeEmptyEvents(programStage);
     }
+
+    @Override
+    public void updateProgramStageInstances( Collection<Integer> programStageInstanceIds,
+        OutboundSms outboundSms )
+    {
+        programStageInstanceStore.update( programStageInstanceIds, outboundSms );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-07-18 02:55:05 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-08-16 13:46:23 +0000
@@ -47,6 +47,7 @@
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceStore;
+import org.hisp.dhis.sms.outbound.OutboundSms;
 import org.hisp.dhis.system.grid.GridUtils;
 import org.hisp.dhis.system.grid.ListGrid;
 import org.hisp.dhis.system.util.DateUtils;
@@ -79,7 +80,7 @@
     {
         this.statementBuilder = statementBuilder;
     }
-    
+
     // -------------------------------------------------------------------------
     // Implemented methods
     // -------------------------------------------------------------------------
@@ -195,16 +196,16 @@
         // ---------------------------------------------------------------------
         // Headers TODO hidden cols
         // ---------------------------------------------------------------------
- 
+
         Grid grid = new ListGrid();
 
         grid.addHeader( new GridHeader( "id", true, true ) );
         grid.addHeader( new GridHeader( "Report date", false, true ) );
 
-        for ( int i=level; i<=maxLevel; i++ )
+        for ( int i = level; i <= maxLevel; i++ )
         {
             String name = orgUnitLevelMap.containsKey( i ) ? orgUnitLevelMap.get( i ).getName() : "Level " + i;
-            
+
             grid.addHeader( new GridHeader( name, false, true ) );
         }
 
@@ -214,11 +215,11 @@
         }
 
         // ---------------------------------------------------------------------
-        // Get SQL and build grid 
+        // Get SQL and build grid
         // ---------------------------------------------------------------------
-        
-        String sql = getTabularReportSql( false, programStage, columns, orgUnits, level, maxLevel, startDate,
-            endDate, descOrder, min, max );
+
+        String sql = getTabularReportSql( false, programStage, columns, orgUnits, level, maxLevel, startDate, endDate,
+            descOrder, min, max );
 
         SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
 
@@ -230,18 +231,41 @@
     public int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate )
     {
-        String sql = getTabularReportSql( true, programStage, columns, organisationUnits, level, maxLevel,
-            startDate, endDate, false, null, null );
+        String sql = getTabularReportSql( true, programStage, columns, organisationUnits, level, maxLevel, startDate,
+            endDate, false, null, null );
 
         return jdbcTemplate.queryForInt( sql );
     }
-    
+
     public void removeEmptyEvents( ProgramStage programStage )
     {
-    	String sql = "delete from programstageinstance where programstageid=" +  programStage.getId() + " and programstageinstanceid not in " +
-    			"(select pdv.programstageinstanceid from patientdatavalue pdv )";
-    	
-    	jdbcTemplate.execute( sql );
+        String sql = "delete from programstageinstance where programstageid=" + programStage.getId()
+            + " and programstageinstanceid not in " + "(select pdv.programstageinstanceid from patientdatavalue pdv )";
+
+        jdbcTemplate.execute( sql );
+    }
+
+    @Override
+    public void update( Collection<Integer> programStageInstanceIds, OutboundSms outboundSms )
+    {
+        for ( Integer programStageInstanceId : programStageInstanceIds )
+        {
+            if ( programStageInstanceId != null && programStageInstanceId != 0 )
+            {
+                ProgramStageInstance programStageInstance = get( programStageInstanceId );
+                
+                List<OutboundSms> outboundSmsList = programStageInstance.getOutboundSms();
+                
+                if( outboundSmsList == null)
+                {
+                    outboundSmsList = new ArrayList<OutboundSms>();
+                }
+                
+                outboundSmsList.add( outboundSms );
+                programStageInstance.setOutboundSms( outboundSmsList );
+                update( programStageInstance );
+            }
+        }
     }
 
     // -------------------------------------------------------------------------
@@ -258,9 +282,10 @@
         String where = "";
         String operator = "where ";
 
-        for ( int i=level; i<=maxLevel; i++ )
+        for ( int i = level; i <= maxLevel; i++ )
         {
-            sql += "(select name from organisationunit where organisationunitid=ous.idlevel" + i + ") as level_" + i + ",";
+            sql += "(select name from organisationunit where organisationunitid=ous.idlevel" + i + ") as level_" + i
+                + ",";
         }
 
         for ( TabularReportColumn column : columns )
@@ -290,7 +315,7 @@
             {
                 sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid="
                     + column.getIdentifier() + ") as attribute_" + column.getIdentifier() + ",";
-                
+
                 if ( column.hasQuery() )
                 {
                     where += operator + "lower(attribute_" + column.getIdentifier() + ") " + column.getQuery() + " ";
@@ -328,7 +353,7 @@
             sql += "and psi.executiondate >= '" + sDate + "' ";
             sql += "and psi.executiondate <= '" + eDate + "' ";
         }
-        
+
         if ( orgUnits != null )
         {
             sql += "and ou.organisationunitid in (" + TextUtils.getCommaDelimitedString( orgUnits ) + ") ";
@@ -336,7 +361,7 @@
 
         sql += "order by ";
 
-        for ( int i=level; i<=maxLevel; i++ )
+        for ( int i = level; i <= maxLevel; i++ )
         {
             sql += "level_" + i + ",";
         }

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/GetGatewayAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/GetGatewayAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/GetGatewayAction.java	2012-08-16 13:46:23 +0000
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.reminder;
+
+import java.util.Map;
+
+import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version GetGatewayAction.java 10:57:08 AM Aug 9, 2012 $
+ */
+public class GetGatewayAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    @Autowired
+    private OutboundSmsTransportService transportService;
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    public Map<String, String> gatewayMap;
+
+    public Map<String, String> getGatewayMap()
+    {
+        return gatewayMap;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        gatewayMap = transportService.getGatewayMap();
+
+        return SUCCESS;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsToListAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsToListAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsToListAction.java	2012-08-16 13:46:23 +0000
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.reminder;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.patient.PatientService;
+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 com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version SendSmsToListAction.java 13:29:34 AM Aug 16, 2012 $
+ */
+public class SendSmsToListAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitSelectionManager selectionManager;
+
+    private PatientService patientService;
+
+    private OutboundSmsService outboundSmsService;
+
+    private ProgramStageInstanceService programStageInstanceService;
+
+    private I18n i18n;
+
+    // -------------------------------------------------------------------------
+    // Input/output
+    // -------------------------------------------------------------------------
+
+    private List<String> searchTexts = new ArrayList<String>();
+
+    private Boolean searchBySelectedOrgunit;
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
+    public void setOutboundSmsService( OutboundSmsService outboundSmsService )
+    {
+        this.outboundSmsService = outboundSmsService;
+    }
+
+    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+    {
+        this.programStageInstanceService = programStageInstanceService;
+    }
+
+    public void setI18n( I18n i18n )
+    {
+        this.i18n = i18n;
+    }
+
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+    {
+        this.selectionManager = selectionManager;
+    }
+
+    public void setSearchBySelectedOrgunit( Boolean searchBySelectedOrgunit )
+    {
+        this.searchBySelectedOrgunit = searchBySelectedOrgunit;
+    }
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
+    public void setSearchTexts( List<String> searchTexts )
+    {
+        this.searchTexts = searchTexts;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+    
+    private String gatewayId;
+
+    public void setGatewayId( String gatewayId )
+    {
+        this.gatewayId = gatewayId;
+    }
+
+    private String msg;
+
+    public void setMsg( String msg )
+    {
+        this.msg = msg;
+    }
+
+    private String message = "";
+
+    public String getMessage()
+    {
+        return message;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action Implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        OrganisationUnit organisationUnit = (searchBySelectedOrgunit) ? selectionManager.getSelectedOrganisationUnit()
+            : null;
+
+        Collection<Integer> programStageInstanceIds = patientService.getProgramStageInstances( searchTexts,
+            organisationUnit, null, null );
+
+        Set<String> phoneNumberList = new HashSet<String>( patientService.getPatientPhoneNumbers( searchTexts,
+            organisationUnit, null, null ) );
+        try
+        {
+            OutboundSms outboundSms = new OutboundSms();
+            outboundSms.setMessage( msg );
+            outboundSms.setRecipients( phoneNumberList );
+
+            outboundSmsService.sendMessage( outboundSms, gatewayId );
+
+            programStageInstanceService.updateProgramStageInstances( programStageInstanceIds, outboundSms );
+
+            message = i18n.getString( "sent_message_success" );
+        }
+        catch ( SmsServiceException e )
+        {
+            message = e.getMessage();
+        }
+
+        return SUCCESS;
+    }
+    
+//    private String convertPhoneNumberList( Collection<String> phoneNumberList )
+//    {
+//        String result = "";
+//        
+//        for( String phoneNumber : phoneNumberList )
+//        {
+//            result = phoneNumber + ";";
+//        }
+//        
+//        return result;
+//    }
+
+}

=== 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	2012-08-16 02:08:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-08-16 13:46:23 +0000
@@ -975,6 +975,11 @@
 	
 	<!-- SMS Reminder -->
 	
+	<bean id="org.hisp.dhis.caseentry.action.reminder.GetGatewayAction"
+		class="org.hisp.dhis.caseentry.action.reminder.GetGatewayAction"
+		scope="prototype">
+	</bean>
+	
 	<bean id="org.hisp.dhis.caseentry.action.reminder.GetOutboundSmsListAction"
 		class="org.hisp.dhis.caseentry.action.reminder.GetOutboundSmsListAction"
 		scope="prototype">
@@ -991,6 +996,19 @@
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
 	
+	<bean id="org.hisp.dhis.caseentry.action.reminder.SendSmsToListAction"
+		class="org.hisp.dhis.caseentry.action.reminder.SendSmsToListAction"
+		scope="prototype">
+		<property name="selectionManager"
+			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+		<property name="patientService"
+			ref="org.hisp.dhis.patient.PatientService" />
+		<property name="outboundSmsService"
+			ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
+		<property name="programStageInstanceService"
+			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+	</bean>
+	
 	<!-- Dashboard -->
 	
 	<bean id="org.hisp.dhis.caseentry.action.patient.PatientDashboardAction"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-08-16 06:20:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-08-16 13:46:23 +0000
@@ -410,4 +410,7 @@
 completed = Completed
 create_event_success = Create event successfully.
 overdue = Overdue
-scheduled_in_future = Scheduled in future
\ No newline at end of file
+scheduled_in_future = Scheduled in future
+sent_message_success = Sent message successfully
+please_select_program_stage = Please select program stage
+send_sms_to_list = Send SMS to list
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-08-12 06:10:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-08-16 13:46:23 +0000
@@ -814,12 +814,25 @@
 			<param name="stylesheets">style/style.css</param>
 		</action>
 		
+		<action name="getGateway"
+			class="org.hisp.dhis.caseentry.action.reminder.GetGatewayAction">
+			<result name="success" type="velocity">/content.vm</result>
+			<param name="page">/dhis-web-caseentry/sendSmsForm.vm</param>
+			<param name="stylesheets">style/style.css</param>
+		</action>
+		
 	    <action name="sendSMS" class="org.hisp.dhis.caseentry.action.reminder.SendSmsAction">
 	      <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 	      <result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
 	      <param name="onExceptionReturn">plainTextError</param>
 	    </action>
 	    
+	    <action name="sendSMSTotList" class="org.hisp.dhis.caseentry.action.reminder.SendSmsToListAction">
+	      <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+	      <result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
+	      <param name="onExceptionReturn">plainTextError</param>
+	    </action>
+	    
 	    <!-- Dashboard -->
 	    
 	    <action name="patientDashboard" class="org.hisp.dhis.caseentry.action.patient.PatientDashboardAction">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-08-16 06:20:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-08-16 13:46:23 +0000
@@ -190,51 +190,66 @@
 	var flag = true;
 	var params = '';
 	var dateOperator = '';
-	jQuery("#searchDiv :input").each( function( i, item )
-    {
-		var elementName = $(this).attr('name');
-		if( elementName=='searchText' && jQuery( item ).val() == '' )
+	if (getFieldValue('searchByProgramStage') == "false"){
+		jQuery("#searchDiv :input").each( function( i, item )
 		{
-			showWarningMessage( i18n_specify_search_criteria );
-			flag = false;
-		}
-	});
-	
+			var elementName = $(this).attr('name');
+			if( elementName=='searchText' && jQuery( item ).val() == '' )
+			{
+				showWarningMessage( i18n_specify_search_criteria );
+				flag = false;
+			}
+		});
+	}
 	if(flag){
-		jQuery( '#advancedSearchTB tbody tr' ).each( function( i, row ){
-			var dateOperator = "";
-			jQuery( this ).find(':input').each( function( idx, item ){
-				if( idx == 0){
-					params += "&searchTexts=" + item.value;
-				}
-				else if( item.name == 'dateOperator'){
-					dateOperator = item.value;
-				}
-				else if( item.name == 'searchText'){
-					params += "_";
+		contentDiv = 'listPatientDiv';
+		jQuery( "#loaderDiv" ).show();
+		advancedSearch( getSearchParams() );
+	}
+}
+
+function getSearchParams()
+{
+	var params = "";
+	if( getFieldValue('searchByProgramStage') == "true"){
+		var programStageId = jQuery('#programStageAddPatientTR [id=programStageAddPatient_' + getFieldValue('programIdAddPatient') + ']').val();
+		var statusEvent = jQuery('#programStageAddPatientTR [id=statusEvent]:checked').val();
+		params += '&searchTexts=prgst_' + programStageId + '_' + statusEvent;
+	}
+	
+	jQuery( '#advancedSearchTB tbody tr' ).each( function( i, row ){
+		var dateOperator = "";
+		var p = "";
+		jQuery( this ).find(':input').each( function( idx, item ){
+			if( idx == 0){
+				p = "&searchTexts=" + item.value;
+			}
+			else if( item.name == 'dateOperator'){
+				dateOperator = item.value;
+			}
+			else if( item.name == 'searchText'){
+				if( item.value!='')
+				{
+					p += "_";
 					if ( dateOperator.length >0 ) {
-						params += dateOperator + "'" +  item.value.toLowerCase() + "'";
+						p += dateOperator + "'" +  item.value.toLowerCase() + "'";
 					}
 					else{
-						params += htmlEncode( item.value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, "") );
+						p += htmlEncode( item.value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, "") );
 					}
 				}
-			})
-		});
-		
-		if( getFieldValue('searchByProgramStage') == "true"){
-			var programStageId = jQuery('#programStageAddPatientTR [id=programStageAddPatient_' + getFieldValue('programIdAddPatient') + ']').val();
-			var statusEvent = jQuery('#programStageAddPatientTR [id=statusEvent]:checked').val();
-			params += '&searchTexts=prgst_' + programStageId + '_' + statusEvent;
-		}
-		
-		params += '&listAll=false';
-		params += '&searchBySelectedOrgunit=' + byId('searchBySelectedOrgunit').checked;
-		
-		contentDiv = 'listPatientDiv';
-		jQuery( "#loaderDiv" ).show();
-		advancedSearch( params );
-	}
+				else {
+					p = "";
+				}
+			}
+		})
+		params += p;
+	});
+		
+	params += '&listAll=false';
+	params += '&searchBySelectedOrgunit=' + byId('searchBySelectedOrgunit').checked;
+	
+	return params;
 }
 
 // ----------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2012-08-16 06:20:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2012-08-16 13:46:23 +0000
@@ -58,6 +58,7 @@
 
 function getOutboundSmsList( programStageInstanceId, isSendSMS ) 
 {
+	setFieldValue('sendToList', "false");
 	$('#smsManagementDiv' ).load("getOutboundSmsList.action",
 		{
 			programStageInstanceId: programStageInstanceId
@@ -81,26 +82,78 @@
 		});
 }
 
+function showSendSmsForm()
+{
+	setFieldValue('sendToList', "true");
+	$('#sendSmsFormDiv' ).load("getGateway.action").dialog(
+		{
+			title:i18n_send_sms,
+			maximize:true, 
+			closable:true,
+			modal:false,
+			overlay:{background:'#000000', opacity:0.1},
+			width:400,
+			height:250
+		});
+}
 function sendSMS()
 {
+	var sendToList = getFieldValue('sendToList');
+	
+	if( sendToList == 'false'){	
+		sendSmsOnePatient()
+	}
+	else{
+		sendSmsToList();
+	}
+	
+}
+
+function sendSmsOnePatient()
+{
 	programStageInstanceId = getFieldValue( 'programStageInstanceId' );
 	jQuery.postUTF8( 'sendSMS.action',
-	{
-		programStageInstanceId: programStageInstanceId,
-		gatewayId: getFieldValue( 'gatewayId' ),
-		msg: getFieldValue( 'smsMessage' )
-	}, function ( json )
-	{
-		if ( json.response == "success" ) {
-			showSuccessMessage( json.message );
-			jQuery('#smsManagementList').prepend("<tr><td>" + getFieldValue('currentDate') + "</td><td>" + getFieldValue('smsMessage') + "</td></tr>");
-			var noMessage = eval( getInnerHTML('noMessageDiv_' + programStageInstanceId)) + 1;
-			jQuery('#noMessageDiv_' + programStageInstanceId).html(noMessage);
-		}
-		else {
-			showErrorMessage( json.message, 7000 );
-		}
-	} ); 
+		{
+			programStageInstanceId: programStageInstanceId,
+			gatewayId: getFieldValue( 'gatewayId' ),
+			msg: getFieldValue( 'smsMessage' )
+		}, function ( json )
+		{
+			if ( json.response == "success" ) {
+				showSuccessMessage( json.message );
+				jQuery('#smsManagementList').prepend("<tr><td>" + getFieldValue('currentDate') + "</td><td>" + getFieldValue('smsMessage') + "</td></tr>");
+				var noMessage = eval( getInnerHTML('noMessageDiv_' + programStageInstanceId)) + 1;
+				jQuery('#noMessageDiv_' + programStageInstanceId).html(noMessage);
+			}
+			else {
+				showErrorMessage( json.message, 7000 );
+			}
+		} ); 
+}
+
+function sendSmsToList()
+{
+	params = getSearchParams();
+	params += "&gatewayId=" + getFieldValue( 'gatewayId' );
+	params += "&msg=" + getFieldValue( 'smsMessage' );
+	$.ajax({
+		url: 'sendSMSTotList.action',
+		type:"POST",
+		data: params,
+		success: function( json ){
+			if ( json.response == "success" ) {
+				showSuccessMessage( json.message );
+				jQuery("#patientList [programStageId=" + programStageId + "][status=" + status + "]" ).each( function(){
+					var programStageInstanceId = jQuery(this).attr('programStageInstanceId');
+					var noMessage = eval( getInnerHTML('noMessageDiv_' + programStageInstanceId)) + 1;
+					jQuery('#noMessageDiv_' + programStageInstanceId).html(noMessage);
+				});
+			}
+			else {
+				showErrorMessage( json.message );
+			}
+		}
+	});
 }
 
 function loadProgramStageRecords( programStageInstanceId ) 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2012-08-16 06:20:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2012-08-16 13:46:23 +0000
@@ -44,11 +44,15 @@
 				#end
 			</td>
 			<td>
-				<input type="radio" disabled id="statusEvent" name="statusEvent" value='1'> $i18n.getString("completed") 
+				<input type="radio" disabled id="statusEvent" name="statusEvent" value='1' checked> $i18n.getString("completed") 
 				<input type="radio" disabled id="statusEvent" name="statusEvent" value='2'> $i18n.getString("incomplete") 
 				<input type="radio" disabled id="statusEvent" name="statusEvent" value='3'> $i18n.getString("scheduled_in_future") 
 				<input type="radio" disabled id="statusEvent" name="statusEvent" value='4'> $i18n.getString("overdue") 
 			</td>
+			<td colspan=2=></td>
+			<td>
+				<input type="button" id='programStageActionBtn' value="$i18n.getString('send_sms_for_result_list')" onclick="showSendSmsForm();">
+			</td>
 		</tr>
 		</thead>
 		<tbody>

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sendSmsForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sendSmsForm.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sendSmsForm.vm	2012-08-16 13:46:23 +0000
@@ -0,0 +1,47 @@
+<script type="text/javascript">
+	jQuery(document).ready(	function(){
+		$('#tabs').tabs();
+		validation( 'sendSMSForm', function(form){
+			sendSMS();
+		});
+	});
+</script>
+
+#if ( $!gatewayMap && $!gatewayMap.size() > 0 )
+	<form id="sendSMSForm" name="sendSMSForm" action="sendSMS.action">
+		<table>
+			<tbody>
+				<tr>
+					<td>$i18n.getString( "gateway_type" )</td>
+					<td>
+						#set( $keys = $!gatewayMap.keySet() )
+						<select id="gatewayId" name="gatewayId">
+							#foreach( $key in $!keys )
+							<option value="$gatewayMap.get( $key )">$i18n.getString( $key )</option>
+							#end
+						</select>
+					</td>
+				</tr>
+				
+				<tr>
+					<td>$i18n.getString( "message" )</td>
+					<td><textarea id="smsMessage" name="smsMessage" style="width:260px;height:100px;" class="{validate:{required:true}}"></textarea></td>
+				</tr>
+			
+				<tr>
+					<td></td>
+					<td><input type="submit" name="send" value="$i18n.getString( 'send_sms' )"/></td>
+				</tr>
+				
+			</tbody>
+		</table>
+	</form>
+	<div class='hidden'>
+		<input type='hidden' id='currentDate'>
+		<script>
+			datePickerValid( 'currentDate', true );
+		</script>
+	</div>
+#else
+	<p>No Sms service available</p>
+#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsPatientRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsPatientRecords.vm	2012-08-13 06:36:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsPatientRecords.vm	2012-08-16 13:46:23 +0000
@@ -50,7 +50,7 @@
 											<td>
 												<table class='stage-object'>
 													<tr>
-														<td><input type='button' id='ps_$programStageInstance.id' name='programStageBtn' class='stage-object' value='$programStageInstance.programStage.name $format.formatDate( $programStageInstance.dueDate )' onclick='javascript:getOutboundSmsList( $programStageInstance.id, false );'></td>
+														<td><input type='button' id='ps_$programStageInstance.id' name='programStageBtn' programStageInstanceId='$programStageInstance.id' programStageId='$programStageInstance.programStage.id' status="$statusMap.get( $programStageInstance.id )" class='stage-object' value='$programStageInstance.programStage.name $format.formatDate( $programStageInstance.dueDate )' onclick='javascript:getOutboundSmsList( $programStageInstance.id, false );'></td>
 														<script>	
 															var status = $statusMap.get( $programStageInstance.id ); 
 															setEventColorStatus( 'ps_' + $programStageInstance.id ,status);
@@ -91,3 +91,13 @@
 	
 	<div id="detailsInfo"></div>
 #end
+
+<script>
+	#if($!listAll)
+	#else
+		var programId = jQuery("#programIdAddPatient").val();
+		var programStageId = jQuery("#programStageAddPatientTR [id=programStageAddPatient_" + programId + "]").val();
+		var status = jQuery('#programStageAddPatientTR [id=statusEvent]:checked').val();
+		jQuery("#patientList [programStageId=" + programStageId + "][status=" + status + "]" ).addClass("stage-object-selected");
+	#end
+</script>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderList.vm	2012-08-09 14:21:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderList.vm	2012-08-16 13:46:23 +0000
@@ -30,44 +30,7 @@
 		<li><a href="#tab-2">$i18n.getString("sms_reminder_list")</a></li>
 	</ul>
 	<div id="tab-1">
-		#if ( $!gatewayMap && $!gatewayMap.size() > 0 )
-		<form id="sendSMSForm" name="sendSMSForm" action="sendSMS.action">
-			<table>
-				<tbody>
-					<tr>
-						<td>$i18n.getString( "gateway_type" )</td>
-						<td>
-							#set( $keys = $!gatewayMap.keySet() )
-							<select id="gatewayId" name="gatewayId">
-								#foreach( $key in $!keys )
-								<option value="$gatewayMap.get( $key )">$i18n.getString( $key )</option>
-								#end
-							</select>
-						</td>
-					</tr>
-					
-					<tr>
-						<td>$i18n.getString( "message" )</td>
-						<td><textarea id="smsMessage" name="smsMessage" style="width:260px;height:100px;" class="{validate:{required:true}}"></textarea></td>
-					</tr>
-				
-					<tr>
-						<td></td>
-						<td><input type="submit" name="send" value="$i18n.getString( 'send_sms' )"/></td>
-					</tr>
-					
-				</tbody>
-			</table>
-		</form>
-		<div class='hidden'>
-			<input type='hidden' id='currentDate'>
-			<script>
-				datePickerValid( 'currentDate', true );
-			</script>
-		</div>
-	#else
-	<p>No Sms service available</p>
-	#end
+		#parse( "/dhis-web-caseentry/sendSmsForm.vm" )
 	</div>
 	
 	<div id="tab-2">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm	2012-08-16 06:20:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm	2012-08-16 13:46:23 +0000
@@ -8,7 +8,7 @@
 				item.remove();
 			}
 		});
-		
+
 		jQuery("#searchObjectId [value=prg]").remove();
 		hideById('addPatientBtn');
 		disable('advancedSearchBtn');
@@ -21,6 +21,7 @@
 <form>
 	<input type='hidden' id='isRegistration' name= 'isRegistration' value='false'>
 	<input type='hidden' id='listAll' name='listAll'>
+	<input type='hidden' id='sendToList' name='sendToList'>
 	<input type='hidden' id='programStageInstanceId' name='programStageInstanceId' value='$programStageInstance.id'>
 	<div id='searchDiv'>
 		#parse( "dhis-web-caseentry/searchPatientCriteria.vm" )	
@@ -31,6 +32,7 @@
 
 <div id='listPatientDiv'></div>
 <div id='smsManagementDiv'></div>
+<div id='sendSmsFormDiv'></div>
 
 <script>
 	unSave = false;
@@ -39,5 +41,7 @@
 	var i18n_please_select = '[' + '$encoder.jsEscape( $i18n.getString( "please_select" ) , "'")' + ']';
 	var i18n_specify_search_criteria = '$encoder.jsEscape( $i18n.getString( "specify_search_criteria" ) , "'")';
 	var i18n_color_quick_help = '$encoder.jsEscape( $i18n.getString( "color_quick_help" ) , "'")';
+	var i18n_patient_details_and_history = '$encoder.jsEscape( $i18n.getString( "patient_details_and_history" ) , "'")';
+	
 	var searchTextBox = '<input type="text" id="searchText" name="searchText">';
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2012-08-14 09:50:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2012-08-16 13:46:23 +0000
@@ -132,4 +132,4 @@
 south_africa=South Africa
 spain=Spain
 usa=USA
-germany=Germany
+germany=Germany
\ No newline at end of file