|
3 | 3 | [aidbox-sdk.fixtures.schemas :as fixtures]
|
4 | 4 | [aidbox-sdk.generator :as sut]
|
5 | 5 | [aidbox-sdk.generator.dotnet :refer [generator] :as gen.dotnet]
|
6 |
| - [matcho.core :as matcho] |
7 | 6 | [clojure.java.io :as io]
|
8 | 7 | [clojure.test :refer [deftest is testing]]))
|
9 | 8 |
|
10 |
| -(deftest test-apply-constraints |
11 |
| - (testing "base schema is a specialization schema" |
12 |
| - |
13 |
| - (def constraints |
14 |
| - [{:package "hl7.fhir.r4.core", |
15 |
| - :derivation "constraint", |
16 |
| - :excluded ["value"], |
17 |
| - :type "Extension", |
18 |
| - :elements |
19 |
| - {:extension |
20 |
| - {:slicing |
21 |
| - {:slices |
22 |
| - {:code |
23 |
| - {:schema |
24 |
| - {:scalar true, |
25 |
| - :excluded ["extension"], |
26 |
| - :required ["value"], |
27 |
| - :type "Extension", |
28 |
| - :elements |
29 |
| - {:url {:fixed "code", :type "uri"}, |
30 |
| - :valueCodeableConcept |
31 |
| - {:required-element true, :type "CodeableConcept", :choiceOf "value"}, |
32 |
| - :value {:choices ["valueCodeableConcept"]}}}, |
33 |
| - :min 0, |
34 |
| - :max 1, |
35 |
| - :match {:type "pattern", :value {:url "code"}}}, |
36 |
| - :period |
37 |
| - {:schema |
38 |
| - {:scalar true, |
39 |
| - :excluded ["extension"], |
40 |
| - :required ["value"], |
41 |
| - :type "Extension", |
42 |
| - :elements |
43 |
| - {:url {:fixed "period", :type "uri"}, |
44 |
| - :valuePeriod |
45 |
| - {:required-element true, :type "Period", :choiceOf "value"}, |
46 |
| - :value {:choices ["valuePeriod"]}}}, |
47 |
| - :min 0, |
48 |
| - :max 1, |
49 |
| - :match {:type "pattern", :value {:url "period"}}}}, |
50 |
| - :discriminator [{:type "value", :path "url"}], |
51 |
| - :rules "open"}}, |
52 |
| - :url |
53 |
| - {:fixed "http://hl7.org/fhir/StructureDefinition/patient-nationality"}}, |
54 |
| - :id "patient-nationality", |
55 |
| - :kind "complex-type", |
56 |
| - :url "http://hl7.org/fhir/StructureDefinition/patient-nationality", |
57 |
| - :base "http://hl7.org/fhir/StructureDefinition/Extension"}]) |
58 |
| - |
59 |
| - (def base {"http://hl7.org/fhir/StructureDefinition/Extension" |
60 |
| - {:package "hl7.fhir.r4.core", |
61 |
| - :derivation "specialization", |
62 |
| - :name "Extension", |
63 |
| - :type "Extension", |
64 |
| - :elements |
65 |
| - [{:name "valueBase64Binary", |
66 |
| - :base "Extension", |
67 |
| - :array false, |
68 |
| - :required false, |
69 |
| - :value "string"}], |
70 |
| - :url "http://hl7.org/fhir/StructureDefinition/Extension", |
71 |
| - :backbone-elements [], |
72 |
| - :base "http://hl7.org/fhir/StructureDefinition/Element"}}) |
73 |
| - |
74 |
| - (matcho/match |
75 |
| - (gen.dotnet/apply-constraints constraints base) |
76 |
| - {"http://hl7.org/fhir/StructureDefinition/patient-nationality" |
77 |
| - {:package "hl7.fhir.r4.core", |
78 |
| - :derivation "specialization", |
79 |
| - :name "Extension", |
80 |
| - :type "Extension", |
81 |
| - :elements |
82 |
| - [{:name "meta", |
83 |
| - :required true, |
84 |
| - :value "Meta", |
85 |
| - :meta |
86 |
| - " = new() { Profile = [\"http://hl7.org/fhir/StructureDefinition/patient-nationality\"] };"} |
87 |
| - {:name "valueBase64Binary", |
88 |
| - :base "Extension", |
89 |
| - :array false, |
90 |
| - :required false, |
91 |
| - :value "string"}] |
92 |
| - :url "http://hl7.org/fhir/StructureDefinition/Extension", |
93 |
| - :base "http://hl7.org/fhir/StructureDefinition/Element"}})) |
94 |
| - |
95 |
| - (testing "base schema is a constraint schema" |
96 |
| - (def constraints [{:package "hl7.fhir.us.mcode", |
97 |
| - :derivation "constraint", |
98 |
| - :fhirVersion "4.0.1", |
99 |
| - :name "SecondaryCancerCondition", |
100 |
| - :type "Condition", |
101 |
| - :resourceType "StructureDefinition", |
102 |
| - :title "Secondary Cancer Condition Profile", |
103 |
| - :status "active", |
104 |
| - :id "mcode-secondary-cancer-condition", |
105 |
| - :kind "resource", |
106 |
| - :url |
107 |
| - "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-secondary-cancer-condition", |
108 |
| - :base "http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition", |
109 |
| - :version "2.1.0", |
110 |
| - :fqn "hl7.fhir.us.mcode#2.1.0/mcode-secondary-cancer-condition"}]) |
111 |
| - |
112 |
| - (def base {"http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition" |
113 |
| - {:package "hl7.fhir.us.core", |
114 |
| - :derivation "constraint", |
115 |
| - :fhirVersion "4.0.1", |
116 |
| - :jurisdiction [{:coding [{:system "urn:iso:std:iso:3166", :code "US"}]}], |
117 |
| - :name "USCoreCondition", |
118 |
| - :type "Condition", |
119 |
| - :experimental false, |
120 |
| - :resourceType "StructureDefinition", |
121 |
| - :elements {:recordedDate {:mustSupport true}} |
122 |
| - :title "US Core Condition Profile", |
123 |
| - :status "active", |
124 |
| - :id "us-core-condition", |
125 |
| - :kind "resource", |
126 |
| - :url "http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition", |
127 |
| - :base "http://hl7.org/fhir/StructureDefinition/Condition", |
128 |
| - :version "4.1.0", |
129 |
| - :fqn "hl7.fhir.us.core#4.1.0/us-core-condition", |
130 |
| - :required ["category" "code"]}}) |
131 |
| - |
132 |
| - (matcho/match |
133 |
| - (gen.dotnet/apply-constraints constraints base) |
134 |
| - {"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-secondary-cancer-condition" |
135 |
| - {:package "hl7.fhir.us.mcode", |
136 |
| - :derivation "constraint", |
137 |
| - :name "USCoreCondition", |
138 |
| - :type "Condition", |
139 |
| - :experimental false, |
140 |
| - :resourceType "StructureDefinition", |
141 |
| - :elements |
142 |
| - [{:name "meta", |
143 |
| - :required true, |
144 |
| - :value "Meta", |
145 |
| - :meta |
146 |
| - " = new() { Profile = [\"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-secondary-cancer-condition\"] };"} |
147 |
| - [:recordedDate {:mustSupport true}]] |
148 |
| - :title "US Core Condition Profile", |
149 |
| - :status "active", |
150 |
| - :id "us-core-condition", |
151 |
| - :kind "resource", |
152 |
| - :url "http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition", |
153 |
| - :base "http://hl7.org/fhir/StructureDefinition/Condition", |
154 |
| - :version "4.1.0", |
155 |
| - :fqn "hl7.fhir.us.core#4.1.0/us-core-condition", |
156 |
| - :required ["category" "code"]}}))) |
157 | 9 |
|
158 | 10 | (deftest test-generate-property
|
159 | 11 | (testing "simple case"
|
|
0 commit comments