private String buildReOrderMessage(ReOrderPeriodMessageVoCollection voCollMessages) { if(voCollMessages == null) return null; StringBuilder message = new StringBuilder(); for(ReOrderPeriodMessageVo item : voCollMessages) { message.append("The minimum re-order period for '").append(item.getItemName()).append("' is '").append(item.getAmount()); message.append(" ").append(item.getUnit().getText()).append("'").append("\rThis item was last ordered for this patient on "); message.append(item.getRequiredByDate() != null ? item.getRequiredByDate().getDate().toString() : item.getOrderedDateTime().getDate().toString()); message.append(" at ").append(item.getRequiredByDate() != null ? item.getRequiredByDate().getTime().toString() : item.getOrderedDateTime().getTime().toString()); message.append(".").append("\rDo you still wish to order this item?"); if(voCollMessages.size() > 1) message.append("\r\r"); } return message.toString(); }
private InvestigationRefVoCollection removeFromRefusedInvestigation() { ReOrderPeriodMessageVoCollection voCollMessages = form.getGlobalContext().OCRR.getYesNoDialogWithReasonMessage(); if(voCollMessages == null || voCollMessages.size() == 0) return null; InvestigationRefVoCollection invColl = form.getGlobalContext().OCRR.getRefusedInvestigation(); if(invColl == null) return null; for(ReOrderPeriodMessageVo item : voCollMessages) { if(item == null || item.getInvestigationId() == null) continue; removeComponentFromRefusedInvestigations(item.getInvestigationId()); } return invColl; }
private void removeReOrderMessages() { ReOrderPeriodMessageVoCollection messages = form.getGlobalContext().OCRR.getYesNoDialogWithReasonMessage(); if(messages == null || messages.size() == 0) return; for(int i = messages.size() - 1; i >= 0; i--) { if(messages.get(i) == null || messages.get(i).getInvestigationId() == null) continue; if(itemIdIsInRefusedList(messages.get(i))) { messages.remove(messages.get(i)); } } }
private ReOrderPeriodMessageVoCollection buildReOrderMessage(ReOrderPeriodMessageVoCollection voCollMessages) { if(voCollMessages == null || voCollMessages.get(0) == null) throw new CodingRuntimeException("No Re-Order Message to Display - Coding Error"); //sort the collection on date to get the last occurence it was ordered voCollMessages.sort(SortOrder.DESCENDING); voCollMessages = getDistinctListOfMessages(voCollMessages); return voCollMessages; }
private ReOrderPeriodMessageVoCollection getDistinctListOfMessages(ReOrderPeriodMessageVoCollection voCollMessages) { ReOrderPeriodMessageVoCollection collMessages = new ReOrderPeriodMessageVoCollection(); HashMap<String, ReOrderPeriodMessageVo> map = new HashMap<String, ReOrderPeriodMessageVo>(); for(int i=0;i<voCollMessages.size();i++) { if(!map.containsKey(voCollMessages.get(i).getItemName())) map.put(voCollMessages.get(i).getItemName(), voCollMessages.get(i)); } for (ReOrderPeriodMessageVo element : map.values()) { collMessages.add(element); //WDEV-16624 if(form.getLocalContext().getBreachedInvestigations() == null) form.getLocalContext().setBreachedInvestigations(new BreachedInvestigationsVoCollection());//WDEV-16762 //WDEV-16762 BreachedInvestigationsVo breached = new BreachedInvestigationsVo(); breached.setInvestigationId(element.getInvestigationId()); breached.setParentId(element.getParentId()); form.getLocalContext().getBreachedInvestigations().add(breached);//WDEV-16624, WDEV-16762 } return collMessages; }
public ReOrderPeriodMessageVoCollection listOrderSetInvestigationsWithinMinReOrderPeriod(OrderSetRefVo orderSet, PatientShort patient, BreachedInvestigationsVoCollection breachedInvestigations) // WDEV-16762 { if(orderSet == null || patient == null) throw new CodingRuntimeException("orderSet or patient is null in method listOrderSetInvestigationsWithinMinReOrderPeriod"); boolean isFemale = patient.getSexIsNotNull() && patient.getSex().equals(Sex.FEMALE); DomainFactory factory = getDomainFactory(); OrderSet doOrderSet = (OrderSet) factory.getDomainObject(orderSet); if(doOrderSet == null || doOrderSet.getComponent() == null) return null; Iterator it = doOrderSet.getComponent().iterator(); ReOrderPeriodMessageVoCollection voCollMessages = new ReOrderPeriodMessageVoCollection(); while(it.hasNext()) { Object comp = it.next(); if(!(comp instanceof OrderSetComponent)) continue; Investigation doInv = ((OrderSetComponent) comp).getInvestigation(); ReOrderPeriodMessageVoCollection profOrderInvMessages = listMessages(doInv, patient, isFemale, breachedInvestigations, null);//WDEV-16762 if(profOrderInvMessages != null) { for(ReOrderPeriodMessageVo item : profOrderInvMessages) voCollMessages.add(item); } } return voCollMessages; }
private ReOrderPeriodMessageVoCollection listMessages(Investigation doInv, PatientShort patient, boolean isFemale, BreachedInvestigationsVoCollection breachedInvestigations, Integer parentId) //WDEV-16762 { if(doInv == null) return null; if(Boolean.TRUE.equals(doInv.getInvestigationIndex().isIsProfile())) { if(doInv.getAssocInvestigations() != null) { Iterator it = doInv.getAssocInvestigations().iterator(); ReOrderPeriodMessageVoCollection messages = new ReOrderPeriodMessageVoCollection();//WDEV-16624 while(it.hasNext()) { Object comp = it.next(); if(!(comp instanceof Investigation)) continue; addMessagesCollection(messages, listMessages((Investigation)comp, patient, isFemale, breachedInvestigations, doInv.getId()));//WDEV-16624, WDEV-16762 } return messages;//WDEV-16624 } } else { if(isInvestigationInBreachedList(doInv, breachedInvestigations)) return null; } LookupInstance femaleUnit = doInv.getFemaleMinReorderPeriodUnit(); LookupInstance maleUnit = doInv.getMinReorderPeriodUnit(); MinReorderPeriod unit = null; if(isFemale && femaleUnit != null) unit = LookupHelper.getMinReorderPeriodInstance(getLookupService(), doInv.getFemaleMinReorderPeriodUnit().getId()); else if(!isFemale && maleUnit != null) unit = LookupHelper.getMinReorderPeriodInstance(getLookupService(), doInv.getMinReorderPeriodUnit().getId()); Integer dataValue = isFemale ? doInv.getFemaleMinReorderPeriodVal() : doInv.getMinReorderPeriodVal(); if(dataValue == null && unit == null) return null; DateTime[] dateTimes = calculateDateTimeRange(dataValue, unit); return listInvOrderedWithinMinReOrderPeriod(doInv.getId(),dateTimes[0] , dateTimes[1], patient, dataValue, unit, assembleCategory(doInv.getInvestigationIndex().getCategory()), parentId);//WDEV-16580, WDEV-16762 }