Ejemplo n.º 1
0
        public static void SavePreferences(PatientLogModel db, string controller, string viewModel, Dictionary <string, string> values)
        {
            if (values.Count > 0)
            {
                string userID = HubSecurity.getLoggedInUserID();
                foreach (KeyValuePair <string, string> entry in values)
                {
                    UserPreference preference = (from u in db.UserPreferences where u.Controller == controller && u.ViewModel == viewModel && u.FilterName == entry.Key && u.UserID == userID select u).FirstOrDefault();

                    //If user preference query returns a value, update it. If not, create a new entry in the db
                    if (preference != null)
                    {
                        preference.FilterValue     = entry.Value;
                        db.Entry(preference).State = EntityState.Modified;
                    }
                    else
                    {
                        preference             = new UserPreference();
                        preference.Controller  = controller;
                        preference.ViewModel   = viewModel;
                        preference.FilterName  = entry.Key;
                        preference.FilterValue = entry.Value;
                        preference.UserID      = userID;
                        db.UserPreferences.Add(preference);
                    }
                }
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        //private static string getController()
        //{
        //    try
        //    {
        //        return HttpContext.Current.Request.FilePath.Substring(1, HttpContext.Current.Request.FilePath.LastIndexOf("/") - 1);
        //    }
        //    catch (Exception ex)
        //    {
        //        return "getControllerErrored";
        //    }

        //}

        //private static string getPage()
        //{
        //    try
        //    {
        //        return HttpContext.Current.Request.FilePath.Substring(HttpContext.Current.Request.FilePath.LastIndexOf("/") + 1);
        //    }
        //    catch (Exception ex)
        //    {
        //        return "getPageErrored";
        //    }
        //}
        public static int CreateFavorite(PatientLogModel db, string users, string hospitals, string types, string name, bool isDefault)
        {
            ScheduleFavorite fave = new ScheduleFavorite();

            fave.Users    = users;
            fave.Hospital = hospitals;
            fave.Types    = types;
            fave.Name     = name;
            fave.Default  = isDefault;
            fave.UserID   = HubSecurity.getLoggedInUserID();
            //If this entry is set to be default, make sure all current ones get default put to false
            if (isDefault)
            {
                List <int> ids = (from f in db.ScheduleFavorites where f.UserID == fave.UserID select f.ID).ToList();
                foreach (int id in ids)
                {
                    ScheduleFavorite f = db.ScheduleFavorites.Find(id);
                    f.Default         = false;
                    db.Entry(f).State = EntityState.Modified;
                }
            }
            db.ScheduleFavorites.Add(fave);
            db.SaveChanges();
            return(fave.ID);
        }
Ejemplo n.º 3
0
        //public static List<string> getArcturusPCPs(PatientLogModel db)
        //{
        //    var returnList = from u in db.Users
        //                     join ud in db.UserDetails on u.UserID equals ud.UserID
        //                     where (ud.UserType == "RefPhy") && (from rp in db.RefPractUser join prac in db.ReferringPractices on rp.PracID equals prac.PracID where prac.LegacyShortName.StartsWith("ARCH") select rp.RefPracUser).Contains(ud.UserID)
        //                     orderby u.LastName
        //                     select new { Value = (u.LastName + ", " + u.FirstName) };

        //    return returnList.ToList();
        //}
        //Returns JSON list of PCPs that match the specified site
        //public static IQueryable< jsonPCP(string site)
        //{
        //    var query = from u in db.Users
        //                join ud in db.UserDetails on u.UserID equals ud.UserID
        //                where (ud.UserType == "RefPhy") && (ud.DefaultHospital == site)
        //                orderby u.LastName
        //                select new { Value = (u.LastName + ", " + u.FirstName) };

        //    return Json(query, JsonRequestBehavior.AllowGet);
        //}

        ////Returns JSON list of AIMS Physicians that match the specified site
        //public ActionResult jsonAIMSPhy(string site)
        //{
        //    var query = from u in db.Users
        //                join ud in db.UserDetails on u.UserID equals ud.UserID
        //                where (ud.UserType == "AIMSPhy" && ud.Active == true) && (ud.DefaultHospital == site)
        //                orderby u.LastName
        //                select new { Text = (u.LastName + ", " + u.FirstName), Value = u.UserID };

        //    return Json(query, JsonRequestBehavior.AllowGet);
        //}

        public static string LoadPreference(PatientLogModel db, string controller, string viewModel, string filterName)
        {
            //Code already operates on null values so no casting is needed from this call
            string userID = HubSecurity.getLoggedInUserID();
            string result = (from u in db.UserPreferences where u.UserID == userID && u.Controller == controller && u.ViewModel == viewModel && u.FilterName == filterName select u.FilterValue).FirstOrDefault();

            return(result);
        }
Ejemplo n.º 4
0
        public static Dictionary <string, string> LoadPreferences(PatientLogModel db, string controller, string viewModel)
        {
            Dictionary <string, string> preferences = new Dictionary <string, string>();
            string userID = HubSecurity.getLoggedInUserID();

            preferences = (from u in db.UserPreferences where u.UserID == userID && u.Controller == controller && u.ViewModel == viewModel select new { Key = u.FilterName, Value = u.FilterValue }).ToDictionary(t => t.Key, t => t.Value);
            return(preferences);
        }
Ejemplo n.º 5
0
 public ActionResult Create(PatientLogCreateViewModel viewM)
 {
     if (ModelState.IsValid)
     {
         viewM.Patient.Physician = HubSecurity.getLoggedInUserID();
         DataSubmissions.CreatePatient(db, viewM.Patient);
         return(RedirectToAction("Index"));
     }
     return(View(viewM.Patient));
 }
Ejemplo n.º 6
0
        public static string getFavoriteDefault(PatientLogModel db)
        {
            string userID = HubSecurity.getLoggedInUserID();
            var    fav    = (from f in db.ScheduleFavorites where f.UserID == userID && f.Default == true select f.Name).FirstOrDefault();

            if (fav == null)
            {
                return("[none]");
            }
            else
            {
                return(fav.ToString());
            }
        }
Ejemplo n.º 7
0
        //private IEnumerable<PCPCommunicationManagePatient> pcpManageQueryGenerator(DateTime fromDate, DateTime toDate, List<string> selectedHosp, List<string> selectedPCP, PCPCommunicationManageViewModel.BasedOn basedOn)
        //{
        //    IEnumerable<PatientLog> query = from p in db.PatientLogs
        //                                    where (p.ServiceType == "DC - STD" || p.ServiceType == "DC - EXT") &&
        //                                    (p.ServiceDate >= fromDate && p.ServiceDate <= toDate)
        //                                    select p;

        //    if (selectedHosp.Any())
        //    {
        //        query = query.Where(h => selectedHosp.Contains(h.Hospital));
        //    }
        //    if (selectedPCP.Any())
        //    {
        //        query = query.Where(s => selectedPCP.Contains(s.ServiceType));
        //    }

        //    List<int> idList = query.Select(p => p.ID).ToList();

        //    IEnumerable<PCPCommunicationManagePatient> ret;

        //}

        private IEnumerable <PatientLog> pcpCommunicationQueryGenerator(DateTime fromDate, DateTime toDate)
        {
            string user = HubSecurity.getLoggedInUserID(); //LINQ doesn't like the function to be in the query
            IEnumerable <PatientLog> query = from d in db.PatientLogs
                                             where (d.ServiceDate >= fromDate && d.ServiceDate <= toDate) && d.Physician == user && (d.PCP_Practice != "No PCP" && d.PCP_Practice != null)
                                             select d;

            //Only select entries that are not registered in PCPCommunication
            query = query.Where(c => !db.PCPCommunications.Select(b => b.PLRecord).Contains(c.ID));

            //Only select valid fax entries
            query = query.Where(c => db.FaxServiceTypes.Select(b => b.Service).Contains(c.ServiceType));

            return(query);
        }
Ejemplo n.º 8
0
        //Returns SelectList containing practice friendly name and practice ID for value with provided practice selected
        public static SelectList getFavorites(PatientLogModel db)
        {
            string userID = HubSecurity.getLoggedInUserID();
            IQueryable <SelectListItem> practices = from f in db.ScheduleFavorites
                                                    where f.UserID == userID
                                                    select new SelectListItem {
                Value = f.ID.ToString(), Text = f.Name
            };

            List <SelectListItem> list = practices.ToList();

            //if (list.Count == 0)
            //{
            //    list.Add(new SelectListItem { Text = "", Value = "" });
            //}
            return(new SelectList(list, "Value", "Text"));
        }
Ejemplo n.º 9
0
        public ActionResult EditPreferences()
        {
            PracticeAdminEditPreferencesViewModel viewM = new PracticeAdminEditPreferencesViewModel();

            viewM.practices = DataCollections.getPractices(db, HubSecurity.getLoggedInUserID());
            if (viewM.practices.Count() > 1)
            {
                viewM.selectedPrac = DataCollections.getPractice(db, viewM.practices.Skip(1).First().Value);
            }
            else
            {
                viewM.selectedPrac = DataCollections.getPractice(db, viewM.practices.First().Value);
            }
            viewM.hidPrac     = viewM.selectedPrac.PracID.ToString();
            viewM.specialties = DataCollections.getSpecialties(db, viewM.selectedPrac.PracID);
            return(View(viewM));
        }
Ejemplo n.º 10
0
        //public static void SetDailyRepeatSchedule(PatientLogModel db, string user, string hospital, string type, DateTime start, DateTime end, int interval, DateTime repeatTo)
        //{

        //}

        public static string SetDefaultFavorite(PatientLogModel db, string id)
        {
            string userid = HubSecurity.getLoggedInUserID();
            string ret;
            int    newID = Convert.ToInt32(id);
            List <ScheduleFavorite> query = (from f in db.ScheduleFavorites where f.UserID == userid select f).ToList();

            foreach (ScheduleFavorite f in query)
            {
                f.Default         = false;
                db.Entry(f).State = EntityState.Modified;
            }
            ScheduleFavorite newD = db.ScheduleFavorites.Find(newID);

            ret                  = newD.Name;
            newD.Default         = true;
            db.Entry(newD).State = EntityState.Modified;
            db.SaveChanges();
            return(ret);
        }
Ejemplo n.º 11
0
        public static void SavePreference(PatientLogModel db, string controller, string viewModel, string filterName, string filterValue)
        {
            string         userID     = HubSecurity.getLoggedInUserID();
            UserPreference preference = (from u in db.UserPreferences where u.Controller == controller && u.ViewModel == viewModel && u.FilterName == filterName && u.UserID == userID select u).FirstOrDefault();

            //If user preference query returns a value, update it. If not, create a new entry in the db
            if (preference != null)
            {
                preference.FilterValue     = filterValue;
                db.Entry(preference).State = EntityState.Modified;
            }
            else
            {
                preference.Controller  = controller;
                preference.ViewModel   = viewModel;
                preference.FilterName  = filterName;
                preference.FilterValue = filterValue;
                preference.UserID      = userID;
                db.UserPreferences.Add(preference);
            }
            //Decided to leave this outside of the function so that it is only called once, supposed to be more efficient
            //db.SaveChanges();
        }
Ejemplo n.º 12
0
        private void sendCommunications(string ids)
        {
            List <int> listofID = new List <int>();

            string[] splitList;
            splitList = ids.Split(new char[] { ',' });

            foreach (string i in splitList)
            {
                int theID = Convert.ToInt32(i);

                //Query patient record
                PatientLog pat = db.PatientLogs.Find(theID);

                //Determine fax type from table
                string faxType = (from f in db.FaxServiceTypes
                                  where f.Service == pat.ServiceType
                                  select f.FaxType).Single() + "Notice";

                //Break apart PCP name
                string[] splitName;
                splitName = pat.PCP_Practice.Split(new char[] { ',' });
                string pcpName   = splitName[1] + " " + splitName[0];
                string firstname = splitName[1].Trim(); //LINQ doesn't like arrays, throws error
                string lastname  = splitName[0].Trim();
                string pcpID     = (from u in db.Users where u.FirstName == firstname && u.LastName == lastname select u.UserID).Single();

                //Get practice info of PCP, default to AIMS otherwise
                ReferringPractice prac = new ReferringPractice();
                try
                {
                    prac = (from p in db.ReferringPractices
                            join r in db.RefPracUsers on p.PracID equals r.PracID
                            where r.UserID == pcpID
                            select p).Single();
                }
                catch
                {
                    prac.Fax             = "248-354-4807";
                    prac.FaxNotification = true;
                }

                //Create new reportviewer object and set parameters
                ReportViewer report = new ReportViewer();
                report.ProcessingMode         = ProcessingMode.Local;
                report.LocalReport.ReportPath = Server.MapPath("~") + "AdDisNotice\\" + faxType + pat.Hospital + ".rdlc";

                //Cannot perform ToShortDateString on pat.ServiceDate because of DateTime? type
                DateTime thed = new DateTime();
                thed = Convert.ToDateTime(pat.ServiceDate);
                DateTime birth = new DateTime();

                //Null values will cause the reportviewer control to error out
                try
                {
                    birth = Convert.ToDateTime(pat.DOB);
                }
                catch
                {
                    birth = DateTime.Parse("1/1/1900");
                }
                if (pat.PatientName == null)
                {
                    pat.PatientName = "";
                }
                if (pat.Comments == null)
                {
                    pat.Comments = "";
                }
                if (pat.MRN_FIN == null)
                {
                    pat.MRN_FIN = "";
                }

                ReportParameter dateparam      = new ReportParameter("Date", thed.ToShortDateString());
                ReportParameter faxparam       = new ReportParameter("Fax", prac.Fax);
                ReportParameter faxtoparam     = new ReportParameter("FaxTo", pcpName);
                ReportParameter dischargeparam = new ReportParameter("DischargeDate", thed.ToShortDateString());
                ReportParameter patientparam   = new ReportParameter("Patient", pat.PatientName);
                ReportParameter treatmentparam = new ReportParameter("Treatment", pat.Comments);
                ReportParameter mrnparam       = new ReportParameter("MRN", pat.MRN_FIN);
                ReportParameter physicianparam = new ReportParameter("Physician", HubSecurity.getLoggedInDisplayName());
                ReportParameter dobparam       = new ReportParameter("DOB", birth.ToShortDateString());

                ReportParameterCollection theparams = new ReportParameterCollection()
                {
                    dateparam, faxparam, faxtoparam, dischargeparam, patientparam, treatmentparam, mrnparam, physicianparam, dobparam
                };
                report.LocalReport.SetParameters(theparams);
                report.LocalReport.Refresh();

                string notificationTypes = "";
                if (prac.FaxNotification == true)
                {
                    notificationTypes += "Fax;";
                }
                if (prac.EmailNotification == true)
                {
                    notificationTypes += "Email;";
                }

                GenerateComms gcomm = new GenerateComms();
                gcomm.SendFax(faxType, report, FAX_FOLDER, prac.Fax, pat.Hospital, HubSecurity.getLoggedInUserID(), pcpID, pcpName,
                              pat.ID, pat.PatientName, pat.Comments, "", notificationTypes, birth.ToShortDateString(),
                              prac.PDFPassword, pat.Hospital + faxType, prac.Email, "");
            }
        }
Ejemplo n.º 13
0
        public JsonResult jsonSubmitSpecialtiesAll(List <RefPracSpecialty> specialties)
        {
            DataSubmissions.SaveSpecialties(db, specialties, HubSecurity.getLoggedInUserID());

            return(Json("Specialties Saved"));
        }
Ejemplo n.º 14
0
        public ActionResult EditPreferences(PracticeAdminEditPreferencesViewModel viewM)
        {
            PracticeAdminEditPreferencesViewModel returnM = new PracticeAdminEditPreferencesViewModel();
            ReferringPractice oldPrac;

            returnM.practices = DataCollections.getPractices(db, HubSecurity.getLoggedInUserID());
            int id;

            if (viewM.UpdatePracticeInformation != null)
            {
                if (viewM.hidAll == "true")
                {
                    foreach (SelectListItem prac in returnM.practices)
                    {
                        if (prac.Value == "ALL")
                        {
                            continue;
                        }
                        id                    = Convert.ToInt32(prac.Value);
                        oldPrac               = (from r in db.ReferringPractices where r.PracID == id select r).Single();
                        oldPrac.Address1      = viewM.selectedPrac.Address1;
                        oldPrac.Address2      = viewM.selectedPrac.Address2;
                        oldPrac.Address3      = viewM.selectedPrac.Address3;
                        oldPrac.City          = viewM.selectedPrac.City;
                        oldPrac.State         = viewM.selectedPrac.State;
                        oldPrac.Zip           = viewM.selectedPrac.Zip;
                        oldPrac.Phone         = viewM.selectedPrac.Phone;
                        oldPrac.Fax           = viewM.selectedPrac.Fax;
                        oldPrac.OfficeManager = viewM.selectedPrac.OfficeManager;
                        oldPrac.Other         = viewM.selectedPrac.Other;
                        oldPrac.PDFPassword   = viewM.selectedPrac.PDFPassword;
                        DataSubmissions.SavePractice(db, oldPrac);
                    }
                }
                else
                {
                    oldPrac               = (from r in db.ReferringPractices where r.PracID == viewM.selectedPrac.PracID select r).Single();
                    oldPrac.Address1      = viewM.selectedPrac.Address1;
                    oldPrac.Address2      = viewM.selectedPrac.Address2;
                    oldPrac.Address3      = viewM.selectedPrac.Address3;
                    oldPrac.City          = viewM.selectedPrac.City;
                    oldPrac.State         = viewM.selectedPrac.State;
                    oldPrac.Zip           = viewM.selectedPrac.Zip;
                    oldPrac.Phone         = viewM.selectedPrac.Phone;
                    oldPrac.Fax           = viewM.selectedPrac.Fax;
                    oldPrac.OfficeManager = viewM.selectedPrac.OfficeManager;
                    oldPrac.Other         = viewM.selectedPrac.Other;
                    oldPrac.PDFPassword   = viewM.selectedPrac.PDFPassword;
                    DataSubmissions.SavePractice(db, oldPrac);
                }
            }
            if (viewM.UpdateCommunicationMethod != null)
            {
                if (viewM.hidAll == "true")
                {
                    foreach (SelectListItem prac in returnM.practices)
                    {
                        if (prac.Value == "ALL")
                        {
                            continue;
                        }
                        id      = Convert.ToInt32(prac.Value);
                        oldPrac = (from r in db.ReferringPractices where r.PracID == id select r).Single();
                        oldPrac.EmailNotification = viewM.selectedPrac.EmailNotification;
                        oldPrac.FaxNotification   = viewM.selectedPrac.FaxNotification;
                        DataSubmissions.SavePractice(db, oldPrac);
                    }
                }
                else
                {
                    oldPrac = (from r in db.ReferringPractices where r.PracID == viewM.selectedPrac.PracID select r).Single();
                    oldPrac.EmailNotification = viewM.selectedPrac.EmailNotification;
                    oldPrac.FaxNotification   = viewM.selectedPrac.FaxNotification;
                    DataSubmissions.SavePractice(db, oldPrac);
                }
            }

            returnM.practices    = DataCollections.getPractices(db, HubSecurity.getLoggedInUserID());
            returnM.selectedPrac = DataCollections.getPractice(db, viewM.hidPrac);
            returnM.specialties  = DataCollections.getSpecialties(db, viewM.selectedPrac.PracID);
            returnM.hidPrac      = viewM.hidPrac;
            returnM.tabReturn    = viewM.tabReturn;
            returnM.hidAll       = viewM.hidAll;

            return(View(returnM));
        }
Ejemplo n.º 15
0
        //This function returns results from PatientLog table for all PatientLog Views aside from PatientSort
        private IQueryable <PatientLog> patientLogQueryGenerator(DateTime fromDate, DateTime toDate, List <string> selectedHosp, List <string> selectedServ,
                                                                 GridFilter.SortDirections direction, string sortColumn, bool assigned)
        {
            //Query PatientLog by physicians and date/time range
            string user = HubSecurity.getLoggedInUserID();
            IQueryable <PatientLog> query;

            //Alter query to show all Assigned entries if selected to do so
            if (!assigned)
            {
                if (sortColumn == null)
                {
                    query = from d in db.PatientLogs
                            where d.ServiceDate >= fromDate &&
                            d.ServiceDate <= toDate &&
                            d.Physician == user
                            orderby d.PatientName, d.ServiceDate
                    select d;
                }
                else
                {
                    query = from d in db.PatientLogs
                            where d.ServiceDate >= fromDate &&
                            d.ServiceDate <= toDate &&
                            d.Physician == user
                            select d;
                }
            }
            else
            {
                if (sortColumn == null)
                {
                    query = from d in db.PatientLogs
                            where d.Physician == user && d.ServiceType == "Assigned"
                            orderby d.PatientName, d.ServiceDate
                    select d;
                }
                else
                {
                    query = from d in db.PatientLogs
                            where d.Physician == user && d.ServiceType == "Assigned"
                            select d;
                }
            }

            //Apply hospital filters if any are provided
            if (selectedHosp.Any())
            {
                query = query.Where(h => selectedHosp.Contains(h.Hospital));
            }

            //Apply service type filters only if not showing assigned view
            if (!assigned)
            {
                if (selectedServ.Any())
                {
                    query = query.Where(s => selectedServ.Contains(s.ServiceType));
                }
            }

            //Apply sorting
            if (direction == GridFilter.SortDirections.Ascending)
            {
                if (sortColumn == "PatientName")
                {
                    query = query.OrderBy(sortColumn + ", ServiceDate");
                }
                else
                {
                    query = query.OrderBy(sortColumn);
                }
            }
            else
            {
                query = query.OrderBy(sortColumn + " DESC");
            }

            List <int> idList = query.Select(p => p.ID).ToList();

            Session["patientLogListOfID"] = idList;

            //Update user preferences if Assigned is not selected
            if (!assigned)
            {
                Dictionary <string, string> filters = new Dictionary <string, string>();
                string hospPref = null;
                foreach (string hosp in selectedHosp)
                {
                    hospPref += hosp + ",";
                }
                if (hospPref != null)
                {
                    hospPref = hospPref.Substring(0, hospPref.Length - 1);
                }
                filters.Add("Hospital", hospPref);

                string servPref = null;
                foreach (string serv in selectedServ)
                {
                    servPref += serv + ",";
                }
                if (servPref != null)
                {
                    servPref = servPref.Substring(0, servPref.Length - 1);
                }
                filters.Add("ServiceType", servPref);

                if (direction == GridFilter.SortDirections.Ascending)
                {
                    filters.Add("SortDirection", "Ascending");
                }
                else
                {
                    filters.Add("SortDirection", "Descending");
                }
                filters.Add("SortColumn", sortColumn);

                DataSubmissions.SavePreferences(db, "PatientLog", "PatientLogIndex", filters);
            }

            return(query);
        }