Search in sources :

Example 96 with StringOrListParam

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

the class SearchParameterMapTest method shouldAddStringOrListParamIntoAnExistingMapUsingTheSameKeyValue.

@Test
public void shouldAddStringOrListParamIntoAnExistingMapUsingTheSameKeyValue() {
    StringOrListParam orListParam1 = new StringOrListParam();
    orListParam1.addOr(new StringParam("Clement"));
    StringOrListParam orListParam2 = new StringOrListParam();
    orListParam2.addOr(new StringParam("Jane"));
    searchParam.addParameter(NAME, orListParam1);
    searchParam.addParameter(NAME, orListParam2);
    assertThat(searchParam, notNullValue());
    assertThat(searchParam.getParameters(NAME), not(empty()));
    assertThat(searchParam.getParameters(NAME), hasSize(is(2)));
}
Also used : StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Test(org.junit.Test)

Example 97 with StringOrListParam

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

the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByPostalCode.

@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByPostalCode() {
    StringAndListParam postalCodeParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
    when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(postalCodeParam)), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, null, postalCodeParam, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, Matchers.notNullValue());
    assertThat(resultList.iterator().next().fhirType(), equalTo(FhirConstants.RELATED_PERSON));
    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) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 98 with StringOrListParam

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

the class LocationFhirResourceProviderTest method findLocationsByPostalCode_shouldReturnMatchingBundleOfLocations.

@Test
public void findLocationsByPostalCode_shouldReturnMatchingBundleOfLocations() {
    StringAndListParam postalCodeParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
    when(locationService.searchForLocations(isNull(), isNull(), isNull(), argThat(Matchers.is(postalCodeParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchLocations(null, null, null, postalCodeParam, null, null, null, null, null, null, null, null);
    assertThat(results, notNullValue());
    List<Location> resultList = get(results);
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(equalTo(1)));
    assertThat(resultList.get(0).getAddress().getPostalCode(), equalTo(POSTAL_CODE));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 99 with StringOrListParam

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

the class LocationFhirResourceProviderTest method findLocationsByName_shouldReturnMatchingBundleOfLocations.

@Test
public void findLocationsByName_shouldReturnMatchingBundleOfLocations() {
    StringAndListParam nameParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_NAME)));
    when(locationService.searchForLocations(argThat(Matchers.is(nameParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchLocations(nameParam, null, null, null, null, null, null, null, null, null, null, null);
    List<Location> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getName(), equalTo(LOCATION_NAME));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 100 with StringOrListParam

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

the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfLocations.

@Test
public void searchLocations_shouldReturnMatchingBundleOfLocations() {
    List<Location> locations = new ArrayList<>();
    locations.add(location);
    when(locationService.searchForLocations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(locations, PREFERRED_PAGE_SIZE, COUNT));
    StringAndListParam location = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_NAME)));
    IBundleProvider resultLocations = resourceProvider.searchLocations(location, null, null, null, null, null, null, null, null, null, null, null);
    assertThat(resultLocations, notNullValue());
    List<Location> resultList = get(resultLocations);
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(equalTo(1)));
    assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) ArrayList(java.util.ArrayList) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) 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