示例#1
0
        //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 };

            var query = DataCollections.getAIMSPhy(db, site);

            return(Json(query, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public ActionResult Correction()
        {
            string        patient            = "";
            List <string> hospitals          = new List <string>();
            List <string> services           = new List <string>();
            BillingCorrectionViewModel viewM = new BillingCorrectionViewModel();

            if (Session["billingCorrectionServiceDate"] != null)
            {
                viewM.SearchServiceDate = Session["billingCorrectionServiceDate"].ToString();
            }
            else
            {
                viewM.SearchServiceDate = DateTime.Now.ToShortDateString();
                Session["billingCorrectionServiceDate"] = viewM.SearchServiceDate;
            }
            if (Session["billingCorrectionPatient"] != null)
            {
                patient = Session["billingCorrectionPatient"].ToString();
            }
            if (Session["billingCorrectionHospitals"] != null)
            {
                hospitals = (List <string>)Session["billingCorrectionHospitals"];
            }
            if (Session["billingCorrectionServices"] != null)
            {
                services = (List <string>)Session["billingCorrectionServices"];
            }

            viewM.Patients          = new List <BillingIndexPatient>().AsEnumerable();
            viewM.GenderList        = DataCollections.getGender(db);
            viewM.PhysicianList     = DataCollections.getAIMSPhy(db);
            viewM.PCPList           = DataCollections.getPCP(db, "BRO");
            viewM.HospitalList      = DataCollections.getHospital(db);
            viewM.ServiceList       = DataCollections.getServiceType(db);
            viewM.SelectedHospitals = hospitals;
            viewM.SelectedServices  = services;
            viewM.SearchPatientName = patient;

            return(View(viewM));
        }
示例#3
0
        public ActionResult Correction(BillingCorrectionViewModel viewM)
        {
            DateTime      fromD     = getValidDate(viewM.SearchServiceDate, true);
            DateTime      toD       = getValidDate(viewM.SearchServiceDate, false);
            string        patient   = viewM.SearchPatientName;
            List <string> hospitals = new List <string>();
            List <string> services  = new List <string>();

            string[] splitList;

            if (viewM.hidHospitals != null && viewM.hidHospitals != "")
            {
                splitList = viewM.hidHospitals.Split(new char[] { ',' });
                hospitals = splitList.ToList <string>();
            }
            if (viewM.hidServices != null && viewM.hidServices != "")
            {
                splitList = viewM.hidServices.Split(new char[] { ',' });
                services  = splitList.ToList <string>();
            }

            BillingCorrectionViewModel returnM = new BillingCorrectionViewModel();

            returnM.Patients          = billingCorrectionQueryGenerator(fromD, toD, patient, hospitals, services);
            returnM.GenderList        = DataCollections.getGender(db);
            returnM.PhysicianList     = DataCollections.getAIMSPhy(db);
            returnM.PCPList           = DataCollections.getPCP(db, "BRO");
            returnM.HospitalList      = DataCollections.getHospital(db);
            returnM.ServiceList       = DataCollections.getServiceType(db);
            returnM.SearchPatientName = patient;
            returnM.SearchServiceDate = fromD.ToShortDateString();
            returnM.SelectedHospitals = hospitals;
            returnM.SelectedServices  = services;

            return(View(returnM));
        }
示例#4
0
        public ActionResult Index(BillingIndexViewModel viewM)
        {
            BillingIndexViewModel returnM  = new BillingIndexViewModel();
            var           fromD            = new DateTime();
            var           toD              = new DateTime();
            List <string> physicians       = new List <string>();
            List <string> hospitals        = new List <string>();
            List <string> services         = new List <string>();
            List <string> lastnamefilters  = new List <string>();
            bool?         notesCompleted   = null;
            bool?         notesCopied      = null;
            bool?         faceSheetEntered = null;
            bool?         codingCompleted  = null;
            bool?         chargePosted     = null;

            string[] splitList;

            //Manages physician input and builds a List<string> to be used in the query
            if (viewM.hidPhysicians != null && viewM.hidPhysicians != "")
            {
                splitList  = viewM.hidPhysicians.Split(new char[] { ',' });
                physicians = splitList.ToList <string>();
            }
            //Manages physician input and builds a List<string> to be used in the query
            if (viewM.hidHospitals != null && viewM.hidHospitals != "")
            {
                splitList = viewM.hidHospitals.Split(new char[] { ',' });
                hospitals = splitList.ToList <string>();
            }
            if (viewM.hidServices != null && viewM.hidServices != "")
            {
                splitList = viewM.hidServices.Split(new char[] { ',' });
                services  = splitList.ToList <string>();
            }
            if (viewM.hidLastNameFilters != null && viewM.hidLastNameFilters != "")
            {
                splitList       = viewM.hidLastNameFilters.Split(new char[] { ',' });
                lastnamefilters = splitList.ToList <string>();
            }
            if (viewM.hidNotesCompleted != null)
            {
                switch (viewM.hidNotesCompleted)
                {
                case "true":
                    notesCompleted = true;
                    break;

                case "false":
                    notesCompleted = false;
                    break;
                }
            }
            if (viewM.hidNotesCopied != null)
            {
                switch (viewM.hidNotesCopied)
                {
                case "true":
                    notesCopied = true;
                    break;

                case "false":
                    notesCopied = false;
                    break;
                }
            }
            if (viewM.hidFaceSheetEntered != null)
            {
                switch (viewM.hidFaceSheetEntered)
                {
                case "true":
                    faceSheetEntered = true;
                    break;

                case "false":
                    faceSheetEntered = false;
                    break;
                }
            }
            if (viewM.hidCodingCompleted != null)
            {
                switch (viewM.hidCodingCompleted)
                {
                case "true":
                    codingCompleted = true;
                    break;

                case "false":
                    codingCompleted = false;
                    break;
                }
            }
            if (viewM.hidChargePosted != null)
            {
                switch (viewM.hidChargePosted)
                {
                case "true":
                    chargePosted = true;
                    break;

                case "false":
                    chargePosted = false;
                    break;
                }
            }


            fromD = getValidDate(viewM.FromDate, true);
            toD   = getValidDate(viewM.ToDate, false);

            IQueryable <BillingIndexPatient> query = billingIndexQueryGenerator(fromD, toD, physicians, hospitals, services, lastnamefilters, notesCompleted, notesCopied, faceSheetEntered, chargePosted, codingCompleted, viewM.SortDirection, viewM.SortColumn, false);

            Session["billingFromDate"]      = fromD;
            Session["billingToDate"]        = toD;
            Session["billingSortColumn"]    = viewM.SortColumn;
            Session["billingSortDirection"] = viewM.SortDirection;
            //Session["billingPhysicians"] = physicians;
            //Session["billingHospitals"] = hospitals;
            //Session["billingServices"] = services;
            //Session["billingLastNameFilters"] = lastnamefilters;
            //Session["billingNotesCompleted"] = notesCompleted;
            //Session["billingNotesCopied"] = notesCopied;
            //Session["billingFaceSheetEntered"] = faceSheetEntered;
            //Session["billingCodingCompleted"] = codingCompleted;
            //Session["billingChargePosted"] = chargePosted;

            returnM.Patients           = query.AsEnumerable();
            returnM.FromDate           = fromD.ToShortDateString();
            returnM.ToDate             = toD.ToShortDateString();
            returnM.PhysicianList      = DataCollections.getAIMSPhy(db);
            returnM.HospitalList       = DataCollections.getHospital(db);
            returnM.ServiceList        = DataCollections.getServiceType(db);
            returnM.LastNameFilterList = DataCollections.getLastNameFilter();
            returnM.YesNo = DataCollections.getYesNo();
            returnM.SelectedPhysicians       = physicians;
            returnM.SelectedHospitals        = hospitals;
            returnM.SelectedServices         = services;
            returnM.SelectedLastNameFilters  = lastnamefilters;
            returnM.SelectedNotesCompleted   = notesCompleted;
            returnM.SelectedNotesCopied      = notesCopied;
            returnM.SelectedFaceSheetEntered = faceSheetEntered;
            returnM.SelectedCodingCompleted  = codingCompleted;
            returnM.SelectedChargePosted     = chargePosted;
            returnM.SortColumn    = viewM.SortColumn;
            returnM.SortDirection = viewM.SortDirection;
            return(View("Index", returnM));
        }
示例#5
0
        // GET: Billing
        public ActionResult Index()
        {
            BillingIndexViewModel viewM             = new BillingIndexViewModel();
            var           fromD                     = new DateTime();
            var           toD                       = new DateTime();
            List <string> physicians                = new List <string>();
            List <string> hospitals                 = new List <string>();
            List <string> services                  = new List <string>();
            List <string> lastnamefilters           = new List <string>();
            Dictionary <string, string> preferences = new Dictionary <string, string>();
            bool?notesCompleted                     = null;
            bool?notesCopied      = null;
            bool?faceSheetEntered = null;
            bool?codingCompleted  = null;
            bool?chargePosted     = null;

            string[] splitList;

            if (Session["billingFromDate"] != null && Session["billingToDate"] != null)
            {
                fromD = Convert.ToDateTime(Session["billingFromDate"]);
                toD   = Convert.ToDateTime(Session["billingToDate"]);
            }
            else
            {
                fromD = getValidDate("", true);
                toD   = getValidDate("", false);
            }
            if (Session["billingSortColumn"] != null)
            {
                viewM.SortColumn    = Session["billingSortColumn"].ToString();
                viewM.SortDirection = (GridFilter.SortDirections)Session["billingSortDirection"];
            }

            //Load user preferences into a dictionary
            preferences = DataCollections.LoadPreferences(db, "Billing", "BillingIndex");

            if (preferences.Count > 0)
            {
                if (preferences["Physician"] != null)
                {
                    splitList  = preferences["Physician"].Split(new char[] { ',' });
                    physicians = splitList.ToList();
                }

                if (preferences["LastNameFilter"] != null)
                {
                    splitList       = preferences["LastNameFilter"].Split(new char[] { ',' });
                    lastnamefilters = splitList.ToList();
                }

                if (preferences["Hospital"] != null)
                {
                    splitList = preferences["Hospital"].Split(new char[] { ',' });
                    hospitals = splitList.ToList();
                }

                if (preferences["ServiceType"] != null)
                {
                    splitList = preferences["ServiceType"].Split(new char[] { ',' });
                    services  = splitList.ToList();
                }
                if (preferences["NotesCompleted"] != null)
                {
                    if (preferences["NotesCompleted"] == "true")
                    {
                        notesCompleted = true;
                    }
                    else
                    {
                        notesCompleted = false;
                    }
                }
                if (preferences["NotesCopied"] != null)
                {
                    if (preferences["NotesCopied"] == "true")
                    {
                        notesCopied = true;
                    }
                    else
                    {
                        notesCopied = false;
                    }
                }
                if (preferences["FaceSheetEntered"] != null)
                {
                    if (preferences["FaceSheetEntered"] == "true")
                    {
                        faceSheetEntered = true;
                    }
                    else
                    {
                        faceSheetEntered = false;
                    }
                }
                if (preferences["CodingCompleted"] != null)
                {
                    if (preferences["CodingCompleted"] == "true")
                    {
                        codingCompleted = true;
                    }
                    else
                    {
                        codingCompleted = false;
                    }
                }
                if (preferences["ChargePosted"] != null)
                {
                    if (preferences["ChargePosted"] == "true")
                    {
                        chargePosted = true;
                    }
                    else
                    {
                        chargePosted = false;
                    }
                }
            }

            //if (Session["billingPhysicians"] != null)
            //{
            //    physicians = (List<string>)Session["billingPhysicians"];
            //}
            //if (Session["billingHospitals"] != null)
            //{
            //    hospitals = (List<string>)Session["billingHospitals"];
            //}
            //if (Session["billingServices"] != null)
            //{
            //    services = (List<string>)Session["billingServices"];
            //}
            //if (Session["billingLastNameFilters"] != null)
            //{
            //    lastnamefilters = (List<string>)Session["billingLastNameFilters"];
            //}

            //if (Session["billingNotesCompleted"] != null)
            //{
            //    notesCompleted = (bool)Session["billingNotesCompleted"];
            //}
            //if (Session["billingNotesCopied"] != null)
            //{
            //    notesCopied = (bool)Session["billingNotesCopied"];
            //}
            //if (Session["billingFaceSheetEntered"] != null)
            //{
            //    faceSheetEntered = (bool)Session["billingFaceSheetEntered"];
            //}
            //if (Session["billingCodingCompleted"] != null)
            //{
            //    codingCompleted = (bool)Session["billingCodingCompleted"];
            //}
            //if (Session["billingChargePosted"] != null)
            //{
            //    chargePosted = (bool)Session["billingChargePosted"];
            //}

            Session["billingFromDate"]      = fromD;
            Session["billingToDate"]        = toD;
            Session["billingSortColumn"]    = viewM.SortColumn;
            Session["billingSortDirection"] = viewM.SortDirection;
            //Session["billingPhysicians"] = physicians;
            //Session["billingHospitals"] = hospitals;
            //Session["billingServices"] = services;
            //Session["billingLastNameFilters"] = lastnamefilters;
            //Session["billingNotesCompleted"] = notesCompleted;
            //Session["billingNotesCopied"] = notesCopied;
            //Session["billingFaceSheetEntered"] = faceSheetEntered;
            //Session["billingCodingCompleted"] = codingCompleted;
            //Session["billingChargePosted"] = chargePosted;

            IQueryable <BillingIndexPatient> query = billingIndexQueryGenerator(fromD, toD, physicians, hospitals, services, lastnamefilters, notesCompleted, notesCopied, faceSheetEntered, chargePosted, codingCompleted, viewM.SortDirection, viewM.SortColumn, false);

            viewM.Patients           = query.AsEnumerable();
            viewM.FromDate           = fromD.ToShortDateString();
            viewM.ToDate             = toD.ToShortDateString();
            viewM.PhysicianList      = DataCollections.getAIMSPhy(db);
            viewM.HospitalList       = DataCollections.getHospital(db);
            viewM.ServiceList        = DataCollections.getServiceType(db);
            viewM.LastNameFilterList = DataCollections.getLastNameFilter();
            viewM.YesNo = DataCollections.getYesNo();
            viewM.SelectedPhysicians       = physicians;
            viewM.SelectedHospitals        = hospitals;
            viewM.SelectedServices         = services;
            viewM.SelectedLastNameFilters  = lastnamefilters;
            viewM.SelectedNotesCompleted   = notesCompleted;
            viewM.SelectedNotesCopied      = notesCopied;
            viewM.SelectedFaceSheetEntered = faceSheetEntered;
            viewM.SelectedCodingCompleted  = codingCompleted;
            viewM.SelectedChargePosted     = chargePosted;
            return(View("Index", viewM));
        }
示例#6
0
        // GET: PatientLog/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PatientLog patientLog = await db.PatientLogs.FindAsync(id);

            PatientLogEditViewModel viewM = new PatientLogEditViewModel();

            if (patientLog == null)
            {
                return(HttpNotFound());
            }
            viewM.Patient = patientLog;

            //Checks if service type is faxable
            bool foundType = db.FaxServiceTypes.AsEnumerable().Any(f => f.Service == patientLog.ServiceType);

            //If faxable, check that a notification was not sent already, and return the result
            if (foundType)
            {
                string faxType = (from f in db.FaxServiceTypes
                                  where f.Service == patientLog.ServiceType
                                  select f.FaxType).Single() + "Notification";

                bool commSent = db.PCPCommunications.AsEnumerable().Where(c => c.PLRecord == id && c.DocumentType == faxType).Any();
                viewM.isFaxable    = !commSent;
                viewM.alreadyFaxed = commSent;
            }
            else
            {
                viewM.isFaxable = false;
            }

            List <int> idList = (List <int>)Session["patientLogListOfID"];

            //Populates index variables that the view uses to set up previous/next logic
            for (int i = 0; i < idList.Count; i++)
            {
                if (id == idList[i])
                {
                    viewM.Indexer = i;
                    break;
                }
            }
            viewM.IndexerDisplay = viewM.Indexer + 1;
            if (idList.Count() == 1)
            {
                viewM.SafeIndexerPrev = 0;
                viewM.SafeIndexerNext = 0;
            }
            else
            {
                if (viewM.Indexer == 0)
                {
                    viewM.SafeIndexerPrev = 1;
                }
                else
                {
                    viewM.SafeIndexerPrev = viewM.Indexer - 1;
                }
                if (viewM.Indexer == (idList.Count() - 1))
                {
                    viewM.SafeIndexerNext = viewM.Indexer - 1;
                }
                else
                {
                    viewM.SafeIndexerNext = viewM.Indexer + 1;
                }
            }

            //Populates dropdownlists with selected value of current patient
            viewM.GenderList       = DataCollections.getGender(db, viewM.Patient.Gender);
            viewM.HospitalList     = DataCollections.getHospital(db, viewM.Patient.Hospital);
            viewM.PCPList          = DataCollections.getPCP(db, viewM.Patient.Hospital, viewM.Patient.PCP_Practice);
            viewM.ServiceTypeList  = DataCollections.getServiceType(db, viewM.Patient.ServiceType);
            viewM.PatientClassList = DataCollections.getPatientClass(db, viewM.Patient.PatientClass);
            viewM.PhysicianList    = DataCollections.getAIMSPhy(db, viewM.Patient.Hospital, viewM.Patient.Physician);
            return(View(viewM));
        }
示例#7
0
        //public FileResult ExportFile()
        //{


        //    return File("C:\\Users\\Ficke\\Desktop\\Import2.xlsx", "application/xlsx", "NewImportYay.xlsx");
        //}

        // GET: PatientAssignment/EditAll
        public ActionResult EditAll()
        {
            var fromD = new DateTime();
            var toD   = new DateTime();

            //List<string> physicians = new List<string>();
            //List<string> hospitals = new List<string>();
            //string hospitals;

            if (Session["patientAssignmentFromDate"] != null && Session["patientAssignmentToDate"] != null)
            {
                fromD = Convert.ToDateTime(Session["patientAssignmentFromDate"]);
                toD   = Convert.ToDateTime(Session["patientAssignmentToDate"]);
            }
            else
            {
                fromD = DateTime.Now.AddDays(intDayFallback);
                toD   = DateTime.Now;
            }
            //if (Session["patientAssignmentPhysicians"] != null)
            //{
            //    physicians = (List<string>)Session["patientAssignmentPhysicians"];
            //}
            //else
            //{
            //    physicians.Add(HubSecurity.getLoggedInUserID());
            //}
            //if (Session["patientAssignmentHospitals"] != null)
            //{
            //    hospitals = Session["patientAssignmentHospitals"].ToString();
            //}

            PatientAssignmentEditAllViewModel viewM = new PatientAssignmentEditAllViewModel();

            viewM.FromDate = fromD.ToShortDateString();
            viewM.ToDate   = toD.ToShortDateString();
            viewM.isAdmin  = (HubSecurity.isAdmin || HubSecurity.isSiteLeader);

            PatientLogEditViewModel oneEntry;
            List <int> patientList = (List <int>)Session["patientAssignmentListOfID"];

            //Checks if list is null, this should never be the case but stops page from erroring out. This session variable is only empty
            //if you browse to this page before using the Index page
            if (patientList != null)
            {
                foreach (int patID in patientList)
                {
                    oneEntry         = new PatientLogEditViewModel();
                    oneEntry.Patient = db.PatientLogs.Find(patID);

                    oneEntry.GenderList       = DataCollections.getGender(db, oneEntry.Patient.Gender);
                    oneEntry.HospitalList     = DataCollections.getHospital(db, oneEntry.Patient.Hospital);
                    oneEntry.PCPList          = DataCollections.getPCP(db, oneEntry.Patient.Hospital, oneEntry.Patient.PCP_Practice);
                    oneEntry.ServiceTypeList  = DataCollections.getServiceType(db, oneEntry.Patient.ServiceType);
                    oneEntry.PatientClassList = DataCollections.getPatientClass(db, oneEntry.Patient.PatientClass);
                    oneEntry.PhysicianList    = DataCollections.getAIMSPhy(db, oneEntry.Patient.Hospital, oneEntry.Patient.Physician);

                    viewM.Patients.Add(oneEntry);
                }
            }

            return(View("EditAll", viewM));
        }
示例#8
0
        public ActionResult Index(PatientAssignmentIndexViewModel viewM)
        {
            //Value will always be null unless CopyButton caused post
            if (viewM.CopyButton != null)
            {
                DataSubmissions.CopyPatients(db, viewM.hidSelectedIDs);
            }
            //Value will always be null unless DeleteButton caused post
            if (viewM.DeleteButton != null)
            {
                DataSubmissions.DeletePatients(db, viewM.hidSelectedIDs);
            }

            var           fromD      = new DateTime();
            var           toD        = new DateTime();
            List <string> physicians = new List <string>();
            //List<string> hospitals = new List<string>();
            string        hospitals = viewM.SelectedHospitals;
            List <string> services  = new List <string>();

            string[] splitList;

            //Manages physician input and builds a List<string> to be used in the query
            if (viewM.hidPhysicians != null && viewM.hidPhysicians != "")
            {
                splitList  = viewM.hidPhysicians.Split(new char[] { ',' });
                physicians = splitList.ToList <string>();
            }

            //Manages physician input and builds a List<string> to be used in the query
            //if (viewM.hidHospitals != null && viewM.hidHospitals != "")
            //{
            //    //splitList = viewM.hidHospitals.Split(new char[] { ',' });
            //    //hospitals = splitList.ToList<string>();
            //    hospitals = viewM.hidHospitals;
            //}
            if (viewM.hidServices != null && viewM.hidServices != "")
            {
                splitList = viewM.hidServices.Split(new char[] { ',' });
                services  = splitList.ToList <string>();
            }


            fromD = getValidDate(viewM.FromDate, true);
            toD   = getValidDate(viewM.ToDate, false);

            PatientAssignmentIndexViewModel returnM = new PatientAssignmentIndexViewModel();

            returnM.FromDate           = fromD.ToShortDateString();
            returnM.ToDate             = toD.ToShortDateString();
            returnM.PhysicianList      = DataCollections.getAIMSPhy(db);
            returnM.HospitalList       = DataCollections.getHospital(db);
            returnM.ServiceList        = DataCollections.getServiceType(db);
            returnM.ImportColumns      = DataCollections.getImportColumns(db);
            returnM.SelectedPhysicians = physicians;
            returnM.SelectedHospitals  = hospitals;
            returnM.SelectedServices   = services;
            returnM.SortColumn         = viewM.SortColumn;
            returnM.SortDirection      = viewM.SortDirection;

            Session["patientAssignmentFromDate"]      = fromD;
            Session["patientAssignmentToDate"]        = toD;
            Session["patientAssignmentSortColumn"]    = returnM.SortColumn;
            Session["patientAssignmentSortDirection"] = returnM.SortDirection;
            //Session["patientAssignmentPhysicians"] = physicians;
            //Session["patientAssignmentHospitals"] = hospitals;
            //Session["patientAssignmentServices"] = services;

            IQueryable <PatientLog> query = patientAssignmentQueryGenerator(fromD, toD, physicians, hospitals, services, returnM.SortDirection, returnM.SortColumn);

            returnM.Patients      = query.AsEnumerable <PatientLog>();
            returnM.ToLookupTally = query.ToLookup(p => p.Physician, p => p.ServiceType).ToDictionary(p => p.Key, p => p.ToArray());
            if (returnM.ToLookupTally.Count == 0)
            {
                returnM.ToLookupTally.Add("No data", new string[] { "" });
            }
            return(View(returnM));
        }
示例#9
0
        //GET: PatientLog
        public ActionResult Index()
        {
            var viewM = new PatientAssignmentIndexViewModel();
            var fromD = new DateTime();
            var toD   = new DateTime();
            Dictionary <string, string> preferences = new Dictionary <string, string>();
            List <string> physicians = new List <string>();
            string        hospitals  = "BRO";
            List <string> services   = new List <string>();

            string[] splitList;

            if (Session["patientAssignmentFromDate"] != null && Session["patientAssignmentToDate"] != null)
            {
                fromD = Convert.ToDateTime(Session["patientAssignmentFromDate"]);
                toD   = Convert.ToDateTime(Session["patientAssignmentToDate"]);
            }
            else
            {
                fromD = DateTime.Now.AddDays(intDayFallback);
                fromD = fromD.Date + new TimeSpan(0, 0, 0);
                toD   = DateTime.Now;
                toD   = toD.Date + new TimeSpan(23, 59, 59);
            }
            if (Session["patientAssignmentSortColumn"] != null)
            {
                //sortColumn = Session["patientLogSortColumn"].ToString();
                //sortDirection = (GridFilter.FilterTypes)Session["patientLogSortDirection"];
                viewM.SortColumn    = Session["patientAssignmentSortColumn"].ToString();
                viewM.SortDirection = (GridFilter.SortDirections)Session["patientAssignmentSortDirection"];
            }

            //Load user preferences into a dictionary
            preferences = DataCollections.LoadPreferences(db, "PatientAssignment", "PatientAssignmentIndex");

            if (preferences.Count > 0)
            {
                if (preferences["Physician"] != null)
                {
                    splitList  = preferences["Physician"].Split(new char[] { ',' });
                    physicians = splitList.ToList();
                }

                if (preferences["Hospital"] != null)
                {
                    hospitals = preferences["Hospital"];
                }

                if (preferences["ServiceType"] != null)
                {
                    splitList = preferences["ServiceType"].Split(new char[] { ',' });
                    services  = splitList.ToList();
                }
            }
            //if (Session["patientAssignmentPhysicians"] != null)
            //{
            //    physicians = (List<string>)Session["patientAssignmentPhysicians"];
            //}
            //if (Session["patientAssignmentHospitals"] != null)
            //{
            //    string hosp = Session["patientAssignmentHospitals"].ToString();
            //    //tempList.Add(hosp);
            //    hospitals = hosp;
            //}
            //else
            //{
            //    //List<string> tempList = new List<string>();
            //    //string usr = HubSecurity.getLoggedInUserID();
            //    ////string hosp = (from u in db.UserDetails
            //    ////              where u.UserID == usr && u.UserType == "AIMSPhy"
            //    ////              select u.DefaultHospital).Single().ToString();
            //    //string hosp = "HFM"; //DEBUG
            //    //tempList.Add(hosp);
            //    hospitals = "BRO";
            //}
            //if (Session["patientAssignmentServices"] != null)
            //{
            //    services = (List<string>)Session["patientAssignmentServices"];
            //}



            Session["patientAssignmentFromDate"]      = fromD;
            Session["patientAssignmentToDate"]        = toD;
            Session["patientAssignmentSortColumn"]    = viewM.SortColumn;
            Session["patientAssignmentSortDirection"] = viewM.SortDirection;
            //Session["patientAssignmentPhysicians"] = physicians;
            //Session["patientAssignmentHospitals"] = hospitals;
            //Session["patientAssignmentServices"] = services;

            IQueryable <PatientLog> query = patientAssignmentQueryGenerator(fromD, toD, physicians, hospitals, services, viewM.SortDirection, viewM.SortColumn);

            viewM.Patients = query.AsEnumerable <PatientLog>();
            //viewM.ToLookupTally = viewM.Patients.ToLookup(p => p.Physician, p => p.ServiceType);
            viewM.ToLookupTally = query.ToLookup(p => p.Physician, p => p.ServiceType).ToDictionary(p => p.Key, p => p.ToArray());
            if (viewM.ToLookupTally.Count == 0)
            {
                viewM.ToLookupTally.Add("No data", new string[] { "" });
            }
            viewM.FromDate           = fromD.ToShortDateString();
            viewM.ToDate             = toD.ToShortDateString();
            viewM.PhysicianList      = DataCollections.getAIMSPhy(db);
            viewM.HospitalList       = DataCollections.getHospital(db);
            viewM.ServiceList        = DataCollections.getServiceType(db);
            viewM.ImportColumns      = DataCollections.getImportColumns(db);
            viewM.SelectedPhysicians = physicians;
            viewM.SelectedHospitals  = hospitals;
            viewM.SelectedServices   = services;

            return(View("Index", viewM));
        }