本文整理了Java中org.openmrs.Order.isActive()
方法的一些代码示例,展示了Order.isActive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Order.isActive()
方法的具体详情如下:
包路径:org.openmrs.Order
类名称:Order
方法名:isActive
[英]Convenience method to determine if the order was active as of the current date
[中]确定订单在当前日期是否有效的便捷方法
代码示例来源:origin: openmrs/openmrs-core
/**
* Convenience method to determine if the order was active as of the current date
*
* @since 1.10.1
* @return boolean indicating whether the order was active on the check date
*/
public boolean isActive() {
return isActive(new Date());
}
代码示例来源:origin: openmrs/openmrs-core
public static boolean isActiveOrder(Order order, Date asOfDate) {
return order.isActive(asOfDate) && order.getAction() != Order.Action.DISCONTINUE;
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActive()
*/
@Test
public void isActive_shouldBeCurrentAfterDateActivated() throws Exception {
//assertTrue("dateActivated==null && no end date should always be current", o.isActive(ymd.parse("2007-10-26")));
o.setDateActivated(ymd.parse("2007-01-01"));
assertFalse("shouldn't be current before dateActivated", o.isActive(ymd.parse("2006-10-26")));
assertTrue("should be current after dateActivated", o.isActive(ymd.parse("2007-10-26")));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActive()
*/
@Test
public void isActive_shouldBeCurrentBetweenDateActivatedAndAutoExpireDate() throws Exception {
o.setDateActivated(ymd.parse("2007-01-01"));
o.setAutoExpireDate(ymd.parse("2007-12-31"));
assertFalse("shouldn't be current before dateActivated", o.isActive(ymd.parse("2006-10-26")));
assertTrue("should be current between dateActivated and autoExpireDate", o.isActive(ymd.parse("2007-10-26")));
assertFalse("shouldn't be current after autoExpireDate", o.isActive(ymd.parse("2008-10-26")));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @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")));
}
代码示例来源:origin: openmrs/openmrs-core
private void requireNoActiveOrderOfSameType(Patient patient1, Patient patient2) {
String messageKey = "Patient.merge.cannotHaveSameTypeActiveOrders";
List<Order> ordersByPatient1 = Context.getOrderService().getAllOrdersByPatient(patient1);
List<Order> ordersByPatient2 = Context.getOrderService().getAllOrdersByPatient(patient2);
ordersByPatient1.forEach((Order order1) -> ordersByPatient2.forEach((Order order2) -> {
if (order1.isActive() && order2.isActive() && order1.getOrderType().equals(order2.getOrderType())) {
Object[] parameters = { patient1.getPatientId(), patient2.getPatientId(), order1.getOrderType() };
String message = Context.getMessageSourceService().getMessage(messageKey, parameters,
Context.getLocale());
log.debug(message);
throw new APIException(message);
}
}));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.OrderService#unvoidOrder(org.openmrs.Order)
*/
@Override
public Order unvoidOrder(Order order) throws APIException {
Order previousOrder = order.getPreviousOrder();
if (previousOrder != null && isDiscontinueOrReviseOrder(order)) {
if (!previousOrder.isActive()) {
final String action = DISCONTINUE == order.getAction() ? "discontinuation" : "revision";
throw new CannotUnvoidOrderException(action);
}
stopOrder(previousOrder, aMomentBefore(order.getDateActivated()), false);
}
return saveOrderInternal(order, null);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @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));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @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)));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActive(java.util.Date)
*/
@Test
public void isActive_shouldReturnFalseForAnExpiredOrder() 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));
assertFalse(order.isActive(DateUtils.parseDate("2014-11-01 11:11:12", DATE_FORMAT)));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActive(java.util.Date)
*/
@Test
public void isActive_shouldReturnTrueIfAnOrderExpiredOnTheCheckDate() 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());
assertTrue(order.isActive(checkDate));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActive(java.util.Date)
*/
@Test
public void isActive_shouldReturnTrueIfAnOrderWasActivatedOnTheCheckDate() throws Exception {
Order order = new Order();
Date activationDate = DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT);
order.setDateActivated(activationDate);
assertNull(order.getDateStopped());
assertNull(order.getAutoExpireDate());
assertTrue(order.isActive(activationDate));
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void saveRetrospectiveOrder_shouldDiscontinueOrderInRetrospectiveEntry() throws ParseException {
executeDataSet("org/openmrs/api/include/OrderServiceTest-ordersWithAutoExpireDate.xml");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
Date originalOrderDateActivated = dateFormat.parse("2008-11-19 09:24:10.0");
Date discontinuationOrderDate = DateUtils.addDays(originalOrderDateActivated, 2);
Order originalOrder = orderService.getOrder(201);
assertNull(originalOrder.getDateStopped());
assertEquals(dateFormat.parse("2008-11-23 09:24:09.0"), originalOrder.getAutoExpireDate());
assertFalse(originalOrder.isActive());
assertTrue(originalOrder.isActive(discontinuationOrderDate));
Order discontinueationOrder = originalOrder.cloneForDiscontinuing();
discontinueationOrder.setPreviousOrder(originalOrder);
discontinueationOrder.setEncounter(encounterService.getEncounter(17));
discontinueationOrder.setOrderer(providerService.getProvider(1));
discontinueationOrder.setDateActivated(discontinuationOrderDate);
orderService.saveRetrospectiveOrder(discontinueationOrder, null);
assertNotNull(originalOrder.getDateStopped());
assertEquals(discontinueationOrder.getAutoExpireDate(), discontinueationOrder.getDateActivated());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActive(Date)
*/
@Test
public void isActive_shouldReturnTrueIfAnOrderWasActivatedOnTheCheckDateButScheduledForTheFuture() throws Exception {
Order order = new Order();
order.setUrgency(Urgency.ON_SCHEDULED_DATE);
Date scheduledDateInFuture = DateUtils.addMonths(new Date(), 2);
order.setScheduledDate(scheduledDateInFuture);
Date activationDate = DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT);
order.setDateActivated(activationDate);
assertNull(order.getDateStopped());
assertNull(order.getAutoExpireDate());
assertTrue(order.isActive(activationDate));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActive(java.util.Date)
*/
@Test
public void isActive_shouldReturnFalseForAnOrderActivatedAfterTheCheckDate() 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.isActive(DateUtils.parseDate("2014-11-01 11:11:09", DATE_FORMAT)));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActive(java.util.Date)
*/
@Test
public void isActive_shouldReturnFalseForADiscontinuationOrder() throws Exception {
Order order = new Order();
Date activationDate = DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT);
order.setDateActivated(activationDate);
order.setAction(Order.Action.DISCONTINUE);
assertNull(order.getDateStopped());
assertNull(order.getAutoExpireDate());
assertFalse(order.isActive(activationDate));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#discontinueOrder(org.openmrs.Order, String, java.util.Date,
* org.openmrs.Provider, org.openmrs.Encounter)
*/
@Test
public void discontinueOrder_shouldFailForADiscontinuedOrder() {
Order discontinuationOrder = orderService.getOrder(2);
assertFalse(discontinuationOrder.isActive());
assertNotNull(discontinuationOrder.getDateStopped());
Encounter encounter = encounterService.getEncounter(3);
expectedException.expect(CannotStopInactiveOrderException.class);
expectedException.expectMessage(mss.getMessage("Order.cannot.discontinue.inactive"));
orderService.discontinueOrder(discontinuationOrder, "some reason", null, null, encounter);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#discontinueOrder(org.openmrs.Order, org.openmrs.Concept, java.util.Date,
* org.openmrs.Provider, org.openmrs.Encounter)
*/
@Test
public void discontinueOrder_shouldNotPassForADiscontinuedOrder() {
Order discontinuationOrder = orderService.getOrder(2);
assertFalse(discontinuationOrder.isActive());
assertNotNull(discontinuationOrder.getDateStopped());
Encounter encounter = encounterService.getEncounter(3);
expectedException.expect(CannotStopInactiveOrderException.class);
expectedException.expectMessage(mss.getMessage("Order.cannot.discontinue.inactive"));
orderService.discontinueOrder(discontinuationOrder, (Concept) null, null, null, encounter);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActive(java.util.Date)
*/
@Test
public void isActive_shouldReturnFalseForAVoidedOrder() throws Exception {
Order order = new Order();
order.setVoided(true);
order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT));
assertNull(order.getDateStopped());
assertNull(order.getAutoExpireDate());
assertFalse(order.isActive(DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldNotAllowRevisingAnOrderWithNoPreviousOrder() {
Order originalOrder = orderService.getOrder(111);
assertTrue(originalOrder.isActive());
Order revisedOrder = originalOrder.cloneForRevision();
revisedOrder.setEncounter(encounterService.getEncounter(5));
revisedOrder.setInstructions("Take after a meal");
revisedOrder.setPreviousOrder(null);
revisedOrder.setOrderer(providerService.getProvider(1));
revisedOrder.setDateActivated(new Date());
expectedException.expect(MissingRequiredPropertyException.class);
expectedException.expectMessage(mss.getMessage("Order.previous.required"));
orderService.saveOrder(revisedOrder, null);
}
内容来源于网络,如有侵权,请联系作者删除!