Skip to content

Commit e51f33f

Browse files
committed
fix: update structuredefinitions
1 parent 078347f commit e51f33f

14 files changed

+87
-3
lines changed

bb.edn

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{:tasks
2+
{:requires ([babashka.fs :as fs]
3+
[babashka.curl :as curl]
4+
[clojure.java.shell]
5+
[clojure.string :as str]
6+
[cheshire.core :as json]
7+
[clojure.edn :as edn]
8+
[clojure.java.io :as io])
9+
10+
download
11+
{:desc "download deps"
12+
:task
13+
(do
14+
15+
(def deps-downloaded (atom #{}))
16+
(def deps-not-downloaded (atom #{}))
17+
(def base-url "gs://fhir-schema-registry/1.0.0/")
18+
(def resources-dir "./resources")
19+
20+
(defn run-gsutil [command]
21+
(println (str "Running: gsutil " (str/join " " command)))
22+
(let [result (apply shell "gsutil" command)]
23+
(if (= 0 (:exit result))
24+
(println "Success!")
25+
(println "Failed:" (:err result)))))
26+
27+
(defn download-package [package-gs-name dir]
28+
(try
29+
(let [path (str resources-dir "/" dir "/" package-gs-name ".ndjson.gz")]
30+
(run-gsutil ["cp" (str base-url package-gs-name "/package.ndjson.gz")
31+
path])
32+
(swap! deps-downloaded (fn [a] (conj a package-gs-name)))
33+
path)
34+
(catch Exception e
35+
(swap! deps-not-downloaded (fn [a] (conj a package-gs-name)))
36+
(println " ex, continuing " e))))
37+
38+
;; from ndjson.gz
39+
(defn extract-first-line [file-path]
40+
(with-open [reader (-> file-path
41+
io/input-stream
42+
java.util.zip.GZIPInputStream.
43+
io/reader)]
44+
(first (line-seq reader))))
45+
46+
(defn get-dependencies [ndjson-path]
47+
(let [json-str (extract-first-line ndjson-path)
48+
parsed-json (json/parse-string json-str true)]
49+
;; json: [":hl7.fhir.uv.extensions.r4#1.0.0" ":hl7.fhir.r4.core#4.0.1"...]
50+
(mapv
51+
(fn [d] (subs d 1))
52+
(:dependencies parsed-json))))
53+
54+
(defn download-deps [dependencies dir]
55+
(doseq [dep dependencies]
56+
(when-not (get (deref deps-downloaded) dep)
57+
(println "DOWNLOADING " dep)
58+
(def path (download-package dep dir))
59+
(println "\n\n Downloaded deps: " (str (deref deps-downloaded)) "\n\n\n")
60+
(when path
61+
(def more-deps (get-dependencies path))
62+
(when (seq more-deps)
63+
(println " more! " more-deps)
64+
(download-deps more-deps dir))))))
65+
66+
(do
67+
(def us-core-path (download-package "hl7.fhir.us.core#6.1.0" "r4"))
68+
69+
(let [dependencies (get-dependencies us-core-path)]
70+
(download-deps dependencies "r4"))
71+
72+
(def r5 (download-package "hl7.fhir.r5.core#5.0.0" "r5"))
73+
74+
(let [dependencies (get-dependencies r5)]
75+
(download-deps dependencies "r5"))
76+
77+
(def r4b (download-package "hl7.fhir.r4b.core#4.3.0" "r4b"))
78+
79+
(let [dependencies (get-dependencies r4b)]
80+
(download-deps dependencies "r4b"))
81+
82+
(println "Done!")
83+
(println "Deps downloaded: " (str (deref deps-downloaded)))
84+
(println "Deps not downloaded: " (str (deref deps-not-downloaded)))))}}}

dev/user.clj

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
[clojure.data]
1111
[clojure.java.io :as io]))
1212

13-
(def r4-schemas (import/retrieve (import/resource "resources/schemas") {}))
14-
(def r4b-schemas (import/retrieve (import/resource "resources/r4b-schemas") {}))
15-
(def r5-schemas (import/retrieve (import/resource "resources/r5-schemas") {}))
13+
(def r4-schemas (import/retrieve (import/resource "resources/r4") {}))
14+
(def r4b-schemas (import/retrieve (import/resource "resources/r4b") {}))
15+
(def r5-schemas (import/retrieve (import/resource "resources/r5") {}))
1616

1717
(def aidbox-schemas (import/retrieve
1818
(import/resource "http://localhost:8765/api/sdk/fhir-packages")
1.27 MB
Binary file not shown.
65.1 KB
Binary file not shown.
820 Bytes
Binary file not shown.
Binary file not shown.
39.4 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
1.09 KB
Binary file not shown.
18 MB
Binary file not shown.
20.4 MB
Binary file not shown.
1.18 MB
Binary file not shown.
1.22 MB
Binary file not shown.

0 commit comments

Comments
 (0)