Search in sources :

Example 11 with Location

use of com.ibm.watson.compare_comply.v1.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationSearchQueryTest method searchForLocations_shouldReturnCorrectLocationByParentCountry.

@Test
public void searchForLocations_shouldReturnCorrectLocationByParentCountry() {
    ReferenceAndListParam parentLocation = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(LOCATION_PARENT_COUNTRY).setChain("address-country")));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.LOCATION_REFERENCE_SEARCH_HANDLER, parentLocation);
    IBundleProvider locations = search(theParams);
    List<Location> resultList = get(locations);
    assertThat(locations, notNullValue());
    assertThat(resultList, hasSize(equalTo(1)));
    assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(LOCATION_UUID));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) 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 12 with Location

use of com.ibm.watson.compare_comply.v1.model.Location 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 13 with Location

use of com.ibm.watson.compare_comply.v1.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentPostalCode.

@Test
public void searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentPostalCode() {
    ReferenceAndListParam locationParentPostalCode = new ReferenceAndListParam();
    locationParentPostalCode.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue("234-30100").setChain(Location.SP_ADDRESS_POSTALCODE)));
    when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(Matchers.is(locationParentPostalCode)), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchLocations(null, null, null, null, null, null, locationParentPostalCode, null, null, null, null, null);
    assertThat(results, notNullValue());
    List<Location> resultList = get(results);
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 14 with Location

use of com.ibm.watson.compare_comply.v1.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method updateLocation_shouldThrowInvalidRequestExceptionForMissingId.

@Test(expected = InvalidRequestException.class)
public void updateLocation_shouldThrowInvalidRequestExceptionForMissingId() {
    Location noIdLocation = new Location();
    when(locationService.update(LOCATION_UUID, noIdLocation)).thenThrow(InvalidRequestException.class);
    resourceProvider.updateLocation(new IdType().setValue(LOCATION_UUID), noIdLocation);
}
Also used : Location(org.hl7.fhir.r4.model.Location) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 15 with Location

use of com.ibm.watson.compare_comply.v1.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method findLocationsByCountry_shouldReturnMatchingBundleOfLocations.

@Test
public void findLocationsByCountry_shouldReturnMatchingBundleOfLocations() {
    StringAndListParam countryParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
    when(locationService.searchForLocations(isNull(), isNull(), argThat(Matchers.is(countryParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchLocations(null, null, countryParam, null, 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(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getAddress().getCountry(), equalTo(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) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)120 Location (org.hl7.fhir.r4.model.Location)93 Location (org.hl7.fhir.dstu3.model.Location)66 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)59 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)42 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)30 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)27 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)21 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)20 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)20 StringParam (ca.uhn.fhir.rest.param.StringParam)20 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)16 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)16 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)16 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)16 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)13 Test (org.junit.jupiter.api.Test)13 ArrayList (java.util.ArrayList)11 HashSet (java.util.HashSet)11 TokenParam (ca.uhn.fhir.rest.param.TokenParam)10