|
96 | 96 | "new ")
|
97 | 97 | (when (and (:required element)
|
98 | 98 | (not (:meta element))) "required ")
|
99 |
| - (:value element) |
| 99 | + (or (:value element) (:type element)) |
100 | 100 | (:generic element)
|
101 | 101 | (when (:array element) "[]")
|
102 | 102 | (when (and (not (:required element))
|
|
133 | 133 | (assoc % :value "T")
|
134 | 134 | %)))
|
135 | 135 |
|
136 |
| - properties (try (->> elements |
137 |
| - (map generate-property) |
138 |
| - (map u/add-indent) |
139 |
| - (str/join "\n")) |
140 |
| - (catch Exception _ |
141 |
| - (prn schema))) |
| 136 | + properties (->> elements |
| 137 | + (map generate-property) |
| 138 | + (map u/add-indent) |
| 139 | + (str/join "\n")) |
142 | 140 |
|
143 | 141 | base-class (cond (= base-class "Resource") "Base.Resource"
|
144 | 142 | (= base-class "DomainResource") "DomainResource, IResource"
|
|
213 | 211 |
|
214 | 212 | (defn apply-choices [choices schema]
|
215 | 213 | (->> choices
|
216 |
| - (map (fn [[key, item]] |
| 214 | + (map (fn [[key item]] |
217 | 215 | (set/difference
|
218 | 216 | (set (:choices (first (filter #(= (:name %) (name key)) schema))))
|
219 | 217 | (set (:choices item)))))
|
220 | 218 | (reduce set/union #{})
|
221 |
| - ((fn [choises-to-exclude] |
222 |
| - (filter #(not (contains? choises-to-exclude (:name %))) schema))))) |
| 219 | + ((fn [choices-to-exclude] |
| 220 | + (filter #(not (contains? choices-to-exclude (:name %))) schema))))) |
223 | 221 |
|
224 | 222 | (defn pattern-codeable-concept [name schema]
|
225 | 223 | (->> (str "}")
|
|
233 | 231 | (str (when (contains? code :display) (str "\tpublic new string Display { get; } = \"" (:display code) "\";\n")))
|
234 | 232 | (str "\n\nclass Coding" (str/join (str/split (:code code) #"-")) " : Coding\n{\n"))) coding))) "\n")))
|
235 | 233 |
|
236 |
| -(defn create-single-pattern [constraint-name, [key, schema], elements] |
| 234 | +(defn create-single-pattern [constraint-name [key schema] elements] |
237 | 235 | (case (url->resource-name (some #(when (= (name key) (:name %)) (:value %)) elements))
|
238 | 236 | "CodeableConcept" (pattern-codeable-concept (str (uppercase-first-letter (url->resource-name constraint-name)) (uppercase-first-letter (subs (str key) 1))) schema) ""))
|
239 | 237 |
|
|
242 | 240 | (if-let [pattern (some #(when (= (name (first %)) (:name item)) (last %)) patterns)]
|
243 | 241 | (case (:value item)
|
244 | 242 | "str" (assoc item :value (:pattern pattern) :literal true)
|
245 |
| - "CodeableConcept" (conj item (hash-map :value (str (str/join (map uppercase-first-letter (str/split (url->resource-name constraint-name) #"-"))) (str/join (map uppercase-first-letter (str/split (:name item) #"-")))) :codeable-concept-pattern true)) |
| 243 | + "CodeableConcept" (conj item (hash-map :value (str |
| 244 | + (str/join |
| 245 | + (map uppercase-first-letter |
| 246 | + (str/split (url->resource-name constraint-name) #"-"))) |
| 247 | + (str/join (map uppercase-first-letter |
| 248 | + (str/split (:name item) #"-")))) |
| 249 | + :codeable-concept-pattern true)) |
246 | 250 | "Quantity" item item) item)) (:elements schema))
|
247 | 251 | (hash-map :elements)
|
248 | 252 | (conj schema (hash-map :patterns (concat (get schema :patterns []) (map (fn [item] (create-single-pattern constraint-name item (:elements schema))) patterns))))))
|
249 | 253 |
|
250 | 254 | (defn add-meta [constraint-name elements]
|
251 | 255 | (->> (filter #(not (= (:name %) "meta")) elements)
|
252 |
| - (concat [{:name "meta" :required true :value (str "Meta") :meta (str " = new() { Profile = [\"" constraint-name "\"] };")}]))) |
| 256 | + (concat [{:name "meta" |
| 257 | + :required true :value "Meta" |
| 258 | + :meta (str " = Meta(profile=[\"" constraint-name "\"]);")}]))) |
253 | 259 |
|
254 | 260 | (defn apply-single-constraint [constraint parent-schema]
|
255 | 261 | (->> (:elements parent-schema)
|
|
0 commit comments