/** * Run this before each unit test in this class. The "@Before" method in * {@link BaseContextSensitiveTest} is run right before this method. * * @throws Exception */ @Before public void runBeforeAllTests() { if (null == orderSetService) { orderSetService = Context.getOrderSetService(); } if (null == orderService) { orderService = Context.getOrderService(); } if (null == conceptService) { conceptService = Context.getConceptService(); } }
@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()); }
@Test public void shouldAddOrderSetMemberFromTheEndOfTheListIfNegativePositionIsGiven() { 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); Integer position = -2; orderSet.addOrderSetMember(newOrderSetMember, position); 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 given position", newOrderSetMember.getUuid(), savedOrderSet .getOrderSetMembers().get(position + initialSize + 1).getUuid()); }
@Override public OrderSet getByUniqueId(String uniqueId) { return Context.getOrderSetService().getOrderSetByUuid(uniqueId); }
@Before public void setup() { if (orderService == null) { orderService = Context.getOrderService(); } if (patientService == null) { patientService = Context.getPatientService(); } if (conceptService == null) { conceptService = Context.getConceptService(); } if (encounterService == null) { encounterService = Context.getEncounterService(); } if (providerService == null) { providerService = Context.getProviderService(); } if (adminService == null) { adminService = Context.getAdministrationService(); } if (orderSetService == null) { orderSetService = Context.getOrderSetService(); } if (mss == null) { mss = Context.getMessageSourceService(); } }
orderSet.addOrderSetMember(newOrderSetMember, position); Context.getOrderSetService().saveOrderSet(orderSet); OrderSet savedOrderSet = Context.getOrderSetService().getOrderSetByUuid(orderSet.getUuid());
OrderSet orderSet = Context.getOrderSetService().getOrderSet(2000); OrderGroup orderGroup = new OrderGroup(); orderGroup.setOrderSet(orderSet);
OrderSet orderSet = Context.getOrderSetService().getOrderSet(2000); OrderGroup orderGroup = new OrderGroup(); orderGroup.setOrderSet(orderSet);
OrderSet orderSet = Context.getOrderSetService().getOrderSet(2000); OrderGroup orderGroup = new OrderGroup(); orderGroup.setOrderSet(orderSet);
OrderSet orderSet = Context.getOrderSetService().getOrderSet(2000); OrderGroup orderGroup = new OrderGroup(); orderGroup.setOrderSet(orderSet);
@Override public void purge(OrderSetMember orderSetMember, RequestContext context) throws ResponseException { OrderSet orderSet = orderSetMember.getOrderSet(); orderSet.removeOrderSetMember(orderSetMember); Context.getOrderSetService().saveOrderSet(orderSet); }
@Override protected void delete(OrderSetMember orderSetMember, String reason, RequestContext context) throws ResponseException { OrderSet orderSet = orderSetMember.getOrderSet(); orderSet.retireOrderSetMember(orderSetMember); Context.getOrderSetService().saveOrderSet(orderSet); }
@Override public OrderSetMember save(OrderSetMember delegate) { OrderSet parent = delegate.getOrderSet(); parent.addOrderSetMember(delegate); Context.getOrderSetService().saveOrderSet(parent); return delegate; }
OrderSet orderSet = Context.getOrderSetService().getOrderSet(2000); OrderGroup orderGroup = new OrderGroup(); orderGroup.setOrderSet(orderSet);
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<OrderSet> doGetAll(RequestContext context) { return new NeedsPaging<OrderSet>(Context.getOrderSetService().getOrderSets(context.getIncludeAll()), context); }
OrderSet orderSet = Context.getOrderSetService().getOrderSet(2000); OrderGroup orderGroup = new OrderGroup(); orderGroup.setOrderSet(orderSet);
@Before public void init() throws Exception { orderSetService = Context.getOrderSetService(); executeDataSet(RestTestConstants1_12.TEST_DATA_SET); }
@Override public OrderSet newObject() { return Context.getOrderSetService().getOrderSetByUuid(getUuidProperty()); }
@Before public void init() throws Exception { orderSetService = Context.getOrderSetService(); executeDataSet(RestTestConstants1_12.TEST_DATA_SET); }
@Before public void init() throws Exception { orderSetService = Context.getOrderSetService(); executeDataSet(RestTestConstants1_12.TEST_DATA_SET); }