/**
         * Sets a notification as responded to. Since the only response requried
         * by an email, other than ignoring it, is YES it simply starts a refill
         *
         * @receives - refill response link from sent emails
         */
        public ActionResult Respond()
        {
            try {
                var otp          = DatabaseEmailOtpService.GetByCode(RouteData.Values["otp"].ToString());
                var notification = DatabaseNotificationService.GetById(otp.NotificationId);
                var patient      = DatabasePatientService.GetById(notification.PatientId);

                if (otp.IsActive())
                {
                    if (patient.object_active)
                    {
                        notification.NotificationResponse = "Refill";
                        DatabaseNotificationService.Update(notification);

                        var refill = DatabaseRefillService.GetByPrescriptionId(DatabasePrescriptionService.GetByPatientId(patient.PatientId).PrescriptionId);
                        refill.RefillIt = true;
                        DatabaseRefillService.Update(refill);

                        DatabaseEmailOtpService.Disable(otp.Id);

                        return(RefillSuccess());
                    }
                    else
                    {
                        return(RefillFailure());
                    }
                }
                else
                {
                    return(ExpiredOtp());
                }
            } catch (Exception) {
                return(BadLink());
            }
        }
        /**
         * Modifies a patients contact preferences to request not to be
         * contacted again.
         *
         * @receives - unsubscribe request from the bottom of notification based emails
         */
        public ActionResult Unsubscribe()
        {
            try {
                var otp          = DatabaseEmailOtpService.GetByCode(RouteData.Values["otp"].ToString());
                var notification = DatabaseNotificationService.GetById(otp.NotificationId);
                var patient      = DatabasePatientService.GetById(notification.PatientId);

                if (otp.IsActive())
                {
                    if (patient.object_active)
                    {
                        patient.ContactMethod = Patient.PrimaryContactMethod.OptOut;
                        DatabasePatientService.Update(patient);

                        notification.NotificationResponse = "Unsubscribe";
                        DatabaseNotificationService.Update(notification);

                        DatabaseEmailOtpService.Disable(otp.Id);

                        return(UnsubscribeSuccess());
                    }
                    else
                    {
                        return(UnsubscribeFailure());
                    }
                }
                else
                {
                    return(ExpiredOtp());
                }
            } catch (Exception) {
                return(BadLink());
            }
        }
Exemple #3
0
        public ActionResult SendNotification(long id)
        {
            var n = DatabaseNotificationService.GetById(id);

            NotificationSending.NotificationSender.SendNotification(n);
            return(Redirect("/Notification/NotificationList"));
        }
Exemple #4
0
        public ActionResult Refill(long id)
        {
            var      n   = DatabaseNotificationService.GetById(id);
            var      pat = DatabasePatientService.GetById(n.PatientId);
            Pharmacy p   = DatabasePharmacyService.GetById(pat.PharmacyId);

            p.GetTemplates();
            string message = p.GetRefillTemplate().TemplatePhone;
            var    xml     = new XDocument(
                new XElement("Response",
                             new XElement("Gather",
                                          new XAttribute("timeout", "10"),
                                          new XAttribute("numDigits", "1"),
                                          new XAttribute("action", "https://ocharambe.localtunnel.me/twilioresponse/refillresponse/" + id),
                                          new XElement("Say",
                                                       message
                                                       )
                                          ),
                             new XElement("Say",
                                          "We didn't recieve any input, Goodbye!")
                             )
                );

            return(new XmlActionResult(xml));
        }
Exemple #5
0
        public ActionResult RecallResponse(long id)
        {
            var    notification = DatabaseNotificationService.GetById(id);
            var    user         = DatabasePatientService.GetById(notification.PatientId);
            string digits       = Request["Digits"];

            System.Diagnostics.Debug.WriteLine(digits);
            if (digits.Contains("9"))
            {
                var xml = new XDocument(
                    new XElement("Response",
                                 new XElement("Say",
                                              "Connecting you to a pharmacist."),
                                 new XElement("Dial",
                                              DatabasePharmacyService.GetById(user.PharmacyId).PharmacyPhone)
                                 )
                    );
                return(new XmlActionResult(xml));
            }
            else
            {
                var xml = new XDocument(
                    new XElement("Response",
                                 new XElement("Say",
                                              "Unrecognized Input, Goodbye")
                                 )
                    );
                return(new XmlActionResult(xml));
            }
        }
Exemple #6
0
        public ActionResult RefillResponse(long id)
        {
            string digits = Request["Digits"];

            System.Diagnostics.Debug.WriteLine(Request["To"]);
            var notification = DatabaseNotificationService.GetById(id);
            var user         = DatabasePatientService.GetById(notification.PatientId);

            if (digits.Contains("1"))
            {
                XDocument xml = null;
                if (user != null)
                {
                    notification.NotificationResponse = Request["digits"];
                    DatabaseNotificationService.Update(notification);
                    var refill = DatabaseRefillService.GetByPrescriptionId(DatabasePrescriptionService.GetByPatientId(user.PatientId).PrescriptionId);
                    refill.RefillIt = true;
                    DatabaseRefillService.Update(refill);
                    xml = new XDocument(
                        new XElement("Response",
                                     new XElement("Say",
                                                  "Your refill will be ready shortly.")
                                     )
                        );
                }
                else
                {
                    xml = new XDocument(
                        new XElement("Response",
                                     new XElement("Say",
                                                  "couldn't find refill")
                                     )
                        );
                }
                return(new XmlActionResult(xml));
            }
            else if (digits.Contains("9"))
            {
                var xml = new XDocument(
                    new XElement("Response",
                                 new XElement("Say",
                                              "Connecting you to a pharmacist."),
                                 new XElement("Dial",
                                              DatabasePharmacyService.GetById(user.PharmacyId).PharmacyPhone)
                                 )
                    );
                return(new XmlActionResult(xml));
            }
            else
            {
                var xml = new XDocument(
                    new XElement("Response",
                                 new XElement("Say",
                                              "Unrecognized Input, Goodbye")
                                 )
                    );
                return(new XmlActionResult(xml));
            }
        }
Exemple #7
0
        public ActionResult Recall(long id)
        {
            var n   = DatabaseNotificationService.GetById(id);
            var xml = new XDocument(
                new XElement("Response",
                             new XElement("Gather",
                                          new XAttribute("timeout", "10"),
                                          new XAttribute("numDigits", "1"),
                                          new XAttribute("action", "https://ocharambe.localtunnel.me/twilioresponse/recallresponse/" + id),
                                          new XElement("Say",
                                                       n.NotificationMessage
                                                       )
                                          ),
                             new XElement("Say",
                                          "Goodbye!")
                             )
                );

            return(new XmlActionResult(xml));
        }