Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#Use the tomcat image as a base
FROM tomcat:8.5.13-jre8
FROM maven:3.6.0-jdk-8 AS builder
WORKDIR /usr/src/cql_src
ADD . .
RUN git clone https://github.com/DBCG/cql_engine.git
RUN mvn clean install -DskipTests -f /usr/src/cql_src/cql_engine/cql-engine
RUN mvn clean install -DskipTests -f /usr/src/cql_src

FROM tomcat:latest
#move the WAR for contesa to the webapps directory
COPY ./target/CQLExecSvc-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/CQLExecSvc-1.0-SNAPSHOT.war
COPY ./src/main/resources/* /usr/local/tomcat/src/main/resources/
COPY --from=builder /usr/src/cql_src/target/CQLExecSvc-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/CQLExecSvc-1.0-SNAPSHOT.war
COPY --from=builder /usr/src/cql_src/src/main/resources/* /usr/local/tomcat/src/main/resources/
Empty file added Jenkinsfile
Empty file.
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cqlVersion>1.2.52-SNAPSHOT</cqlVersion>
</properties>

<repositories>
Expand All @@ -32,12 +33,12 @@
<dependency>
<groupId>org.opencds.cqf</groupId>
<artifactId>cql-engine</artifactId>
<version>1.2.50-SNAPSHOT</version>
<version>${cqlVersion}</version>
</dependency>
<dependency>
<groupId>org.opencds.cqf</groupId>
<artifactId>cql-engine-fhir</artifactId>
<version>1.2.50-SNAPSHOT</version>
<version>${cqlVersion}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
Expand Down Expand Up @@ -94,6 +95,11 @@
<artifactId>jersey-hk2</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>

<build>
Expand Down
49 changes: 30 additions & 19 deletions src/main/java/org/opencds/cqf/cql/execution/Executor.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
package org.opencds.cqf.cql.execution;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.JAXBException;

import org.cqframework.cql.cql2elm.CqlTranslator;
import org.cqframework.cql.cql2elm.CqlTranslatorException;
import org.cqframework.cql.cql2elm.LibraryManager;
Expand All @@ -12,7 +27,6 @@
import org.cqframework.cql.elm.execution.Library;
import org.cqframework.cql.elm.execution.ParameterDef;
import org.cqframework.cql.elm.tracking.TrackBack;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
Expand All @@ -23,24 +37,16 @@
import org.opencds.cqf.cql.data.fhir.FhirDataProviderStu3;
import org.opencds.cqf.cql.terminology.fhir.FhirTerminologyProvider;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.JAXBException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.*;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;

/**
* Created by Christopher on 1/13/2017.
*/
@Path("evaluate")
public class Executor {

private Map<String, List<Integer>> locations = new HashMap<>();

// for future use
Expand Down Expand Up @@ -220,11 +226,13 @@ public String evaluateCql(String requestData) throws JAXBException, IOException,
String patientId = (String) json.get("patientId");
json.remove("patientId");


CqlTranslator translator;
try {
translator = getTranslator(code, getLibraryManager(), getModelManager());
}
catch (IllegalArgumentException iae) {
iae.printStackTrace();
JSONObject result = new JSONObject();
JSONArray resultArr = new JSONArray();
result.put("translation-error", iae.getMessage());
Expand Down Expand Up @@ -252,9 +260,12 @@ public String evaluateCql(String requestData) throws JAXBException, IOException,
registerProviders(context, terminologyServiceUri, terminologyUser, terminologyPass, dataServiceUri, dataUser, dataPass);

JSONArray resultArr = new JSONArray();
for(ParameterDef def : library.getParameters().getDef()) {
library.getParameters().evaluate(context);
context.setParameter(library.getLocalId(), def.getName(), json.get(def.getName()));
if(library.getParameters() != null) {
for(ParameterDef def:library.getParameters().getDef()) {
if(context.resolveParameterRef(library.getLocalId(), def.getName()) != null) {
context.setParameter(library.getLocalId(), def.getName(), json.get(def.getName()));
}
}
}
for (ExpressionDef def : library.getStatements().getDef()) {
context.enterContext(def.getContext());
Expand Down