diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/DateRangeParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/DateRangeParam.java index 0dbc92416dd..0d6e0bd655f 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/DateRangeParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/DateRangeParam.java @@ -194,6 +194,7 @@ public class DateRangeParam implements IQueryParameterAnd { break; case GREATERTHAN: case GREATERTHAN_OR_EQUALS: + case STARTS_AFTER: if (myLowerBound != null) { throw new InvalidRequestException(Msg.code(1923) + "Can not have multiple date range parameters for the same param that specify a lower bound"); } @@ -201,6 +202,7 @@ public class DateRangeParam implements IQueryParameterAnd { break; case LESSTHAN: case LESSTHAN_OR_EQUALS: + case ENDS_BEFORE: if (myUpperBound != null) { throw new InvalidRequestException(Msg.code(1924) + "Can not have multiple date range parameters for the same param that specify an upper bound"); } diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4350-eb-sa-modifiers.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4350-eb-sa-modifiers.yaml new file mode 100644 index 00000000000..54f3235e5d4 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4350-eb-sa-modifiers.yaml @@ -0,0 +1,4 @@ +--- +type: fix +issue: 4350 +title: "Support was accidentally removed for date `sa` and `eb` modifiers in the `date` type search parameters. This has been corrected." diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java index 333bdcf0c0c..999dd5e45d3 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Date; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -90,6 +91,20 @@ public class ResourceProviderSearchModifierR4Test extends BaseResourceProviderR4 assertEquals(obsList.get(9).toString(), ids.get(8)); } + @Test + public void test_eb_and_sa_modifiers() throws Exception { + List obsList = createObs(10, false, "2023-02-01"); + + String uri = myServerBase + "/Observation?date=eb2023-02-02"; + List ids = searchAndReturnUnqualifiedVersionlessIdValues(uri); + + assertEquals(10, ids.size()); + + uri = myServerBase + "/Observation?date=sa2023-01-31"; + ids = searchAndReturnUnqualifiedVersionlessIdValues(uri); + assertEquals(10, ids.size()); + } + @Test public void testSearch_SingleCode_multiple_not_modifier() throws Exception { @@ -289,35 +304,38 @@ public class ResourceProviderSearchModifierR4Test extends BaseResourceProviderR4 return ids; } - private List createObs(int obsNum, boolean isMultiple) { - + private List createObs(int obsNum, boolean isMultiple, String effectiveDateString) { Patient patient = new Patient(); patient.addIdentifier().setSystem("urn:system").setValue("001"); patient.addName().setFamily("Tester").addGiven("Joe"); IIdType pid = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless(); - + List obsIds = new ArrayList<>(); IIdType obsId = null; for (int i=0; i createObs(int obsNum, boolean isMultiple) { + return createObs(obsNum, isMultiple, "2001-02-01"); + } + } diff --git a/hapi-fhir-storage-test-utilities/src/main/java/ca/uhn/fhir/storage/test/BaseDateSearchDaoTests.java b/hapi-fhir-storage-test-utilities/src/main/java/ca/uhn/fhir/storage/test/BaseDateSearchDaoTests.java index 49b10c328bc..4098bd2acac 100644 --- a/hapi-fhir-storage-test-utilities/src/main/java/ca/uhn/fhir/storage/test/BaseDateSearchDaoTests.java +++ b/hapi-fhir-storage-test-utilities/src/main/java/ca/uhn/fhir/storage/test/BaseDateSearchDaoTests.java @@ -32,6 +32,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.MethodSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -95,7 +96,7 @@ public abstract class BaseDateSearchDaoTests { */ @ParameterizedTest // use @CsvSource to debug individual cases. - //@CsvSource("2019-12-31T08:00:00,eq2020,false,inline,1") +// @CsvSource("2020-01-01,eb2021-01-01, True, eb == ends-before") @MethodSource("dateSearchCases") public void testDateSearchMatching(String theResourceDate, String theQuery, boolean theExpectedMatch, String theFileName, int theLineNumber) { if (isShouldSkip(theResourceDate, theQuery)) { diff --git a/hapi-fhir-test-utilities/src/main/resources/ca/uhn/fhir/jpa/conformance/DateSearchTestCase.csv b/hapi-fhir-test-utilities/src/main/resources/ca/uhn/fhir/jpa/conformance/DateSearchTestCase.csv index 8ce90384885..6ec62b8b76e 100644 --- a/hapi-fhir-test-utilities/src/main/resources/ca/uhn/fhir/jpa/conformance/DateSearchTestCase.csv +++ b/hapi-fhir-test-utilities/src/main/resources/ca/uhn/fhir/jpa/conformance/DateSearchTestCase.csv @@ -1,4 +1,8 @@ #ObservationDate, Query, Result, Comment (ignored) +2020-01-01,eb2021-01-01, True, eb == ends-before +2020-01-01,eb2019-01-01, False, eb == ends-before +2020-01-01,sa2019-01-01, True, sa == starts-after +2020-01-01,sa2021-01-01, False, sa == starts-after 2020,eq2020, True, A harmless comment 2021,eq2020, False 2020-01,eq2020, True @@ -19,7 +23,7 @@ 2020-01-01,eq2020-01, True 2020-01-30,eq2020-01, True 2021-01-01,eq2020-01, False -2020-01-01T08:00:00.000,eq2020-01, True +2020-01-01T08:00:00.000,eq2020-01, True, 2019-12-31T08:00:00.000,eq2020-01, False 2020-01-01T12:00:00.000Z,eq2020-01, True 2019-12-31T12:00:00.000Z,eq2020-01, False