/** * @see OrderService#getCareSettings(boolean) */ @Test public void getCareSettings_shouldReturnOnlyUnRetiredCareSettingsIfIncludeRetiredIsSetToFalse() { List<CareSetting> careSettings = orderService.getCareSettings(false); assertEquals(2, careSettings.size()); assertTrue(containsId(careSettings, 1)); assertTrue(containsId(careSettings, 2)); }
/** * @see OrderService#getCareSettings(boolean) */ @Test public void getCareSettings_shouldReturnRetiredCareSettingsIfIncludeRetiredIsSetToTrue() { CareSetting retiredCareSetting = orderService.getCareSetting(3); assertTrue(retiredCareSetting.getRetired()); List<CareSetting> careSettings = orderService.getCareSettings(true); assertEquals(3, careSettings.size()); assertTrue(containsId(careSettings, retiredCareSetting.getCareSettingId())); }
@Override public long getAllCount() { return service.getCareSettings(false).size(); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<CareSetting> doSearch(RequestContext context) { List<CareSetting> careSettings = Context.getOrderService().getCareSettings(context.getIncludeAll()); for (Iterator<CareSetting> iterator = careSettings.iterator(); iterator.hasNext();) { CareSetting cs = iterator.next(); if (!Pattern.compile(Pattern.quote(context.getParameter("q")), Pattern.CASE_INSENSITIVE).matcher(cs.getName()) .find()) { iterator.remove(); } } return new NeedsPaging<CareSetting>(careSettings, context); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<CareSetting> doGetAll(RequestContext context) { return new NeedsPaging<CareSetting>(Context.getOrderService().getCareSettings(context.getIncludeAll()), context); }
public static DropdownWidget createCareSettingWidget(FormEntryContext context, boolean inpatientOnly) { DropdownWidget careSettingWidget = new DropdownWidget(); List<CareSetting> careSettings = Context.getOrderService().getCareSettings(false); List<Option> options = new ArrayList<Option>(); for (CareSetting careSetting : careSettings) { if (!inpatientOnly || careSetting.getCareSettingType().equals(CareSettingType.INPATIENT)) { options.add(new Option(careSetting.getName(), careSetting.getId().toString(), false)); } } setupDropdownWidget(context, careSettingWidget, options); return careSettingWidget; }
@Test public void shouldListAllCareSettingsIncludingRetiredOnesIfIncludeAllIsSetToTrue() throws Exception { SimpleObject result = deserialize(handle(newGetRequest(getURI(), new Parameter("includeAll", "true")))); assertNotNull(result); assertEquals(service.getCareSettings(true).size(), Util.getResultsSize(result)); }