private List<NonNumericTests> getNonNumericTests(List<ReferralItem> referralItems) { DictionaryDAO dictionaryDAO = new DictionaryDAOImpl(); Set<String> testIdSet = new HashSet<String>(); for (ReferralItem item : referralItems) { for (IdValuePair pair : item.getTestSelectionList()) { testIdSet.add(pair.getId()); } } List<NonNumericTests> nonNumericTestList = new ArrayList<NonNumericTests>(); TestResultDAO testResultDAO = new TestResultDAOImpl(); for (String testId : testIdSet) { List<TestResult> testResultList = testResultDAO.getActiveTestResultsByTest(testId); if (!(testResultList == null || testResultList.isEmpty())) { NonNumericTests nonNumericTests = new NonNumericTests(); nonNumericTests.testId = testId; nonNumericTests.testType = testResultList.get(0).getTestResultType(); boolean isSelectList = ResultType.isDictionaryVariant(nonNumericTests.testType); if (isSelectList) { List<IdValuePair> dictionaryValues = new ArrayList<IdValuePair>(); for (TestResult testResult : testResultList) { if (ResultType.isDictionaryVariant(testResult.getTestResultType())) { String resultName = dictionaryDAO.getDictionaryById(testResult.getValue()).getLocalizedName(); dictionaryValues.add(new IdValuePair(testResult.getValue(), resultName)); } } nonNumericTests.dictionaryValues = dictionaryValues; } if (nonNumericTests.testType != null) { nonNumericTestList.add(nonNumericTests); } } } return nonNumericTestList; }
@Override public int compare(ReferralItem left, ReferralItem right) { int result = left.getAccessionNumber().compareTo(right.getAccessionNumber()); if (result != 0) { return result; } result = left.getSampleType().compareTo(right.getSampleType()); if (result != 0) { return result; } return left.getReferringTestName().compareTo(right.getReferringTestName()); }
private void fillInDictionaryValuesForReferralItems(List<ReferralItem> referralItems) { for (ReferralItem referralItem : referralItems) { String referredResultType = referralItem.getReferredResultType(); if (ResultType.isDictionaryVariant(referredResultType)) { referralItem.setDictionaryResults( getDictionaryValuesForTest(referralItem.getReferredTestId())); } if (referralItem.getAdditionalTests() != null) { for (ReferredTest test : referralItem.getAdditionalTests()) { if (ResultType.isDictionaryVariant(test.getReferredResultType())) { test.setDictionaryResults(getDictionaryValuesForTest(test.getReferredTestId())); } } } } }
private ReferralItem getReferralItem(Referral referral) { boolean allReferralResultsHaveResults = true; List<ReferralResult> referralResults = referralResultDAO.getReferralResultsForReferral(referral.getId()); for (ReferralResult referralResult : referralResults) { if (referralResult.getResult() == null || GenericValidator.isBlankOrNull(referralResult.getResult().getValue())) { allReferralResultsHaveResults = false; break; } } if (allReferralResultsHaveResults) { return null; } ReferralItem referralItem = new ReferralItem(); AnalysisService analysisService = new AnalysisService(referral.getAnalysis()); referralItem.setCanceled(false); referralItem.setReferredResultType("N"); referralItem.setAccessionNumber(analysisService.getOrderAccessionNumber()); TypeOfSample typeOfSample = analysisService.getTypeOfSample(); referralItem.setSampleType(typeOfSample.getLocalizedName()); referralItem.setReferringTestName( TestService.getUserLocalizedTestName(analysisService.getAnalysis().getTest())); List<Result> resultList = analysisService.getResults(); String resultString = ""; if (!resultList.isEmpty()) { Result result = resultList.get(0); resultString = getAppropriateResultValue(resultList); referralItem.setInLabResultId(result.getId()); } referralItem.setReferralId(referral.getId()); if (!referralResults.isEmpty()) { referralResults = setReferralItemForNextTest(referralItem, referralResults); if (!referralResults.isEmpty()) { referralItem.setAdditionalTests(getAdditionalReferralTests(referralResults)); } } referralItem.setReferralResults(resultString); referralItem.setReferralDate(DateUtil.convertTimestampToStringDate(referral.getRequestDate())); referralItem.setReferredSendDate(getSendDateOrDefault(referral)); referralItem.setReferrer(referral.getRequesterName()); referralItem.setReferralReasonId(referral.getReferralReasonId()); referralItem.setTestSelectionList(getTestsForTypeOfSample(typeOfSample)); referralItem.setReferralId(referral.getId()); if (referral.getOrganization() != null) { referralItem.setReferredInstituteId(referral.getOrganization().getId()); } String notes = analysisService.getNotesAsString(true, true, "<br/>", false); if (notes != null) { referralItem.setPastNotes(notes); } return referralItem; }