public void Test_LinkTo_NullProtocol()
        {
            ProtocolAssignmentStep ps1 = new ProtocolAssignmentStep();
            ProtocolAssignmentStep ps2 = new ProtocolAssignmentStep();

            ps1.LinkTo(ps2);
        }
		/// <summary>
		/// Obtains a set of interpretation steps that are candidates for linked reporting to the specified interpretation step.
		/// </summary>
		/// <param name="step"></param>
		/// <param name="author"></param>
		/// <returns></returns>
		public IList<ProtocolAssignmentStep> GetLinkedProtocolCandidates(ProtocolAssignmentStep step, Staff author)
		{
			var q = this.GetNamedHqlQuery("linkedProtocolCandidates");
			q.SetParameter(0, step);
			q.SetParameter(1, author);
			return q.List<ProtocolAssignmentStep>();
		}
Example #3
0
        public void Test_Schedule_PreStep_And_SchedulingOffset()
        {
            var procedure = new Procedure(new ProcedureType(), "111", "1.111");

            var protocolStep = new ProtocolAssignmentStep(new Protocol(procedure));

            procedure.AddProcedureStep(protocolStep);
            var registrationStep  = new RegistrationProcedureStep(procedure);
            var modalityStep      = new ModalityProcedureStep(procedure, "description", new Modality());
            var documentationStep = new DocumentationProcedureStep(procedure);
            var reportingStep     = new ConcreteReportingProcedureStep(procedure);

            Assert.IsNull(protocolStep.Scheduling.StartTime);
            Assert.IsNull(registrationStep.Scheduling.StartTime);
            Assert.IsNull(modalityStep.Scheduling.StartTime);
            Assert.IsNull(documentationStep.Scheduling.StartTime);
            Assert.IsNull(reportingStep.Scheduling.StartTime);

            var now = DateTime.Now;

            procedure.Schedule(now);

            Assert.AreEqual(now.Truncate(DateTimePrecision.Minute), procedure.ScheduledStartTime);
            Assert.AreEqual(protocolStep.CreationTime, protocolStep.Scheduling.StartTime);
            Assert.AreEqual(procedure.ScheduledStartTime, registrationStep.Scheduling.StartTime);
            Assert.AreEqual(procedure.ScheduledStartTime, modalityStep.Scheduling.StartTime);
            Assert.IsNull(documentationStep.Scheduling.StartTime);
            Assert.IsNull(reportingStep.Scheduling.StartTime);
        }
        public void Test_CanAcceptRejctSuspendSave()
        {
            ProtocolAssignmentStep procedureStep = new ProtocolAssignmentStep(new Protocol());
            Assert.AreEqual(ActivityStatus.SC, procedureStep.State);

            procedureStep.Start(new Staff());

            Assert.AreEqual(ActivityStatus.IP, procedureStep.State);
            Assert.IsTrue(procedureStep.CanAccept);
            Assert.IsTrue(procedureStep.CanReject);
            Assert.IsTrue(procedureStep.CanSuspend);
            Assert.IsTrue(procedureStep.CanSave);

            procedureStep.Suspend();

            Assert.AreEqual(ActivityStatus.SU, procedureStep.State);
            Assert.IsFalse(procedureStep.CanAccept);
            Assert.IsFalse(procedureStep.CanReject);
            Assert.IsFalse(procedureStep.CanSuspend);
            Assert.IsFalse(procedureStep.CanSave);

            procedureStep.Complete();

            Assert.AreEqual(ActivityStatus.CM, procedureStep.State);
            Assert.IsFalse(procedureStep.CanAccept);
            Assert.IsFalse(procedureStep.CanReject);
            Assert.IsFalse(procedureStep.CanSuspend);
            Assert.IsFalse(procedureStep.CanSave);
        }
        public void Test_CanApprove()
        {
            Procedure procedure = new Procedure();
            Protocol protocol = new Protocol(procedure);
            ProtocolAssignmentStep procedureStep = new ProtocolAssignmentStep(protocol);

            Assert.AreEqual(ProtocolStatus.PN, procedureStep.Protocol.Status);
            Assert.IsFalse(procedureStep.CanApprove);

            protocol.SubmitForApproval();

            Assert.AreEqual(ActivityStatus.SC, procedureStep.State);
            Assert.AreEqual(ProtocolStatus.AA, procedureStep.Protocol.Status);
            Assert.IsTrue(procedureStep.CanApprove);

            procedureStep.Start(new Staff());

            Assert.AreEqual(ActivityStatus.IP, procedureStep.State);
            Assert.AreEqual(ProtocolStatus.AA, procedureStep.Protocol.Status);
            Assert.IsTrue(procedureStep.CanApprove);

            procedureStep.Suspend();

            Assert.AreEqual(ActivityStatus.SU, procedureStep.State);
            Assert.AreEqual(ProtocolStatus.AA, procedureStep.Protocol.Status);
            Assert.IsFalse(procedureStep.CanApprove);

            procedureStep.Complete();

            Assert.AreEqual(ActivityStatus.CM, procedureStep.State);
            Assert.AreEqual(ProtocolStatus.AA, procedureStep.Protocol.Status);
            Assert.IsFalse(procedureStep.CanApprove);

            // TODO : test all other Protocol state conditions
        }
        private void SaveProtocolHelper(ProtocolAssignmentStep step, ProtocolDetail protocolDetail, List <OrderNoteDetail> notes, EntityRef supervisorRef, bool supervisorValidationRequired)
        {
            var protocol = step.Protocol;

            if (protocolDetail != null && supervisorRef != null)
            {
                throw new RequestValidationException("UpdateProtocolRequest should not specify both a ProtocolDetail and a SupervisorRef");
            }

            if (supervisorValidationRequired &&
                Thread.CurrentPrincipal.IsInRole(Extended.Common.AuthorityTokens.Workflow.Protocol.OmitSupervisor) == false &&
                protocol.Supervisor == null &&
                (protocolDetail == null || protocolDetail.Supervisor == null) &&
                supervisorRef == null)
            {
                throw new SupervisorValidationException();
            }

            if (protocolDetail != null)
            {
                var assembler = new ProtocolAssembler();
                assembler.UpdateProtocol(protocol, protocolDetail, this.PersistenceContext);
            }

            if (supervisorRef != null)
            {
                var supervisor = this.PersistenceContext.Load <Staff>(supervisorRef);
                protocol.Supervisor = supervisor;
            }

            if (notes != null)
            {
                UpdateOrderNotes(step.Procedure.Order, notes);
            }
        }
        public void Test_CanApprove()
        {
            Procedure procedure = new Procedure();
            Protocol  protocol  = new Protocol(procedure);
            ProtocolAssignmentStep procedureStep = new ProtocolAssignmentStep(protocol);

            Assert.AreEqual(ProtocolStatus.PN, procedureStep.Protocol.Status);
            Assert.IsFalse(procedureStep.CanApprove);

            protocol.SubmitForApproval();

            Assert.AreEqual(ActivityStatus.SC, procedureStep.State);
            Assert.AreEqual(ProtocolStatus.AA, procedureStep.Protocol.Status);
            Assert.IsTrue(procedureStep.CanApprove);

            procedureStep.Start(new Staff());

            Assert.AreEqual(ActivityStatus.IP, procedureStep.State);
            Assert.AreEqual(ProtocolStatus.AA, procedureStep.Protocol.Status);
            Assert.IsTrue(procedureStep.CanApprove);

            procedureStep.Suspend();

            Assert.AreEqual(ActivityStatus.SU, procedureStep.State);
            Assert.AreEqual(ProtocolStatus.AA, procedureStep.Protocol.Status);
            Assert.IsFalse(procedureStep.CanApprove);

            procedureStep.Complete();

            Assert.AreEqual(ActivityStatus.CM, procedureStep.State);
            Assert.AreEqual(ProtocolStatus.AA, procedureStep.Protocol.Status);
            Assert.IsFalse(procedureStep.CanApprove);

            // TODO : test all other Protocol state conditions
        }
        public void Test_CanAcceptRejctSuspendSave()
        {
            ProtocolAssignmentStep procedureStep = new ProtocolAssignmentStep(new Protocol());

            Assert.AreEqual(ActivityStatus.SC, procedureStep.State);

            procedureStep.Start(new Staff());

            Assert.AreEqual(ActivityStatus.IP, procedureStep.State);
            Assert.IsTrue(procedureStep.CanAccept);
            Assert.IsTrue(procedureStep.CanReject);
            Assert.IsTrue(procedureStep.CanSuspend);
            Assert.IsTrue(procedureStep.CanSave);

            procedureStep.Suspend();

            Assert.AreEqual(ActivityStatus.SU, procedureStep.State);
            Assert.IsFalse(procedureStep.CanAccept);
            Assert.IsFalse(procedureStep.CanReject);
            Assert.IsFalse(procedureStep.CanSuspend);
            Assert.IsFalse(procedureStep.CanSave);

            procedureStep.Complete();

            Assert.AreEqual(ActivityStatus.CM, procedureStep.State);
            Assert.IsFalse(procedureStep.CanAccept);
            Assert.IsFalse(procedureStep.CanReject);
            Assert.IsFalse(procedureStep.CanSuspend);
            Assert.IsFalse(procedureStep.CanSave);
        }
