remove BaseRequestPartitionHelperSvc
This commit is contained in:
parent
83aee91b72
commit
6747111c10
|
@ -19,38 +19,30 @@
|
||||||
*/
|
*/
|
||||||
package ca.uhn.fhir.cr.common;
|
package ca.uhn.fhir.cr.common;
|
||||||
|
|
||||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
|
||||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||||
import ca.uhn.fhir.jpa.partition.BaseRequestPartitionHelperSvc;
|
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||||
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
|
|
||||||
import ca.uhn.fhir.rest.param.UriParam;
|
import ca.uhn.fhir.rest.param.UriParam;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.opencds.cqf.cql.evaluator.fhir.dal.FhirDal;
|
import org.opencds.cqf.cql.evaluator.fhir.dal.FhirDal;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
/**
|
/**
|
||||||
* This class leverages DaoRegistry from Hapi-fhir to implement CRUD FHIR API operations constrained to provide only the operations necessary for the cql-evaluator modules to function.
|
* This class leverages DaoRegistry from Hapi-fhir to implement CRUD FHIR API operations constrained to provide only the operations necessary for the cql-evaluator modules to function.
|
||||||
**/
|
**/
|
||||||
public class HapiFhirDal implements FhirDal {
|
public class HapiFhirDal implements FhirDal {
|
||||||
private static Logger logger = LoggerFactory.getLogger(HapiFhirDal.class);
|
|
||||||
protected final DaoRegistry myDaoRegistry;
|
protected final DaoRegistry myDaoRegistry;
|
||||||
protected final RequestDetails myRequestDetails;
|
protected final RequestDetails myRequestDetails;
|
||||||
protected final BaseRequestPartitionHelperSvc myBaseRequestPartitionHelperSvc;
|
|
||||||
|
|
||||||
public HapiFhirDal(DaoRegistry theDaoRegistry, BaseRequestPartitionHelperSvc theBaseRequestPartitionHelperSvc) {
|
|
||||||
this(theDaoRegistry,null, theBaseRequestPartitionHelperSvc);
|
|
||||||
|
|
||||||
|
public HapiFhirDal(DaoRegistry theDaoRegistry) {
|
||||||
|
this(theDaoRegistry,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HapiFhirDal(DaoRegistry theDaoRegistry, RequestDetails theRequestDetails, BaseRequestPartitionHelperSvc theBaseRequestPartitionHelperSvc) {
|
public HapiFhirDal(DaoRegistry theDaoRegistry, RequestDetails theRequestDetails) {
|
||||||
this.myDaoRegistry = theDaoRegistry;
|
this.myDaoRegistry = theDaoRegistry;
|
||||||
this.myRequestDetails = theRequestDetails;
|
this.myRequestDetails = theRequestDetails;
|
||||||
this.myBaseRequestPartitionHelperSvc = theBaseRequestPartitionHelperSvc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,20 +76,9 @@ public class HapiFhirDal implements FhirDal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<IBaseResource> searchByUrl(String theResourceType, String theUrl) {
|
public Iterable<IBaseResource> searchByUrl(String theResourceType, String theUrl) {
|
||||||
|
|
||||||
if(myBaseRequestPartitionHelperSvc.isResourcePartitionable(theResourceType)){
|
|
||||||
var b = this.myDaoRegistry.getResourceDao(theResourceType)
|
var b = this.myDaoRegistry.getResourceDao(theResourceType)
|
||||||
.search(new SearchParameterMap().add("url", new UriParam(theUrl)), myRequestDetails);
|
.search(new SearchParameterMap().add("url", new UriParam(theUrl)), myRequestDetails);
|
||||||
return new BundleIterable(myRequestDetails, b);
|
return new BundleIterable(myRequestDetails, b);
|
||||||
} else {
|
|
||||||
//In Partitioned deployment certain resources are only available in default partition
|
|
||||||
SystemRequestDetails systemRequestDetails = new SystemRequestDetails();
|
|
||||||
systemRequestDetails.setRequestPartitionId(RequestPartitionId.defaultPartition());
|
|
||||||
var b = this.myDaoRegistry.getResourceDao(theResourceType)
|
|
||||||
.search(new SearchParameterMap().add("url", new UriParam(theUrl)), systemRequestDetails);
|
|
||||||
return new BundleIterable(systemRequestDetails, b);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,10 @@
|
||||||
*/
|
*/
|
||||||
package ca.uhn.fhir.cr.common;
|
package ca.uhn.fhir.cr.common;
|
||||||
|
|
||||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
|
||||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||||
import ca.uhn.fhir.jpa.partition.BaseRequestPartitionHelperSvc;
|
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||||
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
|
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
|
||||||
import ca.uhn.fhir.rest.param.UriParam;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.opencds.cqf.cql.engine.fhir.retrieve.SearchParamFhirRetrieveProvider;
|
import org.opencds.cqf.cql.engine.fhir.retrieve.SearchParamFhirRetrieveProvider;
|
||||||
import org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterMap;
|
import org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterMap;
|
||||||
|
@ -50,18 +47,17 @@ public class HapiFhirRetrieveProvider extends SearchParamFhirRetrieveProvider im
|
||||||
|
|
||||||
private final DaoRegistry myDaoRegistry;
|
private final DaoRegistry myDaoRegistry;
|
||||||
private final RequestDetails myRequestDetails;
|
private final RequestDetails myRequestDetails;
|
||||||
protected final BaseRequestPartitionHelperSvc myBaseRequestPartitionHelperSvc;
|
|
||||||
|
|
||||||
public HapiFhirRetrieveProvider(DaoRegistry theDaoRegistry, SearchParameterResolver theSearchParameterResolver, BaseRequestPartitionHelperSvc theBaseRequestPartitionHelperSvc) {
|
|
||||||
this(theDaoRegistry, theSearchParameterResolver, new SystemRequestDetails(), theBaseRequestPartitionHelperSvc);
|
public HapiFhirRetrieveProvider(DaoRegistry theDaoRegistry, SearchParameterResolver theSearchParameterResolver) {
|
||||||
|
this(theDaoRegistry, theSearchParameterResolver, new SystemRequestDetails());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HapiFhirRetrieveProvider(DaoRegistry theRegistry, SearchParameterResolver searchParameterResolver,
|
public HapiFhirRetrieveProvider(DaoRegistry registry, SearchParameterResolver searchParameterResolver,
|
||||||
RequestDetails theRequestDetails, BaseRequestPartitionHelperSvc theBaseRequestPartitionHelperSvc) {
|
RequestDetails requestDetails) {
|
||||||
super(searchParameterResolver);
|
super(searchParameterResolver);
|
||||||
this.myDaoRegistry = theRegistry;
|
this.myDaoRegistry = registry;
|
||||||
this.myRequestDetails = theRequestDetails;
|
this.myRequestDetails = requestDetails;
|
||||||
this.myBaseRequestPartitionHelperSvc = theBaseRequestPartitionHelperSvc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,6 +67,7 @@ public class HapiFhirRetrieveProvider extends SearchParamFhirRetrieveProvider im
|
||||||
|
|
||||||
private final String dataType;
|
private final String dataType;
|
||||||
private final List<SearchParameterMap> queries;
|
private final List<SearchParameterMap> queries;
|
||||||
|
|
||||||
private final BiFunction<String, SearchParameterMap, Iterable<IBaseResource>> queryFunc;
|
private final BiFunction<String, SearchParameterMap, Iterable<IBaseResource>> queryFunc;
|
||||||
|
|
||||||
public QueryIterable(String dataType, List<SearchParameterMap> queries, BiFunction<String, SearchParameterMap, Iterable<IBaseResource>> queryFunc) {
|
public QueryIterable(String dataType, List<SearchParameterMap> queries, BiFunction<String, SearchParameterMap, Iterable<IBaseResource>> queryFunc) {
|
||||||
|
@ -141,11 +138,11 @@ public class HapiFhirRetrieveProvider extends SearchParamFhirRetrieveProvider im
|
||||||
return new QueryIterable(dataType, queries, this::executeQuery);
|
return new QueryIterable(dataType, queries, this::executeQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Iterable<IBaseResource> executeQuery(String theDataType, SearchParameterMap theSearchParameterMap) {
|
protected Iterable<IBaseResource> executeQuery(String dataType, SearchParameterMap map) {
|
||||||
ca.uhn.fhir.jpa.searchparam.SearchParameterMap hapiMap = new ca.uhn.fhir.jpa.searchparam.SearchParameterMap();
|
ca.uhn.fhir.jpa.searchparam.SearchParameterMap hapiMap = new ca.uhn.fhir.jpa.searchparam.SearchParameterMap();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
for (Map.Entry<String, List<List<IQueryParameterType>>> entry : theSearchParameterMap.entrySet()) {
|
for (Map.Entry<String, List<List<IQueryParameterType>>> entry : map.entrySet()) {
|
||||||
hapiMap.put(entry.getKey(), entry.getValue());
|
hapiMap.put(entry.getKey(), entry.getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -154,13 +151,7 @@ public class HapiFhirRetrieveProvider extends SearchParamFhirRetrieveProvider im
|
||||||
logger.warn("Error converting search parameter map", e);
|
logger.warn("Error converting search parameter map", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemRequestDetails systemRequestDetails = new SystemRequestDetails();
|
return search(getClass(dataType), hapiMap, myRequestDetails);
|
||||||
|
|
||||||
if(!myBaseRequestPartitionHelperSvc.isResourcePartitionable(theDataType)){
|
|
||||||
//if non-partitionable datatype, set to default partition
|
|
||||||
systemRequestDetails.setRequestPartitionId(RequestPartitionId.defaultPartition());
|
|
||||||
}
|
|
||||||
return search(getClass(theDataType), hapiMap, systemRequestDetails);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,10 +19,8 @@
|
||||||
*/
|
*/
|
||||||
package ca.uhn.fhir.cr.common;
|
package ca.uhn.fhir.cr.common;
|
||||||
|
|
||||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
|
||||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||||
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
|
|
||||||
import org.cqframework.cql.cql2elm.LibraryContentType;
|
import org.cqframework.cql.cql2elm.LibraryContentType;
|
||||||
import org.cqframework.cql.cql2elm.LibrarySourceProvider;
|
import org.cqframework.cql.cql2elm.LibrarySourceProvider;
|
||||||
import org.hl7.elm.r1.VersionedIdentifier;
|
import org.hl7.elm.r1.VersionedIdentifier;
|
||||||
|
@ -64,12 +62,7 @@ public class HapiLibrarySourceProvider
|
||||||
LibraryContentType theLibraryContentType) {
|
LibraryContentType theLibraryContentType) {
|
||||||
String name = theLibraryIdentifier.getId();
|
String name = theLibraryIdentifier.getId();
|
||||||
String version = theLibraryIdentifier.getVersion();
|
String version = theLibraryIdentifier.getVersion();
|
||||||
|
var libraries = search(getClass("Library"), Searches.byName(name), myRequestDetails);
|
||||||
// needed for partitioned environment
|
|
||||||
SystemRequestDetails systemRequestDetails = new SystemRequestDetails();
|
|
||||||
systemRequestDetails.setRequestPartitionId(RequestPartitionId.defaultPartition());
|
|
||||||
|
|
||||||
var libraries = search(getClass("Library"), Searches.byName(name), systemRequestDetails);
|
|
||||||
var libraryList = new ArrayList<IBaseResource>();
|
var libraryList = new ArrayList<IBaseResource>();
|
||||||
for(var l:libraries){
|
for(var l:libraries){
|
||||||
libraryList.add(l);
|
libraryList.add(l);
|
||||||
|
|
|
@ -38,7 +38,6 @@ import ca.uhn.fhir.cr.common.ITerminologyProviderFactory;
|
||||||
import ca.uhn.fhir.i18n.Msg;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||||
import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry;
|
import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry;
|
||||||
import ca.uhn.fhir.jpa.partition.BaseRequestPartitionHelperSvc;
|
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||||
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
||||||
import org.cqframework.cql.cql2elm.CqlTranslatorOptions;
|
import org.cqframework.cql.cql2elm.CqlTranslatorOptions;
|
||||||
|
@ -58,7 +57,6 @@ import org.opencds.cqf.cql.evaluator.CqlOptions;
|
||||||
import org.opencds.cqf.cql.evaluator.builder.DataProviderComponents;
|
import org.opencds.cqf.cql.evaluator.builder.DataProviderComponents;
|
||||||
import org.opencds.cqf.cql.evaluator.builder.EndpointInfo;
|
import org.opencds.cqf.cql.evaluator.builder.EndpointInfo;
|
||||||
import org.opencds.cqf.cql.evaluator.cql2elm.util.LibraryVersionSelector;
|
import org.opencds.cqf.cql.evaluator.cql2elm.util.LibraryVersionSelector;
|
||||||
import org.opencds.cqf.cql.evaluator.engine.execution.CacheAwareLibraryLoaderDecorator;
|
|
||||||
import org.opencds.cqf.cql.evaluator.engine.execution.TranslatingLibraryLoader;
|
import org.opencds.cqf.cql.evaluator.engine.execution.TranslatingLibraryLoader;
|
||||||
import org.opencds.cqf.cql.evaluator.engine.model.CachingModelResolverDecorator;
|
import org.opencds.cqf.cql.evaluator.engine.model.CachingModelResolverDecorator;
|
||||||
import org.opencds.cqf.cql.evaluator.engine.retrieve.BundleRetrieveProvider;
|
import org.opencds.cqf.cql.evaluator.engine.retrieve.BundleRetrieveProvider;
|
||||||
|
@ -170,15 +168,15 @@ public abstract class BaseClinicalReasoningConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
IFhirDalFactory fhirDalFactory(DaoRegistry theDaoRegistry, BaseRequestPartitionHelperSvc theBaseRequestPartitionHelperSvc) {
|
IFhirDalFactory fhirDalFactory(DaoRegistry theDaoRegistry) {
|
||||||
return rd -> new HapiFhirDal(theDaoRegistry, rd, theBaseRequestPartitionHelperSvc);
|
return rd -> new HapiFhirDal(theDaoRegistry, rd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
IDataProviderFactory dataProviderFactory(ModelResolver theModelResolver, DaoRegistry theDaoRegistry,
|
IDataProviderFactory dataProviderFactory(ModelResolver theModelResolver, DaoRegistry theDaoRegistry,
|
||||||
SearchParameterResolver theSearchParameterResolver, BaseRequestPartitionHelperSvc theBaseRequestPartitionHelperSvc) {
|
SearchParameterResolver theSearchParameterResolver) {
|
||||||
return (rd, t) -> {
|
return (rd, t) -> {
|
||||||
HapiFhirRetrieveProvider provider = new HapiFhirRetrieveProvider(theDaoRegistry, theSearchParameterResolver, rd, theBaseRequestPartitionHelperSvc);
|
HapiFhirRetrieveProvider provider = new HapiFhirRetrieveProvider(theDaoRegistry, theSearchParameterResolver, rd);
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
provider.setTerminologyProvider(t);
|
provider.setTerminologyProvider(t);
|
||||||
provider.setExpandValueSets(true);
|
provider.setExpandValueSets(true);
|
||||||
|
@ -209,8 +207,8 @@ public abstract class BaseClinicalReasoningConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public HapiFhirRetrieveProvider fhirRetrieveProvider(DaoRegistry theDaoRegistry,
|
public HapiFhirRetrieveProvider fhirRetrieveProvider(DaoRegistry theDaoRegistry,
|
||||||
SearchParameterResolver theSearchParameterResolver, BaseRequestPartitionHelperSvc theBaseRequestPartitionHelperSvc) {
|
SearchParameterResolver theSearchParameterResolver) {
|
||||||
return new HapiFhirRetrieveProvider(theDaoRegistry, theSearchParameterResolver, theBaseRequestPartitionHelperSvc);
|
return new HapiFhirRetrieveProvider(theDaoRegistry, theSearchParameterResolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
Loading…
Reference in New Issue