Ejemplo n.º 1
0
        public bool CanDiscardProtocol(ProtocolOperationEnablementContext enablementContext)
        {
            // if there is no proc step ref, operation is not available
            if (enablementContext.ProcedureStepRef == null)
            {
                return(false);
            }

            var step = this.PersistenceContext.Load <ProcedureStep>(enablementContext.ProcedureStepRef);

            var isAssignedToMe =
                (step.State == ActivityStatus.SC && Equals(step.AssignedStaff, this.CurrentUserStaff)) ||
                (step.State == ActivityStatus.IP && Equals(step.PerformingStaff, this.CurrentUserStaff));

            if (isAssignedToMe)
            {
                // Protocol is assigned to current user, allow cancel only if user has Create or Cancel token
                if (!Thread.CurrentPrincipal.IsInRole(Extended.Common.AuthorityTokens.Workflow.Protocol.Create) &&
                    !Thread.CurrentPrincipal.IsInRole(Extended.Common.AuthorityTokens.Workflow.Protocol.Cancel))
                {
                    return(false);
                }
            }
            else
            {
                // Protocol not assigned to current user, allow cancel only if user has Cancel token
                if (!Thread.CurrentPrincipal.IsInRole(Extended.Common.AuthorityTokens.Workflow.Protocol.Cancel))
                {
                    return(false);
                }
            }

            return(CanExecuteOperation <ProtocolAssignmentStep>(new ProtocollingOperations.DiscardProtocolOperation(), enablementContext.ProcedureStepRef));
        }
Ejemplo n.º 2
0
 public bool CanResubmitProtocol(ProtocolOperationEnablementContext enablementContext)
 {
     if (!Thread.CurrentPrincipal.IsInRole(Extended.Common.AuthorityTokens.Workflow.Protocol.Resubmit))
     {
         return(false);
     }
     return(CanExecuteOperation(new ProtocollingOperations.ResubmitProtocolOperation(), enablementContext.OrderRef));
 }
Ejemplo n.º 3
0
 public bool CanRejectProtocol(ProtocolOperationEnablementContext enablementContext)
 {
     if (!Thread.CurrentPrincipal.IsInRole(Extended.Common.AuthorityTokens.Workflow.Protocol.Create))
     {
         return(false);
     }
     return(CanExecuteOperation <ProtocolAssignmentStep>(new ProtocollingOperations.RejectProtocolOperation(), enablementContext.ProcedureStepRef));
 }
Ejemplo n.º 4
0
        public bool CanSaveProtocol(ProtocolOperationEnablementContext enablementContext)
        {
            if (!Thread.CurrentPrincipal.IsInRole(Extended.Common.AuthorityTokens.Workflow.Protocol.Create))
            {
                return(false);
            }

            if (enablementContext.ProcedureStepRef == null)
            {
                return(false);
            }

            var step = this.PersistenceContext.Load <ProcedureStep>(enablementContext.ProcedureStepRef);

            if (!step.Is <ProtocolAssignmentStep>())
            {
                return(false);
            }

            if (step.AssignedStaff != null && !Equals(step.AssignedStaff, this.CurrentUserStaff))
            {
                return(false);
            }

            if (step.PerformingStaff != null && !Equals(step.PerformingStaff, CurrentUserStaff))
            {
                return(false);
            }

            // items submitted for review should not be editable.
            var assignmentStep = step.As <ProtocolAssignmentStep>();

            if (assignmentStep.Protocol.Status == ProtocolStatus.AA)
            {
                if (Equals(assignmentStep.Protocol.Author, this.CurrentUserStaff))
                {
                    return(false);
                }
            }

            if (step.IsTerminated)
            {
                return(false);
            }

            return(true);
        }