use of org.openmrs.OrderSetMember 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.OrderSetMember 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());
}
use of org.openmrs.OrderSetMember in project openmrs-core by openmrs.
the class OrderSetServiceTest method shouldRetireOrderSetAndOrderSetMembersAsWell.
@Test
public void shouldRetireOrderSetAndOrderSetMembersAsWell() {
executeDataSet(ORDER_SET);
int initialNumberOfOrderSets = orderSetService.getOrderSets(false).size();
OrderSet orderSet = orderSetService.getOrderSet(2001);
orderSetService.retireOrderSet(orderSet, "Testing");
Context.flushSession();
int numberOfOrderSetsAfterRetire = orderSetService.getOrderSets(false).size();
assertEquals(initialNumberOfOrderSets - 1, numberOfOrderSetsAfterRetire);
OrderSet retiredOrderSet = orderSetService.getOrderSet(2001);
assertEquals(true, retiredOrderSet.getRetired());
List<OrderSetMember> orderSetMembers = retiredOrderSet.getOrderSetMembers();
for (OrderSetMember orderSetMember : orderSetMembers) {
assertTrue(orderSetMember.getRetired());
}
}
use of org.openmrs.OrderSetMember in project openmrs-core by openmrs.
the class OrderSetServiceTest method shouldFetchUnRetiredOrderSetMembers.
@Test
public void shouldFetchUnRetiredOrderSetMembers() {
executeDataSet(ORDER_SET);
OrderSet orderSet = orderSetService.getOrderSet(2000);
int initialCountOfMembers = orderSet.getOrderSetMembers().size();
OrderSetMember orderSetMember = orderSet.getOrderSetMembers().get(0);
// Retiring an orderSetMember in an existing list of orderSetMembers
orderSet.retireOrderSetMember(orderSetMember);
orderSetService.saveOrderSet(orderSet);
Context.flushSession();
OrderSet savedOrderSet = orderSetService.getOrderSetByUuid(orderSet.getUuid());
assertEquals("Count of orderSetMembers are not changed if we get all members", initialCountOfMembers, savedOrderSet.getOrderSetMembers().size());
// Fetching the unRetired members
int finalSize = savedOrderSet.getUnRetiredOrderSetMembers().size();
assertEquals("Count of orderSetMembers gets modified if we filter out the retired members", initialCountOfMembers - 1, finalSize);
}
use of org.openmrs.OrderSetMember in project openmrs-core by openmrs.
the class OrderSetServiceTest method shouldFetchOrderSetMemberByUuid.
@Test
public void shouldFetchOrderSetMemberByUuid() {
String orderSetUuid = "2d3fb1d0-ae06-22e3-a5e2-0140211c2002";
executeDataSet(ORDER_SET);
OrderSetMember orderSetMember = orderSetService.getOrderSetMemberByUuid(orderSetUuid);
assertNotNull(orderSetMember.getId());
}
Aggregations