Search in sources :

Example 56 with SearchQueryInclude

use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.

the class FhirPersonServiceImplTest method searchForPeople_shouldReturnEmptyCollectionWhenPersonCityNotMatched.

@Test
public void searchForPeople_shouldReturnEmptyCollectionWhenPersonCityNotMatched() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_ADDRESS_FIELD)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, stringAndListParam);
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
    IBundleProvider results = personService.searchForPeople(null, null, null, stringAndListParam, 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) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 57 with SearchQueryInclude

use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.

the class FhirPersonServiceImplTest method searchForPeople_shouldReturnCollectionOfPeopleWhenUUIDMatched.

@Test
public void searchForPeople_shouldReturnCollectionOfPeopleWhenUUIDMatched() {
    TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(PERSON_UUID));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid);
    when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(person));
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PERSON_UUID));
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(personTranslator.toFhirResource(person)).thenReturn(fhirPerson);
    IBundleProvider results = personService.searchForPeople(null, null, null, null, null, null, null, uuid, null, null, null);
    assertThat(results, notNullValue());
    assertThat(get(results), not(empty()));
    assertThat(results.size(), greaterThanOrEqualTo(1));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 58 with SearchQueryInclude

use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.

the class FhirPersonServiceImplTest method searchForPeople_shouldReturnCollectionOfPersonForPartialMatchOnName.

@Test
public void searchForPeople_shouldReturnCollectionOfPersonForPartialMatchOnName() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(PERSON_PARTIAL_NAME)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, stringAndListParam);
    when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(person));
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PERSON_UUID));
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(personTranslator.toFhirResource(person)).thenReturn(fhirPerson);
    IBundleProvider results = personService.searchForPeople(stringAndListParam, 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 : 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) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 59 with SearchQueryInclude

use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.

the class FhirPersonServiceImplTest method searchForPeople_shouldReturnCollectionOfPersonForGivenNameMatched.

@Test
public void searchForPeople_shouldReturnCollectionOfPersonForGivenNameMatched() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(GIVEN_NAME)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, stringAndListParam);
    when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(person));
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PERSON_UUID));
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(personTranslator.toFhirResource(person)).thenReturn(fhirPerson);
    IBundleProvider results = personService.searchForPeople(stringAndListParam, 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 : 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) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 60 with SearchQueryInclude

use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.

the class FhirPersonServiceImplTest method searchForPeople_shouldReturnCollectionOfPersonWhenPersonPostalCodeMatched.

@Test
public void searchForPeople_shouldReturnCollectionOfPersonWhenPersonPostalCodeMatched() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.POSTAL_CODE_PROPERTY, stringAndListParam);
    when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(person));
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PERSON_UUID));
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(personTranslator.toFhirResource(person)).thenReturn(fhirPerson);
    IBundleProvider results = personService.searchForPeople(null, null, null, null, null, stringAndListParam, 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) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Aggregations

SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)190 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)187 Test (org.junit.Test)184 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)148 StringParam (ca.uhn.fhir.rest.param.StringParam)72 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)66 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)49 TokenParam (ca.uhn.fhir.rest.param.TokenParam)41 ArrayList (java.util.ArrayList)41 SimpleBundleProvider (ca.uhn.fhir.rest.server.SimpleBundleProvider)39 Include (ca.uhn.fhir.model.api.Include)29 HashSet (java.util.HashSet)29 SearchQueryInclude (org.openmrs.module.fhir2.api.search.SearchQueryInclude)29 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)28 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)27 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)22 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)22 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)22 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)19 Patient (org.openmrs.Patient)12