private boolean search(boolean fromTimer, boolean showMessages, boolean checkForWarning) { resetResults(); NewResultsCriteriaVo criteria = getCriteria(fromTimer); if(criteria == null) return false; if (checkWarning(criteria) && checkForWarning) { engine.showMessage("You are about to perform a search with limited filters in place, this could result in a large number of resulted investigations being returned. Do you wish to proceed?", "Warning", MessageButtons.YESNO); return false; } NewResultsSearchListVoCollection newResults = domain.listNewResults(criteria); if (newResults == null || newResults.size() == 0) { if(showMessages) { engine.showMessage("No results found.", "Message"); } if (!criteria.getSelectedTab().equals(PATIENT)) form.getGlobalContext().OCRR.setNewResultsCriteria(criteria); return true; } Integer nNewResUnseenDays = new Integer(ConfigFlag.DOM.OCS_NEWRES_UNSEEN_CUTOFF.getValue()); Date dateUnseen = new Date().addDay(-1 * nNewResUnseenDays.intValue()); for (NewResultsSearchListVo newResult : newResults) addNewResult(newResult, dateUnseen); if (!criteria.getSelectedTab().equals(PATIENT)) form.getGlobalContext().OCRR.setNewResultsCriteria(criteria); updateSearchTotal(form.grdResults().getAllRows().length); return true; }
public NewResultsSearchListVoCollection listNewResults(NewResultsCriteriaVo criteria) { if (criteria == null || criteria.getFromDate() == null) throw new CodingRuntimeException("Invalid start date"); // Search for OrderInvestigation ID matching the search criteria by intervals List<Integer> investigations = getInvestigationsByCriteria(criteria); // If no OrderInvestigation ID was found in the interval, then return null if (investigations == null || investigations.size() == 0) return null; // StringBuilder query = new StringBuilder(getBaseSelectQuery(investigations)); StringBuilder query = new StringBuilder("SELECT oi "); query.append(" FROM OrderInvestigation AS oi WHERE oi.id IN ("); for (int i = 0; i < investigations.size(); i++) { query.append(investigations.get(i)); if (i != investigations.size() - 1) query.append(", "); } query.append(")"); query.append(" ORDER BY oi.resultSortDate"); if (Boolean.TRUE.equals(criteria.getNewestFirst())) query.append(" DESC"); query.append(", oi.ordInvSeq"); long startTime = System.currentTimeMillis(); // List<?> searchResults = getDomainFactory().find(query.toString()); // // if (searchResults == null || searchResults.size() == 0) // return null; // NewResultsSearchListVoCollection results = NewResultsSearchListVoAssembler.createNewResultsSearchListVoCollectionFromOrderInvestigation(getDomainFactory().find(query.toString())); // NewResultsSearchListVoCollection results = new NewResultsSearchListVoCollection(); // // for (int i = 0; i < searchResults.size(); i++) // { // Object[] result = (Object[]) searchResults.get(i); // // if (result[0] instanceof OrderInvestigation) // { // NewResultsSearchListVo newResult = NewResultsSearchListVoAssembler.create((OrderInvestigation) result[0]); // // if (result[1] instanceof Long && (Long)result[1] > 0) // newResult.setAbnormalResults(Boolean.TRUE); // else // newResult.setAbnormalResults(Boolean.FALSE); // // results.add(newResult); // } // } long endTime = System.currentTimeMillis(); System.out.println("Time elapsed to retrive record data (ms): " + (endTime - startTime)); // List<?> resultsCustomConstructor = getDomainFactory().find(query.toString()); // // NewResultSearchListVoCollection resultsCollection = new NewResultSearchListVoCollection(); // // for (int i = 0; i < results.size(); i++) // { // if (resultsCustomConstructor.get(i) instanceof NewResultSearchListVo) // resultsCollection.add((NewResultSearchListVo) resultsCustomConstructor.get(i)); // } return results; }