Skip to content

Commit 5e7a228

Browse files
committed
fix(dotnet): make it being able to pack as nuget package
Fixed all the errors I got on running `dotnet pack --configuration Release`
1 parent bffc4f9 commit 5e7a228

File tree

8 files changed

+323
-256
lines changed

8 files changed

+323
-256
lines changed

src/aidbox_sdk/converter.clj

+20-2
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
(url->resource-name (get schema :base)))
198198
:fhir-version (get schema :fhir-version)
199199
:package (get schema :package)
200+
:service-type? (fhir/service-type? schema)
200201
:url (get schema :url)
201202
:type (get schema :type)
202203
:derivation (get schema :derivation))))))
@@ -216,6 +217,23 @@
216217
x))
217218
elements))))
218219

220+
(defn add-service-type-flag
221+
"Adds `service-type` flag to each element. The value will be `true` if type of
222+
element belongs to service-types, and `false` otherwise."
223+
[schema]
224+
(letfn [(update-elements [elements]
225+
(walk/postwalk
226+
(fn [x]
227+
(if (:type x)
228+
(let [service-type? (fhir/service-type-element? (:fhir-version schema) x)]
229+
(assoc x :service-type service-type?))
230+
x))
231+
elements))]
232+
(-> schema
233+
(update :elements update-elements)
234+
(update :backbone-elements (fn [backbone-elements]
235+
(for [backbone backbone-elements]
236+
(update backbone :elements update-elements)))))))
219237
;;
220238

221239
(defn find-elements-by-names [element-names schema]
@@ -267,7 +285,6 @@
267285
;; Convert main function
268286
;;
269287

270-
271288
(defn convert [schemas]
272289
(->> schemas
273290
(map resolve-element-references)
@@ -276,7 +293,8 @@
276293
(map (fn [schema]
277294
(update schema :backbone-elements #(resolve-choices (flatten-backbones % [])))))
278295
(resolve-choices)
279-
(resolve-dependencies)))
296+
(resolve-dependencies)
297+
(map add-service-type-flag)))
280298

281299
;;
282300
;; Search Params

src/aidbox_sdk/fhir.clj

+35-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
;; Base Types and Datatypes
77

8-
(def r4-base-types #{"Element" "Resource" "DomainResource"})
8+
(def r4-base-types #{"Element" "Resource" "DomainResource"
9+
;; NOTE: technically `Bundle` is not a base type,
10+
;; but it's here for a reason.
11+
"Bundle"})
912

1013
(def r4-primitive-types
1114
#{"boolean" "integer" "string" "decimal" "uri" "url" "canonical" "base64Binary"
@@ -32,6 +35,13 @@
3235
r4-metadata-types
3336
r4-special-purpose-datatypes))
3437

38+
(def r4-service-types
39+
"This is special set of types that are not represented in FHIR in no way,
40+
but are needed for SDK generation. Essentially, service schemas are:
41+
base types + datatypes - primitive-types."
42+
(set/union (set/difference r4-datatypes r4-primitive-types)
43+
r4-base-types))
44+
3545
(def r4b-base-types r4-base-types)
3646

3747
(def r4b-primitive-types r4-primitive-types)
@@ -51,6 +61,13 @@
5161
r4b-metadata-types
5262
r4b-special-purpose-datatypes))
5363

64+
(def r4b-service-types
65+
"This is special set of types that are not represented in FHIR in no way,
66+
but are needed for SDK generation. Essentially, service schemas are:
67+
base types + datatypes - primitive-types."
68+
(set/union (set/difference r4b-datatypes r4b-primitive-types)
69+
r4b-base-types))
70+
5471
(def r5-base-types
5572
#{"Base" "Element" "BackboneElement" "DataType" "PrimitiveType" "BackboneType"
5673
"Resource" "DomainResource" "CanonicalResource" "MetadataResource"})
@@ -73,6 +90,13 @@
7390
r5-metadata-types
7491
r5-special-purpose-datatypes))
7592

93+
(def r5-service-types
94+
"This is special set of types that are not represented in FHIR in no way,
95+
but are needed for SDK generation. Essentially, service schemas are:
96+
base types + datatypes - primitive-types."
97+
(set/union (set/difference r5-datatypes r5-primitive-types)
98+
r5-base-types))
99+
76100
;; Predicates
77101
(defn resource-type-pred [rt] (fn [schema] (= rt (:resourceType schema))))
78102
(defn kind-pred [kind] (fn [schema] (= kind (:kind schema))))
@@ -162,3 +186,13 @@
162186

163187
(defn base-package? [schema]
164188
(contains? #{"hl7.fhir.r4.core" "hl7.fhir.r4b.core" "hl7.fhir.r5.core"} (:package schema)))
189+
190+
(defmulti service-type? :fhir-version)
191+
(defmethod service-type? "hl7.fhir.r4.core" [schema] (contains? r4-service-types (:id schema)))
192+
(defmethod service-type? "hl7.fhir.r4b.core" [schema] (contains? r4b-service-types (:id schema)))
193+
(defmethod service-type? "hl7.fhir.r5.core" [schema] (contains? r5-service-types (:id schema)))
194+
195+
(defmulti service-type-element? (fn [package _element] package))
196+
(defmethod service-type-element? "hl7.fhir.r4.core" [_ {:keys [type]}] (contains? r4-service-types type))
197+
(defmethod service-type-element? "hl7.fhir.r4b.core" [_ {:keys [type]}] (contains? r4b-service-types type))
198+
(defmethod service-type-element? "hl7.fhir.r5.core" [_ {:keys [type]}] (contains? r5-service-types type))

0 commit comments

Comments
 (0)