コード例 #1
0
        /// <summary>
        /// משנה עונה לעונה מוגדרת כאשר יש מספיק מידע המוכיח את השוני המשמעותי בעונה
        /// </summary>
        /// <param name="seasonType"></param>
        /// <param name="num"></param>
        public static void DefineSeasonInfo(int seasonType, int num)
        {
            Hospital_DBEntities2 db          = new Hospital_DBEntities2();
            List <Seasons>       tempSeasons = new List <Seasons>();
            Seasons tempLongSeasons          = new Seasons();

            switch (seasonType)
            {
            case 1: { db.Seasons.Add(new Seasons {
                        Date = DateTime.Today.Date, IsDefined = true, NumOfDays = 1
                    }); db.SaveChanges(); tempSeasons = BLManager.GetCurrentDate(false); tempLongSeasons = BLManager.GetLongDateSeason(); BLManager.CurrentDate = db.Seasons.Last(); } break;

            case 2: { db.Seasons.Add(new Seasons {
                        HebrewDate = DateTime.Today.Date, IsDefined = true, NumOfDays = 1
                    }); db.SaveChanges(); tempSeasons = BLManager.GetCurrentHeberewDate(false); tempLongSeasons = BLManager.GetLongHeberewDateSeason(); BLManager.CurrentHeberewDate = db.Seasons.Last(); } break;

            case 3: { db.Seasons.Add(new Seasons {
                        DayOfWeek = (int)DateTime.Today.DayOfWeek, IsDefined = true, NumOfDays = 1
                    }); tempSeasons = BLManager.GetCurrentDayOfWeek(false); BLManager.CurrentDayOfWeek = db.Seasons.Last(); } break;
            }

            db.SaveChanges();
            List <SeasonInformation> seasonTempInfo = new List <SeasonInformation>();

            if (tempLongSeasons == null)
            {
                //מקבץ את כל המידע לתקופה של תקופת יום בשבוע מסויימת לא מוגדרות
                CombineSeasons(GetInfoForSeasonList(tempSeasons), num, db.Seasons.ToList().Last().SeasonCode);
            }
            else
            {
                if (seasonType == 1)
                {
                    BLManager.CurrentDate = tempLongSeasons;
                }
                else
                {
                    BLManager.CurrentHeberewDate = tempLongSeasons;
                }
                CombineSeasons(GetInfoForSeasonList(tempSeasons), 5, tempLongSeasons.SeasonCode);
                db.Seasons.Remove(db.Seasons.Last());
            }

            db.SeasonInformation.ToList().ForEach(se => tempSeasons.ForEach(s => { if (se.SeasonCode == s.SeasonCode)
                                                                                   {
                                                                                       seasonTempInfo.Add(se);
                                                                                   }
                                                                            }));
            db.SeasonInformation.RemoveRange(seasonTempInfo);
            db.SaveChanges();
            List <int> listCode = tempSeasons.Select(i => i.SeasonCode).ToList();

            db.Seasons.RemoveRange(db.Seasons.Where(item => listCode.Any(item2 => item2 == item.SeasonCode)));
        }
