public JsonResult ClearIt(string unit) { theDb = new NursingBedBoardEntities(); var query = from p in theDb.Comments where p.Unit == unit && p.AccountNumber == "" select p; foreach (Comment c in query) { LogIt(c.HospitalNumber.ToString(), c.Unit.ToString(), c.AccountNumber.ToString(), "CCLEAR", "", ""); theDb.DeleteObject(c); } theDb.SaveChanges(); return Json(new { Success = true, //Message = thecomment }); }
public void LogIt(string hospitalnumber, string unit, string accountnumber, string logcode, string changemade, string commentsmade) { NursingBedBoardEntities thedb = new NursingBedBoardEntities(); dblog = new Log(); dblog.AccountNumber = accountnumber; dblog.ChangeMade = changemade; dblog.CommentsMade = commentsmade; dblog.EnteredDateTime = DateTime.Now; dblog.HospitalNumber = hospitalnumber; dblog.LogCode = logcode; dblog.Unit = unit; dblog.WhoMade = Request.ServerVariables.Get("AUTH_USER"); thedb.Logs.AddObject(dblog); thedb.SaveChanges(); }
public JsonResult RoomDirty(string unit) { using (NursingBedBoardEntities theDb = new NursingBedBoardEntities()) { if (theDb.Boards.Where(a => a.Unit == unit).Count() != 0) { // Change IsClean flag to 1 (true) var query2 = from p in theDb.Boards where p.Unit == unit select p; string hostpitalnumber = ""; string unitnum = ""; foreach (Board c in query2) { hostpitalnumber = c.HospitalNumber; unitnum = c.Unit; c.IsClean = false; c.DirtyNotification = null; } LogIt(hostpitalnumber, unitnum, "", "BDIRTY", "Room Is Dirty", ""); } theDb.SaveChanges(); //Return a success return Json(new { Success = true, //Message = "Data saved Successfully " + patientname + ' ' + unit + ' ' + comment + ' ' + color }); } }
private void DirtyNotification(string UnitName, string HospitalNumber, string Location) { var entities = new NursingBedBoardEntities(); var query = from row in entities.Boards where row.Unit == UnitName && row.HospitalNumber == HospitalNumber && row.IsClean == false && row.Name == "" select row; try { Boolean SendIt = false; foreach (var note in query) { if (!note.DirtyNotification.HasValue) { SendIt = true; } else if (note.DirtyNotification.Value.AddHours(4) < DateTime.Now) { SendIt = true; } if (SendIt) { // The email needs to be sent // The DirtyNotification needs to be set // Event needs to be logged if ((DateTime.Today.DayOfWeek != DayOfWeek.Saturday && DateTime.Today.DayOfWeek != DayOfWeek.Sunday) || !(DateTime.Now.Hour >= 0 && DateTime.Now.Hour < 6)) { if (HospitalNumber == "1") { MailAddress from = new MailAddress("*****@*****.**"); MailAddress to = new MailAddress(((HospitalNumber == "1") ? "*****@*****.**" : "*****@*****.**")); MailMessage mail = new MailMessage(from, to); mail.Subject = "Dirty room on " + Location; mail.Body = "Room: " + UnitName + Environment.NewLine + ((HospitalNumber == "1") ? " West Campus" : " East Campus"); SmtpClient client = new SmtpClient("alert.yrmc.org"); try { var entities2 = new NursingBedBoardEntities(); var query2 = from row in entities2.Boards where row.Unit == UnitName && row.HospitalNumber == HospitalNumber && row.IsClean == false select row; foreach (var rec in query2) { rec.DirtyNotification = DateTime.Now; } entities2.SaveChanges(); client.Send(mail); LogIt(HospitalNumber, UnitName, "", "NOTIFY", "Dirty room notification", ""); } catch (Exception e) { throw e; } } } } } } catch { } }
public JsonResult RoomClean(string unit) { using (NursingBedBoardEntities theDb = new NursingBedBoardEntities()) { if (theDb.Boards.Where(a => a.Unit == unit).Count() != 0) { // Change IsClean flag to 1 (true) var query2 = from p in theDb.Boards where p.Unit == unit select p; string hostpitalnumber = ""; string unitnum = ""; string department = ""; foreach (Board c in query2) { hostpitalnumber = c.HospitalNumber; unitnum = c.Unit; department = c.Department; c.IsClean = true; c.DirtyNotification = null; } LogIt(hostpitalnumber, unitnum, "", "BCLEAN", "Room Is Clean", ""); MailAddress from = new MailAddress("*****@*****.**"); MailAddress to = new MailAddress("*****@*****.**"); MailMessage mail = new MailMessage(from, to); mail.Subject = "Room cleaned on " + department; mail.Body = "Room: " + unitnum + Environment.NewLine + ((hostpitalnumber == "1") ? " West Campus" : " East Campus"); SmtpClient client = new SmtpClient("alert.yrmc.org"); client.Send(mail); } theDb.SaveChanges(); //Return a success return Json(new { Success = true, //Message = "Data saved Successfully " + patientname + ' ' + unit + ' ' + comment + ' ' + color }); } }