/*
  * check if this is the current version of the amend/renewal Qn
  */
 private boolean isCurrentAmendRenewalQn(AnswerHeader answerHeader) {
   boolean isCurrentQn =
       CoeusSubModule.AMENDMENT_RENEWAL.equals(answerHeader.getModuleSubItemCode())
           || CoeusSubModule.AMENDMENT.equals(answerHeader.getModuleSubItemCode())
           || CoeusSubModule.RENEWAL.equals(answerHeader.getModuleSubItemCode())
           || CoeusSubModule.ZERO_SUBMODULE.equals(answerHeader.getModuleSubItemCode());
   if (isCurrentQn) {
     if (CoeusSubModule.ZERO_SUBMODULE.equals(answerHeader.getModuleSubItemCode())) {
       isCurrentQn = isCurrentRegularQn(answerHeader);
     } else if (CoeusSubModule.AMENDMENT_RENEWAL.equals(answerHeader.getModuleSubItemCode())
         || CoeusSubModule.AMENDMENT.equals(answerHeader.getModuleSubItemCode())
         || CoeusSubModule.RENEWAL.equals(answerHeader.getModuleSubItemCode())) {
       isCurrentQn = isCurrentAorRQn(answerHeader);
     }
   }
   return isCurrentQn;
 }
  public void setupQnPrintOption(
      List<AnswerHeader> answerHeaders,
      ProtocolBase protocol,
      List<QuestionnairePrintOption> questionnairesToPrints) {
    setProtocol(protocol);
    int maxSubmissionNumber = getMaxSubmissionNumber();
    for (AnswerHeader answerHeader : answerHeaders) {

      // moduleItemKey is protocol number. When moduleSubItemCode indicates initial protocol as
      // ZERO_MODULE and we have its current qnnr answers
      // ensure those answers can be retrieved from the table by using the original protocol number
      // and not the amend/renew number.
      String moduleItemKey = answerHeader.getModuleItemKey();
      if (CoeusSubModule.ZERO_SUBMODULE.equalsIgnoreCase(answerHeader.getModuleSubItemCode())
          && isCurrentRegularQn(answerHeader)) {
        moduleItemKey = answerHeader.getModuleItemKey().substring(0, 10);
      }

      // only submission questionnaire and current protocol questionnaire will be printed
      if ((CoeusSubModule.PROTOCOL_SUBMISSION.equals(answerHeader.getModuleSubItemCode())
              && Integer.parseInt(answerHeader.getModuleSubItemKey()) <= maxSubmissionNumber)
          || (isCurrentAmendRenewalQn(answerHeader))) {
        QuestionnairePrintOption printOption = new QuestionnairePrintOption();
        printOption.setQuestionnaireId(
            answerHeader.getQuestionnaire().getQuestionnaireRefIdAsLong());
        printOption.setQuestionnaireSeqId(
            answerHeader.getQuestionnaire().getQuestionnaireSeqIdAsInteger());
        printOption.setSelected(true);
        printOption.setQuestionnaireName(answerHeader.getQuestionnaire().getName());
        printOption.setLabel(getQuestionnaireLabel(answerHeader));
        printOption.setItemKey(moduleItemKey);
        printOption.setSubItemKey(answerHeader.getModuleSubItemKey());
        printOption.setSubItemCode(answerHeader.getModuleSubItemCode());
        // finally check if the answerheader's questionnaire is active, and set it accordingly in
        // the Qnnr print option bean
        printOption.setQuestionnaireActive(isQuestionnaireActive(answerHeader));
        questionnairesToPrints.add(printOption);
      }
    }
    Collections.sort(questionnairesToPrints, new QuestionnairePrintOptionComparator());
  }