diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/fhirpath/IFhirPathEvaluationContext.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/fhirpath/IFhirPathEvaluationContext.java index 5dc55a24d396..b492a042817a 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/fhirpath/IFhirPathEvaluationContext.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/fhirpath/IFhirPathEvaluationContext.java @@ -46,5 +46,7 @@ default IBase resolveReference(@Nonnull IIdType theReference, @Nullable IBase th * @param beforeContext * @return */ - default List resolveConstant(Object appContext, String name, boolean beforeContext) {return null; } + default List resolveConstant(Object appContext, String name, boolean beforeContext) { + return null; + } } diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicConfig.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicConfig.java index 802f43a47e56..3b5225246c0a 100644 --- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicConfig.java +++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicConfig.java @@ -24,6 +24,7 @@ import ca.uhn.fhir.jpa.searchparam.matcher.SearchParamMatcher; import ca.uhn.fhir.jpa.subscription.config.SubscriptionConfig; import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubscriptionQueryValidator; +import ca.uhn.fhir.jpa.util.MemoryCacheService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -33,11 +34,12 @@ @Import(SubscriptionConfig.class) public class SubscriptionTopicConfig { @Bean - SubscriptionTopicMatchingSubscriber subscriptionTopicMatchingSubscriber(FhirContext theFhirContext) { + SubscriptionTopicMatchingSubscriber subscriptionTopicMatchingSubscriber( + FhirContext theFhirContext, MemoryCacheService memoryCacheService) { switch (theFhirContext.getVersion().getVersion()) { case R5: case R4B: - return new SubscriptionTopicMatchingSubscriber(theFhirContext); + return new SubscriptionTopicMatchingSubscriber(theFhirContext, memoryCacheService); default: return null; } diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicMatcher.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicMatcher.java index 93bfe7c03466..77ba9bbd8bb5 100644 --- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicMatcher.java +++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicMatcher.java @@ -21,6 +21,7 @@ import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult; import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage; +import ca.uhn.fhir.jpa.util.MemoryCacheService; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r5.model.SubscriptionTopic; @@ -29,10 +30,15 @@ public class SubscriptionTopicMatcher { private final SubscriptionTopicSupport mySubscriptionTopicSupport; private final SubscriptionTopic myTopic; + private final MemoryCacheService myMemoryCacheService; - public SubscriptionTopicMatcher(SubscriptionTopicSupport theSubscriptionTopicSupport, SubscriptionTopic theTopic) { + public SubscriptionTopicMatcher( + SubscriptionTopicSupport theSubscriptionTopicSupport, + SubscriptionTopic theTopic, + MemoryCacheService memoryCacheService) { mySubscriptionTopicSupport = theSubscriptionTopicSupport; myTopic = theTopic; + myMemoryCacheService = memoryCacheService; } public InMemoryMatchResult match(ResourceModifiedMessage theMsg) { @@ -43,7 +49,7 @@ public InMemoryMatchResult match(ResourceModifiedMessage theMsg) { for (SubscriptionTopic.SubscriptionTopicResourceTriggerComponent next : triggers) { if (resourceName.equals(next.getResource())) { SubscriptionTriggerMatcher matcher = - new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, theMsg, next); + new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, theMsg, next, myMemoryCacheService); InMemoryMatchResult result = matcher.match(); if (result.matched()) { // as soon as one trigger matches, we're done diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicMatchingSubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicMatchingSubscriber.java index c1776bf29834..67151db08ec2 100644 --- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicMatchingSubscriber.java +++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTopicMatchingSubscriber.java @@ -27,6 +27,7 @@ import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage; import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage; import ca.uhn.fhir.jpa.topic.filter.InMemoryTopicFilterMatcher; +import ca.uhn.fhir.jpa.util.MemoryCacheService; import ca.uhn.fhir.rest.api.RestOperationTypeEnum; import ca.uhn.fhir.subscription.api.IResourceModifiedMessagePersistenceSvc; import ca.uhn.fhir.util.Logs; @@ -67,8 +68,11 @@ public class SubscriptionTopicMatchingSubscriber implements MessageHandler { @Autowired private IResourceModifiedMessagePersistenceSvc myResourceModifiedMessagePersistenceSvc; - public SubscriptionTopicMatchingSubscriber(FhirContext theFhirContext) { + private MemoryCacheService myMemoryCacheService; + + public SubscriptionTopicMatchingSubscriber(FhirContext theFhirContext, MemoryCacheService memoryCacheService) { myFhirContext = theFhirContext; + this.myMemoryCacheService = memoryCacheService; } @Override @@ -110,7 +114,8 @@ private void matchActiveSubscriptionTopicsAndDeliver(ResourceModifiedMessage the Collection topics = mySubscriptionTopicRegistry.getAll(); for (SubscriptionTopic topic : topics) { - SubscriptionTopicMatcher matcher = new SubscriptionTopicMatcher(mySubscriptionTopicSupport, topic); + SubscriptionTopicMatcher matcher = + new SubscriptionTopicMatcher(mySubscriptionTopicSupport, topic, myMemoryCacheService); InMemoryMatchResult result = matcher.match(theMsg); if (result.matched()) { int deliveries = deliverToTopicSubscriptions(theMsg, topic, result); diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTriggerMatcher.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTriggerMatcher.java index b6f3eb3087e3..8f61a1cbc18f 100644 --- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTriggerMatcher.java +++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTriggerMatcher.java @@ -24,6 +24,7 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult; import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage; +import ca.uhn.fhir.jpa.util.MemoryCacheService; import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.server.messaging.BaseResourceMessage; import ca.uhn.fhir.storage.PreviousVersionReader; @@ -50,11 +51,13 @@ public class SubscriptionTriggerMatcher { private final IFhirResourceDao myDao; private final PreviousVersionReader myPreviousVersionReader; private final SystemRequestDetails mySrd; + private final MemoryCacheService myMemoryCacheService; public SubscriptionTriggerMatcher( SubscriptionTopicSupport theSubscriptionTopicSupport, ResourceModifiedMessage theMsg, - SubscriptionTopic.SubscriptionTopicResourceTriggerComponent theTrigger) { + SubscriptionTopic.SubscriptionTopicResourceTriggerComponent theTrigger, + MemoryCacheService theMemoryCacheService) { mySubscriptionTopicSupport = theSubscriptionTopicSupport; myOperation = theMsg.getOperationType(); myResource = theMsg.getPayload(theSubscriptionTopicSupport.getFhirContext()); @@ -63,6 +66,7 @@ public SubscriptionTriggerMatcher( myTrigger = theTrigger; myPreviousVersionReader = new PreviousVersionReader(myDao); mySrd = new SystemRequestDetails(); + myMemoryCacheService = theMemoryCacheService; } public InMemoryMatchResult match() { @@ -114,39 +118,51 @@ private InMemoryMatchResult match( } // WIP STR5 implement resultForCreate and resultForDelete if (theQueryCriteria.getRequireBoth()) { - return InMemoryMatchResult.and(InMemoryMatchResult.and(previousMatches, currentMatches), fhirPathCriteriaEvaluationResult); + return InMemoryMatchResult.and( + InMemoryMatchResult.and(previousMatches, currentMatches), fhirPathCriteriaEvaluationResult); } else { - return InMemoryMatchResult.and(InMemoryMatchResult.or(previousMatches, currentMatches), fhirPathCriteriaEvaluationResult); + return InMemoryMatchResult.and( + InMemoryMatchResult.or(previousMatches, currentMatches), fhirPathCriteriaEvaluationResult); } } - private InMemoryMatchResult evaluateFhirPathCriteria(String theFhirPathCriteria) { if (!Strings.isNullOrEmpty(theFhirPathCriteria)) { - IFhirPath fhirPathEngine = mySubscriptionTopicSupport.getFhirContext().newFhirPath(); - fhirPathEngine.setEvaluationContext(new IFhirPathEvaluationContext(){ + IFhirPath fhirPathEngine = + mySubscriptionTopicSupport.getFhirContext().newFhirPath(); + fhirPathEngine.setEvaluationContext(new IFhirPathEvaluationContext() { @Override public List resolveConstant(Object appContext, String name, boolean beforeContext) { - if("current".equalsIgnoreCase(name)) - return List.of(myResource); + if ("current".equalsIgnoreCase(name)) return List.of(myResource); - if("previous".equalsIgnoreCase(name)) - { + if ("previous".equalsIgnoreCase(name)) { Optional previousResource = myPreviousVersionReader.readPreviousVersion(myResource); - if(previousResource.isPresent()) - return List.of((IBase) previousResource.get()); + if (previousResource.isPresent()) return List.of((IBase) previousResource.get()); } return null; } }); try { - IFhirPath.IParsedExpression expression = fhirPathEngine.parse(theFhirPathCriteria); + IFhirPath.IParsedExpression expression = myMemoryCacheService.get( + MemoryCacheService.CacheEnum.FHIRPATH_EXPRESSION, theFhirPathCriteria, exp -> { + try { + return fhirPathEngine.parse(exp); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + List result = fhirPathEngine.evaluate(myResource, expression, IBase.class); - return InMemoryMatchResult.fromBoolean( result != null && result.size() == 1 && ((BooleanType)result.get(0)).booleanValue()); + return InMemoryMatchResult.fromBoolean( + result != null && result.size() == 1 && ((BooleanType) result.get(0)).booleanValue()); } catch (Exception e) { - ourLog.warn("Subscription topic {} has a fhirPathCriteria that is not valid: {}", myTrigger.getId(), theFhirPathCriteria, e); + ourLog.warn( + "Subscription topic {} has a fhirPathCriteria that is not valid: {}", + myTrigger.getId(), + theFhirPathCriteria, + e); return InMemoryMatchResult.unsupportedFromReason(e.getMessage()); } } diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/topic/SubscriptionTriggerMatcherTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/topic/SubscriptionTriggerMatcherTest.java index 200f9afb5f2a..40e3d6197cd1 100644 --- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/topic/SubscriptionTriggerMatcherTest.java +++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/topic/SubscriptionTriggerMatcherTest.java @@ -1,11 +1,13 @@ package ca.uhn.fhir.jpa.topic; import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult; import ca.uhn.fhir.jpa.searchparam.matcher.SearchParamMatcher; import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage; +import ca.uhn.fhir.jpa.util.MemoryCacheService; import org.hl7.fhir.r5.model.Encounter; import org.hl7.fhir.r5.model.Enumerations; import org.hl7.fhir.r5.model.IdType; @@ -32,11 +34,14 @@ class SubscriptionTriggerMatcherTest { @Mock SearchParamMatcher mySearchParamMatcher; + MemoryCacheService myMemoryCacheService; + private SubscriptionTopicSupport mySubscriptionTopicSupport; private Encounter myEncounter; @BeforeEach public void before() { + myMemoryCacheService = new MemoryCacheService(new JpaStorageSettings()); mySubscriptionTopicSupport = new SubscriptionTopicSupport(ourFhirContext, myDaoRegistry, mySearchParamMatcher); myEncounter = new Encounter(); myEncounter.setIdElement(new IdType("Encounter", "123", "2")); @@ -50,7 +55,7 @@ public void testCreateEmptryTriggerNoMatch() { SubscriptionTopic.SubscriptionTopicResourceTriggerComponent trigger = new SubscriptionTopic.SubscriptionTopicResourceTriggerComponent(); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -67,7 +72,7 @@ public void testCreateSimpleTriggerMatches() { trigger.addSupportedInteraction(SubscriptionTopic.InteractionTrigger.CREATE); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -84,7 +89,7 @@ public void testCreateWrongOpNoMatch() { trigger.addSupportedInteraction(SubscriptionTopic.InteractionTrigger.UPDATE); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -101,7 +106,7 @@ public void testUpdateMatch() { trigger.addSupportedInteraction(SubscriptionTopic.InteractionTrigger.UPDATE); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -126,7 +131,7 @@ public void testUpdateWithPrevCriteriaMatch() { when(mySearchParamMatcher.match(any(), any(), any())).thenReturn(InMemoryMatchResult.successfulMatch()); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -144,7 +149,7 @@ public void testFalseFhirPathCriteriaEvaluation() { trigger.setFhirPathCriteria("false"); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -162,7 +167,7 @@ public void testInvalidFhirPathCriteriaEvaluation() { trigger.setFhirPathCriteria("random text"); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -180,7 +185,7 @@ public void testInvalidBooleanOutcomeOfFhirPathCriteriaEvaluation() { trigger.setFhirPathCriteria("id"); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -198,7 +203,7 @@ public void testValidFhirPathCriteriaEvaluation() { trigger.setFhirPathCriteria("id = " + myEncounter.getIdElement().getIdPart()); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -216,7 +221,7 @@ public void testValidFhirPathCriteriaEvaluationUsingCurrent() { trigger.setFhirPathCriteria("%current.id = " + myEncounter.getIdElement().getIdPart()); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -234,7 +239,7 @@ public void testValidFhirPathCriteriaEvaluationReturningNonBoolean() { trigger.setFhirPathCriteria("%current.id"); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -257,7 +262,7 @@ public void testValidFhirPathReturningCollection() { when(mockEncounterDao.read(any(), any(), eq(false))).thenReturn(encounterPreviousVersion); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -283,7 +288,7 @@ public void testUpdateWithPrevCriteriaMatchAndFailingFhirPathCriteria() { when(mySearchParamMatcher.match(any(), any(), any())).thenReturn(InMemoryMatchResult.successfulMatch()); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -310,7 +315,7 @@ public void testUpdateWithPrevCriteriaMatchAndFhirPathCriteriaUsingPreviousVersi when(mySearchParamMatcher.match(any(), any(), any())).thenReturn(InMemoryMatchResult.successfulMatch()); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); // verify @@ -335,10 +340,37 @@ public void testUpdateOnlyFhirPathCriteriaUsingPreviousVersion() { when(mockEncounterDao.read(any(), any(), eq(false))).thenReturn(encounterPreviousVersion); // run - SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger); + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); + InMemoryMatchResult result = svc.match(); + + // verify + assertTrue(result.matched()); + } + + @Test + public void testCacheUsage() { + myEncounter.setStatus(Enumerations.EncounterStatus.INPROGRESS); + ResourceModifiedMessage msg = new ResourceModifiedMessage(ourFhirContext, myEncounter, ResourceModifiedMessage.OperationTypeEnum.UPDATE); + + // setup + SubscriptionTopic.SubscriptionTopicResourceTriggerComponent trigger = new SubscriptionTopic.SubscriptionTopicResourceTriggerComponent(); + trigger.setResource("Encounter"); + trigger.addSupportedInteraction(SubscriptionTopic.InteractionTrigger.UPDATE); + String fhirPathCriteria = "%current.status='in-progress'"; + trigger.setFhirPathCriteria(fhirPathCriteria); + + + IFhirResourceDao mockEncounterDao = mock(IFhirResourceDao.class); + when(myDaoRegistry.getResourceDao("Encounter")).thenReturn(mockEncounterDao); + + assertFalse(myMemoryCacheService.getIfPresent(MemoryCacheService.CacheEnum.FHIRPATH_EXPRESSION, fhirPathCriteria)); + // run + SubscriptionTriggerMatcher svc = new SubscriptionTriggerMatcher(mySubscriptionTopicSupport, msg, trigger, myMemoryCacheService); InMemoryMatchResult result = svc.match(); + // verify assertTrue(result.matched()); + assertTrue(myMemoryCacheService.getIfPresent(MemoryCacheService.CacheEnum.FHIRPATH_EXPRESSION, fhirPathCriteria) != null); } } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/util/MemoryCacheService.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/util/MemoryCacheService.java index dbe59938f7ea..8df91adfa239 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/util/MemoryCacheService.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/util/MemoryCacheService.java @@ -77,6 +77,7 @@ private void populateCaches() { case HISTORY_COUNT: case TAG_DEFINITION: case RESOURCE_CONDITIONAL_CREATE_VERSION: + case FHIRPATH_EXPRESSION: default: timeoutSeconds = SECONDS.convert(1, MINUTES); maximumSize = 10000; @@ -193,6 +194,7 @@ public enum CacheEnum { TAG_DEFINITION(TagDefinitionCacheKey.class), RESOURCE_LOOKUP(String.class), FORCED_ID_TO_PID(String.class), + FHIRPATH_EXPRESSION(String.class), /** * Key type: {@literal Long} * Value type: {@literal Optional} diff --git a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/fhirpath/FhirPathR5.java b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/fhirpath/FhirPathR5.java index 5f0efdf11fc6..6c7f950aa86f 100644 --- a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/fhirpath/FhirPathR5.java +++ b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/fhirpath/FhirPathR5.java @@ -95,7 +95,9 @@ public void setEvaluationContext(@Nonnull IFhirPathEvaluationContext theEvaluati @Override public List resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException { - return theEvaluationContext.resolveConstant(appContext, name, beforeContext).stream().map(Base.class::cast).collect(Collectors.toUnmodifiableList()); + return theEvaluationContext.resolveConstant(appContext, name, beforeContext).stream() + .map(Base.class::cast) + .collect(Collectors.toUnmodifiableList()); } @Override