@Override
  public boolean hasDerivedRole(
      String principalId,
      List<String> groupIds,
      String namespaceCode,
      String roleName,
      Map<String, String> qualification) {
    validateRequiredAttributesAgainstReceived(qualification);

    String protocolNumber = qualification.get(KcKimAttributes.PROTOCOL);

    ProtocolBase protocol = getProtocol(protocolNumber);

    if (protocol != null && CollectionUtils.isNotEmpty(protocol.getProtocolPersons())) {
      for (ProtocolPersonBase person : protocol.getProtocolPersons()) {
        // Find protocol person that matches the principal id
        if (StringUtils.equals(principalId, person.getPersonId())) {
          if (StringUtils.equals(roleName, person.getProtocolPersonRoleId())) {
            return true;
          }
        }
      }
    }

    return false;
  }
  @Override
  public List<CommitteeMembershipBase> getAvailableCommitteeMembersForCurrentSubmission(
      ProtocolBase protocol) {
    List<CommitteeMembershipBase> results = new ArrayList<CommitteeMembershipBase>();

    ProtocolSubmissionBase submission = protocol.getProtocolSubmission();
    submission.refreshReferenceObject("protocolOnlineReviews");
    if (LOG.isDebugEnabled()) {
      LOG.debug(
          String.format(
              "Fetching available committee members for protocol %s, submission %s",
              protocol.getProtocolNumber(), submission.getSubmissionNumber()));
    }

    List<ProtocolOnlineReviewBase> currentReviews = submission.getProtocolOnlineReviews();
    List<CommitteeMembershipBase> committeeMembers =
        getCommitteeService()
            .getAvailableMembers(submission.getCommitteeId(), submission.getScheduleId());
    // TODO: Make this better.
    for (CommitteeMembershipBase member : committeeMembers) {
      boolean found = false;
      for (ProtocolOnlineReviewBase review : currentReviews) {
        if (review.getProtocolReviewer().isProtocolReviewerFromCommitteeMembership(member)
            && review.isActive()) {
          found = true;
          break;
        }
      }
      if (!found && !isProtocolPersonnel(protocol, member)) {
        results.add(member);
      }
    }

    return results;
  }
  /*
   * if questionnaire is associated with Amendment/renewal submodulecode.
   * if this protocol is normal protocol, then it has to check whether the A/R of this
   * questionnaire has merged to this protocol yet.
   */
  private boolean isCurrentAorRQn(AnswerHeader answerHeader) {
    boolean isCurrentQn = false;
    if (getProtocol().isAmendment() || getProtocol().isRenewal()) {
      // if this is A/R, then just match sequencenumber and modulesubitemkey
      isCurrentQn =
          answerHeader.getModuleSubItemKey().equals(getProtocol().getSequenceNumber().toString());
    } else {
      // if this is a regular protocol, then get this A/R associated this this Qn and see if
      // A/R has been merged to this version of protocol
      Map keyValues = new HashMap();
      keyValues.put("protocolNumber", answerHeader.getModuleItemKey());

      ProtocolBase protocol =
          ((List<ProtocolBase>)
                  getBusinessObjectService()
                      .findMatchingOrderBy(
                          getProtocolBOClassHook(), keyValues, "sequenceNumber", false))
              .get(0);

      isCurrentQn =
          answerHeader.getModuleSubItemKey().equals(protocol.getSequenceNumber().toString())
              && !CollectionUtils.isEmpty(protocol.getProtocolSubmissions())
              && isMergedToProtocol(getProtocol(), protocol);
    }
    return isCurrentQn;
  }
