Exemplo n.º 1
0
        public void Test_IsTerminatedTrue()
        {
            var procedure = new Procedure();

            procedure.Cancel();

            Assert.AreEqual(ProcedureStatus.CA, procedure.Status);
            Assert.IsTrue(procedure.IsTerminated);

            procedure = new Procedure();
            var procedureStep = new ModalityProcedureStep(procedure, "New Modality", new Modality());

            procedureStep.Start(new Staff());
            procedure.Complete(Platform.Time);

            Assert.AreEqual(ProcedureStatus.CM, procedure.Status);
            Assert.IsTrue(procedure.IsTerminated);

            procedure     = new Procedure();
            procedureStep = new ModalityProcedureStep(procedure, "New Modality", new Modality());
            procedureStep.Start(new Staff());
            procedure.Discontinue();

            Assert.AreEqual(ProcedureStatus.DC, procedure.Status);
            Assert.IsTrue(procedure.IsTerminated);
        }
        public void Test_CancelOrderWithCancelledProcedure()
        {
            Order order = TestOrderFactory.CreateOrder(2, 2, true);

            CheckStatus(OrderStatus.SC, order);

            // cancel one of the procedures - this will not cancel the order
            Procedure p1 = CollectionUtils.FirstElement(order.Procedures);

            p1.Cancel();

            // order is still scheduled
            CheckStatus(OrderStatus.SC, order);

            // now cancel order
            order.Cancel(new OrderCancelInfo(_defaultCancelReason, TestStaffFactory.CreateStaff(new StaffTypeEnum("SCLR", null, null)), "", null));

            CheckStatus(OrderStatus.CA, order);
            Assert.IsNull(order.StartTime);
            Assert.IsNotNull(order.EndTime);

            foreach (Procedure rp in order.Procedures)
            {
                CheckStatus(ProcedureStatus.CA, rp);
                Assert.IsNull(rp.StartTime);
                Assert.IsNotNull(rp.EndTime);
                foreach (ProcedureStep step in rp.ProcedureSteps)
                {
                    CheckStatus(ActivityStatus.DC, step);
                }
            }
        }
        public void Test_AutoDiscontinueOrder()
        {
            Order order = TestOrderFactory.CreateOrder(2, 2, true);

            // copy req procs to a list so we can access them by index
            List <Procedure> reqProcs = new List <Procedure>(
                new TypeSafeEnumerableWrapper <Procedure>(order.Procedures));
            Procedure rp1 = reqProcs[0];
            Procedure rp2 = reqProcs[1];

            // start and discontinue rp1
            rp1.ModalityProcedureSteps[0].Start(TestStaffFactory.CreateStaff(new StaffTypeEnum("STEC", null, null)));
            rp1.Discontinue();
            Assert.IsNotNull(rp1.StartTime);
            Assert.IsNotNull(rp1.EndTime);

            // cancel rp2
            rp2.Cancel();
            Assert.IsNull(rp2.StartTime);
            Assert.IsNotNull(rp2.EndTime);

            // order should be discontinued
            CheckStatus(OrderStatus.DC, order);
            Assert.IsNotNull(order.StartTime);
            Assert.IsNotNull(order.EndTime);
        }
        public void Test_Test_AutoCompleteOrderProcedure()
        {
            Order order = TestOrderFactory.CreateOrder(2, 1, true);
            // copy req procs to a list so we can access them by index
            List <Procedure> reqProcs = new List <Procedure>(
                new TypeSafeEnumerableWrapper <Procedure>(order.Procedures));
            Procedure rp1 = reqProcs[0];
            Procedure rp2 = reqProcs[1];


            // cancel rp2
            rp2.Cancel();

            // complete rp1 and publish it
            rp1.ModalityProcedureSteps[0].Complete(TestStaffFactory.CreateStaff(new StaffTypeEnum("STEC", null, null)));

            PublicationStep pub1 = new PublicationStep();

            pub1.ReportPart = new ReportPart(new Report(), 0); // must have a report part or we get null-ref exception
            rp1.AddProcedureStep(pub1);

            pub1.Complete(TestStaffFactory.CreateStaff(new StaffTypeEnum("PRAD", null, null)));

            CheckStatus(ProcedureStatus.CA, rp2);
            Assert.IsNull(rp2.StartTime);
            Assert.IsNotNull(rp2.EndTime);

            CheckStatus(ProcedureStatus.CM, rp1);
            Assert.IsNotNull(rp1.StartTime);
            Assert.IsNotNull(rp1.EndTime);

            CheckStatus(OrderStatus.CM, order);
            Assert.IsNotNull(rp1.StartTime);
            Assert.IsNotNull(rp1.EndTime);
        }
