コード例 #1
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"));
        }
コード例 #2
0
        //Returns SelectList containing PCP's from a single site
        public static SelectList getPCP(PatientLogModel db, string hosp)
        {
            IQueryable <SelectListItem> pcpModel = from u in db.Users
                                                   join ud in db.UserDetails on u.UserID equals ud.UserID
                                                   where (ud.UserType == "RefPhy") && (ud.DefaultHospital == hosp)
                                                   orderby u.LastName
                                                   select new SelectListItem {
                Value = (u.LastName + ", " + u.FirstName), Text = (u.LastName + ", " + u.FirstName)
            };

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

            list.Insert(0, new SelectListItem {
                Text = "No PCP", Value = "No PCP"
            });
            return(new SelectList(list, "Value", "Value"));
        }
コード例 #3
0
        //Returns DISTINCT SelectList containing all AIMSPhy users
        public static SelectList getAIMSPhy(PatientLogModel db)
        {
            IQueryable <SelectListItem> phyModel = from u in db.Users
                                                   join ud in db.UserDetails on u.UserID equals ud.UserID
                                                   where (ud.UserType == "AIMSPhy" && ud.Active == true)
                                                   select new SelectListItem {
                Text = (u.LastName + ", " + u.FirstName), Value = u.UserID
            };

            phyModel = phyModel.Distinct().OrderBy(u => u.Text);
            List <SelectListItem> list = phyModel.ToList();

            list.Insert(0, new SelectListItem {
                Text = "Unassigned", Value = "Unassigned"
            });
            return(new SelectList(list, "Value", "Text"));
        }
コード例 #4
0
        //Returns List<string> containing PCP names based on an admin user
        public static List <string> getPracticeAdminPCPs(PatientLogModel db, string userID)
        {
            List <string> retList = new List <string>();

            List <string> practices = (from r in db.RefPracAdmins
                                       where r.UserID == userID
                                       select r.UserID).Distinct().ToList();

            var pcpmodel = (from u in db.Users
                            join ud in db.UserDetails on u.UserID equals ud.UserID
                            where (ud.UserType == "RefPhy" && practices.Contains(ud.UserID))
                            orderby u.LastName
                            select new { Value = (u.LastName + ", " + u.FirstName) }).Distinct();

            retList = pcpmodel.Select(x => x.Value).ToList();
            return(retList);
        }
コード例 #5
0
        //Returns SelectList containing all PCP's
        public static SelectList getPCP(PatientLogModel db)
        {
            IQueryable <SelectListItem> pcpModel = from u in db.Users
                                                   join ud in db.UserDetails on u.UserID equals ud.UserID
                                                   where (ud.UserType == "RefPhy")
                                                   orderby u.LastName
                                                   select new SelectListItem {
                Value = (u.LastName + ", " + u.FirstName), Text = (u.LastName + ", " + u.FirstName)
            };

            pcpModel = pcpModel.Distinct().OrderBy(u => u.Value);

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

            list.Insert(0, new SelectListItem {
                Text = "No PCP", Value = "No PCP"
            });
            return(new SelectList(list, "Value", "Value"));
        }
コード例 #6
0
        public static void SavePatient(PatientLogModel db, PatientLog patient)
        {
            patient.LastUpdated     = DateTime.Now;
            db.Entry(patient).State = EntityState.Modified;


            //db.Audits.Add(new Audit
            //{
            //    Action = "Update",
            //    FunctionUsed = "SavePatient(PatientLog)",
            //    UserID = HubSecurity.getLoggedInUserID(),
            //    TargetIDs = patient.ID.ToString(),
            //    Controller = getController(),
            //    Page = getPage(),
            //    TimeStamp = DateTime.Now
            //});

            db.SaveChanges();
        }
コード例 #7
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);
        }
コード例 #8
0
        public static void CreatePatient(PatientLogModel db, PatientLog patient)
        {
            patient.DateCreated = DateTime.Now;
            //patientLog.LastUpdated = DateTime.Now;

            if (patient.Physician == "" || patient.Physician == null)
            {
                patient.Physician = "Unassigned";
            }
            if (patient.PCP_Practice == "" || patient.PCP_Practice == null)
            {
                patient.PCP_Practice = "No PCP";
            }
            if (patient.ServiceType == "" || patient.ServiceType == null)
            {
                patient.ServiceType = "Assigned";
            }
            db.PatientLogs.Add(patient);
            db.SaveChanges();
        }
