Skip to content

Commit

Permalink
Merge pull request #287 from samply/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
alexanderkiel authored Dec 13, 2020
2 parents a00ab71 + f2213ca commit df3e18a
Show file tree
Hide file tree
Showing 71 changed files with 1,886 additions and 1,075 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := "0.10.0"
VERSION := "0.10.1"
MODULES := $(wildcard modules/*)

$(MODULES):
Expand Down
6 changes: 3 additions & 3 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 report any issues you encounter during evaluation.

Latest release: [v0.10.0][5]
Latest release: [v0.10.1][5]

## Quick Start

Expand All @@ -24,7 +24,7 @@ In order to run Blaze just execute the following:

```bash
docker volume create blaze-data
docker run -p 8080:8080 -v blaze-data:/app/data samply/blaze:0.10.0
docker run -p 8080:8080 -v blaze-data:/app/data samply/blaze:0.10.1
```

Blaze will create multiple directories inside the `blaze-data` volume on its first start and use the same directories on subsequent starts.
Expand Down Expand Up @@ -63,7 +63,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.10.0>
[5]: <https://github.com/samply/blaze/releases/tag/v0.10.1>
[6]: <https://www.yourkit.com/java/profiler/>
[7]: <https://www.yourkit.com/.net/profiler/>
[8]: <https://www.yourkit.com/youmonitor/>
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.2'
services:
blaze:
image: "samply/blaze:0.10.0"
image: "samply/blaze:0.10.1"
environment:
BASE_URL: "http://localhost:8080"
JAVA_TOOL_OPTIONS: "-Xmx2g"
Expand Down
2 changes: 1 addition & 1 deletion docs/cql-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The most accessible way to create and execute CQL queries is to use the Quality
If you don't already have Blaze running, you can read about how to do it in [Deployment](deployment/). If you have Docker available just run:

```
docker run -p 8080:8080 -v blaze-data:/app/data samply/blaze:0.10.0
docker run -p 8080:8080 -v blaze-data:/app/data samply/blaze:0.10.1
```

Start the Quality Reporting UI. You should see an empty measure list.
Expand Down
8 changes: 4 additions & 4 deletions docs/deployment/docker-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ docker volume create blaze-data
## Blaze

```bash
docker run -d --name blaze -p 8080:8080 -v blaze-data:/app/data samply/blaze:0.10.0
docker run -d --name blaze -p 8080:8080 -v blaze-data:/app/data samply/blaze:0.10.1
```

Blaze should log something like this:
Expand All @@ -29,7 +29,7 @@ Blaze should log something like this:
2020-06-23 08:06:49.235+0000 73c1e4c03d80 INFO [blaze.core:60] - JVM version: 11.0.6
2020-06-23 08:06:49.236+0000 73c1e4c03d80 INFO [blaze.core:61] - Maximum available memory: 1488 MiB
2020-06-23 08:06:49.236+0000 73c1e4c03d80 INFO [blaze.core:62] - Number of available processors: 4
2020-06-23 08:06:49.238+0000 73c1e4c03d80 INFO [blaze.core:63] - Successfully started Blaze version 0.10.0 in 24.9 seconds
2020-06-23 08:06:49.238+0000 73c1e4c03d80 INFO [blaze.core:63] - Successfully started Blaze version 0.10.1 in 24.9 seconds
```

In order to test connectivity, query the health endpoint:
Expand All @@ -49,7 +49,7 @@ that should return:
```javascript
{
"name": "Blaze",
"version": "0.10.0"
"version": "0.10.1"
}
```

Expand All @@ -63,7 +63,7 @@ A Docker Compose file looks like this:
version: '3.2'
services:
blaze:
image: "samply/blaze:0.10.0"
image: "samply/blaze:0.10.1"
environment:
BASE_URL: "http://localhost:8080"
JAVA_TOOL_OPTIONS: "-Xmx2g"
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.9.0). Look for `blaze-0.10.0-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.9.0). Look for `blaze-0.10.1-standalone.jar`.

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

```bash
java -jar blaze-0.10.0-standalone.jar -m blaze.core
java -jar blaze-0.10.1-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:

```bash
STORAGE=standalone java -jar blaze-0.10.0-standalone.jar -m blaze.core
STORAGE=standalone java -jar blaze-0.10.1-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.10.0-standalone.jar -m blaze.core
java -jar blaze-0.10.1-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 Down Expand Up @@ -76,7 +76,7 @@ The output should look like this:
2020-06-23 06:45:06.858+0000 my-server INFO [blaze.core:60] - JVM version: 11.0.7
2020-06-23 06:45:06.859+0000 my-server INFO [blaze.core:61] - Maximum available memory: 4070 MiB
2020-06-23 06:45:06.859+0000 my-server INFO [blaze.core:62] - Number of available processors: 4
2020-06-23 06:45:06.860+0000 my-server INFO [blaze.core:63] - Successfully started Blaze version 0.10.0 in 25,5 seconds
2020-06-23 06:45:06.860+0000 my-server INFO [blaze.core:63] - Successfully started Blaze version 0.10.1 in 25,5 seconds
```

In order to test connectivity, query the health endpoint:
Expand All @@ -96,7 +96,7 @@ that should return:
```javascript
{
"name": "Blaze",
"version": "0.10.0"
"version": "0.10.1"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@


(defn- execute-multi-get [session get-statement hashes]
(map #(ac/->completable-future (execute-get session get-statement %)) hashes))
(mapv #(ac/->completable-future (execute-get session get-statement %)) hashes))


(defn- bind-put [^PreparedStatement statement hash resource]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
(def ^:private entry-thawer
(map
(fn [[k v]]
[(bs/from-byte-array k) (fhir-spec/conform-json (parse-cbor v hash))])))
[(bs/from-byte-array k) (fhir-spec/conform-cbor (parse-cbor v hash))])))


(def ^:private entry-freezer
Expand Down
2 changes: 1 addition & 1 deletion modules/db/test/blaze/db/api_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
(new-kv-resource-store)
(new-random-slow-resource-store))})]
(let [db-futures
(map
(mapv
#(d/transact node [[:create {:fhir/type :fhir/Patient :id (str %)}]])
(range 10))]

Expand Down
18 changes: 18 additions & 0 deletions modules/fhir-structure/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# FHIR Structure

This module provides [specs][1] for the [FHIR Data Model][2] and functions to conform und unform JSON and XML representation to and from the internal representation used by Blaze.

## Examples

### Conforming a JSON Representation to the Internal Representation

```clojure
(use 'blaze.fhir.spec)

(conform-json {:resourceType "Patient" :id "0"})
;;=> {:id "0", :fhir/type :fhir/Patient}
```


[1]: <https://clojure.org/guides/spec>
[2]: <../../docs/implementation/fhir-data-model.md>
35 changes: 17 additions & 18 deletions modules/fhir-structure/src/blaze/fhir/spec/impl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
[cuerdas.core :as str])
(:import
[java.net URLEncoder]
[java.nio.charset StandardCharsets]
[clojure.data.xml.node Element]))


(xml-name/alias-uri 'f "http://hl7.org/fhir")


(def ^:const fhir-namespace
(str "xmlns." (URLEncoder/encode "http://hl7.org/fhir")))
(str "xmlns." (URLEncoder/encode "http://hl7.org/fhir" StandardCharsets/UTF_8)))


(defn- find-fhir-type [{:keys [extension]}]
Expand Down Expand Up @@ -689,16 +690,15 @@


;; Resource Spec
(defn conform-json-resource [{type :resourceType :as resource}]
(s/conform (keyword "fhir.json" type) resource))
(defmulti json-resource identity)


(defn unform-json-resource [{:fhir/keys [type] :as resource}]
(s/unform (keyword "fhir.json" (name type)) resource))
(defmethod json-resource :default [{json-type :resourceType :fhir/keys [type]}]
(keyword "fhir.json" (or json-type (name type))))


(s/def :fhir.json/Resource
(s/conformer conform-json-resource unform-json-resource))
(s/multi-spec json-resource (fn [value tag] (assoc value :resourceType tag))))


(defn conform-cbor-resource [{type :resourceType :as resource}]
Expand All @@ -713,25 +713,24 @@
(s/conformer conform-cbor-resource unform-cbor-resource))


(def ^:const invalid ::s/invalid)
(defmulti xml-resource identity)


(defn conform-xml-resource
{:arglists '([element])}
[{:keys [content]}]
(if-let [{:keys [tag] :as element} (some #(when (element? %) %) content)]
(if-let [spec-key (some->> tag name (keyword "fhir.xml"))]
(s/conform spec-key element)
invalid)
invalid))
(defmethod xml-resource :default [{:keys [tag] :fhir/keys [type]}]
(->> (or tag type) name (keyword "fhir.xml")))


(defn unform-xml-resource [{:fhir/keys [type] :as resource}]
(xml-node/element ::f/resource {} (s/unform (keyword "fhir.xml" (name type)) resource)))
(defn conform-xml-resource [{:keys [content]}]
(some #(when (element? %) %) content))


(defn unform-xml-resource [resource]
(xml-node/element ::f/resource {} resource))


(s/def :fhir.xml/Resource
(s/conformer conform-xml-resource unform-xml-resource))
(s/and (s/conformer conform-xml-resource unform-xml-resource)
(s/multi-spec xml-resource (fn [value _] value))))


;; register all resource specs
Expand Down
14 changes: 0 additions & 14 deletions modules/fhir-structure/test/blaze/fhir/spec/impl_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -481,20 +481,6 @@
(def sexp prxml/sexp-as-element)


(deftest conform-xml-test
(testing "patient resource with mixed character content"
(given (impl/conform-xml :fhir/Patient (sexp [::f/Patient "" [::f/id {:value "0"}]]))
:fhir/type := :fhir/Patient
:id (sexp [::f/id {:value "0"}]))))


(deftest conform-xml-resource-test
(testing "patient resource with mixed character content"
(given (impl/conform-xml-resource (sexp [::f/resource "" [::f/Patient [::f/id {:value "0"}]]]))
:fhir/type := :fhir/Patient
:id "0")))


(deftest elem-def->spec-def
(testing "normal type"
(is (= (impl/elem-def->spec-def
Expand Down
45 changes: 41 additions & 4 deletions modules/fhir-structure/test/blaze/fhir/spec_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,14 @@

(testing "Patient with multipleBirthInteger"
(let [json {:resourceType "Patient" :multipleBirthInteger 2}]
(is (= json (fhir-spec/unform-json {:fhir/type :fhir/Patient :multipleBirth (int 2)}))))))
(is (= json (fhir-spec/unform-json {:fhir/type :fhir/Patient :multipleBirth (int 2)})))))

(testing "Bundle with Patient"
(let [json {:resourceType "Bundle"
:entry
[{:resource
{:resourceType "Patient" :id "0"}}]}]
(is (= json (fhir-spec/unform-json (fhir-spec/conform-json json)))))))


(deftest unform-primitives-test
Expand Down Expand Up @@ -508,7 +515,20 @@
[:fhir/issues 0 :fhir.issues/code] := "invariant"
[:fhir/issues 0 :fhir.issues/diagnostics] :=
"Error on value `1`. Expected type is `HumanName`."
[:fhir/issues 0 :fhir.issues/expression] := "name[0]")))
[:fhir/issues 0 :fhir.issues/expression] := "name[0]"))

(testing "Bundle with invalid Patient gender"
(given (fhir-spec/explain-data-json
{:resourceType "Bundle"
:entry
[{:resource
{:resourceType "Patient"
:gender 1}}]})
[:fhir/issues 0 :fhir.issues/severity] := "error"
[:fhir/issues 0 :fhir.issues/code] := "invariant"
[:fhir/issues 0 :fhir.issues/diagnostics] :=
"Error on value `1`. Expected type is `code`."
[:fhir/issues 0 :fhir.issues/expression] := "entry[0].resource.gender")))


(deftest explain-data-xml
Expand All @@ -528,7 +548,8 @@
(given (fhir-spec/explain-data-xml {:tag "<unknown>"})
[:fhir/issues 0 :fhir.issues/severity] := "error"
[:fhir/issues 0 :fhir.issues/code] := "value"
[:fhir/issues 0 :fhir.issues/diagnostics] := "Unknown resource type `<unknown>`."))
[:fhir/issues 0 :fhir.issues/diagnostics] :=
"Unknown resource type `<unknown>`."))

(testing "invalid resource"
(given (fhir-spec/explain-data-xml
Expand All @@ -538,7 +559,23 @@
[:fhir/issues 0 :fhir.issues/diagnostics] :=
"Error on value ``. Expected type is `code`, regex `[^\\s]+(\\s[^\\s]+)*`."
;; TODO: implement expression for XML
(comment [:fhir/issues 0 :fhir.issues/expression] := "name[0].use"))))
(comment [:fhir/issues 0 :fhir.issues/expression] := "name[0].use")))

(testing "Bundle with invalid Patient gender"
(given (fhir-spec/explain-data-xml
(sexp
[::f/Bundle
[::f/entry
[::f/resource
[::f/Patient [::f/gender {:value " "}]]]]]))
[:fhir/issues 0 :fhir.issues/severity] := "error"
[:fhir/issues 0 :fhir.issues/code] := "invariant"
[:fhir/issues 0 :fhir.issues/diagnostics] :=
"Error on value ` `. Expected type is `code`, regex `[^\\s]+(\\s[^\\s]+)*`."
;; TODO: implement expression for XML
(comment
[:fhir/issues 0 :fhir.issues/expression] :=
"entry[0].resource.gender"))))


(deftest primitive?
Expand Down
6 changes: 3 additions & 3 deletions modules/interaction/src/blaze/interaction/create.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[blaze.anomaly :refer [throw-anom]]
[blaze.async.comp :as ac]
[blaze.db.api :as d]
[blaze.db.spec]
[blaze.fhir.response.create :as response]
[blaze.handler.util :as handler-util]
[blaze.interaction.create.spec]
Expand Down Expand Up @@ -50,9 +51,8 @@
(-> (ac/supply (validate-resource type body))
(ac/then-apply #(assoc % :id id))
(ac/then-compose #(d/transact node [[:create %]]))
;; it's important to switch to the transaction executor here, because
;; otherwise the central indexing thread would execute response
;; building.
;; it's important to switch to the executor here, because otherwise
;; the central indexing thread would execute response building.
(ac/then-apply-async identity executor)
(ac/then-compose
#(response/build-created-response
Expand Down
3 changes: 2 additions & 1 deletion modules/interaction/src/blaze/interaction/delete.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
(:require
[blaze.async.comp :as ac]
[blaze.db.api :as d]
[blaze.db.spec]
[blaze.handler.util :as handler-util]
[blaze.interaction.delete.spec]
[blaze.middleware.fhir.metrics :refer [wrap-observe-request-duration]]
Expand Down Expand Up @@ -50,7 +51,7 @@
(-> (build-response* (d/tx db t))
(ac/completed-future))
(-> (d/transact node [[:delete type id]])
;; it's important to switch to the transaction executor here,
;; it's important to switch to the executor here,
;; because otherwise the central indexing thread would execute
;; response building.
(ac/then-apply-async build-response executor)))
Expand Down
Loading

0 comments on commit df3e18a

Please sign in to comment.