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; } }