/** * @see OrderService#(OrderSearchCriteria) */ @Test public void getOrders_shouldGetOrdersByActivatedOnOrBeforeDate() { // should get orders activated any time on this day Date activatedOnOrBeforeDate = new GregorianCalendar(2008, 7, 19).getTime(); OrderSearchCriteria orderSearchCriteria = new OrderSearchCriteriaBuilder().setActivatedOnOrBeforeDate(activatedOnOrBeforeDate).build(); List<Order> orders = orderService.getOrders(orderSearchCriteria); assertEquals(11, orders.size()); }
/** * @see OrderService#(OrderSearchCriteria) */ @Test public void getOrders_shouldGetOrdersByActivatedOnOrAfterDate() { // hour and minute should be ignored by search Date activatedOnOrAfterDate = new GregorianCalendar(2008, 7, 19, 12, 0).getTime(); OrderSearchCriteria orderSearchCriteria = new OrderSearchCriteriaBuilder().setActivatedOnOrAfterDate(activatedOnOrAfterDate).build(); List<Order> orders = orderService.getOrders(orderSearchCriteria); assertEquals(3, orders.size()); }
/** * @see OrderService#(OrderSearchCriteria) */ @Test public void getOrders_shouldGetOrdersByOrderTypes() { List<OrderType> orderTypes = new ArrayList<>(); orderTypes.add(orderService.getOrderType(1)); // drug order OrderSearchCriteria orderSearchCriteria = new OrderSearchCriteriaBuilder().setOrderTypes(orderTypes).build(); List<Order> orders = orderService.getOrders(orderSearchCriteria); assertEquals(10, orders.size()); }
/** * @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting, * org.openmrs.OrderType, boolean) */ @Test public void getOrders_shouldFailIfPatientIsNull() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Patient is required"); orderService.getOrders(null, null, null, false); }
/** * @see OrderService#(OrderSearchCriteria) */ @Test public void getOrders_shouldGetOrdersByConcepts() { List<Concept> concepts = new ArrayList<>(); concepts.add(conceptService.getConcept(88)); // aspirin concepts.add(conceptService.getConcept(3)); // cough syrup OrderSearchCriteria orderSearchCriteria = new OrderSearchCriteriaBuilder().setConcepts(concepts).build(); List<Order> orders = orderService.getOrders(orderSearchCriteria); assertEquals(6, orders.size()); }
/** * @see OrderService#(OrderSearchCriteria) */ @Test public void getOrders_shouldGetOrdersByIncludeVoided() { OrderSearchCriteria orderSearchCriteria = new OrderSearchCriteriaBuilder().setIncludeVoided(true).build(); List<Order> orders = orderService.getOrders(orderSearchCriteria); assertEquals(14, orders.size()); }
/** * @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting, * org.openmrs.OrderType, boolean) */ @Test public void getOrders_shouldGetAllUnvoidedMatchesIfIncludeVoidedIsSetToFalse() { Patient patient = patientService.getPatient(2); CareSetting outPatient = orderService.getCareSetting(1); OrderType testOrderType = orderService.getOrderType(2); assertEquals(3, orderService.getOrders(patient, outPatient, testOrderType, false).size()); }
/** * @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting, * org.openmrs.OrderType, boolean) */ @Test public void getOrders_shouldIncludeVoidedMatchesIfIncludeVoidedIsSetToTrue() { Patient patient = patientService.getPatient(2); CareSetting outPatient = orderService.getCareSetting(1); OrderType testOrderType = orderService.getOrderType(2); assertEquals(4, orderService.getOrders(patient, outPatient, testOrderType, true).size()); }
/** * @see OrderService#(OrderSearchCriteria) */ @Test public void getOrders_shouldGetTheOrdersByCareSettingAndOrderType() { CareSetting outPatient = orderService.getCareSetting(1); List<OrderType> orderTypes = new ArrayList<>(); orderTypes.add(orderService.getOrderType(2)); // test order type OrderSearchCriteria orderSearchCriteria = new OrderSearchCriteriaBuilder().setCareSetting(outPatient).setOrderTypes(orderTypes).build(); List<Order> orders = orderService.getOrders(orderSearchCriteria); assertEquals(3, orders.size()); }
/** * @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting, * org.openmrs.OrderType, boolean) */ @Test public void getOrders_shouldFailIfCareSettingIsNull() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("CareSetting is required"); orderService.getOrders(new Patient(), null, null, false); }
/** * @see OrderService#(OrderSearchCriteria) */ @Test public void getOrders_shouldGetOrdersByCareSetting() { CareSetting outPatient = orderService.getCareSetting(1); OrderSearchCriteria orderSearchCriteria = new OrderSearchCriteriaBuilder().setCareSetting(outPatient).build(); List<Order> orders = orderService.getOrders(orderSearchCriteria); assertEquals(12, orders.size()); }
/** * @see OrderService#(OrderSearchCriteria) */ @Test public void getOrders_shouldGetOrdersByPatient() { Patient patient = patientService.getPatient(2); OrderSearchCriteria orderSearchCriteria = new OrderSearchCriteriaBuilder().setPatient(patient).build(); List<Order> orders = orderService.getOrders(orderSearchCriteria); assertEquals(11, orders.size()); }
/** * @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting, * org.openmrs.OrderType, boolean) */ @Test public void getOrders_shouldGetTheOrdersThatMatchAllTheArguments() { Patient patient = patientService.getPatient(2); CareSetting outPatient = orderService.getCareSetting(1); OrderType testOrderType = orderService.getOrderType(2); List<Order> testOrders = orderService.getOrders(patient, outPatient, testOrderType, false); assertEquals(3, testOrders.size()); TestUtil.containsId(testOrders, 6); TestUtil.containsId(testOrders, 7); TestUtil.containsId(testOrders, 9); OrderType drugOrderType = orderService.getOrderType(1); List<Order> drugOrders = orderService.getOrders(patient, outPatient, drugOrderType, false); assertEquals(5, drugOrders.size()); TestUtil.containsId(drugOrders, 2); TestUtil.containsId(drugOrders, 3); TestUtil.containsId(drugOrders, 44); TestUtil.containsId(drugOrders, 444); TestUtil.containsId(drugOrders, 5); CareSetting inPatient = orderService.getCareSetting(2); List<Order> inPatientDrugOrders = orderService.getOrders(patient, inPatient, drugOrderType, false); assertEquals(222, inPatientDrugOrders.get(0).getOrderId().intValue()); }
/** * @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting, * org.openmrs.OrderType, boolean) */ @Test public void getOrders_shouldIncludeOrdersForSubTypesIfOrderTypeIsSpecified() { executeDataSet("org/openmrs/api/include/OrderServiceTest-otherOrders.xml"); Patient patient = patientService.getPatient(2); OrderType testOrderType = orderService.getOrderType(2); CareSetting outPatient = orderService.getCareSetting(1); List<Order> orders = orderService.getOrders(patient, outPatient, testOrderType, false); assertEquals(7, orders.size()); Order[] expectedOrder1 = { orderService.getOrder(6), orderService.getOrder(7), orderService.getOrder(9), orderService.getOrder(101), orderService.getOrder(102), orderService.getOrder(103), orderService.getOrder(104) }; assertThat(orders, hasItems(expectedOrder1)); OrderType labTestOrderType = orderService.getOrderType(7); orders = orderService.getOrders(patient, outPatient, labTestOrderType, false); assertEquals(3, orderService.getOrders(patient, outPatient, labTestOrderType, false).size()); Order[] expectedOrder2 = { orderService.getOrder(101), orderService.getOrder(103), orderService.getOrder(104) }; assertThat(orders, hasItems(expectedOrder2)); }
/** * @see org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest#getAllCount() */ @Override public long getAllCount() { return service.getOrders(Order.class, null, null, null, null, null, null).size(); }
/** * Gets the inactive orders of the specified patient as of the specified date, defaults to * current date if no date is specified * * @param patient * @param careSetting * @param orderType * @param asOfDate * @return */ public static List<Order> getOrders(Patient patient, CareSetting careSetting, OrderType orderType, String status, Date asOfDate, boolean includeVoided) { OrderService os = Context.getOrderService(); if (!INACTIVE.equals(status) && !ANY.equals(status)) { return os.getActiveOrders(patient, orderType, careSetting, asOfDate); } if (INACTIVE.equals(status)) { includeVoided = false; } List<Order> orders = os.getOrders(patient, careSetting, orderType, includeVoided); if (INACTIVE.equals(status)) { removeActiveOrders(orders, asOfDate); } return orders; }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) * @should return all Orders (including retired) if context.includeAll is set */ @Override protected PageableResult doGetAll(RequestContext context) throws ResponseException { //ORDER_STATUS.ANY is used to specify that all orders, including voided ones should be retrieved ORDER_STATUS orderStatus = context.getIncludeAll() ? ORDER_STATUS.ANY : null; return new NeedsPaging<Order>(Context.getOrderService().getOrders(Order.class, null, null, orderStatus, null, null, null), context); }
List<Order> orders = orderService.getOrders(orderSearchCriteria);
@Test public void shouldGetAllOrders() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); SimpleObject result = deserialize(handle(req)); int count = service.getOrders(Order.class, null, null, null, null, null, null).size(); Assert.assertEquals(count, Util.getResultsSize(result)); }
@Test public void shouldGetAllDrugOrders() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.setParameter(RestConstants.REQUEST_PROPERTY_FOR_TYPE, "drugorder"); SimpleObject result = deserialize(handle(req)); int count = service.getOrders(DrugOrder.class, null, null, null, null, null, null).size(); Assert.assertEquals(count, Util.getResultsSize(result)); }