protected ActivityReportBean createActivityReportBean(Result result, boolean useTestName) {
    ActivityReportBean item = new ActivityReportBean();

    ResultService resultService = new ResultService(result);
    SampleService sampleService =
        new SampleService(result.getAnalysis().getSampleItem().getSample());
    PatientService patientService = new PatientService(sampleService.getSample());
    item.setResultValue(resultService.getResultValue("\n", true, true));
    item.setTechnician(resultService.getSignature());
    item.setAccessionNumber(sampleService.getAccessionNumber().substring(PREFIX_LENGTH));
    item.setReceivedDate(sampleService.getReceivedDateWithTwoYearDisplay());
    item.setResultDate(DateUtil.convertTimestampToTwoYearStringDate(result.getLastupdated()));
    item.setCollectionDate(
        DateUtil.convertTimestampToTwoYearStringDate(
            result.getAnalysis().getSampleItem().getCollectionDate()));

    List<String> values = new ArrayList<String>();
    values.add(
        patientService.getLastName() == null ? "" : patientService.getLastName().toUpperCase());
    values.add(patientService.getNationalId());

    String referringPatientId =
        ObservationHistoryService.getValueForSample(
            ObservationType.REFERRERS_PATIENT_ID, sampleService.getSample().getId());
    values.add(referringPatientId == null ? "" : referringPatientId);

    String name = StringUtil.buildDelimitedStringFromList(values, " / ", true);

    if (useTestName) {
      item.setPatientOrTestName(resultService.getTestName());
      item.setNonPrintingPatient(name);
    } else {
      item.setPatientOrTestName(name);
    }

    return item;
  }
  protected RejectionReportBean createRejectionReportBean(
      String noteText, Analysis analysis, boolean useTestName) {
    RejectionReportBean item = new RejectionReportBean();

    AnalysisService analysisService = new AnalysisService(analysis);
    SampleService sampleService =
        new SampleService(analysisService.getAnalysis().getSampleItem().getSample());
    PatientService patientService = new PatientService(sampleService.getSample());

    List<Result> results = analysisService.getResults();
    for (Result result : results) {
      String signature = new ResultService(result).getSignature();
      if (!GenericValidator.isBlankOrNull(signature)) {
        item.setTechnician(signature);
        break;
      }
    }

    item.setAccessionNumber(sampleService.getAccessionNumber().substring(PREFIX_LENGTH));
    item.setReceivedDate(sampleService.getTwoYearReceivedDateForDisplay());
    item.setCollectionDate(
        DateUtil.convertTimestampToTwoYearStringDate(
            analysisService.getAnalysis().getSampleItem().getCollectionDate()));
    item.setRejectionReason(noteText);

    StringBuilder nameBuilder = new StringBuilder(patientService.getLastName().toUpperCase());
    if (!GenericValidator.isBlankOrNull(patientService.getNationalId())) {
      if (nameBuilder.length() > 0) {
        nameBuilder.append(" / ");
      }
      nameBuilder.append(patientService.getNationalId());
    }

    if (useTestName) {
      item.setPatientOrTestName(analysisService.getTest().getLocalizedName());
      item.setNonPrintingPatient(nameBuilder.toString());
    } else {
      item.setPatientOrTestName(nameBuilder.toString());
    }

    return item;
  }