Skip to content

Commit

Permalink
Merge pull request #648 from samply/release-v0.16.3
Browse files Browse the repository at this point in the history
Release v0.16.3
  • Loading branch information
alexanderkiel authored Mar 16, 2022
2 parents a2297e8 + 3ce11a1 commit c3aafe0
Show file tree
Hide file tree
Showing 25 changed files with 163 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup clj-kondo
uses: DeLaGuardo/setup-clj-kondo@master
with:
version: '2022.03.04'
version: '2022.03.09'

- name: Check out Git repository
uses: actions/checkout@v3
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## v0.16.3

### Bugfixes

* Trim Values in FHIR Search ([#644](https://github.com/samply/blaze/pull/644))

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

## v0.16.2

### 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.16.2][5]
Latest release: [v0.16.3][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.16.2>
[5]: <https://github.com/samply/blaze/releases/tag/v0.16.3>
[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.16.2 in 8.2 seconds
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.16.3 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.16.2"
"version": "0.16.3"
}
```

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.16.2). Look for `blaze-0.16.2-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.16.3). Look for `blaze-0.16.3-standalone.jar`.

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

```sh
java -jar blaze-0.16.2-standalone.jar -m blaze.core
java -jar blaze-0.16.3-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.16.2-standalone.jar -m blaze.core
STORAGE=standalone java -jar blaze-0.16.3-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.16.2-standalone.jar -m blaze.core
java -jar blaze-0.16.3-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.16.2 in 8.2 seconds
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.16.3 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.16.2"
"version": "0.16.3"
}
```

Expand Down
2 changes: 1 addition & 1 deletion modules/cassandra/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

;; current version of transitive dependency of com.datastax.oss/java-driver-core
io.netty/netty-handler
{:mvn/version "4.1.74.Final"}}
{:mvn/version "4.1.75.Final"}}

:aliases
{:test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
#(case (::spq/category %)
::spq/invalid-decimal-value
(assoc %
::anom/message (spq/invalid-decimal-value-msg code v2))
::anom/message (u/invalid-decimal-value-msg code v2))
::spq/unsupported-prefix
(assoc %
::anom/message
(spq/unsupported-prefix-msg
(u/unsupported-prefix-msg
code (::spq/unsupported-prefix %)))
%))))

Expand Down
6 changes: 1 addition & 5 deletions modules/db/src/blaze/db/impl/search_param/date.clj
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@
(format "Invalid date-time value `%s` in search parameter `%s`." value code))


(defn- unsupported-prefix-msg [code op]
(format "Unsupported prefix `%s` in search parameter `%s`." (name op) code))


(defn- resource-keys!
([context c-hash tid {:keys [op lower-bound upper-bound]}]
(case op
Expand Down Expand Up @@ -221,7 +217,7 @@
(:le :lt)
{:op op
:upper-bound (date-ub date-time-value)}
(ba/unsupported (unsupported-prefix-msg code op)))
(ba/unsupported (u/unsupported-prefix-msg code op)))
#(assoc % ::anom/message (invalid-date-time-value-msg code value)))))

(-resource-handles [_ context tid _ value]
Expand Down
25 changes: 3 additions & 22 deletions modules/db/src/blaze/db/impl/search_param/number.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,6 @@
(set! *warn-on-reflection* true)



;; ---- compile-value ---------------------------------------------------------

(defn invalid-decimal-value-msg [code value]
(format "Invalid decimal value `%s` in search parameter `%s`." value code))


(defn unsupported-prefix-msg [code op]
(format "Unsupported prefix `%s` in search parameter `%s`." (name op) code))


(defn- eq-value [decimal-value]
(let [delta (.movePointLeft 0.5M (.scale ^BigDecimal decimal-value))]
{:op :eq
:lower-bound (codec/number (- decimal-value delta))
:exact-value (codec/number decimal-value)
:upper-bound (codec/number (+ decimal-value delta))}))


(defmulti index-entries
"Returns index entries for `value` from a resource."
{:arglists '([url value])}
Expand Down Expand Up @@ -66,16 +47,16 @@
(if-ok [decimal-value (system/parse-decimal value)]
(case op
:eq
(eq-value decimal-value)
(u/eq-value codec/number decimal-value)
(:gt :lt :ge :le)
{:op op :exact-value (codec/number decimal-value)}
(ba/unsupported
(unsupported-prefix-msg code op)
(u/unsupported-prefix-msg code op)
::category ::unsupported-prefix
::unsupported-prefix op))
#(assoc %
::category ::invalid-decimal-value
::anom/message (invalid-decimal-value-msg code value)))))
::anom/message (u/invalid-decimal-value-msg code value)))))

