From a1b6e37395746b006594ef144e2b33fab754feaf Mon Sep 17 00:00:00 2001 From: Gary Graham Date: Tue, 25 Feb 2020 17:03:50 -0500 Subject: [PATCH] Fix bug with Period bounds not counting as first value --- .../jpa/model/entity/ResourceIndexedSearchParamDate.java | 8 +++++--- .../searchparam/extractor/BaseSearchParamExtractor.java | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedSearchParamDate.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedSearchParamDate.java index 17d011d4e0c..d38f4dfe440 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedSearchParamDate.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedSearchParamDate.java @@ -102,9 +102,11 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar this.myValueHighDateOrdinal = generateOrdinalDateInteger(theHigh); } private int generateOrdinalDateInteger(String theDateString){ - String t = theDateString.substring(0, theDateString.indexOf("T")); - t = t.replace("-", ""); - return Integer.valueOf(t); + if (theDateString.contains("T")) { + theDateString = theDateString.substring(0, theDateString.indexOf("T")); + } + theDateString = theDateString.replace("-", ""); + return Integer.valueOf(theDateString); } private void computeValueLowDateOrdinal(String theLow) { diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java index d3b42491c51..eb44a8a0a7a 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java @@ -642,6 +642,10 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor String endString = extractValueAsString(myPeriodEndValueChild, bounds.get()); dates.add(start); dates.add(end); + //TODO Check if this logic is valid. Does the start of the first period indicate a lower bound?? + if (firstValue == null) { + firstValue = extractValueAsString(myPeriodStartValueChild, bounds.get()); + } finalValue = endString; } }