/** * Checks whether this order's orderType matches or is a sub type of the specified one * * @since 1.10 * @param orderType the orderType to match on * @return true if the type of the order matches or is a sub type of the other order * @should true if it is the same or is a subtype * @should false if it neither the same nor a subtype */ public boolean isType(OrderType orderType) { return OrderUtil.isType(orderType, this.orderType); }
/** * @see OrderUtil#isType(org.openmrs.OrderType, org.openmrs.OrderType) */ @Test public void isType_shouldReturnFalseIfTheyAreBothNull() { assertFalse(OrderUtil.isType(null, null)); }
/** * @see OrderUtil#isType(org.openmrs.OrderType, org.openmrs.OrderType) */ @Test public void isType_shouldTrueIfOrderType2IsTheSameOrIsASubtypeOfOrderType1() { OrderType orderType = new OrderType(); OrderType subType1 = new OrderType(); OrderType subType2 = new OrderType(); subType2.setParent(subType1); subType1.setParent(orderType); assertTrue(OrderUtil.isType(subType2, subType2)); assertTrue(OrderUtil.isType(subType1, subType2)); assertTrue(OrderUtil.isType(orderType, subType2)); }
/** * @see OrderUtil#isType(org.openmrs.OrderType, org.openmrs.OrderType) */ @Test public void isType_shouldFalseIfOrderType2IsNeitherTheSameNorASubtypeOfOrderType1() { assertFalse(OrderUtil.isType(new OrderType(), new OrderType())); }
if (orderType.getParent() != null && OrderUtil.isType(orderType, orderType.getParent())) { errors.rejectValue("parent", "OrderType.parent.amongDescendants", new Object[] { orderType.getName() }, "Parent of " + orderType.getName() + " is among its descendants");
/** * @see OrderService#saveOrder(org.openmrs.Order, OrderContext) */ @Test public void saveOrder_shouldFailIfTheOrderTypeOfThePreviousOrderDoesNotMatch() { Order order = orderService.getOrder(7); assertTrue(OrderUtilTest.isActiveOrder(order, null)); Order discontinuationOrder = order.cloneForDiscontinuing(); OrderType orderType = orderService.getOrderType(7); assertNotEquals(discontinuationOrder.getOrderType(), orderType); assertTrue(OrderUtil.isType(discontinuationOrder.getOrderType(), orderType)); discontinuationOrder.setOrderType(orderType); discontinuationOrder.setOrderer(Context.getProviderService().getProvider(1)); discontinuationOrder.setEncounter(Context.getEncounterService().getEncounter(6)); expectedException.expect(EditedOrderDoesNotMatchPreviousException.class); expectedException.expectMessage(mss.getMessage("Order.type.doesnot.match")); orderService.saveOrder(discontinuationOrder, null); }