public JsonResult Index(string patientaccount) { string thecomment = ""; theDb = new NursingBedBoardEntities(); if (theDb.Comments.Where(p => p.AccountNumber == patientaccount).Count() != 0) { var entities = new NursingBedBoardEntities(); IQueryable<Comment> items = ( from row in entities.Comments where row.AccountNumber == patientaccount orderby row.CommentsID select row); foreach (var comments in items) { string dttime = comments.CommentDateTime.ToString("MM/dd/yy @ HH:mm"); thecomment += "<font style='color:blue'>" + GetFullName(comments.EnteredBy.ToString()) + " on " + dttime + "</font> - " + comments.CommentText.ToString() + "\r\n"; } } return Json(new { Success = true, Message = thecomment }); }
public string FlagColor(string rhospitalnumber, string raccountnumber, string unit) { using (NursingBedBoardEntities theDb = new NursingBedBoardEntities()) { // This is a flag for an empty room if (raccountnumber.Substring(0, 2) == "::") { var entities = new NursingBedBoardEntities(); string thependingcolor = ""; string thecolor = ""; DateTime thedatetime = Convert.ToDateTime("1/2/1900"); IQueryable<Notation> items = ( from row in entities.Notations where row.HospitalNumber == rhospitalnumber && row.Unit == raccountnumber.Substring(2) && row.AccountNumber == "" && (row.RoomType == null || row.RoomType == "") select row); try { foreach (var color in items) { if (color.AlertColor == "yellow") thependingcolor = "yellow"; thedatetime = Convert.ToDateTime(color.EnteredDateTime); } thecolor = thependingcolor; if (IsPendingAdmission(rhospitalnumber, unit, "") >= thedatetime) { thecolor = "yellow"; } return thecolor.ToString(); } catch { return ""; } } // This is a flag for a patient room else if (theDb.Notations.Where(p => p.HospitalNumber == rhospitalnumber && p.Unit == unit).Count() != 0) { var entities = new NursingBedBoardEntities(); string thecolor = ""; DateTime thedatetime = Convert.ToDateTime("1/2/1900"); IQueryable<Notation> items = ( from row in entities.Notations where row.HospitalNumber == rhospitalnumber && row.Unit == unit && (row.RoomType == null || row.RoomType == "") select row); foreach (var color in items) { thecolor = color.AlertColor; thedatetime = Convert.ToDateTime(color.EnteredDateTime); } if (IsPendingAdmission(rhospitalnumber, unit, raccountnumber) >= thedatetime) { thecolor = "yellow"; } return thecolor.ToString(); } else { return ""; } } }
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 string GetFlagComment(string hospitalnumber, string unit, string accountnumber) { using (NursingBedBoardEntities entities = new NursingBedBoardEntities()) { IQueryable<Notation> items = ( from row in entities.Notations where row.HospitalNumber == hospitalnumber && row.Unit == unit && (row.RoomType == null || row.RoomType == "") orderby row.EnteredDateTime descending select row); foreach (var color in items) { if (color.AlertColor == "yellow" && color.AccountNumber == accountnumber) { try { return color.CommentText.ToString(); } catch { return ""; } } else if (color.AlertColor == "yellow" && accountnumber == "") { return color.CommentText.ToString(); } else { return ""; } } return ""; } }
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 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 }); } }
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 }); } }
public string LastComment(string rhospitalnumber, string raccountnumber) { using (NursingBedBoardEntities theDb = new NursingBedBoardEntities()) { // this is for a comment on an empty room if (raccountnumber.Substring(0, 2) == "::") { var entities = new NursingBedBoardEntities(); string thecomment = ""; IQueryable<Comment> items = ( from row in entities.Comments where row.HospitalNumber == rhospitalnumber && row.Unit == raccountnumber.Substring(2) && row.AccountNumber == "" orderby row.CommentsID select row); try { foreach (var comment in items) { string dttime = comment.CommentDateTime.ToString("MM/dd/yy @ HH:mm"); thecomment = "Cmt By: " + GetFullName(comment.EnteredBy.ToString()) + " on " + dttime + " - " + comment.CommentText.ToString(); } return thecomment.ToString(); } catch { return ""; } } // this would leave a comment on a patient else if (theDb.Comments.Where(p => p.HospitalNumber == rhospitalnumber && p.AccountNumber == raccountnumber).Count() != 0) { var entities = new NursingBedBoardEntities(); string thecomment = ""; IQueryable<Comment> items = ( from row in entities.Comments where row.HospitalNumber == rhospitalnumber && row.AccountNumber == raccountnumber orderby row.CommentsID select row); foreach (var comment in items) { string dttime = comment.CommentDateTime.ToString("MM/dd/yy @ HH:mm"); thecomment = "Cmt By: " + GetFullName(comment.EnteredBy.ToString()) + " on " + dttime + " - " + comment.CommentText.ToString(); } return thecomment.ToString(); } else { return ""; } } }
public Boolean IsUnavailable(string hospitalnumber, string unit) { using (NursingBedBoardEntities entities = new NursingBedBoardEntities()) { IQueryable<Notation> items = ( from row in entities.Notations where row.HospitalNumber == hospitalnumber && row.Unit == unit && row.AccountNumber == "" && row.RoomType == "unavailable" select row); foreach (var color in items) { return true; } return false; } }
public DateTime IsPendingAdmission(string hospitalnumber,string unit, string accountnumber) { using (NursingBedBoardEntities entities = new NursingBedBoardEntities()) { IQueryable<Notation> items = ( from row in entities.Notations where row.HospitalNumber == hospitalnumber && row.Unit == unit && (row.RoomType == null || row.RoomType == "") orderby row.EnteredDateTime descending select row); foreach (var color in items) { if (color.AlertColor == "yellow" && color.AccountNumber == accountnumber) { return Convert.ToDateTime(color.EnteredDateTime); } else if (color.AlertColor == "yellow" && accountnumber == "") { return Convert.ToDateTime(color.EnteredDateTime); } else { return Convert.ToDateTime("1/1/1900"); } } return Convert.ToDateTime("1/1/1900"); } }
public ActionResult Index(string id /* Location -> Name */) { IsAuthorizedEnum isAuthorized = IsAuthorized(); bool update = false; Location location; if (isAuthorized == IsAuthorizedEnum.Unauthorized) { Response.StatusCode = 401; return Json(new { Error = "Unauthorized" }, JsonRequestBehavior.AllowGet); } if (!_locations.ContainsKey(isAuthorized)) _locations.Add(isAuthorized, new List<Location>()); if (_locations[isAuthorized].Where(o => o.Name == id).Count() == 0) { update = true; } else if (DateTime.Now.Subtract(_locations[isAuthorized].Where(o => o.Name == id).First().LastUpdate) >= _locationTimespan) { update = true; } if (update) { location = new Location(id); using (var entities = new NursingBedBoardEntities()) { if (String.IsNullOrEmpty(id)) return null; List<Board> items = ( from row in entities.Boards where row.Location == id orderby row.Location, row.Department, row.Unit.Length, row.Unit select row).ToList(); var departments = items.Where(o => o.Location == id).Select(o => o.Department).Distinct(); foreach (string departmentName in departments) { Department department = new Department(departmentName); var units = items.Where(o => o.Location == id && o.Department == departmentName).Select(o => o.Unit).Distinct(); foreach (string unitName in units) { Unit unit; string roomtype = ""; var item = items.Where(o => o.Location == id && o.Department == departmentName && o.Unit == unitName) .Select(o => o).FirstOrDefault(); if (IsIsolation(item.HospitalNumber, item.Unit)) { roomtype = "isolation"; } if (IsUnavailable(item.HospitalNumber, item.Unit)) { roomtype = "unavailable"; } DateTime PendingDate; string elapsedtime = ""; try { if (item.DischargeStatusDateTime.Length > 1) { PendingDate = Convert.ToDateTime(item.DischargeStatusDateTime); TimeSpan ts = DateTime.Now.Subtract(PendingDate); if (ts.Days > 0) { elapsedtime = string.Format("{0}D {1:00}:{2:00}", ts.Days, ts.Hours, ts.Minutes); } else { elapsedtime = string.Format("{0:00}:{1:00}", ts.Hours, ts.Minutes); } } } catch { //Nothing, it is null } if (string.IsNullOrEmpty(item.AccountNumber)) { unit = new Unit(unitName, FlagColor(item.HospitalNumber, "::" + unitName, unitName), roomtype, GetFlagComment(item.HospitalNumber, unitName, "")); if (isAuthorized == IsAuthorizedEnum.Staffing || isAuthorized == IsAuthorizedEnum.ViewOnly) { unit.Patient = new Patient(item.Name, item.Gender, item.Age, item.ATP, item.DischargeStatus, item.DischargeStatusComment, item.Description, "", LastComment(item.HospitalNumber, "::" + unitName), item.IsClean, elapsedtime); } else { unit.Patient = new Patient("", "", "", "", "", "", "", "", "", item.IsClean, elapsedtime); } } else { if (isAuthorized == IsAuthorizedEnum.Staffing || isAuthorized == IsAuthorizedEnum.ViewOnly) { if (FlagColor(item.HospitalNumber, item.AccountNumber, item.Unit).Length == 0) { unit = new Unit(unitName, "", roomtype, GetFlagComment(item.HospitalNumber, unitName, "")); } else { unit = new Unit(unitName, FlagColor(item.HospitalNumber, item.AccountNumber, item.Unit), roomtype, GetFlagComment(item.HospitalNumber, item.Unit, item.AccountNumber)); } unit.Patient = new Patient(item.Name, item.Gender, item.Age, item.ATP, item.DischargeStatus, item.DischargeStatusComment, item.Description, item.AccountNumber.ToString(), LastComment(item.HospitalNumber, item.AccountNumber.ToString()), item.IsClean, elapsedtime); } else { unit = new Unit(unitName, "", roomtype, ""); if (item.Name.Length > 1) { unit.Patient = new Patient("Occupied", "", "", "", item.DischargeStatus, "", "", "", "", item.IsClean, elapsedtime); } else { unit.Patient = new Patient("", "", "", "", "", "", "", "", "", item.IsClean, elapsedtime); } } } // Check if dirty and if notification needs to be sent. DirtyNotification(unitName, item.HospitalNumber, item.Department); department.Units.Add(unit); } location.Departments.Add(department); } } location.LastUpdate = DateTime.Now; // Replace/Add the latest data in our static list. if (_locations[isAuthorized].Where(o => o.Name == id).Count() != 0) _locations[isAuthorized][_locations[isAuthorized].IndexOf(_locations[isAuthorized].Where(o => o.Name == id).First())] = location; else _locations[isAuthorized].Add(location); } else { location = _locations[isAuthorized].Where(o => o.Name == id).First(); } return Json(location, JsonRequestBehavior.AllowGet); }