private void checkIfSamplesFinished(List<AnalysisItem> resultItemList) {
    sampleUpdateList = new ArrayList<Sample>();

    String currentSampleId = "";
    boolean sampleFinished = true;

    for (AnalysisItem analysisItem : resultItemList) {

      String analysisSampleId =
          sampleDAO.getSampleByAccessionNumber(analysisItem.getAccessionNumber()).getId();
      if (!analysisSampleId.equals(currentSampleId)) {

        currentSampleId = analysisSampleId;

        List<Analysis> analysisList = analysisDAO.getAnalysesBySampleId(currentSampleId);

        for (Analysis analysis : analysisList) {
          if (!sampleFinishedStatus.contains(Integer.parseInt(analysis.getStatusId()))) {
            sampleFinished = false;
            break;
          }
        }

        if (sampleFinished) {
          Sample sample = new Sample();
          sample.setId(currentSampleId);
          sampleDAO.getData(sample);
          sample.setStatusId(StatusService.getInstance().getStatusID(OrderStatus.Finished));
          sampleUpdateList.add(sample);
        }

        sampleFinished = true;
      }
    }
  }
 private void setSampleFinishedStatuses() {
   sampleFinishedStatus = new ArrayList<Integer>();
   sampleFinishedStatus.add(
       Integer.parseInt(StatusService.getInstance().getStatusID(AnalysisStatus.Finalized)));
   sampleFinishedStatus.add(
       Integer.parseInt(StatusService.getInstance().getStatusID(AnalysisStatus.Canceled)));
   sampleFinishedStatus.add(
       Integer.parseInt(
           StatusService.getInstance().getStatusID(AnalysisStatus.NonConforming_depricated)));
 }
  private void createNeededNotes(AnalysisItem analysisItem, NoteService noteService) {
    if (analysisItem.getIsRejected()) {
      Note note =
          noteService.createSavableNote(
              NoteType.INTERNAL,
              StringUtil.getMessageForKey("validation.note.retest"),
              RESULT_SUBJECT,
              currentUserId);
      noteUpdateList.add(note);
    }

    if (!GenericValidator.isBlankOrNull(analysisItem.getNote())) {
      NoteType noteType = analysisItem.getIsAccepted() ? NoteType.EXTERNAL : NoteType.INTERNAL;
      Note note =
          noteService.createSavableNote(
              noteType, analysisItem.getNote(), RESULT_SUBJECT, currentUserId);
      noteUpdateList.add(note);
    }
  }
  private void createUpdateList(List<AnalysisItem> analysisItems, boolean areListeners) {

    List<String> analysisIdList = new ArrayList<String>();

    for (AnalysisItem analysisItem : analysisItems) {
      if (!analysisItem.isReadOnly() && analysisItemWillBeUpdated(analysisItem)) {

        AnalysisService analysisService = new AnalysisService(analysisItem.getAnalysisId());
        Analysis analysis = analysisService.getAnalysis();
        NoteService noteService = new NoteService(analysis);

        analysis.setSysUserId(currentUserId);

        if (!analysisIdList.contains(analysis.getId())) {

          if (analysisItem.getIsAccepted()) {
            analysis.setStatusId(StatusService.getInstance().getStatusID(AnalysisStatus.Finalized));
            analysis.setReleasedDate(new java.sql.Date(Calendar.getInstance().getTimeInMillis()));
            analysisIdList.add(analysis.getId());
            analysisUpdateList.add(analysis);
          }

          if (analysisItem.getIsRejected()) {
            analysis.setStatusId(
                StatusService.getInstance().getStatusID(AnalysisStatus.BiologistRejected));
            analysisIdList.add(analysis.getId());
            analysisUpdateList.add(analysis);
          }
        }

        createNeededNotes(analysisItem, noteService);

        if (areResults(analysisItem)) {
          List<Result> results =
              createResultFromAnalysisItem(analysisItem, analysisService, noteService);
          for (Result result : results) {
            resultUpdateList.add(result);

            if (areListeners) {
              addResultSets(analysis, result);
            }
          }
        }
      }
    }
  }
  private List<Result> createResultFromAnalysisItem(
      AnalysisItem analysisItem, AnalysisService analysisService, NoteService noteService) {

    ResultSaveBean bean = ResultSaveBeanAdapter.fromAnalysisItem(analysisItem);
    ResultSaveService resultSaveService =
        new ResultSaveService(analysisService.getAnalysis(), currentUserId);
    List<Result> results = resultSaveService.createResultsFromTestResultItem(bean, deletableList);
    if (analysisService.patientReportHasBeenDone() && resultSaveService.isUpdatedResult()) {
      analysisService.getAnalysis().setCorrectedSincePatientReport(true);
      noteUpdateList.add(
          noteService.createSavableNote(
              NoteType.EXTERNAL,
              StringUtil.getMessageForKey("note.corrected.result"),
              RESULT_SUBJECT,
              currentUserId));
    }
    return results;
  }
 /**
  * メソッド概要 ・ユーザー名一覧を設定する
  *
  * @param ・なし
  * @return ・なし
  */
 public void fEtexExecuteRecognitionSetAllStaffName() {
   /* 社員名             */
   String stgSelectStaff = null;
   /* 選択オプション         */
   String stgSelect = null;
   /* DB接続ハンドル       */
   CEtexGeneralDbHandle clsParamDbHandle = null;
   /* 一覧情報格納リスト    */
   ArrayList arrayDispData = null;
   /* 画面表示データBean   */
   CEtexRecognitionDispBean clsDispBean = null;
   /* リクエスト情報          */
   HttpServletRequest hpRequest = null;
   /* リクエスト情報取得          */
   hpRequest = clsRecognitionCtlBean.getRecognitionRequest();
   /* DB接続ハンドル生成   */
   clsParamDbHandle = new CEtexGeneralDbHandle();
   /* リストデータ生成 */
   arrayDispData = new ArrayList();
   /* 選択されているユーザ情報取得 */
   stgSelectStaff = clsRecognitionCtlBean.getRecognitionSerchStaffCode();
   /* 「全員」項目情報設定 */
   clsDispBean = new CEtexRecognitionDispBean();
   /* 選択オプション情報設定 */
   clsDispBean.setRecognitionDispStaffSelect(ETEX_RECOGNITION_SELECT);
   /* 対象ユーザー社員コード設定 */
   clsDispBean.setRecognitionDispStaffCode("000-0000");
   /* 対象ユーザー名前設定 */
   clsDispBean.setRecognitionDispStaffName("全員");
   /* 対象ユーザーよみがな設定 */
   clsDispBean.setRecognitionDispStaffKana("ALL");
   /* リスト追加 */
   arrayDispData.add(clsDispBean);
   /* DBオープン */
   fEtexGeneralDbUtilOpen(clsParamDbHandle);
   /* DBのExceptionエラー用のtry */
   try {
     /* DB検索 */
     fEtexGeneralDbUtilSelect(
         clsParamDbHandle,
         fEtexExecuteRecognitionPublishSql(ETEX_RECOGNITION_DB_SELECT_EIMD010_EX, null));
     /* 検索結果が存在するかチェック */
     while (fEtexGeneralDbUtilSeek(clsParamDbHandle) == true) {
       /* 画面表示Bean生成 */
       clsDispBean = new CEtexRecognitionDispBean();
       /* リスト追加 */
       /* 対象ユーザと検索結果のユーザー情報が一致するかチェック */
       if (stgSelectStaff.equals(fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "md010010v"))
           == true) {
         stgSelect = ETEX_RECOGNITION_SELECT;
       } else {
         stgSelect = ETEX_GENERAL_STRING_EMPTY;
       }
       /* 選択オプション情報設定 */
       clsDispBean.setRecognitionDispStaffSelect(stgSelect);
       /* 対象ユーザー社員コード設定 */
       clsDispBean.setRecognitionDispStaffCode(
           fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "md010010v"));
       /* 対象ユーザー名前設定 */
       clsDispBean.setRecognitionDispStaffName(
           fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "md010110v"));
       /* 対象ユーザーよみがな設定 */
       clsDispBean.setRecognitionDispStaffKana(
           fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "md010120v"));
       /* リスト追加 */
       arrayDispData.add(clsDispBean);
     }
   } catch (Exception e) {
     /* DBのExceptionエラーをCatchする為のcatch */
     /* 例外情報設定 */
     fEtexGeneralExceptionUtilSetRequest(hpRequest, e);
     /* 例外情報表示 */
     System.err.println(
         "CEtexRecognitionExecute:fEtexExecuteRecognitionSetAllStaffName:" + e.toString());
   }
   /* DBクローズ */
   fEtexGeneralDbUtilClose(clsParamDbHandle);
   /* 設定 */
   clsRecognitionCtlBean.setRecognitionArrayDispBean(arrayDispData);
 }
 /**
  * メソッド概要 ・データ(精算情報表示用)の読み込みコントロール
  *
  * @param ・なし
  * @return ・なし
  */
 public void fEtexExecuteRecognitionReadCtl() {
   /* DB接続ハンドル       */
   CEtexGeneralDbHandle clsParamDbHandle = null;
   /* データ情報          */
   CEtexRecognitionDataBean clsDataBean = null;
   /* データ情報格納リスト   */
   ArrayList arraData = null;
   /* 編集バッファ         */
   String stgbuf = null;
   /* DB接続ハンドル生成   */
   clsParamDbHandle = new CEtexGeneralDbHandle();
   /* リストデータ生成 */
   arraData = new ArrayList();
   /* DBオープン */
   fEtexGeneralDbUtilOpen(clsParamDbHandle);
   /* DBのExceptionエラー用のtry */
   try {
     /* DB検索 */
     fEtexGeneralDbUtilSelect(
         clsParamDbHandle,
         fEtexExecuteRecognitionPublishSql(ETEX_RECOGNITION_DB_SELECT_EITD100, null));
     /* データ読み込み */
     for (int intCnt = 0; fEtexGeneralDbUtilSeek(clsParamDbHandle); intCnt++) {
       clsDataBean = new CEtexRecognitionDataBean();
       /* 承認チェックボックス */
       clsDataBean.setRecognitionDark_1(
           fEtexExecuteRecognitionGetDark_1(
               fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100170C")));
       /* 解除チェックボックス */
       clsDataBean.setRecognitionDark_2(
           fEtexExecuteRecognitionGetDark_2(
               fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100170C")));
       /* 社員コード */
       clsDataBean.setRecognitionDataStaff(
           fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "MD010010V"));
       /* 社員名 */
       clsDataBean.setRecognitionDataName(
           fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "MD010110V"));
       /* 年/月/日(yyyy/mm/dd) */
       stgbuf =
           fEtexGeneralStringUtilFormatChk(
               ETEX_RECOGNITION_FORMAT_YYYYMMDD,
               fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100020V"),
               ETEX_RECOGNITION_STRING_EMPTY_YYYYMMDD);
       clsDataBean.setRecognitionDataDate(stgbuf);
       /* 月/日(mm/dd) */
       stgbuf =
           fEtexGeneralStringUtilFormatChk(
               ETEX_RECOGNITION_FORMAT_MMDD,
               fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100020V").substring(5, 10),
               ETEX_RECOGNITION_STRING_EMPTY_MMDD);
       clsDataBean.setRecognitionDataMMDD(
           fEtexGeneralStringUtilReplace(
               stgbuf, 2, ETEX_RECOGNITION_STRING_SLASH, ETEX_RECOGNITION_STRING_EMPTY_MMDD));
       /* 曜日(d) */
       stgbuf =
           fEtexGeneralStringUtilFormatChk(
               ETEX_RECOGNITION_FORMAT_YYYYMMDD,
               fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100020V"),
               ETEX_RECOGNITION_STRING_EMPTY_YYYYMMDD);
       clsDataBean.setRecognitionDataToday("(" + fEtexGeneralDbUtilGetDayOfWeek(stgbuf) + ")");
       /* 曜日(カラー)*/
       clsDataBean.setRecognitionDataTodayColor(fEtexGeneralDbUtilGetDayOfWeekColor(stgbuf));
       /* index */
       clsDataBean.setRecognitionDataIndex(
           ETEX_GENERAL_STRING_EMPTY
               + fEtexGeneralDbUtilGetDataInt(clsParamDbHandle, "TD100030I"));
       /* 精算区分 */
       clsDataBean.setRecognitionDataClassify(
           fEtexExecuteRecognitionGetClassify(
               fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100170C")));
       /* 訪問先 */
       clsDataBean.setRecognitionDataVisit(
           fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100100V"));
       /* 用件 */
       clsDataBean.setRecognitionDataMatter(
           fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100110V"));
       /* from */
       clsDataBean.setRecognitionDataFrom(
           fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100120V"));
       /* きごう*/
       clsDataBean.setRecognitionDataArrow(
           fEtexExecuteRecognitionGetArrow(
               fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100130C")));
       /* to */
       clsDataBean.setRecognitionDataTo(
           fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "TD100140V"));
       /* 機関 */
       clsDataBean.setRecognitionDataFacility(
           fEtexGeneralDbUtilGetFacility(
               fEtexGeneralDbUtilGetDataString(clsParamDbHandle, "MD120010C")));
       /* 金額*/
       clsDataBean.setRecognitionDataMoney(
           fEexGeneralNumericalUtilCnvStringMoney(
               fEtexGeneralDbUtilGetDataInt(clsParamDbHandle, "TD100150N")));
       /* リスト追加 */
       arraData.add(clsDataBean);
     }
   } catch (Exception e) {
     /* DBのExceptionエラーをCatchする為のcatch */
     /* 例外情報設定 */
     fEtexGeneralExceptionUtilSetRequest(clsRecognitionCtlBean.getRecognitionRequest(), e);
     /* 例外情報表示 */
     System.err.println("CEtexRecognitionExecute:fEtexExecuteRecognitionReadCtl:" + e.toString());
   }
   /* DBクローズ */
   fEtexGeneralDbUtilClose(clsParamDbHandle);
   /* リストデータ格納 */
   clsRecognitionCtlBean.setRecognitionArrayDataBean(arraData);
   /* 次フェーズの設定 */
   clsRecognitionCtlBean.setRecognitionPhase(ETEX_RECOGNITION_PHASE_SCREEN_ADJUST);
 }