Example #9
0
        /// <summary>
        /// Obtains a set of interpretation steps that are candidates for linked reporting to the specified interpretation step.
        /// </summary>
        /// <param name="step"></param>
        /// <param name="author"></param>
        /// <returns></returns>
        public IList <ProtocolAssignmentStep> GetLinkedProtocolCandidates(ProtocolAssignmentStep step, Staff author)
        {
            var q = this.GetNamedHqlQuery("linkedProtocolCandidates");

            q.SetParameter(0, step);
            q.SetParameter(1, author);
            return(q.List <ProtocolAssignmentStep>());
        }
Example #10
0
 public void Execute(ProtocolAssignmentStep assignmentStep, Staff acceptedBy)
 {
     if (assignmentStep.State == ActivityStatus.IP)
     {
         assignmentStep.Complete();
     }
     else
     {
         assignmentStep.Complete(acceptedBy);
     }
     assignmentStep.Protocol.Accept();
 }
Example #11
0
            private void ReplaceAssignmentStep(Procedure procedure, Protocol protocol, Staff reassignToStaff)
            {
                ProtocolAssignmentStep replacementAssignmentStep = new ProtocolAssignmentStep(protocol);

                procedure.AddProcedureStep(replacementAssignmentStep);
                if (reassignToStaff != null)
                {
                    replacementAssignmentStep.Assign(reassignToStaff);
                }

                replacementAssignmentStep.Schedule(Platform.Time);
            }
