protected RejectionReportBean createIdentityRejectionBean( RejectionReportBean item, boolean blankCollectionDate) { RejectionReportBean filler = new RejectionReportBean(); filler.setAccessionNumber(item.getAccessionNumber()); filler.setReceivedDate(item.getReceivedDate()); filler.setCollectionDate(blankCollectionDate ? " " : item.getCollectionDate()); filler.setPatientOrTestName(item.getNonPrintingPatient()); return filler; }
protected void injectPatientLineAndCopyToFinalList(ArrayList<RejectionReportBean> rawResults) { Collections.sort( rawResults, new Comparator<RejectionReportBean>() { @Override public int compare(RejectionReportBean o1, RejectionReportBean o2) { int sortResult = o1.getAccessionNumber().compareTo(o2.getAccessionNumber()); return sortResult == 0 ? o1.getPatientOrTestName().compareTo(o2.getPatientOrTestName()) : sortResult; } }); String currentAccessionNumber = ""; for (RejectionReportBean item : rawResults) { if (!currentAccessionNumber.equals(item.getAccessionNumber())) { rejections.add(createIdentityRejectionBean(item, false)); currentAccessionNumber = item.getAccessionNumber(); } item.setCollectionDate(null); rejections.add(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; }