/** * 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 Order#isDiscontinued(Date) */ @Test public void isDiscontinued_shouldDiscontinueActivatedOrderAfterDateStopped() throws Exception { o.setDateActivated(ymd.parse("2007-01-01")); o.setAutoExpireDate(ymd.parse("2007-12-31")); OrderUtilTest.setDateStopped(o, ymd.parse("2007-11-01")); assertTrue("should be discontinued after dateStopped", o.isDiscontinued(ymd.parse("2007-11-26"))); }
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 OrderUtil#isType(org.openmrs.OrderType, org.openmrs.OrderType) */ @Test public void isType_shouldReturnFalseIfTheyAreBothNull() { assertFalse(OrderUtil.isType(null, null)); }
/** * @see Order#isDiscontinued(Date) */ @Test public void isDiscontinued_shouldNotDiscontinueActivatedOrderBeforeDateStopped() throws Exception { o.setDateActivated(ymd.parse("2007-01-01")); o.setAutoExpireDate(ymd.parse("2007-12-31")); OrderUtilTest.setDateStopped(o, ymd.parse("2007-11-01")); assertFalse("shouldn't be discontinued before dateStopped", o.isDiscontinued(ymd.parse("2007-10-26"))); }
/** * @see Order#isActive() */ @Test public void isActive_shouldBeCurrentBetweenDateActivatedAndDateStopped() throws Exception { o.setDateActivated(ymd.parse("2007-01-01")); o.setAutoExpireDate(ymd.parse("2007-12-31")); OrderUtilTest.setDateStopped(o, ymd.parse("2007-11-01")); assertFalse("shouldn't be current before dateActivated", o.isActive(ymd.parse("2006-10-26"))); assertTrue("should be current between dateActivated and dateStopped", o.isActive(ymd.parse("2007-10-26"))); assertFalse("shouldn't be current after dateStopped", o.isActive(ymd.parse("2007-11-26"))); }
/** * @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 Order#isActive(java.util.Date) */ @Test public void isActive_shouldReturnTrueIfAnOrderWasDiscontinuedOnTheCheckDate() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); Date dateStopped = DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT); OrderUtilTest.setDateStopped(order, dateStopped); assertTrue(order.isActive(dateStopped)); }
/** * @see OrderUtil#isType(org.openmrs.OrderType, org.openmrs.OrderType) */ @Test public void isType_shouldFalseIfOrderType2IsNeitherTheSameNorASubtypeOfOrderType1() { assertFalse(OrderUtil.isType(new OrderType(), new OrderType())); }
/** * @see Order#isActive(java.util.Date) */ @Test public void isActive_shouldReturnFalseForADiscontinuedOrder() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); OrderUtilTest.setDateStopped(order, DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)); assertFalse(order.isActive(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT))); }
/** * @see Order#isDiscontinued(java.util.Date) */ @Test public void isDiscontinued_shouldReturnFalseIfDateActivatedIsAfterCheckDate() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT)); OrderUtilTest.setDateStopped(order, DateUtils.parseDate("2014-11-01 11:11:13", DATE_FORMAT)); assertFalse(order.isDiscontinued(DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT))); }
/** * @see Order#isDiscontinued(java.util.Date) */ @Test public void isDiscontinued_shouldReturnFalseIfAutoExpireDateIsNullAndDateStoppedIsEqualToCheckDate() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); Date checkDate = DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT); OrderUtilTest.setDateStopped(order, checkDate); assertNull(order.getAutoExpireDate()); assertFalse(order.isDiscontinued(checkDate)); }
/** * @see Order#isExpired(java.util.Date) */ @Test public void isExpired_shouldReturnFalseIfCheckDateIsAfterDateStoppedButBeforeAutoExpireDate() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); OrderUtilTest.setDateStopped(order, DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)); order.setAutoExpireDate(DateUtils.parseDate("2014-11-01 11:11:13", DATE_FORMAT)); assertFalse(order.isExpired(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT))); }
/** * @see Order#isDiscontinued(java.util.Date) */ @Test public void isDiscontinued_shouldReturnTrueIfCheckDateIsAfterDateStoppedButBeforeAutoExpireDate() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); OrderUtilTest.setDateStopped(order, DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)); order.setAutoExpireDate(DateUtils.parseDate("2014-11-01 11:11:13", DATE_FORMAT)); assertTrue(order.isDiscontinued(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT))); }
/** * @see Order#isExpired(java.util.Date) */ @Test public void isExpired_shouldReturnFalseIfCheckDateIsAfterBothDateStoppedAutoExpireDate() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); OrderUtilTest.setDateStopped(order, DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)); order.setAutoExpireDate(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT)); assertFalse(order.isExpired(DateUtils.parseDate("2014-11-01 11:11:13", DATE_FORMAT))); }
/** * @see Order#isDiscontinued(java.util.Date) */ @Test public void isDiscontinued_shouldReturnTrueIfCheckDateIsAfterBothDateStoppedAutoExpireDate() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); OrderUtilTest.setDateStopped(order, DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)); order.setAutoExpireDate(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT)); assertTrue(order.isDiscontinued(DateUtils.parseDate("2014-11-01 11:11:13", DATE_FORMAT))); }
/** * @see Order#isDiscontinued(java.util.Date) */ @Test public void isDiscontinued_shouldReturnFalseIfAutoExpireDateIsNullAndDateStoppedIsAfterCheckDate() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); OrderUtilTest.setDateStopped(order, DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT)); assertNull(order.getAutoExpireDate()); assertFalse(order.isDiscontinued(DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT))); }
/** * @see Order#isDiscontinued(java.util.Date) */ @Test public void isDiscontinued_shouldReturnTrueIfAutoExpireDateIsNullAndDateStoppedIsBeforeCheckDate() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); OrderUtilTest.setDateStopped(order, DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)); assertNull(order.getAutoExpireDate()); assertTrue(order.isDiscontinued(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT))); }
/** * @see Order#isDiscontinued(java.util.Date) */ @Test public void isDiscontinued_shouldReturnFalseForAVoidedOrder() throws Exception { Order order = new Order(); order.setVoided(true); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); OrderUtilTest.setDateStopped(order, DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)); assertNull(order.getAutoExpireDate()); assertFalse(order.isDiscontinued(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT))); }