Пример #1
0
        public ActionResult jsonSubmitPatient(PatientLog patientLog)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    PatientLog sourcePatient;
                    sourcePatient = (from p in db.PatientLogs
                                     where p.ID == patientLog.ID
                                     select p).Single();

                    sourcePatient.Notes           = patientLog.Notes;
                    sourcePatient.FaceSheet       = patientLog.FaceSheet;
                    db.Entry(sourcePatient).State = EntityState.Modified;
                    db.SaveChanges();
                    return(Content("Patient information has been saved successfully!"));
                }
                else
                {
                    return(Content("Model state is not valid."));
                }
            }
            catch (Exception ex) {
                return(Content(ex.Message));
            }
        }
Пример #2
0
 public static void DeletePatients(PatientLogModel db, PatientLog[] patient)
 {
     foreach (PatientLog pat in patient)
     {
         db.PatientLogTmps.Add(CreateTmpPatient(pat));
         db.PatientLogs.Remove(pat);
         db.SaveChanges();
     }
     db.SaveChanges();
 }
        public ActionResult Create([Bind(Include = "PracID,PracName,Address1,Address2,Address3,City,State,Zip,Phone,Fax,Email,OfficeManager,Other,PDFPassword,EmailNotification,FaxNotification")] ReferringPractice referringPractice)
        {
            if (ModelState.IsValid)
            {
                db.ReferringPractices.Add(referringPractice);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(referringPractice));
        }
Пример #4
0
        public static int DeleteSchedule(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 <ScheduleWorkArea> toDelete = from w in db.ScheduleWorkAreas
                                                     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));
            }

            count = toDelete.Count();
            foreach (ScheduleWorkArea sch in toDelete)
            {
                db.ScheduleWorkAreas.Remove(sch);
            }
            db.SaveChanges();
            return(count);
        }
Пример #5
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);
        }
Пример #6
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();
            }
        }
Пример #7
0
        //Saves specialties to all of admins practices
        public static void SaveSpecialties(PatientLogModel db, List <RefPracSpecialty> specialties, string practiceAdmin)
        {
            List <int> ids = new List <int>();

            ids = (from a in db.RefPracAdmins where a.UserID == practiceAdmin select a.PracID).ToList();

            foreach (int id in ids)
            {
                bool exists = (from s in db.RefPracSpecialties where s.PracID == id select s.ID).Any();

                if (exists)
                {
                    foreach (RefPracSpecialty spec in specialties)
                    {
                        RefPracSpecialty oldSpec = (from s in db.RefPracSpecialties where s.PracID == id && s.Specialty == spec.Specialty select s).Single();
                        oldSpec.FirstChoice     = spec.FirstChoice;
                        oldSpec.Backup          = spec.Backup;
                        oldSpec.Comments        = spec.Comments;
                        db.Entry(oldSpec).State = EntityState.Modified;
                    }
                }
                else
                {
                    foreach (RefPracSpecialty spec in specialties)
                    {
                        spec.PracID = id;
                        db.RefPracSpecialties.Add(spec);
                    }
                }
            }
            db.SaveChanges();
        }
Пример #8
0
        public static int MassEditSchedule(PatientLogModel db, List <string> users, List <string> hosps, List <string> types, DateTime start, DateTime end, string criteria, string change)
        {
            DateTime newStart = start.Date + new TimeSpan(0, 0, 0);
            DateTime newEnd   = end.Date + new TimeSpan(23, 59, 59);
            int      count;

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

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

            count = toEdit.Count();
            foreach (ScheduleWorkArea sch in toEdit)
            {
                string shortHand = sch.ScheduleType.Substring(sch.ScheduleType.IndexOf("(") + 1);
                shortHand = shortHand.Substring(0, shortHand.Count() - 1);
                switch (criteria)
                {
                case "Hospital":
                    sch.HospitalShortName = change;
                    sch.Title             = sch.HospitalShortName + "-" + shortHand + "-" + sch.UserID.Substring(1);
                    break;

                case "StartTime":
                    sch.StartTime = DateTime.Parse(change);
                    break;

                case "EndTime":
                    sch.EndTime = DateTime.Parse(change);
                    break;

                case "ScheduleType":
                    sch.ScheduleType = change;
                    sch.Title        = sch.HospitalShortName + "-" + shortHand + "-" + sch.UserID.Substring(1);
                    break;

                case "UserID":
                    sch.UserID = change;
                    sch.Title  = sch.HospitalShortName + "-" + shortHand + "-" + sch.UserID.Substring(1);
                    break;
                }

                db.Entry(sch).State = EntityState.Modified;
            }
            db.SaveChanges();
            return(count);
        }
Пример #9
0
        public static void DeletePatient(PatientLogModel db, int id)
        {
            PatientLog patient = db.PatientLogs.Find(id);

            db.PatientLogTmps.Add(CreateTmpPatient(patient));
            db.PatientLogs.Remove(patient);
            db.SaveChanges();
        }
