Skip to content

Commit

Permalink
Merge pull request #756 from samply/release-v0.17.9
Browse files Browse the repository at this point in the history
Release v0.17.9
  • Loading branch information
alexanderkiel authored Jul 1, 2022
2 parents 1bfb78e + 3926bf0 commit 580ec32
Show file tree
Hide file tree
Showing 27 changed files with 374 additions and 80 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## v0.17.9

### Other Improvements

* Implement CQL ToTime and rearrange ToDate and ToDateTime ([#747](https://github.com/samply/blaze/pull/747))
* Improve CQL Error Message on Subtract ([#755](https://github.com/samply/blaze/pull/755))

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

## v0.17.8

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

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.17.8). Look for `blaze-0.17.8-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.17.9). Look for `blaze-0.17.9-standalone.jar`.

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

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

Expand Down
9 changes: 6 additions & 3 deletions modules/anomaly/src/blaze/anomaly.clj
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@


(defmacro try-one
"Applies a try-catch arround `body` catching exceptions of `type`, returning
an anomaly with `category` and possible message of the exception."
"Applies a try-catch form arround `body` catching exceptions of `type`,
returning an anomaly with `category` and possible message of the exception."
[type category & body]
`(try
~@body
Expand All @@ -125,7 +125,10 @@
`(try-one Throwable ~category ~@body))


(defmacro try-anomaly [& body]
(defmacro try-anomaly
"Applies a try-catch form arround `body` catching all Throwables and returns
an anomaly created by the `anomaly` function."
[& body]
`(try
~@body
(catch Throwable e#
Expand Down
12 changes: 11 additions & 1 deletion modules/cql/src/blaze/elm/compiler/type_operators.clj
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,14 @@
(p/to-string x))


;; TODO 22.31. ToTime
;; 22.31. ToTime
(defrecord ToTimeOperatorExpression [operand]
core/Expression
(-eval [_ {:keys [now] :as context} resource scope]
(p/to-time (core/-eval operand context resource scope) now)))


(defmethod core/compile* :elm.compiler.type/to-time
[context {:keys [operand]}]
(when-let [operand (core/compile* context operand)]
(->ToTimeOperatorExpression operand)))
85 changes: 62 additions & 23 deletions modules/cql/src/blaze/elm/date_time.clj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@
(- months (:months other))
(- millis (:millis other)))
(throw (ex-info (str "Invalid RHS subtracting from Period. Expected Period but was `" (type other) "`.")
{:op :subtract :this this :other other})))))
{:op :subtract :this this :other other}))))

Object
(toString [_]
(format "Period[month = %d, millis = %d]" months millis)))


(defn period [years months millis]
Expand Down Expand Up @@ -527,13 +531,43 @@


;; 16.20. Subtract
(defn- year-out-of-range-msg [result period year]
(format "Year %s out of range while subtracting the period %s from the year %s."
result period year))


(defn year-out-of-range-ex-info [year period result]
(ex-info (year-out-of-range-msg result period year)
{:op :subtract :year year :period period}))


(defn- year-month-out-of-range-msg [result period year-month]
(format "Year-month %s out of range while subtracting the period %s from the year-month %s."
result period year-month))


(defn year-month-out-of-range-ex-info [year-month period result]
(ex-info (year-month-out-of-range-msg result period year-month)
{:op :subtract :year-month year-month :period period}))


(defn- date-out-of-range-msg [result period date]
(format "Date %s out of range while subtracting the period %s from the date %s."
result period date))


(defn date-out-of-range-ex-info [date period result]
(ex-info (date-out-of-range-msg result period date)
{:op :subtract :date date :period period}))


(extend-protocol p/Subtract
Year
(subtract [this other]
(if (instance? Period other)
(let [result (time/minus this (time/years (quot (:months other) 12)))]
(if (time/before? result min-year)
(throw (ex-info "Out of range." {:op :subtract :this this :other other}))
(throw (year-out-of-range-ex-info this other result))
result))
(throw (ex-info (str "Invalid RHS adding to Year. Expected Period but was `" (type other) "`.")
{:op :subtract :this this :other other}))))
Expand All @@ -543,7 +577,7 @@
(if (instance? Period other)
(let [result (time/minus this (time/years (quot (:months other) 12)))]
(if (time/before? result date-time-min-year)
(throw (ex-info "Out of range." {:op :subtract :this this :other other}))
(throw (year-out-of-range-ex-info this other result))
result))
(throw (ex-info (str "Invalid RHS adding to Year. Expected Period but was `" (type other) "`.")
{:op :subtract :this this :other other}))))
Expand All @@ -553,7 +587,7 @@
(if (instance? Period other)
(let [result (time/minus this (time/months (:months other)))]
(if (time/before? result min-year-month)
(throw (ex-info "Out of range." {:op :subtract :this this :other other}))
(throw (year-month-out-of-range-ex-info this other result))
result))
(throw (ex-info (str "Invalid RHS adding to YearMonth. Expected Period but was `" (type other) "`.")
{:op :subtract :this this :other other}))))
Expand All @@ -563,7 +597,7 @@
(if (instance? Period other)
(let [result (time/minus this (time/months (:months other)))]
(if (time/before? result date-time-min-year-month)
(throw (ex-info "Out of range." {:op :subtract :this this :other other}))
(throw (year-month-out-of-range-ex-info this other result))
result))
(throw (ex-info (str "Invalid RHS adding to YearMonth. Expected Period but was `" (type other) "`.")
{:op :subtract :this this :other other}))))
Expand All @@ -576,7 +610,7 @@
(time/months (:months other))
(time/days (quot (:millis other) 86400000)))]
(if (time/before? result min-date)
(throw (ex-info "Out of range." {:op :subtract :this this :other other}))
(throw (date-out-of-range-ex-info this other result))
result))
(throw (ex-info (str "Invalid RHS adding to LocalDate. Expected Period but was `" (type other) "`.")
{:op :subtract :this this :other other}))))
Expand All @@ -589,7 +623,7 @@
(time/months (:months other))
(time/days (quot (:millis other) 86400000)))]
(if (time/before? result date-time-min-date)
(throw (ex-info "Out of range." {:op :subtract :this this :other other}))
(throw (date-out-of-range-ex-info this other result))
result))
(throw (ex-info (str "Invalid RHS adding to LocalDate. Expected Period but was `" (type other) "`.")
{:op :subtract :this this :other other}))))
Expand Down Expand Up @@ -1233,14 +1267,6 @@

