org.openmrs.Order.isExpired()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.openmrs.Order.isExpired()方法的一些代码示例,展示了Order.isExpired()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Order.isExpired()方法的具体详情如下:
包路径:org.openmrs.Order
类名称:Order
方法名:isExpired

Order.isExpired介绍

[英]Convenience method to determine if the order is expired as of the specified date
[中]确定订单是否在指定日期过期的便捷方法

代码示例

代码示例来源:origin: openmrs/openmrs-core

/**
 * Convenience method to determine if the order is expired as of the specified date
 * 
 * @return boolean indicating whether the order is expired at the current time
 * @since 1.10.1
 */
public boolean isExpired() {
  return isExpired(new Date());
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * Convenience method to determine if the order is active as of the specified date
 * 
 * @param checkDate - the date on which to check order. if null, will use current date
 * @return boolean indicating whether the order was active on the check date
 * @since 1.10.1
 * @should return true if an order expired on the check date
 * @should return true if an order was discontinued on the check date
 * @should return true if an order was activated on the check date
 * @should return true if an order was activated on the check date but scheduled for the future
 * @should return false for a voided order
 * @should return false for a discontinued order
 * @should return false for an expired order
 * @should return false for an order activated after the check date
 * @should return false for a discontinuation order
 */
public boolean isActive(Date aCheckDate) {
  if (getVoided() || action == Action.DISCONTINUE) {
    return false;
  }
  Date checkDate = aCheckDate == null ? new Date() : aCheckDate;
  return isActivated(checkDate) && !isDiscontinued(checkDate) && !isExpired(checkDate);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Order#isExpired(java.util.Date)
 */
@Test
public void isExpired_shouldReturnFalseIfDateStoppedIsNullAndAutoExpireDateIsEqualToCheckDate() 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);
  order.setAutoExpireDate(checkDate);
  assertNull(order.getDateStopped());
  assertFalse(order.isExpired(checkDate));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @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)));
}

代码示例来源:origin: openmrs/openmrs-module-webservices.rest

@Override
public boolean evaluate(Object object) {
  Order order = (Order) object;
  return order.isDiscontinued(asOfDate) || order.isExpired(asOfDate);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Order#isExpired(java.util.Date)
 */
@Test
public void isExpired_shouldReturnFalseIfDateStoppedAndAutoExpireDateAreBothNull() throws Exception {
  Order order = new Order();
  order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT));
  assertNull(order.getDateStopped());
  assertNull(order.getAutoExpireDate());
  assertFalse(order.isExpired(DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Order#isExpired(java.util.Date)
 */
@Test
public void isExpired_shouldReturnFalseIfDateActivatedIsAfterCheckDate() throws Exception {
  Order order = new Order();
  order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT));
  order.setAutoExpireDate(DateUtils.parseDate("2014-11-01 11:11:13", DATE_FORMAT));
  assertNull(order.getDateStopped());
  assertFalse(order.isExpired(DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Order#isExpired(java.util.Date)
 */
@Test
public void isExpired_shouldReturnTrueIfDateStoppedIsNullAndAutoExpireDateIsBeforeCheckDate() throws Exception {
  Order order = new Order();
  order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT));
  order.setAutoExpireDate(DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT));
  assertNull(order.getDateStopped());
  assertTrue(order.isExpired(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT)));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Order#isExpired(java.util.Date)
 */
@Test
public void isExpired_shouldReturnFalseIfDateStoppedIsNullAndAutoExpireDateIsAfterCheckDate() throws Exception {
  Order order = new Order();
  order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT));
  order.setAutoExpireDate(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT));
  assertNull(order.getDateStopped());
  assertFalse(order.isExpired(DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @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)));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Order#isExpired(java.util.Date)
 */
@Test
public void isExpired_shouldReturnFalseForAVoidedOrder() throws Exception {
  Order order = new Order();
  order.setVoided(true);
  order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT));
  order.setAutoExpireDate(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT));
  assertNull(order.getDateStopped());
  assertFalse(order.isExpired(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT)));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see Order#isExpired(java.util.Date)
 */
@Test
public void isExpired_shouldFailIfDateStoppedIsAfterAutoExpireDate() throws Exception {
  Order order = new Order();
  order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT));
  order.setAutoExpireDate(DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT));
  OrderUtilTest.setDateStopped(order, DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT));
  expectedException.expect(APIException.class);
  expectedException.expectMessage(
    Context.getMessageSourceService().getMessage("Order.error.invalidDateStoppedAndAutoExpireDate"));
  order.isExpired(DateUtils.parseDate("2014-11-01 11:11:13", DATE_FORMAT));
}

相关文章