Ejemplo n.º 4
0
  @Override
  public void setPrincipalInvestigator(
      ProtocolPersonBase newPrincipalInvestigator, ProtocolBase protocol) {
    if (protocol != null) {
      ProtocolPerson currentPrincipalInvestigator =
          (ProtocolPerson) getPrincipalInvestigator(protocol.getProtocolPersons());

      if (newPrincipalInvestigator != null) {
        newPrincipalInvestigator.setProtocolPersonRoleId(getPrincipalInvestigatorRole());
        if (currentPrincipalInvestigator == null) {
          protocol.getProtocolPersons().add(newPrincipalInvestigator);
        } else if (!isDuplicatePerson(protocol.getProtocolPersons(), newPrincipalInvestigator)) {
          protocol.getProtocolPersons().remove(currentPrincipalInvestigator);
          protocol.getProtocolPersons().add(newPrincipalInvestigator);
        }

        // Assign the PI the APPROVER role if PI has a personId (for doc cancel).
        if (newPrincipalInvestigator.getPersonId() != null) {
          personEditableService.populateContactFieldsFromPersonId(newPrincipalInvestigator);
          KcAuthorizationService kraAuthService =
              KcServiceLocator.getService(KcAuthorizationService.class);
          kraAuthService.addDocumentLevelRole(
              newPrincipalInvestigator.getPersonId(), RoleConstants.PROTOCOL_APPROVER, protocol);
        } else {
          personEditableService.populateContactFieldsFromRolodexId(newPrincipalInvestigator);
        }
      }
    }
  }
 @Override
 public List<ProtocolOnlineReviewDocumentBase> getProtocolReviewDocumentsForCurrentSubmission(
     ProtocolBase protocol) {
   List<ProtocolOnlineReviewDocumentBase> onlineReviewDocuments =
       new ArrayList<ProtocolOnlineReviewDocumentBase>();
   ProtocolSubmissionBase submission = protocol.getProtocolSubmission();
   List<ProtocolOnlineReviewBase> reviews =
       findProtocolOnlineReviews(protocol.getProtocolId(), submission.getSubmissionId());
   for (ProtocolOnlineReviewBase review : reviews) {
     if (review.isActive()) {
       review.refresh();
       try {
         onlineReviewDocuments.add(
             (ProtocolOnlineReviewDocumentBase)
                 (documentService.getByDocumentHeaderId(
                     review.getProtocolOnlineReviewDocument().getDocumentNumber())));
       } catch (WorkflowException e) {
         throw new RuntimeException(
             String.format(
                 "Could not load ProtocolOnlineReviewBase docuemnt %s due to WorkflowException: %s",
                 review.getProtocolOnlineReviewDocument().getDocumentNumber(), e.getMessage()),
             e);
       }
     }
   }
   return onlineReviewDocuments;
 }
 @Override
 public boolean isAuthorized(String username, IacucProtocolTask task) {
   ProtocolBase protocol = task.getProtocol();
   return !(kraWorkflowService.isInWorkflow(protocol.getProtocolDocument())
           && kraWorkflowService.isCurrentNode(
               protocol.getProtocolDocument(), Constants.PROTOCOL_IACUCREVIEW_ROUTE_NODE_NAME)
           && canExecuteAction(protocol, IacucProtocolActionType.ASSIGNED_TO_AGENDA)
           && isAssignedToCommittee(protocol))
       && hasPermission(username, protocol, PermissionConstants.PERFORM_IACUC_ACTIONS_ON_PROTO);
 }
Ejemplo n.º 7
0
  protected ProtocolDocument getReturnedVersionedDocument(ProtocolBase protocol) throws Exception {
    getDocumentService()
        .cancelDocument(
            protocol.getProtocolDocument(),
            "Protocol document cancelled - protocol has been returned for revisions.");
    getProtocolOnlineReviewService()
        .finalizeOnlineReviews(
            protocol.getProtocolSubmission(),
            "Protocol Review finalized - protocol has been returned for revisions.");

    return (ProtocolDocument) getVersionedDocument(protocol);
  }
 @Override
 public ModuleQuestionnaireBean getModuleQnBean() {
   String baseProtocolNumber = protocol.getProtocolNumber();
   baseProtocolNumber = baseProtocolNumber.replaceAll("[A-Z]+", "");
   return new ProtocolModuleQuestionnaireBean(
       getModuleCode(),
       baseProtocolNumber,
       CoeusSubModule.PROTOCOL_SUBMISSION,
       StringUtils.isNotBlank(submissionNumber) ? submissionNumber : actionTypeCode,
       StringUtils.isNotBlank(submissionNumber)
           || protocol.getProtocolNumber().endsWith(SUFFIX_T)
           || readOnlyView);
 }
  @Override
  public List<ProtocolOnlineReviewBase> getProtocolReviews(String protocolNumber) {
    ProtocolBase protocol = protocolFinderDao.findCurrentProtocolByNumber(protocolNumber);
    List<ProtocolOnlineReviewBase> reviews = null;

    if (protocol != null && protocol.getProtocolSubmission() != null) {
      reviews = protocol.getProtocolSubmission().getProtocolOnlineReviews();
    } else {
      reviews = new ArrayList<ProtocolOnlineReviewBase>();
    }

    return reviews;
  }