Example #12
0
            public void Execute(ProtocolAssignmentStep assignmentStep, List <ProtocolAssignmentStep> linkedSteps, Staff protocolPerformer, bool canPerformerAcceptProtocols, out bool protocolClaimed, out Staff assignedStaff)
            {
                protocolClaimed = false;
                assignedStaff   = null;

                if (assignmentStep.IsInitial)
                {
                    assignedStaff = assignmentStep.AssignedStaff;

                    // Scheduled assignment step exists (i.e. Protocol has not been claimed), so claim it
                    assignmentStep.Start(protocolPerformer);

                    // Current user should be set as the supervisor if the protocol is awaiting approval
                    // and the user is able to accept protocols
                    if (assignmentStep.Protocol.Status == ProtocolStatus.AA)
                    {
                        if (!canPerformerAcceptProtocols)
                        {
                            // User is unable to approve
                            //throw new RequestValidationException(SR.ExceptionNoProtocolAssignmentStep);
                            throw new Exception("TODO: user unable to approve");
                        }
                    }
                    // otherwise, it's just a new protocol
                    else
                    {
                        assignmentStep.Protocol.Author = protocolPerformer;
                    }

                    protocolClaimed = true;

                    if (linkedSteps != null)
                    {
                        foreach (ProtocolAssignmentStep step in linkedSteps)
                        {
                            step.LinkTo(assignmentStep);
                        }
                    }
                }
                else
                {
                    // In-progress assignment step started by someone else
                    if (assignmentStep.PerformingStaff != protocolPerformer)
                    {
                        // So not available to this user to start
                        //throw new RequestValidationException(SR.ExceptionNoProtocolAssignmentStep);
                        throw new Exception("TODO: protocol already started");
                    }

                    // otherwise, it's been claimed by this user, so do nothing
                }
            }
