Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #20 from DBCG/develop
Browse files Browse the repository at this point in the history
Proposed Release 1.3.0
  • Loading branch information
JPercival authored Sep 30, 2020
2 parents 4229226 + 8936fff commit 116c48a
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 89 deletions.
63 changes: 31 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,43 @@ language: java
jdk: openjdk11
os: linux
dist: xenial

cache:
timeout: 180
directories:
- "$HOME/.m2/repository"

install:
- mvn install -U -DskipTests=true -Dmaven.javadoc.skip=true -B -V

- ./scripts/install.sh
script:
# master or PRs into master, use the release profile
- 'if [[ "$TRAVIS_BRANCH" =~ master* ]]; then mvn test -B -P release; fi'
- 'if ! [[ "$TRAVIS_BRANCH" =~ master* ]]; then mvn test -B; fi'


## export GPG details
- if [[ "$TRAVIS_BRANCH" =~ master* ]]; then mvn test -B -P release; fi
- if ! [[ "$TRAVIS_BRANCH" =~ master* ]]; then mvn test -B; fi
before_deploy:
- 'if [[ "$TRAVIS_BRANCH" =~ master* ]]; then echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import; fi'
- 'if [[ "$TRAVIS_BRANCH" =~ master* ]]; then echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust; fi'

# NOTE: tests were already run as part of the script phase
- if [[ "$TRAVIS_BRANCH" =~ master* ]]; then echo $GPG_SECRET_KEYS | base64 --decode
| $GPG_EXECUTABLE --import; fi
- if [[ "$TRAVIS_BRANCH" =~ master* ]]; then echo $GPG_OWNERTRUST | base64 --decode
| $GPG_EXECUTABLE --import-ownertrust; fi
deploy:
# deploy develop as a snapshot
- provider: script
script: "cp .travis.settings.xml $HOME/.m2/settings.xml && mvn deploy -DskipTests=true"
cleanup: false
skip_cleanup: true # this is the current correct option, soon to be deprecated by the above
on:
branch: develop
# deploy master to production
- provider: script
script: "cp .travis.settings.xml $HOME/.m2/settings.xml && mvn deploy -P release -DskipTests=true"
cleanup: false
skip_cleanup: true # this is the current correct option, soon to be deprecated by the above
on:
branch: master