(-resource-handles [_ context tid _ value]
(coll/eduction
Expand Down
27 changes: 4 additions & 23 deletions modules/db/src/blaze/db/impl/search_param/quantity.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,6 @@
(set! *warn-on-reflection* true)



;; ---- compile-value ---------------------------------------------------------

(defn invalid-decimal-value-msg [code value]
(format "Invalid decimal value `%s` in search parameter `%s`." value code))


(defn unsupported-prefix-msg [code op]
(format "Unsupported prefix `%s` in search parameter `%s`." (name op) code))


(defn- eq-value [unit decimal-value]
(let [delta (.movePointLeft 0.5M (.scale ^BigDecimal decimal-value))]
{:op :eq
:lower-bound (codec/quantity unit (- decimal-value delta))
:exact-value (codec/quantity unit decimal-value)
:upper-bound (codec/quantity unit (+ decimal-value delta))}))


(defmulti index-entries
"Returns index entries for `value` from a resource."
{:arglists '([url value])}
Expand Down Expand Up @@ -302,20 +283,20 @@
p/SearchParam
(-compile-value [_ _ value]
(let [[op value-and-unit] (u/separate-op value)
[value unit] (str/split value-and-unit #"\|" 2)]
[value unit] (str/split value-and-unit #"\s*\|\s*" 2)]
(if-ok [decimal-value (system/parse-decimal value)]
(case op
:eq
(eq-value unit decimal-value)
(u/eq-value (partial codec/quantity unit) decimal-value)
(:gt :lt :ge :le)
{:op op :exact-value (codec/quantity unit decimal-value)}
(ba/unsupported
(unsupported-prefix-msg code op)
(u/unsupported-prefix-msg code op)
::category ::unsupported-prefix
::unsupported-prefix op))
#(assoc %
::category ::invalid-decimal-value
::anom/message (invalid-decimal-value-msg code value)))))
::anom/message (u/invalid-decimal-value-msg code value)))))

(-resource-handles [_ context tid _ value]
(coll/eduction
Expand Down
26 changes: 22 additions & 4 deletions modules/db/src/blaze/db/impl/search_param/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[blaze.byte-string :as bs]
[blaze.db.impl.byte-buffer :as bb]
[blaze.db.impl.codec :as codec]
[blaze.fhir.spec :as fhir-spec])
[blaze.fhir.spec :as fhir-spec]
[clojure.string :as str])
(:import
[clojure.lang IReduceInit Indexed]))

Expand All @@ -18,9 +19,10 @@
returns a tuple of operator and value. The default operator :eq is returned if
no prefix was given."
[value]
(if (re-find #"^(eq|ne|gt|lt|ge|le|sa|eb|ap)" value)
[(keyword (subs value 0 2)) (subs value 2)]
[:eq value]))
(let [value (str/trim value)]
(if (re-find #"^(eq|ne|gt|lt|ge|le|sa|eb|ap)" value)
[(keyword (subs value 0 2)) (str/trim (subs value 2))]
[:eq value])))


(defn format-skip-indexing-msg [value url type]
Expand Down Expand Up @@ -103,3 +105,19 @@
(let [id (.substring s (unchecked-inc-int idx))]
(when (.matches (re-matcher #"[A-Za-z0-9\-\.]{1,64}" id))
[type id])))))))


(defn invalid-decimal-value-msg [code value]
(format "Invalid decimal value `%s` in search parameter `%s`." value code))


(defn unsupported-prefix-msg [code op]
(format "Unsupported prefix `%s` in search parameter `%s`." (name op) code))