Exemplo n.º 5
0
        public void Test_Schedule_Cancelled()
        {
            var procedure = new Procedure();

            procedure.Cancel();
            Assert.AreEqual(ProcedureStatus.CA, procedure.Status);

            procedure.Schedule(Platform.Time);
        }
Exemplo n.º 6
0
        public void UpdateProcedureFromRequisition(Procedure procedure, ProcedureRequisition requisition, Staff currentUserStaff, IPersistenceContext context)
        {
            // check if the procedure was cancelled
            if (requisition.Cancelled)
            {
                if (procedure.Status == ProcedureStatus.SC)
                {
                    // if RP is still scheduled, cancel it
                    procedure.Cancel();
                }
                else if (procedure.Status == ProcedureStatus.IP)
                {
                    // if RP in-progress, discontinue it
                    procedure.Discontinue();
                }

                // early exit - nothing else to update
                return;
            }

            // The following properties are appropriate only for procedures in SC status.
            if (!IsProcedureModifiable(procedure))
            {
                return;
            }

            procedure.Schedule(requisition.ScheduledTime, requisition.ScheduledDuration);
            procedure.SchedulingCode = EnumUtils.GetEnumValue <SchedulingCodeEnum>(requisition.SchedulingCode, context);

            procedure.PerformingFacility   = context.Load <Facility>(requisition.PerformingFacility.FacilityRef, EntityLoadFlags.Proxy);
            procedure.PerformingDepartment = requisition.PerformingDepartment == null ? null
                                : context.Load <Department>(requisition.PerformingDepartment.DepartmentRef, EntityLoadFlags.Proxy);

            // if the requisition explicitly specifies a modality, assign that modality to all MPS
            // (we ignore the fact that the procedure plan can theoretically contain modality procedures steps spanning multiple
            // DICOM modalities, since in the small clinic use-case, each procedure type generally only has a single MPS)
            if (requisition.Modality != null)
            {
                foreach (var mps in procedure.ModalityProcedureSteps)
                {
                    mps.Modality = context.Load <Modality>(requisition.Modality.ModalityRef, EntityLoadFlags.Proxy);
                }
            }

            procedure.Laterality = EnumUtils.GetEnumValue <Laterality>(requisition.Laterality);
            procedure.Portable   = requisition.PortableModality;

            if (requisition.CheckedIn && procedure.IsPreCheckIn)
            {
                procedure.CheckIn(currentUserStaff, null);
            }
            else if (!requisition.CheckedIn && procedure.IsCheckedIn)
            {
                procedure.RevertCheckIn();
            }
        }
Exemplo n.º 7
0
        public void Test_Cancel_InProgress()
        {
            var procedure = new Procedure();
            var ps        = new ModalityProcedureStep(procedure, "New modality.", new Modality());

            ps.Start(new Staff());
            Assert.AreEqual(ProcedureStatus.IP, procedure.Status);

            procedure.Cancel();
        }
Exemplo n.º 8
0
        public void Test_Discontinue_Cancelled()
        {
            var procedure = new Procedure();

            procedure.Cancel();

            Assert.AreEqual(ProcedureStatus.CA, procedure.Status);

            procedure.Discontinue();
        }
Exemplo n.º 9
0
        public void Test_Cancel_Discontinued()
        {
            var procedure = new Procedure();
            var ps        = new ModalityProcedureStep(procedure, "New modality.", new Modality());

            ps.Start(new Staff());
            procedure.Discontinue();
            Assert.AreEqual(ProcedureStatus.DC, procedure.Status);

            procedure.Cancel();
        }
Exemplo n.º 10
0
        public void Test_Cancel_Completed()
        {
            var procedure = new Procedure();
            var ps        = new ModalityProcedureStep(procedure, "New modality.", new Modality());

            ps.Start(new Staff());
            procedure.Complete(DateTime.Now);
            Assert.AreEqual(ProcedureStatus.CM, procedure.Status);

            procedure.Cancel();
        }
