Search in sources :

Example 1 with OrderEntryException

use of org.openmrs.api.OrderEntryException in project openmrs-core by openmrs.

the class OrderServiceImpl method ensureCareSettingIsSet.

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);
}
Also used : DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Order(org.openmrs.Order) OrderEntryException(org.openmrs.api.OrderEntryException) CareSetting(org.openmrs.CareSetting)

Example 2 with OrderEntryException

use of org.openmrs.api.OrderEntryException in project openmrs-core by openmrs.

the class OrderServiceImpl method ensureOrderTypeIsSet.

private void ensureOrderTypeIsSet(Order order, OrderContext orderContext) {
    if (order.getOrderType() != null) {
        return;
    }
    OrderType orderType = null;
    if (orderContext != null) {
        orderType = orderContext.getOrderType();
    }
    if (orderType == null) {
        orderType = getOrderTypeByConcept(order.getConcept());
    }
    if (orderType == null && order instanceof DrugOrder) {
        orderType = Context.getOrderService().getOrderTypeByUuid(OrderType.DRUG_ORDER_TYPE_UUID);
    }
    if (orderType == null && order instanceof TestOrder) {
        orderType = Context.getOrderService().getOrderTypeByUuid(OrderType.TEST_ORDER_TYPE_UUID);
    }
    if (orderType == null) {
        throw new OrderEntryException("Order.type.cannot.determine");
    }
    Order previousOrder = order.getPreviousOrder();
    if (previousOrder != null && !orderType.equals(previousOrder.getOrderType())) {
        throw new OrderEntryException("Order.type.does.not.match");
    }
    order.setOrderType(orderType);
}
Also used : DrugOrder(org.openmrs.DrugOrder) DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Order(org.openmrs.Order) OrderEntryException(org.openmrs.api.OrderEntryException) OrderType(org.openmrs.OrderType) TestOrder(org.openmrs.TestOrder)

Aggregations

DrugOrder (org.openmrs.DrugOrder)2 Order (org.openmrs.Order)2 TestOrder (org.openmrs.TestOrder)2 OrderEntryException (org.openmrs.api.OrderEntryException)2 CareSetting (org.openmrs.CareSetting)1 OrderType (org.openmrs.OrderType)1