本文整理了Java中org.openmrs.Order.getPreviousOrder()
方法的一些代码示例,展示了Order.getPreviousOrder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Order.getPreviousOrder()
方法的具体详情如下:
包路径:org.openmrs.Order
类名称:Order
方法名:getPreviousOrder
[英]Gets the previous related order.
[中]获取上一个相关顺序。
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.OrderService#getOrderHistoryByOrderNumber(java.lang.String)
*/
@Override
@Transactional(readOnly = true)
public List<Order> getOrderHistoryByOrderNumber(String orderNumber) {
List<Order> orders = new ArrayList<>();
Order order = dao.getOrderByOrderNumber(orderNumber);
while (order != null) {
orders.add(order);
order = order.getPreviousOrder();
}
return orders;
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.OrderService#voidOrder(org.openmrs.Order, java.lang.String)
*/
@Override
public Order voidOrder(Order order, String voidReason) throws APIException {
if (!StringUtils.hasLength(voidReason)) {
throw new IllegalArgumentException("voidReason cannot be empty or null");
}
Order previousOrder = order.getPreviousOrder();
if (previousOrder != null && isDiscontinueOrReviseOrder(order)) {
setProperty(previousOrder, "dateStopped", null);
}
return saveOrderInternal(order, null);
}
代码示例来源:origin: openmrs/openmrs-core
private void ensureCareSettingIsSet(Order order, OrderContext orderContext) {
if (order.getCareSetting() != null) {
return;
}
CareSetting careSetting = null;
if (orderContext != null) {
careSetting = orderContext.getCareSetting();
}
Order previousOrder = order.getPreviousOrder();
if (careSetting == null || (previousOrder != null && !careSetting.equals(previousOrder.getCareSetting()))) {
throw new OrderEntryException("Order.care.cannot.determine");
}
order.setCareSetting(careSetting);
}
代码示例来源:origin: openmrs/openmrs-core
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));
}
代码示例来源: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
/**
* This test ensures that the getter for previous order field returns objects of the actual sub
* types for subclasses instead proxies that are instances of Order
*
* @throws Exception
*/
@Test
public void shouldNotReturnAProxyForPreviousOrder() {
Order dcOrder = orderService.getOrder(22);
Order previousOrder = dcOrder.getPreviousOrder();
assertNotNull(previousOrder);
Order testOrder = orderService.getOrder(7);
Order dcTestOrder = orderService.discontinueOrder(testOrder, "Testing", null, testOrder.getOrderer(), testOrder
.getEncounter());
Context.flushSession();
Context.clearSession();
dcTestOrder = orderService.getOrder(dcTestOrder.getOrderId()).getPreviousOrder();
}
代码示例来源: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 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
@Test
public void shouldDiscontinueAnActiveOrderAndFlushSuccessfully() {
executeDataSet(ORDER_ENTRY_DATASET_XML);
executeDataSet("org/openmrs/api/include/OrderServiceTest-discontinueReason.xml");
Order firstOrderToDiscontinue = orderService.getOrder(3);
Encounter encounter = encounterService.getEncounter(3);
assertTrue(OrderUtilTest.isActiveOrder(firstOrderToDiscontinue, null));
Concept discontinueReason = Context.getConceptService().getConcept(1);
Provider orderer = providerService.getProvider(1);
Order discontinuationOrder1 = orderService.discontinueOrder(firstOrderToDiscontinue, discontinueReason, null,
orderer, encounter);
Context.flushSession();
assertEquals(firstOrderToDiscontinue, discontinuationOrder1.getPreviousOrder());
}
代码示例来源: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 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 previous order to anOrder", anOrder, orderThatCanDiscontinueTheOrder.getPreviousOrder());
内容来源于网络,如有侵权,请联系作者删除!