use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationAddressTranslatorImplTest method shouldTranslateAddressStateToLocationState.
@Test
public void shouldTranslateAddressStateToLocationState() {
org.hl7.fhir.r4.model.Address address = new Address();
address.setState(STATE_PROVINCE);
omrsLocation = translator.toOpenmrsType(new Location(), address);
assertThat(omrsLocation, notNullValue());
assertThat(omrsLocation.getStateProvince(), notNullValue());
assertThat(omrsLocation.getStateProvince(), equalTo(STATE_PROVINCE));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationTranslatorImplTest method shouldTranslateLocationAttributeToFhirContactPoint.
@Test
public void shouldTranslateLocationAttributeToFhirContactPoint() {
ContactPoint contactPoint = new ContactPoint();
contactPoint.setId(CONTACT_POINT_ID);
contactPoint.setValue(CONTACT_POINT_VALUE);
LocationAttribute locationAttribute = new LocationAttribute();
locationAttribute.setUuid(LOCATION_ATTRIBUTE_UUID);
locationAttribute.setValue(LOCATION_ATTRIBUTE_VALUE);
LocationAttributeType attributeType = new LocationAttributeType();
attributeType.setName(LOCATION_ATTRIBUTE_TYPE_NAME);
attributeType.setUuid(LOCATION_ATTRIBUTE_TYPE_UUID);
locationAttribute.setAttributeType(attributeType);
org.hl7.fhir.r4.model.Location location = locationTranslator.toFhirResource(new Location());
assertThat(location, notNullValue());
assertThat(location.getTelecom(), notNullValue());
}
use of org.hl7.fhir.r4.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)));
}
use of org.hl7.fhir.r4.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);
}
use of org.hl7.fhir.r4.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));
}
Aggregations