Пример #1
0
        public void Test_Discontinue_DiscontinuedState()
        {
            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.Discontinue();
        }
        public void Test_DiscontinueProcedure()
        {
            Order order = TestOrderFactory.CreateOrder(1, 3, 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];

            // put one mps in progress and the other completed, leaving the third scheduled
            rp1.ModalityProcedureSteps[0].Start(TestStaffFactory.CreateStaff(new StaffTypeEnum("STEC", null, null)));
            rp1.ModalityProcedureSteps[1].Complete(TestStaffFactory.CreateStaff(new StaffTypeEnum("STEC", null, null)));

            // discontinue rp1
            rp1.Discontinue();

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

            // expect scheduled step was discontinued
            CheckStatus(ActivityStatus.DC, rp1.ModalityProcedureSteps[2]);
            Assert.IsNull(rp1.ModalityProcedureSteps[2].StartTime);
            Assert.IsNotNull(rp1.ModalityProcedureSteps[2].EndTime);

            // expect in-progress step was discontinued
            CheckStatus(ActivityStatus.DC, rp1.ModalityProcedureSteps[0]);
            Assert.IsNotNull(rp1.ModalityProcedureSteps[0].StartTime);
            Assert.IsNotNull(rp1.ModalityProcedureSteps[0].EndTime);

            // expect completed steps unchanged
            CheckStatus(ActivityStatus.CM, rp1.ModalityProcedureSteps[1]);
            Assert.IsNotNull(rp1.ModalityProcedureSteps[1].StartTime);
            Assert.IsNotNull(rp1.ModalityProcedureSteps[1].EndTime);
        }
        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);
        }
Пример #4
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);
        }
Пример #5
0
        public void Test_Discontinue_Scheduling()
        {
            var procedure = new Procedure();

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

            procedure.Discontinue();
        }
Пример #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();
            }
        }
Пример #7
0
        public void Test_Discontinue_Cancelled()
        {
            var procedure = new Procedure();

            procedure.Cancel();

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

            procedure.Discontinue();
        }
Пример #8
0
        public void Test_Discontinue_Complete()
        {
            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.Discontinue();
        }
Пример #9
0
        public void Discontinue()
        {
            var procedure     = new Procedure();
            var procedureStep = new ModalityProcedureStep(procedure, "New Modality", new Modality());

            procedureStep.Start(new Staff());

            Assert.AreEqual(ProcedureStatus.IP, procedure.Status);
            Assert.AreEqual(ActivityStatus.IP, procedureStep.State);

            procedure.Discontinue();

            Assert.AreEqual(ProcedureStatus.DC, procedure.Status);
            Assert.AreEqual(ActivityStatus.DC, procedureStep.State);
        }
Пример #10
0
		public void Test_Discontinue_Complete()
		{
			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.Discontinue();
		}
Пример #11
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();
		}
Пример #12
0
		public void Test_Discontinue_Scheduling()
		{
			var procedure = new Procedure();
			Assert.AreEqual(ProcedureStatus.SC, procedure.Status);

			procedure.Discontinue();
		}
Пример #13
0
		public void Test_Discontinue_Cancelled()
		{
			var procedure = new Procedure();
			procedure.Cancel();

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

			procedure.Discontinue();
		}
Пример #14
0
		public void Discontinue()
		{
			var procedure = new Procedure();
			var procedureStep = new ModalityProcedureStep(procedure, "New Modality", new Modality());
			procedureStep.Start(new Staff());

			Assert.AreEqual(ProcedureStatus.IP, procedure.Status);
			Assert.AreEqual(ActivityStatus.IP, procedureStep.State);

			procedure.Discontinue();

			Assert.AreEqual(ProcedureStatus.DC, procedure.Status);
			Assert.AreEqual(ActivityStatus.DC, procedureStep.State);
		}
Пример #15
0
		public void Test_Schedule_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.Schedule(Platform.Time);
		}
Пример #16
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);
		}