コード例 #9
0
 public static void SavePatients(PatientLogModel db, PatientLog[] patient)
 {
     //string ids = "";
     foreach (PatientLog pat in patient)
     {
         pat.LastUpdated     = DateTime.Now;
         db.Entry(pat).State = EntityState.Modified;
         //ids += pat.ID.ToString() + ",";
     }
     //db.Audits.Add(new Audit
     //{
     //    Action = "Update",
     //    FunctionUsed = "SavePatients(PatientLog[])",
     //    UserID = HubSecurity.getLoggedInUserID(),
     //    TargetIDs = ids.Substring(0, ids.Length - 1),
     //    Controller = getController(),
     //    Page = getPage(),
     //    TimeStamp = DateTime.Now
     //});
     db.SaveChanges();
 }
コード例 #10
0
        //Returns SelectList containing practice friendly name and practice ID for value with provided practice selected
        public static SelectList getPractices(PatientLogModel db, string userID, string selectedPrac)
        {
            IQueryable <SelectListItem> practices = from p in db.ReferringPractices
                                                    join a in db.RefPracAdmins on p.PracID equals a.PracID
                                                    where a.UserID == userID
                                                    orderby p.PracName
                                                    select new SelectListItem {
                Value = p.PracID.ToString(), Text = p.PracName
            };

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

            if (list.Count > 1)
            {
                list.Insert(0, new SelectListItem {
                    Text = "ALL", Value = "ALL"
                });
            }
            //list.Insert(0, new SelectListItem { Text = "No PCP", Value = "No PCP" });
            return(new SelectList(list, "Value", "Text", selectedPrac));
        }
コード例 #11
0
 //Saves specialties
 public static void SaveSpecialties(PatientLogModel db, List <RefPracSpecialty> specialties)
 {
     //Zero ID indicates this has never been saved to the database before
     if (specialties[0].ID == 0)
     {
         foreach (RefPracSpecialty spec in specialties)
         {
             db.RefPracSpecialties.Add(spec);
         }
     }
     else
     {
         foreach (RefPracSpecialty spec in specialties)
         {
             RefPracSpecialty oldSpec = (from s in db.RefPracSpecialties where s.ID == spec.ID select s).Single();
             oldSpec.FirstChoice     = spec.FirstChoice;
             oldSpec.Backup          = spec.Backup;
             oldSpec.Comments        = spec.Comments;
             db.Entry(oldSpec).State = EntityState.Modified;
         }
     }
     db.SaveChanges();
 }
コード例 #12
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();
        }
コード例 #13
0
        public static SelectList getAllLocationsByType(PatientLogModel db, bool addNone)
        {
            IQueryable <Hospital> hosps = from h in db.Hospitals
                                          where h.Active == true
                                          select h;

            hosps = hosps.OrderBy(h => (h.HospitalType == "HOS") ? 0 : (h.HospitalType == "NH") ? 1 : 2).ThenBy(h => h.ShortName);
            List <SelectListItem> list = new List <SelectListItem>();

            if (addNone)
            {
                list.Add(new SelectListItem {
                    Text = "-none-", Value = "none"
                });
            }
            foreach (Hospital hosp in hosps)
            {
                list.Add(new SelectListItem {
                    Text = hosp.ShortName, Value = hosp.ShortName
                });
            }
            return(new SelectList(list, "Value", "Text"));
        }
コード例 #14
0
        public static void CopyPatient(PatientLogModel db, int id)
        {
            PatientLog patient = db.PatientLogs.Find(id);

            //Reset values for copied record
            patient.ServiceDate = DateTime.Parse(DateTime.Now.ToShortDateString());
            patient.DateCreated = DateTime.Now;
            patient.LastUpdated = null;
            patient.Notes       = null;

            //db.Audits.Add(new Audit
            //{
            //    Action = "Copy",
            //    FunctionUsed = "CopyPatient(int)",
            //    UserID = HubSecurity.getLoggedInUserID(),
            //    TargetIDs = id.ToString(),
            //    Controller = getController(),
            //    Page = getPage(),
            //    TimeStamp = DateTime.Now
            //});

            db.PatientLogs.Add(patient);
            db.SaveChanges();
        }
