use of ca.uhn.fhir.rest.param.StringAndListParam in project openmrs-module-fhir2 by openmrs.
the class SearchParameterMapTest method shouldAddStringAndListParamIntoAnExistingMapUsingTheSameKeyValue.
@Test
public void shouldAddStringAndListParamIntoAnExistingMapUsingTheSameKeyValue() {
StringAndListParam andListParam1 = new StringAndListParam();
andListParam1.addAnd(new StringParam("John"));
StringAndListParam andListParam2 = new StringAndListParam();
andListParam2.addAnd(new StringParam("Joe"));
searchParam.addParameter(NAME, andListParam1);
searchParam.addParameter(NAME, andListParam2);
assertThat(searchParam, notNullValue());
assertThat(searchParam.getParameters(NAME), not(empty()));
assertThat(searchParam.getParameters(NAME), hasSize(is(2)));
}
use of ca.uhn.fhir.rest.param.StringAndListParam in project elexis-server by elexis.
the class PersonResourceProvider method search.
@Search
public List<Person> search(@OptionalParam(name = Person.SP_NAME) StringParam name, @OptionalParam(name = ca.uhn.fhir.rest.api.Constants.PARAM_FILTER) StringAndListParam theFtFilter) {
IQuery<IPerson> query = modelService.getQuery(IPerson.class);
if (name != null) {
QueryUtil.andContactNameCriterion(query, name);
}
if (theFtFilter != null) {
new IContactSearchFilterQueryAdapter().adapt(query, theFtFilter);
}
List<IPerson> persons = query.execute();
List<Person> _persons = persons.parallelStream().map(org -> getTransformer().getFhirObject(org)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
return _persons;
}
use of ca.uhn.fhir.rest.param.StringAndListParam in project elexis-server by elexis.
the class PractitionerResourceProvider method search.
@Search
public List<Practitioner> search(@OptionalParam(name = Practitioner.SP_NAME) StringParam name, @OptionalParam(name = ca.uhn.fhir.rest.api.Constants.PARAM_FILTER) StringAndListParam theFtFilter) {
IQuery<IMandator> query = coreModelService.getQuery(IMandator.class);
if (name != null) {
QueryUtil.andContactNameCriterion(query, name);
}
if (theFtFilter != null) {
new IContactSearchFilterQueryAdapter().adapt(query, theFtFilter);
}
List<IMandator> practitioners = query.execute();
List<Practitioner> _practitioners = practitioners.parallelStream().map(org -> getTransformer().getFhirObject(org)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
return _practitioners;
}
use of ca.uhn.fhir.rest.param.StringAndListParam in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method findLocationsByCountry_shouldReturnMatchingBundleOfLocations.
@Test
public void findLocationsByCountry_shouldReturnMatchingBundleOfLocations() {
StringAndListParam countryParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
when(locationService.searchForLocations(isNull(), isNull(), argThat(Matchers.is(countryParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchLocations(null, null, countryParam, null, null, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
List<Location> resultList = get(results);
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).getAddress().getCountry(), equalTo(COUNTRY));
}
use of ca.uhn.fhir.rest.param.StringAndListParam in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method findLocationsByName_shouldReturnMatchingBundleOfLocations.
@Test
public void findLocationsByName_shouldReturnMatchingBundleOfLocations() {
StringAndListParam nameParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_NAME)));
when(locationService.searchForLocations(argThat(Matchers.is(nameParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchLocations(nameParam, null, null, null, null, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
List<Location> resultList = get(results);
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList.get(0).getName(), equalTo(LOCATION_NAME));
}
Aggregations