Beispiel #1
0
        public void DeleteRange()
        {
            var target    = DoctorScheduleEN.GetService("");
            int startDate = DateTimeEpoch.ConvertDateToSecondsEpoch(new DateTime(2020, 1, 6));
            int endDate   = startDate + DateTimeEpoch.OneDaySeconds;

            var getTimesP = new DoctorScheduleGetByRangeSP()
            {
                DoctorID       = TestEnums.User.constDoctorID,
                StartUnixEpoch = startDate,
                EndUnixEpoch   = endDate
            };

            if (target.GetCountByRange(getTimesP) == 0)
            {
                PopulateDatabase(startDate, endDate, 15);
                Assert.IsTrue(target.GetCountByRange(getTimesP) > 0, "PopulateDatabase didn't generate any doctor availablility time slot.");
            }

            target.DeleteRange(new DoctorScheduleDeleteRangeSP()
            {
                DoctorID       = TestEnums.User.constDoctorID,
                StartUnixEpoch = startDate,
                EndUnixEpoch   = endDate,
            });

            Assert.IsTrue(target.GetCountByRange(getTimesP) == 0, "Delete range didn't all slots in the specified range. Please make sure that there is no visit associated with slots.");
        }
Beispiel #2
0
        //Please write your properties and functions here. This part will not be replaced.


        protected override bool onBeforeInsert(object entitySet, InsertParameters parameters)
        {
            Visit           visit = (Visit)entitySet;
            var             doctorScheduleService = DoctorScheduleEN.GetService("");
            vDoctorSchedule doctorScheduleV       = doctorScheduleService.GetByIDV(visit.DoctorScheduleID, new GetByIDParameters());

            ((VisitBR)BusinessLogicObject).CheckInsert(visit, doctorScheduleV);

            visit.VisitStatusID  = (int)EntityEnums.VisitStatusEnum.Scheduled;
            visit.DoctorReport   = null;
            visit.ChiefComplaint = null;
            visit.Description    = null;

            // updating doctor schedule number of registered patients
            DoctorSchedule doctorSchedule = doctorScheduleService.GetByIDT(visit.DoctorScheduleID, new GetByIDParameters());

            doctorSchedule.NumberOfRegisteredPatients++;

            parameters.DetailEntityObjects.Add(new DetailObjectInfo()
            {
                EntityName = vDoctorSchedule.EntityName,
                FnName     = RuleFunctionSEnum.Update,
                EntitySet  = doctorSchedule
            });

            return(true);
        }
Beispiel #3
0
        public void InsertTest()
        {
            TestUtils.Security.SetCurrentUser(TestEnums.User.constDoctorID);

            var doctorSchedule = DoctorScheduleServiceTest.CreateNewDoctorSchedule();
            var target         = DoctorScheduleEN.GetService("");

            target.Insert(doctorSchedule, new InsertParameters());
            // Happy scenario without exception
        }
Beispiel #4
0
        public ViewNeedClass CheckNeed(long doctorId)
        {
            var filter = new FilterExpression(vDoctorSchedule.ColumnNames.DoctorID, doctorId);

            filter.AddFilter(vDoctorSchedule.ColumnNames.SlotUnixEpoch, DateTimeEpoch.GetUtcNowEpoch(), FilterOperatorEnum.GreaterThan);
            filter.AddFilter(vDoctorSchedule.ColumnNames.NumberOfFreePositions, 0, FilterOperatorEnum.GreaterThan);
            if (DoctorScheduleEN.GetService().GetCount(filter) < 1)
            {
                return(new ViewNeedClass("No available time is available for booking.", "DoctorSchedule-CalendarEdit"));
            }

            return(null);
        }
Beispiel #5
0
        protected override bool onBeforeDelete(object entitySet, DeleteParameters parameters)
        {
            Visit           visit = (Visit)entitySet;
            var             doctorScheduleService = DoctorScheduleEN.GetService("");
            vDoctorSchedule doctorSchedule        = doctorScheduleService.GetByIDV(visit.DoctorScheduleID, new GetByIDParameters());

            doctorSchedule.NumberOfRegisteredPatients--;
            parameters.DetailEntityObjects.Add(new DetailObjectInfo()
            {
                EntityName = vDoctorSchedule.EntityName,
                FnName     = RuleFunctionSEnum.Update,
                EntitySet  = doctorSchedule
            });

            return(true);
        }
Beispiel #6
0
        public void GetByRangeTest()
        {
            DateTime startDate = new DateTime(2020, 1, 1);
            DateTime endDate   = new DateTime(2020, 1, 3);

            var target = DoctorScheduleEN.GetService("");

            var list = target.GetByRange(new DoctorScheduleGetByRangeSP()
            {
                DoctorID       = TestEnums.User.constDoctorID,
                StartUnixEpoch = DateTimeEpoch.ConvertDateToSecondsEpoch(startDate),
                EndUnixEpoch   = DateTimeEpoch.ConvertDateToSecondsEpoch(endDate)
            })
            ;

            Assert.IsTrue(list.Count > 0); // some items retrieved
        }
Beispiel #7
0
        private static void PopulateDatabase(int startDate, int endDate, int numberOfSamples)
        {
            var target = DoctorScheduleEN.GetService("");

            for (int i = 1; i < numberOfSamples; i++)
            {
                var doctorSchedule = DoctorScheduleServiceTest.CreateNewDoctorSchedule();
                int everyFiveMinuteCountInStartDateToEndDate = (endDate - startDate) / 60 / 5;
                int randomNumberInEveryFiveMinuteFromStart   = TestUtils.RandomUtils.RandomNumber(0, everyFiveMinuteCountInStartDateToEndDate);
                int randomTime = startDate + (randomNumberInEveryFiveMinuteFromStart * 60 * 5);
                //TestUtils.RandomUtils.RandomNumber(5, 60) * 60; //every minute is 60 seconds
                doctorSchedule.SlotUnixEpoch = randomTime;
                try
                {
                    target.Insert(doctorSchedule, null);
                }
                catch (BRException)
                {
                    // just don't do anything
                    //i--;
                }
            }
        }
Beispiel #8
0
        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        private IDoctorScheduleService CreateService()
        {
            return(DoctorScheduleEN.GetService(""));
        }