private boolean areResults(AnalysisItem item) { return !(isBlankOrNull(item.getResult()) || (ResultType.DICTIONARY.matches(item.getResultType()) && "0".equals(item.getResult()))) || (ResultType.isMultiSelectVariant(item.getResultType()) && !isBlankOrNull(item.getMultiSelectResultValues())); }
protected TestResult getTestResult(AnalysisItem analysisItem) { TestResult testResult = null; if (ResultType.DICTIONARY.matches(analysisItem.getResultType())) { testResult = testResultDAO.getTestResultsByTestAndDictonaryResult( analysisItem.getTestId(), analysisItem.getResult()); } else { List<TestResult> testResultList = testResultDAO.getTestResultsByTest(analysisItem.getTestId()); // we are assuming there is only one testResult for a numeric type // result if (!testResultList.isEmpty()) { testResult = testResultList.get(0); } } return testResult; }
private String getAppropriateResultValue(List<Result> results) { Result result = results.get(0); if (ResultType.DICTIONARY.matches(result.getResultType())) { Dictionary dictionary = dictionaryDAO.getDictionaryById(result.getValue()); if (dictionary != null) { return dictionary.getLocalizedName(); } } else if (ResultType.isMultiSelectVariant(result.getResultType())) { Dictionary dictionary = new Dictionary(); StringBuilder multiResult = new StringBuilder(); for (Result subResult : results) { dictionary.setId(subResult.getValue()); dictionaryDAO.getData(dictionary); if (dictionary.getId() != null) { multiResult.append(dictionary.getLocalizedName()); multiResult.append(", "); } } if (multiResult.length() > 0) { multiResult.setLength(multiResult.length() - 2); // remove last ", " } return multiResult.toString(); } else { String resultValue = GenericValidator.isBlankOrNull(result.getValue()) ? "" : result.getValue(); if (!GenericValidator.isBlankOrNull(resultValue) && result.getAnalysis().getTest().getUnitOfMeasure() != null) { resultValue += " " + result.getAnalysis().getTest().getUnitOfMeasure().getName(); } return resultValue; } return ""; }