changelog
This commit is contained in:
parent
cdbe527456
commit
9e83f1d40a
|
@ -20,21 +20,20 @@ package ca.uhn.fhir.model.primitive;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||||
|
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||||
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
import org.apache.commons.lang3.time.FastDateFormat;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
|
||||||
import org.apache.commons.lang3.time.FastDateFormat;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
|
||||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
|
||||||
|
|
||||||
public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
||||||
static final long NANOS_PER_MILLIS = 1000000L;
|
static final long NANOS_PER_MILLIS = 1000000L;
|
||||||
|
@ -343,6 +342,10 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
||||||
throwBadDateFormat(value);
|
throwBadDateFormat(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value.equalsIgnoreCase("%now")) {
|
||||||
|
return new Date();
|
||||||
|
}
|
||||||
|
|
||||||
TemporalPrecisionEnum precision = null;
|
TemporalPrecisionEnum precision = null;
|
||||||
cal.set(Calendar.YEAR, parseInt(value, value.substring(0, 4), 0, 9999));
|
cal.set(Calendar.YEAR, parseInt(value, value.substring(0, 4), 0, 9999));
|
||||||
precision = TemporalPrecisionEnum.YEAR;
|
precision = TemporalPrecisionEnum.YEAR;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public abstract class BaseParamWithPrefix<T extends BaseParam> extends BaseParam
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
char nextChar = theString.charAt(offset);
|
char nextChar = theString.charAt(offset);
|
||||||
if (nextChar == '-' || Character.isDigit(nextChar)) {
|
if (nextChar == '-' || nextChar == '%' || Character.isDigit(nextChar)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ public class InMemoryResourceMatcherTest {
|
||||||
public static final String OBS_DATE = "1970-10-17";
|
public static final String OBS_DATE = "1970-10-17";
|
||||||
private static final String EARLY_DATE = "1965-08-09";
|
private static final String EARLY_DATE = "1965-08-09";
|
||||||
private static final String LATE_DATE = "2000-06-29";
|
private static final String LATE_DATE = "2000-06-29";
|
||||||
|
// FIXME KHS move this
|
||||||
|
private static final String NOW = "NOW";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private
|
private
|
||||||
|
@ -67,13 +69,6 @@ public class InMemoryResourceMatcherTest {
|
||||||
mySearchParams = extractDateSearchParam(myObservation);
|
mySearchParams = extractDateSearchParam(myObservation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourceIndexedSearchParams extractDateSearchParam(Observation theObservation) {
|
|
||||||
ResourceIndexedSearchParams retval = new ResourceIndexedSearchParams();
|
|
||||||
BaseDateTimeType dateValue = (BaseDateTimeType) theObservation.getEffective();
|
|
||||||
ResourceIndexedSearchParamDate dateParam = new ResourceIndexedSearchParamDate("date", dateValue.getValue(), dateValue.getValue(), dateValue.getValueAsString());
|
|
||||||
retval.myDateParams.add(dateParam);
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnsupportedOps() {
|
public void testUnsupportedOps() {
|
||||||
|
@ -115,7 +110,21 @@ public class InMemoryResourceMatcherTest {
|
||||||
assertTrue(result.getUnsupportedReason(), result.supported());
|
assertTrue(result.getUnsupportedReason(), result.supported());
|
||||||
assertEquals(result.matched(), theLater);
|
assertEquals(result.matched(), theLater);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNow() {
|
||||||
|
InMemoryMatchResult result = myInMemoryResourceMatcher.match("date=lt%now", myObservation, mySearchParams);
|
||||||
|
assertTrue(result.getUnsupportedReason(), result.supported());
|
||||||
|
assertTrue(result.matched());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ResourceIndexedSearchParams extractDateSearchParam(Observation theObservation) {
|
||||||
|
ResourceIndexedSearchParams retval = new ResourceIndexedSearchParams();
|
||||||
|
BaseDateTimeType dateValue = (BaseDateTimeType) theObservation.getEffective();
|
||||||
|
ResourceIndexedSearchParamDate dateParam = new ResourceIndexedSearchParamDate("date", dateValue.getValue(), dateValue.getValue(), dateValue.getValueAsString());
|
||||||
|
retval.myDateParams.add(dateParam);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,13 @@
|
||||||
the RequestValidatingInterceptor, but not including any HAPI FHIR security interceptors)
|
the RequestValidatingInterceptor, but not including any HAPI FHIR security interceptors)
|
||||||
could be bypassed if a Content Type was not included.
|
could be bypassed if a Content Type was not included.
|
||||||
</action>
|
</action>
|
||||||
|
<action type="add">
|
||||||
|
Added support for comparing resource dates to the current time via a new variable %now. E.g.
|
||||||
|
Procedure?date=gt%now would match future procedures.
|
||||||
|
</action>
|
||||||
|
<action type="add">
|
||||||
|
Add support for in-memory matching on date comparisons ge,gt,eq,lt,le.
|
||||||
|
</action>
|
||||||
</release>
|
</release>
|
||||||
<release version="4.0.1" date="2019-09-03" description="Igloo (Point Release)">
|
<release version="4.0.1" date="2019-09-03" description="Igloo (Point Release)">
|
||||||
<action type="fix">
|
<action type="fix">
|
||||||
|
|
Loading…
Reference in New Issue