(defn eq-value [f ^BigDecimal decimal-value]
(let [delta (.movePointLeft 0.5M (.scale decimal-value))]
{:op :eq
:lower-bound (f (.subtract decimal-value delta))
:exact-value (f decimal-value)
:upper-bound (f (.add decimal-value delta))}))
1 change: 1 addition & 0 deletions modules/db/test/blaze/db/impl/search_param/number_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[blaze.db.impl.search-param :as search-param]
[blaze.db.impl.search-param-spec]
[blaze.db.impl.search-param.number :as spn]
[blaze.db.impl.search-param.util-spec]
[blaze.db.search-param-registry :as sr]
[blaze.fhir-path :as fhir-path]
[blaze.fhir.hash :as hash]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[blaze.db.impl.index.search-param-value-resource-spec]
[blaze.db.impl.search-param.quantity :as spq]
[blaze.db.impl.search-param.quantity.spec]
[blaze.db.impl.search-param.util-spec]
[blaze.db.spec]
[blaze.fhir.spec.type.system-spec]
[clojure.spec.alpha :as s]))
Expand Down
13 changes: 11 additions & 2 deletions modules/db/test/blaze/db/impl/search_param/quantity_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@

"23.4" (codec/quantity nil 23.35M) (codec/quantity nil 23.45M)
"23.0|kg/m2" (codec/quantity "kg/m2" 22.95M) (codec/quantity "kg/m2" 23.05M)
;; with white space between value and unit
"23.0| kg/m2" (codec/quantity "kg/m2" 22.95M) (codec/quantity "kg/m2" 23.05M)
"23.0 | kg/m2" (codec/quantity "kg/m2" 22.95M) (codec/quantity "kg/m2" 23.05M)
"0.1" (codec/quantity nil 0.05M) (codec/quantity nil 0.15M)
"0" (codec/quantity nil -0.5M) (codec/quantity nil 0.5M)
"0.0" (codec/quantity nil -0.05M) (codec/quantity nil 0.05M)))
Expand All @@ -113,8 +116,14 @@
:op := op
:exact-value := exact-value)

(str (name op) "23") (codec/quantity nil 23M)
(str (name op) "0.1") (codec/quantity nil 0.1M))))
(str (name op) "23.4") (codec/quantity nil 23.4M)
(str (name op) "23.0|kg/m2") (codec/quantity "kg/m2" 23.0M)
;; with white space between value and unit
(str (name op) "23.0| kg/m2") (codec/quantity "kg/m2" 23.0M)
(str (name op) "23.0 | kg/m2") (codec/quantity "kg/m2" 23.0M)
(str (name op) "0.1") (codec/quantity nil 0.1M)
;; with white space between op and value
(str (name op) " 1") (codec/quantity nil 1M))))

(testing "invalid decimal value"
(given (search-param/compile-values
Expand Down
10 changes: 10 additions & 0 deletions modules/db/test/blaze/db/impl/search_param/util_spec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@
[clojure.spec.alpha :as s]))


(s/fdef u/separate-op
:args (s/cat :value string?)
:ret (s/tuple keyword? string?))


(s/fdef u/resource-handle-mapper
:args (s/cat :context :blaze.db.impl.batch-db/context :tid :blaze.db/tid))


(s/fdef u/eq-value
:args (s/cat :f ifn? :decimal-value decimal?)
:ret map?)
5 changes: 5 additions & 0 deletions modules/db/test/blaze/db/impl/search_param/util_test.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns blaze.db.impl.search-param.util-test
(:require
[blaze.db.impl.search-param.util :as util]
[blaze.db.impl.search-param.util-spec]
[clojure.spec.test.alpha :as st]
[clojure.test :as test :refer [are deftest is]]
[taoensso.timbre :as log]))
Expand All @@ -22,7 +23,11 @@
(deftest separate-op-test
(are [value tuple] (= tuple (util/separate-op value))
"1" [:eq "1"]
" 1" [:eq "1"]
"1 " [:eq "1"]
" 1 " [:eq "1"]
"eq1" [:eq "1"]
"eq 1" [:eq "1"]
"ne1" [:ne "1"]
"fo1" [:eq "fo1"]
"1ne" [:eq "1ne"]))
Expand Down
6 changes: 5 additions & 1 deletion modules/interaction/src/blaze/interaction/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
[]
(comp
(remove remove-query-param?)
(mapcat (fn [[k v]] (mapv #(into [k] (str/split % #",")) (fhir-util/to-seq v)))))
(mapcat
(fn [[k v]]
(map
#(into [k] (map str/trim) (str/split % #","))
(fhir-util/to-seq v)))))
query-params))


Expand Down
Loading

0 comments on commit c3aafe0

Please sign in to comment.