diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java index 771f75bbaf1..8dcbda74c4e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java @@ -3484,6 +3484,25 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { assertThat(ids, contains(locId)); } + @Test + public void testNearSearchNear() { + Location loc = new Location(); + double latitude = 1000.0; + double longitude = 2000.0; + double offset = 50.0; + Location.LocationPositionComponent position = new Location.LocationPositionComponent().setLatitude(latitude).setLongitude(longitude); + loc.setPosition(position); + String locId = myLocationDao.create(loc).getId().toUnqualifiedVersionless().getValue(); + + SearchParameterMap map = new SearchParameterMap(); + map.add(Location.SP_NEAR, new TokenParam((latitude + offset) + ":" + (longitude - offset))); + QuantityParam distance = new QuantityParam(ParamPrefixEnum.LESSTHAN_OR_EQUALS, offset * 2, "http://unitsofmeasure.org", "km"); + map.add(Location.SP_NEAR_DISTANCE, distance); + + List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); + assertThat(ids, contains(locId)); + } + private String toStringMultiline(List theResults) { StringBuilder b = new StringBuilder(); for (Object next : theResults) {