no distance and zero distance tested

This commit is contained in:
Ken Stevens 2020-01-21 16:18:42 -05:00
parent 992b62151b
commit 04b60a4a16
2 changed files with 26 additions and 11 deletions

View File

@ -468,12 +468,6 @@ public class SearchBuilder implements ISearchBuilder {
String theParamName,
List<? extends IQueryParameterType> theList,
SearchFilterParser.CompareOperation operation) {
// FIXME KHS
if ("Location".equals(theResourceName) && Location.SP_NEAR_DISTANCE.equals(theParamName)) {
return null;
}
Join<ResourceTable, ResourceIndexedSearchParamQuantity> join = createJoin(JoinEnum.QUANTITY, theParamName);
if (theList.get(0).getMissing() != null) {
@ -2121,7 +2115,7 @@ public class SearchBuilder implements ISearchBuilder {
QuantityParam distanceParam = myParams.getNearDistanceParam();
Predicate latitudePredicate;
Predicate longitudePredicate;
if (distanceParam == null) {
if (distanceParam == null || distanceParam.getValue().doubleValue() == 0.0) {
latitudePredicate = theBuilder.equal(theFrom.get("myLatitude"), latitudeValue);
longitudePredicate = theBuilder.equal(theFrom.get("myLongitude"), longitudeValue);
} else {

View File

@ -3473,7 +3473,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
}
@Test
public void testNearSearchExact() {
public void testNearSearchDistanceNoDistance() {
Location loc = new Location();
double latitude = 1000.0;
double longitude = 2000.0;
@ -3481,9 +3481,30 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
loc.setPosition(position);
String locId = myLocationDao.create(loc).getId().toUnqualifiedVersionless().getValue();
SearchParameterMap map = new SearchParameterMap();
map.add(Location.SP_NEAR, new TokenParam(latitude + ":" + longitude));
map.add(Location.SP_NEAR_DISTANCE, new QuantityParam(0L));
SearchParameterMap map = myMatchUrlService.translateMatchUrl(
"Location?" +
Location.SP_NEAR + "=" + latitude + ":" + longitude,
myFhirCtx.getResourceDefinition("Location"));
List<String> ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map));
assertThat(ids, contains(locId));
}
@Test
public void testNearSearchDistanceZero() {
Location loc = new Location();
double latitude = 1000.0;
double longitude = 2000.0;
Location.LocationPositionComponent position = new Location.LocationPositionComponent().setLatitude(latitude).setLongitude(longitude);
loc.setPosition(position);
String locId = myLocationDao.create(loc).getId().toUnqualifiedVersionless().getValue();
SearchParameterMap map = myMatchUrlService.translateMatchUrl(
"Location?" +
Location.SP_NEAR + "=" + latitude + ":" + longitude +
"&" +
Location.SP_NEAR_DISTANCE + "=0||",
myFhirCtx.getResourceDefinition("Location"));
List<String> ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map));
assertThat(ids, contains(locId));