use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByIdentifier.
@Test
public void shouldSearchForPractitionersByIdentifier() {
TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(IDENTIFIER));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.IDENTIFIER_SEARCH_HANDLER, identifier);
when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
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(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
IBundleProvider results = practitionerService.searchForPractitioners(identifier, null, null, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class FhirPractitionerServiceImplTest method shouldNotAddRelatedResourcesToReturnedResultsForEmptyReverseInclude.
@Test
public void shouldNotAddRelatedResourcesToReturnedResultsForEmptyReverseInclude() {
HashSet<Include> revIncludes = new HashSet<>();
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.REVERSE_INCLUDE_SEARCH_HANDLER, revIncludes);
when(practitionerDao.getSearchResultUuids(any())).thenReturn(singletonList(UUID));
when(practitionerDao.getSearchResults(any(), any())).thenReturn(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, null, null, null, null, null, null, revIncludes);
List<IBaseResource> resultList = get(results);
assertThat(resultList, notNullValue());
assertThat(resultList, Matchers.not(empty()));
assertThat(resultList.size(), Matchers.equalTo(1));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByGivenNameWhoIsUserAndProvider.
@Test
public void shouldSearchForPractitionersByGivenNameWhoIsUserAndProvider() {
StringAndListParam givenName = new StringAndListParam().addAnd(new StringParam(PRACTITIONER_GIVEN_NAME));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, FhirConstants.GIVEN_PROPERTY, givenName);
when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
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(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider(practitioner2));
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, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(2)));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class FhirUserServiceImplTest method shouldsearchForUsersByIdentifier.
@Test
public void shouldsearchForUsersByIdentifier() {
TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(USER_SYSTEM_ID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(IDENTIFIER_SEARCH_HANDLER, identifier);
when(dao.getSearchResultUuids(any())).thenReturn(singletonList(USER_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(singletonList(user));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
when(translator.toFhirResource(user)).thenReturn(practitioner);
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
IBundleProvider results = userService.searchForUsers(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class FhirUserServiceImplTest method shouldSearchForUsersByName.
@Test
public void shouldSearchForUsersByName() {
StringAndListParam name = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(USER_NAME)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(NAME_SEARCH_HANDLER, NAME_PROPERTY, name);
when(dao.getSearchResultUuids(any())).thenReturn(singletonList(USER_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(singletonList(user));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
when(translator.toFhirResource(user)).thenReturn(practitioner);
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
IBundleProvider results = userService.searchForUsers(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Aggregations