Ejemplo n.º 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));
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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.º 4
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.º 5
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);
        }
Ejemplo n.º 6
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();
        }
 public ActionResult Edit([Bind(Include = "PracID,PracName,Address1,Address2,Address3,City,State,Zip,Phone,Fax,Email,OfficeManager,Other,PDFPassword,EmailNotification,FaxNotification")] ReferringPractice referringPractice)
 {
     if (ModelState.IsValid)
     {
         db.Entry(referringPractice).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(referringPractice));
 }
Ejemplo n.º 8
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.º 9
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();
        }
Ejemplo n.º 10
0
        public async Task <ActionResult> Edit([Bind(Include = "ID,Physician,Hospital,PCP_Practice,MRN_FIN,PatientName,DateCreated,ServiceType,Comments,LastUpdated,ServiceDate,RoomNo,AIMSComments,FaceSheet,Notes,AIMSBillingCodes,DOB,Gender,PatientClass")] PatientLog patientLog)
        {
            if (ModelState.IsValid)
            {
                patientLog.LastUpdated     = DateTime.Now;
                db.Entry(patientLog).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(patientLog));
        }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
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();
 }
Ejemplo n.º 13
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();
 }
Ejemplo n.º 14
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.º 15
0
        public JsonResult jsonImportFileCommit(HttpPostedFileBase file, string columns, bool copyDayBefore, bool sourceListFinal, string hospital)
        {
            file.SaveAs("C:\\Data\\PatientAssignment\\" + file.FileName);
            FileInfo     savedFile = new FileInfo("C:\\Data\\PatientAssignment\\" + file.FileName);
            DataTable    result    = new DataTable();
            ExcelPackage pack      = new ExcelPackage(savedFile);

            result = ToDataTable(pack);
            DateTime srvDate = DateTime.Now.Date + new TimeSpan(00, 00, 00);

            string[]      splitColumns = columns.Split(new char[] { ',' });
            List <string> listMRNs     = new List <string>(); //List of imported MRN's used to evaluate whether the record should be deleted if sourceListFinal is true

            string[] dcs = new string[] { "DC - STD", "DC - EXT" };

            //Copies from day before if selected to do so
            if (copyDayBefore)
            {
                DateTime dayBefore = srvDate.AddDays(-1);
                var      query     = from p in db.PatientLogs
                                     where p.ServiceDate == dayBefore && p.Hospital == hospital && !dcs.Contains(p.ServiceType)
                                     select p;

                foreach (PatientLog pat in query)
                {
                    pat.ServiceDate = srvDate;
                    pat.ServiceType = "Assigned";
                    db.PatientLogs.Add(pat);
                }
                db.SaveChanges();
            }
            DataValidations validate = new DataValidations();

            //Parses the Excel spreadsheet to create a Patient object
            for (int i = 0; i < result.Rows.Count; i++)
            {
                PatientLog patient = new PatientLog();

                for (int j = 0; j < splitColumns.Length; j++)
                {
                    switch (splitColumns[j])
                    {
                    case "Comments":
                        patient.Comments = result.Rows[i][j].ToString();
                        break;

                    case "DOB":
                        try
                        {
                            patient.DOB = DateTime.Parse(result.Rows[i][j].ToString());
                        }
                        catch
                        {
                            patient.DOB = DateTime.Parse("1/1/1900");
                        }
                        break;

                    case "Gender":
                        patient.Gender = validate.checkGender(db, result.Rows[i][j].ToString());
                        break;

                    case "Hospital":
                        patient.Hospital = result.Rows[i][j].ToString();
                        break;

                    case "MRN_FIN":
                        patient.MRN_FIN = result.Rows[i][j].ToString();
                        listMRNs.Add(patient.MRN_FIN);
                        break;

                    case "PatientClass":
                        patient.PatientClass = result.Rows[i][j].ToString();
                        break;

                    case "PatientName":
                        patient.PatientName = result.Rows[i][j].ToString();
                        break;

                    case "PCP_Practice":
                        patient.PCP_Practice = validate.checkPCPandHosp(db, result.Rows[i][j].ToString(), hospital);
                        break;

                    case "Physician":
                        patient.Physician = validate.checkAIMSPhyAndHosp(db, result.Rows[i][j].ToString(), hospital);
                        break;

                    case "RoomNo":
                        patient.RoomNo = result.Rows[i][j].ToString();
                        break;

                    case "ServiceDate":
                        try
                        {
                            patient.ServiceDate = DateTime.Parse(result.Rows[i][j].ToString());
                        }
                        catch
                        {
                            patient.ServiceDate = DateTime.Parse(DateTime.Now.ToShortDateString());
                        }
                        break;

                    case "ServiceType":
                        patient.ServiceType = result.Rows[i][j].ToString();
                        break;
                    }
                }
                patient.Hospital = hospital;
                if (patient.ServiceDate == null)
                {
                    patient.ServiceDate = srvDate;
                }


                //Set default service type if none exists
                if (patient.ServiceType == null || patient.ServiceType == "")
                {
                    patient.ServiceType = "Assigned";
                }

                //Detect if patient already exists
                bool alreadyExists = (from p in db.PatientLogs
                                      where p.PatientName == patient.PatientName && p.MRN_FIN == patient.MRN_FIN && p.ServiceDate == patient.ServiceDate
                                      select p).Any();

                //If does not exist, add, otherwise check if sourceFinalList is true and evaluate eligibility
                if (!alreadyExists)
                {
                    //Set physician to unassigned if none exists
                    if (patient.Physician == null || patient.Physician == "")
                    {
                        patient.Physician = "Unassigned";
                    }
                    patient.DateCreated = DateTime.Now;
                    db.PatientLogs.Add(patient);
                }
                else
                {
                    PatientLog oldData = (from p in db.PatientLogs
                                          where p.PatientName == patient.PatientName && p.MRN_FIN == patient.MRN_FIN && p.ServiceDate == patient.ServiceDate
                                          select p).First();

                    if (patient.Comments != null && patient.Comments != "")
                    {
                        oldData.Comments = patient.Comments;
                    }

                    if (patient.DOB != null)
                    {
                        oldData.DOB = patient.DOB;
                    }

                    if (patient.Gender != null && patient.Gender != "")
                    {
                        oldData.Gender = patient.Gender;
                    }

                    if (patient.Hospital != null && patient.Hospital != "")
                    {
                        oldData.Hospital = patient.Hospital;
                    }

                    if (patient.PatientClass != null && patient.PatientClass != "")
                    {
                        oldData.PatientClass = patient.PatientClass;
                    }

                    if (patient.PCP_Practice != null && patient.PCP_Practice != "")
                    {
                        oldData.PCP_Practice = patient.PCP_Practice;
                    }

                    if (patient.Physician != null && patient.Physician != "")
                    {
                        oldData.Physician = patient.Physician;
                    }

                    if (patient.RoomNo != null && patient.RoomNo != "")
                    {
                        oldData.RoomNo = patient.RoomNo;
                    }

                    if (patient.ServiceType != null && patient.ServiceType != "")
                    {
                        oldData.ServiceType = patient.ServiceType;
                    }

                    db.Entry(oldData).State = EntityState.Modified;
                    //oldData = MergePatient(oldData, patient);
                    //db.SaveChanges();
                }

                //patient.Hospital = hospital;
                //importList.Add(patient);
            }
            db.SaveChanges();


            //If sourceListFinal is true and this MRN is not found, it is deleted
            if (sourceListFinal)
            {
                var todaysPatients = from p in db.PatientLogs
                                     where p.ServiceDate == srvDate && p.Hospital == hospital && !dcs.Contains(p.ServiceType)
                                     select p;
                foreach (PatientLog pat in todaysPatients)
                {
                    if (!listMRNs.Contains(pat.MRN_FIN))
                    {
                        db.PatientLogs.Remove(pat);
                    }
                }
            }

            db.SaveChanges();
            return(Json("Success", JsonRequestBehavior.AllowGet));
        }