Ejemplo n.º 1
0
  private void addAnalyzerResultFromLine(List<AnalyzerResults> results, String line) {
    String[] fields = StringUtil.separateCSVWithMixedEmbededQuotes(line);

    // This insures that the row has not been truncated
    if (fields.length < maxViewedIndex) {
      return;
    }

    AnalyzerReaderUtil readerUtil = new AnalyzerReaderUtil();
    String analyzerAccessionNumber = fields[Sample_ID].replace("\"", "");
    analyzerAccessionNumber = StringUtil.strip(analyzerAccessionNumber, " ");

    String date = fields[Date_Analyzed].replace("\"", "");

    // this is sort of dumb, we have the indexes we are interested in
    for (int i = 0; i < testNameIndex.length; i++) {
      if (!GenericValidator.isBlankOrNull(testNameIndex[i])) {
        MappedTestName mappedName =
            AnalyzerTestNameCache.instance()
                .getMappedTest(AnalyzerType.FACSCANTO, testNameIndex[i].replace("\"", ""));

        if (mappedName == null) {
          mappedName =
              AnalyzerTestNameCache.instance()
                  .getEmptyMappedTestName(
                      AnalyzerType.FACSCANTO, testNameIndex[i].replace("\"", ""));
        }

        AnalyzerResults analyzerResults = new AnalyzerResults();

        analyzerResults.setAnalyzerId(mappedName.getAnalyzerId());

        String result = fields[i].replace("\"", "");
        result = roundTwoDigits(result);
        analyzerResults.setResult(result);
        analyzerResults.setUnits(unitsIndex[i]);

        analyzerResults.setCompleteDate(
            DateUtil.convertStringDateToTimestampWithPatternNoLocale(date, DATE_PATTERN));
        // analyzerResults.setCompleteTime(DateUtil.convertStringDateToTimestamp(date));
        analyzerResults.setTestId(mappedName.getTestId());
        analyzerResults.setAccessionNumber(analyzerAccessionNumber);
        analyzerResults.setTestName(mappedName.getOpenElisTestName());

        if (analyzerAccessionNumber != null) {
          analyzerResults.setIsControl(
              analyzerAccessionNumber.startsWith(CONTROL_ACCESSION_PREFIX));
        } else {
          analyzerResults.setIsControl(false);
        }

        results.add(analyzerResults);

        AnalyzerResults resultFromDB = readerUtil.createAnalyzerResultFromDB(analyzerResults);
        if (resultFromDB != null) {
          results.add(resultFromDB);
        }
      }
    }
  }
  private ReportExternalImport createReportExternalImport(
      String sendingSiteId, String eventDate, String data) {
    ReportExternalImport importReport = new ReportExternalImport();

    importReport.setEventDate(
        DateUtil.convertStringDateToTimestampWithPatternNoLocale(eventDate, DATE_PATTERN));
    importReport.setSendingSite(sendingSiteId);
    importReport.setReportType("testIndicators");

    ReportExternalImport rei = reportImportDAO.getReportByEventDateSiteType(importReport);

    if (rei != null) {
      importReport = rei;
    }

    importReport.setData(data);
    importReport.setSysUserId("1");
    importReport.setRecievedDate(DateUtil.getTimestampAtMidnightForDaysAgo(0));

    return importReport;
  }