4350 ap sa and eb prefixes are not handled correctly (#4358)

* Add test and implementation

* Add changelog
This commit is contained in:
Tadgh 2022-12-11 15:19:54 -08:00 committed by GitHub
parent 7747ebae41
commit daaa92fdbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 10 deletions

View File

@ -194,6 +194,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
break; break;
case GREATERTHAN: case GREATERTHAN:
case GREATERTHAN_OR_EQUALS: case GREATERTHAN_OR_EQUALS:
case STARTS_AFTER:
if (myLowerBound != null) { 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"); 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<DateParam> {
break; break;
case LESSTHAN: case LESSTHAN:
case LESSTHAN_OR_EQUALS: case LESSTHAN_OR_EQUALS:
case ENDS_BEFORE:
if (myUpperBound != null) { 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"); throw new InvalidRequestException(Msg.code(1924) + "Can not have multiple date range parameters for the same param that specify an upper bound");
} }

View File

@ -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."

View File

@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals; 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)); assertEquals(obsList.get(9).toString(), ids.get(8));
} }
@Test
public void test_eb_and_sa_modifiers() throws Exception {
List<IIdType> obsList = createObs(10, false, "2023-02-01");
String uri = myServerBase + "/Observation?date=eb2023-02-02";
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
assertEquals(10, ids.size());
uri = myServerBase + "/Observation?date=sa2023-01-31";
ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
assertEquals(10, ids.size());
}
@Test @Test
public void testSearch_SingleCode_multiple_not_modifier() throws Exception { public void testSearch_SingleCode_multiple_not_modifier() throws Exception {
@ -289,8 +304,7 @@ public class ResourceProviderSearchModifierR4Test extends BaseResourceProviderR4
return ids; return ids;
} }
private List<IIdType> createObs(int obsNum, boolean isMultiple) { private List<IIdType> createObs(int obsNum, boolean isMultiple, String effectiveDateString) {
Patient patient = new Patient(); Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001"); patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().setFamily("Tester").addGiven("Joe"); patient.addName().setFamily("Tester").addGiven("Joe");
@ -302,7 +316,7 @@ public class ResourceProviderSearchModifierR4Test extends BaseResourceProviderR4
Observation obs = new Observation(); Observation obs = new Observation();
obs.setStatus(ObservationStatus.FINAL); obs.setStatus(ObservationStatus.FINAL);
obs.getSubject().setReferenceElement(pid); obs.getSubject().setReferenceElement(pid);
obs.setEffective(new DateTimeType("2001-02-01")); obs.setEffective(new DateTimeType(effectiveDateString));
CodeableConcept cc = obs.getCode(); CodeableConcept cc = obs.getCode();
cc.addCoding().setCode("2345-"+i).setSystem("http://loinc.org"); cc.addCoding().setCode("2345-"+i).setSystem("http://loinc.org");
@ -320,4 +334,8 @@ public class ResourceProviderSearchModifierR4Test extends BaseResourceProviderR4
return obsIds; return obsIds;
} }
private List<IIdType> createObs(int obsNum, boolean isMultiple) {
return createObs(obsNum, isMultiple, "2001-02-01");
}
} }

View File

@ -32,6 +32,7 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -95,7 +96,7 @@ public abstract class BaseDateSearchDaoTests {
*/ */
@ParameterizedTest @ParameterizedTest
// use @CsvSource to debug individual cases. // 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") @MethodSource("dateSearchCases")
public void testDateSearchMatching(String theResourceDate, String theQuery, boolean theExpectedMatch, String theFileName, int theLineNumber) { public void testDateSearchMatching(String theResourceDate, String theQuery, boolean theExpectedMatch, String theFileName, int theLineNumber) {
if (isShouldSkip(theResourceDate, theQuery)) { if (isShouldSkip(theResourceDate, theQuery)) {

View File

@ -1,4 +1,8 @@
#ObservationDate, Query, Result, Comment (ignored) #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 2020,eq2020, True, A harmless comment
2021,eq2020, False 2021,eq2020, False
2020-01,eq2020, True 2020-01,eq2020, True
@ -19,7 +23,7 @@
2020-01-01,eq2020-01, True 2020-01-01,eq2020-01, True
2020-01-30,eq2020-01, True 2020-01-30,eq2020-01, True
2021-01-01,eq2020-01, False 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 2019-12-31T08:00:00.000,eq2020-01, False
2020-01-01T12:00:00.000Z,eq2020-01, True 2020-01-01T12:00:00.000Z,eq2020-01, True
2019-12-31T12:00:00.000Z,eq2020-01, False 2019-12-31T12:00:00.000Z,eq2020-01, False

1 #ObservationDate, Query, Result, Comment (ignored)
2 2020-01-01,eb2021-01-01, True, eb == ends-before
3 2020-01-01,eb2019-01-01, False, eb == ends-before
4 2020-01-01,sa2019-01-01, True, sa == starts-after
5 2020-01-01,sa2021-01-01, False, sa == starts-after
6 2020,eq2020, True, A harmless comment
7 2021,eq2020, False
8 2020-01,eq2020, True
23 2020-01-01,eq2020-01, True
24 2020-01-30,eq2020-01, True
25 2021-01-01,eq2020-01, False
26 2020-01-01T08:00:00.000,eq2020-01, True 2020-01-01T08:00:00.000,eq2020-01, True,
27 2019-12-31T08:00:00.000,eq2020-01, False
28 2020-01-01T12:00:00.000Z,eq2020-01, True
29 2019-12-31T12:00:00.000Z,eq2020-01, False