コード例 #2
0
        /// <summary>
        /// אם הממוצע היומי שונה משמעותית מהמידע הכללי ולא מופיע לתאריך זה מידע שהוגדר
        /// נוצר מופע חדש של עונה לא מוגדרת המכילה את כל הנתונים- תאריך עברי לועזי ויום בשבוע לצורך בדיקה
        /// </summary>
        public void AddSeason()
        {
            List <Seasons>       seasonToCheck = new List <Seasons>();
            Hospital_DBEntities2 db            = new Hospital_DBEntities2();

            if (BLManager.CurrentDate != null)
            {
                seasonToCheck.Add(BLManager.CurrentDate);
            }
            if (BLManager.CurrentHeberewDate != null)
            {
                seasonToCheck.Add(BLManager.CurrentHeberewDate);
            }
            else if (BLManager.CurrentDate == null)
            {
                seasonToCheck.Add(new Seasons {
                    Date = DateTime.Today, DayOfWeek = ((int)DateTime.Today.DayOfWeek) + 1, HebrewDate = DateTime.Today, IsDefined = false, NumOfDays = 1
                });
                db.Seasons.Add(seasonToCheck[0]);
                db.SaveChanges();
            }
            seasonToCheck.ForEach(s =>
            {
                db.SeasonInformation.Add(new SeasonInformation
                {
                    AddingDate       = DateTime.Today,
                    DepartmentCode   = DepartmentCode,
                    Ishistory        = false,
                    StaffAvg         = StaffAvg,
                    WaitersAvg       = WaitersAvg,
                    WaitingTimeAvg   = DayWaitingAvg,
                    Whidnesstochange = 1,
                    SeasonCode       = s.SeasonCode
                });
            });
            db.SaveChanges();
            if (BLManager.GetCurrentDate(false).Count() == 10)
            {
                DefineSeasonInfo(1, 5);
            }

            if (BLManager.GetCurrentHeberewDate(false).Count() == 10)
            {
                DefineSeasonInfo(2, 5);
            }

            if (BLManager.GetCurrentDayOfWeek(false).Count() == 100)
            {
                DefineSeasonInfo(3, 52);
            }
        }
コード例 #3
0
        /// <summary>
        /// מחשבת את זמן ההמתנה המשוער במחלקה ובאגף המיון יחד
        /// עפ"י התאריך-העברי הלועזי והיום בשבוע והמצב הנוכחי במחלקה
        /// </summary>
        /// <param name="departmentCode"></param>
        public void CalcWaitingTime(int departmentCode)
        {
            Hospital_DBEntities2 db             = new Hospital_DBEntities2();
            SeasonInformation    dayOfWeekAvg   = null;
            SeasonInformation    dateAvg        = null;
            SeasonInformation    heberewDateAvg = null;

            if (BLManager.CurrentDayOfWeek != null)
            {
                dayOfWeekAvg = BLManager.GetSeasonInformation(BLManager.CurrentDayOfWeek.SeasonCode, departmentCode, true);
            }
            //בגלל שיש שוני בין השנים והמועדים הלועזיים תלויים ביום בחודש ובחודש לכן היחס ליום הינו אילו היה חל בשנה בו נשמר המידע
            if (BLManager.CurrentDate != null)
            {
                dateAvg = BLManager.GetSeasonInformation(BLManager.CurrentDate.SeasonCode, departmentCode, true);
            }
            if (BLManager.CurrentHeberewDate != null)
            {
                heberewDateAvg = BLManager.GetSeasonInformation(BLManager.CurrentHeberewDate.SeasonCode, departmentCode, true);
            }
            if (dayOfWeekAvg == null && heberewDateAvg == null && dateAvg == null)
            {
                WaitingTime += StatisticsCalculations.CalcEstimatedWaitingTime(db.Departments.FirstOrDefault(d => d.DepartmentCode == departmentCode).SeasonInformation.FirstOrDefault(si => si.SeasonCode == db.Seasons.FirstOrDefault(s => s.HebrewDate == null && s.Date.Value == null && s.DayOfWeek == null).SeasonCode));
            }
            else if (dayOfWeekAvg != null && heberewDateAvg == null && dateAvg == null)
            {
                WaitingTime += StatisticsCalculations.CalcEstimatedWaitingTime(dayOfWeekAvg);
            }
            else if (heberewDateAvg != null && dateAvg == null)
            {
                WaitingTime += StatisticsCalculations.CalcEstimatedWaitingTime(heberewDateAvg);
            }
            else if (heberewDateAvg == null && dateAvg != null)
            {
                WaitingTime += StatisticsCalculations.CalcEstimatedWaitingTime(dateAvg);
            }
            else if (heberewDateAvg != null && dateAvg != null)//אם יום מסויים הינו גם תאריך עברי מיוחד וגם תאריך לועזי מיוחד משוקלל הממוצע של שניהם
            {
                WaitingTime += StatisticsCalculations.CalcEstimatedWaitingTime(heberewDateAvg);
                WaitingTime += StatisticsCalculations.CalcEstimatedWaitingTime(dateAvg);
                WaitingTime -= StatisticsCalculations.CalcEstimatedWaitingTime(BLManager.GetSeasonInformation(db.Seasons.FirstOrDefault(s => s.NumOfDays == 365).SeasonCode, departmentCode, true));
            }
            else //אין אף תאריך מיוחד סימן הזיהוי של המידע הכללי הינו אורך של 365 ימים
            {
                WaitingTime += StatisticsCalculations.CalcEstimatedWaitingTime(BLManager.GetSeasonInformation(db.Seasons.FirstOrDefault(s => s.NumOfDays == 365).SeasonCode, departmentCode, true));
            }
        }
