Search in sources :

Example 16 with TokenAndListParam

use of ca.uhn.fhir.rest.param.TokenAndListParam 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)));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) 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 17 with TokenAndListParam

use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.

the class FhirRelatedPersonServiceImplTest method searchForRelatedPeople_shouldReturnEmptyCollectionWhenRelatedPersonGenderNotMatched.

@Test
public void searchForRelatedPeople_shouldReturnEmptyCollectionWhenRelatedPersonGenderNotMatched() {
    TokenAndListParam tokenAndListParam = new TokenAndListParam().addAnd(new TokenOrListParam().add(WRONG_GENDER));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.GENDER_SEARCH_HANDLER, tokenAndListParam);
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
    IBundleProvider results = relatedPersonService.searchForRelatedPeople(null, tokenAndListParam, null, null, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, empty());
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 18 with TokenAndListParam

use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.

the class FhirServiceRequestServiceImplTest method searchForServiceRequest_shouldReturnCollectionOfServiceRequestByUUID.

@Test
public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByUUID() {
    TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(SERVICE_REQUEST_UUID));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid);
    when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(order));
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(SERVICE_REQUEST_UUID));
    when(translator.toFhirResource(order)).thenReturn(fhirServiceRequest);
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, null, null, uuid, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, Matchers.notNullValue());
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
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) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 19 with TokenAndListParam

use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.

the class FhirServiceRequestServiceImplTest method searchForServiceRequest_shouldReturnCollectionOfServiceRequestByCode.

@Test
public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByCode() {
    TokenAndListParam code = new TokenAndListParam().addAnd(new TokenParam(CODE));
    SearchParameterMap theParams = new SearchParameterMap();
    theParams.addParameter(CODED_SEARCH_HANDLER, code);
    when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(order));
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(SERVICE_REQUEST_UUID));
    when(translator.toFhirResource(order)).thenReturn(fhirServiceRequest);
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    IBundleProvider results = serviceRequestService.searchForServiceRequests(null, code, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasSize(equalTo(1)));
}
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) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 20 with TokenAndListParam

use of ca.uhn.fhir.rest.param.TokenAndListParam 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)));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Aggregations

TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)357 Test (org.junit.Test)347 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)340 TokenParam (ca.uhn.fhir.rest.param.TokenParam)312 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)260 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)247 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)211 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)119 HashSet (java.util.HashSet)79 Include (ca.uhn.fhir.model.api.Include)77 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)48 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)48 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)46 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)46 NumberParam (ca.uhn.fhir.rest.param.NumberParam)36 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)36 Observation (org.hl7.fhir.r4.model.Observation)24 StringParam (ca.uhn.fhir.rest.param.StringParam)21 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)21 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)19