Add precision checker for ordinal date returning on DateRangeParam
This commit is contained in:
parent
f86a4c9fa1
commit
b1d7072c42
|
@ -272,7 +272,27 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
|||
if (myLowerBound == null || myLowerBound.getValue() == null) {
|
||||
return null;
|
||||
}
|
||||
return DateUtils.convertDatetoDayInteger(myLowerBound.getValue());
|
||||
//TODO LOOK AT THE DATE VERSION, WHERE PRECISION OCCASIONALLY CHANGES THE STUPID THING. ESSENTIALLY ADD A SWITCH
|
||||
int retVal = DateUtils.convertDatetoDayInteger(myLowerBound.getValue());
|
||||
|
||||
if (myLowerBound.getPrefix() != null) {
|
||||
switch (myLowerBound.getPrefix()) {
|
||||
case GREATERTHAN:
|
||||
case STARTS_AFTER:
|
||||
retVal += 1;
|
||||
break;
|
||||
case EQUAL:
|
||||
case GREATERTHAN_OR_EQUALS:
|
||||
break;
|
||||
case LESSTHAN:
|
||||
case APPROXIMATE:
|
||||
case LESSTHAN_OR_EQUALS:
|
||||
case ENDS_BEFORE:
|
||||
case NOT_EQUAL:
|
||||
throw new IllegalStateException("Invalid lower bound comparator: " + myLowerBound.getPrefix());
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -284,7 +304,25 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
|||
if (myUpperBound == null || myUpperBound.getValue() == null) {
|
||||
return null;
|
||||
}
|
||||
return DateUtils.convertDatetoDayInteger(myUpperBound.getValue());
|
||||
int retVal = DateUtils.convertDatetoDayInteger(myUpperBound.getValue());
|
||||
if (myUpperBound.getPrefix() != null) {
|
||||
switch (myUpperBound.getPrefix()) {
|
||||
case LESSTHAN:
|
||||
case ENDS_BEFORE:
|
||||
retVal -= 1;
|
||||
break;
|
||||
case EQUAL:
|
||||
case LESSTHAN_OR_EQUALS:
|
||||
break;
|
||||
case GREATERTHAN_OR_EQUALS:
|
||||
case GREATERTHAN:
|
||||
case APPROXIMATE:
|
||||
case NOT_EQUAL:
|
||||
case STARTS_AFTER:
|
||||
throw new IllegalStateException("Invalid upper bound comparator: " + myUpperBound.getPrefix());
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public Date getLowerBoundAsInstant() {
|
||||
|
|
|
@ -250,6 +250,7 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
|||
boolean result;
|
||||
if (theUseOrdinalDatesForDayComparison) {
|
||||
result = matchesOrdinalDateBounds(range);
|
||||
result = matchesDateBounds(range);
|
||||
} else {
|
||||
result = matchesDateBounds(range);
|
||||
}
|
||||
|
@ -284,6 +285,7 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
|||
return false;
|
||||
}
|
||||
if (lowerBoundAsDateInteger != null) {
|
||||
//TODO as we run into equality issues
|
||||
result &= (myValueLowDateOrdinal.equals(lowerBoundAsDateInteger) || myValueLowDateOrdinal > lowerBoundAsDateInteger);
|
||||
result &= (myValueHighDateOrdinal.equals(lowerBoundAsDateInteger) || myValueHighDateOrdinal > lowerBoundAsDateInteger);
|
||||
}
|
||||
|
|
|
@ -148,8 +148,8 @@ public class InMemoryResourceMatcherR5Test {
|
|||
|
||||
@Test
|
||||
public void testDateSupportedOps() {
|
||||
testDateSupportedOp(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, true, true, false);
|
||||
testDateSupportedOp(ParamPrefixEnum.GREATERTHAN, true, false, false);
|
||||
testDateSupportedOp(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, true, true, false);
|
||||
testDateSupportedOp(ParamPrefixEnum.EQUAL, false, true, false);
|
||||
testDateSupportedOp(ParamPrefixEnum.LESSTHAN_OR_EQUALS, false, true, true);
|
||||
testDateSupportedOp(ParamPrefixEnum.LESSTHAN, false, false, true);
|
||||
|
@ -165,7 +165,7 @@ public class InMemoryResourceMatcherR5Test {
|
|||
{
|
||||
InMemoryMatchResult result = myInMemoryResourceMatcher.match(equation + OBSERVATION_DATE, myObservation, mySearchParams);
|
||||
assertTrue(result.getUnsupportedReason(), result.supported());
|
||||
assertEquals(result.matched(), theSame);
|
||||
assertEquals(theSame, result.matched());
|
||||
}
|
||||
{
|
||||
InMemoryMatchResult result = myInMemoryResourceMatcher.match(equation + LATE_DATE, myObservation, mySearchParams);
|
||||
|
|
Loading…
Reference in New Issue