Exemplo n.º 1
0
        public SpecimentsInOrder GetDataSpeciment()
        {
            SessionFactory SF = new SessionFactory();

            SF.Init();
            SF.OpenSession();

            int IdSpeciment = 2;

            //вытягиваем все тесты для спесимента ,у которого id=2
            GenericDaoImpl <SpecimentsInOrder, int> specimentDao = new GenericDaoImpl <SpecimentsInOrder, int>(SF.GetSession());
            SpecimentsInOrder spec = specimentDao.Get(IdSpeciment);

            spec.testsInOrderList = new List <int>();

            TestsInOrderDaoImpl testDao = new TestsInOrderDaoImpl(SF.GetSession());

            foreach (TestsInOrder item in testDao.GetTestsOfSpeciment(IdSpeciment).ToList())
            {
                spec.testsInOrderList.Add(item.ID_TestOrder);
            }

            SF.CloseSession();
            return(spec);
        }
Exemplo n.º 2
0
        public void DeleteSpeciment(List <SpecimentsInOrder> listSpeciments)
        {
            SessionFactory SF = new SessionFactory();

            SF.Init();
            SF.OpenSession();

            SpecimentsInOrderDaoImpl              specimentDao       = new SpecimentsInOrderDaoImpl(SF.GetSession());
            GenericDaoImpl <OrderOfPatient, int>  orderDao           = new GenericDaoImpl <OrderOfPatient, int>(SF.GetSession());
            GenericDaoImpl <Speciment, int>       specimentNameDao   = new GenericDaoImpl <Speciment, int>(SF.GetSession());
            GenericDaoImpl <SpecimentStatus, int> specimentStatusDao = new GenericDaoImpl <SpecimentStatus, int>(SF.GetSession());
            TestsInOrderDaoImpl              testDao       = new TestsInOrderDaoImpl(SF.GetSession());
            GenericDaoImpl <Test, int>       testNameDao   = new GenericDaoImpl <Test, int>(SF.GetSession());
            GenericDaoImpl <TestStatus, int> testStatusDao = new GenericDaoImpl <TestStatus, int>(SF.GetSession());
            List <TestsInOrder>              listTest;

            OrderOfPatient  order           = new OrderOfPatient();
            Speciment       specimentName   = new Speciment();
            SpecimentStatus specimentStatus = new SpecimentStatus();
            Test            testName        = new Test();
            TestStatus      testStatus      = new TestStatus();

            foreach (SpecimentsInOrder itemSpec in listSpeciments)
            {
                order           = orderDao.Get(itemSpec.Order.ID_Order);
                specimentName   = specimentNameDao.Get(itemSpec.Speciment.ID_Speciment);
                specimentStatus = specimentStatusDao.Get(itemSpec.SpecimentStatus.ID_SpecimentStatus);

                itemSpec.Order           = order;
                itemSpec.Speciment       = specimentName;
                itemSpec.SpecimentStatus = specimentStatus;
                itemSpec.Status          = 0;
                specimentDao.SaveOrUpdate(itemSpec);

                listTest = testDao.GetTestsOfSpeciment(itemSpec.ID_SpecimentOrder).ToList();

                if (listTest.Count > 0)
                {
                    foreach (TestsInOrder itemTest in listTest)
                    {
                        testName   = testNameDao.Get(itemTest.Test.ID_Test);
                        testStatus = testStatusDao.Get(itemTest.TestStatus.ID_TestStatus);

                        itemTest.Test       = testName;
                        itemTest.TestStatus = testStatus;
                        itemTest.Status     = 0;
                        testDao.SaveOrUpdate(itemTest);
                    }
                }
            }

            SF.CloseSession();
        }
