//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"); }
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)); }
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()); }
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"); }
public static bool ParseCsv(HttpPostedFileBase upload, long pharmacyId) { //Check if valid file was uploaded if (upload != null && upload.ContentLength > 0 && upload.FileName.EndsWith(".csv")) { //Convert binary file received from request into text var textdata = string.Empty; using (BinaryReader b = new BinaryReader(upload.InputStream)) { var binData = b.ReadBytes(upload.ContentLength); textdata = Encoding.UTF8.GetString(binData); } //Get list of patients from database for comparison var patients = new Dictionary <string, Patient>(); var patientlist = DatabasePatientService.GetAll(pharmacyId); foreach (var p in patientlist) { p.LoadUserData(); patients.Add(p.PersonCode, p); } //Interate over each line of text in the file var text = new StringReader(textdata); var line = string.Empty; //Remove headers from file text.ReadLine(); while ((line = text.ReadLine()) != null) { var row = line.Split(','); //Check if patient exists try { var dateNow = DateTime.Now; Patient patient = new Patient() { PersonCode = row[0], FirstName = row[1], LastName = row[2], DateOfBirth = DateTime.ParseExact(row[3], "yyyyMMdd", null), Phone = row[5], Email = row[6], PharmacyId = pharmacyId }; if (patients.ContainsKey(row[0])) { //Update patient var oldPatient = patients[row[0]]; patient.UserId = oldPatient.UserId; patient.PatientId = patients[row[0]].PatientId; patient.Type = oldPatient.Type; patient.UserLogin = oldPatient.UserLogin; patient.ContactMethod = oldPatient.ContactMethod; patient.PreferedContactTime = oldPatient.PreferedContactTime; patient.SendBirthdayMessage = oldPatient.SendBirthdayMessage; patient.SendRefillMessage = oldPatient.SendRefillMessage; DatabaseUserService.Update(patient); DatabasePatientService.Update(patient); DatabaseUserService.Enable(patient.PatientId); DatabasePatientService.Enable(patient.PatientId); } else { //Create patient patient.PreferedContactTime = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 15, 0, 0); patient.UserId = DatabaseUserService.Insert(patient); patient.PatientId = DatabasePatientService.Insert(patient); } //Check if prescription exists try { var prescriptionId = Convert.ToInt32(row[8]); var prescription = new Prescription() { PrescriptionDateFilled = DateTime.ParseExact(row[7], "yyyyMMdd", null), PrescriptionNumber = prescriptionId, PrescriptionId = prescriptionId, PrescriptionDaysSupply = Convert.ToInt32(row[9]), PrescriptionRefills = Convert.ToInt32(row[10]), PrescriptionUpc = row[11], PrescriptionName = row[12], PatientId = patient.PatientId }; DatabasePrescriptionService.InsertOrUpdate(prescription); if (DatabaseRefillService.GetByPrescriptionId(prescription.PrescriptionId) == null) { var refill = new Refill(prescription) { }; DatabaseRefillService.Insert(refill); } } catch (Exception e) { //Ignore prescriptions that fail the model building } } catch (Exception e) { //Do not add patients which fail the model building } } return(true); } return(false); }