Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
87d9743
WIP
Capt-Mac Jul 13, 2023
04d106d
WIP
Capt-Mac Jul 13, 2023
5a971dd
WIP refactor
Capt-Mac Jul 14, 2023
3e7d240
Initial commit
barhodes Jul 20, 2023
3db25ec
measureRefactor WIP
Capt-Mac Jul 21, 2023
902df2d
version bump
tadgh Jul 21, 2023
9a996ce
Bump to core release 6.0.22 (#5028)
dotasek Jul 24, 2023
8133598
adding tests WIP
Capt-Mac Jul 24, 2023
4c449b9
Rework MeasureServiceFActory
JPercival Jul 24, 2023
d08ac31
measure refactor WIP
Capt-Mac Jul 25, 2023
7dcf085
merge master fixes
Capt-Mac Jul 25, 2023
1697783
Resolve 5126 hfj res ver prov might cause migration error on db that …
TynerGjs Jul 26, 2023
ecf26ee
generic provider loader
Capt-Mac Jul 26, 2023
3afc2d0
provider loader update
Capt-Mac Jul 26, 2023
49716a7
tests wip
Capt-Mac Jul 26, 2023
ff507cd
5123 - Use DEFAULT partition for server-based requests if none specif…
steve-corbett-smilecdr Jul 27, 2023
4820759
consent remove all suppresses next link in bundle (#5119)
fil512 Jul 27, 2023
e077393
5117 MDM Score for No Match Fields Should Not Be Included in Total Sc…
jdar8 Jul 27, 2023
0bd5b53
Merge branch 'master' into br-20230720-add-cds-on-fhir
barhodes Jul 28, 2023
d24f0d5
measureRefactor tests WIP
Capt-Mac Jul 28, 2023
7a1416f
update tests wip
Capt-Mac Jul 28, 2023
0b3992b
remove baseCrR4Test
Capt-Mac Jul 28, 2023
3f475af
update imports
Capt-Mac Jul 28, 2023
864ff08
add paging provider config to tests
Capt-Mac Jul 28, 2023
992f7ac
dstu3 tests
Capt-Mac Jul 28, 2023
aa652a5
Merge branch 'master' into br-20230720-add-cds-on-fhir
barhodes Jul 29, 2023
e42b91d
Merge branch '5089-clinical-reasoning-measure-refactor' into br-20230…
barhodes Jul 30, 2023
4ec17c9
_source search parameter needs to support modifiers (#5095)
volodymyr-korzh Jul 31, 2023
5629833
latest work
barhodes Jul 31, 2023
a7ae219
cleanup
barhodes Jul 31, 2023
36012fc
Refactor operation providers to support use in multiple modules
barhodes Aug 1, 2023
ca2c7bd
Fix HFQL docs (#5151)
nathandoef Aug 1, 2023
f15c54e
repository measure refactor
Capt-Mac Aug 2, 2023
8a7b166
Merge branch 'master' into br-20230720-add-cds-on-fhir
barhodes Aug 2, 2023
77fbca4
undo bundle edit, add config
Capt-Mac Aug 2, 2023
d5fbaa6
embedded library true
Capt-Mac Aug 2, 2023
f7908d3
undo post of bundle
Capt-Mac Aug 2, 2023
60e66f5
Merge branch 'master' into br-20230720-add-cds-on-fhir
barhodes Aug 2, 2023
e04e76d
clear library cache on test
Capt-Mac Aug 2, 2023
50377cb
fix sumbit-data test
Capt-Mac Aug 2, 2023
551473f
Fix tests
barhodes Aug 3, 2023
e52d260
cleanup
barhodes Aug 8, 2023
6f5e1f7
Update MeasureService.java
barhodes Aug 8, 2023
70ad11f
Merge branch 'master' into br-20230720-add-cds-on-fhir
barhodes Aug 14, 2023
265607b
Merge branch 'master' into br-20230720-add-cds-on-fhir
barhodes Aug 14, 2023
8a3bf00
latest
barhodes Aug 17, 2023
a49d97b
3.0.0 engine update
barhodes Aug 17, 2023
2cb1786
Merge branch 'master' into br-20230720-add-cds-on-fhir
barhodes Aug 21, 2023
6aaea07
merge cleanup
barhodes Aug 21, 2023
8921530
cr updates
barhodes Aug 22, 2023
c62aeff
cleanup
barhodes Aug 22, 2023
8472b2c
Only create services for PlanDefs that have a trigger with a named event
barhodes Aug 23, 2023
af6ff22
Merge branch 'master' into br-20230720-add-cds-on-fhir
barhodes Aug 23, 2023
b31edb6
Fix parameters being sent through invoke
barhodes Aug 23, 2023
eda216a
Handle system actions
barhodes Aug 24, 2023
7555c98
cleanup
barhodes Aug 24, 2023
6834f55
cr update and merge master updates
Capt-Mac Aug 24, 2023
76a33e8
missing packages from cql
Capt-Mac Aug 25, 2023
70e2dfb
fix test data and test cases for repository api
Capt-Mac Aug 28, 2023
b8d3393
latest
barhodes Aug 28, 2023
48d9dbd
fix pom
barhodes Aug 28, 2023
2256fd2
fix test config
barhodes Aug 28, 2023
344966e
cleanup
barhodes Aug 28, 2023
4f19ff9
merge master
Capt-Mac Aug 28, 2023
b46b7c7
3.0.0 clinical reasoning uplift
Capt-Mac Aug 30, 2023
cf048f0
r4 cql execution provider and tests
Capt-Mac Aug 30, 2023
b01937f
fix submitdata provider config
Capt-Mac Aug 30, 2023
bc8762d
wip cql tests
Capt-Mac Aug 30, 2023
b95c471
debugging cql op wip
Capt-Mac Aug 31, 2023
f9d26b7
wip debugging cql
Capt-Mac Aug 31, 2023
a059983
update tests for $cql, fix class names
Capt-Mac Sep 1, 2023
bfda963
prep for Pre6 uplift
Capt-Mac Sep 1, 2023
d55209f
spotless checks and test fixes
Capt-Mac Sep 1, 2023
f11472a
Merge branch 'master' into 5089-cr-measure-refactor
Capt-Mac Sep 1, 2023
f1686d2
bump to 3.0.0-PRE6
Capt-Mac Sep 1, 2023
d445245
cleanup
barhodes Sep 1, 2023
5c49424
fix version
Capt-Mac Sep 2, 2023
6e12305
merge
Capt-Mac Sep 2, 2023
b9ca2bd
cleanup
barhodes Sep 4, 2023
360493b
Merge branch 'master' into br-20230720-add-cds-on-fhir
barhodes Sep 4, 2023
648e4f4
Merge branch '5089-cr-measure-refactor' into br-20230720-add-cds-on-fhir
barhodes Sep 4, 2023
f86ad69
cleanup
barhodes Sep 4, 2023
d5681b6
fix exlusions in pom
Capt-Mac Sep 5, 2023
bcf2e86
Merge branch '5089-cr-measure-refactor' of https://github.com/hapifhi…
Capt-Mac Sep 5, 2023
28e7c50
add in cache invalidation config
Capt-Mac Sep 6, 2023
fb51eac
fix resource resolution
barhodes Sep 6, 2023
4f59e54
cleanup
barhodes Sep 6, 2023
60f2365
search converter bug and test for repository
Capt-Mac Sep 8, 2023
6a2353c
update pom
barhodes Sep 12, 2023
ce478ba
update searchconverter
Capt-Mac Sep 18, 2023
65fcb1a
Merge branch 'master' into 5089-cr-measure-refactor
Capt-Mac Sep 18, 2023
7b4261b
version bump, add changelog
Capt-Mac Sep 20, 2023
53448f5
remove term config, move IDaoRegistryUser class
Capt-Mac Sep 20, 2023
0fc47e8
Break out dstu3 providers and move config to version folders
barhodes Sep 21, 2023
1650267
Merge branch '5089-cr-measure-refactor' into br-20230720-add-cds-on-fhir
barhodes Sep 21, 2023
5853ef5
Merge branch 'master' into br-20230720-add-cds-on-fhir
barhodes Sep 23, 2023
9d77fc8
merge cleanup
barhodes Sep 23, 2023
1a6fa7c
merge cleanup
barhodes Sep 23, 2023
dd655bc
Add changelog
barhodes Sep 23, 2023
357e80f
spotless
barhodes Sep 23, 2023
b5efa7a
fix error codes
barhodes Sep 23, 2023
2a157aa
cleanup
barhodes Sep 23, 2023
daf6b09
cleanup
barhodes Sep 23, 2023
572d751
Handle missing beans in Operation configs
barhodes Sep 25, 2023
22baa09
spotless
barhodes Sep 25, 2023
a4e8f55
Use CondtionalOnBean for CR Operation and Repository configs
barhodes Sep 25, 2023
f21aaff
Fix test config
barhodes Sep 25, 2023
0954852
Add RepositoryFactory and RestfulServer to CdsConfigService
barhodes Sep 26, 2023
4909a41
Move createRequestDetails into CdsConfigService
barhodes Sep 27, 2023
16a222d
spotless
barhodes Sep 27, 2023
a2d215f
review comments
barhodes Sep 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
type: add
issue: 5238
title: "Added an implementation of Clinical Reasoning CDS on FHIR to the CDS Hooks module that allows PlanDefinition
worfklows to be processed as CDS Services using the $apply operation.
"
5 changes: 5 additions & 0 deletions hapi-fhir-server-cds-hooks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<artifactId>hapi-fhir-storage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-storage-cr</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@
package ca.uhn.hapi.fhir.cdshooks.api;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.cr.common.IRepositoryFactory;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
import ca.uhn.fhir.rest.api.server.SystemRestfulResponse;
import ca.uhn.fhir.rest.server.RestfulServer;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.opencds.cqf.fhir.utility.Ids;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -37,4 +43,22 @@ public interface ICdsConfigService {
default DaoRegistry getDaoRegistry() {
return null;
}

@Nullable
default IRepositoryFactory getRepositoryFactory() {
return null;
}

@Nullable
default RestfulServer getRestfulServer() {
return null;
}

default RequestDetails createRequestDetails(FhirContext theFhirContext, String theId, String theResourceType) {
SystemRequestDetails rd = new SystemRequestDetails();
rd.setServer(getRestfulServer());
rd.setResponse(new SystemRestfulResponse(rd));
rd.setId(Ids.newId(theFhirContext.getVersion().getVersion(), theResourceType, theId));
return rd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ void registerService(
boolean theAllowAutoFhirClientPrefetch,
String theModuleId);

/**
* Register a new Clinical Reasoning CDS Service with the endpoint.
*
* @param theServiceId the id of the service PlanDefinition
* @return the service was registered
*/
boolean registerCrService(String theServiceId);

/**
* Remove registered CDS service with the service ID, only removes dynamically registered service
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,35 @@
package ca.uhn.hapi.fhir.cdshooks.config;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.cr.common.IRepositoryFactory;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry;
import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.hapi.fhir.cdshooks.api.ICdsConfigService;
import ca.uhn.hapi.fhir.cdshooks.api.ICdsHooksDaoAuthorizationSvc;
import ca.uhn.hapi.fhir.cdshooks.api.ICdsServiceRegistry;
import ca.uhn.hapi.fhir.cdshooks.module.CdsHooksObjectMapperFactory;
import ca.uhn.hapi.fhir.cdshooks.svc.CdsConfigServiceImpl;
import ca.uhn.hapi.fhir.cdshooks.svc.CdsHooksContextBooter;
import ca.uhn.hapi.fhir.cdshooks.svc.CdsServiceRegistryImpl;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrServiceDstu3;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrServiceR4;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrServiceR5;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsServiceInterceptor;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.ICdsCrServiceFactory;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.CrDiscoveryServiceDstu3;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.CrDiscoveryServiceR4;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.CrDiscoveryServiceR5;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.ICrDiscoveryServiceFactory;
import ca.uhn.hapi.fhir.cdshooks.svc.prefetch.CdsPrefetchDaoSvc;
import ca.uhn.hapi.fhir.cdshooks.svc.prefetch.CdsPrefetchFhirClientSvc;
import ca.uhn.hapi.fhir.cdshooks.svc.prefetch.CdsPrefetchSvc;
import ca.uhn.hapi.fhir.cdshooks.svc.prefetch.CdsResolutionStrategySvc;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.opencds.cqf.fhir.api.Repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
Expand All @@ -44,12 +59,23 @@ public class CdsHooksConfig {

public static final String CDS_HOOKS_OBJECT_MAPPER_FACTORY = "cdsHooksObjectMapperFactory";

public static final String PLAN_DEFINITION_RESOURCE_NAME = "PlanDefinition";

@Autowired(required = false)
private DaoRegistry myDaoRegistry;

@Autowired(required = false)
private MatchUrlService myMatchUrlService;

@Autowired(required = false)
private IResourceChangeListenerRegistry myResourceChangeListenerRegistry;

@Autowired(required = false)
private IRepositoryFactory myRepositoryFactory;

@Autowired(required = false)
private RestfulServer myRestfulServer;

@Bean(name = CDS_HOOKS_OBJECT_MAPPER_FACTORY)
public ObjectMapper objectMapper(FhirContext theFhirContext) {
return new CdsHooksObjectMapperFactory(theFhirContext).newMapper();
Expand All @@ -59,14 +85,78 @@ public ObjectMapper objectMapper(FhirContext theFhirContext) {
public ICdsServiceRegistry cdsServiceRegistry(
CdsHooksContextBooter theCdsHooksContextBooter,
CdsPrefetchSvc theCdsPrefetchSvc,
@Qualifier(CDS_HOOKS_OBJECT_MAPPER_FACTORY) ObjectMapper theObjectMapper) {
return new CdsServiceRegistryImpl(theCdsHooksContextBooter, theCdsPrefetchSvc, theObjectMapper);
@Qualifier(CDS_HOOKS_OBJECT_MAPPER_FACTORY) ObjectMapper theObjectMapper,
ICdsCrServiceFactory theCdsCrServiceFactory,
ICrDiscoveryServiceFactory theCrDiscoveryServiceFactory) {
return new CdsServiceRegistryImpl(
theCdsHooksContextBooter,
theCdsPrefetchSvc,
theObjectMapper,
theCdsCrServiceFactory,
theCrDiscoveryServiceFactory);
}

@Bean
public ICdsCrServiceFactory cdsCrServiceFactory(FhirContext theFhirContext, ICdsConfigService theCdsConfigService) {
return id -> {
if (myRepositoryFactory == null) {
return null;
}
RequestDetails rd =
theCdsConfigService.createRequestDetails(theFhirContext, id, PLAN_DEFINITION_RESOURCE_NAME);
Repository repository = myRepositoryFactory.create(rd);
switch (theFhirContext.getVersion().getVersion()) {
case DSTU3:
return new CdsCrServiceDstu3(rd, repository);
case R4:
return new CdsCrServiceR4(rd, repository);
case R5:
return new CdsCrServiceR5(rd, repository);
default:
return null;
}
};
}

@Bean
public ICrDiscoveryServiceFactory crDiscoveryServiceFactory(
FhirContext theFhirContext, ICdsConfigService theCdsConfigService) {
return id -> {
if (myRepositoryFactory == null) {
return null;
}
RequestDetails rd =
theCdsConfigService.createRequestDetails(theFhirContext, id, PLAN_DEFINITION_RESOURCE_NAME);
Repository repository = myRepositoryFactory.create(rd);
switch (theFhirContext.getVersion().getVersion()) {
case DSTU3:
return new CrDiscoveryServiceDstu3(rd.getId(), repository);
case R4:
return new CrDiscoveryServiceR4(rd.getId(), repository);
case R5:
return new CrDiscoveryServiceR5(rd.getId(), repository);
default:
return null;
}
};
}

@Bean
public CdsServiceInterceptor cdsServiceInterceptor() {
if (myResourceChangeListenerRegistry == null) {
return null;
}
CdsServiceInterceptor listener = new CdsServiceInterceptor();
myResourceChangeListenerRegistry.registerResourceResourceChangeListener(
PLAN_DEFINITION_RESOURCE_NAME, SearchParameterMap.newSynchronous(), listener, 1000);
return listener;
}

@Bean
public ICdsConfigService cdsConfigService(
FhirContext theFhirContext, @Qualifier(CDS_HOOKS_OBJECT_MAPPER_FACTORY) ObjectMapper theObjectMapper) {
return new CdsConfigServiceImpl(theFhirContext, theObjectMapper, myDaoRegistry);
return new CdsConfigServiceImpl(
theFhirContext, theObjectMapper, myDaoRegistry, myRepositoryFactory, myRestfulServer);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*-
* #%L
* HAPI FHIR - CDS Hooks
* %%
* Copyright (C) 2014 - 2023 Smile CDR, Inc.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package ca.uhn.hapi.fhir.cdshooks.svc;

import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.model.api.IModelJson;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
import ca.uhn.hapi.fhir.cdshooks.api.ICdsMethod;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.ICdsCrServiceFactory;
import com.fasterxml.jackson.databind.ObjectMapper;

abstract class BaseCdsCrMethod implements ICdsMethod {
private ICdsCrServiceFactory myCdsCrServiceFactory;

public BaseCdsCrMethod(ICdsCrServiceFactory theCdsCrServiceFactory) {
myCdsCrServiceFactory = theCdsCrServiceFactory;
}

public Object invoke(ObjectMapper theObjectMapper, IModelJson theJson, String theServiceId) {
try {
return myCdsCrServiceFactory.create(theServiceId).invoke(theJson);
} catch (Exception e) {
if (e.getCause() != null && e.getCause() instanceof BaseServerResponseException) {
throw (BaseServerResponseException) e.getCause();
}
throw new ConfigurationException(Msg.code(2434) + "Failed to invoke $apply on " + theServiceId, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
package ca.uhn.hapi.fhir.cdshooks.svc;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.cr.common.IRepositoryFactory;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.hapi.fhir.cdshooks.api.ICdsConfigService;
import com.fasterxml.jackson.databind.ObjectMapper;

Expand All @@ -31,14 +33,20 @@ public class CdsConfigServiceImpl implements ICdsConfigService {
private final FhirContext myFhirContext;
private final ObjectMapper myObjectMapper;
private final DaoRegistry myDaoRegistry;
private final IRepositoryFactory myRepositoryFactory;
private final RestfulServer myRestfulServer;

public CdsConfigServiceImpl(
@Nonnull FhirContext theFhirContext,
@Nonnull ObjectMapper theObjectMapper,
@Nullable DaoRegistry theDaoRegistry) {
@Nullable DaoRegistry theDaoRegistry,
@Nullable IRepositoryFactory theRepositoryFactory,
@Nullable RestfulServer theRestfulServer) {
myFhirContext = theFhirContext;
myObjectMapper = theObjectMapper;
myDaoRegistry = theDaoRegistry;
myRepositoryFactory = theRepositoryFactory;
myRestfulServer = theRestfulServer;
}

@Nonnull
Expand All @@ -58,4 +66,16 @@ public ObjectMapper getObjectMapper() {
public DaoRegistry getDaoRegistry() {
return myDaoRegistry;
}

@Nullable
@Override
public IRepositoryFactory getRepositoryFactory() {
return myRepositoryFactory;
}

@Nullable
@Override
public RestfulServer getRestfulServer() {
return myRestfulServer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*-
* #%L
* HAPI FHIR - CDS Hooks
* %%
* Copyright (C) 2014 - 2023 Smile CDR, Inc.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package ca.uhn.hapi.fhir.cdshooks.svc;

import ca.uhn.hapi.fhir.cdshooks.api.ICdsServiceMethod;
import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceJson;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.ICdsCrServiceFactory;

public class CdsCrServiceMethod extends BaseCdsCrMethod implements ICdsServiceMethod {
private final CdsServiceJson myCdsServiceJson;

public CdsCrServiceMethod(CdsServiceJson theCdsServiceJson, ICdsCrServiceFactory theCdsCrServiceFactory) {
super(theCdsCrServiceFactory);
myCdsServiceJson = theCdsServiceJson;
}

@Override
public CdsServiceJson getCdsServiceJson() {
return myCdsServiceJson;
}

@Override
public boolean isAllowAutoFhirClientPrefetch() {
// The $apply operation will make FHIR requests for any data it needs
// directly against the fhirServer of the ServiceRequest.
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceRequestJson;
import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceResponseJson;
import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServicesJson;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.ICdsCrServiceFactory;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.ICrDiscoveryServiceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,6 +35,8 @@
import java.util.Map;
import java.util.function.Function;

import static ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrConstants.CDS_CR_MODULE_ID;

public class CdsServiceCache {
static final Logger ourLog = LoggerFactory.getLogger(CdsServiceCache.class);
final Map<String, ICdsMethod> myServiceMap = new LinkedHashMap<>();
Expand Down Expand Up @@ -66,6 +70,23 @@ public void registerDynamicService(
}
}

public void registerCrService(
String theServiceId,
ICrDiscoveryServiceFactory theDiscoveryServiceFactory,
ICdsCrServiceFactory theCrServiceFactory) {
if (!isCdsServiceAlreadyRegistered(theServiceId, CDS_CR_MODULE_ID)) {
CdsServiceJson cdsServiceJson =
theDiscoveryServiceFactory.create(theServiceId).resolveService();
if (cdsServiceJson != null) {
final CdsCrServiceMethod cdsCrServiceMethod =
new CdsCrServiceMethod(cdsServiceJson, theCrServiceFactory);
myServiceMap.put(theServiceId, cdsCrServiceMethod);
myCdsServiceJson.addService(cdsServiceJson);
ourLog.info("Created service for {}", theServiceId);
}
}
}

public void registerFeedback(String theServiceId, Object theServiceBean, Method theMethod) {
final CdsFeedbackMethod cdsFeedbackMethod = new CdsFeedbackMethod(theServiceBean, theMethod);
myFeedbackMap.put(theServiceId, cdsFeedbackMethod);
Expand Down
Loading