/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected AlreadyPaged<Patient> doSearch(RequestContext context) { return new ServiceSearcher<Patient>(PatientService.class, "getPatients", "getCountOfPatients").search( context.getParameter("q"), context); }
/** * Gets encounters for the given patient (paged according to context if necessary) only if a * patient parameter exists in the request set on the {@link RequestContext} otherwise searches * for encounters that match the specified query * * @param context * @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 patientUuid = context.getRequest().getParameter("patient"); if (patientUuid != null) { Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); if (patient == null) return new EmptySearchResult(); List<Encounter> encs = Context.getEncounterService().getEncountersByPatient(patient); return new NeedsPaging<Encounter>(encs, context); } return new ServiceSearcher<Encounter>(EncounterService.class, "getEncounters", "getCountOfEncounters").search( context.getParameter("q"), context); }