added search % now test

This commit is contained in:
Ken Stevens 2019-09-10 10:11:09 -04:00
parent 42a9672cc2
commit c974e9283b
2 changed files with 19 additions and 1 deletions

View File

@ -5,7 +5,11 @@ import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl;
import ca.uhn.fhir.jpa.util.TestUtil;
import ca.uhn.fhir.parser.StrictErrorHandler;
import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor;
import ca.uhn.fhir.util.UrlUtil;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.DateTimeType;
import org.hl7.fhir.r5.model.Observation;
import org.hl7.fhir.r5.model.Patient;
import org.junit.After;
import org.junit.AfterClass;
@ -84,6 +88,20 @@ public class ResourceProviderR5Test extends BaseResourceProviderR5Test {
}
@Test
public void testDateNowSyntax() {
Observation observation = new Observation();
observation.setEffective(new DateTimeType("1965-08-09"));
IIdType oid = myObservationDao.create(observation).getId().toUnqualified();
String nowParam = UrlUtil.escapeUrlParam("%now");
Bundle output = ourClient
.search()
.byUrl("Observation?date=lt" + nowParam)
.returnBundle(Bundle.class)
.execute();
List<IIdType> ids = output.getEntry().stream().map(t -> t.getResource().getIdElement().toUnqualified()).collect(Collectors.toList());
assertThat(ids, containsInAnyOrder(oid));
}
@AfterClass
public static void afterClassClearContext() {

View File

@ -30,7 +30,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@RunWith(SpringRunner.class)
public class InMemoryResourceMatcherTest {
public class InMemoryResourceMatcherR5Test {
public static final String OBSERVATION_DATE = "1970-10-17";
private static final String EARLY_DATE = "1965-08-09";
private static final String LATE_DATE = "2000-06-29";