Esempio n. 1
0
        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_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
        }
Esempio n. 3
0
        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_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);
        }
Esempio n. 5
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
                }
            }
Esempio n. 6
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);
            }
Esempio n. 7
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));
        }
Esempio n. 9
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));
        }
        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
        }
Esempio n. 11
0
        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
        }