# Remove the binaries generated by this build so that the cache isn't invalidated.
# Probably a better way to do this.
- provider: script
script: cp .travis.settings.xml $HOME/.m2/settings.xml && mvn deploy -DskipTests=true
cleanup: false
skip_cleanup: true
on:
branch: develop
- provider: script
script: cp .travis.settings.xml $HOME/.m2/settings.xml && mvn deploy -P release
-DskipTests=true
cleanup: false
skip_cleanup: true
on:
branch: master
before_cache:
- rm -rf $HOME/.m2/repository/org/opencds/cqf/cds
- rm -rf $HOME/.m2/repository/org/opencds/cqf/cds
notifications:
slack:
- rooms:
- secure: ECKEk6sCGWP0IdlKx8cW7JMuD5Z9UsrpIa+gcHFyYHTly0ExTAaGAFFbFI3h1hnLdVqlUDhP5F65VXurEJ430Z9nF9Eb5oy+2Evhur5S0jWiHwak8Yf7MAkhf3waAWPtft4I0imMmMHgBSMI9R9VLjCiyhhS90OQpN7giDK0uo6AovijN+UelkZUNMH+6mQS9c1q5BXqoFU90hCCX5VUPPGXAXW535ZadNTd3b284MFVmLxik+p+hg+FxjI5utAA5o5f9uxxAtEBkDgM9vxyDRKKi4rMvNG12YZ/e20RiFJwPcsUA4uuaWqAJP8J9OHRTfrbGbFUDCTaSUp8CZcS/ydoaZBb0BYhF33U19aqYTovdcKzoCmWs5csoEHeFqjKYKyBc6dZcj3sZ1C2HOoz+Hb7uqRAAfi0N+kxTR2j/h1eAPS/28np1Uh1nSuVNx1h3OwCms0fDBNANRcpXOhfI01aV7Zx0HSu4fO9Gek6fJ4mB6eK47cO0H8O9F6px1WtPvaEoCXPoaCCO5QLI+OM/WX+Vj+iYE+3Z/FBBwcTgVrrHc5GFW5SPttr01qKGjkee5VBUkPTL9zr2tvavZYzJ9V25gvCta5ZXDGyLjfW7HoB6dOh9sDpQTzMUnb2AiYKLztEaotQwJRX6Se8ASHpkzbkwMszzmpta2qR1uvsrhE=
on_success: always
on_failure: never
- rooms:
- secure: mtnhu2EQGqxdfEAZ0IpVEzRlFTKwNcGM88YGWmeiSVnmFZJuJfzGxM5bziJMTc+5R3nZcg2fuDyHeSIApLRXsBlQnmuh9TZZMWhDnBDmcd3ead7c8/8/6ap6pSEYhDPtLP4oQ+a7txutd51mGxL1zCPb43RAK573sO9n1e7ujMWsz7IZN6xyd7aHWyTjHTBt83b3gsc6KRdzXRr/1+sYxQQJ21HKtaIdfUCij+HkchwxMTtTZtQbwqbu07j3nyeBEwZhadThVu8bw48ORQuiUUAtUkp9cI5yjGiXhofGiRq5ZAw6qzesdGuT5YhVXd28b4Ljpb0dMNJVAMVspigIFnk1bh6V9c45ZaT6uyudLocHuOKWQKRSt6ntA4/wjU8ubuKb5OEE9s7SD5cddwyz6aoT11qenni2ZD7tJBYrZHTCsATIYwUWZI1IkNC0BqYR0VmCogRDo5ihALCBxlHPNeWIYj0H3Byf+8OuvBQnSrWRDQLRP/GgVjmq80fgUrPzJjGBTcv9xwRd6BQZ+rtpbK/ldPWM3VW/JNXfKwqHBQlEsuv8Id9H5TpfkJkDx57ae8lzB/5ryhAVDbn0JQvxz24r3drECK9vV6An9N4l5vWCJv+qwGttEniWRY8vNdoJnFz00b8WOd23Q1E4ztIXC0c24/amL++t6oZMqNdnik0=
on_success: never
on_failure: always
17 changes: 15 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@

<properties>
<version.major>1</version.major>
<version.minor>1</version.minor>
<version.minor>3</version.minor>
<version.patch>0</version.patch>
<!-- NOTE: Building under the release profile automatically drops the -SNAPSHOT extension -->
<revision>${version.major}.${version.minor}.${version.patch}-SNAPSHOT</revision>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<cql-engine.version>1.4.0</cql-engine.version>
<cql-engine.version>1.5.0</cql-engine.version>
<cql-evaluator-execution.version>1.0.0</cql-evaluator-execution.version>
</properties>

<name>cds-hooks</name>
Expand Down Expand Up @@ -59,6 +60,12 @@
</repositories>

<dependencies>
<dependency>
<groupId>org.opencds.cqf.cql</groupId>
<artifactId>evaluator.execution</artifactId>
<version>${cql-evaluator-execution.version}</version>
</dependency>

