Search in sources :

Example 6 with SimpleBundleProvider

use of ca.uhn.fhir.rest.server.SimpleBundleProvider in project openmrs-module-fhir2 by openmrs.

the class FhirPractitionerServiceImplTest method shouldReturnEmptyCollectionByWrongName.

@Test
public void shouldReturnEmptyCollectionByWrongName() {
    StringAndListParam name = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(WRONG_NAME)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(NAME_SEARCH_HANDLER, NAME_PROPERTY, name);
    when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    IBundleProvider results = practitionerService.searchForPractitioners(null, name, null, null, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, empty());
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 7 with SimpleBundleProvider

use of ca.uhn.fhir.rest.server.SimpleBundleProvider in project openmrs-module-fhir2 by openmrs.

the class FhirPractitionerServiceImplTest method shouldReturnEmptyCollectionByWrongUUID.

@Test
public void shouldReturnEmptyCollectionByWrongUUID() {
    TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(WRONG_UUID));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid);
    when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    IBundleProvider results = practitionerService.searchForPractitioners(null, null, null, null, null, null, null, null, uuid, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, empty());
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 8 with SimpleBundleProvider

use of ca.uhn.fhir.rest.server.SimpleBundleProvider in project openmrs-module-fhir2 by openmrs.

the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByAddressCity.

@Test
public void shouldSearchForPractitionersByAddressCity() {
    StringAndListParam city = new StringAndListParam().addAnd(new StringParam(CITY));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, city);
    when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
    when(practitionerDao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(provider));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
    when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    IBundleProvider results = practitionerService.searchForPractitioners(null, null, null, null, city, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 9 with SimpleBundleProvider

use of ca.uhn.fhir.rest.server.SimpleBundleProvider in project openmrs-module-fhir2 by openmrs.

the class FhirPractitionerServiceImplTest method shouldReturnEmptyCollectionByWrongGivenName.

@Test
public void shouldReturnEmptyCollectionByWrongGivenName() {
    StringAndListParam givenName = new StringAndListParam().addAnd(new StringParam(WRONG_GIVEN_NAME));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, FhirConstants.GIVEN_PROPERTY, givenName);
    when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    IBundleProvider results = practitionerService.searchForPractitioners(null, null, givenName, null, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, empty());
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 10 with SimpleBundleProvider

use of ca.uhn.fhir.rest.server.SimpleBundleProvider in project openmrs-module-fhir2 by openmrs.

the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByAddressState.

@Test
public void shouldSearchForPractitionersByAddressState() {
    StringAndListParam state = new StringAndListParam().addAnd(new StringParam(STATE));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, state);
    when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(practitionerDao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(provider));
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
    when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    IBundleProvider results = practitionerService.searchForPractitioners(null, null, null, null, null, state, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Aggregations

SimpleBundleProvider (ca.uhn.fhir.rest.server.SimpleBundleProvider)40 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)39 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)38 Test (org.junit.Test)38 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)38 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)18 StringParam (ca.uhn.fhir.rest.param.StringParam)18 Include (ca.uhn.fhir.model.api.Include)6 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)6 HashSet (java.util.HashSet)6 SearchQueryInclude (org.openmrs.module.fhir2.api.search.SearchQueryInclude)6 TokenParam (ca.uhn.fhir.rest.param.TokenParam)5 ArrayList (java.util.ArrayList)5 Encounter (org.openmrs.Encounter)5 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)4 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)4 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)3 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)3 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)3 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)2