From 4a33a01b78d21b2519a9d39f2390153302e00bda Mon Sep 17 00:00:00 2001 From: Melih Aydogdu Date: Thu, 27 Jun 2024 13:58:36 +0200 Subject: [PATCH] string param support added --- .../matcher/InMemoryResourceMatcher.java | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) 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) {