Skip to content

Commit

Permalink
Merge pull request #458 from DBCG/feature-cpg-cql
Browse files Browse the repository at this point in the history
$cql OperationProvider and Tests
  • Loading branch information
JPercival authored Feb 18, 2022
2 parents ada8237 + e0724ed commit d231289
Show file tree
Hide file tree
Showing 30 changed files with 1,895 additions and 19 deletions.
13 changes: 12 additions & 1 deletion plugin/cpg/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# CPG Plugin

This plugin holds operation on library evaluate.
This plugin provides the following Operations:

Library
$evaluate

System
$cql

$cql is defined in the CPG Implementation Guide here: http://build.fhir.org/ig/HL7/cqf-recommendations/OperationDefinition-cpg-cql.html

*Note* prefetchData is not yet implemented
*Note* subject only supports Patient references as of now
7 changes: 7 additions & 0 deletions plugin/cpg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
<version>0.5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.31.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.opencds.cqf.ruler</groupId>
<artifactId>cqf-ruler-test</artifactId>
Expand Down
32 changes: 32 additions & 0 deletions plugin/cpg/src/main/java/org/opencds/cqf/ruler/cpg/CpgConfig.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package org.opencds.cqf.ruler.cpg;

import org.opencds.cqf.cql.evaluator.builder.library.FhirRestLibraryContentProviderFactory;
import org.opencds.cqf.cql.evaluator.cql2elm.util.LibraryVersionSelector;
import org.opencds.cqf.cql.evaluator.fhir.ClientFactory;
import org.opencds.cqf.ruler.api.OperationProvider;
import org.opencds.cqf.ruler.cql.CqlConfig;
import org.opencds.cqf.ruler.external.annotations.OnDSTU3Condition;
import org.opencds.cqf.ruler.external.annotations.OnR4Condition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import ca.uhn.fhir.context.FhirContext;

@Configuration
@ConditionalOnProperty(prefix = "hapi.fhir.cpg", name ="enabled", havingValue = "true", matchIfMissing=true)
@Import({CqlConfig.class})
Expand All @@ -24,4 +30,30 @@ public CpgProperties cpgProperties() {
public OperationProvider r4LibraryEvaluationProvider() {
return new org.opencds.cqf.ruler.cpg.r4.provider.LibraryEvaluationProvider();
}

@Bean
@Conditional(OnR4Condition.class)
public OperationProvider r4CqlExecutionProvider() {
return new org.opencds.cqf.ruler.cpg.r4.provider.CqlExecutionProvider();
}

@Bean
@Conditional(OnDSTU3Condition.class)
public OperationProvider dstu3CqlExecutionProvider() {
return new org.opencds.cqf.ruler.cpg.dstu3.provider.CqlExecutionProvider();
}

@Bean
@Conditional(OnR4Condition.class)
public FhirRestLibraryContentProviderFactory r4FhirRestibraryContentProviderFactory() {
org.opencds.cqf.cql.evaluator.fhir.adapter.r4.AdapterFactory r4AdapterFactory = new org.opencds.cqf.cql.evaluator.fhir.adapter.r4.AdapterFactory();
return new FhirRestLibraryContentProviderFactory(new ClientFactory(FhirContext.forR4Cached()), r4AdapterFactory, new LibraryVersionSelector(r4AdapterFactory));
}

@Bean
@Conditional(OnDSTU3Condition.class)
public FhirRestLibraryContentProviderFactory dstu3FhirRestibraryContentProviderFactory() {
org.opencds.cqf.cql.evaluator.fhir.adapter.dstu3.AdapterFactory r4AdapterFactory = new org.opencds.cqf.cql.evaluator.fhir.adapter.dstu3.AdapterFactory();
return new FhirRestLibraryContentProviderFactory(new ClientFactory(FhirContext.forDstu3Cached()), r4AdapterFactory, new LibraryVersionSelector(r4AdapterFactory));
}
}
Loading

0 comments on commit d231289

Please sign in to comment.