Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for translator 3.15.0 #43

Merged
merged 4 commits into from
Sep 19, 2024
Merged
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ EXPOSE 8080

# execute it
# CMD ["mvn", "exec:java"]
CMD ["java", "-jar", "target/cqlTranslationServer-2.4.0.jar", "-d"]
CMD ["java", "-jar", "target/cqlTranslationServer-2.5.0.jar", "-d"]
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Build:

Execute via the command line:

java -jar target/cqlTranslationServer-2.4.0.jar
java -jar target/cqlTranslationServer-2.5.0.jar

_NOTE: The cqlTranslationServer jar assumes that all dependency jars are located in a `libs` directory relative to the jar's location. If you move the jar from the `target` directory, you will need to move the `target/libs` directory as well. This project no longer produces an "uber-jar", as the CQL-to-ELM classes do not function properly when repackaged into a single jar file._

Expand All @@ -17,7 +17,8 @@ _NOTE: The cqlTranslationServer jar assumes that all dependency jars are located
CQL Translation Service versions prior to version 2.0.0 always mirrored the CQL Tools (CQL-to-ELM translator) version they exposed. Starting with version 2.0.0, semantic versioning is now used. As a result, the version of the CQL Translation Service differs from the version of the CQL Tools that it exposes. The following table shows the relationship between [CQL Translation Service releases](https://github.com/cqframework/cql-translation-service/releases) and [CQL Tools releases](https://github.com/cqframework/clinical_quality_language/releases). Note that prior releases from the [MITRE repo](https://github.com/mitre/cql-translation-service/releases) are not included here.

| CQL Translation Service | CQL Tools |
|-------------------------|-----------------------------------------|
| ----------------------- | --------------------------------------- |
| 2.5.0 | 3.15.0 |
| 2.4.0 | 3.7.1 |
| 2.3.0 | 3.3.2 |
| 2.2.0 | 2.11.0 |
Expand Down Expand Up @@ -167,32 +168,33 @@ Will return:

### CQL-to-ELM Translator Options

The CQL-to-ELM translator supports many options to control the output. These options can be passed to the service as query parameters when you post CQL to the service (e.g., `POST http://localhost:8080/cql/translator?annotations=true&result-types=true`). These query parameters are supported for both simple requests and multipart requests. See the table below for the available options:

|Option|Values|Default|
|----|----|----|
|date-range-optimization|true\|false|false|
|annotations|true\|false|false|
|locators|true\|false|false|
|result-types|true\|false|false|
|signatures|None\|Differing\|Overloads\|All|None|
|detailed-errors|true\|false|false|
|disable-list-traversal|true\|false|false|
|disable-list-demotion|true\|false|false|
|disable-list-promotion|true\|false|false|
|enable-interval-demotion|true\|false|false|
|enable-interval-promotion|true\|false|false|
|disable-method-invocation|true\|false|false|
|require-from-keyword|true\|false|false|
|strict|true\|false|false|
|debug|true\|false|false|
|validate-units|true\|false|false|
The CQL-to-ELM translator supports many options to control the output. These options can be passed to the service as query parameters when you post CQL to the service (e.g., `POST http://localhost:8080/cql/translator?annotations=true&result-types=true`). These query parameters are supported for both simple requests and multipart requests. See the table below for the available options:

| Option | Values | Default |
| ------------------------- | ------------------------------- | ------- |
| date-range-optimization | true\|false | false |
| annotations | true\|false | false |
| locators | true\|false | false |
| result-types | true\|false | false |
| signatures | None\|Differing\|Overloads\|All | None |
| detailed-errors | true\|false | false |
| disable-list-traversal | true\|false | false |
| disable-list-demotion | true\|false | false |
| disable-list-promotion | true\|false | false |
| enable-interval-demotion | true\|false | false |
| enable-interval-promotion | true\|false | false |
| disable-method-invocation | true\|false | false |
| require-from-keyword | true\|false | false |
| strict | true\|false | false |
| debug | true\|false | false |
| validate-units | true\|false | false |

For more information on each of these options, see the [CQL-to-ELM Overview](https://github.com/cqframework/clinical_quality_language/blob/master/Src/java/cql-to-elm/OVERVIEW.md#usage).

_**NOTE:**_
* _Previous versions of the CQL-to-ELM Translation Service defaulted **annotations** to true. To align better with the CQL-to-ELM console client, the translation service now defaults annotations to false._
* _Previous versions of the CQL-to-ELM Translation Service allowed list-promotion to be disabled via an extra multipart form field named **disablePromotion**. This is no longer supported, as it was ambiguous and inconsistent with the CQL-to-ELM console client. The **disable-list-promotion** query parameter should be used instead._

- _Previous versions of the CQL-to-ELM Translation Service defaulted **annotations** to true. To align better with the CQL-to-ELM console client, the translation service now defaults annotations to false._
- _Previous versions of the CQL-to-ELM Translation Service allowed list-promotion to be disabled via an extra multipart form field named **disablePromotion**. This is no longer supported, as it was ambiguous and inconsistent with the CQL-to-ELM console client. The **disable-list-promotion** query parameter should be used instead._

## Formatter Endpoint

Expand Down Expand Up @@ -231,7 +233,6 @@ formatted part for each CQL part in the submitted package.

Example usage via HTTP request:


POST /cql/formatter HTTP/1.1
Host: localhost:8080
Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
Expand Down Expand Up @@ -284,22 +285,21 @@ Will return:
42
--Boundary_2_1638692479_1658770032240--


## Docker Deployment

You may deploy pre-built Docker images into your existing hosting environment with:

docker run -d -p 8080:8080 --restart unless-stopped cqframework/cql-translation-service:latest # or any official tag
docker run -d -p 8080:8080 --restart unless-stopped cqframework/cql-translation-service:latest # or any official tag

And you're done. No environment variables or further configuration are needed. Jedis may use your existing Kubernetes, Open Shift etc installations as you see fit. :)

To build your own image for your current architecture:

docker build -t cqframework/cql-translation-service:latest . # but use your your own repo and tag strings!
docker build -t cqframework/cql-translation-service:latest . # but use your your own repo and tag strings!

To build your own image for multiple architectures (e.g., Intel and Mac M1):

docker buildx build --platform linux/amd64,linux/arm64 -t cqframework/cql-translation-service:latest . # but use your your own repo and tag strings!
docker buildx build --platform linux/amd64,linux/arm64 -t cqframework/cql-translation-service:latest . # but use your your own repo and tag strings!

Note that Docker doesn't support loading multi-platform builds locally, so the above multi-platform build commmand is only helpful when used with `--push`. See: [https://github.com/docker/buildx/issues/59](https://github.com/docker/buildx/issues/59).

Expand All @@ -315,7 +315,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
20 changes: 13 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>org.mitre.bonnie</groupId>
<artifactId>cqlTranslationServer</artifactId>
<packaging>jar</packaging>
<version>2.4.0</version>
<version>2.5.0</version>
<name>cqlTranslationServer</name>

<repositories>
Expand All @@ -26,6 +26,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -53,7 +60,7 @@
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>3.1.0-M1</version>
<version>4.0.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand All @@ -62,9 +69,8 @@
<version>3.15.6.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -194,8 +200,8 @@
</build>

<properties>
<cql.version>3.7.1</cql.version>
<jersey.version>3.0.12</jersey.version>
<cql.version>3.15.0</cql.version>
<jersey.version>3.1.8</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.mitre.bonnie.cqlTranslationServer;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
Expand All @@ -14,9 +14,9 @@
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class FormatterResourceTest {

Expand All @@ -26,7 +26,7 @@ public class FormatterResourceTest {
// The CQL formatter is hard-coded to use \r\n for line breaks
private final String newLine = "\r\n";

@Before
@BeforeEach
public void setUp() throws Exception {
// start the server
server = Main.startServer();
Expand All @@ -36,13 +36,13 @@ public void setUp() throws Exception {
target = c.target(Main.BASE_URI.replace("0.0.0.0", "localhost"));
}

@After
@AfterEach
public void tearDown() throws Exception {
server.shutdownNow();
}

@Test
public void testUnformattedLibrary() {
void testUnformattedLibrary() {
String input = "library HelloWorld using QDM define Hello: 'World'";
Response resp = target.path("formatter").request(FormatterResource.CQL_TEXT_TYPE).post(Entity.entity(input, FormatterResource.CQL_TEXT_TYPE));
assertEquals(Status.OK.getStatusCode(), resp.getStatus());
Expand All @@ -62,7 +62,7 @@ public void testUnformattedLibrary() {
}

@Test
public void testInvalidCql() {
void testInvalidCql() {
String input = "lib HelloWorld using QDM define Hello: 'World'";
Response resp = target.path("formatter").request(FormatterResource.CQL_TEXT_TYPE).post(Entity.entity(input, FormatterResource.CQL_TEXT_TYPE));
assertEquals(Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
Expand All @@ -73,7 +73,7 @@ public void testInvalidCql() {
}

@Test
public void testSingleUnformattedLibraryAsMultipart() {
void testSingleUnformattedLibraryAsMultipart() {
String input = "library HelloWorld2 using QDM define Hello: 'World2'";
FormDataMultiPart pkg = new FormDataMultiPart();
pkg.field("foo", input, new MediaType("application", "cql"));
Expand All @@ -99,7 +99,7 @@ public void testSingleUnformattedLibraryAsMultipart() {
}

@Test
public void testTwoUnformattedLibrariesAsMultipart() {
void testTwoUnformattedLibrariesAsMultipart() {
String input = "library HelloWorld3 using FHIR define Hello: 'World3'";
String input2 = "library FHIRHelpers version '4.0.1' using FHIR version '4.0.1'\n" +
"context Patient define \"IsFakeFHIRHelpers\": true";
Expand Down Expand Up @@ -142,7 +142,7 @@ public void testTwoUnformattedLibrariesAsMultipart() {
}

@Test
public void testInvalidCqlInMultipart() {
void testInvalidCqlInMultipart() {
String input = "library HelloWorld3 using FHIR define Hello: 'World3'";
String input2 = "library FHIRHelpers version '4.0.1' using FHIR version '4.0.1'\n" +
"ctx Patient define \"IsFakeFHIRHelpers\": true";
Expand Down
Loading
Loading