Example #1
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));
        }
Example #2
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));
        }