Skip to content

Commit

Permalink
Merge pull request #770 from samply/release-v0.17.11
Browse files Browse the repository at this point in the history
Release v0.17.11
  • Loading branch information
alexanderkiel committed Jul 13, 2022
2 parents ac423e8 + 02f2409 commit d8b317e
Show file tree
Hide file tree
Showing 29 changed files with 436 additions and 196 deletions.
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# Changelog

## v0.17.10
## v0.17.11

### Bugfixes

* Fix Reference Resolution on Extended Primitive References
* Fix Quantity Indexing without Value ([#764](https://github.com/samply/blaze/issues/764))
* Fix Deserialisation of Primitive Values in Extensions ([#767](https://github.com/samply/blaze/issues/767))

### Other Improvements ([#758](https://github.com/samply/blaze/issues/758))

* Implement Functions in CQL ([#766](https://github.com/samply/blaze/pull/766))

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

## v0.17.10

### Bugfixes

* Fix Reference Resolution on Extended Primitive References ([#758](https://github.com/samply/blaze/issues/758))

### Other Improvements

* Implement CQL ConvertsToTime ([#759](https://github.com/samply/blaze/pull/759))

The full changelog can be found [here](https://github.com/samply/blaze/milestone/48?closed=1).
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.10][5]
Latest release: [v0.17.11][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.10>
[5]: <https://github.com/samply/blaze/releases/tag/v0.17.11>
[6]: <https://www.yourkit.com/java/profiler/>
[7]: <https://www.yourkit.com/.net/profiler/>
[8]: <https://www.yourkit.com/youmonitor/>
Expand Down
66 changes: 33 additions & 33 deletions docs/conformance/cql.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The section numbers refer to the documentation of the [ELM Specification](https:
|------|---------------|------------|---------------------------------------------|-------|
| 9.1. | ExpressionDef || | |
| 9.2. | ExpressionRef | ! | only inside same library | |
| 9.3. | FunctionDef | | | |
| 9.3. | FunctionDef | | | |
| 9.4. | FunctionRef | ! | hard coded implementation of some functions | |

### 10. Queries
Expand Down Expand Up @@ -322,38 +322,38 @@ The section numbers refer to the documentation of the [ELM Specification](https:
### 22. Type Operators

| Num | Group | Expression | State | Notes |
|--------|--------------------|-----------|---------------|-------|
| 22.1. | As | ! | no strictness | |
| 22.2. | CanConvert || | |
| 22.3. | CanConvertQuantity || | |
| 22.4. | Children || | |
| 22.5. | Convert || | |
| 22.6. | ConvertQuantity || | |
| 22.7. | ConvertsToBoolean || | |
| 22.8. | ConvertsToDate || | |
| 22.9. | ConvertsToDateTime || | |
| 22.10. | ConvertsToDecimal || | |
| 22.11. | ConvertsToLong || | |
| 22.12. | ConvertsToInteger || | |
| 22.13. | ConvertsToQuantity || | |
| 22.14. | ConvertsToRatio || | |
| 22.15. | ConvertsToString || | |
| 22.16. | ConvertsToTime || | |
| 22.17. | Descendents || | |
| 22.18. | Is || | |
| 22.19. | ToBoolean || | |
| 22.20. | ToChars || | |
| 22.21. | ToConcept || | |
| 22.22. | ToDate || | |
| 22.23. | ToDateTime || | |
| 22.24. | ToDecimal || | |
| 22.25. | ToInteger || | |
| 22.26. | ToList || | |
| 22.27. | ToLong || | |
| 22.28. | ToQuantity || | |
| 22.29. | ToRatio || | |
| 22.30. | ToString || | |
| 22.31. | ToTime || | |
|--------|--------------------|------------|---------------|-------|
| 22.1. | As | ! | no strictness | |
| 22.2. | CanConvert | | | |
| 22.3. | CanConvertQuantity | | | |
| 22.4. | Children | | | |
| 22.5. | Convert | | | |
| 22.6. | ConvertQuantity | | | |
| 22.7. | ConvertsToBoolean | | | |
| 22.8. | ConvertsToDate | | | |
| 22.9. | ConvertsToDateTime | | | |
| 22.10. | ConvertsToDecimal | | | |
| 22.11. | ConvertsToLong | | | |
| 22.12. | ConvertsToInteger | | | |
| 22.13. | ConvertsToQuantity | | | |
| 22.14. | ConvertsToRatio | | | |
| 22.15. | ConvertsToString | | | |
| 22.16. | ConvertsToTime | | | |
| 22.17. | Descendents | | | |
| 22.18. | Is | | | |
| 22.19. | ToBoolean | | | |
| 22.20. | ToChars | | | |
| 22.21. | ToConcept | | | |
| 22.22. | ToDate | | | |
| 22.23. | ToDateTime | | | |
| 22.24. | ToDecimal | | | |
| 22.25. | ToInteger | | | |
| 22.26. | ToList | | | |
| 22.27. | ToLong | | | |
| 22.28. | ToQuantity | | | |
| 22.29. | ToRatio | | | |
| 22.30. | ToString | | | |
| 22.31. | ToTime | | | |

### 23. Clinical Operators

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.10 in 8.2 seconds
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.17.11 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.10"
"version": "0.17.11"
}
```

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.10). Look for `blaze-0.17.10-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.11). Look for `blaze-0.17.11-standalone.jar`.

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

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

Expand Down
6 changes: 5 additions & 1 deletion modules/cql/src/blaze/elm/compiler/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@


(defmulti compile*
"Compiles `expression` in `context`."
"Compiles `expression` in `context`.
Context consists of:
* :library - the library in it's ELM form
* :node - the database node"
{:arglists '([context expression])}
(fn [_ {:keys [type] :as expr}]
(assert (string? type) (format "Missing :type in expression `%s`." (pr-str expr)))
Expand Down
8 changes: 6 additions & 2 deletions modules/cql/src/blaze/elm/compiler/external_data.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
(defrecord CompartmentListRetrieveExpression [context data-type]
core/Expression
(-eval [_ {:keys [db]} {:keys [id]} _]
(d/list-compartment-resource-handles db context id data-type)))
(d/list-compartment-resource-handles db context id data-type))
(-form [_]
`(~'compartment-list-retrieve ~data-type)))


(defrecord CompartmentQueryRetrieveExpression [query data-type clauses]
Expand Down Expand Up @@ -93,7 +95,9 @@
(defrecord ResourceRetrieveExpression []
core/Expression
(-eval [_ _ resource _]
[resource]))
[resource])
(-form [_]
(list 'retrieve-resource)))


(def ^:private resource-expr
Expand Down
12 changes: 12 additions & 0 deletions modules/cql/src/blaze/elm/compiler/function.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns blaze.elm.compiler.function
(:require
[blaze.elm.compiler.core :as core]))


(defn arity-n [name fn-expr operand-names operands]
(reify core/Expression
(-eval [_ context resource scope]
(let [values (map #(core/-eval % context resource scope) operands)]
(core/-eval fn-expr context resource (merge scope (zipmap operand-names values)))))
(-form [_]
`(~'call ~name ~@(map core/-form operands)))))
58 changes: 38 additions & 20 deletions modules/cql/src/blaze/elm/compiler/library.clj
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
(ns blaze.elm.compiler.library
(:require
[blaze.anomaly :as ba :refer [when-ok]]
[blaze.anomaly :as ba :refer [if-ok when-ok]]
[blaze.elm.compiler :as compiler]
[blaze.elm.compiler.function :as function]
[blaze.elm.deps-infer :as deps-infer]
[blaze.elm.equiv-relationships :as equiv-relationships]
[blaze.elm.normalizer :as normalizer]))


(defn- compile-expression-def
"Compiles the expression of `expression-def` in `context` and associates the
resulting compiled expression under ::compiler/expression to the
`expression-def` which itself is returned.
Returns an anomaly on errors."
{:arglists '([context expression-def])}
[context {:keys [expression] :as expression-def}]
(let [context (assoc context :eval-context (:context expression-def))]
(-> (ba/try-anomaly
(assoc expression-def
::compiler/expression (compiler/compile context expression)))
"Compiles the expression of `def` in `context` and returns a tuple of
`[name compiled-expression]` or an anomaly on errors."
[context {:keys [name expression] :as def}]
(let [context (assoc context :eval-context (:context def))]
(-> (ba/try-anomaly [name (compiler/compile context expression)])
(ba/exceptionally
#(assoc % :context context :elm/expression expression)))))


(defn- expr-defs [context library]
(defn- compile-function-def
"Compiles the function of `def` in `context`.
Returns the compiled function or an anomaly on errors."
[context {:keys [name operand] :as def}]
(when-ok [[_ expression] (compile-expression-def context def)]
(partial function/arity-n name expression (mapv :name operand))))


(defn- compile-function-defs [context library]
(transduce
(comp (map (partial compile-expression-def context))
(halt-when ba/anomaly?))
(filter (comp #{"FunctionDef"} :type))
(completing
(fn [r {:keys [name] ::compiler/keys [expression]}]
(assoc r name expression)))
{}
(fn [context {:keys [name] :as def}]
(if-ok [function (compile-function-def context def)]
(assoc-in context [:functions name] function)
reduced)))
context
(-> library :statements :def)))


(defn- expression-defs [context library]
(when-ok [context (compile-function-defs context library)]
(transduce
(comp (filter (comp nil? :type))
(map (partial compile-expression-def context))
(halt-when ba/anomaly?))
(completing
(fn [r [name expression]]
(assoc r name expression)))
{}
(-> library :statements :def))))


(defn- compile-parameter-def
"Compiles the default value of `parameter-def` in `context` and associates the
resulting compiled default value under :default to the `parameter-def` which
Expand Down Expand Up @@ -71,7 +89,7 @@
equiv-relationships/find-equiv-rels-library
deps-infer/infer-library-deps)
context (assoc opts :node node :library library)]
(when-ok [expr-defs (expr-defs context library)
(when-ok [expression-defs (expression-defs context library)
parameter-default-values (parameter-default-values context library)]
{:compiled-expression-defs expr-defs
{:compiled-expression-defs expression-defs
:parameter-default-values parameter-default-values})))
22 changes: 8 additions & 14 deletions modules/cql/src/blaze/elm/compiler/queries.clj
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,6 @@
(throw (Exception. (str "Unsupported number of " (count sources) " sources in query.")))))


;; ?.? IdentifierRef
;;
;; The IdentifierRef type defines an expression that references an identifier
;; that is either unresolved, or has been resolved to an attribute in an
;; unambiguous iteration scope such as a sort. Implementations should attempt to
;; resolve the identifier, only throwing an error at compile-time (or run-time
;; for an interpretive system) if the identifier reference cannot be resolved.
(defmethod core/compile* :elm.compiler.type/identifier-ref
[_ {:keys [name]}]
(structured-values/->SingleScopePropertyExpression (keyword name)))


;; 10.3. AliasRef
;;
;; The AliasRef expression allows for the reference of a specific source within
Expand All @@ -336,7 +324,13 @@
(->AliasRefExpression name)))


;; 10.12. With
;; 10.7 IdentifierRef
(defmethod core/compile* :elm.compiler.type/identifier-ref
[_ {:keys [name]}]
(structured-values/->SingleScopePropertyExpression (keyword name)))


;; 10.14. With
;;
;; The With clause restricts the elements of a given source to only those
;; elements that have elements in the related source that satisfy the suchThat
Expand Down Expand Up @@ -386,4 +380,4 @@
(format "Unsupported call without single query scope.")))))


;; TODO 10.13. Without
;; TODO 10.15. Without
Loading

0 comments on commit d8b317e

Please sign in to comment.