Example #13
0
            public void Execute(ProtocolAssignmentStep assignmentStep)
            {
                assignmentStep.Complete();
                assignmentStep.Protocol.SubmitForApproval();

                // Replace with new step scheduled step
                ProtocolAssignmentStep approvalStep = new ProtocolAssignmentStep(assignmentStep.Protocol);

                assignmentStep.Procedure.AddProcedureStep(approvalStep);

                approvalStep.Schedule(Platform.Time);
                approvalStep.Assign(assignmentStep.Protocol.Supervisor);
            }
Example #14
0
            public void Execute(ProtocolAssignmentStep assignmentStep, Staff rejectedBy, ProtocolRejectReasonEnum reason)
            {
                if (assignmentStep.State == ActivityStatus.SC)
                {
                    assignmentStep.Start(rejectedBy);
                }
                assignmentStep.Discontinue();
                assignmentStep.Protocol.Reject(reason);

                // TODO: one resolution step or one per procedure?
                ProtocolResolutionStep resolutionStep = new ProtocolResolutionStep(assignmentStep.Protocol);

                assignmentStep.Procedure.AddProcedureStep(resolutionStep);
            }
Example #15
0
            public void Execute(Order order, Staff resolvingStaff)
            {
                foreach (Procedure rp in order.Procedures)
                {
                    ProtocolResolutionStep resolutionStep = ScheduledProcedureStep <ProtocolResolutionStep>(rp);

                    if (resolutionStep != null)
                    {
                        resolutionStep.Complete(resolvingStaff);
                        resolutionStep.Protocol.Resolve();
                        ProtocolAssignmentStep assignmentStep = new ProtocolAssignmentStep(resolutionStep.Protocol);
                        rp.AddProcedureStep(assignmentStep);
                    }
                }
            }
        public void Test_LinkTo()
        {
            Procedure p1               = new Procedure();
            Procedure p2               = new Procedure();
            Protocol  protocol         = new Protocol(p1);
            ProtocolAssignmentStep ps1 = new ProtocolAssignmentStep(protocol),
                                   ps2 = new ProtocolAssignmentStep(new Protocol(p2));

            ps1.Procedure = p1;
            ps2.Procedure = p2;
            ps1.LinkTo(ps2);

            Assert.IsTrue(ps2.Protocol.Procedures.Contains(p1));
            Assert.Contains(p1, ps2.GetLinkedProcedures());
        }
Example #17
0
            public ProtocolAssignmentStep Execute(ProtocolAssignmentStep assignmentStep, Staff author)
            {
                assignmentStep.Protocol.Status     = ProtocolStatus.PN;
                assignmentStep.Protocol.Supervisor = null;
                assignmentStep.Discontinue();

                // Replace with new step scheduled step
                ProtocolAssignmentStep replacementStep = new ProtocolAssignmentStep(assignmentStep.Protocol);

                assignmentStep.Procedure.AddProcedureStep(replacementStep);
                replacementStep.Assign(author);
                replacementStep.Start(author);

                return(replacementStep);
            }
        public void Test_Reassign()
        {
            Procedure procedure = new Procedure();
            Protocol protocol = new Protocol(procedure);
            Staff staff1 = new Staff(),
                  staff2 = new Staff();
            ProtocolAssignmentStep ps1 = new ProtocolAssignmentStep(protocol);
            ps1.Procedure = procedure;
            ps1.Start(staff1);

            ProtocolAssignmentStep ps2 = (ProtocolAssignmentStep)ps1.Reassign(staff2);

            Assert.AreNotEqual(ps1, ps2);
            Assert.AreEqual(ps1.Protocol, ps2.Protocol);
            Assert.IsTrue(procedure.ProcedureSteps.Contains(ps2));
        }
        public void Test_CanEdit()
        {
            ProtocolAssignmentStep procedureStep = new ProtocolAssignmentStep(new Protocol());
            Staff staff = new Staff();

            Assert.AreEqual(ActivityStatus.SC, procedureStep.State);
            Assert.IsFalse(procedureStep.CanEdit(staff));

            procedureStep.Start(staff);

            Assert.AreEqual(ActivityStatus.IP, procedureStep.State);
            Assert.AreEqual(staff, procedureStep.PerformingStaff);
            Assert.IsTrue(procedureStep.CanEdit(staff));
            Assert.IsFalse(procedureStep.CanEdit(new Staff()));

            // TODO : test all other Activity state conditions
        }
