本文整理了Java中org.openmrs.Order.getAction()
方法的一些代码示例,展示了Order.getAction()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Order.getAction()
方法的具体详情如下:
包路径:org.openmrs.Order
类名称:Order
方法名:getAction
[英]Gets the action
[中]得到行动
代码示例来源:origin: openmrs/openmrs-core
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
String prefix = Action.DISCONTINUE == getAction() ? "DC " : "";
return prefix + "Order. orderId: " + orderId + " patient: " + patient + " concept: " + concept + " care setting: "
+ careSetting;
}
代码示例来源:origin: openmrs/openmrs-core
private boolean isDiscontinueOrReviseOrder(Order order) {
return DISCONTINUE == order.getAction() || REVISE == order.getAction();
}
代码示例来源: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
throw new IllegalArgumentException("Discontinue date cannot be in the future");
if (DISCONTINUE == orderToStop.getAction()) {
throw new CannotStopDiscontinuationOrderException();
代码示例来源: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 OrderService#discontinueOrder(org.openmrs.Order, String, java.util.Date,
* org.openmrs.Provider, org.openmrs.Encounter)
*/
@Test
public void discontinueOrder_shouldFailForADiscontinuationOrder() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-discontinuedOrder.xml");
Order discontinuationOrder = orderService.getOrder(26);
assertEquals(Action.DISCONTINUE, discontinuationOrder.getAction());
Encounter encounter = encounterService.getEncounter(3);
expectedException.expect(CannotStopDiscontinuationOrderException.class);
expectedException.expectMessage(mss.getMessage("Order.action.cannot.discontinue"));
orderService.discontinueOrder(discontinuationOrder, "Test if I can discontinue this", 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_shouldNotPassForADiscontinuationOrder() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-discontinuedOrder.xml");
executeDataSet("org/openmrs/api/include/OrderServiceTest-discontinueReason.xml");
Order discontinuationOrder = orderService.getOrder(26);
assertEquals(Action.DISCONTINUE, discontinuationOrder.getAction());
Encounter encounter = encounterService.getEncounter(3);
expectedException.expect(CannotStopDiscontinuationOrderException.class);
expectedException.expectMessage(mss.getMessage("Order.action.cannot.discontinue"));
orderService.discontinueOrder(discontinuationOrder, (Concept) null, null, null, encounter);
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void shouldAllowEditingADiscontinuationOrder() {
Order originalDCOrder = orderService.getOrder(22);
assertEquals(Order.Action.DISCONTINUE, originalDCOrder.getAction());
List<Order> originalPatientOrders = orderService.getAllOrdersByPatient(originalDCOrder.getPatient());
final Order previousOrder = originalDCOrder.getPreviousOrder();
assertNotNull(previousOrder);
final Date newStartDate = originalDCOrder.getEncounter().getEncounterDatetime();
Order newDcOrder = originalDCOrder.cloneForRevision();
newDcOrder.setEncounter(originalDCOrder.getEncounter());
newDcOrder.setOrderer(originalDCOrder.getOrderer());
newDcOrder.setDateActivated(newStartDate);
orderService.voidOrder(originalDCOrder, "To be replace with a new one");
assertNull(originalDCOrder.getDateStopped());
orderService.saveOrder(newDcOrder, null);
//We need to flush so that we ensure the interceptor is okay with all this
Context.flushSession();
assertTrue(originalDCOrder.getVoided());
List<Order> newPatientOrders = orderService.getAllOrdersByPatient(originalDCOrder.getPatient());
assertEquals(originalPatientOrders.size() + 1, newPatientOrders.size());
Collection<Order> newOrders = CollectionUtils.disjunction(originalPatientOrders, newPatientOrders);
assertEquals(1, newOrders.size());
assertEquals(newOrders.iterator().next().getPreviousOrder(), previousOrder);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#voidOrder(org.openmrs.Order, String)
*/
@Test
public void voidOrder_shouldUnsetDateStoppedOfThePreviousOrderIfTheSpecifiedOrderIsADiscontinuation() {
Order order = orderService.getOrder(22);
assertEquals(Action.DISCONTINUE, order.getAction());
Order previousOrder = order.getPreviousOrder();
assertNotNull(previousOrder.getDateStopped());
assertFalse(order.getVoided());
orderService.voidOrder(order, "None");
//Ensures order interceptor is okay with all the changes
Context.flushSession();
assertTrue(order.getVoided());
assertNull(previousOrder.getDateStopped());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#voidOrder(org.openmrs.Order, String)
*/
@Test
public void voidOrder_shouldUnsetDateStoppedOfThePreviousOrderIfTheSpecifiedOrderIsARevision() {
Order order = orderService.getOrder(111);
assertEquals(Action.REVISE, order.getAction());
Order previousOrder = order.getPreviousOrder();
assertNotNull(previousOrder.getDateStopped());
assertFalse(order.getVoided());
orderService.voidOrder(order, "None");
Context.flushSession();
assertTrue(order.getVoided());
assertNull(previousOrder.getDateStopped());
}
代码示例来源: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_shouldSetCorrectAttributesOnTheDiscontinueAndDiscontinuedOrders() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-discontinueReason.xml");
Order order = orderService.getOrderByOrderNumber("111");
Encounter encounter = encounterService.getEncounter(3);
Provider orderer = providerService.getProvider(1);
Date discontinueDate = new Date();
Concept concept = Context.getConceptService().getConcept(1);
Order discontinueOrder = orderService.discontinueOrder(order, concept, discontinueDate, orderer, encounter);
Assert.assertEquals(order.getDateStopped(), discontinueDate);
Assert.assertNotNull(discontinueOrder);
Assert.assertNotNull(discontinueOrder.getId());
Assert.assertEquals(discontinueOrder.getDateActivated(), discontinueOrder.getAutoExpireDate());
Assert.assertEquals(discontinueOrder.getAction(), Action.DISCONTINUE);
Assert.assertEquals(discontinueOrder.getOrderReason(), concept);
Assert.assertEquals(discontinueOrder.getPreviousOrder(), order);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @throws InterruptedException
* @see OrderService#unvoidOrder(org.openmrs.Order)
*/
@Test
public void unvoidOrder_shouldFailForADiscontinuationOrderIfThePreviousOrderIsInactive() throws InterruptedException {
Order order = orderService.getOrder(22);
assertEquals(Action.DISCONTINUE, order.getAction());
Order previousOrder = order.getPreviousOrder();
assertNotNull(previousOrder.getDateStopped());
assertFalse(order.getVoided());
//void the DC order for testing purposes so we can unvoid it later
orderService.voidOrder(order, "None");
assertTrue(order.getVoided());
assertNull(previousOrder.getDateStopped());
//stop the order with a different DC order
orderService.discontinueOrder(previousOrder, "Testing", null, previousOrder.getOrderer(),
previousOrder.getEncounter());
Thread.sleep(10);
expectedException.expect(CannotUnvoidOrderException.class);
expectedException.expectMessage(mss.getMessage("Order.action.cannot.unvoid", new Object[] { "discontinuation" },
null));
orderService.unvoidOrder(order);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#discontinueOrder(org.openmrs.Order, String, java.util.Date,
* org.openmrs.Provider, org.openmrs.Encounter)
*/
@Test
public void discontinueOrder_shouldPopulateCorrectAttributesOnTheDiscontinueAndDiscontinuedOrders() {
Order order = orderService.getOrderByOrderNumber("111");
Encounter encounter = encounterService.getEncounter(3);
Provider orderer = providerService.getProvider(1);
assertTrue(OrderUtilTest.isActiveOrder(order, null));
Date discontinueDate = new Date();
String discontinueReasonNonCoded = "Test if I can discontinue this";
Order discontinueOrder = orderService.discontinueOrder(order, discontinueReasonNonCoded, discontinueDate, orderer,
encounter);
Assert.assertEquals(order.getDateStopped(), discontinueDate);
Assert.assertNotNull(discontinueOrder);
Assert.assertNotNull(discontinueOrder.getId());
Assert.assertEquals(discontinueOrder.getDateActivated(), discontinueOrder.getAutoExpireDate());
Assert.assertEquals(discontinueOrder.getAction(), Action.DISCONTINUE);
Assert.assertEquals(discontinueOrder.getOrderReasonNonCoded(), discontinueReasonNonCoded);
Assert.assertEquals(discontinueOrder.getPreviousOrder(), order);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#cloneForRevision()
*/
@Test
public void cloneForRevision_shouldSetTheRelevantFieldsForADCOrder() throws Exception {
Order order = new Order();
order.setAction(Order.Action.DISCONTINUE);
Date date = new Date();
order.setDateActivated(date);
order.setPreviousOrder(new Order());
order.setAutoExpireDate(date);
order.setAccessionNumber("some number");
OrderUtilTest.setDateStopped(order, date);
Order clone = order.cloneForRevision();
assertEquals(Order.Action.DISCONTINUE, clone.getAction());
assertEquals(order.getDateActivated(), clone.getDateActivated());
assertEquals(order.getPreviousOrder(), clone.getPreviousOrder());
assertNull(clone.getAutoExpireDate());
assertNull(clone.getDateStopped());
assertNull(clone.getAccessionNumber());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @throws Exception
* @see DrugOrder#cloneForRevision()
*/
@Test
public void cloneForRevision_shouldSetTheRelevantFieldsForADCOrder() {
Order order = new DrugOrder();
order.setAction(Order.Action.DISCONTINUE);
Date date = new Date();
order.setDateActivated(date);
order.setAutoExpireDate(date);
order.setAccessionNumber("some number");
OrderUtilTest.setDateStopped(order, date);
order.setPreviousOrder(new Order());
Order clone = order.cloneForRevision();
assertEquals(Order.Action.DISCONTINUE, clone.getAction());
assertEquals(order.getDateActivated(), clone.getDateActivated());
assertEquals(order.getPreviousOrder(), clone.getPreviousOrder());
assertNull(clone.getAutoExpireDate());
assertNull(clone.getDateStopped());
assertNull(clone.getAccessionNumber());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see TestOrder#cloneForRevision()
*/
@Test
public void cloneForRevision_shouldSetTheRelevantFieldsForADCOrder() {
Order order = new TestOrder();
order.setAction(Order.Action.DISCONTINUE);
Date date = new Date();
order.setDateActivated(date);
order.setAutoExpireDate(date);
order.setAccessionNumber("some number");
OrderUtilTest.setDateStopped(order, date);
order.setPreviousOrder(new Order());
Order clone = order.cloneForRevision();
assertEquals(Order.Action.DISCONTINUE, clone.getAction());
assertEquals(order.getDateActivated(), clone.getDateActivated());
assertEquals(order.getPreviousOrder(), clone.getPreviousOrder());
assertNull(clone.getAutoExpireDate());
assertNull(clone.getDateStopped());
assertNull(clone.getAccessionNumber());
}
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#unvoidOrder(org.openmrs.Order)
*/
@Test
public void unvoidOrder_shouldStopThePreviousOrderIfTheSpecifiedOrderIsARevision() {
Order order = orderService.getOrder(111);
assertEquals(Action.REVISE, order.getAction());
Order previousOrder = order.getPreviousOrder();
assertNotNull(previousOrder.getDateStopped());
assertFalse(order.getVoided());
//void the revise order for testing purposes so we can unvoid it later
orderService.voidOrder(order, "None");
Context.flushSession();
assertTrue(order.getVoided());
assertNull(previousOrder.getDateStopped());
orderService.unvoidOrder(order);
Context.flushSession();
assertFalse(order.getVoided());
assertNotNull(previousOrder.getDateStopped());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#unvoidOrder(org.openmrs.Order)
*/
@Test
public void unvoidOrder_shouldStopThePreviousOrderIfTheSpecifiedOrderIsADiscontinuation() {
Order order = orderService.getOrder(22);
assertEquals(Action.DISCONTINUE, order.getAction());
Order previousOrder = order.getPreviousOrder();
assertNotNull(previousOrder.getDateStopped());
assertFalse(order.getVoided());
//void the DC order for testing purposes so we can unvoid it later
orderService.voidOrder(order, "None");
Context.flushSession();
assertTrue(order.getVoided());
assertNull(previousOrder.getDateStopped());
orderService.unvoidOrder(order);
Context.flushSession();
assertFalse(order.getVoided());
assertNotNull(previousOrder.getDateStopped());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see TestOrder#cloneForDiscontinuing()
*/
@Test
public void cloneForDiscontinuing_shouldSetAllTheRelevantFields() {
TestOrder anOrder = new TestOrder();
anOrder.setPatient(new Patient());
anOrder.setCareSetting(new CareSetting());
anOrder.setConcept(new Concept());
anOrder.setOrderType(new OrderType());
Order orderThatCanDiscontinueTheOrder = anOrder.cloneForDiscontinuing();
assertEquals(anOrder.getPatient(), orderThatCanDiscontinueTheOrder.getPatient());
assertEquals(anOrder.getConcept(), orderThatCanDiscontinueTheOrder.getConcept());
assertEquals("should set previous order to anOrder", anOrder, orderThatCanDiscontinueTheOrder.getPreviousOrder());
assertEquals("should set new order action to new", orderThatCanDiscontinueTheOrder.getAction(),
Order.Action.DISCONTINUE);
assertEquals(anOrder.getCareSetting(), orderThatCanDiscontinueTheOrder.getCareSetting());
assertEquals(anOrder.getOrderType(), orderThatCanDiscontinueTheOrder.getOrderType());
}
代码示例来源:origin: openmrs/openmrs-core
assertEquals("should set new order action to new", orderThatCanDiscontinueTheOrder.getAction(),
Order.Action.DISCONTINUE);
内容来源于网络,如有侵权,请联系作者删除!