protected RequestContext buildRequestContext(String... paramNamesAndValues) {
   MockHttpServletRequest request = new MockHttpServletRequest();
   for (int i = 0; i < paramNamesAndValues.length; i += 2) {
     request.addParameter(paramNamesAndValues[i], paramNamesAndValues[i + 1]);
   }
   RequestContext context = new RequestContext();
   context.setRequest(request);
   return context;
 }
 @Override
 protected PageableResult doGetAll(RequestContext context) {
   return new NeedsPaging<LabSpecimenTemplate>(
       Context.getService(LabCatalogService.class)
           .getLabSpecimenTemplate("", context.getIncludeAll(), null, null),
       context);
 }
 @Override
 public PageableResult search(RequestContext context) throws ResponseException {
   String patientUuid = context.getRequest().getParameter("patient");
   String encounterTypeUuid = context.getRequest().getParameter("encounterType");
   Patient patient =
       ((PatientResource1_8)
               Context.getService(RestService.class).getResourceBySupportedClass(Patient.class))
           .getByUniqueId(patientUuid);
   EncounterType encounterType =
       ((EncounterTypeResource1_8)
               Context.getService(RestService.class)
                   .getResourceBySupportedClass(EncounterType.class))
           .getByUniqueId(encounterTypeUuid);
   if (patient != null && encounterType != null) {
     List<Encounter> encounters =
         Context.getEncounterService()
             .getEncounters(
                 patient, null, null, null, null, Arrays.asList(encounterType), null, false);
     return new NeedsPaging<Encounter>(encounters, context);
   }
   return new EmptySearchResult();
 }
  @Override
  public PageableResult search(RequestContext requestContext) throws ResponseException {
    String query = requestContext.getParameter("q");
    List<LocationTag> tags = new ArrayList<>();
    if (query != null && !query.isEmpty()) {
      for (String tag : query.split(",")) {
        tags.add(locationService.getLocationTagByName(tag));
      }
    }

    List<Location> locations = locationService.getLocationsHavingAllTags(tags);
    return new AlreadyPaged<>(requestContext, locations, false);
  }
 /**
  * @see
  *     org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext)
  */
 @Override
 protected NeedsPaging<PersonAttributeType> doSearch(RequestContext context) {
   return new NeedsPaging<PersonAttributeType>(
       service().getPersonAttributeTypes(context.getParameter("q"), null, null, null), context);
 }
 /**
  * @see
  *     org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext)
  */
 @Override
 protected NeedsPaging<PersonAttributeType> doGetAll(RequestContext context)
     throws ResponseException {
   return new NeedsPaging<PersonAttributeType>(
       service().getAllPersonAttributeTypes(context.getIncludeAll()), context);
 }