Пример #10
0
        public static void DeleteScheduleWorkArea(PatientLogModel db, string id)
        {
            int newID            = Convert.ToInt32(id);
            ScheduleWorkArea sch = DataCollections.getScheduleWorkArea(db, id);

            db.ScheduleWorkAreas.Remove(sch);
            db.SaveChanges();
        }
Пример #11
0
        public static void DeletePatient(PatientLogModel db, string id)
        {
            PatientLog patient = db.PatientLogs.Find(Convert.ToInt32(id));

            db.PatientLogTmps.Add(CreateTmpPatient(patient));
            db.PatientLogs.Remove(patient);
            db.SaveChanges();
        }
Пример #12
0
        public static void CreateBillingEntry(PatientLogModel db, int id)
        {
            Billing bill = new Billing();

            bill.PLRecord = id;
            db.Billings.Add(bill);
            db.SaveChanges();
        }
Пример #13
0
 public static void CreateScheduleWorkArea(PatientLogModel db, List <ScheduleWorkArea> sch)
 {
     foreach (ScheduleWorkArea s in sch)
     {
         db.ScheduleWorkAreas.Add(s);
     }
     db.SaveChanges();
 }
Пример #14
0
        private void UpdateStatus(PCPCommunication comm, string status)
        {
            PatientLogModel db = new PatientLogModel();

            comm.CommStatus      = status;
            db.Entry(comm).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            db.Dispose();
        }
Пример #15
0
        private void UpdateCommTable(PCPCommunication comm)
        {
            comm.ScheduledTime = DateTime.Now;
            PatientLogModel db = new PatientLogModel();

            db.PCPCommunications.Add(comm);
            db.SaveChanges();
            db.Dispose();
        }
Пример #16
0
 public static void DeletePatients(PatientLogModel db, string[] id)
 {
     for (int i = 0; i < id.Length; i++)
     {
         PatientLog patient = db.PatientLogs.Find(Convert.ToInt32(id[i]));
         db.PatientLogTmps.Add(CreateTmpPatient(patient));
         db.PatientLogs.Remove(patient);
     }
     db.SaveChanges();
 }
Пример #17
0
        public static void CopyPatient(PatientLogModel db, PatientLog patient)
        {
            //Reset values for copied record
            patient.ServiceDate = DateTime.Parse(DateTime.Now.ToShortDateString());
            patient.DateCreated = DateTime.Now;
            patient.LastUpdated = null;
            patient.Notes       = null;

            db.PatientLogs.Add(patient);
            db.SaveChanges();
        }
Пример #18
0
        public static string DeleteFavorite(PatientLogModel db, string id)
        {
            int              newID = Convert.ToInt32(id);
            string           name;
            ScheduleFavorite f = db.ScheduleFavorites.Find(newID);

            name = f.Name;
            db.ScheduleFavorites.Remove(f);
            db.SaveChanges();
            return(name);
        }
Пример #19
0
 public static void DeletePatients(PatientLogModel db, string id)
 {
     string[] split = id.Split(',');
     for (int i = 0; i < split.Length; i++)
     {
         PatientLog patient = db.PatientLogs.Find(Convert.ToInt32(split[i]));
         db.PatientLogTmps.Add(CreateTmpPatient(patient));
         db.PatientLogs.Remove(patient);
     }
     db.SaveChanges();
 }
Пример #20
0
        public static void SavePractice(PatientLogModel db, ReferringPractice prac)
        {
            ReferringPractice practice = (from r in db.ReferringPractices where r.PracID == prac.PracID select r).FirstOrDefault();

            //If user preference query returns a value, update it. If not, create a new entry in the db
            if (practice != null)
            {
                db.Entry(practice).State = EntityState.Modified;
            }
            else
            {
                db.ReferringPractices.Add(prac);
            }
            db.SaveChanges();
        }
Пример #21
0
        public static void CopyPatients(PatientLogModel db, string[] id)
        {
            for (int i = 0; i < id.Length; i++)
            {
                PatientLog patient = db.PatientLogs.Find(Convert.ToInt32(id[i]));

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

                db.PatientLogs.Add(patient);
            }
            db.SaveChanges();
        }
Пример #22
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();
        }
Пример #23
0
        public ActionResult jsonSaveNotes(string ID, string Notes, string Comments)
        {
            int        newID = Convert.ToInt32(ID);
            PatientLog pat   = db.PatientLogs.Find(newID);

            if (pat == null)
            {
                return(Json("Something went wrong, please notify IT immediately"));
            }
            else
            {
                pat.Notes    = Notes;
                pat.Comments = Comments;

                db.Entry(pat).State = EntityState.Modified;
                db.SaveChanges();
                return(Json("Success"));
            }
        }
Пример #24
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();
        }
Пример #25
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);
        }
Пример #26
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();
 }
Пример #27
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();
 }
Пример #28
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();
        }
Пример #29
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);
        }
Пример #30
0
 public static void CreateScheduleWorkArea(PatientLogModel db, ScheduleWorkArea sch)
 {
     db.ScheduleWorkAreas.Add(sch);
     db.SaveChanges();
 }