From da58e9f2502b0a465f866be8f3710913c26c1f4a Mon Sep 17 00:00:00 2001 From: VK-SMILECDR <88211153+VK-SMILECDR@users.noreply.github.com> Date: Mon, 11 Sep 2023 12:05:50 -0400 Subject: [PATCH] Add dao registry to cds config service (#5292) * add daoRegistry to CdsConfigService * add daoRegistry to CdsConfigService --- .../hapi/fhir/cdshooks/api/ICdsConfigService.java | 7 +++++++ .../hapi/fhir/cdshooks/config/CdsHooksConfig.java | 2 +- .../fhir/cdshooks/svc/CdsConfigServiceImpl.java | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/ICdsConfigService.java b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/ICdsConfigService.java index dc986cb5f15..78f74247e0d 100644 --- a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/ICdsConfigService.java +++ b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/api/ICdsConfigService.java @@ -20,9 +20,11 @@ package ca.uhn.hapi.fhir.cdshooks.api; import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import com.fasterxml.jackson.databind.ObjectMapper; import javax.annotation.Nonnull; +import javax.annotation.Nullable; public interface ICdsConfigService { @Nonnull @@ -30,4 +32,9 @@ public interface ICdsConfigService { @Nonnull ObjectMapper getObjectMapper(); + + @Nullable + default DaoRegistry getDaoRegistry() { + return null; + } } diff --git a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/config/CdsHooksConfig.java b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/config/CdsHooksConfig.java index 1e2306d4692..737a341f460 100644 --- a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/config/CdsHooksConfig.java +++ b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/config/CdsHooksConfig.java @@ -66,7 +66,7 @@ public class CdsHooksConfig { @Bean public ICdsConfigService cdsConfigService( FhirContext theFhirContext, @Qualifier(CDS_HOOKS_OBJECT_MAPPER_FACTORY) ObjectMapper theObjectMapper) { - return new CdsConfigServiceImpl(theFhirContext, theObjectMapper); + return new CdsConfigServiceImpl(theFhirContext, theObjectMapper, myDaoRegistry); } @Bean diff --git a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsConfigServiceImpl.java b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsConfigServiceImpl.java index a223a9cc510..c97b69f2760 100644 --- a/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsConfigServiceImpl.java +++ b/hapi-fhir-server-cds-hooks/src/main/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsConfigServiceImpl.java @@ -20,18 +20,25 @@ package ca.uhn.hapi.fhir.cdshooks.svc; import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.hapi.fhir.cdshooks.api.ICdsConfigService; import com.fasterxml.jackson.databind.ObjectMapper; import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class CdsConfigServiceImpl implements ICdsConfigService { private final FhirContext myFhirContext; private final ObjectMapper myObjectMapper; + private final DaoRegistry myDaoRegistry; - public CdsConfigServiceImpl(@Nonnull FhirContext theFhirContext, @Nonnull ObjectMapper theObjectMapper) { + public CdsConfigServiceImpl( + @Nonnull FhirContext theFhirContext, + @Nonnull ObjectMapper theObjectMapper, + @Nullable DaoRegistry theDaoRegistry) { myFhirContext = theFhirContext; myObjectMapper = theObjectMapper; + myDaoRegistry = theDaoRegistry; } @Nonnull @@ -45,4 +52,10 @@ public class CdsConfigServiceImpl implements ICdsConfigService { public ObjectMapper getObjectMapper() { return myObjectMapper; } + + @Nullable + @Override + public DaoRegistry getDaoRegistry() { + return myDaoRegistry; + } }