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

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

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

Order.isDiscontinued介绍

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

代码示例

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

public boolean isDiscontinuedRightNow() {
  return isDiscontinued(new Date());
}

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

return false;
if (isDiscontinued(checkDate) || autoExpireDate == null) {
  return false;

代码示例来源: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#isDiscontinued(Date)
 */
@Test
public void isDiscontinued_shouldNotDiscontinueGivenOrderWithoutDates() throws Exception {
  assertFalse("order without dates shouldn't be discontinued", o.isDiscontinued(ymd.parse("2007-10-26")));
}

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

/**
 * @see Order#isDiscontinued(Date)
 */
@Test
public void isDiscontinued_shouldNotDiscontinueBeforeActivationDate() throws Exception {
  o.setDateActivated(ymd.parse("2007-01-01"));
  assertFalse("shouldn't be discontinued before date activated", o.isDiscontinued(ymd.parse("2006-10-26")));
}

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

/**
 * @see Order#isDiscontinued(Date)
 */
@Test
public void isDiscontinued_shouldNotDiscontinueGivenActivatedOrderWithoutEndDate() throws Exception {
  o.setDateActivated(ymd.parse("2007-01-01"));
  assertFalse("order without no end dates shouldn't be discontinued", o.isDiscontinued(ymd.parse("2007-10-26")));
}

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

/**
 * @see Order#isDiscontinued(Date)
 */
@Test
public void isDiscontinued_shouldNotDiscontinueActivatedOrderBeforeAutoExpireDate() throws Exception {
  o.setDateActivated(ymd.parse("2007-01-01"));
  o.setAutoExpireDate(ymd.parse("2007-12-31"));
  assertFalse("shouldn't be discontinued before autoExpireDate", o.isDiscontinued(ymd.parse("2007-10-26")));
}

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

/**
 * @see Order#isDiscontinued(Date)
 */
@Test
public void isDiscontinued_shouldNotDiscontinueActivatedOrderAfterAutoExpireDate() throws Exception {
  o.setDateActivated(ymd.parse("2007-01-01"));
  o.setAutoExpireDate(ymd.parse("2007-12-31"));
  assertFalse("shouldn't be discontinued after autoExpireDate", o.isDiscontinued(ymd.parse("2008-10-26")));
}

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
 * @see Order#isDiscontinued(java.util.Date)
 */
@Test
public void isDiscontinued_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.isDiscontinued(DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)));
}

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

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

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

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

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

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

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

/**
 * @see Order#isDiscontinued(Date)
 */
@Test
public void isDiscontinued_shouldReturnTrueIfTheOrderIsScheduledForTheFutureAndActivatedOnCheckDateButTheCheckDateIsAfterDateStopped()
    throws Exception {
  // tests the case when a scheduled order is revised:
  // in that case its original order is stopped.
  // the stopped date of the original order is set to a moment before the activated date of the revised order.
  // the order here represents such an original order
  Order order = new Order();
  order.setUrgency(Urgency.ON_SCHEDULED_DATE);
  Date today = new Date();
  Date scheduledDateInFuture = DateUtils.addMonths(today, 2);
  order.setScheduledDate(scheduledDateInFuture);
  Date activationDate = DateUtils.addDays(today, -2);
  order.setDateActivated(activationDate);
  Date stopDate = new Date();
  OrderUtilTest.setDateStopped(order, stopDate);
  assertNotNull(order.getDateActivated());
  assertNotNull(order.getDateStopped());
  assertNull(order.getAutoExpireDate());
  assertTrue(order.isDiscontinued(DateUtils.addSeconds(stopDate, 1)));
}

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

/**
 * @see Order#isDiscontinued(java.util.Date)
 */
@Test
public void isDiscontinued_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.isDiscontinued(DateUtils.parseDate("2014-11-01 11:11:13", DATE_FORMAT));
}

相关文章