Ejemplo n.º 10
0
 /**
  * This method is to return appropriate watermark with respect to the protocol document status.
  *
  * @return waterMarkBean
  */
 public WatermarkBean getWatermark() {
   ProtocolBase protocol = (ProtocolBase) getPersistableBusinessObject();
   String protocolStatusCode = protocol.getProtocolStatusCode();
   if (protocolStatusCode != null) {
     WatermarkBean waterMarkBean = null;
     try {
       waterMarkBean = getProtocolWatermarkBeanObject(protocolStatusCode);
     } catch (Exception e) {
       LOG.error("Exception Occured in (ProtocolPrintWatermarkBase) :", e);
     }
     return waterMarkBean;
   }
   return null;
 }
Ejemplo n.º 11
0
 protected void performDisapprove(ProtocolBase protocol) throws Exception {
   if (protocol.getProtocolDocument() != null) {
     WorkflowDocument currentWorkflowDocument =
         protocol.getProtocolDocument().getDocumentHeader().getWorkflowDocument();
     if (currentWorkflowDocument != null) {
       currentWorkflowDocument.disapprove(
           "Protocol document disapproved after committee decision");
     }
   }
   getProtocolOnlineReviewService()
       .cancelOnlineReviews(
           protocol.getProtocolSubmission(),
           "Protocol Review cancelled - protocol has been disapproved.");
 }
 private boolean isMergedToProtocol(ProtocolBase protocol, ProtocolBase amendment) {
   boolean merged = false;
   int submissionNumber =
       amendment
           .getProtocolSubmissions()
           .get(amendment.getProtocolSubmissions().size() - 1)
           .getSubmissionNumber();
   for (ProtocolSubmissionBase submission : protocol.getProtocolSubmissions()) {
     if (submissionNumber == submission.getSubmissionNumber().intValue()) {
       merged = true;
       break;
     }
   }
   return merged;
 }
