Search in sources :

Example 21 with StringOrListParam

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

the class LocationSearchQueryTest method searchForLocations_shouldReturnCorrectLocationByCity.

@Test
public void searchForLocations_shouldReturnCorrectLocationByCity() {
    StringAndListParam city = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_CITY)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.CITY_SEARCH_HANDLER, city);
    IBundleProvider locations = search(theParams);
    assertThat(locations, notNullValue());
    assertThat(locations.size(), equalTo(1));
    List<Location> resultList = get(locations);
    assertThat(resultList, hasSize(equalTo(1)));
    assertThat(resultList.get(0).getAddress().getCity(), equalTo(LOCATION_CITY));
}
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) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Location(org.hl7.fhir.r4.model.Location) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 22 with StringOrListParam

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

the class LocationSearchQueryTest method searchForLocations_shouldReturnEmptyCollectionWhenCalledWithUnknownCity.

@Test
public void searchForLocations_shouldReturnEmptyCollectionWhenCalledWithUnknownCity() {
    StringAndListParam city = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(UNKNOWN_LOCATION_CITY)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.CITY_SEARCH_HANDLER, city);
    IBundleProvider locations = search(theParams);
    assertThat(locations, notNullValue());
    assertThat(locations.size(), equalTo(0));
    List<Location> resultList = get(locations);
    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) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Location(org.hl7.fhir.r4.model.Location) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 23 with StringOrListParam

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

the class LocationSearchQueryTest method searchForLocations_shouldReturnEmptyCollectionWhenCalledWithUnknownCountry.

@Test
public void searchForLocations_shouldReturnEmptyCollectionWhenCalledWithUnknownCountry() {
    StringAndListParam country = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(UNKNOWN_LOCATION_COUNTRY)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COUNTRY_SEARCH_HANDLER, country);
    IBundleProvider locations = search(theParams);
    assertThat(locations, notNullValue());
    assertThat(get(locations).size(), equalTo(0));
}
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) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 24 with StringOrListParam

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

the class LocationSearchQueryTest method searchForLocations_shouldReturnCorrectLocationByCountry.

@Test
public void searchForLocations_shouldReturnCorrectLocationByCountry() {
    StringAndListParam country = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_COUNTRY)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COUNTRY_SEARCH_HANDLER, country);
    IBundleProvider locations = search(theParams);
    assertThat(locations, notNullValue());
    assertThat(locations.size(), equalTo(2));
    List<Location> resultList = get(locations);
    assertThat(resultList, hasSize(equalTo(2)));
    assertThat(resultList.get(0).getAddress().getCountry(), equalTo(LOCATION_COUNTRY));
}
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) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Location(org.hl7.fhir.r4.model.Location) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 25 with StringOrListParam

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

the class RelatedPersonSearchQueryTest method shouldReturnCollectionOfRelatedPeopleForMatchOnState.

@Test
public void shouldReturnCollectionOfRelatedPeopleForMatchOnState() {
    StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(STATE)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, stringAndListParam);
    IBundleProvider relationships = search(theParams);
    assertThat(relationships, notNullValue());
    assertThat(relationships.size(), equalTo(1));
    List<RelatedPerson> relationList = get(relationships);
    assertThat(relationList, hasSize(equalTo(1)));
    assertThat(relationList.get(0).getAddressFirstRep().getState(), equalTo(STATE));
}
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) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) 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