コード例 #15
0
        public static DataTable getScheduleWorkArea(PatientLogModel db, DateTime start, DateTime end, List <string> users, List <string> hospitals, List <string> types, bool rounding)
        {
            DataTable returnDT = new DataTable();

            returnDT.Columns.Add("ID");
            returnDT.Columns.Add("StartTime");
            returnDT.Columns.Add("EndTime");
            returnDT.Columns.Add("Title");
            returnDT.Columns.Add("ScheduleType");
            returnDT.Columns.Add("UserID");
            returnDT.Columns.Add("Hospital");

            var query = from s in db.ScheduleWorkAreas
                        where s.StartTime >= start && s.EndTime <= end
                        select s;

            if (rounding)
            {
                List <string> round = (from t in db.ScheduleRoundingTypes select t.Event).ToList <string>();
                query = query.Where(s => round.Contains(s.ScheduleType));
            }
            if (users.Any())
            {
                query = query.Where(s => users.Contains(s.UserID));
            }
            if (hospitals.Any())
            {
                query = query.Where(s => hospitals.Contains(s.HospitalShortName));
            }
            if (types.Any())
            {
                query = query.Where(s => types.Contains(s.ScheduleType));
            }

            //Implement Ordering
            //Orders by Day, then Day Nursing, everything else, and finally Scheduled Off at the bottom, alphabetical order of the users for each type
            query = query.OrderBy(s => (s.ScheduleType == "Day-(D)") ? 0 : (s.ScheduleType == "Day Nursing-(DN)") ? 1 : (s.ScheduleType == "Scheduled Off-(O)") ? 100 : 2).ThenBy(s => s.UserID.Substring(1));

            foreach (ScheduleWorkArea sch in query)
            {
                string  displayStart = sch.StartTime.Value.ToString("htt");
                string  displayEnd   = sch.EndTime.Value.ToString("htt");
                DataRow dr           = returnDT.NewRow();
                dr["ID"]        = sch.ID;
                dr["StartTime"] = sch.StartTime;
                //If time span is overnight, set End Time same as Start to avoid tag spilling into the next day
                if (sch.EndTime.Value.Day == sch.StartTime.Value.Day + 1)
                {
                    dr["EndTime"] = sch.StartTime;
                }
                else
                {
                    dr["EndTime"] = sch.EndTime;
                }

                dr["Title"]        = displayStart + ' ' + sch.Title + ' ' + displayEnd;
                dr["ScheduleType"] = sch.ScheduleType;
                dr["UserID"]       = sch.UserID;
                dr["Hospital"]     = sch.HospitalShortName;
                returnDT.Rows.Add(dr);
            }

            return(returnDT);
        }
コード例 #16
0
        public static int FinalizeSchedule(PatientLogModel db, List <string> users, List <string> hosps, List <string> types, DateTime start, DateTime end)
        {
            DateTime newStart = start.Date + new TimeSpan(0, 0, 0);
            DateTime newEnd   = end.Date + new TimeSpan(23, 59, 59);
            int      count;

            IQueryable <Schedule> toDelete = from w in db.Schedules
                                             where w.StartTime >= newStart && w.StartTime <= newEnd
                                             select w;

            if (users.Any())
            {
                toDelete = toDelete.Where(w => users.Contains(w.UserID));
            }
            if (hosps.Any())
            {
                toDelete = toDelete.Where(w => hosps.Contains(w.HospitalShortName));
            }
            if (types.Any())
            {
                toDelete = toDelete.Where(w => types.Contains(w.ScheduleType));
            }

            //Delete all matching criteria from schedule
            foreach (Schedule sch in toDelete)
            {
                db.Schedules.Remove(sch);
            }
            db.SaveChanges();


            IQueryable <ScheduleWorkArea> toAdd = from w in db.ScheduleWorkAreas
                                                  where w.StartTime >= newStart && w.StartTime <= newEnd
                                                  select w;

            if (users.Any())
            {
                toAdd = toAdd.Where(w => users.Contains(w.UserID));
            }
            if (hosps.Any())
            {
                toAdd = toAdd.Where(w => hosps.Contains(w.HospitalShortName));
            }
            if (types.Any())
            {
                toAdd = toAdd.Where(w => types.Contains(w.ScheduleType));
            }

            //Add all matching ScheduleWorkArea schedules to the schedule table
            count = toAdd.Count();
            foreach (ScheduleWorkArea sch in toAdd)
            {
                Schedule newSchedule = new Schedule();

                newSchedule.Comments          = sch.Comments;
                newSchedule.DateCreated       = DateTime.Now;
                newSchedule.EndTime           = sch.EndTime;
                newSchedule.HospitalShortName = sch.HospitalShortName;
                newSchedule.ScheduleType      = sch.ScheduleType;
                newSchedule.StartTime         = sch.StartTime;
                newSchedule.Title             = sch.Title;
                newSchedule.UserID            = sch.UserID;
                db.Schedules.Add(newSchedule);
            }
            db.SaveChanges();

            return(count);
        }