;; 22.22. ToDate
(extend-protocol p/ToDate
nil
(to-date [_ _])

String
(to-date [s _]
(-> (system/parse-date s)
(ba/exceptionally (constantly nil))))

Year
(to-date [this _]
this)
Expand Down Expand Up @@ -1277,9 +1303,6 @@

;; 22.23. ToDateTime
(extend-protocol p/ToDateTime
nil
(to-date-time [_ _])

Instant
(to-date-time [this now]
(-> (.atOffset this (.getOffset ^OffsetDateTime now))
Expand Down Expand Up @@ -1320,11 +1343,7 @@
OffsetDateTime
(to-date-time [this now]
(-> (.withOffsetSameInstant this (.getOffset ^OffsetDateTime now))
(.toLocalDateTime)))

String
(to-date-time [s now]
(p/to-date-time (system/parse-date-time s) now)))
(.toLocalDateTime))))


;; 22.30. ToString
Expand Down Expand Up @@ -1360,3 +1379,23 @@
LocalDateTime
(to-string [x]
(str x)))


;; 22.31. ToTime
(extend-protocol p/ToTime
LocalTime
(to-time [this _]
this)

LocalDateTime
(to-time [this _]
(.toLocalTime this))

OffsetDateTime
(to-time [this now]
(-> (.withOffsetSameInstant this (.getOffset ^OffsetDateTime now))
(.toLocalTime)))

PrecisionLocalTime
(to-time [this _]
(.-local_time this)))
3 changes: 3 additions & 0 deletions modules/cql/src/blaze/elm/deps_infer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@
(derive :elm.deps.type/to-quantity :elm.deps.type/unary-expression)


;; 22.31. ToTime
(derive :elm.deps.type/to-time :elm.deps.type/unary-expression)


;; 23. Clinical Operators

Expand Down
18 changes: 18 additions & 0 deletions modules/cql/src/blaze/elm/nil.clj
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,18 @@
(to-boolean [_]))


;; 22.22. ToDate
(extend-protocol p/ToDate
nil
(to-date [_ _]))


;; 22.23. ToDateTime
(extend-protocol p/ToDateTime
nil
(to-date-time [_ _]))


;; 22.24. ToDecimal
(extend-protocol p/ToDecimal
nil
Expand Down Expand Up @@ -312,3 +324,9 @@
(extend-protocol p/ToString
nil
(to-string [_]))


;; 22.31. ToTime
(extend-protocol p/ToTime
nil
(to-time [_ _]))
6 changes: 6 additions & 0 deletions modules/cql/src/blaze/elm/protocols.clj
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,9 @@
;; 22.30. ToString
(defprotocol ToString
(to-string [x]))


;; 22.31. ToTime
(defprotocol ToTime
"Converts an object into something usable as Time relative to `now`."
(to-time [x now]))
Loading

0 comments on commit 580ec32

Please sign in to comment.