コード例 #4
0
        /// <summary>
        /// עידכון נתוני העונות במסד הנתונים
        /// </summary>
        public void SetSeasonInfo()

        {       //set date not historical season information
            if (BLManager.CurrentDate != null && BLManager.GetSeasonInformation(BLManager.CurrentDate.SeasonCode, DepartmentCode, false) != null)
            {
                SetSeasonInfoInDB(BLManager.GetSeasonInformation(BLManager.CurrentDate.SeasonCode, DepartmentCode, false));
            }
            //set heberew date not historical season information
            if (BLManager.CurrentHeberewDate != null && BLManager.GetSeasonInformation(BLManager.CurrentHeberewDate.SeasonCode, DepartmentCode, false) != null)
            {
                SetSeasonInfoInDB(BLManager.GetSeasonInformation(BLManager.CurrentHeberewDate.SeasonCode, DepartmentCode, false));
            }

            //set day of week not historical  season information
            if (BLManager.CurrentDayOfWeek != null && BLManager.GetSeasonInformation(BLManager.CurrentDayOfWeek.SeasonCode, DepartmentCode, false) != null)
            {
                SetSeasonInfoInDB(BLManager.GetSeasonInformation(BLManager.CurrentDayOfWeek.SeasonCode, DepartmentCode, false));
            }
            //Check if difining new season needed (if no specific info for dopartment for heberew date or date)
            if ((BLManager.CurrentDate == null || BLManager.GetSeasonInformation(BLManager.CurrentDate.SeasonCode, DepartmentCode, false) == null) && (BLManager.CurrentHeberewDate == null || BLManager.GetSeasonInformation(BLManager.CurrentHeberewDate.SeasonCode, DepartmentCode, false) == null))
            {
                //only day of week info is not strong enough
                //רוצים לבדוק האם הנתונים של היום שונים באופן משמעותי מהנתונים הכלליים
                //האם צריך לשמור את היום כתאריך מיוחד או לא
                //הנתונים הכלליים משמעותם: או המידע של כל השנה או המידע של היום הנוכחי בשבוע, תלוי בשאילה אם
                //יש מידע על יום בשבוע או אין
                SeasonInformation infoToCheck;
                if (BLManager.CurrentDayOfWeek == null)
                {
                    infoToCheck = BLManager.GetSeasonInformation(new Hospital_DBEntities2().Seasons.First(s => s.NumOfDays == 365).SeasonCode, DepartmentCode, true);
                }
                else
                {
                    infoToCheck = BLManager.GetSeasonInformation(BLManager.CurrentDayOfWeek.SeasonCode, DepartmentCode, true);
                }
                //בודק מה היחס שבין היחסים של התאריכים
                //אם היחס שונה משמעותית
                if (infoToCheck.Ratio / DayWaitingAvg / (WaitersAvg / StaffAvg) < 0.5 || infoToCheck.Ratio / (DayWaitingAvg / (WaitersAvg / StaffAvg)) > 1.5)
                {
                    AddSeason();
                }
            }
        }