Package org.sis.ancmessaging.server.utility

Examples of org.sis.ancmessaging.server.utility.SmsMessageHandler


                reminder.setStatus("CONFIRMED");
                reminderDao.update(reminder);
            }
            mainForm.setLogText("\n1 Reminder Confirmed.");
        } else if (identifier.equals("2")) {
            SmsMessageHandler messageHandler = new SmsMessageHandler();
            String recipient = emergencyDao.getEmergencyPhone();
            messageHandler.setRecipient(recipient);
           
            Emergency emergency = new Emergency();

            emergency.setArrivedOn(new DateTime().toDate());

            String workerName = mother.getHealthWorker().getFullName();
            String messageContent = "Emergency\n" + mother.getMotherId() + "\n" + mother.getFullName()
                        + "\n" + workerName + "\n" + mother.getGott();
            emergency.setContent(messageContent);
            messageHandler.setContent(messageContent);
            messageHandler.setStatusReportEnabled(false);
            emergency.setMother(mother);

            emergencyDao.saveEmergency(emergency);

            try {
                messageHandler.sendMessage();
                mainForm.setLogText("\n1 emergency sent to HC");
            } catch (Exception e) {
                mainForm.setLogText("\nError: " + "\n" + e.getMessage());
            }
        }
View Full Code Here


    }

    @Override
    public void readIncomingInInterval() {
        MainForm mainForm = MainForm.getInstance();
        SmsMessageHandler messageHandler = new SmsMessageHandler();
        try {
            List<InboundMessage> msgList = messageHandler.readMessages();

            for (InboundMessage inboundMessage : msgList) {
                String content = inboundMessage.getText().trim();
                String identifier = content.substring(0, 1);
                int seqId = Integer.parseInt(content.substring(2).trim());
                Mother m = motherDao.getMother(seqId);

                if (identifier.equals("1") || identifier.equals("2")) {
                    mainForm.setLogText("\n\n" + new DateTime().toString());
                }

                if (identifier.equals("1")) {

                    Reminder reminder = reminderDao.getLatestReminder(m);
                    if (reminder.getStatus().equals("UNCONFIRMED")) {
                        reminder.setConfirmationArrivedOn(DateTime.now().toDate());
                        reminder.setStatus("CONFIRMED");
                        reminderDao.update(reminder);
                    }
                    mainForm.setLogText("\n1 Reminder Confirmed.");
                } else if (identifier.equals("2")) {
                    //SmsMessageHandler messageHandler = new SmsMessageHandler();
                    String r = emergencyDao.getEmergencyPhone();
                    messageHandler.setRecipient(r);

                    Emergency emergency = new Emergency();

                    emergency.setArrivedOn(new DateTime().toDate());

                    String workerName = m.getHealthWorker().getFullName();
                    String messageContent = "Emergency\n" + m.getMotherId() + "\n" + m.getFullName()
                            + "\n" + workerName + "\n" + m.getGott();
                    emergency.setContent(messageContent);
                    messageHandler.setContent(messageContent);
                    messageHandler.setStatusReportEnabled(false);
                    emergency.setMother(m);

                    emergencyDao.saveEmergency(emergency);

                    try {
                        messageHandler.sendMessage();
                        mainForm.setLogText("\n1 emergency sent to HC");
                    } catch (Exception e) {
                        mainForm.setLogText("\nError: " + "\n" + e.getMessage());
                    }
                }
View Full Code Here

        template += line1 + line2 + line3 + line4 + line5;
        template += "Reminders\n";
        template += line6 + line7;
        template += "EDD\n" + line8;
       
        SmsMessageHandler messageHandler = new SmsMessageHandler();
        messageHandler.setContent(template);
        messageHandler.setStatusReportEnabled(true);
       
        String recipient = appSettingDao.getSetting().getReportPhone();
        messageHandler.setRecipient(recipient);
        try {
            int smscCode = Integer.parseInt(messageHandler.sendMessage());
            if (smscCode > 0) {
                report.setStatus("SENT");
                reportDao.updateStatus(report.getReportId(), report.getStatus());
            }
        } catch (Exception ex) {
View Full Code Here

    LocalDate eddEth = eddGreg.withChronology(EthiopicChronology.getInstance()).toLocalDate();
    String date = eddEth.getDayOfMonth() + "/" + eddEth.getMonthOfYear() + "/" + eddEth.getYear();
    String gott = (mother.getGott() == null) ? "Urban" : mother.getGott();
    String template = "ID: " + mother.getSeqId() + "\n" + mother.getFullName() + "\n" + gott + "\nEDD: " + date;
   
        SmsMessageHandler messageHandler = new SmsMessageHandler();
    messageHandler.setContent(template);
        messageHandler.setStatusReportEnabled(false);
    HealthExtensionWorker healthWorker = mother.getHealthWorker();

        String recipient = healthWorker.getPhoneNumber();
    messageHandler.setRecipient(recipient);
    try {
            int smscCode = Integer.parseInt(messageHandler.sendMessage());
            TextMessage oldMessage = textMessageDao.getMessageInProgress(mother.getSeqId());
            if (oldMessage != null) {
                textMessageDao.changeStatus(oldMessage, "R");
            }
            TextMessage textMessage = new TextMessage();
View Full Code Here

TOP

Related Classes of org.sis.ancmessaging.server.utility.SmsMessageHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.