コード例 #17
0
 public static void CreateScheduleWorkArea(PatientLogModel db, ScheduleWorkArea sch)
 {
     db.ScheduleWorkAreas.Add(sch);
     db.SaveChanges();
 }
コード例 #18
0
 public static void DeletePatient(PatientLogModel db, PatientLog patient)
 {
     db.PatientLogTmps.Add(CreateTmpPatient(patient));
     db.PatientLogs.Remove(patient);
     db.SaveChanges();
 }
コード例 #19
0
 //Returns SelectList of servicetype with specified service as default
 public static SelectList getServiceType(PatientLogModel db, string serv)
 {
     return(new SelectList(db.ServiceTypes, "Service", "Service", serv));
 }
コード例 #20
0
 //Returns SelectList containing PatientClass types with passed pclass as selected
 public static SelectList getPatientClass(PatientLogModel db, string pclass)
 {
     return(new SelectList(db.PatientClasses, "ShortName", "ShortName", pclass));
 }
コード例 #21
0
 //Returns genders
 public static SelectList getGender(PatientLogModel db)
 {
     return(new SelectList(db.Genders, "Gender1", "Gender1", "Male"));
 }
コード例 #22
0
        //Searches RefPracSpecialty for provided practice, if found returns results, else returns a blank default of common specialties
        public static List <RefPracSpecialty> getSpecialties(PatientLogModel db, int selectedPrac)
        {
            IQueryable <RefPracSpecialty> specials = from s in db.RefPracSpecialties
                                                     where s.PracID == selectedPrac
                                                     select s;

            List <RefPracSpecialty> list = new List <RefPracSpecialty>();

            if (specials.Any() == false)
            {
                list.Add(new RefPracSpecialty {
                    Specialty = "Allergy and Immunology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Anesthesiology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Cardiology - EP", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Cardiology - General", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Cardiology - Interventional", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Cardiology - Surgery", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Dermatology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Endocrinology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "ENT", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Gastroenterology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Hematology/Oncology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Infectious Disease", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Nephrology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Neurology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Neurosurgery", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "OB/GYN", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "OMFS", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Ophthamology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Orthopedic Spine", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Orthopedic Surgery", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Orthopedics", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Other 1", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Other 2", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Other 3", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Other 4", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Other 5", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Plastic Surgery", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "PMR", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Podiatry", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Psychiatry", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Pulmonary/CCM", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Rheumatology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Surgery - Cardio Thoracic", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Surgery - Colon & Rectal", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Surgery - General", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Surgery - Neurological", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Surgery - Orthopedic", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Surgery - Plastic", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Surgery - Thoracic", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Surgery - Urological", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Surgery - Vascular", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
                list.Add(new RefPracSpecialty {
                    Specialty = "Urology", FirstChoice = "", Backup = "", Comments = "", ID = 0
                });
            }
            else
            {
                list = specials.ToList();
            }

            return(list);
        }
コード例 #23
0
        public static ReferringPractice getPractice(PatientLogModel db, int PracID)
        {
            ReferringPractice prac = (from r in db.ReferringPractices where r.PracID == PracID select r).Single();

            return(prac);
        }
コード例 #24
0
 //Returns SelectList containing PatientClass types
 public static SelectList getPatientClass(PatientLogModel db)
 {
     return(new SelectList(db.PatientClasses, "ShortName", "ShortName", "None"));
 }
コード例 #25
0
 //Returns SelectList of genders with specified gender as default
 public static SelectList getGender(PatientLogModel db, string gen)
 {
     return(new SelectList(db.Genders, "Gender1", "Gender1", gen));
 }