/** * @see org.openmrs.api.ProviderService#getCountOfProviders(java.lang.String) */ @Override @Transactional(readOnly = true) public Integer getCountOfProviders(String query) { return Context.getProviderService().getCountOfProviders(query, false); }
/** * @see ProviderService#getCountOfProviders(String,null) */ @Test public void getCountOfProviders_shouldIncludeRetiredProvidersIfIncludeRetiredIsSetToTrue() { assertEquals(4, service.getCountOfProviders("provider", true).intValue()); }
/** * @see ProviderService#getCountOfProviders(String) */ @Test public void getCountOfProviders_shouldExcludeRetiredProviders() { assertEquals(2, service.getCountOfProviders("provider").intValue()); }
/** * @see ProviderService#getCountOfProviders(String,null) */ @Test public void getCountOfProviders_shouldFetchNumberOfProviderMatchingGivenQuery() { assertEquals(1, service.getCountOfProviders("Hippo").intValue()); Person person = Context.getPersonService().getPerson(502); Set<PersonName> names = person.getNames(); for (PersonName name : names) { name.setVoided(true); } PersonName personName = new PersonName("Hippot", "A", "B"); personName.setPreferred(true); person.addName(personName); Context.getPersonService().savePerson(person); assertEquals(1, service.getCountOfProviders("Hippo").intValue()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected PageableResult doSearch(RequestContext context) { String query = context.getParameter("q"); if (query == null) { return new EmptySearchResult(); } List<Provider> providers = Context.getProviderService().getProviders(query, context.getStartIndex(), context.getLimit(), null, context.getIncludeAll()); int count = Context.getProviderService().getCountOfProviders(query, context.getIncludeAll()); boolean hasMore = count > context.getStartIndex() + context.getLimit(); return new AlreadyPaged<Provider>(context, providers, hasMore); }