private boolean areDrugOrdersOfSameOrderableAndOverlappingSchedule(Order firstOrder, Order secondOrder) { return firstOrder.hasSameOrderableAs(secondOrder) && !OpenmrsUtil.nullSafeEquals(firstOrder.getPreviousOrder(), secondOrder) && OrderUtil.checkScheduleOverlap(firstOrder, secondOrder) && firstOrder.getOrderType().equals( Context.getOrderService().getOrderTypeByUuid(OrderType.DRUG_ORDER_TYPE_UUID)); }
/** * @see Order#hasSameOrderableAs(Order) */ @Test public void hasSameOrderableAs_shouldReturnFalseIfOtherOrderIsNull() throws Exception { Order order = new Order(); order.setConcept(new Concept()); assertFalse(order.hasSameOrderableAs(null)); }
/** * Checks whether orderable of this drug order is same as other order * * @since 1.10 * @param otherOrder the other order to match on * @return true if the drugs match * @should return false if the other order is null * @should return false if the other order is not a drug order * @should return false if both drugs are null and the concepts are different * @should return false if the concepts match and only this has a drug * @should return false if the concepts match and only the other has a drug * @should return false if the concepts match and drugs are different and not null * @should return true if both drugs are null and the concepts match * @should return true if the drugs match */ @Override public boolean hasSameOrderableAs(Order otherOrder) { if (!super.hasSameOrderableAs(otherOrder)) { return false; } if (!(otherOrder instanceof DrugOrder)) { return false; } DrugOrder otherDrugOrder = (DrugOrder) otherOrder; if (isNonCodedDrug() || otherDrugOrder.isNonCodedDrug()) { return OpenmrsUtil.nullSafeEqualsIgnoreCase(this.getDrugNonCoded(), otherDrugOrder.getDrugNonCoded()); } return OpenmrsUtil.nullSafeEquals(this.getDrug(), otherDrugOrder.getDrug()); }
/** * @see Order#hasSameOrderableAs(Order) */ @Test public void hasSameOrderableAs_shouldReturnTrueIfTheOrdersHaveTheSameConcept() throws Exception { Order order = new Order(); Concept concept = new Concept(); order.setConcept(concept); Order otherOrder = new Order(); otherOrder.setConcept(concept); assertTrue(order.hasSameOrderableAs(otherOrder)); }
/** * @see Order#hasSameOrderableAs(Order) */ @Test public void hasSameOrderableAs_shouldReturnFalseIfTheConceptOfTheOrdersDoNotMatch() throws Exception { Order order = new Order(); order.setConcept(new Concept()); Order otherOrder = new Order(); otherOrder.setConcept(new Concept()); assertFalse(order.hasSameOrderableAs(otherOrder)); }
if (!order.hasSameOrderableAs(previousOrder)) { throw new EditedOrderDoesNotMatchPreviousException("Order.orderable.doesnot.match"); } else if (!order.getOrderType().equals(previousOrder.getOrderType())) {
Order existing = order.hasSameOrderableAs(activeOrder) ? activeOrder : null; if (existing != null) { if (orderToBeDiscontinued == null) {