|
5 | 5 |
|
6 | 6 | ;; Base Types and Datatypes
|
7 | 7 |
|
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"}) |
9 | 12 |
|
10 | 13 | (def r4-primitive-types
|
11 | 14 | #{"boolean" "integer" "string" "decimal" "uri" "url" "canonical" "base64Binary"
|
|
32 | 35 | r4-metadata-types
|
33 | 36 | r4-special-purpose-datatypes))
|
34 | 37 |
|
| 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 | + |
35 | 45 | (def r4b-base-types r4-base-types)
|
36 | 46 |
|
37 | 47 | (def r4b-primitive-types r4-primitive-types)
|
|
51 | 61 | r4b-metadata-types
|
52 | 62 | r4b-special-purpose-datatypes))
|
53 | 63 |
|
| 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 | + |
54 | 71 | (def r5-base-types
|
55 | 72 | #{"Base" "Element" "BackboneElement" "DataType" "PrimitiveType" "BackboneType"
|
56 | 73 | "Resource" "DomainResource" "CanonicalResource" "MetadataResource"})
|
|
73 | 90 | r5-metadata-types
|
74 | 91 | r5-special-purpose-datatypes))
|
75 | 92 |
|
| 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 | + |
76 | 100 | ;; Predicates
|
77 | 101 | (defn resource-type-pred [rt] (fn [schema] (= rt (:resourceType schema))))
|
78 | 102 | (defn kind-pred [kind] (fn [schema] (= kind (:kind schema))))
|
|
162 | 186 |
|
163 | 187 | (defn base-package? [schema]
|
164 | 188 | (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