diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcher.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcher.java index 3b580a4e5f4e..60a951534e1e 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcher.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcher.java @@ -663,20 +663,9 @@ private boolean matchChainedReferenceParam( // Create new search parameter map to match the next resource SearchParameterMap searchParameterMap = new SearchParameterMap(); - if (resourceSearchParam.getParamType().equals(RestSearchParameterTypeEnum.REFERENCE)) { - searchParameterMap.add( - parameterName, new ReferenceParam(modifier, chain, referenceParam.getValue())); - } else { - TokenParam tokenParam; - if (referenceParam.getValue().contains("|")) { - String[] systemAndValue = referenceParam.getValue().split("\\|"); - tokenParam = new TokenParam(systemAndValue[0], systemAndValue[1]); - } else { - tokenParam = new TokenParam(referenceParam.getValue()); - } - tokenParam.setModifier(TokenParamModifier.forValue(":" + modifier)); - searchParameterMap.add(parameterName, tokenParam); - } + IQueryParameterType theParam = + convertReferenceParam(referenceParam, resourceSearchParam, modifier, chain); + searchParameterMap.add(parameterName, theParam); // Recursively match the chained resources return searchParamMatcher @@ -685,6 +674,25 @@ private boolean matchChainedReferenceParam( }); } + private static IQueryParameterType convertReferenceParam( + ReferenceParam referenceParam, RuntimeSearchParam resourceSearchParam, String modifier, String chain) { + if (resourceSearchParam.getParamType().equals(RestSearchParameterTypeEnum.REFERENCE)) { + return new ReferenceParam(modifier, chain, referenceParam.getValue()); + } else if (resourceSearchParam.getParamType().equals(RestSearchParameterTypeEnum.STRING)) { + return new StringParam(referenceParam.getValue(), "exact".equals(modifier)); + } else { + TokenParam tokenParam; + if (referenceParam.getValue().contains("|")) { + String[] systemAndValue = referenceParam.getValue().split("\\|"); + tokenParam = new TokenParam(systemAndValue[0], systemAndValue[1]); + } else { + tokenParam = new TokenParam(referenceParam.getValue()); + } + tokenParam.setModifier(TokenParamModifier.forValue(":" + modifier)); + return tokenParam; + } + } + private boolean systemContainsCode(TokenParam theQueryParam, ResourceIndexedSearchParamToken theSearchParamToken) { IValidationSupport validationSupport = getValidationSupportOrNull(); if (validationSupport == null) {