1 | require 'test/unit'
|
---|
2 | require 'set'
|
---|
3 | require 'rm'
|
---|
4 |
|
---|
5 | class ReferenceModelTest < Test::Unit::TestCase
|
---|
6 | def setup
|
---|
7 | @authored_resource = OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE.new(:original_language => "ja",
|
---|
8 | :translations => "en",
|
---|
9 | :description => "test")
|
---|
10 | @translation_details = OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS.new(nil,nil,nil,nil,nil)
|
---|
11 | # @openehr_definitions = OpenEHR::RM::Support::Definition::OpenEHR_Definitions.new
|
---|
12 | # @code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase.new
|
---|
13 | # @agent = OpenEHR::RM::Demogrphic::Agent.new
|
---|
14 | # @organisation = OpenEHR::RM::Demogrphic::Organisation.new
|
---|
15 | # @person = OpenEHR::RM::Demogrphic::Person.new
|
---|
16 | # @group = OpenEHR::RM::Demogrphic::Group.new
|
---|
17 | end
|
---|
18 |
|
---|
19 | def test_init
|
---|
20 | assert_instance_of OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE, @authored_resource
|
---|
21 | assert_instance_of OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS, @translation_details
|
---|
22 | # assert_instance_of OpenEHR::RM::Demogrphic::Agent, @agent
|
---|
23 | # assert_instance_of OpenEHR::RM::Demogrphic::Organisation, @organisation
|
---|
24 | # assert_instance_of OpenEHR::RM::Demogrphic::Person, @person
|
---|
25 | # assert_instance_of OpenEHR::RM::Demogrphic::Group, @group
|
---|
26 | end
|
---|
27 |
|
---|
28 | def test_constant
|
---|
29 | assert_equal("\r", OpenEHR::RM::Support::Definition::OpenEHR_Definitions::CR)
|
---|
30 | assert_equal("\n", OpenEHR::RM::Support::Definition::OpenEHR_Definitions::LF)
|
---|
31 | assert_equal("\r", OpenEHR::RM::Data_Types::Basic::Data_Value::CR)
|
---|
32 | assert_equal("\n", OpenEHR::RM::Data_Types::Basic::Data_Value::LF)
|
---|
33 | end
|
---|
34 | end
|
---|
35 |
|
---|
36 | class RM_Support_Identification_Test < Test::Unit::TestCase
|
---|
37 | def setup
|
---|
38 | assert_nothing_raised(Exception){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.3")}
|
---|
39 | assert_nothing_raised(Exception){@object_ref = OpenEHR::RM::Support::Identification::Object_Ref.new('local', 'ANY', @object_id)}
|
---|
40 | assert_nothing_raised(Exception){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
41 | assert_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("ICD10",'2003')}
|
---|
42 | assert_nothing_raised(Exception){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", "openehr")}
|
---|
43 | assert_nothing_raised(Exception){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.3')}
|
---|
44 | assert_nothing_raised(Exception){@hier_object_id = OpenEHR::RM::Support::Identification::Hier_Object_ID.new('0.0.4')}
|
---|
45 | assert_nothing_raised(Exception){@locatable_ref = OpenEHR::RM::Support::Identification::Locatable_Ref.new('unknown', 'PERSON', @uid_based_id, 'data/event[at0001, standing]')}
|
---|
46 | assert_nothing_raised(Exception){@party_ref = OpenEHR::RM::Support::Identification::Party_Ref.new('unknown', 'ORGANISATION', @object_id)}
|
---|
47 | assert_nothing_raised(Exception){@access_group_ref = OpenEHR::RM::Support::Identification::Access_Group_Ref.new('unknown', 'ACCESS_GROUP', @object_id)}
|
---|
48 | assert_nothing_raised(Exception){@version_tree_id = OpenEHR::RM::Support::Identification::Version_Tree_ID.new('1.2.3')}
|
---|
49 | end
|
---|
50 |
|
---|
51 | def test_init
|
---|
52 | assert_instance_of OpenEHR::RM::Support::Identification::Object_ID, @object_id
|
---|
53 | assert_instance_of OpenEHR::RM::Support::Identification::Object_Ref, @object_ref
|
---|
54 | assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, @archetype_id
|
---|
55 | assert_instance_of OpenEHR::RM::Support::Identification::Terminology_ID, @terminology_id
|
---|
56 | assert_instance_of OpenEHR::RM::Support::Identification::Object_ID, @object_id
|
---|
57 | assert_instance_of OpenEHR::RM::Support::Identification::Generic_ID, @generic_id
|
---|
58 | assert_instance_of OpenEHR::RM::Support::Identification::UID_Based_ID, @uid_based_id
|
---|
59 | assert_instance_of OpenEHR::RM::Support::Identification::Hier_Object_ID, @hier_object_id
|
---|
60 | assert_instance_of OpenEHR::RM::Support::Identification::Locatable_Ref, @locatable_ref
|
---|
61 | assert_instance_of OpenEHR::RM::Support::Identification::Party_Ref, @party_ref
|
---|
62 | assert_instance_of OpenEHR::RM::Support::Identification::Access_Group_Ref, @access_group_ref
|
---|
63 | assert_instance_of OpenEHR::RM::Support::Identification::Version_Tree_ID, @version_tree_id
|
---|
64 | end
|
---|
65 |
|
---|
66 | def test_object_id
|
---|
67 | assert_equal "0.0.3", @object_id.value
|
---|
68 | assert_nothing_raised(Exception){@object_id.value = "0.0.4"}
|
---|
69 | assert_equal "0.0.4", @object_id.value
|
---|
70 | assert_raise(ArgumentError){@object_id.value=nil}
|
---|
71 | assert_raise(ArgumentError){@object_id.value=""}
|
---|
72 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new}
|
---|
73 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new(nil)}
|
---|
74 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new("")}
|
---|
75 | assert_equal @object_id, OpenEHR::RM::Support::Identification::Object_ID.new("0.0.4")
|
---|
76 | end
|
---|
77 |
|
---|
78 | def test_object_refs
|
---|
79 | assert_equal 'local', @object_ref.namespace
|
---|
80 | assert_equal 'ANY', @object_ref.type
|
---|
81 | assert_equal @object_id, @object_ref.id
|
---|
82 |
|
---|
83 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new}
|
---|
84 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new(nil, 'ANY', @object_id)}
|
---|
85 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('', 'ANY', @object_id)}
|
---|
86 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', nil, @object_id)}
|
---|
87 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', '', @object_id)}
|
---|
88 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', 'ANY', nil)}
|
---|
89 |
|
---|
90 | assert_nothing_raised(Exception){@object_ref.namespace = 'terminology'}
|
---|
91 | assert_equal 'terminology', @object_ref.namespace
|
---|
92 | assert_raise(ArgumentError){@object_ref.namespace = nil}
|
---|
93 | assert_raise(ArgumentError){@object_ref.namespace = ''}
|
---|
94 | assert_raise(ArgumentError){@object_ref.namespace = '?&&'}
|
---|
95 | assert_raise(ArgumentError){@object_ref.namespace = '843'}
|
---|
96 |
|
---|
97 | assert_nothing_raised(Exception){@object_ref.type = 'GUIDELINE'}
|
---|
98 | assert_equal 'GUIDELINE', @object_ref.type
|
---|
99 | assert_raise(ArgumentError){@object_ref.type = nil}
|
---|
100 | assert_raise(ArgumentError){@object_ref.type = ''}
|
---|
101 |
|
---|
102 | assert_nothing_raised(Exception){@object_ref.id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.5")}
|
---|
103 | assert_equal OpenEHR::RM::Support::Identification::Object_ID.new("0.0.5"), @object_ref.id
|
---|
104 | assert_raise(ArgumentError){@object_ref.id = nil}
|
---|
105 | end
|
---|
106 |
|
---|
107 | def test_archetype_id
|
---|
108 | assert_equal "0.0.5", @archetype_id.value
|
---|
109 | assert_nothing_raised(Exception){@archetype_id.value = "0.0.6"}
|
---|
110 | assert_equal "0.0.6", @archetype_id.value
|
---|
111 | assert_raise(ArgumentError){@archetype_id.value=nil}
|
---|
112 | assert_raise(ArgumentError){@archetype_id.value=""}
|
---|
113 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new}
|
---|
114 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new(nil, "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
115 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
116 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", nil, "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
117 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
118 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", nil, "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
119 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
120 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", nil, "openehr","cholesterol","0.0.3")}
|
---|
121 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "", "openehr","cholesterol","0.0.3")}
|
---|
122 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", nil,"cholesterol","0.0.3")}
|
---|
123 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "","cholesterol","0.0.3")}
|
---|
124 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr",nil ,"0.0.3")}
|
---|
125 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","","0.0.3")}
|
---|
126 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol", nil)}
|
---|
127 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","")}
|
---|
128 |
|
---|
129 | assert_equal "biochemistry result_cholesterol", @archetype_id.domain_concept
|
---|
130 | assert_nothing_raised(Exception){(@archetype_id.domain_concept = "biochemistry result_triglyceride")}
|
---|
131 | assert_equal "biochemistry result_triglyceride", @archetype_id.domain_concept
|
---|
132 | assert_raise(ArgumentError){@archetype_id.domain_concept = nil}
|
---|
133 | assert_raise(ArgumentError){@archetype_id.domain_concept = ""}
|
---|
134 |
|
---|
135 | assert_equal "entry", @archetype_id.rm_name
|
---|
136 | assert_nothing_raised(Exception){@archetype_id.rm_name = "section"}
|
---|
137 | assert_equal "section", @archetype_id.rm_name
|
---|
138 | assert_raise(ArgumentError){@archetype_id.rm_name = nil}
|
---|
139 | assert_raise(ArgumentError){@archetype_id.rm_name = ""}
|
---|
140 |
|
---|
141 | assert_equal "ehr_rm", @archetype_id.rm_entity
|
---|
142 | assert_nothing_raised(Exception){@archetype_id.rm_entity = "13606"}
|
---|
143 | assert_equal "13606", @archetype_id.rm_entity
|
---|
144 | assert_raise(ArgumentError){@archetype_id.rm_entity = nil}
|
---|
145 | assert_raise(ArgumentError){@archetype_id.rm_entity = ""}
|
---|
146 |
|
---|
147 | assert_equal "openehr", @archetype_id.rm_originator
|
---|
148 | assert_nothing_raised(Exception){@archetype_id.rm_originator = "cen"}
|
---|
149 | assert_equal "cen", @archetype_id.rm_originator
|
---|
150 | assert_raise(ArgumentError){@archetype_id.rm_originator = nil}
|
---|
151 | assert_raise(ArgumentError){@archetype_id.rm_originator = ""}
|
---|
152 |
|
---|
153 | assert_equal "cholesterol", @archetype_id.specialisation
|
---|
154 | assert_nothing_raised(Exception){@archetype_id.specialisation = "triglyceride"}
|
---|
155 | assert_equal "triglyceride", @archetype_id.specialisation
|
---|
156 | assert_raise(ArgumentError){@archetype_id.specialisation = nil}
|
---|
157 | assert_raise(ArgumentError){@archetype_id.specialisation = ""}
|
---|
158 |
|
---|
159 | assert_equal "0.0.3", @archetype_id.version_id
|
---|
160 | assert_nothing_raised(Exception){@archetype_id.version_id = "0.0.7"}
|
---|
161 | assert_equal "0.0.7", @archetype_id.version_id
|
---|
162 | assert_raise(ArgumentError){@archetype_id.version_id = nil}
|
---|
163 | assert_raise(ArgumentError){@archetype_id.version_id = ""}
|
---|
164 | end
|
---|
165 |
|
---|
166 | def test_terminology_id
|
---|
167 | assert_equal "ICD10(2003)", @terminology_id.value
|
---|
168 | assert_nothing_raised(Exception){@terminology_id.value = "ICD9(1999)"}
|
---|
169 | assert_equal "ICD9", @terminology_id.name
|
---|
170 | assert_equal "1999", @terminology_id.version_id
|
---|
171 | assert_raise(ArgumentError){@terminology_id.value = nil}
|
---|
172 | assert_raise(ArgumentError){@terminology_id.value = ""}
|
---|
173 |
|
---|
174 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new}
|
---|
175 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new(nil,'2008')}
|
---|
176 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('','02008')}
|
---|
177 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("SNOMED", nil)}
|
---|
178 | assert_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("SNOMED",'')}
|
---|
179 |
|
---|
180 | assert_equal "SNOMED", @terminology_id.name
|
---|
181 | assert_nothing_raised(Exception){@terminology_id.name = "LOINC"}
|
---|
182 | assert_equal "LOINC", @terminology_id.name
|
---|
183 | assert_raise(ArgumentError){@terminology_id.name = nil}
|
---|
184 | assert_raise(ArgumentError){@terminology_id.name = ""}
|
---|
185 |
|
---|
186 | assert_equal "", @terminology_id.version_id
|
---|
187 | assert_nothing_raised(Exception){@terminology_id.version_id = "2008"}
|
---|
188 | assert_equal "2008", @terminology_id.version_id
|
---|
189 | assert_equal 'LOINC(2008)', @terminology_id.value
|
---|
190 | assert_raise(ArgumentError){@terminology_id.version_id = nil}
|
---|
191 | assert_nothing_raised(Exception){@terminology_id.version_id = ''}
|
---|
192 | end
|
---|
193 |
|
---|
194 | def test_generic_id
|
---|
195 | assert_equal "0.0.3", @generic_id.value
|
---|
196 | assert_equal "openehr", @generic_id.scheme
|
---|
197 |
|
---|
198 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new(nil, "openehr")}
|
---|
199 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("", "openehr")}
|
---|
200 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", nil)}
|
---|
201 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", "")}
|
---|
202 |
|
---|
203 | assert_raise(ArgumentError){@generic_id.value = nil}
|
---|
204 | assert_raise(ArgumentError){@generic_id.value = ""}
|
---|
205 | assert_nothing_raised(Exception){@generic_id.value = "0.0.5"}
|
---|
206 | assert_equal "0.0.5", @generic_id.value
|
---|
207 |
|
---|
208 | assert_raise(ArgumentError){@generic_id.scheme = nil}
|
---|
209 | assert_raise(ArgumentError){@generic_id.scheme = ""}
|
---|
210 | assert_nothing_raised(Exception){@generic_id.scheme = "cen"}
|
---|
211 | assert_equal "cen", @generic_id.scheme
|
---|
212 | end
|
---|
213 |
|
---|
214 | def test_uid_based_id
|
---|
215 | assert_equal "rrip::0.0.3", @uid_based_id.value
|
---|
216 | assert_equal "rrip", @uid_based_id.root
|
---|
217 | assert_equal '0.0.3', @uid_based_id.extension
|
---|
218 | assert @uid_based_id.has_extension?
|
---|
219 |
|
---|
220 | assert_raise(ArgumentError){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new(nil)}
|
---|
221 | assert_raise(ArgumentError){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('')}
|
---|
222 | assert_raise(ArgumentError){@uid_based_id.value = nil}
|
---|
223 | assert_raise(ArgumentError){@uid_based_id.value = ''}
|
---|
224 |
|
---|
225 | assert_nothing_raised(Exception){@uid_based_id.value = 'rrip'}
|
---|
226 | assert_equal 'rrip', @uid_based_id.value
|
---|
227 | assert_equal 'rrip', @uid_based_id.root
|
---|
228 | assert_equal '', @uid_based_id.extension
|
---|
229 | end
|
---|
230 |
|
---|
231 | def test_hier_object_id
|
---|
232 | assert_equal '0.0.4', @hier_object_id.value
|
---|
233 | assert !@hier_object_id.root.nil?
|
---|
234 | assert !@hier_object_id.has_extension?
|
---|
235 | # in the specification 1.0.1 has_extension? xor extention != Void void is not nil?
|
---|
236 | assert @hier_object_id.extension.empty?
|
---|
237 | assert_nothing_raised(Exception){@hier_object_id.value = "ehr::test"}
|
---|
238 | assert !@hier_object_id.root.nil?
|
---|
239 | assert @hier_object_id.has_extension?
|
---|
240 | assert !@hier_object_id.extension.empty?
|
---|
241 | end
|
---|
242 |
|
---|
243 | def test_locatable_ref
|
---|
244 | # test constructor
|
---|
245 | assert_equal 'unknown', @locatable_ref.namespace
|
---|
246 | assert_equal 'PERSON', @locatable_ref.type
|
---|
247 | assert_equal @uid_based_id, @locatable_ref.id
|
---|
248 | assert_equal 'data/event[at0001, standing]', @locatable_ref.path
|
---|
249 | assert_equal 'ehr://rrip::0.0.3/data/event[at0001, standing]', @locatable_ref.as_uri
|
---|
250 | #test path
|
---|
251 | assert_nothing_raised(Exception){@locatable_ref.path = 'data/event[at0002, tilting]'}
|
---|
252 | assert_equal 'data/event[at0002, tilting]', @locatable_ref.path
|
---|
253 | assert_equal 'ehr://rrip::0.0.3/data/event[at0002, tilting]', @locatable_ref.as_uri
|
---|
254 | end
|
---|
255 |
|
---|
256 | def test_party_ref
|
---|
257 | # test constructor
|
---|
258 | assert_equal 'unknown', @party_ref.namespace
|
---|
259 | assert_equal 'ORGANISATION', @party_ref.type
|
---|
260 | assert_equal @object_id, @party_ref.id
|
---|
261 | # test type validation
|
---|
262 | assert_raise(ArgumentError){@party_ref.type = 'GUIDELINE'}
|
---|
263 | assert_nothing_raised(Exception){@party_ref.type = 'PERSON'}
|
---|
264 | assert_equal 'PERSON', @party_ref.type
|
---|
265 | assert_nothing_raised(Exception){@party_ref.type = 'GROUP'}
|
---|
266 | assert_nothing_raised(Exception){@party_ref.type = 'AGENT'}
|
---|
267 | assert_nothing_raised(Exception){@party_ref.type = 'ROLE'}
|
---|
268 | assert_nothing_raised(Exception){@party_ref.type = 'PARTY'}
|
---|
269 | assert_nothing_raised(Exception){@party_ref.type = 'ACTOR'}
|
---|
270 | end
|
---|
271 |
|
---|
272 | def test_access_group_ref
|
---|
273 | # test constructor
|
---|
274 | assert_equal 'unknown', @access_group_ref.namespace
|
---|
275 | assert_equal 'ACCESS_GROUP', @access_group_ref.type
|
---|
276 | assert_equal @object_id, @access_group_ref.id
|
---|
277 | # test type validation
|
---|
278 | assert_raise(ArgumentError){@access_group_ref.type = 'PERSON'}
|
---|
279 | assert_nothing_raised(Exception){@access_group_ref.type = 'ACCESS_GROUP'}
|
---|
280 | end
|
---|
281 |
|
---|
282 | def test_version_tree_id
|
---|
283 | assert_equal '1.2.3', @version_tree_id.value
|
---|
284 | assert_equal '1', @version_tree_id.trunk_version
|
---|
285 | assert_equal '2', @version_tree_id.branch_number
|
---|
286 | assert_equal '3', @version_tree_id.branch_version
|
---|
287 | assert @version_tree_id.is_first?
|
---|
288 | assert @version_tree_id.is_branch?
|
---|
289 | assert_nothing_raised(Exception){@version_tree_id.value = '2'}
|
---|
290 | assert_equal '2', @version_tree_id.trunk_version
|
---|
291 | assert !@version_tree_id.is_first?
|
---|
292 | assert !@version_tree_id.is_branch?
|
---|
293 | assert_nil @version_tree_id.branch_number
|
---|
294 | assert_nil @version_tree_id.branch_version
|
---|
295 | assert_raise(ArgumentError){@version_tree_id.branch_version = '5'}
|
---|
296 | end
|
---|
297 | end
|
---|
298 |
|
---|
299 | class RM_Common_Archetyped_Test < Test::Unit::TestCase
|
---|
300 | def setup
|
---|
301 | @dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('Test')
|
---|
302 | @uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.5')
|
---|
303 | @archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
|
---|
304 | @template_id = OpenEHR::RM::Support::Identification::Template_ID.new('1.0.1')
|
---|
305 | assert_nothing_raised(Exception){@archetyped = OpenEHR::RM::Common::Archetyped::Archetyped.new(@archetype_id, '1.0.1')}
|
---|
306 | assert_nothing_raised(Exception){@link = OpenEHR::RM::Common::Archetyped::Link.new(OpenEHR::RM::Data_Types::Text::DV_Text.new("generic"), OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://test/"),OpenEHR::RM::Data_Types::Text::DV_Text.new("problem"))}
|
---|
307 | # assert_nothing_raised(Exception){@
|
---|
308 | end
|
---|
309 |
|
---|
310 | def test_init
|
---|
311 | assert_instance_of OpenEHR::RM::Common::Archetyped::Archetyped, @archetyped
|
---|
312 | assert_instance_of OpenEHR::RM::Common::Archetyped::Link, @link
|
---|
313 | end
|
---|
314 |
|
---|
315 | def test_archetyped
|
---|
316 | assert_equal @archetype_id, @archetyped.archetype_id
|
---|
317 | assert_equal '1.0.1', @archetyped.rm_version
|
---|
318 | assert_raise(ArgumentError){@archetyped.archetype_id = nil}
|
---|
319 | assert_raise(ArgumentError){@archetyped.rm_version = nil}
|
---|
320 | assert_raise(ArgumentError){@archetyped.rm_version = ''}
|
---|
321 | assert_nothing_raised(Exception){@archetyped.template_id = @template_id}
|
---|
322 | assert_equal @template_id, @archetyped.template_id
|
---|
323 | archetype_id2 = OpenEHR::RM::Support::Identification::Archetype_ID.new("1.0.2", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
|
---|
324 | assert_nothing_raised(ArgumentError){@archetyped.archetype_id = archetype_id2}
|
---|
325 | assert_equal archetype_id2, @archetyped.archetype_id
|
---|
326 | assert_nothing_raised(ArgumentError){@archetyped.rm_version = '1.0.2'}
|
---|
327 | assert_equal '1.0.2', @archetyped.rm_version
|
---|
328 | end
|
---|
329 |
|
---|
330 | def test_link
|
---|
331 | # test constructor
|
---|
332 | assert_equal 'generic', @link.meaning.value
|
---|
333 | assert_equal 'ehr://test/', @link.target.value
|
---|
334 | assert_equal 'problem', @link.type.value
|
---|
335 | # test meaning
|
---|
336 | assert_nothing_raised(Exception){@link.meaning = OpenEHR::RM::Data_Types::Text::DV_Text.new('clinical')}
|
---|
337 | assert_equal 'clinical', @link.meaning.value
|
---|
338 | assert_raise(ArgumentError){@link.meaning = nil}
|
---|
339 | # test target
|
---|
340 | assert_nothing_raised(Exception){@link.target = OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://try/")}
|
---|
341 | assert_equal 'ehr://try/', @link.target.value
|
---|
342 | assert_raise(ArgumentError){@link.target = nil}
|
---|
343 | # test type
|
---|
344 | assert_nothing_raised(Exception){@link.type = OpenEHR::RM::Data_Types::Text::DV_Text.new("issue")}
|
---|
345 | assert_equal 'issue', @link.type.value
|
---|
346 | assert_raise(ArgumentError){@link.type = nil}
|
---|
347 | end
|
---|
348 | end
|
---|
349 |
|
---|
350 |
|
---|
351 | class RM_Data_Types_Basic_Test < Test::Unit::TestCase
|
---|
352 | def setup
|
---|
353 | assert_nothing_raised(Exception){@dv_boolean = OpenEHR::RM::Data_Types::Basic::DV_Boolean.new("TRUE")}
|
---|
354 | @terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('openEHR','1.0.2')
|
---|
355 | @code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('PROPOSED', @terminology_id)
|
---|
356 | @dv_coded_text = OpenEHR::RM::Data_Types::Text::DV_Coded_Text.new("Blood examination", @code_phrase)
|
---|
357 | assert_nothing_raised(Exception){@dv_state = OpenEHR::RM::Data_Types::Basic::DV_State.new(@dv_coded_text, false)}
|
---|
358 | assert_nothing_raised(Exception){@dv_identifier = OpenEHR::RM::Data_Types::Basic::DV_Identifier.new("Ruby Hospital","0123456-0", "Information office", "personal id")}
|
---|
359 | end
|
---|
360 |
|
---|
361 | def test_init
|
---|
362 | assert_instance_of OpenEHR::RM::Data_Types::Basic::DV_Boolean, @dv_boolean
|
---|
363 | assert_instance_of OpenEHR::RM::Data_Types::Basic::DV_State, @dv_state
|
---|
364 | assert_instance_of OpenEHR::RM::Data_Types::Basic::DV_Identifier, @dv_identifier
|
---|
365 | end
|
---|
366 |
|
---|
367 | def test_dv_boolean
|
---|
368 | assert @dv_boolean.value?
|
---|
369 | @dv_boolean.value = false
|
---|
370 | assert !@dv_boolean.value?
|
---|
371 | # inv: Value_exists
|
---|
372 | assert_raise(ArgumentError){@dv_boolean.value=nil}
|
---|
373 | assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Basic::DV_Boolean.new(nil)}
|
---|
374 | end
|
---|
375 |
|
---|
376 | def test_dv_state
|
---|
377 | assert_equal 'Blood examination', @dv_state.value.value
|
---|
378 | assert_equal 'PROPOSED', @dv_state.value.defining_code.code_string
|
---|
379 | assert_equal 'openEHR', @dv_state.value.defining_code.terminology_id.name
|
---|
380 | assert_equal '1.0.2', @dv_state.value.defining_code.terminology_id.version_id
|
---|
381 | assert !@dv_state.is_terminal?
|
---|
382 | assert_nothing_raised(Exception){@dv_state.value.defining_code.code_string = "COMPLETED"}
|
---|
383 | assert_nothing_raised(Exception){@dv_state.is_terminal = true}
|
---|
384 | assert_equal 'COMPLETED', @dv_state.value.defining_code.code_string
|
---|
385 | assert @dv_state.is_terminal?
|
---|
386 | assert_raise(ArgumentError) {OpenEHR::RM::Data_Types::Basic::DV_State.new(nil,nil)}
|
---|
387 | assert_raise(ArgumentError) {@dv_state.value=nil}
|
---|
388 | assert_raise(ArgumentError) {@dv_state.is_terminal=nil}
|
---|
389 | end
|
---|
390 |
|
---|
391 | def test_dv_identifier
|
---|
392 | assert_equal("Ruby Hospital", @dv_identifier.assigner)
|
---|
393 | assert_equal("0123456-0", @dv_identifier.id)
|
---|
394 | assert_equal("Information office", @dv_identifier.issuer)
|
---|
395 | assert_equal("personal id", @dv_identifier.type)
|
---|
396 | @dv_identifier.assigner = "Test Hospital"
|
---|
397 | assert_equal("Test Hospital", @dv_identifier.assigner)
|
---|
398 | @dv_identifier.id = "TEST-0987"
|
---|
399 | assert_equal("TEST-0987", @dv_identifier.id)
|
---|
400 | @dv_identifier.issuer = "Security office"
|
---|
401 | assert_equal("Security office", @dv_identifier.issuer)
|
---|
402 | @dv_identifier.type = "test id"
|
---|
403 | assert_equal("test id", @dv_identifier.type)
|
---|
404 | assert_raise(ArgumentError) {OpenEHR::RM::Data_Types::Basic::DV_Identifier.new(nil, nil, nil, nil)}
|
---|
405 | end
|
---|
406 | end
|
---|
407 |
|
---|
408 | # fixed
|
---|
409 | class RM_Data_Types_URI_Test < Test::Unit::TestCase
|
---|
410 | def setup
|
---|
411 | @dv_uri = OpenEHR::RM::Data_Types::URI::DV_URI.new("http://www.openehr.jp/changeset/test?cmd=93#file0")
|
---|
412 | @dv_ehr_uri = OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://1234567/87284370-2D4B-4e3d-A3F3-F303D2F4F34B@2005-08-02T04:30:00")
|
---|
413 | end
|
---|
414 |
|
---|
415 | def test_init
|
---|
416 | assert_instance_of OpenEHR::RM::Data_Types::URI::DV_URI, @dv_uri
|
---|
417 | assert_instance_of OpenEHR::RM::Data_Types::URI::DV_EHR_URI, @dv_ehr_uri
|
---|
418 | end
|
---|
419 |
|
---|
420 | def test_dv_uri
|
---|
421 | assert_equal("file0", @dv_uri.fragment_id)
|
---|
422 | assert_equal("/changeset/test", @dv_uri.path)
|
---|
423 | assert_equal("cmd=93", @dv_uri.query)
|
---|
424 | assert_equal("http", @dv_uri.scheme)
|
---|
425 | assert_equal("http://www.openehr.jp/changeset/test?cmd=93#file0", @dv_uri.value)
|
---|
426 | @dv_uri.value="svn://www.openehr.jp/openehr-jp/"
|
---|
427 | assert_equal("svn://www.openehr.jp/openehr-jp/", @dv_uri.value)
|
---|
428 | assert_equal("/openehr-jp/", @dv_uri.path)
|
---|
429 | end
|
---|
430 |
|
---|
431 | def test_dv_ehr_uri
|
---|
432 | assert_equal("ehr", @dv_ehr_uri.scheme)
|
---|
433 | assert_raise(ArgumentError){
|
---|
434 | @dv_ehr_uri.value="svn://www.openehr.jp/openehr-jp/" }
|
---|
435 | end
|
---|
436 | end
|
---|
437 |
|
---|
438 | class RM_Data_Types_Text_Test < Test::Unit::TestCase
|
---|
439 | def setup
|
---|
440 | assert_nothing_raised(Exception){@dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new("valid value")}
|
---|
441 | @terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('ICD10', '')
|
---|
442 |
|
---|
443 | assert_nothing_raised(Exception){@code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('C92.0', @terminology_id)}
|
---|
444 | assert_nothing_raised(Exception){@dv_coded_text = OpenEHR::RM::Data_Types::Text::DV_Coded_Text.new("Acute Myeloid Leukemia", @code_phrase)}
|
---|
445 | @dv_paragraph = OpenEHR::RM::Data_Types::Text::DV_Paragraph.new(Set.new(["test1", "test2"]))
|
---|
446 | @term_mapping = OpenEHR::RM::Data_Types::Text::Term_Mapping.new('=',@dv_coded_text,"TEST")
|
---|
447 | end
|
---|
448 |
|
---|
449 | def test_init
|
---|
450 | assert_instance_of OpenEHR::RM::Data_Types::Text::DV_Text, @dv_text
|
---|
451 | assert_instance_of OpenEHR::RM::Data_Types::Text::Code_Phrase, @code_phrase
|
---|
452 | assert_instance_of OpenEHR::RM::Data_Types::Text::DV_Coded_Text, @dv_coded_text
|
---|
453 | assert_instance_of OpenEHR::RM::Data_Types::Text::Term_Mapping, @term_mapping
|
---|
454 | end
|
---|
455 |
|
---|
456 | def test_dv_text
|
---|
457 | assert_equal("valid value", @dv_text.value)
|
---|
458 | assert_raise(ArgumentError){@dv_text.value = "not valid value\n"}
|
---|
459 | assert_raise(ArgumentError){@dv_text.value = nil }
|
---|
460 | assert_raise(ArgumentError){@dv_text.value = "" }
|
---|
461 | assert_raise(ArgumentError){@dv_text.formatting = "" }
|
---|
462 | assert_raise(ArgumentError){@dv_text.encoding = ""}
|
---|
463 | assert_raise(ArgumentError){@dv_text.language = ""}
|
---|
464 | assert_raise(ArgumentError){@dv_text.mappings = Set.new}
|
---|
465 | assert_raise(ArgumentError){@dv_text.mappings = ""}
|
---|
466 | assert_raise(ArgumentError){@dv_text.language = ""}
|
---|
467 | end
|
---|
468 |
|
---|
469 | def test_code_phrase
|
---|
470 | assert_equal 'C92.0', @code_phrase.code_string
|
---|
471 | assert_equal 'ICD10', @code_phrase.terminology_id.value
|
---|
472 | assert_nothing_raised(Exception){@code_phrase.code_string = 'C93.0'}
|
---|
473 | assert_equal 'C93.0', @code_phrase.code_string
|
---|
474 | end
|
---|
475 |
|
---|
476 | def test_dv_coded_text
|
---|
477 | assert_equal("Acute Myeloid Leukemia", @dv_coded_text.value)
|
---|
478 | assert_equal("ICD10", @dv_coded_text.defining_code.terminology_id.name)
|
---|
479 | assert_raise(ArgumentError){@dv_coded_text.defining_code=nil}
|
---|
480 | end
|
---|
481 |
|
---|
482 | def test_dv_paragraph
|
---|
483 | assert_equal((Set.new ["test1", "test2"]), @dv_paragraph.items)
|
---|
484 | assert_raise(ArgumentError){@dv_paragraph.items=Set.new}
|
---|
485 | end
|
---|
486 |
|
---|
487 | def test_term_mapping
|
---|
488 | assert_equal '=', @term_mapping.match
|
---|
489 | assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('>')
|
---|
490 | assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('=')
|
---|
491 | assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('<')
|
---|
492 | assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('?')
|
---|
493 | assert !OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('!')
|
---|
494 | assert_equal @dv_coded_text, @term_mapping.purpose
|
---|
495 | assert_equal "TEST", @term_mapping.target
|
---|
496 | assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new}
|
---|
497 | assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new('!',@dv_coded_text, "invalid case")}
|
---|
498 | assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new('=',nil , "invalid case")}
|
---|
499 | assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new('=',@dv_coded_text, nil)}
|
---|
500 | end
|
---|
501 | end
|
---|
502 |
|
---|
503 | class RM_Common_Generic_Test < Test::Unit::TestCase
|
---|
504 | def setup
|
---|
505 | assert_nothing_raised(Exception){@party_proxy = OpenEHR::RM::Common::Generic::Party_Proxy.new}
|
---|
506 | # assert_nothing_raised(Exception){@audit_details = OpenEHR::RM::Common::Generic::Audit_Details.new('pikachu', @party_proxy, OpenEHR::RM::Data_Types::Quantity::Date_Time::DV_DATE_TIME.new(2008))}
|
---|
507 | end
|
---|
508 | def test_init
|
---|
509 | end
|
---|
510 | end
|
---|
511 |
|
---|
512 | class RM_Common_Directory_Test < Test::Unit::TestCase
|
---|
513 | def setup
|
---|
514 | dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('root')
|
---|
515 | assert_nothing_raised(Exception){@folder = OpenEHR::RM::Common::Directory::Folder.new('at0000', dv_text, nil)}
|
---|
516 | end
|
---|
517 |
|
---|
518 | def test_init
|
---|
519 | assert_instance_of OpenEHR::RM::Common::Directory::Folder, @folder
|
---|
520 | end
|
---|
521 |
|
---|
522 | def test_folder
|
---|
523 | assert_equal 'at0000', @folder.archetype_node_id
|
---|
524 | assert_equal 'root', @folder.name.value
|
---|
525 | end
|
---|
526 | end
|
---|