Search in sources :

Example 1 with SearchParameterMap

use of org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterMap in project cqf-ruler by DBCG.

the class JpaFhirRetrieveProvider method executeQuery.

protected List<IBaseResource> executeQuery(String dataType, SearchParameterMap map) {
    // TODO: Once HAPI breaks this out from the server dependencies
    // we can include it on its own.
    ca.uhn.fhir.jpa.searchparam.SearchParameterMap hapiMap = ca.uhn.fhir.jpa.searchparam.SearchParameterMap.newSynchronous();
    try {
        Method[] methods = hapiMap.getClass().getDeclaredMethods();
        List<Method> methodList = Arrays.asList(methods);
        List<Method> puts = methodList.stream().filter(x -> x.getName().equals("put")).collect(Collectors.toList());
        Method method = puts.get(0);
        method.setAccessible(true);
        for (Map.Entry<String, List<List<IQueryParameterType>>> entry : map.entrySet()) {
            method.invoke(hapiMap, entry.getKey(), entry.getValue());
        }
    } catch (Exception e) {
        logger.warn("Error converting search parameter map", e);
    }
    IBundleProvider bundleProvider = search(getClass(dataType), hapiMap, myRequestDetails);
    if (bundleProvider.isEmpty()) {
        return new ArrayList<>();
    }
    return bundleProvider.getAllResources();
}
Also used : Arrays(java.util.Arrays) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) SearchParamFhirRetrieveProvider(org.opencds.cqf.cql.engine.fhir.retrieve.SearchParamFhirRetrieveProvider) SearchParameterMap(org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterMap) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) DaoRegistryUser(org.opencds.cqf.ruler.behavior.DaoRegistryUser) List(java.util.List) DaoRegistry(ca.uhn.fhir.jpa.api.dao.DaoRegistry) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Map(java.util.Map) SearchParameterResolver(org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver) Method(java.lang.reflect.Method) Collections(java.util.Collections) IQueryParameterType(ca.uhn.fhir.model.api.IQueryParameterType) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) ArrayList(java.util.ArrayList) List(java.util.List) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IQueryParameterType(ca.uhn.fhir.model.api.IQueryParameterType) SearchParameterMap(org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterMap) Map(java.util.Map)

Aggregations

DaoRegistry (ca.uhn.fhir.jpa.api.dao.DaoRegistry)1 IQueryParameterType (ca.uhn.fhir.model.api.IQueryParameterType)1 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)1 RequestDetails (ca.uhn.fhir.rest.api.server.RequestDetails)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)1 SearchParamFhirRetrieveProvider (org.opencds.cqf.cql.engine.fhir.retrieve.SearchParamFhirRetrieveProvider)1 SearchParameterMap (org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterMap)1 SearchParameterResolver (org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver)1 DaoRegistryUser (org.opencds.cqf.ruler.behavior.DaoRegistryUser)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1