Example #20
0
        public void Test_Reassign()
        {
            Procedure procedure        = new Procedure();
            Protocol  protocol         = new Protocol(procedure);
            Staff     staff1           = new Staff(),
                      staff2           = new Staff();
            ProtocolAssignmentStep ps1 = new ProtocolAssignmentStep(protocol);

            ps1.Procedure = procedure;
            ps1.Start(staff1);

            ProtocolAssignmentStep ps2 = (ProtocolAssignmentStep)ps1.Reassign(staff2);

            Assert.AreNotEqual(ps1, ps2);
            Assert.AreEqual(ps1.Protocol, ps2.Protocol);
            Assert.IsTrue(procedure.ProcedureSteps.Contains(ps2));
        }
Example #21
0
        public void Test_GetProcedureSteps()
        {
            var procedure = new Procedure();

            Assert.IsEmpty(procedure.GetProcedureSteps(delegate { return(true); }));

            var ps1 = new DocumentationProcedureStep(procedure);
            var ps2 = new ModalityProcedureStep(procedure, "1", new Modality());
            var ps3 = new ModalityProcedureStep(procedure, "2", new Modality());
            var ps4 = new ProtocolAssignmentStep();

            procedure.AddProcedureStep(ps4);

            Assert.AreEqual(4, procedure.GetProcedureSteps(delegate { return(true); }).Count);
            Assert.IsEmpty(procedure.GetProcedureSteps(delegate { return(false); }));
            Assert.AreEqual(1, procedure.GetProcedureSteps(ps => ps is DocumentationProcedureStep).Count);
            Assert.AreEqual(2, procedure.GetProcedureSteps(ps => ps is ModalityProcedureStep).Count);
            Assert.AreEqual(0, procedure.GetProcedureSteps(ps => ps is ReportingProcedureStep).Count);
            Assert.AreEqual(1, procedure.GetProcedureSteps(ps => ps is ProtocolProcedureStep).Count);
        }
Example #22
0
            public void Execute(ProtocolAssignmentStep assignmentStep, Staff reassignToStaff)
            {
                assignmentStep.Discontinue();

                // if it's an approval step, replace the assignment step but keep the existing protocol
                if (assignmentStep.Protocol.Status == ProtocolStatus.AA)
                {
                    // replace the step and unclaim the protocol
                    ReplaceAssignmentStep(assignmentStep.Procedure, assignmentStep.Protocol, reassignToStaff);
                }
                // other wise, create a new assignment step with its own new protocol for each procedure in the old protocol
                else
                {
                    assignmentStep.Protocol.Cancel();

                    List <Procedure> procedures = new List <Procedure>(assignmentStep.Protocol.Procedures);
                    foreach (Procedure procedure in procedures)
                    {
                        Protocol protocol = new Protocol(procedure);
                        ReplaceAssignmentStep(procedure, protocol, reassignToStaff);
                        PersistenceScope.CurrentContext.Lock(protocol, DirtyState.New);
                    }
                }
            }
