Skip to content

Commit

Permalink
chore: add useful shortcuts in dev/user
Browse files Browse the repository at this point in the history
  • Loading branch information
krvital committed Sep 25, 2024
1 parent 4da9105 commit e0d2dd3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 24 deletions.
54 changes: 40 additions & 14 deletions dev/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,29 @@
[clojure.spec.alpha :as s]
[clojure.data]
[clojure.java.io :as io]
[aidbox-sdk.generator.typescript :as gen.typescript]))
[aidbox-sdk.generator.typescript :as gen.typescript]
[clojure.data.json :as json]))

(defonce aidbox-schemas (atom nil))

(defn load-aidbox-schemas []
(reset! aidbox-schemas
(import/retrieve
(import/resource "http://localhost:8765/api/sdk/fhir-packages") {:auth "YmFzaWM6c2VjcmV0"}))
(import/resource "http://localhost:3333/r4/fhir-packages") {:auth "YmFzaWM6c2VjcmV0"}))
nil)

(comment
(load-aidbox-schemas)

(defonce r4-schemas (import/retrieve (import/resource "resources/r4") {}))
(defonce r4b-schemas (import/retrieve (import/resource "resources/r4b") {}))
(defonce r5-schemas (import/retrieve (import/resource "resources/schemas/r5") {}))

)

(defonce r5-schemas (import/retrieve (import/resource "resources/schemas/r5") {})))

(defn kinds [schemas] (distinct (map :kind schemas)))
(defn resource-types [schemas] (distinct (map :resourceType schemas)))
(defn packages [schemas] (distinct (map :package schemas)))

(defn exclude-keys [m keys]
(apply dissoc m keys))
(defn exclude-keys [m keys] (apply dissoc m keys))

(defn filter-by-url [url schemas]
(filter #(= url (:url %)) schemas))
Expand Down Expand Up @@ -100,16 +97,45 @@
constraint-ir-schemas (converter/convert-constraints constraint-schemas
(remove fhir/constraint? ir-schemas))]

ir-schemas
)
(map models/validate-fhir-schema fhir-schemas)

:rcf)
#_(filter-by-url "http://hl7.org/fhir/StructureDefinition/Resource" fhir-schemas))

;
)

(comment
;; Mock Server

;; run server
(do (require '[mock-server.main :as server])
(def mock-server (server/run)))

;; stop server
(mock-server)

;
)


(comment
(sdk/generate! :dotnet
"http://localhost:3333/r4/fhir-packages"
{:output-dir "dist/dotnet"
:auth-token "YmFzaWM6c2VjcmV0"
:exit (fn [_] nil)})

(sdk/generate! :typescript
"http://localhost:3333/r4/fhir-packages"
{:output-dir "dist/typescript"
:auth-token "YmFzaWM6c2VjcmV0"
:exit (fn [_] nil)})

(sdk/generate! :python
"http://localhost:8765/api/sdk/fhir-packages"
{:output-dir "out"
"http://localhost:3333/r4/fhir-packages"
{:output-dir "dist/python"
:auth-token "YmFzaWM6c2VjcmV0"
:exit (fn [_] nil)})

:rcf)
;
)
12 changes: 2 additions & 10 deletions src/mock_server/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@
;; else
(not-found)))

(defn -main []
(server/run-server app {:port 3333}))
(defn run [] (server/run-server app {:port 3333}))

(comment
(def my-server (server/run-server app {:port 3333}))

;; stop server
(my-server)

;
)
(defn -main [] (run))

0 comments on commit e0d2dd3

Please sign in to comment.