Exemplo n.º 3
0
        public void DeleteOrder(List <OrderOfPatient> listOrders)
        {
            SessionFactory SF = new SessionFactory();

            SF.Init();
            SF.OpenSession();

            OrderOfPatientDaoImpl    orderDao     = new OrderOfPatientDaoImpl(SF.GetSession());
            SpecimentsInOrderDaoImpl specimentDao = new SpecimentsInOrderDaoImpl(SF.GetSession());
            TestsInOrderDaoImpl      testDao      = new TestsInOrderDaoImpl(SF.GetSession());

            List <SpecimentsInOrder> listSpec;
            List <TestsInOrder>      listTest;

            foreach (OrderOfPatient item in listOrders)
            {
                item.Status = 0;
                orderDao.SaveOrUpdate(item);

                listSpec = specimentDao.GetSpecimentsOfOrder(item.ID_Order).ToList();

                if (listSpec.Count > 0)
                {
                    foreach (SpecimentsInOrder itemSpec in listSpec)
                    {
                        itemSpec.Status = 0;
                        specimentDao.SaveOrUpdate(itemSpec);

                        listTest = testDao.GetTestsOfSpeciment(itemSpec.ID_SpecimentOrder).ToList();

                        if (listTest.Count > 0)
                        {
                            foreach (TestsInOrder itemTest in listTest)
                            {
                                itemTest.Status = 0;
                                testDao.SaveOrUpdate(itemTest);
                            }
                        }
                    }
                }
            }


            SF.CloseSession();
        }
Exemplo n.º 4
0
        public void DeletePatient(List <Patient> listPatients)
        {
            SessionFactory SF = new SessionFactory();

            SF.Init();
            SF.OpenSession();

            GenericDaoImpl <Patient, int> patientDao  = new GenericDaoImpl <Patient, int>(SF.GetSession());
            RelativeDaoImpl              relativeDao  = new RelativeDaoImpl(SF.GetSession());
            OrderOfPatientDaoImpl        orderDao     = new OrderOfPatientDaoImpl(SF.GetSession());
            SpecimentsInOrderDaoImpl     specimentDao = new SpecimentsInOrderDaoImpl(SF.GetSession());
            TestsInOrderDaoImpl          testDao      = new TestsInOrderDaoImpl(SF.GetSession());
            GenericDaoImpl <Gender, int> genderDao    = new GenericDaoImpl <Gender, int>(SF.GetSession());

            List <Relative>          listRel;
            List <OrderOfPatient>    listOrd;
            List <SpecimentsInOrder> listSpec;
            List <TestsInOrder>      listTest;

            Gender male   = genderDao.Get(1);
            Gender female = genderDao.Get(2);

            foreach (Patient patient in listPatients)
            {
                if (patient.Gender.ID_Gender == male.ID_Gender)
                {
                    patient.Gender = male;
                }
                else if (patient.Gender.ID_Gender == female.ID_Gender)
                {
                    patient.Gender = female;
                }

                listRel = relativeDao.GetListRelativesOfPatient(patient.ID_Patient).ToList();
                listOrd = orderDao.GetOrdersOfPatient(patient.ID_Patient).ToList();

                if (listRel.Count == 0 && listOrd.Count == 0)
                {
                    patientDao.Delete(patient);
                }
                else if (listRel.Count > 0 || listOrd.Count > 0)
                {
                    if (listRel.Count > 0)
                    {
                        foreach (Relative item in listRel)
                        {
                            item.Status = 0;
                            relativeDao.SaveOrUpdate(item);
                        }
                    }
                    if (listOrd.Count > 0)
                    {
                        foreach (OrderOfPatient item in listOrd)
                        {
                            item.Status = 0;
                            orderDao.SaveOrUpdate(item);

                            listSpec = specimentDao.GetSpecimentsOfOrder(item.ID_Order).ToList();

                            if (listSpec.Count > 0)
                            {
                                foreach (SpecimentsInOrder itemSpec in listSpec)
                                {
                                    itemSpec.Status = 0;
                                    specimentDao.SaveOrUpdate(itemSpec);

                                    listTest = testDao.GetTestsOfSpeciment(itemSpec.ID_SpecimentOrder).ToList();

                                    if (listTest.Count > 0)
                                    {
                                        foreach (TestsInOrder itemTest in listTest)
                                        {
                                            itemTest.Status = 0;
                                            testDao.SaveOrUpdate(itemTest);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    patient.Status = 0;
                    patientDao.SaveOrUpdate(patient);
                }
            }
            SF.CloseSession();
        }