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;
  }