Search in sources :

Example 6 with StringOrListParam

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

the class FhirRelatedPersonServiceImplTest method searchForRelatedPeople_shouldReturnEmptyCollectionWhenRelatedPersonNameNotMatched.

@Test
public void searchForRelatedPeople_shouldReturnEmptyCollectionWhenRelatedPersonNameNotMatched() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_FOUND_NAME)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, stringAndListParam);
    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(stringAndListParam, null, 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) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 7 with StringOrListParam

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

the class FhirRelatedPersonServiceImplTest method searchForPeople_shouldReturnEmptyCollectionWhenPersonCountryNotMatched.

@Test
public void searchForPeople_shouldReturnEmptyCollectionWhenPersonCountryNotMatched() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_ADDRESS_FIELD)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, stringAndListParam);
    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, null, null, null, null, null, stringAndListParam, 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 8 with StringOrListParam

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

the class FhirRelatedPersonServiceImplTest method searchForRelatedPeople_shouldReturnEmptyCollectionWhenRelatedPersonStateNotMatched.

@Test
public void searchForRelatedPeople_shouldReturnEmptyCollectionWhenRelatedPersonStateNotMatched() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_ADDRESS_FIELD)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, stringAndListParam);
    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, null, null, null, stringAndListParam, 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 9 with StringOrListParam

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

the class FhirRelatedPersonServiceImplTest method searchForRelatedPeople_shouldReturnEmptyCollectionWhenRelatedPersonPostalCodeNotMatched.

@Test
public void searchForRelatedPeople_shouldReturnEmptyCollectionWhenRelatedPersonPostalCodeNotMatched() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_ADDRESS_FIELD)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.POSTAL_CODE_PROPERTY, stringAndListParam);
    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, null, null, null, null, stringAndListParam, 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 10 with StringOrListParam

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

the class FhirRelatedPersonServiceImplTest method searchForRelatedPeople_shouldReturnCollectionOfRelatedPersonForPartialMatchOnName.

@Test
public void searchForRelatedPeople_shouldReturnCollectionOfRelatedPersonForPartialMatchOnName() {
    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.getSearchResultUuids(any())).thenReturn(singletonList(RELATED_PERSON_UUID));
    when(dao.getSearchResults(any(), any())).thenReturn(singletonList(relationship));
    when(translator.toFhirResource(relationship)).thenReturn(relatedPerson);
    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 = relatedPersonService.searchForRelatedPeople(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(equalTo(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

StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)116 StringParam (ca.uhn.fhir.rest.param.StringParam)116 Test (org.junit.Test)112 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)110 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)110 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)69 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)60 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)32 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)25 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)18 Location (org.hl7.fhir.r4.model.Location)14 RelatedPerson (org.hl7.fhir.r4.model.RelatedPerson)8 Person (org.hl7.fhir.r4.model.Person)7 Location (org.hl7.fhir.dstu3.model.Location)6 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)4 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)4 SimpleBundleProvider (ca.uhn.fhir.rest.server.SimpleBundleProvider)4 Practitioner (org.hl7.fhir.r4.model.Practitioner)4 ArrayList (java.util.ArrayList)3 Description (ca.uhn.fhir.model.api.annotation.Description)2