예제 #1
0
        public ActionResult Index(PatientLogIndexViewModel viewM)
        {
            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>();

            string[] splitList;
            bool     assigned;

            //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.Assigned)
            {
                assigned = (bool)viewM.Assigned;
            }
            else
            {
                assigned = false;
            }


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

            PatientLogIndexViewModel returnM = new PatientLogIndexViewModel();

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

            Session["patientLogFromDate"]      = fromD;
            Session["patientLogToDate"]        = toD;
            Session["patientLogSortColumn"]    = returnM.SortColumn;
            Session["patientLogSortDirection"] = returnM.SortDirection;
            //Session["patientLogPhysicians"] = physicians;
            //Session["patientLogHospitals"] = hospitals;
            //Session["patientLogServices"] = services;
            //Session["patientLogAssigned"] = assigned;

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

            returnM.Patients   = query.AsEnumerable <PatientLog>();
            returnM.RiskFactor = new Dictionary <string, string>();
            foreach (PatientLog pat in returnM.Patients)
            {
                bool isHigh = (from p in db.PatientLogs where pat.MRN_FIN == p.MRN_FIN && p.ServiceType.Contains("DC -") && (p.ServiceDate >= DbFunctions.AddDays(pat.ServiceDate, -7) && p.ServiceDate < pat.ServiceDate) select p.ID).Any();

                if (isHigh)
                {
                    returnM.RiskFactor.Add(pat.ID.ToString(), "H");
                    continue;
                }

                bool isMed = (from p in db.PatientLogs where pat.MRN_FIN == p.MRN_FIN && p.ServiceType.Contains("DC -") && (p.ServiceDate >= DbFunctions.AddDays(pat.ServiceDate, -30) && p.ServiceDate < pat.ServiceDate) select p.ID).Any();

                if (isMed)
                {
                    returnM.RiskFactor.Add(pat.ID.ToString(), "M");
                }
            }
            return(View(returnM));
        }
예제 #2
0
        //GET: PatientLog
        public ActionResult Index()
        {
            var viewM = new PatientLogIndexViewModel();
            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>();

            string[] splitList;
            string   pref;
            bool     assigned;

            //PatientLogIndexViewModel viewM;


            if (Session["patientLogFromDate"] != null && Session["patientLogToDate"] != null)
            {
                fromD = Convert.ToDateTime(Session["patientLogFromDate"]);
                toD   = Convert.ToDateTime(Session["patientLogToDate"]);
            }
            else
            {
                fromD = getValidDate("", true);
                toD   = getValidDate("", false);
            }
            if (Session["patientLogSortColumn"] != null)
            {
                viewM.SortColumn    = Session["patientLogSortColumn"].ToString();
                viewM.SortDirection = (GridFilter.SortDirections)Session["patientLogSortDirection"];
            }

            pref = DataCollections.LoadPreference(db, "PatientLog", "PatientLogIndex", "Hospital");

            if (pref != null)
            {
                splitList = pref.Split(new char[] { ',' });
                hospitals = splitList.ToList();
            }
            pref = DataCollections.LoadPreference(db, "PatientLog", "PatientLogIndex", "ServiceType");
            if (pref != null)
            {
                splitList = pref.Split(new char[] { ',' });
                services  = splitList.ToList();
            }

            if (Session["patientLogAssigned"] != null)
            {
                assigned = (bool)Session["patientLogAssigned"];
            }
            else
            {
                assigned = false;
            }

            Session["patientLogFromDate"]      = fromD;
            Session["patientLogToDate"]        = toD;
            Session["patientLogSortColumn"]    = viewM.SortColumn;
            Session["patientLogSortDirection"] = viewM.SortDirection;
            //Session["patientLogPhysicians"] = physicians;
            //Session["patientLogHospitals"] = hospitals;
            //Session["patientLogServices"] = services;

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

            viewM.Patients = query.AsEnumerable();
            //Determines risk factor for each patient
            viewM.RiskFactor = new Dictionary <string, string>();
            foreach (PatientLog pat in viewM.Patients)
            {
                bool isHigh = (from p in db.PatientLogs where pat.MRN_FIN == p.MRN_FIN && p.ServiceType.Contains("DC -") && (p.ServiceDate >= DbFunctions.AddDays(pat.ServiceDate, -7) && p.ServiceDate < pat.ServiceDate) select p.ID).Any();

                if (isHigh)
                {
                    viewM.RiskFactor.Add(pat.ID.ToString(), "H");
                    continue;
                }

                bool isMed = (from p in db.PatientLogs where pat.MRN_FIN == p.MRN_FIN && p.ServiceType.Contains("DC -") && (p.ServiceDate >= DbFunctions.AddDays(pat.ServiceDate, -30) && p.ServiceDate < pat.ServiceDate) select p.ID).Any();

                if (isMed)
                {
                    viewM.RiskFactor.Add(pat.ID.ToString(), "M");
                }
            }

            if (viewM.RiskFactor == null)
            {
                viewM.RiskFactor.Add("testkey", "val1");
            }
            viewM.FromDate = fromD.ToShortDateString();
            viewM.ToDate   = toD.ToShortDateString();
            //viewM.PhysicianList = DataCollections.getAIMSPhy(db);
            viewM.HospitalList = DataCollections.getHospital(db);
            viewM.ServiceList  = DataCollections.getServiceType(db);
            //viewM.SelectedPhysicians = physicians;
            viewM.SelectedHospitals = hospitals;
            viewM.SelectedServices  = services;

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