Beispiel #1
0
        public ActionResult SavePharmacist(Pharmacist m, String command)
        {
            // if id's are default, get actual id's for the (new) pharmacist
            // use sql to save pharmacist to db
            if (m.PharmacistId == 0)
            {
                m.Type = Models.User.UserType.Pharmacist;
                var phid = DatabaseUserService.Insert(m);
                m.UserId       = phid;
                m.PharmacistId = DatabasePharmacistService.Insert(m);
                var login = new Login();
                login.LoginToken = "";
                login.UserId     = m.UserId;
                login.SetPassword(Login.GetUniqueKey(32));
                DatabaseLoginService.Insert(login);
                EmailService.SendReset(m);
            }
            else
            {
                DatabaseUserService.Update(m);
                DatabasePharmacistService.Update(m);
            }

            if (DatabaseUserService.GetById((long)Session["user_id"]).Type == Models.User.UserType.PPOkAdmin)
            {
                return(RedirectToAction("AddorEditPharmacy", "PpokAdmin", new { id = m.PharmacyId }));
            }
            return(RedirectToAction("Admin", "Pharmacy"));
        }
Beispiel #2
0
        //Sends test emails with working callbacks to the email specified
        public string SendTestEmail()
        {
            var u  = new User();
            var p  = new Patient();
            var n  = new Notification();
            var pr = new Prescription();
            var r  = new Refill();

            u.Email     = "*****@*****.**";     // PUT YOUR EMAIL HERE TO TEST
            u.FirstName = "Test";
            u.LastName  = "User";
            u.Phone     = "+14055555555";
            u.UserId    = DatabaseUserService.Insert(u);

            p.UserId              = u.UserId;
            p.PharmacyId          = 1;
            p.DateOfBirth         = DateTime.Now;
            p.PreferedContactTime = DateTime.Now;
            p.ContactMethod       = Patient.PrimaryContactMethod.Email;
            p.PersonCode          = "0";
            p.SendBirthdayMessage = true;
            p.SendRefillMessage   = true;
            p.PatientId           = DatabasePatientService.Insert(p);

            pr.PatientId = p.PatientId;
            pr.PrescriptionDaysSupply = 30;
            pr.PrescriptionRefills    = 3;
            pr.PrescriptionName       = "Tylenol";
            pr.PrescriptionNumber     = 1;
            pr.PrescriptionUpc        = "ABC123";
            pr.PrescriptionDateFilled = DateTime.Now;
            pr.PrescriptionId         = DatabasePrescriptionService.Insert(pr);

            r.RefillIt       = false;
            r.PrescriptionId = pr.PrescriptionId;
            r.Refilled       = false;
            r.RefillDate     = DateTime.Now;
            r.RefillId       = DatabaseRefillService.Insert(r);

            n.PatientId           = p.PatientId;
            n.Type                = Notification.NotificationType.Refill;
            n.NotificationMessage = "This is a test email for a refill";
            n.ScheduledTime       = DateTime.Now;
            n.SentTime            = null;
            n.Sent                = false;
            n.NotificationId      = DatabaseNotificationService.Insert(n);


            EmailService.SendNotification(n);
            EmailService.SendReset(u);

            return("Sent an notification and reset email to test account");
        }
Beispiel #3
0
        public ActionResult UploadRecalls(HttpPostedFileBase upload, string recallMessage)
        {
            var pharm = DatabasePharmacyService.GetById((long)Session["pharm_id"]);

            pharm.GetTemplates();
            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    if (upload.FileName.EndsWith(".csv"))
                    {
                        var stream   = upload.InputStream;
                        var csvTable = new DataTable();
                        using (var csvReader =
                                   new CsvReader(new StreamReader(stream), true))
                        {
                            csvTable.Load(csvReader);
                        }
                        foreach (DataRow row in csvTable.Rows)
                        {
                            var patient = new Patient {
                                FirstName           = row["PatientFirstName"].ToString(),
                                LastName            = row["PatientLastName"].ToString(),
                                Phone               = row["Phone"].ToString(),
                                PharmacyId          = 1,
                                DateOfBirth         = DateTime.Now,
                                Email               = "*****@*****.**",
                                ContactMethod       = Patient.PrimaryContactMethod.Call,
                                PreferedContactTime = DateTime.Now,
                                PersonCode          = row["PersonCode"].ToString()
                            };
                            var id = DatabaseUserService.Insert(patient);
                            patient.UserId    = id;
                            patient.PatientId = DatabasePatientService.Insert(patient);
                            var notification = new Notification(DateTime.Now, patient.PatientId, Notification.NotificationType.Recall, recallMessage);
                            DatabasePatientService.Disable(patient.PatientId);
                            DatabaseNotificationService.Insert(notification);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("File", "This file format is not supported");
                        return(View(pharm));
                    }
                }
                else
                {
                    ModelState.AddModelError("File", "Please Upload Your file");
                }
            }
            return(View(pharm));
        }
Beispiel #4
0
        public string AddFakeLogin(long pid)
        {
            var pharmAdmin = new Pharmacist {
                FirstName  = "Pharma",
                LastName   = "cist",
                Phone      = "+19999999993",
                Email      = "*****@*****.**",
                PharmacyId = pid,
                UserId     = 1,
                IsAdmin    = true,
                Type       = Models.User.UserType.Pharmacist
            };

            pharmAdmin.UserId = DatabaseUserService.Insert(pharmAdmin);
            var login = new Login {
                LoginId    = 1,
                UserId     = pharmAdmin.UserId,
                LoginToken = ""
            };

            login.SetPassword("harambe");
            DatabaseLoginService.Insert(login);

            DatabasePharmacistService.Insert(pharmAdmin);

            var ppokAdmin = new User {
                LastName  = "dmin",
                FirstName = "PPOk A",
                Type      = Models.User.UserType.PPOkAdmin,
                Phone     = "+19999999998",
                Email     = "*****@*****.**"
            };

            ppokAdmin.UserId = DatabaseUserService.Insert(ppokAdmin);

            var login2 = new Login {
                UserId     = ppokAdmin.UserId,
                LoginToken = ""
            };

            login2.SetPassword("harambe");

            DatabaseLoginService.Insert(login2);

            return("sucess <br/> Pharm: username: [email protected] password: harambe <br/> Admin: username: [email protected] password: harambe");
        }
Beispiel #5
0
        public ActionResult SavePatient(Patient m, String command)
        {
            // if id's are default, get actual id's for the (new) patient
            // use sql to save patient to db

            if (m.PatientId == 0)
            {
                m.PharmacyId = (long)Session["pharm_id"];
                var pid = DatabaseUserService.Insert((User)m);
                m.UserId = pid;
                DatabasePatientService.Insert(m);
            }
            else
            {
                DatabaseUserService.Update(m);
                DatabasePatientService.Update(m);
            }

            return(PatientListView());
        }
Beispiel #6
0
        public string AddFakePatient(long pid)
        {
            var pat = new Patient {
                ContactMethod       = Patient.PrimaryContactMethod.Text,
                FirstName           = "John",
                LastName            = "Doe",
                PersonCode          = "1",
                DateOfBirth         = System.DateTime.Now,
                Phone               = "+18065703539",
                PharmacyId          = pid,
                PreferedContactTime = System.DateTime.Now,
                SendRefillMessage   = true,
                SendBirthdayMessage = true
            };
            var id = DatabaseUserService.Insert(pat);

            pat.UserId = id;
            var patId = DatabasePatientService.Insert(pat);

            this.AddFakePresRefillNotif(patId);
            return("success");
        }