Example #23
0
		public void Test_Schedule_PreStep_And_SchedulingOffset()
		{
			var procedure = new Procedure(new ProcedureType(), "111", "1.111");

			var protocolStep = new ProtocolAssignmentStep(new Protocol(procedure));
			procedure.AddProcedureStep(protocolStep);
			var registrationStep = new RegistrationProcedureStep(procedure);
			var modalityStep = new ModalityProcedureStep(procedure, "description", new Modality());
			var documentationStep = new DocumentationProcedureStep(procedure);
			var reportingStep = new ConcreteReportingProcedureStep(procedure);

			Assert.IsNull(protocolStep.Scheduling.StartTime);
			Assert.IsNull(registrationStep.Scheduling.StartTime);
			Assert.IsNull(modalityStep.Scheduling.StartTime);
			Assert.IsNull(documentationStep.Scheduling.StartTime);
			Assert.IsNull(reportingStep.Scheduling.StartTime);

			var now = DateTime.Now;
			procedure.Schedule(now);

			Assert.AreEqual(now.Truncate(DateTimePrecision.Minute), procedure.ScheduledStartTime);
			Assert.AreEqual(protocolStep.CreationTime, protocolStep.Scheduling.StartTime);
			Assert.AreEqual(procedure.ScheduledStartTime, registrationStep.Scheduling.StartTime);
			Assert.AreEqual(procedure.ScheduledStartTime, modalityStep.Scheduling.StartTime);
			Assert.IsNull(documentationStep.Scheduling.StartTime);
			Assert.IsNull(reportingStep.Scheduling.StartTime);
		}
        public void Test_Name()
        {
            ProtocolAssignmentStep procedureStep = new ProtocolAssignmentStep(new Protocol());

            Assert.AreEqual("Protocol Assignment", procedureStep.Name);
        }
        public void Test_CanEdit()
        {
            ProtocolAssignmentStep procedureStep = new ProtocolAssignmentStep(new Protocol());
            Staff staff = new Staff();
            Assert.AreEqual(ActivityStatus.SC, procedureStep.State);
            Assert.IsFalse(procedureStep.CanEdit(staff));

            procedureStep.Start(staff);

            Assert.AreEqual(ActivityStatus.IP, procedureStep.State);
            Assert.AreEqual(staff, procedureStep.PerformingStaff);
            Assert.IsTrue(procedureStep.CanEdit(staff));
            Assert.IsFalse(procedureStep.CanEdit(new Staff()));

            // TODO : test all other Activity state conditions
        }
Example #26
0
		public void Test_GetProcedureSteps()
		{
			var procedure = new Procedure();

			Assert.IsEmpty(procedure.GetProcedureSteps(delegate { return true; }));

			var ps1 = new DocumentationProcedureStep(procedure);
			var ps2 = new ModalityProcedureStep(procedure, "1", new Modality());
			var ps3 = new ModalityProcedureStep(procedure, "2", new Modality());
			var ps4 = new ProtocolAssignmentStep();
			procedure.AddProcedureStep(ps4);

			Assert.AreEqual(4, procedure.GetProcedureSteps(delegate { return true; }).Count);
			Assert.IsEmpty(procedure.GetProcedureSteps(delegate { return false; }));
			Assert.AreEqual(1, procedure.GetProcedureSteps(ps => ps is DocumentationProcedureStep).Count);
			Assert.AreEqual(2, procedure.GetProcedureSteps(ps => ps is ModalityProcedureStep).Count);
			Assert.AreEqual(0, procedure.GetProcedureSteps(ps => ps is ReportingProcedureStep).Count);
			Assert.AreEqual(1, procedure.GetProcedureSteps(ps => ps is ProtocolProcedureStep).Count);
		}
 public void Test_LinkTo_NullProtocol()
 {
     ProtocolAssignmentStep ps1 = new ProtocolAssignmentStep();
     ProtocolAssignmentStep ps2 = new ProtocolAssignmentStep();
     ps1.LinkTo(ps2);
 }
        public void Test_LinkTo()
        {
            Procedure p1 = new Procedure();
            Procedure p2 = new Procedure();
            Protocol protocol = new Protocol(p1);
            ProtocolAssignmentStep ps1 = new ProtocolAssignmentStep(protocol),
                                   ps2 = new ProtocolAssignmentStep(new Protocol(p2));
            ps1.Procedure = p1;
            ps2.Procedure = p2;
            ps1.LinkTo(ps2);

            Assert.IsTrue(ps2.Protocol.Procedures.Contains(p1));
            Assert.Contains(p1, ps2.GetLinkedProcedures());
        }
        public void Test_Name()
        {
            ProtocolAssignmentStep procedureStep = new ProtocolAssignmentStep(new Protocol());

            Assert.AreEqual("Protocol Assignment", procedureStep.Name);
        }