<dependency>
<groupId>org.opencds.cqf.cql</groupId>
<artifactId>engine</artifactId>
Expand All @@ -82,6 +89,12 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
2 changes: 2 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
mvn install -U -DskipTests=true -Dmaven.javadoc.skip=true -B -V
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,26 @@
public class DiscoveryResolutionR4 {

private final String PATIENT_ID_CONTEXT = "{{context.patientId}}";
private final int URI_MAX_LENGTH = 8000;
private final int DEFAULT_MAX_URI_LENGTH = 8000;
private int maxUriLength;

private IGenericClient client;

public DiscoveryResolutionR4(IGenericClient client) {
this.client = client;
this.maxUriLength = DEFAULT_MAX_URI_LENGTH;
}

public int getMaxUriLength() {
return this.maxUriLength;
}

public void setMaxUriLength(int maxUriLength) {
if (maxUriLength <= 0) {
throw new IllegalArgumentException("maxUriLength must be >0");
}

this.maxUriLength = maxUriLength;
}

public PlanDefinition resolvePlanDefinition(Bundle.BundleEntryComponent component) {
Expand Down Expand Up @@ -115,10 +129,10 @@ private StringBuilder getCodesStringBuilder(List<String> ret, StringBuilder code
String codeToken = system + "|" + code;
int postAppendLength = codes.length() + codeToken.length();

if (codes.length() > 0 && postAppendLength < URI_MAX_LENGTH) {
if (codes.length() > 0 && postAppendLength < this.maxUriLength) {
codes.append(",");
}
else if (postAppendLength > URI_MAX_LENGTH) {
else if (postAppendLength > this.maxUriLength) {
ret.add(codes.toString());
codes = new StringBuilder();
}
Expand All @@ -128,7 +142,7 @@ else if (postAppendLength > URI_MAX_LENGTH) {

public List<String> createRequestUrl(DataRequirement dataRequirement) {
if (!isPatientCompartment(dataRequirement.getType())) return null;
String patientRelatedResource = dataRequirement.getType() + "?" + getPatientSearchParam(dataRequirement.getType()) + "=" + PATIENT_ID_CONTEXT;
String patientRelatedResource = dataRequirement.getType() + "?" + getPatientSearchParam(dataRequirement.getType()) + "=Patient/" + PATIENT_ID_CONTEXT;
List<String> ret = new ArrayList<>();
if (dataRequirement.hasCodeFilter()) {
for (DataRequirement.DataRequirementCodeFilterComponent codeFilterComponent : dataRequirement.getCodeFilter()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,26 @@
public class DiscoveryResolutionStu3 {

private final String PATIENT_ID_CONTEXT = "{{context.patientId}}";
private final int URI_MAX_LENGTH = 8000;
private final int DEFAULT_MAX_URI_LENGTH = 8000;
private int maxUriLength;

private IGenericClient client;

public DiscoveryResolutionStu3(IGenericClient client) {
this.client = client;
this.maxUriLength = DEFAULT_MAX_URI_LENGTH;
}

public int getMaxUriLength() {
return this.maxUriLength;
}

public void setMaxUriLength(int maxUriLength) {
if (maxUriLength <= 0) {
throw new IllegalArgumentException("maxUriLength must be >0");
}

this.maxUriLength = maxUriLength;
}

public PlanDefinition resolvePlanDefinition(Bundle.BundleEntryComponent component) {
Expand Down Expand Up @@ -114,10 +128,10 @@ private StringBuilder getCodesStringBuilder(List<String> ret, StringBuilder code
String codeToken = system + "|" + code;
int postAppendLength = codes.length() + codeToken.length();

if (codes.length() > 0 && postAppendLength < URI_MAX_LENGTH) {
if (codes.length() > 0 && postAppendLength < this.maxUriLength) {
codes.append(",");
}
else if (postAppendLength > URI_MAX_LENGTH) {
else if (postAppendLength > this.maxUriLength) {
ret.add(codes.toString());
codes = new StringBuilder();
}
Expand All @@ -127,7 +141,7 @@ else if (postAppendLength > URI_MAX_LENGTH) {

public List<String> createRequestUrl(DataRequirement dataRequirement) {
if (!isPatientCompartment(dataRequirement.getType())) return null;
String patientRelatedResource = dataRequirement.getType() + "?" + getPatientSearchParam(dataRequirement.getType()) + "=" + PATIENT_ID_CONTEXT;
String patientRelatedResource = dataRequirement.getType() + "?" + getPatientSearchParam(dataRequirement.getType()) + "=Patient/" + PATIENT_ID_CONTEXT;
List<String> ret = new ArrayList<>();
if (dataRequirement.hasCodeFilter()) {
for (DataRequirement.DataRequirementCodeFilterComponent codeFilterComponent : dataRequirement.getCodeFilter()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;

import org.opencds.cqf.cds.hooks.Hook;
import org.opencds.cqf.cds.providers.ProviderConfiguration;
import org.opencds.cqf.cds.exceptions.NotImplementedException;

import org.cqframework.cql.elm.execution.Library;
Expand Down Expand Up @@ -45,8 +46,10 @@ public abstract class EvaluationContext<T extends IBaseResource> {

private IGenericClient client;

private ProviderConfiguration providerConfiguration;

public EvaluationContext(Hook hook, FhirVersionEnum fhirVersion, IGenericClient fhirClient, Context context,
Library library, T planDefinition) {
Library library, T planDefinition, ProviderConfiguration providerConfiguration) {

// How to determine if it's a local server?
// Local Server url?
Expand All @@ -62,6 +65,8 @@ public EvaluationContext(Hook hook, FhirVersionEnum fhirVersion, IGenericClient

this.client = fhirClient;

this.providerConfiguration = providerConfiguration;

context.registerDataProvider("http://hl7.org/fhir", getDataProvider());
}

Expand Down Expand Up @@ -98,8 +103,6 @@ public Library getLibrary() {
private DataProvider getDataProvider() {
if (remoteProvider == null) {
ModelResolver resolver;

// TODO: Need to factor out all the SearchParamRegistry stuff.
TerminologyProvider terminologyProvider;
switch (fhirVersion) {
case DSTU2:
Expand All @@ -123,6 +126,11 @@ private DataProvider getDataProvider() {
RestFhirRetrieveProvider provider = new RestFhirRetrieveProvider(
new SearchParameterResolver(this.fhirContext), this.getHookFhirClient());
provider.setTerminologyProvider(terminologyProvider);
provider.setExpandValueSets(true);

provider.setExpandValueSets(this.providerConfiguration.getExpandValueSets());
provider.setMaxCodesPerQuery(this.providerConfiguration.getMaxCodesPerQuery());
provider.setSearchStyle(this.providerConfiguration.getSearchStyle());

this.remoteProvider = new CompositeDataProvider(resolver, provider);
}
Expand Down Expand Up @@ -185,6 +193,10 @@ public IGenericClient getHookFhirClient() {
return client;
}

public ProviderConfiguration getProviderConfiguration() {
return this.providerConfiguration;
}

// NOTE: This is an operation defined in the cqf-ruler
abstract List<Object> applyCqlToResources(List<Object> resources);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ca.uhn.fhir.rest.client.api.IGenericClient;

import org.opencds.cqf.cds.hooks.Hook;
import org.opencds.cqf.cds.providers.ProviderConfiguration;
import org.cqframework.cql.elm.execution.Library;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Parameters;
Expand All @@ -12,18 +13,23 @@
import org.opencds.cqf.cql.engine.execution.Context;
import org.opencds.cqf.cql.engine.terminology.TerminologyProvider;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class R4EvaluationContext extends EvaluationContext<PlanDefinition> {

public R4EvaluationContext(Hook hook, FhirVersionEnum fhirVersion, IGenericClient fhirClient,
TerminologyProvider terminologyProvider, Context context, Library library, PlanDefinition planDefinition) {
super(hook, fhirVersion, fhirClient, context, library, planDefinition);
TerminologyProvider terminologyProvider, Context context, Library library, PlanDefinition planDefinition, ProviderConfiguration providerConfiguration) {
super(hook, fhirVersion, fhirClient, context, library, planDefinition, providerConfiguration);
}

@Override
List<Object> applyCqlToResources(List<Object> resources) {
if (resources == null || resources.isEmpty()) {
return new ArrayList<>();
}

Bundle bundle = new Bundle();
for (Object res : resources) {
bundle.addEntry(new Bundle.BundleEntryComponent().setResource((Resource) res));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ca.uhn.fhir.rest.client.api.IGenericClient;

import org.opencds.cqf.cds.hooks.Hook;
import org.opencds.cqf.cds.providers.ProviderConfiguration;
import org.cqframework.cql.elm.execution.Library;
import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.Parameters;
Expand All @@ -12,18 +13,23 @@
import org.opencds.cqf.cql.engine.execution.Context;
import org.opencds.cqf.cql.engine.terminology.TerminologyProvider;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Stu3EvaluationContext extends EvaluationContext<PlanDefinition> {

public Stu3EvaluationContext(Hook hook, FhirVersionEnum fhirVersion, IGenericClient fhirClient,
TerminologyProvider terminologyProvider, Context context, Library library, PlanDefinition planDefinition) {
super(hook, fhirVersion, fhirClient, context, library, planDefinition);
TerminologyProvider terminologyProvider, Context context, Library library, PlanDefinition planDefinition, ProviderConfiguration providerConfiguration) {
super(hook, fhirVersion, fhirClient, context, library, planDefinition, providerConfiguration);
}

@Override
List<Object> applyCqlToResources(List<Object> resources) {
if (resources == null || resources.isEmpty()) {
return new ArrayList<>();
}

Bundle bundle = new Bundle();
for (Object res : resources) {
bundle.addEntry(new Bundle.BundleEntryComponent().setResource((Resource) res));
Expand Down
Loading

0 comments on commit 116c48a

Please sign in to comment.