use of org.openmrs.OrderSet in project openmrs-core by openmrs.
the class OrderSetServiceTest method shouldNotAutomaticallyPropagateToSetMembersIfExcludingOrderSet.
@Test
public void shouldNotAutomaticallyPropagateToSetMembersIfExcludingOrderSet() {
executeDataSet(ORDER_SET);
List<OrderSet> orderSets = orderSetService.getOrderSets(false);
Integer numberOfOrderSetMembers = 0;
for (OrderSet oS : orderSets) {
numberOfOrderSetMembers = numberOfOrderSetMembers + oS.getOrderSetMembers().size();
}
assertEquals(new Integer(4), numberOfOrderSetMembers);
}
use of org.openmrs.OrderSet in project openmrs-core by openmrs.
the class EncounterServiceTest method shouldSaveOrderGroupAlongWithOrders.
@Test
public void shouldSaveOrderGroupAlongWithOrders() {
executeDataSet(ORDER_SET);
// Created a new Encounter
Encounter encounter = new Encounter();
encounter.setPatient(Context.getPatientService().getPatient(3));
encounter.setEncounterType(Context.getEncounterService().getEncounterType(1));
encounter.setEncounterDatetime(new Date());
Context.getEncounterService().saveEncounter(encounter);
Integer encounterId = Context.getEncounterService().getEncounterByUuid(encounter.getUuid()).getId();
// Created a new OrderGroup
OrderSet orderSet = Context.getOrderSetService().getOrderSet(2000);
OrderGroup orderGroup = new OrderGroup();
orderGroup.setOrderSet(orderSet);
orderGroup.setPatient(encounter.getPatient());
orderGroup.setEncounter(Context.getEncounterService().getEncounter(encounterId));
// Added this OrderGroup to two new orders
Order firstOrderWithOrderGroup = new OrderBuilder().withAction(Order.Action.NEW).withPatient(3).withConcept(1000).withCareSetting(1).withOrderer(1).withEncounter(encounterId).withDateActivated(new Date()).withOrderType(17).withUrgency(Order.Urgency.ON_SCHEDULED_DATE).withScheduledDate(new Date()).withOrderGroup(orderGroup).build();
Order secondOrderWithOrderGroup = new OrderBuilder().withAction(Order.Action.NEW).withPatient(3).withConcept(1001).withCareSetting(1).withOrderer(1).withEncounter(encounterId).withDateActivated(new Date()).withOrderType(17).withUrgency(Order.Urgency.ON_SCHEDULED_DATE).withScheduledDate(new Date()).withOrderGroup(orderGroup).build();
// Add these orders to the Encounter
encounter.addOrder(firstOrderWithOrderGroup);
encounter.addOrder(secondOrderWithOrderGroup);
Context.getEncounterService().saveEncounter(encounter);
Context.flushSession();
List<Order> orders = new ArrayList<>(Context.getEncounterService().getEncounterByUuid(encounter.getUuid()).getOrders());
assertNotNull("OrderGroup is saved", orders.get(0).getOrderGroup());
assertEquals("OrderGroup isa same for both the orders ", true, orders.get(0).getOrderGroup().equals(orders.get(1).getOrderGroup()));
}
use of org.openmrs.OrderSet in project openmrs-core by openmrs.
the class OrderSetServiceTest method orderSetBuilder.
private OrderSet orderSetBuilder(boolean orderSetRetired, boolean orderSetMemberRetired) {
OrderSet orderSet = new OrderSet();
orderSet.setName("Test Order Set");
orderSet.setDescription("Test Order Set Description");
orderSet.setOperator(OrderSet.Operator.ALL);
OrderSetMember orderSetMember = new OrderSetMember();
orderSetMember.setOrderType(orderService.getOrderType(100));
orderSetMember.setConcept(conceptService.getConcept(1000));
orderSetMember.setCreator(new User(1));
orderSetMember.setDateCreated(new Date());
orderSetMember.setRetired(orderSetMemberRetired);
orderSetMember.setOrderSet(orderSet);
List<OrderSetMember> orderSetMembers = new ArrayList<>(Collections.singletonList(orderSetMember));
orderSet.setOrderSetMembers(orderSetMembers);
orderSet.setCreator(new User(1));
orderSet.setDateCreated(new Date());
orderSet.setRetired(orderSetRetired);
return orderSet;
}
use of org.openmrs.OrderSet in project openmrs-core by openmrs.
the class OrderSetServiceTest method shouldSaveAndUpdateOrderSet.
@Test
public void shouldSaveAndUpdateOrderSet() {
executeDataSet(ORDER_SET);
OrderSet orderSet = orderSetBuilder(false, false);
OrderSet orderSetObj = orderSetService.saveOrderSet(orderSet);
orderSetObj.setOperator(OrderSet.Operator.ONE);
orderSetObj.setDescription("Test Order Set Description Updated");
assertNull("OrderSet is new and is not changed", orderSetObj.getChangedBy());
assertNull("OrderSet is new and has no change date", orderSetObj.getDateChanged());
orderSetService.saveOrderSet(orderSetObj);
Context.flushSession();
assertNotNull("OrderSet has a order_set_id", orderSetObj.getId());
assertEquals("OrderSet has updated description", "Test Order Set Description Updated", orderSetObj.getDescription());
assertEquals("OrderSet has updated operator", "ONE", orderSetObj.getOperator().toString());
assertNotNull("OrderSet has been changed", orderSetObj.getChangedBy());
assertNotNull("OrderSet has been changed on some date", orderSetObj.getDateChanged());
}
use of org.openmrs.OrderSet in project openmrs-core by openmrs.
the class OrderSetServiceTest method shouldAddOrderSetMemberAtLastPositionInsideAnExistingOrderSetIfPositionIsNull.
@Test
public void shouldAddOrderSetMemberAtLastPositionInsideAnExistingOrderSetIfPositionIsNull() {
executeDataSet(ORDER_SET);
OrderSet orderSet = orderSetService.getOrderSet(2001);
Integer initialSize = orderSet.getOrderSetMembers().size();
OrderSetMember newOrderSetMember = new OrderSetMember();
newOrderSetMember.setOrderType(orderService.getOrderType(100));
newOrderSetMember.setConcept(conceptService.getConcept(1002));
newOrderSetMember.setCreator(new User(1));
newOrderSetMember.setDateCreated(new Date());
newOrderSetMember.setRetired(false);
orderSet.addOrderSetMember(newOrderSetMember, null);
Context.getOrderSetService().saveOrderSet(orderSet);
Context.flushSession();
OrderSet savedOrderSet = Context.getOrderSetService().getOrderSetByUuid(orderSet.getUuid());
assertEquals("Size of the orderSetMembers got updated", initialSize + 1, savedOrderSet.getOrderSetMembers().size());
assertEquals("New OrderSetMember got added at last position", newOrderSetMember.getUuid(), savedOrderSet.getOrderSetMembers().get(initialSize).getUuid());
}
Aggregations