Example #1
0
        public void Test_merge_order()
        {
            var patient  = TestPatientFactory.CreatePatient();
            var visit    = TestVisitFactory.CreateVisit(patient);
            var facility = TestFacilityFactory.CreateFacility();
            var order1   = TestOrderFactory.CreateOrder(patient, visit, facility, "101", 2, 1, true, true);
            var order2   = TestOrderFactory.CreateOrder(patient, visit, facility, "102", 2, 1, true, true);
            var staff    = TestStaffFactory.CreateStaff();

            // merge order1 into order2
            order1.Merge(new OrderMergeInfo(staff, DateTime.Now, order2));

            // order1 post conditions
            Assert.AreEqual(OrderStatus.MG, order1.Status);
            Assert.IsNotNull(order1.MergeInfo);
            Assert.AreEqual(order2, order1.MergeInfo.MergeDestinationOrder);
            Assert.AreEqual(staff, order1.MergeInfo.MergedBy);
            Assert.AreEqual(2, order1.Procedures.Count);
            Assert.IsTrue(CollectionUtils.TrueForAll(order1.Procedures, p => p.Status == ProcedureStatus.GH));

            // order2 post conditions
            Assert.AreEqual(OrderStatus.SC, order2.Status);
            Assert.IsNull(order2.MergeInfo);
            Assert.AreEqual(4, order2.Procedures.Count);
            Assert.IsTrue(CollectionUtils.TrueForAll(order1.Procedures, p => p.Status == ProcedureStatus.SC));
        }
Example #2
0
        public static Order CreateOrder(int numProcedures, int numMpsPerProcedure, bool createProcedureSteps, bool schedule)
        {
            Patient patient  = TestPatientFactory.CreatePatient();
            Visit   visit    = TestVisitFactory.CreateVisit(patient);
            var     facility = TestFacilityFactory.CreateFacility();

            return(CreateOrder(patient, visit, facility, "10000001", numProcedures, numMpsPerProcedure, createProcedureSteps, schedule));
        }
        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);
                }
            }
        }