Ejemplo n.º 13
0
 /** {@inheritDoc} */
 @Override
 public boolean isAuthorized(String username, IacucProtocolTask task) {
   ProtocolBase protocol = task.getProtocol();
   return (!canExecuteAction(protocol, IacucProtocolActionType.NOTIFY_IACUC)
           || isAmendmentOrRenewal(protocol)
           || (isRequestForSuspension(
                   findSubmisionHook(task.getProtocol()),
                   IacucProtocolSubmissionType.REQUEST_SUSPEND)
               && !isAdmin(
                   username,
                   RoleConstants.DEPARTMENT_ROLE_TYPE,
                   RoleConstants.IACUC_ADMINISTRATOR)))
       && (hasPermission(username, protocol, PermissionConstants.SUBMIT_IACUC_PROTOCOL)
           || hasPermission(username, protocol, PermissionConstants.SUBMIT_ANY_IACUC_PROTOCOL)
           || StringUtils.equals(protocol.getPrincipalInvestigator().getUserName(), username));
 }
 @Override
 protected ProtocolActionBase getNewDisapprovedInRoutingProtocolActionInstanceHook(
     ProtocolBase protocol) {
   return new IacucProtocolAction(
       (IacucProtocol) protocol,
       (IacucProtocolSubmission) protocol.getProtocolSubmission(),
       IacucProtocolActionType.REJECTED_IN_ROUTING);
 }
 @Override
 public void iacucAcknowledgement(ProtocolBase protocol, ProtocolGenericActionBean actionBean)
     throws Exception {
   performGenericAction(
       protocol,
       actionBean,
       IacucProtocolActionType.IACUC_ACKNOWLEDGEMENT,
       protocol.getProtocolStatusCode());
 }
  private List<String> getPersonnelIds(ProtocolBase protocol) {
    List<String> PersonnelIds = new ArrayList<String>();
    for (ProtocolPersonBase person : protocol.getProtocolPersons()) {
      if (StringUtils.isNotBlank(person.getPersonId())) {
        PersonnelIds.add(person.getPersonId());
      } else {
        PersonnelIds.add(person.getRolodexId().toString());
      }
    }

    return PersonnelIds;
  }
  @Override
  public List<RoleMembership> getRoleMembersFromDerivedRole(
      String namespaceCode, String roleName, Map<String, String> qualification) {
    validateRequiredAttributesAgainstReceived(qualification);

    List<RoleMembership> members = new ArrayList<RoleMembership>();

    String protocolNumber = qualification.get(KcKimAttributes.PROTOCOL);
    ProtocolBase protocol = getProtocol(protocolNumber);

    if (protocol != null && CollectionUtils.isNotEmpty(protocol.getProtocolPersons())) {
      for (ProtocolPersonBase person : protocol.getProtocolPersons()) {
        if (StringUtils.equals(person.getProtocolPersonRoleId(), roleName)
            && StringUtils.isNotBlank(person.getPerson().getPersonId())) {
          members.add(
              RoleMembership.Builder.create(
                      null, null, person.getPerson().getPersonId(), MemberType.PRINCIPAL, null)
                  .build());
        }
      }
    }

    return members;
  }
  protected void buildAndAttachProtocolCorrespondence(
      ProtocolBase protocol, byte[] data, String correspTypeCode) {

    ProtocolCorrespondence protocolCorrespondence = getNewProtocolCorrespondenceHook();
    protocolCorrespondence.setProtocol(protocol);
    protocolCorrespondence.setProtocolId(protocol.getProtocolId());
    protocolCorrespondence.setProtocolNumber(protocol.getProtocolNumber());
    protocolCorrespondence.setSequenceNumber(protocol.getSequenceNumber());
    protocolCorrespondence.setProtoCorrespTypeCode(correspTypeCode);

    ProtocolActionBase lastAction = protocol.getLastProtocolAction();
    protocolCorrespondence.setProtocolAction(lastAction);
    protocolCorrespondence.setActionIdFk(lastAction.getProtocolActionId());
    protocolCorrespondence.setCorrespondence(data);
    protocolCorrespondence.setActionId(lastAction.getActionId());

    // What is Final flag used for? ANSWER: the final flag is used by the IRB admin to denote
    // correspondences
    // that are ready to be sent/published to the PI etc.
    protocolCorrespondence.setFinalFlag(false);
    protocolCorrespondence.setCreateUser(GlobalVariables.getUserSession().getPrincipalName());
    protocolCorrespondence.setCreateTimestamp(dateTimeService.getCurrentTimestamp());

    if (lastAction.getProtocolCorrespondences() == null) {
      List<ProtocolCorrespondence> correspondences = new ArrayList<ProtocolCorrespondence>();
      correspondences.add(protocolCorrespondence);
      lastAction.setProtocolCorrespondences(correspondences);
      protocol.refreshReferenceObject("protocolSubmissions");
    } else {
      lastAction.getProtocolCorrespondences().add(protocolCorrespondence);
    }

    getBusinessObjectService().save(protocolCorrespondence);

    getBusinessObjectService().save(protocol);
  }
 /*
  * This is Questionnaire answer is with submodulecode of "0".
  * Then if this protocol is A/R, then it has to check whether this is the first version
  * A/R merged into.
  */
 private boolean isCurrentRegularQn(AnswerHeader answerHeader) {
   boolean isCurrentQn = false;
   if ((getProtocol().isAmendment() || getProtocol().isRenewal())
       && !answerHeader.getModuleItemKey().equals(getProtocol().getProtocolNumber())) {
     Map keyValues = new HashMap();
     keyValues.put("protocolNumber", answerHeader.getModuleItemKey());
     ProtocolBase prevProtocol = null;
     // if this is an A/R protocol, then need to find the original protocol that the A/R first
     // merged into.
     for (ProtocolBase protocol :
         ((List<ProtocolBase>)
             getBusinessObjectService()
                 .findMatchingOrderBy(
                     getProtocolBOClassHook(), keyValues, "sequenceNumber", true))) {
       isCurrentQn =
           answerHeader.getModuleSubItemKey().equals(protocol.getSequenceNumber().toString())
               && !CollectionUtils.isEmpty(getProtocol().getProtocolSubmissions())
               && isMergedToProtocol(protocol, getProtocol());
       if (isCurrentQn) {
         if (prevProtocol == null || !isMergedToProtocol(prevProtocol, getProtocol())) {
           // this is the protocol this A/R merged into. so, use this questionnaire.
           break;
         } else {
           // prevProtocol is the initial ProtocolBase that this A/R merged into.
           isCurrentQn = false;
         }
       }
       prevProtocol = protocol;
     }
   } else {
     // if this is a regular protocol, then check if sequencenumber & modulesubitemkey match
     isCurrentQn =
         answerHeader.getModuleSubItemKey().equals(getProtocol().getSequenceNumber().toString());
   }
   return isCurrentQn;
 }
