private void doSearch() { form.lyrHL7().tabQuery().grdMsgs().getRows().clear(); DateTime dtFrom = getDateTimeFrom(); DateTime dtTo = getDateTimeTo(); QryOrderMsgVoCollection messages = domain.listOrdersByDateTimeRange(form.getLocalContext().getPatId(), dtFrom, dtTo); //WDEV-14638 if (messages==null || messages.size()==0) { updateTotalLabel(); engine.showMessage("There are no Records for the Search Criteria Provided"); return; } if (messages != null) { for (int i = 0; i < messages.size(); i++) { addRowToGrid(messages.get(i)); } } updateTotalLabel(); }
public QryOrderMsgVoCollection listOrdersByDateTimeRange(PatientId patIdVo, DateTime dtFrom, DateTime dtTo) { Patient domPatient = null; if (patIdVo != null) { domPatient = findPatientById(patIdVo); if (null==domPatient) return null; } ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); StringBuffer sb = new StringBuffer("select om from OrderMessage om, OcsOrderSession ord, " + "OrderInvestigation oi where om.orderDetails.id = ord.id " + "and oi.orderDetails = ord.id "); if (domPatient != null) { sb.append(" and ord.patient = :domPatient"); markers.add("domPatient"); values.add(domPatient); } if (dtFrom != null && dtTo != null && dtFrom.isLessOrEqualThan(dtTo)) { sb.append(" and ( (ord.systemInformation.creationDateTime >= :fromDate and ord.systemInformation.creationDateTime <= :toDate)"); sb.append(" or (om.systemInformation.lastUpdateDateTime >= :fromDate and om.systemInformation.lastUpdateDateTime <= :toDate))"); markers.add("fromDate"); values.add(dtFrom.getJavaDate()); markers.add("toDate"); values.add(dtTo.addDays(1).getJavaDate()); } sb.append(" order by ord.systemInformation.creationDateTime desc"); List messages = getDomainFactory().find(sb.toString(), markers, values); return QryOrderMsgVoAssembler.createQryOrderMsgVoCollectionFromOrderMessage(messages); }