Exemplo n.º 11
0
        public void Test_Cancel()
        {
            var procedure = new Procedure();
            var ps        = new ConcreteProcedureStep(procedure);

            Assert.AreEqual(ProcedureStatus.SC, procedure.Status);
            Assert.AreEqual(ActivityStatus.SC, ps.State);
            Assert.IsFalse(ps.IsPreStep);              // Only nPreStep will update procedure status

            procedure.Cancel();

            Assert.AreEqual(ActivityStatus.DC, ps.State);
            Assert.AreEqual(ProcedureStatus.CA, procedure.Status);
        }
        public void Test_CancelProcedureFromInProgress()
        {
            try
            {
                Order order = TestOrderFactory.CreateOrder(1, 1, true);

                Procedure rp = CollectionUtils.FirstElement(order.Procedures);
                rp.ModalityProcedureSteps[0].Start(TestStaffFactory.CreateStaff(new StaffTypeEnum("STEC", null, null)));

                CheckStatus(ProcedureStatus.IP, rp);

                rp.Cancel();

                Assert.Fail("expected exception when trying to cancel in progress procedure");
            }
            catch (WorkflowException e)
            {
                Assert.IsInstanceOfType(typeof(WorkflowException), e);
            }
        }
        public void Test_CancelProcedureFromScheduled()
        {
            Order order = TestOrderFactory.CreateOrder(1, 2, true);

            // copy req procs to a list so we can access them by index
            List <Procedure> reqProcs = new List <Procedure>(
                new TypeSafeEnumerableWrapper <Procedure>(order.Procedures));
            Procedure rp1 = reqProcs[0];

            rp1.Cancel();
            CheckStatus(ProcedureStatus.CA, rp1);
            Assert.IsNull(rp1.StartTime);
            Assert.IsNotNull(rp1.EndTime);

            foreach (ProcedureStep step in rp1.ProcedureSteps)
            {
                // all steps were scheduled, so they should all be discontinued
                CheckStatus(ActivityStatus.DC, step);
                Assert.IsNull(step.StartTime);
                Assert.IsNotNull(step.EndTime);
            }
        }
Exemplo n.º 14
0
		public void Test_IsTerminatedTrue()
		{
			var procedure = new Procedure();
			procedure.Cancel();

			Assert.AreEqual(ProcedureStatus.CA, procedure.Status);
			Assert.IsTrue(procedure.IsTerminated);

			procedure = new Procedure();
			var procedureStep = new ModalityProcedureStep(procedure, "New Modality", new Modality());
			procedureStep.Start(new Staff());
			procedure.Complete(Platform.Time);

			Assert.AreEqual(ProcedureStatus.CM, procedure.Status);
			Assert.IsTrue(procedure.IsTerminated);

			procedure = new Procedure();
			procedureStep = new ModalityProcedureStep(procedure, "New Modality", new Modality());
			procedureStep.Start(new Staff());
			procedure.Discontinue();

			Assert.AreEqual(ProcedureStatus.DC, procedure.Status);
			Assert.IsTrue(procedure.IsTerminated);
		}
Exemplo n.º 15
0
		public void Test_Cancel()
		{
			var procedure = new Procedure();
			var ps = new ConcreteProcedureStep(procedure);
			Assert.AreEqual(ProcedureStatus.SC, procedure.Status);
			Assert.AreEqual(ActivityStatus.SC, ps.State);
			Assert.IsFalse(ps.IsPreStep);  // Only nPreStep will update procedure status

			procedure.Cancel();

			Assert.AreEqual(ActivityStatus.DC, ps.State);
			Assert.AreEqual(ProcedureStatus.CA, procedure.Status);
		}
Exemplo n.º 16
0
		public void Test_Discontinue_Cancelled()
		{
			var procedure = new Procedure();
			procedure.Cancel();

			Assert.AreEqual(ProcedureStatus.CA, procedure.Status);

			procedure.Discontinue();
		}
Exemplo n.º 17
0
		public void Test_Cancel_CancelledState()
		{
			var procedure = new Procedure();
			procedure.Cancel();
			Assert.AreEqual(ProcedureStatus.CA, procedure.Status);

			procedure.Cancel();
		}
Exemplo n.º 18
0
		public void Test_Cancel_InProgress()
		{
			var procedure = new Procedure();
			var ps = new ModalityProcedureStep(procedure, "New modality.", new Modality());
			ps.Start(new Staff());
			Assert.AreEqual(ProcedureStatus.IP, procedure.Status);

			procedure.Cancel();
		}
Exemplo n.º 19
0
		public void Test_Cancel_Discontinued()
		{
			var procedure = new Procedure();
			var ps = new ModalityProcedureStep(procedure, "New modality.", new Modality());
			ps.Start(new Staff());
			procedure.Discontinue();
			Assert.AreEqual(ProcedureStatus.DC, procedure.Status);

			procedure.Cancel();
		}
Exemplo n.º 20
0
		public void Test_Cancel_Completed()
		{
			var procedure = new Procedure();
			var ps = new ModalityProcedureStep(procedure, "New modality.", new Modality());
			ps.Start(new Staff());
			procedure.Complete(DateTime.Now);
			Assert.AreEqual(ProcedureStatus.CM, procedure.Status);

			procedure.Cancel();
		}
Exemplo n.º 21
0
		public void Test_Schedule_Cancelled()
		{
			var procedure = new Procedure();
			procedure.Cancel();
			Assert.AreEqual(ProcedureStatus.CA, procedure.Status);

			procedure.Schedule(Platform.Time);
		}