Ejemplo n.º 1
0
        public static Order CreateOrder(Patient patient, Visit visit, Facility facility, string accession, int numProcedures, int numMpsPerProcedure, bool createProcedureSteps, bool schedule)
        {
            var      procedureNumberBroker = new TestProcedureNumberBroker();
            var      dicomUidBroker        = new TestDicomUidBroker();
            DateTime?scheduleTime          = DateTime.Now;

            DiagnosticService    ds             = TestDiagnosticServiceFactory.CreateDiagnosticService(numProcedures);
            string               reasonForStudy = "Test";
            ExternalPractitioner orderingPrac   = TestExternalPractitionerFactory.CreatePractitioner();

            Order order = Order.NewOrder(new OrderCreationArgs(
                                             Platform.Time,
                                             TestStaffFactory.CreateStaff(new StaffTypeEnum("SCLR", null, null)),
                                             null,
                                             accession,
                                             patient,
                                             visit,
                                             ds,
                                             reasonForStudy,
                                             OrderPriority.R,
                                             facility,
                                             facility,
                                             scheduleTime,
                                             orderingPrac,
                                             new List <ResultRecipient>()),
                                         procedureNumberBroker,
                                         dicomUidBroker);

            if (createProcedureSteps)
            {
                foreach (Procedure proc in order.Procedures)
                {
                    AddProcedureSteps(proc, numMpsPerProcedure);
                }
            }

            DateTime dt = DateTime.Now;

            if (schedule)
            {
                foreach (Procedure proc in order.Procedures)
                {
                    proc.Schedule(dt);
                }
            }

            return(order);
        }
        public void Test_CreateNewOrderScheduled()
        {
            DateTime scheduleTime = DateTime.Now;

            Patient              patient        = TestPatientFactory.CreatePatient();
            Visit                visit          = TestVisitFactory.CreateVisit(patient);
            DiagnosticService    ds             = TestDiagnosticServiceFactory.CreateDiagnosticService();
            string               accession      = "10000001";
            string               reasonForStudy = "Test";
            ExternalPractitioner orderingPrac   = TestExternalPractitionerFactory.CreatePractitioner();
            Facility             facility       = TestFacilityFactory.CreateFacility();

            Order order = Order.NewOrder(new OrderCreationArgs(Platform.Time, TestStaffFactory.CreateStaff(new StaffTypeEnum("SCLR", null, null)), null,
                                                               accession, patient, visit, ds, reasonForStudy, OrderPriority.R, facility, facility,
                                                               scheduleTime, orderingPrac, new List <ResultRecipient>()), new TestProcedureNumberBroker(), new TestDicomUidBroker());

            // check basics
            Assert.AreEqual(accession, order.AccessionNumber);
            Assert.AreEqual(reasonForStudy, order.ReasonForStudy);
            Assert.AreEqual(patient, order.Patient);
            Assert.AreEqual(visit, order.Visit);
            Assert.AreEqual(ds, order.DiagnosticService);
            Assert.AreEqual(scheduleTime, order.SchedulingRequestTime);
            Assert.AreEqual(null, order.ScheduledStartTime); // because the order has not been scheduled
            Assert.AreEqual(null, order.StartTime);          // because the order has not been started
            Assert.AreEqual(null, order.EndTime);            // because the order has not been completed
            Assert.AreEqual(orderingPrac, order.OrderingPractitioner);
            Assert.AreEqual(facility, order.OrderingFacility);
            Assert.AreEqual(OrderPriority.R, order.Priority);
            CheckStatus(OrderStatus.SC, order);

            // check that diagnostic service plan was copied properly
            Assert.AreEqual(ds.ProcedureTypes.Count, order.Procedures.Count);
            foreach (Procedure rp in order.Procedures)
            {
                CheckStatus(ProcedureStatus.SC, rp);

                ProcedureType rpType = CollectionUtils.SelectFirst(ds.ProcedureTypes,
                                                                   delegate(ProcedureType rpt) { return(rpt.Equals(rp.Type)); });

                Assert.IsNotNull(rpType, "diagnostic service plan not copied correctly");
                foreach (ModalityProcedureStep mps in rp.ModalityProcedureSteps)
                {
                    CheckStatus(ActivityStatus.SC, mps);
                }
            }
        }