Ejemplo n.º 20
0
 @Override
 public void suspend(
     ProtocolBase protocol,
     org.kuali.kra.protocol.actions.genericactions.ProtocolGenericActionBean actionBean)
     throws Exception {
   if (ProtocolActionType.REQUEST_FOR_SUSPENSION.equals(
       protocol.getLastProtocolAction().getProtocolActionType().getProtocolActionTypeCode())) {
     // if previous action is request to suspend then the new status is suspend by investigator
     performGenericAction(
         protocol, actionBean, ProtocolActionType.SUSPENDED, ProtocolStatus.SUSPENDED_BY_PI);
   } else {
     // else suspend by IRB
     performGenericAction(
         protocol, actionBean, ProtocolActionType.SUSPENDED, ProtocolStatus.SUSPENDED_BY_IRB);
   }
 }
 protected ProtocolSubmission getSubmission(ProtocolBase protocol) {
   // There are 'findCommission' in other classes.  Consider to create a utility static method for
   // this
   // need to loop thru to find the last submission.
   // it may have submit/Wd/notify irb/submit, and this will cause problem if don't loop thru.
   ProtocolSubmission protocolSubmission = null;
   for (ProtocolSubmissionBase submission : protocol.getProtocolSubmissions()) {
     if (StringUtils.equals(
             submission.getSubmissionStatusCode(), ProtocolSubmissionStatus.IN_AGENDA)
         || StringUtils.equals(
             submission.getSubmissionStatusCode(),
             ProtocolSubmissionStatus.SUBMITTED_TO_COMMITTEE)) {
       protocolSubmission = (ProtocolSubmission) submission;
     }
   }
   return protocolSubmission;
 }
 @Override
 public void iacucLiftHold(ProtocolBase protocol, ProtocolGenericActionBean actionBean)
     throws Exception {
   // find the last lift notification protocol action.
   ProtocolActionBase selectedPa = null;
   for (ProtocolActionBase pa : protocol.getProtocolActions()) {
     if (StringUtils.equalsIgnoreCase(pa.getProtocolActionTypeCode(), IacucProtocolActionType.HOLD)
         && (selectedPa == null || pa.getSequenceNumber() > selectedPa.getSequenceNumber())) {
       selectedPa = pa;
     }
   }
   performGenericAction(
       protocol,
       actionBean,
       IacucProtocolActionType.LIFT_HOLD,
       selectedPa.getPrevProtocolStatusCode());
 }
 @Override
 public boolean isProtocolInStateToBeReviewed(ProtocolBase protocol) {
   boolean isReviewable = false;
   ProtocolSubmission submission =
       (ProtocolSubmission) ((Protocol) protocol).getProtocolSubmission();
   if (submission != null) {
     try {
       isReviewable =
           StringUtils.isNotEmpty(submission.getScheduleId())
               || ProtocolReviewType.EXPEDITED_REVIEW_TYPE_CODE.equals(
                   submission.getProtocolReviewTypeCode())
               || (ProtocolReviewType.FYI_TYPE_CODE.equalsIgnoreCase(
                       submission.getProtocolReviewTypeCode())
                   && ProtocolSubmissionType.NOTIFY_IRB.equalsIgnoreCase(
                       submission.getProtocolSubmissionType().getSubmissionTypeCode()));
       isReviewable &=
           (StringUtils.equals(
                   submission.getSubmissionStatusCode(),
                   ProtocolSubmissionStatus.SUBMITTED_TO_COMMITTEE)
               || StringUtils.equals(
                   submission.getSubmissionStatusCode(), ProtocolSubmissionStatus.IN_AGENDA));
       ProtocolDocument protocolDocument =
           (ProtocolDocument)
               protocol
                   .getProtocolDocument(); // (ProtocolDocument)
                                           // documentService.getByDocumentHeaderId(protocol.getProtocolDocument().getDocumentNumber());
       isReviewable &=
           getKraWorkflowService()
               .isCurrentNode(protocolDocument, Constants.PROTOCOL_IRBREVIEW_ROUTE_NODE_NAME);
     } catch (Exception e) {
       String errorString =
           String.format(
               "WorkflowException checking route node for creating new ProtocolOnlineReviewDocument "
                   + "for protocol %s",
               submission.getProtocolNumber());
       LOG.error(errorString, e);
       throw new RuntimeException(errorString, e);
     }
   }
   return isReviewable;
 }
  public boolean isProtocolInStateToBeReviewed(ProtocolBase protocol) {
    boolean isReviewable = false;
    ProtocolSubmissionBase submission =
        (IacucProtocolSubmission) ((IacucProtocol) protocol).getProtocolSubmission();

    if (submission != null) {
      try {
        isReviewable =
            StringUtils.isNotEmpty(submission.getScheduleId())
                || StringUtils.equals(
                    submission.getProtocolSubmissionType().getSubmissionTypeCode(),
                    IacucProtocolSubmissionType.NOTIFY_IACUC);
        isReviewable &=
            (StringUtils.equals(
                    submission.getSubmissionStatusCode(),
                    IacucProtocolSubmissionStatus.SUBMITTED_TO_COMMITTEE)
                || StringUtils.equals(
                    submission.getSubmissionStatusCode(), IacucProtocolSubmissionStatus.IN_AGENDA));
        ProtocolDocumentBase protocolDocument =
            (ProtocolDocumentBase)
                documentService.getByDocumentHeaderId(
                    protocol.getProtocolDocument().getDocumentNumber());
        isReviewable &=
            kraWorkflowService.isCurrentNode(
                protocolDocument, Constants.IACUC_PROTOCOL_IACUCREVIEW_ROUTE_NODE_NAME);
      } catch (WorkflowException e) {
        String errorString =
            String.format(
                "WorkflowException checking route node for creating new ProtocolOnlineReviewDocumentBase "
                    + "for protocol %s",
                submission.getProtocolNumber());
        LOG.error(errorString, e);
        throw new RuntimeException(errorString, e);
      }
    }
    return isReviewable;
  }
Ejemplo n.º 25
0
 /**
  * Can the user on the current thread execute the given action for the given protocol?
  *
  * @param protocol
  * @param protocolActionTypeCode
  * @return true if the action can be executed; otherwise false
  */
 protected final boolean canExecuteAction(ProtocolBase protocol, String protocolActionTypeCode) {
   return protocol.isActive()
       && !protocol.getProtocolDocument().isViewOnly()
       && protocolActionService.isActionAllowed(protocolActionTypeCode, protocol);
 }
Ejemplo n.º 26
0
 /**
  * Is the protocol an amendment or renewal protocol? Including continuation here - since
  * continuation is similar to renewal
  *
  * @param protocol the protocol
  * @return true if the protocol is an amendment or renewal; otherwise false
  */
 protected final boolean isAmendmentOrRenewal(ProtocolBase protocol) {
   return protocol.getProtocolNumber() != null
       && (protocol.getProtocolNumber().contains("A")
           || protocol.getProtocolNumber().contains("R")
           || protocol.getProtocolNumber().contains("C"));
 }