Skip to content

Commit

Permalink
Merge pull request #600 from samply/release-v0.15.5
Browse files Browse the repository at this point in the history
Release v0.15.5
  • Loading branch information
alexanderkiel authored Feb 1, 2022
2 parents 5c8f23e + 4ee4458 commit f740d6c
Show file tree
Hide file tree
Showing 12 changed files with 325 additions and 281 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## v0.15.5

### New Features

* Implement FHIRPath Function extension ([#598](https://github.com/samply/blaze/pull/598))

### Bugfixes

* Fix NPE in Reference Resolution ([#599](https://github.com/samply/blaze/pull/599))

The full changelog can be found [here](https://github.com/samply/blaze/milestone/28?closed=1).

## v0.15.4

### Bugfixes
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The goal of this project is to provide a FHIR® Store with an internal CQL Evalu

Blaze passes all [Touchstone FHIR 4.0.1 Basic Tests][12] and almost all [CQL Tests][3]. Please refer to the [Conformance](docs/conformance.md) section and report any issues you encounter during evaluation.

Latest release: [v0.15.4][5]
Latest release: [v0.15.5][5]

## Quick Start

Expand Down Expand Up @@ -72,7 +72,7 @@ Unless required by applicable law or agreed to in writing, software distributed

[3]: <https://cql.hl7.org/tests.html>
[4]: <https://alexanderkiel.gitbook.io/blaze/deployment>
[5]: <https://github.com/samply/blaze/releases/tag/v0.15.4>
[5]: <https://github.com/samply/blaze/releases/tag/v0.15.5>
[6]: <https://www.yourkit.com/java/profiler/>
[7]: <https://www.yourkit.com/.net/profiler/>
[8]: <https://www.yourkit.com/youmonitor/>
Expand Down
4 changes: 2 additions & 2 deletions docs/deployment/docker-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Blaze should log something like this:
2021-06-27T11:02:37.834Z ee086ef908c1 main INFO [blaze.core:64] - JVM version: 16.0.2
2021-06-27T11:02:37.834Z ee086ef908c1 main INFO [blaze.core:65] - Maximum available memory: 1738 MiB
2021-06-27T11:02:37.835Z ee086ef908c1 main INFO [blaze.core:66] - Number of available processors: 8
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.15.4 in 8.2 seconds
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.15.5 in 8.2 seconds
```

In order to test connectivity, query the health endpoint:
Expand All @@ -47,7 +47,7 @@ that should return:
```json
{
"name": "Blaze",
"version": "0.15.4"
"version": "0.15.5"
}
```

Expand Down
12 changes: 6 additions & 6 deletions docs/deployment/manual-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

The installation works under Windows, Linux and macOS. The only dependency is an installed OpenJDK 11. Blaze is tested with [AdoptOpenJDK][1].

Blaze runs on the JVM and comes as single JAR file. Download the most recent version [here](https://github.com/samply/blaze/releases/tag/v0.15.4). Look for `blaze-0.15.4-standalone.jar`.
Blaze runs on the JVM and comes as single JAR file. Download the most recent version [here](https://github.com/samply/blaze/releases/tag/v0.15.5). Look for `blaze-0.15.5-standalone.jar`.

After the download, you can start blaze with the following command (Linux, macOS):

```sh
java -jar blaze-0.15.4-standalone.jar -m blaze.core
java -jar blaze-0.15.5-standalone.jar -m blaze.core
```

Blaze will run with an in-memory, volatile database for testing and demo purposes.
Expand All @@ -17,14 +17,14 @@ Blaze can be run with durable storage by setting the environment variables `STOR
Under Linux/macOS:

```sh
STORAGE=standalone java -jar blaze-0.15.4-standalone.jar -m blaze.core
STORAGE=standalone java -jar blaze-0.15.5-standalone.jar -m blaze.core
```

Under Windows, you need to set the Environment variables in the PowerShell before starting Blaze:

```powershell
$Env:STORAGE="standalone"
java -jar blaze-0.15.4-standalone.jar -m blaze.core
java -jar blaze-0.15.5-standalone.jar -m blaze.core
```

This will create three directories called `index`, `transaction` and `resource` inside the current working directory, one for each database part used.
Expand All @@ -42,7 +42,7 @@ The output should look like this:
2021-06-27T11:02:37.834Z ee086ef908c1 main INFO [blaze.core:64] - JVM version: 16.0.2
2021-06-27T11:02:37.834Z ee086ef908c1 main INFO [blaze.core:65] - Maximum available memory: 1738 MiB
2021-06-27T11:02:37.835Z ee086ef908c1 main INFO [blaze.core:66] - Number of available processors: 8
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.15.4 in 8.2 seconds
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.15.5 in 8.2 seconds
```

In order to test connectivity, query the health endpoint:
Expand All @@ -62,7 +62,7 @@ that should return:
```json
{
"name": "Blaze",
"version": "0.15.4"
"version": "0.15.5"
}
```

Expand Down
114 changes: 67 additions & 47 deletions modules/fhir-path/src/blaze/fhir_path.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns blaze.fhir-path
(:refer-clojure :exclude [eval compile resolve])
(:refer-clojure :exclude [compile eval resolve])
(:require
[blaze.anomaly :as ba :refer [throw-anom]]
[blaze.anomaly-spec]
Expand All @@ -16,30 +16,30 @@
[org.antlr.v4.runtime.tree TerminalNode]
[org.cqframework.cql.gen
fhirpathLexer fhirpathParser
fhirpathParser$TermExpressionContext
fhirpathParser$InvocationExpressionContext
fhirpathParser$IndexerExpressionContext
fhirpathParser$AdditiveExpressionContext
fhirpathParser$TypeExpressionContext
fhirpathParser$UnionExpressionContext
fhirpathParser$EqualityExpressionContext
fhirpathParser$AndExpressionContext
fhirpathParser$InvocationTermContext
fhirpathParser$LiteralTermContext
fhirpathParser$ParenthesizedTermContext
fhirpathParser$NullLiteralContext
fhirpathParser$BooleanLiteralContext
fhirpathParser$StringLiteralContext
fhirpathParser$NumberLiteralContext
fhirpathParser$DateLiteralContext
fhirpathParser$DateTimeLiteralContext
fhirpathParser$MemberInvocationContext
fhirpathParser$FunctionInvocationContext
fhirpathParser$EqualityExpressionContext
fhirpathParser$FunctionContext
fhirpathParser$FunctionInvocationContext
fhirpathParser$IdentifierContext
fhirpathParser$IndexerExpressionContext
fhirpathParser$InvocationExpressionContext
fhirpathParser$InvocationTermContext
fhirpathParser$LiteralTermContext
fhirpathParser$MemberInvocationContext
fhirpathParser$NullLiteralContext
fhirpathParser$NumberLiteralContext
fhirpathParser$ParamListContext
fhirpathParser$TypeSpecifierContext
fhirpathParser$ParenthesizedTermContext
fhirpathParser$QualifiedIdentifierContext
fhirpathParser$IdentifierContext]))
fhirpathParser$StringLiteralContext
fhirpathParser$TermExpressionContext
fhirpathParser$TypeExpressionContext
fhirpathParser$TypeSpecifierContext
fhirpathParser$UnionExpressionContext]))


(set! *warn-on-reflection* true)
Expand Down Expand Up @@ -279,35 +279,6 @@
(throw-anom (ba/incorrect (as-type-specifier-msg coll))))))


;; See: http://hl7.org/fhirpath/#wherecriteria-expression-collection
(defn- non-boolean-result-msg [x]
(format "non-boolean result `%s` of type `%s` while evaluating where function criteria"
(pr-str x) (fhir-spec/fhir-type x)))


(defn- multiple-result-msg [x]
(format "multiple result items `%s` while evaluating where function criteria"
(pr-str x)))


(defrecord WhereFunctionExpression [criteria]
Expression
(-eval [_ context coll]
(filterv
(fn [item]
(let [coll (-eval criteria context [item])]
(case (.count ^Counted coll)
0 false

1 (let [first (nth coll 0)]
(if (identical? :system/boolean (system/type first))
first
(throw-anom (ba/incorrect (non-boolean-result-msg first)))))

(throw-anom (ba/incorrect (multiple-result-msg coll))))))
coll)))


(defrecord OfTypeFunctionExpression [type-specifier]
Expression
(-eval [_ _ coll]
Expand Down Expand Up @@ -368,6 +339,40 @@
(throw-anom (ba/incorrect "missing type specifier in `as` function"))))



;; 5.2. Filtering and projection

;; 5.2.1. where(criteria : expression) : collection

;; See: http://hl7.org/fhirpath/#wherecriteria-expression-collection
(defn- non-boolean-result-msg [x]
(format "non-boolean result `%s` of type `%s` while evaluating where function criteria"
(pr-str x) (fhir-spec/fhir-type x)))


(defn- multiple-result-msg [x]
(format "multiple result items `%s` while evaluating where function criteria"
(pr-str x)))


(defrecord WhereFunctionExpression [criteria]
Expression
(-eval [_ context coll]
(filterv
(fn [item]
(let [coll (-eval criteria context [item])]
(case (.count ^Counted coll)
0 false

1 (let [first (nth coll 0)]
(if (identical? :system/boolean (system/type first))
first
(throw-anom (ba/incorrect (non-boolean-result-msg first)))))

(throw-anom (ba/incorrect (multiple-result-msg coll))))))
coll)))


(defmethod function-expression "where"
[_ ^fhirpathParser$ParamListContext paramsCtx]
(if-let [criteria-ctx (some-> paramsCtx (.expression 0))]
Expand All @@ -389,7 +394,22 @@
(->ExistsFunctionExpression)))


;; See: https://hl7.org/fhir/fhirpath.html#functions

;; Additional functions (https://www.hl7.org/fhir/fhirpath.html#functions)

(defrecord ExtensionFunctionExpression [xf]
Expression
(-eval [_ _ coll]
(into [] xf coll)))


(defmethod function-expression "extension"
[_ ^fhirpathParser$ParamListContext paramsCtx]
(let [url-pred (set (some-> paramsCtx (.expression 0) -compile))
xf (comp (mapcat :extension) (filter (comp url-pred :url)))]
(->ExtensionFunctionExpression xf)))


(defmethod function-expression "resolve"
[_ _]
(->ResolveFunctionExpression))
Expand Down
Loading

0 comments on commit f740d6c

Please sign in to comment.