dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17373
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6885: (mobile) - Sending SMS to Beneficiary (wip)
------------------------------------------------------------
revno: 6885
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-05-09 09:52:11 +0700
message:
(mobile) - Sending SMS to Beneficiary (wip)
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SearchPatientAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSendSMSBeneficiaryFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/state/
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/state/DefaultSelectedStateManager.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/state/SelectedStateManager.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/css/caseentry-patient.css
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/caseentry-commons.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/caseentry-patient.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menuWithTree.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/patientRegistrationList.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendBeneficiarySMSPage.vm
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ProcessingSendSMSAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml
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_vi_VN.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/sendSMS.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.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-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ProcessingSendSMSAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ProcessingSendSMSAction.java 2012-04-03 03:17:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ProcessingSendSMSAction.java 2012-05-09 02:52:11 +0000
@@ -34,6 +34,8 @@
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.sms.MessageSender;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
@@ -59,6 +61,9 @@
private CurrentUserService currentUserService;
@Autowired
+ private PatientService patientService;
+
+ @Autowired
private MessageSender messageSender;
// -------------------------------------------------------------------------
@@ -86,6 +91,13 @@
this.smsMessage = smsMessage;
}
+ private String sendTarget;
+
+ public void setSendTarget( String sendTarget )
+ {
+ this.sendTarget = sendTarget;
+ }
+
private Set<String> recipients = new HashSet<String>();
public void setRecipients( Set<String> recipients )
@@ -124,67 +136,72 @@
return ERROR;
}
- if ( smsMessage != null && !smsMessage.isEmpty() )
- {
- if ( recipients != null && !recipients.isEmpty() )
- {
- message = messageSender.sendMessage( smsSubject, smsMessage, currentUserService.getCurrentUser(), true,
- recipients, gatewayId );
-
- if ( message != null && !message.equals( "success" ) )
- {
- message = i18n.getString( message );
-
- return ERROR;
- }
- }
- else
- {
- Collection<OrganisationUnit> units = selectionTreeManager.getReloadedSelectedOrganisationUnits();
-
- if ( units != null && !units.isEmpty() )
- {
- recipients.clear();
- Set<User> users = new HashSet<User>();
-
- for ( OrganisationUnit unit : units )
- {
- if ( unit.getUsers() == null || unit.getUsers().isEmpty() )
- {
- if ( unit.getPhoneNumber() != null && !unit.getPhoneNumber().isEmpty() )
- {
- recipients.add( unit.getPhoneNumber() );
- }
- }
- else
- {
- users.addAll( unit.getUsers() );
- }
- }
-
- message = messageSender.sendMessage( smsSubject, smsMessage, currentUserService.getCurrentUser(),
- true, recipients, gatewayId );
-
- if ( message != null && (message.equals( "no_recipient" ) || message.equals( "success" )) )
- {
- message = messageSender.sendMessage( smsSubject, smsMessage, currentUserService
- .getCurrentUser(), false, users, gatewayId );
-
- if ( message != null && !message.equals( "success" ) )
- {
- message = i18n.getString( message );
-
- return ERROR;
- }
- }
- else
- {
- message = i18n.getString( message );
-
- return ERROR;
- }
- }
- }
+ if ( smsMessage == null || smsMessage.trim().length() == 0 )
+ {
+ message = i18n.getString( "no_message" );
+
+ return ERROR;
+ }
+
+ if ( sendTarget != null && sendTarget.equals( "phone" ) )
+ {
+ message = messageSender.sendMessage( smsSubject, smsMessage, currentUserService.getCurrentUser(), true,
+ recipients, gatewayId );
+ }
+ else if ( sendTarget.equals( "user" ) )
+ {
+ Collection<OrganisationUnit> units = selectionTreeManager.getReloadedSelectedOrganisationUnits();
+
+ if ( units != null && !units.isEmpty() )
+ {
+ Set<User> users = new HashSet<User>();
+
+ for ( OrganisationUnit unit : units )
+ {
+ users.addAll( unit.getUsers() );
+ }
+
+ message = messageSender.sendMessage( smsSubject, smsMessage, currentUserService.getCurrentUser(),
+ false, users, gatewayId );
+ }
+ }
+ else if ( sendTarget.equals( "unit" ) )
+ {
+ for ( OrganisationUnit unit : selectionTreeManager.getSelectedOrganisationUnits() )
+ {
+ if ( unit.getPhoneNumber() != null && !unit.getPhoneNumber().isEmpty() )
+ {
+ recipients.add( unit.getPhoneNumber() );
+ }
+ }
+
+ message = messageSender.sendMessage( smsSubject, smsMessage, currentUserService.getCurrentUser(), true,
+ recipients, gatewayId );
+ }
+ else
+ {
+ Patient patient = null;
+ Set<String> phones = new HashSet<String>();
+
+ for ( String patientId : recipients )
+ {
+ patient = patientService.getPatient( Integer.parseInt( patientId ) );
+
+ if ( patient != null && patient.getPhoneNumber() != null && !patient.getPhoneNumber().isEmpty() )
+ {
+ phones.add( patient.getPhoneNumber() );
+ }
+ }
+
+ message = messageSender.sendMessage( smsSubject, smsMessage, currentUserService.getCurrentUser(), true,
+ phones, gatewayId );
+ }
+
+ if ( message != null && !message.equals( "success" ) )
+ {
+ message = i18n.getString( message );
+
+ return ERROR;
}
return SUCCESS;
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SearchPatientAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SearchPatientAction.java 2012-05-09 02:52:11 +0000
@@ -0,0 +1,231 @@
+/*
+ * 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.mobile.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.mobile.caseentry.state.SelectedStateManager;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Abyot Asalefew Gizaw
+ * @version $Id$
+ */
+public class SearchPatientAction
+ extends ActionPagingSupport<Patient>
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private SelectedStateManager selectedStateManager;
+
+ @Autowired
+ private PatientService patientService;
+
+ @Autowired
+ private PatientAttributeValueService patientAttributeValueService;
+
+ @Autowired
+ private PatientAttributeService patientAttributeService;
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private List<String> searchText = new ArrayList<String>();
+
+ private Boolean listAll;
+
+ private List<Integer> searchingAttributeId = new ArrayList<Integer>();
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Integer total;
+
+ private Collection<Patient> patients = new ArrayList<Patient>();
+
+ private Map<String, String> mapPatientPatientAttr = new HashMap<String, String>();
+
+ private Map<Integer, String> mapPatientOrgunit = new HashMap<Integer, String>();
+
+ private List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
+
+ // -------------------------------------------------------------------------
+ // Getters/Setters
+ // -------------------------------------------------------------------------
+
+ public List<PatientAttribute> getPatientAttributes()
+ {
+ return patientAttributes;
+ }
+
+ public Map<Integer, String> getMapPatientOrgunit()
+ {
+ return mapPatientOrgunit;
+ }
+
+ public void setSearchText( List<String> searchText )
+ {
+ this.searchText = searchText;
+ }
+
+ public void setListAll( Boolean listAll )
+ {
+ this.listAll = listAll;
+ }
+
+ public Boolean getListAll()
+ {
+ return listAll;
+ }
+
+ public void setSearchingAttributeId( List<Integer> searchingAttributeId )
+ {
+ this.searchingAttributeId = searchingAttributeId;
+ }
+
+ public Collection<Patient> getPatients()
+ {
+ return patients;
+ }
+
+ public Integer getTotal()
+ {
+ return total;
+ }
+
+ public Map<String, String> getMapPatientPatientAttr()
+ {
+ return mapPatientPatientAttr;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+
+ // ---------------------------------------------------------------------
+ // Get all of patients into the selected organisation unit
+ // ---------------------------------------------------------------------
+
+ if ( listAll != null && listAll )
+ {
+ listAllPatient( organisationUnit );
+
+ return SUCCESS;
+ }
+
+ // ---------------------------------------------------------------------
+ // Search patients by attributes
+ // ---------------------------------------------------------------------
+
+ for ( Integer attributeId : searchingAttributeId )
+ {
+ if ( attributeId != null && attributeId > 0 )
+ {
+ patientAttributes.add( patientAttributeService.getPatientAttribute( attributeId ) );
+ }
+ }
+
+ searchPatientByAttributes( searchingAttributeId, searchText );
+
+ return SUCCESS;
+
+ }
+
+ // -------------------------------------------------------------------------
+ // Supporting methods
+ // -------------------------------------------------------------------------
+
+ private void listAllPatient( OrganisationUnit organisationUnit )
+ {
+ total = patientService.countGetPatientsByOrgUnit( organisationUnit );
+ this.paging = createPaging( total );
+
+ patients = new ArrayList<Patient>( patientService.getPatients( organisationUnit, paging.getStartPos(), paging
+ .getPageSize() ) );
+ }
+
+ private void searchPatientByAttributes( List<Integer> searchingAttributeId, List<String> searchText )
+ {
+ total = patientAttributeValueService.countSearchPatients( searchingAttributeId, searchText );
+
+ this.paging = createPaging( total );
+
+ patients = patientAttributeValueService.searchPatients( searchingAttributeId, searchText, paging.getStartPos(),
+ paging.getPageSize() );
+
+ Collection<PatientAttributeValue> attributeValues = patientAttributeValueService
+ .getPatientAttributeValues( patients );
+
+ for ( Patient patient : patients )
+ {
+ mapPatientOrgunit.put( patient.getId(), getHierarchyOrgunit( patient.getOrganisationUnit() ) );
+
+ for ( PatientAttributeValue attributeValue : attributeValues )
+ {
+ mapPatientPatientAttr.put( patient.getId() + "-" + attributeValue.getPatientAttribute().getId(),
+ attributeValue.getValue() );
+ }
+ }
+ }
+
+ private String getHierarchyOrgunit( OrganisationUnit orgunit )
+ {
+ String hierarchyOrgunit = orgunit.getName();
+
+ while ( orgunit.getParent() != null )
+ {
+ hierarchyOrgunit = orgunit.getParent().getName() + " / " + hierarchyOrgunit;
+
+ orgunit = orgunit.getParent();
+ }
+
+ return hierarchyOrgunit;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSendSMSBeneficiaryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSendSMSBeneficiaryFormAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSendSMSBeneficiaryFormAction.java 2012-05-09 02:52:11 +0000
@@ -0,0 +1,128 @@
+/*
+ * 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.mobile.action;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Abyot Asalefew Gizaw
+ * @version $Id$
+ */
+public class ShowSendSMSBeneficiaryFormAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private OutboundSmsTransportService transportService;
+
+ @Autowired
+ private OrganisationUnitSelectionManager selectionManager;
+
+ @Autowired
+ private PatientAttributeService patientAttributeService;
+
+ @Autowired
+ private ProgramService programService;
+
+ // -------------------------------------------------------------------------
+ // Input/output
+ // -------------------------------------------------------------------------
+
+ private Collection<PatientAttribute> patientAttributes;
+
+ public Collection<PatientAttribute> getPatientAttributes()
+ {
+ return patientAttributes;
+ }
+
+ private Collection<Program> programs;
+
+ public Collection<Program> getPrograms()
+ {
+ return programs;
+ }
+
+ private OrganisationUnit organisationUnit;
+
+ public OrganisationUnit getOrganisationUnit()
+ {
+ return organisationUnit;
+ }
+
+ private int status;
+
+ public int getStatus()
+ {
+ return status;
+ }
+
+ public Map<String, String> getGatewayMap()
+ {
+ return transportService.getGatewayMap();
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ patientAttributes = patientAttributeService.getAllPatientAttributes();
+
+ programs = programService.getAllPrograms();
+
+ organisationUnit = selectionManager.getSelectedOrganisationUnit();
+
+ if ( organisationUnit == null )
+ {
+ status = 1;
+ }
+ else if ( !organisationUnit.isHasPatients() )
+ {
+ status = 2;
+ }
+
+ return SUCCESS;
+ }
+}
=== added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry'
=== added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/state'
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/state/DefaultSelectedStateManager.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/state/DefaultSelectedStateManager.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/state/DefaultSelectedStateManager.java 2012-05-09 02:52:11 +0000
@@ -0,0 +1,255 @@
+package org.hisp.dhis.mobile.caseentry.state;
+
+/*
+ * Copyright (c) 2004-2012, 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.
+ */
+
+import java.util.Map;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+
+import com.opensymphony.xwork2.ActionContext;
+
+/**
+ * @author Abyot Asalefew
+ * @version $Id$
+ */
+public class DefaultSelectedStateManager
+ implements SelectedStateManager
+{
+ public static final String SESSION_KEY_SELECTED_PATIENT_ID = "selected_patient_id";
+
+ public static final String SESSION_KEY_SELECTED_PROGRAM_INSTANCE_ID = "selected_program_instance_id";
+
+ public static final String SESSION_KEY_SELECTED_PROGRAM_STAGE_INSTANCE_ID = "selected_program_stage_instance_id";
+
+ public static final String SESSION_KEY_SELECTED_PROGRAM_ID = "selected_program_id";
+
+ public static final String SESSION_KEY_SELECTED_PROGRAMSTAGE_ID = "selected_program_stage_id";
+
+ public static final String SESSION_KEY_LISTALL = "list_all_value";
+
+ public static final String SESSION_KEY_SELECTED_SEARCHING_ATTRIBUTE_ID = "selected_searching_attribute_id";
+
+ public static final String SESSION_KEY_SPECIFIED_SEARCH_TEXT = "specified_search_text";
+
+ public static final String SESSION_KEY_SELECTED_SORT_ATTRIBUTE_ID = "selected_sort_attribute_id";
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private OrganisationUnitSelectionManager selectionManager;
+
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+ {
+ this.selectionManager = selectionManager;
+ }
+
+ private PatientService patientService;
+
+ public void setPatientService( PatientService patientService )
+ {
+ this.patientService = patientService;
+ }
+
+ private ProgramInstanceService programInstanceService;
+
+ public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+ {
+ this.programInstanceService = programInstanceService;
+ }
+
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation methods
+ // -------------------------------------------------------------------------
+
+ public OrganisationUnit getSelectedOrganisationUnit()
+ {
+ return selectionManager.getSelectedOrganisationUnit();
+ }
+
+ public void setSelectedPatient( Patient patient )
+ {
+ getSession().put( SESSION_KEY_SELECTED_PATIENT_ID, patient.getId() );
+ }
+
+ public Patient getSelectedPatient()
+ {
+ Integer id = (Integer) getSession().get( SESSION_KEY_SELECTED_PATIENT_ID );
+
+ if ( id == null )
+ {
+ return null;
+ }
+
+ return patientService.getPatient( id );
+ }
+
+ public void clearSelectedPatient()
+ {
+ getSession().remove( SESSION_KEY_SELECTED_PATIENT_ID );
+ }
+
+ public void setSelectedProgramInstance( ProgramInstance programInstance )
+ {
+ getSession().put( SESSION_KEY_SELECTED_PROGRAM_INSTANCE_ID, programInstance.getId() );
+ }
+
+ public ProgramInstance getSelectedProgramInstance()
+ {
+ Integer id = (Integer) getSession().get( SESSION_KEY_SELECTED_PROGRAM_INSTANCE_ID );
+
+ if ( id == null )
+ {
+ return null;
+ }
+
+ return programInstanceService.getProgramInstance( id );
+ }
+
+ public void clearSelectedProgramInstance()
+ {
+ getSession().remove( SESSION_KEY_SELECTED_PROGRAM_INSTANCE_ID );
+ }
+
+ public void setSelectedProgramStageInstance( ProgramStageInstance programStageInstance )
+ {
+ getSession().put( SESSION_KEY_SELECTED_PROGRAM_STAGE_INSTANCE_ID, programStageInstance.getId() );
+ }
+
+ public ProgramStageInstance getSelectedProgramStageInstance()
+ {
+ Integer id = (Integer) getSession().get( SESSION_KEY_SELECTED_PROGRAM_STAGE_INSTANCE_ID );
+
+ if ( id == null )
+ {
+ return null;
+ }
+
+ return programStageInstanceService.getProgramStageInstance( id );
+ }
+
+ public void clearSelectedProgramStageInstance()
+ {
+ getSession().remove( SESSION_KEY_SELECTED_PROGRAM_STAGE_INSTANCE_ID );
+ }
+
+ public void clearListAll()
+ {
+ getSession().remove( SESSION_KEY_LISTALL );
+ }
+
+ public void clearSearchTest()
+ {
+ getSession().remove( SESSION_KEY_SPECIFIED_SEARCH_TEXT );
+ }
+
+ public void clearSearchingAttributeId()
+ {
+ getSession().remove( SESSION_KEY_SELECTED_SEARCHING_ATTRIBUTE_ID );
+ }
+
+ public boolean getListAll()
+ {
+ if ( getSession().get( SESSION_KEY_LISTALL ) != null )
+ {
+ return (Boolean) getSession().get( SESSION_KEY_LISTALL );
+ }
+
+ else
+ {
+ return false;
+ }
+ }
+
+ public String getSearchText()
+ {
+ return (String) getSession().get( SESSION_KEY_SPECIFIED_SEARCH_TEXT );
+ }
+
+ public Integer getSearchingAttributeId()
+ {
+ return (Integer) getSession().get( SESSION_KEY_SELECTED_SEARCHING_ATTRIBUTE_ID );
+ }
+
+ public void setListAll( boolean listAll )
+ {
+ getSession().put( SESSION_KEY_LISTALL, listAll );
+ }
+
+ public void setSearchText( String searchText )
+ {
+ getSession().put( SESSION_KEY_SPECIFIED_SEARCH_TEXT, searchText );
+ }
+
+ public void setSearchingAttributeId( int searchingAttributeId )
+ {
+ getSession().put( SESSION_KEY_SELECTED_SEARCHING_ATTRIBUTE_ID, searchingAttributeId );
+ }
+
+ // -------------------------------------------------------------------------
+ // Sort by patient-attribute
+ // -------------------------------------------------------------------------
+
+ public void setSortingAttributeId( int sortAttributeId )
+ {
+ getSession().put( SESSION_KEY_SELECTED_SORT_ATTRIBUTE_ID, sortAttributeId );
+ }
+
+ public Integer getSortAttributeId()
+ {
+ return (Integer) getSession().get( SESSION_KEY_SELECTED_SORT_ATTRIBUTE_ID );
+ }
+
+ public void clearSortingAttributeId()
+ {
+ getSession().remove( SESSION_KEY_SELECTED_SORT_ATTRIBUTE_ID );
+ }
+
+ // -------------------------------------------------------------------------
+ // Support methods
+ // -------------------------------------------------------------------------
+
+ private static final Map<String, Object> getSession()
+ {
+ return ActionContext.getContext().getSession();
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/state/SelectedStateManager.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/state/SelectedStateManager.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/caseentry/state/SelectedStateManager.java 2012-05-09 02:52:11 +0000
@@ -0,0 +1,104 @@
+package org.hisp.dhis.mobile.caseentry.state;
+
+/*
+ * Copyright (c) 2004-2012, 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.
+ */
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramStageInstance;
+
+/**
+ * @author Abyot Asalefew
+ * @version $Id$
+ */
+public interface SelectedStateManager
+{
+ OrganisationUnit getSelectedOrganisationUnit();
+
+ // -------------------------------------------------------------------------
+ // Patient
+ // -------------------------------------------------------------------------
+
+ void setSelectedPatient( Patient patient );
+
+ Patient getSelectedPatient();
+
+ void clearSelectedPatient();
+
+ // -------------------------------------------------------------------------
+ // Program-instance
+ // -------------------------------------------------------------------------
+
+ void setSelectedProgramInstance( ProgramInstance programInstance );
+
+ ProgramInstance getSelectedProgramInstance();
+
+ void clearSelectedProgramInstance();
+
+ // -------------------------------------------------------------------------
+ // Program-stage-instance
+ // -------------------------------------------------------------------------
+
+ void setSelectedProgramStageInstance( ProgramStageInstance programStageInstance );
+
+ ProgramStageInstance getSelectedProgramStageInstance();
+
+ void clearSelectedProgramStageInstance();
+
+ // -------------------------------------------------------------------------
+ // for searching patients
+ // -------------------------------------------------------------------------
+
+ void setListAll( boolean listAll );
+
+ boolean getListAll();
+
+ void clearListAll();
+
+ void setSearchingAttributeId( int searchingAttributeId );
+
+ Integer getSearchingAttributeId();
+
+ void clearSearchingAttributeId();
+
+ void setSearchText( String searchText );
+
+ String getSearchText();
+
+ void clearSearchTest();
+
+ // -------------------------------------------------------------------------
+ // for Sorting patients - Sort by patient-attribute
+ // -------------------------------------------------------------------------
+
+ void setSortingAttributeId( int sortAttributeId );
+
+ Integer getSortAttributeId();
+
+ void clearSortingAttributeId();
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-03-23 04:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-05-09 02:52:11 +0000
@@ -3,14 +3,30 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
+ <bean id="org.hisp.dhis.mobile.caseentry.state.SelectedStateManager"
+ class="org.hisp.dhis.mobile.caseentry.state.DefaultSelectedStateManager">
+ <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+ <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+ <property name="programStageInstanceService"
+ ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+ </bean>
+
<bean id="org.hisp.dhis.mobile.action.NoAction" class="org.hisp.dhis.mobile.action.NoAction"
scope="prototype" />
<bean id="org.hisp.dhis.mobile.action.ShowSendSMSFormAction" class="org.hisp.dhis.mobile.action.ShowSendSMSFormAction"
scope="prototype" />
+ <bean id="org.hisp.dhis.mobile.action.ShowSendSMSBeneficiaryFormAction" class="org.hisp.dhis.mobile.action.ShowSendSMSBeneficiaryFormAction"
+ scope="prototype" />
+
<bean id="org.hisp.dhis.mobile.action.ProcessingSendSMSAction" class="org.hisp.dhis.mobile.action.ProcessingSendSMSAction"
scope="prototype" />
+
+ <bean id="org.hisp.dhis.mobile.action.SearchPatientAction" class="org.hisp.dhis.mobile.action.SearchPatientAction"
+ scope="prototype" />
<!-- Patient Mobile Settings -->
=== 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-05-02 13:50:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties 2012-05-09 02:52:11 +0000
@@ -25,6 +25,7 @@
operation=Operation
gateway_type=Gateway Type
send_sms=Send SMS
+send_sms_beneficiary=Send SMS to Beneficiary
add_gateway=Add Gateway
gateway_type=Gateway Type
type=Type
@@ -62,9 +63,19 @@
service_stopping=SMS Service is stopping
message_not_sent=Message not sent
message=Message
+send_sms_to_target=Send SMS to
phone_number=Phone number
+raw_phone_number=Raw phone numbers
+assigned_user_number=User assigned to organisation unit
+selected_unit_number=Selected organisation unit
+patient_number=Beneficiary/Patient
+programs=Programs
+organisation_unit_level=Organisation unit level
+chidren_only=Children only
+please_select_a_program=Please select a program
+there_is_no_program=There is no program selected, won't send SMS to any Beneficiary
please_select_a_gateway_type_to_send_sms=Please specify a gateway to send the SMS
-service_stopped_cannot_send_sms=Service is stopped.SMS cannot be sent.
+service_stopped_cannot_send_sms=Service is stopped. SMS cannot be sent.
please_verify_phone=Please verify the phone number(s). Separate each number with a semicolon (;)
please_select_orgunit=Please select at least one organisation unit
no_recipient=There is no recipient. SMS cannot be sent.\nNotes: Make sure that "Message sms notification" Setting is activated.
@@ -72,4 +83,8 @@
unable_start_smslib_service=Unable to start smsLib service
unable_stop_smslib_service=Unable to stop smsLib service
sms_unable_or_there_is_no_gateway_service_not_started=SMS Service is not enabled or no gateway has been specified.\nSMS Service will not be started.
-unable_load_configuration_cause_of_there_is_no_gateway=Unable to load the configuration because there is no gateway.
\ No newline at end of file
+unable_load_configuration_cause_of_there_is_no_gateway=Unable to load the configuration because there is no gateway.
+registering_unit=Registering Unit
+search_by_name_identifier=Search by name or identifier
+search_by_program=Search by program
+please_select_village=Please select village
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module_vi_VN.properties 2012-04-25 15:07:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module_vi_VN.properties 2012-05-09 02:52:11 +0000
@@ -40,4 +40,9 @@
outbound=Ngo\u00e0i gi\u1edbi h\u1ea1n
api_id=Giao ti\u1ebfp ID
save_settings=L\u01b0u c\u00e0i \u0111\u1eb7t
-show_send_sms_form=Hi\u1ec3n th\u1ecb m\u1eabu g\u1eedi SMS
+show_send_sms_form=G\u1eedi SMS
+send_sms_to_target=G\u1eedi SMS t\u1edbi
+phone_number=S\u1ed1 \u0111i\u1ec7n tho\u1ea1i
+raw_phone_number=S\u1ed1 nh\u1eadp tay
+assigned_user_number=Ng\u01b0\u1eddi d\u00f9ng \u0111\u01b0\u1ee3c g\u00e1n v\u00e0o \u0111\u01a1n v\u1ecb ch\u1ecdn
+selected_unit_number=\u0110\u01a1n v\u1ecb \u0111\u01b0\u1ee3c ch\u1ecdn
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-03-26 04:42:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-05-09 02:52:11 +0000
@@ -32,12 +32,40 @@
<param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/sendSMS.js</param>
<param name="requiredAuthorities">F_MOBILE_SENDSMS</param>
</action>
+
+ <action name="showBeneficiarySMSForm" class="org.hisp.dhis.mobile.action.ShowSendSMSBeneficiaryFormAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-maintenance-mobile/sendBeneficiarySMSPage.vm</param>
+ <param name="menu">/dhis-web-maintenance-mobile/menuWithTree.vm</param>
+ <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js</param>
+ <param name="requiredAuthorities">F_MOBILE_SENDSMS</param>
+ </action>
+
+ <action name="loadProgramsByUnit" class="org.hisp.dhis.mobile.action.LoadProgramsByUnitAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonPrograms.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
<action name="sendSMS" class="org.hisp.dhis.mobile.action.ProcessingSendSMSAction">
<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="organisationUnitHasPatients"
+ class="org.hisp.dhis.caseentry.action.patient.VerifyOrganisationUnitHasParentAction">
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="input" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseInput.vm</result>
+ </action>
+
+ <action name="searchRegistrationPatient"
+ class="org.hisp.dhis.mobile.action.SearchPatientAction">
+ <result name="success" type="velocity">/content.vm</result>
+ <param name="page">/dhis-web-maintenance-mobile/patientRegistrationList.vm</param>
+ <param name="requiredAuthorities">F_PATIENT_MANAGEMENT</param>
+ </action>
<!-- Patient Mobile Setting Action -->
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/css/caseentry-patient.css'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/css/caseentry-patient.css 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/css/caseentry-patient.css 2012-05-09 02:52:11 +0000
@@ -0,0 +1,80 @@
+table
+{
+ margin-bottom:10px;
+ font-size: 13px;
+ line-height:18px;
+}
+
+input.button
+{
+ width: 150px;
+ padding-left:5px;
+ padding-right:5px;
+}
+
+input.imgButton
+{
+ width:20px;
+ height:20px;
+ cursor: pointer;
+}
+
+.hidden
+{
+ display:none;
+}
+
+.text-column
+{
+ text-align:left;
+ padding-right:20px;
+ padding-left:5px;
+}
+
+.infor
+{
+ border:1px solid #808080;
+ vertical-align:top;
+ padding:10px;
+}
+
+.buttons
+{
+ text-align:right;
+ padding-bottom:10px;
+ width:100%;
+}
+
+.list-table
+{
+ width:100%;
+}
+
+.heading-column { width : 450px;}
+td.input-column { width : 390px;}
+td.input-column input[type="text"]{ width: 360px;}
+td.input-column select { width: 367px;}
+td.error {padding-left:1em}
+
+.infor td{vertical-align: top;}
+
+.focusCell{background-color: #AFCCFF}
+.errorCell{background-color: #FFCFCF}
+.sectionOpen {display: true}
+.sectionClose{ display: none}
+.togglePanel.open {height:25px;padding-left:25px; background-image: url(../images/open.gif) ; background-repeat: no-repeat; background-position: top left}
+.togglePanel.close {height:25px;padding-left:25px; background-image: url(../images/close.gif) ; background-repeat: no-repeat; background-position: top left}
+
+.warnmessage {
+ color: red;
+}
+
+#facilityCol
+{
+ width: 130px;
+}
+
+fieldset
+{
+ border: 1px solid #3f5d8e;
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/caseentry-commons.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/caseentry-commons.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/caseentry-commons.js 2012-05-09 02:52:11 +0000
@@ -0,0 +1,235 @@
+
+function verifiedOnchange( container ){
+
+ var checked = byId( 'verified' ).checked;
+ if( checked )
+ {
+ disable( 'age' );
+ }
+ else
+ {
+ enable( 'age' );
+ }
+}
+
+// ----------------------------------------------------------------------------
+// Search patients by name
+// ----------------------------------------------------------------------------
+
+function getPatientsByName( divname )
+{
+ var fullName = jQuery('#' + divname + ' [id=fullName]').val().replace(/^\s+|\s+$/g,"");
+ if( fullName.length > 0)
+ {
+ contentDiv = 'resultSearchDiv';
+ $('#resultSearchDiv' ).load("getPatientsByName.action",
+ {
+ fullName: fullName
+ }).dialog({
+ title: i18n_search_result,
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{ background:'#000000', opacity: 0.8},
+ width: 800,
+ height: 400
+ });
+ }
+ else
+ {
+ alert( i18n_no_patients_found );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// Advanced search
+// -----------------------------------------------------------------------------
+
+function addAttributeOption()
+{
+ var rowId = 'advSearchBox' + jQuery('#advancedSearchTB select[name=searchingAttributeId]').length + 1;
+ var contend = '<td>' + getInnerHTML('searchingAttributeIdTD') + '</td>';
+ contend += '<td>' + searchTextBox ;
+ contend += '<input type="button" value="-" onclick="removeAttributeOption(' + "'" + rowId + "'" + ');"></td>';
+ contend = '<tr id="' + rowId + '">' + contend + '</tr>';
+
+ jQuery('#advancedSearchTB > tbody:last').append( contend );
+}
+
+function removeAttributeOption( rowId )
+{
+ jQuery( '#' + rowId ).remove();
+}
+
+//------------------------------------------------------------------------------
+// Search patients by selected attribute
+//------------------------------------------------------------------------------
+
+function searchingAttributeOnChange( this_ )
+{
+ var container = jQuery(this_).parent().parent().attr('id');
+ var attributeId = jQuery('#' + container+ ' [id=searchingAttributeId]').val();
+ var element = jQuery('#' + container+ ' [id=searchText]');
+ var valueType = jQuery('#' + container+ ' [id=searchingAttributeId] option:selected').attr('valueType');
+
+ if( attributeId == '-1' )
+ {
+ element.replaceWith( getDateField( container ) );
+ datePickerValid( 'searchDateField-' + container + ' [id=searchText]' );
+ }
+ else if( attributeId == '0' )
+ {
+ element.replaceWith( programComboBox );
+ }
+ else if ( valueType=='YES/NO' )
+ {
+ element.replaceWith( trueFalseBox );
+ }
+ else
+ {
+ element.replaceWith( searchTextBox );
+ }
+}
+
+function getDateField( container )
+{
+ var dateField = '<div id="searchDateField-' + container + '" > <input type="text" id="searchText" name="searchText" maxlength="30" style="width:18em" onkeyup="searchPatientsOnKeyUp( event );"></div>';
+ return dateField;
+}
+
+//-----------------------------------------------------------------------------
+// Search Patient
+//-----------------------------------------------------------------------------
+
+function searchPatientsOnKeyUp( event )
+{
+ var key = getKeyCode( event );
+
+ if ( key==13 )// Enter
+ {
+ searchAdvancedPatients()();
+ }
+}
+
+function getKeyCode(e)
+{
+ if (window.event)
+ return window.event.keyCode;
+ return (e)? e.which : null;
+}
+
+function searchAdvancedPatients()
+{
+ hideById( 'listPatientDiv' );
+ var searchTextFields = jQuery('[name=searchText]');
+ var flag = true;
+ jQuery( searchTextFields ).each( function( i, item )
+ {
+ if( jQuery( item ).val() == '' )
+ {
+ showWarningMessage( i18n_specify_search_criteria );
+ flag = false;
+ }
+ });
+
+ if(!flag) return;
+
+ contentDiv = 'listPatientDiv';
+ jQuery( "#loaderDiv" ).show();
+ searchPatient();
+
+}
+
+// ----------------------------------------------------------------------------
+// Show patients
+// ----------------------------------------------------------------------------
+
+function isDeathOnChange()
+{
+ var isDeath = byId('isDead').checked;
+ if(isDeath)
+ {
+ showById('deathDateTR');
+ }
+ else
+ {
+ hideById('deathDateTR');
+ }
+}
+
+// ----------------------------------------------------------------
+// Get Params form Div
+// ----------------------------------------------------------------
+
+function getParamsForDiv( patientDiv)
+{
+ var params = '';
+ jQuery("#" + patientDiv + " :input").each(function()
+ {
+ var elementId = $(this).attr('id');
+
+ if( $(this).attr('type') == 'checkbox' )
+ {
+ var checked = jQuery(this).attr('checked') ? true : false;
+ params += elementId + "=" + checked + "&";
+ }
+ else if( $(this).attr('type') != 'button' )
+ {
+ var value = "";
+ if( jQuery(this).val() != '' )
+ {
+ value = htmlEncode(jQuery(this).val());
+ }
+ params += elementId + "="+ value + "&";
+ }
+ });
+
+ return params;
+}
+
+// -----------------------------------------------------------------------------
+// View patient details
+// -----------------------------------------------------------------------------
+
+function showPatientDetails( patientId )
+{
+ $('#detailsInfo').load("getPatientDetails.action",
+ {
+ id:patientId
+ }
+ , function( ){
+ }).dialog({
+ title: i18n_patient_details,
+ maximize: true,
+ closable: true,
+ modal:false,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 450,
+ height: 300
+ });
+}
+
+function showPatientHistory( patientId )
+{
+ $('#detailsInfo').load("getPatientHistory.action",
+ {
+ patientId:patientId
+ }
+ , function( ){
+
+ }).dialog({
+ title: i18n_patient_details_and_history,
+ maximize: true,
+ closable: true,
+ modal:false,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 800,
+ height: 520
+ });
+}
+
+function exportPatientHistory( patientId, type )
+{
+ var url = "getPatientHistory.action?patientId=" + patientId + "&type=" + type;
+ window.location.href = url;
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/caseentry-patient.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/caseentry-patient.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/caseentry-patient.js 2012-05-09 02:52:11 +0000
@@ -0,0 +1,911 @@
+var COLOR_GREEN = '#b9ffb9';
+var COLOR_YELLOW = '#fffe8c';
+var COLOR_WHITE = '#ffffff';
+var COLOR_ORANGE = '#ff6600';
+var COLOR_RED = '#ff8a8a';
+var COLOR_GREY = '#cccccc';
+
+function organisationUnitSelected( orgUnits )
+{
+ showById('selectDiv');
+ disable('listPatientBtn');
+ hideById('listPatientDiv');
+
+ $.getJSON( 'organisationUnitHasPatients.action', {orgunitId:orgUnits[0]}
+ , function( json )
+ {
+ var type = json.response;
+ setFieldValue('selectedOrgunitText', json.message );
+
+ if( type == 'success' )
+ {
+ showById('searchPatientDiv');
+ enable('listPatientBtn');
+ setInnerHTML('warnmessage','');
+ setFieldValue('selectedOrgunitText', json.message );
+ }
+ else if( type == 'input' )
+ {
+ setInnerHTML('warnmessage', i18n_can_not_register_patient_for_orgunit);
+ disable('listPatientBtn');
+ }
+ } );
+}
+
+selection.setListenerFunction( organisationUnitSelected );
+
+// -----------------------------------------------------------------------------
+// Remove patient
+// -----------------------------------------------------------------------------
+
+function removePatient( patientId, fullName )
+{
+ removeItem( patientId, fullName, i18n_confirm_delete, 'removePatient.action' );
+}
+
+function sortPatients()
+{
+ hideById( 'listPatientDiv' );
+
+ contentDiv = 'listPatientDiv';
+ jQuery( "#loaderDiv" ).show();
+ jQuery('#listPatientDiv').load("searchRegistrationPatient.action",
+ {
+ sortPatientAttributeId: getFieldValue('sortPatientAttributeId')
+ }
+ , function(){
+ showById('listPatientDiv');
+ jQuery( "#loaderDiv" ).hide();
+ });
+}
+
+// -----------------------------------------------------------------------------
+// Add Patient
+// -----------------------------------------------------------------------------
+
+function validateAddPatient()
+{
+ $("#editPatientDiv :input").attr("disabled", true);
+ $.ajax({
+ type: "POST",
+ url: 'validatePatient.action',
+ data: getParamsForDiv('editPatientDiv'),
+ success:addValidationCompleted
+ });
+}
+
+function addValidationCompleted( data )
+{
+ var type = jQuery(data).find('message').attr('type');
+ var message = jQuery(data).find('message').text();
+
+ if ( type == 'success' )
+ {
+ removeDisabledIdentifier( );
+ addPatient( );
+ }
+ else
+ {
+ $("#editPatientDiv :input").attr("disabled", true);
+ if ( type == 'error' )
+ {
+ showErrorMessage( i18n_adding_patient_failed + ':' + '\n' + message );
+ }
+ else if ( type == 'input' )
+ {
+ showWarningMessage( message );
+ }
+ else if( type == 'duplicate' )
+ {
+ showListPatientDuplicate(data, false);
+ }
+
+ $("#editPatientDiv :input").attr("disabled", false);
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// Update Patient
+// -----------------------------------------------------------------------------
+
+function validateUpdatePatient()
+{
+ $("#editPatientDiv :input").attr("disabled", true);
+ $.ajax({
+ type: "POST",
+ url: 'validatePatient.action',
+ data: getParamsForDiv('editPatientDiv'),
+ success:updateValidationCompleted
+ });
+}
+
+function updateValidationCompleted( messageElement )
+{
+ var type = jQuery(messageElement).find('message').attr('type');
+ var message = jQuery(messageElement).find('message').text();
+
+ if ( type == 'success' )
+ {
+ removeDisabledIdentifier();
+ updatePatient();
+ }
+ else
+ {
+ $("#editPatientDiv :input").attr("disabled", true);
+ if ( type == 'error' )
+ {
+ showErrorMessage( i18n_saving_patient_failed + ':' + '\n' + message );
+ }
+ else if ( type == 'input' )
+ {
+ showWarningMessage( message );
+ }
+ else if( type == 'duplicate' )
+ {
+ showListPatientDuplicate(messageElement, true);
+ }
+ $("#editPatientDiv :input").attr("disabled", false);
+ }
+}
+// get and build a param String of all the identifierType id and its value
+// excluding inherited identifiers
+function getIdParams()
+{
+ var params = "";
+ jQuery("input.idfield").each(function(){
+ if( jQuery(this).val() && !jQuery(this).is(":disabled") )
+ params += "&" + jQuery(this).attr("name") +"="+ jQuery(this).val();
+ });
+ return params;
+}
+
+// -----------------------------------------------------------------------------
+// check duplicate patient
+// -----------------------------------------------------------------------------
+
+function checkDuplicate( divname )
+{
+ $.postUTF8( 'validatePatient.action',
+ {
+ fullName: jQuery( '#' + divname + ' [id=fullName]' ).val(),
+ dobType: jQuery( '#' + divname + ' [id=dobType]' ).val(),
+ gender: jQuery( '#' + divname + ' [id=gender]' ).val(),
+ birthDate: jQuery( '#' + divname + ' [id=birthDate]' ).val(),
+ age: jQuery( '#' + divname + ' [id=age]' ).val()
+ }, function( xmlObject, divname )
+ {
+ checkDuplicateCompleted( xmlObject, divname );
+ });
+}
+
+function checkDuplicateCompleted( messageElement, divname )
+{
+ checkedDuplicate = true;
+ var type = jQuery(messageElement).find('message').attr('type');
+ var message = jQuery(messageElement).find('message').text();
+
+ if( type == 'success')
+ {
+ showSuccessMessage(i18n_no_duplicate_found);
+ }
+ if ( type == 'input' )
+ {
+ showWarningMessage(message);
+ }
+ else if( type == 'duplicate' )
+ {
+ showListPatientDuplicate( messageElement, true );
+ }
+}
+/**
+ * Show list patient duplicate by jQuery thickbox plugin
+ * @param rootElement : root element of the response xml
+ * @param validate : is TRUE if this method is called from validation method
+ */
+function showListPatientDuplicate( rootElement, validate )
+{
+ var message = jQuery(rootElement).find('message').text();
+ var patients = jQuery(rootElement).find('patient');
+
+ var sPatient = "";
+ jQuery( patients ).each( function( i, patient )
+ {
+ sPatient += "<hr style='margin:5px 0px;'><table>";
+ sPatient += "<tr><td class='bold'>" + i18n_patient_system_id + "</td><td>" + jQuery(patient).find('systemIdentifier').text() + "</td></tr>" ;
+ sPatient += "<tr><td class='bold'>" + i18n_patient_full_name + "</td><td>" + jQuery(patient).find('fullName').text() + "</td></tr>" ;
+ sPatient += "<tr><td class='bold'>" + i18n_patient_gender + "</td><td>" + jQuery(patient).find('gender').text() + "</td></tr>" ;
+ sPatient += "<tr><td class='bold'>" + i18n_patient_date_of_birth + "</td><td>" + jQuery(patient).find('dateOfBirth').text() + "</td></tr>" ;
+ sPatient += "<tr><td class='bold'>" + i18n_patient_age + "</td><td>" + jQuery(patient).find('age').text() + "</td></tr>" ;
+ sPatient += "<tr><td class='bold'>" + i18n_patient_blood_group + "</td><td>" + jQuery(patient).find('bloodGroup').text() + "</td></tr>";
+ sPatient += "<tr><td class='bold'>" + i18n_patient_phone_number + "</td><td>" + jQuery(patient).find('phoneNumber').text() + "</td></tr>";
+
+ var identifiers = jQuery(patient).find('identifier');
+ if( identifiers.length > 0 )
+ {
+ sPatient += "<tr><td colspan='2' class='bold'>" + i18n_patient_identifiers + "</td></tr>";
+
+ jQuery( identifiers ).each( function( i, identifier )
+ {
+ sPatient +="<tr class='identifierRow'>"
+ +"<td class='bold'>" + jQuery(identifier).find('name').text() + "</td>"
+ +"<td>" + jQuery(identifier).find('value').text() + "</td> "
+ +"</tr>";
+ });
+ }
+
+ var attributes = jQuery(patient).find('attribute');
+ if( attributes.length > 0 )
+ {
+ sPatient += "<tr><td colspan='2' class='bold'>" + i18n_patient_attributes + "</td></tr>";
+
+ jQuery( attributes ).each( function( i, attribute )
+ {
+ sPatient +="<tr class='attributeRow'>"
+ +"<td class='bold'>" + jQuery(attribute).find('name').text() + "</td>"
+ +"<td>" + jQuery(attribute).find('value').text() + "</td> "
+ +"</tr>";
+ });
+ }
+ sPatient += "<tr><td colspan='2'><input type='button' id='"+ jQuery(patient).find('id').first().text() + "' value='" + i18n_edit_this_patient + "' onclick='showUpdatePatientForm(this.id)'/></td></tr>";
+ sPatient += "</table>";
+ });
+
+ var result = i18n_duplicate_warning;
+ if( !validate )
+ {
+ result += "<input type='button' value='" + i18n_create_new_patient + "' onClick='removeDisabledIdentifier( );addPatient();'/>";
+ result += "<br><hr style='margin:5px 0px;'>";
+ }
+
+ result += "<br>" + sPatient;
+ jQuery('#resultSearchDiv' ).html( result );
+ jQuery('#resultSearchDiv' ).dialog({
+ title: i18n_duplicated_patient_list,
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 800,
+ height: 400
+ });
+}
+
+// -----------------------------------------------------------------------------
+// Show representative form
+// -----------------------------------------------------------------------------
+
+function toggleUnderAge(this_)
+{
+ if( jQuery(this_).is(":checked"))
+ {
+ jQuery('#representativeDiv').dialog('destroy').remove();
+ jQuery('<div id="representativeDiv">' ).load( 'showAddRepresentative.action' ).dialog({
+ title: i18n_child_representative,
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 800,
+ height: 450
+ });
+ }else
+ {
+ jQuery("#representativeDiv :input.idfield").each(function(){
+ if( jQuery(this).is(":disabled"))
+ {
+ jQuery(this).removeAttr("disabled").val("");
+ }
+ });
+ jQuery("#representativeId").val("");
+ jQuery("#relationshipTypeId").val("");
+ }
+}
+
+// ----------------------------------------------------------------
+// Add Patient
+// ----------------------------------------------------------------
+
+function showAddPatientForm()
+{
+ hideById('listPatientDiv');
+ hideById('selectDiv');
+ hideById('searchPatientDiv');
+ hideById('migrationPatientDiv');
+
+ jQuery('#loaderDiv').show();
+ jQuery('#editPatientDiv').load('showAddPatientForm.action'
+ , function()
+ {
+ showById('editPatientDiv');
+ jQuery('#loaderDiv').hide();
+ });
+
+}
+
+function addPatient()
+{
+ $.ajax({
+ type: "POST",
+ url: 'addPatient.action',
+ data: getParamsForDiv('editPatientDiv'),
+ success: function(json) {
+ var type = json.response;
+ showProgramEnrollmentSelectForm( json.message );
+ jQuery('#resultSearchDiv').dialog('close');
+ }
+ });
+ return false;
+}
+
+// ----------------------------------------------------------------
+// Update Patient
+// ----------------------------------------------------------------
+
+function showUpdatePatientForm( patientId )
+{
+ hideById('listPatientDiv');
+ setInnerHTML('editPatientDiv', '');
+ hideById('selectDiv');
+ hideById('searchPatientDiv');
+ hideById('migrationPatientDiv');
+
+ jQuery('#loaderDiv').show();
+ jQuery('#editPatientDiv').load('showUpdatePatientForm.action',
+ {
+ id:patientId
+ }, function()
+ {
+ showById('editPatientDiv');
+ jQuery('#searchPatientsDiv').dialog('close');
+ jQuery('#loaderDiv').hide();
+ });
+
+ jQuery('#resultSearchDiv').dialog('close');
+}
+
+function updatePatient()
+{
+ $.ajax({
+ type: "POST",
+ url: 'updatePatient.action',
+ data: getParamsForDiv('editPatientDiv'),
+ success: function( json ) {
+ showProgramEnrollmentSelectForm( getFieldValue('id') );
+ }
+ });
+}
+
+// ----------------------------------------------------------------
+// Enrollment program
+// ----------------------------------------------------------------
+
+function showProgramEnrollmentSelectForm( patientId )
+{
+ hideById('listPatientDiv');
+ hideById('editPatientDiv');
+ hideById('selectDiv');
+ hideById('searchPatientDiv');
+ hideById('migrationPatientDiv');
+
+ jQuery('#loaderDiv').show();
+ jQuery('#enrollmentDiv').load('showProgramEnrollmentForm.action',
+ {
+ id:patientId
+ }, function()
+ {
+ showById('enrollmentDiv');
+
+ jQuery('#loaderDiv').hide();
+ });
+}
+
+function showProgramEnrollmentForm( patientId, programId )
+{
+ if( programId == 0 )
+ {
+ jQuery('#enrollBtn').attr('value',i18n_enroll_to_program);
+ hideEnrolmentField();
+
+ hideById('programEnrollmentDiv');
+
+ return;
+ }
+
+ jQuery('#loaderDiv').show();
+ jQuery('#programEnrollmentDiv').load('enrollmentform.action',
+ {
+ patientId:patientId,
+ programId:programId
+ }, function()
+ {
+ showById('programEnrollmentDiv');
+ showEnrolmentField();
+
+ var singleEvent = jQuery('#enrollmentDiv [name=programId] option:selected').attr('singleevent');
+
+ if(singleEvent=='true')
+ {
+ hideEnrolmentField();
+ }
+ else
+ {
+ showEnrolmentField();
+ var hideDateOfIncident = jQuery('#programEnrollmentSelectDiv [name=programId] option:selected').attr('hidedateofincident');
+
+ if( hideDateOfIncident=='true')
+ {
+ hideById( 'dateOfIncidentTR');
+ }
+ else
+ {
+ showById( 'dateOfIncidentTR');
+ }
+ }
+
+ jQuery('#loaderDiv').hide();
+ });
+}
+
+function validateProgramEnrollment()
+{
+ $.ajax({
+ type: "GET",
+ url: 'validatePatientProgramEnrollment.action',
+ data: getParamsForDiv('programEnrollmentSelectDiv'),
+ success: function(json) {
+ hideById('message');
+ var type = json.response;
+ if ( type == 'success' )
+ {
+ saveProgramEnrollment();
+ }
+ else if ( type == 'error' )
+ {
+ setMessage( i18n_program_enrollment_failed + ':' + '\n' + message );
+ }
+ else if ( type == 'input' )
+ {
+ setMessage( json.message );
+ }
+ }
+ });
+ return false;
+}
+
+function saveProgramEnrollment()
+{
+ $.ajax({
+ type: "POST",
+ url: 'saveProgramEnrollment.action',
+ data: getParamsForDiv('programEnrollmentSelectDiv'),
+ success: function( html ) {
+ setInnerHTML('programEnrollmentDiv', html );
+ jQuery('#enrollBtn').attr('value',i18n_update);
+ showSuccessMessage( i18n_enrol_success );
+ }
+ });
+ return false;
+}
+
+// ----------------------------------------------------------------
+// Un-Enrollment program
+// ----------------------------------------------------------------
+
+function showUnenrollmentSelectForm( patientId )
+{
+ hideById('listPatientDiv');
+ hideById('editPatientDiv');
+ hideById('selectDiv');
+ hideById('searchPatientDiv');
+ hideById('migrationPatientDiv');
+
+ jQuery('#loaderDiv').show();
+ jQuery('#enrollmentDiv').load('showProgramUnEnrollmentForm.action',
+ {
+ patientId:patientId
+ }, function()
+ {
+ showById('enrollmentDiv');
+ jQuery('#loaderDiv').hide();
+ });
+}
+
+function showUnenrollmentForm( programInstanceId )
+{
+ if( programInstanceId == 0 )
+ {
+ hideById( 'unenrollmentFormDiv' );
+ return;
+ }
+
+ jQuery('#loaderDiv').show();
+ jQuery.getJSON( "getProgramInstance.action",
+ {
+ programInstanceId:programInstanceId
+ },
+ function( json )
+ {
+ showById( 'unenrollmentFormDiv' );
+ jQuery( "#loaderDiv" ).hide();
+ });
+}
+
+function unenrollmentForm( programInstanceId )
+{
+ if( programInstanceId == 0 )
+ {
+ disable('enrollBtn');
+ return;
+ }
+
+ $.ajax({
+ type: "POST",
+ url: 'removeEnrollment.action',
+ data: getParamsForDiv('enrollmentDiv'),
+ success: function( json )
+ {
+ showSuccessMessage( i18n_unenrol_success );
+ hideEnrolmentField( 'enrollmentDateTR' );
+ jQuery('#enrollmentDiv [name=programId]').val('0');
+ hideById( 'programEnrollmentDiv' );
+ }
+ });
+}
+
+//-----------------------------------------------------------------------------
+//Save
+//-----------------------------------------------------------------------------
+
+function saveDueDate( programStageInstanceId, programStageInstanceName )
+{
+ var field = document.getElementById( 'value_' + programStageInstanceId + '_date' );
+
+ var dateOfIncident = new Date( byId('dateOfIncident').value );
+ var dueDate = new Date(field.value);
+
+ if( dueDate < dateOfIncident )
+ {
+ field.style.backgroundColor = '#FFCC00';
+ alert( i18n_date_less_incident );
+ return;
+ }
+
+ field.style.backgroundColor = '#ffffcc';
+
+ var dateDueSaver = new DateDueSaver( programStageInstanceId, field.value, '#ccffcc' );
+ dateDueSaver.save();
+}
+
+//----------------------------------------------------
+// Show relationship with new patient
+//----------------------------------------------------
+
+function showRelationshipList( patientId )
+{
+ hideById('addRelationshipDiv');
+
+ if ( getFieldValue('isShowPatientList') == 'false' )
+ {
+ hideById('selectDiv');
+ hideById('searchPatientDiv');
+ hideById('listPatientDiv');
+
+ jQuery('#loaderDiv').show();
+ jQuery('#listRelationshipDiv').load('showRelationshipList.action',
+ {
+ id:patientId
+ }, function()
+ {
+ showById('listRelationshipDiv');
+ jQuery('#loaderDiv').hide();
+ });
+ }
+ else
+ {
+ loadPatientList();
+ }
+}
+
+// ----------------------------------------------------------------
+// Click Back to Search button
+// ----------------------------------------------------------------
+
+function onClickBackBtn()
+{
+ showById('selectDiv');
+ showById('searchPatientDiv');
+ showById('listPatientDiv');
+
+ hideById('editPatientDiv');
+ hideById('enrollmentDiv');
+ hideById('listRelationshipDiv');
+ hideById('addRelationshipDiv');
+ hideById('migrationPatientDiv');
+}
+
+function loadPatientList()
+{
+ hideById('editPatientDiv');
+ hideById('enrollmentDiv');
+ hideById('listRelationshipDiv');
+ hideById('addRelationshipDiv');
+ hideById('dataRecordingSelectDiv');
+ hideById('dataEntryFormDiv');
+ hideById('migrationPatientDiv');
+
+ showById('selectDiv');
+ showById('searchPatientDiv');
+
+ if( statusSearching == 0)
+ {
+ loadAllPatients();
+ }
+ else if( statusSearching == 1 )
+ {
+ searchAdvancedPatients();
+ }
+}
+
+// -----------------------------------------------------------------------------
+// Load all patients
+// -----------------------------------------------------------------------------
+
+function loadAllPatients()
+{
+ hideById('listPatientDiv');
+
+ var sortPatientAttributeId = getFieldValue('sortPatientAttributeId');
+
+ jQuery('#loaderDiv').show();
+ contentDiv = 'listPatientDiv';
+ jQuery('#listPatientDiv').load('searchRegistrationPatient.action',{
+ listAll:true,
+ sortPatientAttributeId: (sortPatientAttributeId ? sortPatientAttributeId : "")
+ },
+ function(){
+ statusSearching = 0;
+ showById('listPatientDiv');
+ jQuery('#loaderDiv').hide();
+ });
+ hideLoader();
+}
+
+function addPhoneToList( elementList, _id, _patientName, _phoneNo )
+{
+ var list = jQuery( "#" + elementList );
+ list.append( "<option value='" + _id + "'>\"" + _patientName + " <" + _phoneNo + ">" + "\"</option>" );
+
+ jQuery( "tr#tr" + _id ).hide();
+}
+
+
+function removePhoneFromList( elementList, _id )
+{
+ var list = jQuery( "#" + elementList + " option[value='" + _id + "']" ).remove();
+
+ jQuery( "tr#tr" + _id ).show();
+}
+
+//-----------------------------------------------------------------------------
+// Saver objects
+//-----------------------------------------------------------------------------
+
+function DateDueSaver( programStageInstanceId_, dueDate_, resultColor_ )
+{
+ var programStageInstanceId = programStageInstanceId_;
+ var dueDate = dueDate_;
+ var resultColor = resultColor_;
+
+ this.save = function()
+ {
+ var params = 'programStageInstanceId=' + programStageInstanceId + '&dueDate=' + dueDate;
+ $.ajax({
+ type: "POST",
+ url: "saveDueDate.action",
+ data: params,
+ dataType: "xml",
+ success: function(result){
+ handleResponse (result);
+ },
+ error: function(request,status,errorThrown) {
+ handleHttpError (request);
+ }
+ });
+ };
+
+ function handleResponse( rootElement )
+ {
+ var codeElement = rootElement.getElementsByTagName( 'code' )[0];
+ var code = parseInt( codeElement.firstChild.nodeValue );
+
+ if ( code == 0 )
+ {
+ markValue( resultColor );
+ }
+ else
+ {
+ markValue( COLOR_GREY );
+ window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
+ }
+ }
+
+ function handleHttpError( errorCode )
+ {
+ markValue( COLOR_GREY );
+ window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
+ }
+
+ function markValue( color )
+ {
+
+ var element = document.getElementById( 'value_' + programStageInstanceId + '_date' );
+
+ element.style.backgroundColor = color;
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// remove value of all the disabled identifier fields
+// an identifier field is disabled when its value is inherited from another person ( underAge is true )
+// we don't save inherited identifiers. Only save the representative id.
+// -----------------------------------------------------------------------------
+
+function removeDisabledIdentifier()
+{
+ jQuery("input.idfield").each(function(){
+ if( jQuery(this).is(":disabled"))
+ jQuery(this).val("");
+ });
+}
+
+function addEventForPatientForm( divname )
+{
+ jQuery("#" + divname + " [id=searchPatientByNameBtn]").click(function() {
+ getPatientsByName( divname );
+ });
+
+ jQuery("#" + divname + " [id=checkDuplicateBtn]").click(function() {
+ checkDuplicate( divname );
+ });
+
+ jQuery("#" + divname + " [id=dobType]").change(function() {
+ dobTypeOnChange( divname );
+ });
+}
+
+function showRepresentativeInfo( patientId)
+{
+ jQuery('#representativeInfo' ).dialog({
+ title: i18n_representative_info,
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 400,
+ height: 300
+ });
+}
+
+function hideEnrolmentField()
+{
+ setFieldValue( 'enrollmentDate', '' );
+ setFieldValue( 'dateOfIncident', '' );
+ hideById('enrollmentDateTR');
+ hideById('dateOfIncidentTR');
+ hideById('enrollBtn');
+}
+
+function showEnrolmentField()
+{
+ showById('enrollmentDateTR');
+ showById('dateOfIncidentTR');
+ showById('enrollBtn');
+}
+
+function saveIdentifierAndAttribute()
+{
+ $.ajax({
+ type: "POST",
+ url: 'savePatientIdentifierAndAttribute.action',
+ data: getParamsForDiv('programEnrollmentInforForm'),
+ success: function(json)
+ {
+ showSuccessMessage( i18n_save_success );
+ }
+ });
+}
+
+//--------------------------------------------------------------------------------------------
+// Show selected data-recording
+//--------------------------------------------------------------------------------------------
+
+function showSelectedDataRecoding( patientId )
+{
+ showLoader();
+ hideById('searchPatientDiv');
+ hideById('dataEntryFormDiv');
+ hideById('migrationPatientDiv');
+ jQuery('#dataRecordingSelectDiv').load( 'selectDataRecording.action',
+ {
+ patientId: patientId
+ },
+ function()
+ {
+ jQuery('#dataRecordingSelectDiv [id=patientInfoDiv]').hide();
+ jQuery('#dataRecordingSelectDiv [id=backBtnFromEntry]').hide();
+ showById('dataRecordingSelectDiv');
+
+ var programId = jQuery('#programEnrollmentSelectDiv [id=programId] option:selected').val();
+ $('#dataRecordingSelectDiv [id=programId]').val( programId );
+ $('#dataRecordingSelectDiv [id=programIdTR]').hide();
+
+ loadProgramStages();
+ hideLoader();
+ hideById('contentDiv');
+ });
+}
+
+function searchPatient()
+{
+ $.ajax({
+ url: 'searchRegistrationPatient.action',
+ type:"POST",
+ data: getParamsForDiv('searchPatientDiv'),
+ success: function( html ){
+ statusSearching = 1;
+ setInnerHTML( 'listPatientDiv', html );
+ showById('listPatientDiv');
+ jQuery( "#loaderDiv" ).hide();
+ }
+ });
+}
+
+//--------------------------------------------------------------------------------------------
+// Migration patient
+//--------------------------------------------------------------------------------------------
+
+function getPatientLocation( patientId )
+{
+ hideById('listPatientDiv');
+ hideById('selectDiv');
+ hideById('searchPatientDiv');
+
+ jQuery('#loaderDiv').show();
+
+ jQuery('#migrationPatientDiv').load("getPatientLocation.action",
+ {
+ patientId: patientId
+ }
+ , function(){
+ showById( 'migrationPatientDiv' );
+ jQuery( "#loaderDiv" ).hide();
+ });
+}
+
+function verifyOrgunitRegistration( patientId )
+{
+ $.getJSON( 'verifyOrgunitRegistration.action', {}
+ , function( json )
+ {
+ var type = json.response;
+ if( type == 'success' )
+ {
+ registerPatientLocation( patientId );
+ }
+ else if( type == 'input' )
+ {
+ showWarningMessage( i18n_can_not_register_patient_for_orgunit);
+ }
+ } );
+}
+
+function registerPatientLocation( patientId )
+{
+ $.getJSON( 'registerPatientLocation.action',{ patientId:patientId }
+ , function( json )
+ {
+ showSuccessMessage( i18n_save_success );
+ } );
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/sendSMS.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/sendSMS.js 2012-04-03 03:17:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/sendSMS.js 2012-05-09 02:52:11 +0000
@@ -1,4 +1,4 @@
-var isChecked = false;
+var _target = "";
var isOrgunitSelected = false;
function selectedOrganisationUnitSendSMS( unitIds )
@@ -6,27 +6,43 @@
isOrgunitSelected = (unitIds && unitIds.length > 0);
}
-function toggleSMSGUI( checked )
+function toggleSMSGUI( _value )
{
- if ( checked ) {
+ if ( _value == "phone" )
+ {
+ showById( 'phoneType' );
+ hideById( 'orgunitType' );
+ }
+ else if ( _value == "user" || _value == "unit" )
+ {
selectionTree.clearSelectedOrganisationUnits();
selectionTree.buildSelectionTree();
hideById( 'phoneType' );
showById( 'orgunitType' );
- } else {
- showById( 'phoneType' );
- hideById( 'orgunitType' );
- }
-
- isChecked = checked;
+ }
+ else {
+ window.location.href = "showBeneficiarySMSForm.action";
+ }
+
+ _target = _value;
+}
+
+function toggleAll( checked )
+{
+ var list = jQuery( "input[type=checkbox][name=patientSMSCheckBox]" );
+
+ for ( var i in list )
+ {
+ list[i].checked = checked;
+ }
}
function sendSMSMessage( _form )
{
var params = "";
- if ( !isChecked )
+ if ( _target == "phone" )
{
var list = getFieldValue( "recipient" );
@@ -48,7 +64,7 @@
params = "?" + params.substring( 0, params.length - 1 );
}
- else
+ else if ( _target == "user" || _target == "unit" )
{
if ( !isOrgunitSelected )
{
@@ -56,11 +72,20 @@
return;
}
}
+ else
+ {
+ if ( hasElements( 'recipients' ) )
+ {
+ params = "?" + getParamString( 'recipients', 'recipients' );
+ }
+ else { markInvalid( "recipients", i18n_list_empty ); }
+ }
jQuery.postUTF8( _form.action + params,
{
gatewayId: getFieldValue( 'gatewayId' ),
- smsMessage: getFieldValue( 'smsMessage' )
+ smsMessage: getFieldValue( 'smsMessage' ),
+ sendTarget: getFieldValue( 'sendTarget' )
}, function ( json )
{
if ( json.response == "success" ) {
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm 2012-03-14 10:36:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm 2012-05-09 02:52:11 +0000
@@ -1,6 +1,6 @@
<h2>DHIS Mobile Configuration</h2>
<ul>
-<!-- <li><a href = "mobileSettings.action">Settings</a></li>-->
+ <!--<li><a href = "mobileSettings.action">Settings</a></li>-->
<li><a href="patientMobileSetting.action">$i18n.getString( "patient_mobile_setting" )</a></li>
<li><a href="showMobileDataSet.action">$i18n.getString( "mobile_dataset" ) </a></li>
<li><a href="showSMSConfigureForm.action">$i18n.getString( "sms_service_configuration" )</a></li>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menuWithTree.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menuWithTree.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menuWithTree.vm 2012-05-09 02:52:11 +0000
@@ -0,0 +1,3 @@
+#parse( "/dhis-web-maintenance-mobile/menu.vm" )
+<br/>
+#parse( "/dhis-web-commons/ouwt/orgunittree.vm" )
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/patientRegistrationList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/patientRegistrationList.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/patientRegistrationList.vm 2012-05-09 02:52:11 +0000
@@ -0,0 +1,159 @@
+<table>
+ <tr>
+ <td class='text-column' >$i18n.getString( "search_result_matching_the_search_criteria" ):</td>
+ <td> </td>
+ <td> </td>
+ <td>
+ #if($!listAll)
+ $i18n.getString( "list_all_patients" )
+ #else
+ $i18n.getString( "search_patients_by_attributes" )
+ #end
+ </td>
+ </tr>
+
+ <tr>
+ <td class='text-column' >$i18n.getString( "total_result" )</td>
+ <td> </td>
+ <td> </td>
+ <td>$!total</td>
+ </tr>
+</table>
+
+#if( $patients.size() > 0 )
+<table class="mainPageTable">
+ <tr>
+ <td>
+ <table class="listTable" id="patientList" width='100%'>
+ <col width="30"/>
+ #foreach( $attribute in $patientAttributes )
+ #if($attribute)<col/>#end
+ #end
+ <col/>
+ <col/>
+ <col/>
+ <col/>
+ #if($mapPatientOrgunit.size()!=0)
+ <col/>
+ #end
+ <col width="20"/>
+
+ <thead>
+ <tr>
+ <th>#</th>
+ #foreach( $attribute in $patientAttributes )
+ #if($attribute)
+ <th id="patientAttributeName">$attribute.name</th>
+ #end
+ #end
+ <th>$i18n.getString( "full_name" )</th>
+ <th>$i18n.getString( "gender" )</th>
+ <th>$i18n.getString( "date_of_birth" )</th>
+ <th class="{sorter: false}">$i18n.getString( "age" )</th>
+ #if($mapPatientOrgunit.size()!=0)
+ <th>$i18n.getString( "hierachy_orgunit" )</th>
+ #end
+ <th style="text-align:center" class="{sorter: false}">$i18n.getString( "operations" )</th>
+ </tr>
+ </thead>
+
+ <tbody id="list">
+ #set( $mark = false )
+ #foreach( $patient in $patients )
+ <tr id="tr${patient.id}" #alternate($mark) >
+
+ <td>
+ #set( $nr = ( ( $paging.getCurrentPage() - 1 ) * $paging.pageSize ) + $velocityCount )
+ $nr
+ </td>
+
+ #foreach( $attribute in $patientAttributes )
+ #if( $attribute )
+ #set ( $key = $patient.id + '-' + $attribute.id )
+ <td>
+ #if( $attribute.valueType == 'YES/NO')
+ $i18n.getString( $mapPatientPatientAttr.get($key) )
+ #else
+ $mapPatientPatientAttr.get($key)
+ #end
+ </td>
+ #end
+ #end
+
+ <td>$!patient.getFullName()</td>
+
+ <td>$i18n.getString($!patient.gender)</td>
+
+ <td>$format.formatDate( $!patient.birthDate)</td>
+
+ <td>$!patient.getAge()</td>
+
+ #if($mapPatientOrgunit.size()!=0)
+
+ <td>$!mapPatientOrgunit.get($patient.id)</td>
+
+ #end
+
+ <td>
+ #if ( $!patient.phoneNumber() && $!patient.phoneNumber() != "" )
+ <a href="javascript:addPhoneToList( 'recipients', '$patient.id', '$patient.getFullName()', '$!patient.phoneNumber' )" title='$i18n.getString( "add_phone_to_list" )'><img src="../images/move_down.png" alt='$i18n.getString( "add_phone_to_list" )'></a>
+ #else
+ <img src="../images/question2.png" alt='$i18n.getString( "no_phone" )'>
+ #end
+ </td>
+
+ </tr>
+ #set( $mark = !$mark)
+ #end
+ </tbody>
+
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="6">
+ <p></p>
+ <div class="paging-container">
+ #parse( "/dhis-web-commons/paging/paging.vm" )
+ </div>
+ </td>
+ <td></td>
+ </tr>
+</table>
+
+<div id="detailsInfo"></div>
+
+#end
+<script type="text/javascript">
+ jQuery(document).ready(function(){
+ tableSorter( 'patientList' );
+ });
+ var i18n_patient_details_and_history = '$encoder.jsEscape( $i18n.getString( "patient_details_and_history" ) , "'" )';
+
+ var i18n_id = '$encoder.jsEscape( $i18n.getString( "id" ), "'")';
+ var i18n_full_name = '$encoder.jsEscape( $i18n.getString( "full_name" ), "'")';
+ var i18n_gender = '$encoder.jsEscape( $i18n.getString( "gender" ), "'")';
+ var i18n_dob_type = '$encoder.jsEscape( $i18n.getString( "dob_type" ), "'")';
+ var i18n_date_of_birth = '$encoder.jsEscape( $i18n.getString( "date_of_birth" ), "'")';
+ var i18n_blood_group = '$encoder.jsEscape( $i18n.getString( "blood_group" ), "'")';
+ var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ), "'")';
+ var i18n_select = '[' + '$encoder.jsEscape( $i18n.getString( "select" ), "'")' + ']';
+ var i18n_program_stages_history_plan = '$encoder.jsEscape( $i18n.getString( "program_stages_history_plan" ) , "'")';
+ var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
+ var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
+ var i18n_value_must_positive_integer = '$encoder.jsEscape( $i18n.getString( "value_must_positive_integer" ) , "'")';
+ var i18n_value_must_negative_integer = '$encoder.jsEscape( $i18n.getString( "value_must_negative_integer" ) , "'")';
+ var i18n_invalid_date = '$encoder.jsEscape( $i18n.getString( "invalid_date" ) , "'")' + ".\n " + '$encoder.jsEscape( $i18n.getString( "format_date" ) , "'")' + " '" + dateFormat.replace('yy', 'yyyy') + " '" ;
+ var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
+ var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
+ var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")';
+ var i18n_complete_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_confirm_message" ) , "'")';
+ var i18n_error_required_field = '$encoder.jsEscape( $i18n.getString( "error_required_field" ) , "'")';
+ var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
+ var i18n_date_is_greater_then_or_equals_due_date = '$encoder.jsEscape( $i18n.getString( "date_is_greater_then_or_equals_due_date" ) , "'")';
+ var i18n_program_stage = '$encoder.jsEscape( $i18n.getString( "program_stage" ) , "'")';
+ var i18n_scheduled_for = '$encoder.jsEscape( $i18n.getString( "scheduled_for" ) , "'")';
+ var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'")';
+ var i18n_create_new_encounter = '$encoder.jsEscape( $i18n.getString( "create_new_encounter" ) , "'")';
+ var i18n_save_success = '$encoder.jsEscape( $i18n.getString( "save_success" ) , "'")';
+</script>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendBeneficiarySMSPage.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendBeneficiarySMSPage.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendBeneficiarySMSPage.vm 2012-05-09 02:52:11 +0000
@@ -0,0 +1,285 @@
+<script type="text/javascript" src="javascript/sendSMS.js"></script>
+<script type="text/javascript" src="javascript/caseentry-commons.js"></script>
+<script type="text/javascript" src="javascript/caseentry-patient.js"></script>
+<script type="text/javascript">
+ jQuery(document).ready( function() {
+ validation( "sendSMSForm", function( form ) { sendSMSMessage( form ); } );
+
+ selection.setListenerFunction( organisationUnitSelected );
+ });
+
+ var i18n_no_recipient = '$encoder.jsEscape( $i18n.getString( "no_recipient" ) , "'")';
+ var i18n_please_verify_phone = '$encoder.jsEscape( $i18n.getString( "please_verify_phone" ) , "'")';
+ var i18n_please_select_orgunit = '$encoder.jsEscape( $i18n.getString( "please_select_orgunit" ) , "'")';
+ var i18n_list_empty = '$encoder.jsEscape( $i18n.getString( "list_empty" ) , "'")';
+ var i18n_please_select_a_program = '$encoder.jsEscape( $i18n.getString( "please_select_a_program" ) , "'")';
+ var i18n_there_is_no_program = '$encoder.jsEscape( $i18n.getString( "there_is_no_program" ) , "'")';
+ var i18n_can_not_register_patient_for_orgunit = '$encoder.jsEscape( $i18n.getString( "can_not_register_patient_for_orgunit" ), "'")';
+</script>
+
+<style type="text/css">
+ .statusBar{
+ color: white;
+ padding: 5px 5px;
+ margin: -16px 0 20px -20px;
+ font-weight: bold;
+ background-color: #8FABC7;
+ }
+</style>
+
+<h3>$i18n.getString( "send_sms_beneficiary" )</h3>
+#if ( $!gatewayMap && $!gatewayMap.size() > 0 )
+<div>
+<form id="sendSMSForm" name="sendSMSForm" action="sendSMS.action">
+ <input type="hidden" id="isShowPatientList" name="isShowPatientList" />
+ <table id="detailsList">
+ <col width="300px"/>
+ <col width="80px"/>
+ <tbody>
+ <tr>
+ <th colspan="2">$i18n.getString( "gateway_type" )</th>
+ </tr>
+ <tr>
+ <td><label for="type">$i18n.getString( "type" ):</label></td>
+ <td>
+ #set( $keys = $!gatewayMap.keySet() )
+ <select id="gatewayId" name="gatewayId" style="width: 100%;">
+ #foreach( $key in $!keys )
+ <option value="$gatewayMap.get( $key )">$i18n.getString( $key )</option>
+ #end
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td>$i18n.getString( "send_sms_to_target" )</td>
+ <td>
+ <select id="sendTarget" name="sendTarget" onchange="javascript:toggleBasicSMSGUI();">
+ <option value="phone">$i18n.getString( "raw_phone_number" )</option>
+ <option value="user">$i18n.getString( "assigned_user_number" )</option>
+ <option value="unit">$i18n.getString( "selected_unit_number" )</option>
+ <option value="patient" selected="true">$i18n.getString( "patient_number" )</option>
+ </select>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <table>
+ <tbody>
+ <tr>
+ <th colspan="5">$i18n.getString( "search_details" )</th>
+ </tr>
+ <tr>
+ <td><label>$i18n.getString( "registering_unit" )</label></td>
+ <td><input type="text" id='selectedOrgunitText' readonly style="min-width:16em"></td>
+ <td><input type="button" id='listPatientBtn' value="$i18n.getString( 'list_all_patients' )" onclick='loadAllPatients();'></td>
+ <td><span id='warnmessage' style='color:red'></span></td>
+ </tr>
+
+ <tr id='advSearchBox0'>
+ <td id='searchingAttributeIdTD'>
+ <select id="searchingAttributeId" name="searchingAttributeId" style="width:20.2em" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end onchange="searchingAttributeOnChange(this)">
+ <option value="">$i18n.getString( "search_by_name_identifier" )</option>
+ <option value="0">$i18n.getString( "search_by_program" )</option>
+ <option value="-1">$i18n.getString( "date_of_birth" )</option>
+ #foreach( $attribute in $patientAttributes )
+ <option value="$attribute.id" valueType='$attribute.valueType'>$encoder.htmlEncode( $attribute.name )</option>
+ #end
+ </select>
+ <em title="$i18n.getString( 'required' )" class="required">*</em></label>
+ </td>
+ <td>
+ <input type="text" id="searchText" name="searchText" maxlength="30" style="width:20em" value="$!searchText" onkeyup='searchPatientsOnKeyUp( event );'/>
+ </td>
+ <td><input type="button" value='+' onclick='addAttributeOption();'/>
+ <input type="button" value='$i18n.getString( "search" )' onclick='searchAdvancedPatients();'/>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <!-- List searching patients -->
+ #parse( "dhis-web-commons/loader/loader.vm" )
+ <div id='listPatientDiv'></div>
+
+ <table>
+ <tbody>
+ <tr><th colspan="2">$i18n.getString( "phone_number" )</th></tr>
+ <tr>
+ <td colspan="2">
+ <select id="recipients" name="recipients" multiple="true" style="width:50em;height:10em" class="{validate:{required:true}}"
+ ondblclick="removePhoneFromList( 'recipients', this.value );"></select></td></tr>
+
+ <tr><th colspan="2">$i18n.getString( "message" )</th></tr>
+ <tr><td colspan="2"><textarea id="smsMessage" name="smsMessage" cols="95" rows="5" class="{validate:{required:true}}"></textarea></td></tr>
+ </tbody>
+
+ <tbody>
+ <tr><td><input type="submit" name="send" value="$i18n.getString( 'send_sms' )"/></td></tr>
+ </tbody>
+ </table>
+</form>
+</div>
+
+#else
+<p>No Sms service available</p>
+#end
+
+<script type="text/javascript">
+
+ var isOrgunitSelected = false;
+
+ function toggleBasicSMSGUI()
+ {
+ window.location.href = "showSMSForm.action";
+ }
+
+ function selectedOrganisationUnitSendSMS( unitIds )
+ {
+ if ( unitIds && unitIds.length > 0 )
+ {
+ isOrgunitSelected = true;
+
+ //loadPrograms( getFieldValue( 'level' ) );
+ } else {
+ isOrgunitSelected = false;
+ }
+ }
+
+ function loadPrograms( _value )
+ {
+ var programList = jQuery( "#programId" );
+
+ if ( _value == "selected" )
+ {
+ jQuery.get( "loadProgramsByUnit.action", {}, function( json )
+ {
+ programList.empty();
+ programList.append( "<option value=''>[ " + i18n_please_select_a_program + " ]</option>" );
+
+ jQuery.each( json.programs, function( i, item )
+ {
+ programList.append( "<option value='" + item.id + "'>" + item.name + "</option>" );
+ } );
+
+ enable( "programId" );
+ showById( "programBody" );
+ } );
+ } else {
+ hideById( "programBody" );
+ disable( "programId" );
+ programList.empty();
+ }
+ }
+
+ var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ) , "'")';
+ var i18n_can_not_register_patient_for_orgunit = '$encoder.jsEscape( $i18n.getString( "can_not_register_patient_for_orgunit" ), "'")';
+ var i18n_please_select_village = '[' + '$encoder.jsEscape( $i18n.getString( "please_select_village" ), "'")' + ']';
+ var i18n_specify_search_criteria = '$encoder.jsEscape( $i18n.getString( "specify_search_criteria" ) , "'")';
+ var i18n_select_program = '[' + '$encoder.jsEscape( $i18n.getString( "select_program" ), "'")' + ']';
+ var i18n_save_success = '$encoder.jsEscape( $i18n.getString( "save_success" ) , "'")';
+ var i18n_list_all_patient = '$encoder.jsEscape( $i18n.getString( "list_all_patient" ) , "'")';
+ var i18n_enrol_success = '$encoder.jsEscape( $i18n.getString( "enrol_success" ) , "'")';
+ var i18n_unenrol_success = '$encoder.jsEscape( $i18n.getString( "unenrol_success" ) , "'")';
+ var i18n_list_patients_by_program = '$encoder.jsEscape( $i18n.getString( "list_patients_by_program" ) , "'" )';
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_patient" ) , "'" )';
+ var i18n_adding_patient_failed = '$encoder.jsEscape( $i18n.getString( "adding_patient_failed" ), "'")';
+ var i18n_updating_patient_failed = '$encoder.jsEscape( $i18n.getString( "updating_patient_failed" ), "'")';
+ var i18n_program_enrollment_failed = '$encoder.jsEscape( $i18n.getString( "program_enrollment_failed" ) , "'")';
+ var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
+ var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
+ var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")';
+ var i18n_date_invalid = '$encoder.jsEscape( $i18n.getString( "date_invalid" ) , "'")';
+ var i18n_date_less_incident = '$encoder.jsEscape( $i18n.getString( "date_less_incident" ) , "'")';
+ var i18n_enroll_to_program = '$encoder.jsEscape( $i18n.getString( "enroll_to_program" ) , "'")';
+ var i18n_update = '$encoder.jsEscape( $i18n.getString( "update" ) , "'")';
+ var i18n_oucode_must_have_9_digits = '$encoder.jsEscape( $i18n.getString( "oucode_must_be_valid" ) , "'")';
+ var i18n_patient_identifiers = '$encoder.jsEscape( $i18n.getString( "patient_identifiers" ) , "'")';
+ var i18n_patient_attributes = '$encoder.jsEscape( $i18n.getString( "patient_attributes" ) , "'")';
+ var i18n_patient_id = '$encoder.jsEscape( $i18n.getString( "id" ) , "'")';
+ var i18n_patient_full_name = '$encoder.jsEscape( $i18n.getString( "full_name" ) , "'")';
+ var i18n_patient_demographics = '$encoder.jsEscape( $i18n.getString( "demographics" ) , "'")';
+ var i18n_patient_gender = '$encoder.jsEscape( $i18n.getString( "gender" ) , "'")';
+ var i18n_patient_date_of_birth = '$encoder.jsEscape( $i18n.getString( "date_of_birth" ) , "'")';
+ var i18n_patient_dob_type = '$encoder.jsEscape( $i18n.getString( "dob_type" ), "'")';
+ var i18n_patient_age = '$encoder.jsEscape( $i18n.getString( "age" ) , "'")';
+ var i18n_patient_blood_group = '$encoder.jsEscape( $i18n.getString( "blood_group" ) , "'")';
+ var i18n_patient_phone_number = '$encoder.jsEscape( $i18n.getString( "phone_number" ) , "'")';
+ var i18n_edit_this_patient = '$encoder.jsEscape( $i18n.getString( "edit_this_patient" ) , "'")';
+ var i18n_no_duplicate_found = '$encoder.jsEscape( $i18n.getString( "no_duplicate_found" ) , "'")';
+ var i18n_patient_system_id = '$encoder.jsEscape( $i18n.getString( "patient_system_id" ) , "'")';
+ var i18n_child_representative = '$encoder.jsEscape( $i18n.getString( "child_representative" ) , "'")';
+ var i18n_no_patients_found = '$encoder.jsEscape( $i18n.getString( "no_patients_found" ) , "'")';
+ var i18n_search_result = '$encoder.jsEscape( $i18n.getString( "search_result" ) , "'")';
+ var i18n_duplicated_patient_list = '$encoder.jsEscape( $i18n.getString( "duplicated_patient_list" ) , "'")';
+ var i18n_duplicate_warning = '$encoder.jsEscape( $i18n.getString( "duplicate_warning" ) , "'")';
+ var i18n_search_by_name_identifier = '$encoder.jsEscape( $i18n.getString( "search_by_name_identifier" ) , "'")';
+ var i18n_search_by_program = '$encoder.jsEscape( $i18n.getString( "search_by_program" ) , "'")';
+ var i18n_create_new_patient = '$encoder.jsEscape( $i18n.getString( "create_new_patient" ) , "'")';
+ var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")';
+ var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")';
+ var i18n_choose_this_person = '$encoder.jsEscape( $i18n.getString( "choose_this_person" ) , "'")';
+ var i18n_representative_info = '$encoder.jsEscape( $i18n.getString( "representative_info" ) , "'")';
+ var i18n_select = '[' + '$encoder.jsEscape( $i18n.getString( "select" ), "'")' + ']';
+ var i18n_program_stages_history_plan = '$encoder.jsEscape( $i18n.getString( "program_stages_history_plan" ) , "'")';
+
+ var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
+ var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
+ var i18n_value_must_positive_integer = '$encoder.jsEscape( $i18n.getString( "value_must_positive_integer" ) , "'")';
+ var i18n_value_must_negative_integer = '$encoder.jsEscape( $i18n.getString( "value_must_negative_integer" ) , "'")';
+ var i18n_invalid_date = '$encoder.jsEscape( $i18n.getString( "invalid_date" ) , "'")' + ".\n "
+ + '$encoder.jsEscape( $i18n.getString( "format_date" ) , "'")' + " '"
+ + dateFormat.replace('yy', 'yyyy') + " '" ;
+ var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
+ var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
+ var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")';
+ var i18n_complete_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_confirm_message" ) , "'")';
+ var i18n_error_required_field = '$encoder.jsEscape( $i18n.getString( "error_required_field" ) , "'")';
+ var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
+ var i18n_date_is_greater_then_or_equals_due_date = '$encoder.jsEscape( $i18n.getString( "date_is_greater_then_or_equals_due_date" ) , "'")';
+
+ var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
+ var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'")';
+ var i18n_please_fill_out_only_one_of_these_fields = '$encoder.jsEscape( $i18n.getString( "please_fill_out_only_one_of_these_fields" ) , "'")';
+ var checkedDuplicate = false;
+ // -1: no search anything
+ // 0: show list all patient
+ // 1: search with conditions
+ var statusSearching = -1;
+ isAjax = true;
+ contentDiv = '';
+
+ // ----------------------------------------------------------------
+ // Search field
+ // ----------------------------------------------------------------
+
+ var searchTextBox = '<input type="text" id="searchText" name="searchText" maxlength="30" style="width:20em" onkeyup="searchPatientsOnKeyUp( event );">';
+
+ var trueFalseBox = '<select id="searchText" name="searchText" style="width:20.2em" >';
+ trueFalseBox += '<option value="true">' + i18n_yes + '</option>';
+ trueFalseBox += '<option value="false">' + i18n_no + '</option>';
+ trueFalseBox += '</select>';
+
+ var programComboBox = '<select id="searchText" name="searchText" style="width:20.2em" >';
+ #foreach ( $program in $programs )
+ programComboBox += '<option value="$program.id">$program.name</option>';
+ #end
+ programComboBox += '</select>';
+
+ // ----------------------------------------------------------------
+ // Search field
+ // ----------------------------------------------------------------
+
+ #if( $status == 1 )
+ setFieldValue('selectedOrgunitText', i18n_please_select_village );
+ setInnerHTML('warnmessage', '' );
+ #elseif( $status == 2 )
+ setFieldValue('selectedOrgunitText', '$organisationUnit.name' );
+ setInnerHTML('warnmessage', i18n_can_not_register_patient_for_orgunit);
+ #else
+ setFieldValue('selectedOrgunitText', '$organisationUnit.name' );
+ setInnerHTML('warnmessage', '' );
+ showById('searchPatientDiv');
+ #end
+</script>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm 2012-04-04 04:27:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm 2012-05-09 02:52:11 +0000
@@ -4,8 +4,7 @@
selectionTreeSelection.setListenerFunction( selectedOrganisationUnitSendSMS );
- uncheck( "sendTypeCB" );
- toggleSMSGUI( false );
+ toggleSMSGUI( "phone" );
});
var i18n_no_recipient = '$encoder.jsEscape( $i18n.getString( "no_recipient" ) , "'")';
@@ -23,7 +22,7 @@
}
</style>
-<h3>Send SMS</h3>
+<h3>$i18n.getString( "send_sms" )</h3>
#if ( $!gatewayMap && $!gatewayMap.size() > 0 )
<form id="sendSMSForm" name="sendSMSForm" action="sendSMS.action">
<table id="detailsList">
@@ -46,12 +45,19 @@
</tr>
<tr>
- <td>$i18n.getString( "org_unit_tree" )</td>
- <td><input type="checkbox" id="sendTypeCB" onchange="toggleSMSGUI( this.checked );"/></td>
+ <td>$i18n.getString( "send_sms_to_target" )</td>
+ <td>
+ <select id="sendTarget" name="sendTarget" onchange="javascript:toggleSMSGUI( this.value );">
+ <option value="phone">$i18n.getString( "raw_phone_number" )</option>
+ <option value="user">$i18n.getString( "assigned_user_number" )</option>
+ <option value="unit">$i18n.getString( "selected_unit_number" )</option>
+ <option value="patient">$i18n.getString( "patient_number" )</option>
+ </select>
+ </td>
</tr>
<tr><th colspan="2">$i18n.getString( "message" )</th></tr>
- <tr><td colspan="2"><textarea id="smsMessage" name="smsMessage" cols="95" rows="10" class="{validate:{required:true}}"></textarea></td></tr>
+ <tr><td colspan="2"><textarea id="smsMessage" name="smsMessage" cols="95" rows="5" class="{validate:{required:true}}"></textarea></td></tr>
</tbody>
</table>