Beispiel #1
0
        public ActionResult FlowSheets()
        {
            var model    = new FlowSheetsModel();
            var db_logic = new DatabaseLogic(connection);
            // get the mrn of the current patient to display correct flow
            // sheets data
            string patient_mrn = Session["mrn"].ToString();


            model.databaseId = Convert.ToInt32(Session["patientId"].ToString());

            //if it's the first time the patient is visiting the page,
            //display the current day and time
            if ((Session["fs_am"]) == null)
            {
                model.curDate = DateTime.Today.Date;
                //for SQL query, set the first datetime of the page range
                if (model.am)
                {
                    model.sqlTime = model.curDate.ToString("MM:dd:yyyy") + ":" + model.amTimes[0].Substring(0, 2);
                }
                else
                {
                    model.sqlTime = model.curDate.ToString("MM:dd:yyyy") + ":" + model.pmTimes[0].Substring(0, 2);
                }

                Session["fs_date"] = model.curDate;
                Session["fs_am"]   = model.am;

                //verify that the model has all correct data
                model = verifyModel(model);
                //verify that all the flowsheets boxes are correct
                db_logic.DatabaseIntegrityCheck(patient_mrn, model);

                model = db_logic.GetFlowSheetsInputData(patient_mrn, model);
                // set the correct hours to display based on time of day
                if (DateTime.Now.Hour < 12)
                {
                    model.am = true;
                    string[] temp = new string[12];
                    model.displayTimes = temp;
                    for (int i = 0; i < model.displayTimes.Length; i++)
                    {
                        model.displayTimes[i] = model.amTimes[i];
                    }
                }
                else
                {
                    model.am           = false;
                    model.displayTimes = new string[12];
                    for (int i = 0; i < model.displayTimes.Length; i++)
                    {
                        model.displayTimes[i] = model.pmTimes[i];
                    }
                }
            }
            // if the patient has already visited the page, display
            // the last day/time where they left off
            else
            {
                model.am      = Convert.ToBoolean(Session["fs_am"]);
                model.curDate = Convert.ToDateTime(Session["fs_date"]);
                if (model.am)
                {
                    model.sqlTime = model.curDate.ToString("MM:dd:yyyy") + ":" + model.amTimes[0].Substring(0, 2);
                }
                else
                {
                    model.sqlTime = model.curDate.ToString("MM:dd:yyyy") + ":" + model.pmTimes[0].Substring(0, 2);
                }
                model = verifyModel(model);
                db_logic.DatabaseIntegrityCheck(patient_mrn, model);
                model = db_logic.GetFlowSheetsInputData(patient_mrn, model);
            }


            return(View(model));
        }