1 | require 'test/unit'
|
---|
2 | require 'set'
|
---|
3 | require 'rm'
|
---|
4 |
|
---|
5 | include OpenEHR::RM::Data_Types::Text
|
---|
6 | include OpenEHR::RM::Common::Resource
|
---|
7 | include OpenEHR::RM::Common::Archetyped
|
---|
8 | include OpenEHR::RM::Common::Generic
|
---|
9 | include OpenEHR::RM::Support::Identification
|
---|
10 | include OpenEHR::RM::Data_Types::Basic
|
---|
11 | include OpenEHR::RM::Data_Types::Quantity
|
---|
12 | include OpenEHR::RM::Data_Types::URI
|
---|
13 |
|
---|
14 | class RM_Common_Resource_Test < Test::Unit::TestCase
|
---|
15 | def setup
|
---|
16 | @authored_resource = OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE.new(:original_language => "ja",
|
---|
17 | :translations => "en",
|
---|
18 | :description => "test")
|
---|
19 | @translation_details = OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS.new(nil,nil,nil,nil,nil)
|
---|
20 | end
|
---|
21 | def test_init
|
---|
22 | assert_instance_of OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE, @authored_resource
|
---|
23 | assert_instance_of OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS, @translation_details
|
---|
24 | end
|
---|
25 |
|
---|
26 | def test_authoured_resource
|
---|
27 | assert_equal 'ja', @authored_resource.original_language
|
---|
28 | end
|
---|
29 | end
|
---|
30 |
|
---|
31 |
|
---|
32 | class RM_Common_Archetyped_Test < Test::Unit::TestCase
|
---|
33 | def setup
|
---|
34 | @dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('Test')
|
---|
35 | @uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.5')
|
---|
36 | @archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
|
---|
37 | @template_id = OpenEHR::RM::Support::Identification::Template_ID.new('1.0.1')
|
---|
38 | assert_nothing_raised(Exception){@archetyped = OpenEHR::RM::Common::Archetyped::Archetyped.new(@archetype_id, '1.0.1')}
|
---|
39 | 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"))}
|
---|
40 | assert_nothing_raised(Exception){
|
---|
41 | @pathable = OpenEHR::RM::Common::Archetyped::Pathable.new }
|
---|
42 | name = OpenEHR::RM::Data_Types::Text::DV_Text.new('blood')
|
---|
43 | links = Set.new([@uid_based_id])
|
---|
44 | assert_nothing_raised(Exception){
|
---|
45 | @locatable = OpenEHR::RM::Common::Archetyped::Locatable.new('at0001',name,links)}
|
---|
46 | provider = Party_Identified.new(:name => 'NERV')
|
---|
47 | location = Party_Identified.new(:name => 'GEOFRONT')
|
---|
48 | object_version_id = Object_Version_ID.new('ABC::DEF::1.3.4')
|
---|
49 | party_ref = Party_Ref.new('local', 'ORGANISATION', object_id)
|
---|
50 | assert_nothing_raised(Exception){
|
---|
51 | @feeder_audit_details = Feeder_Audit_Details.new(:system_id => 'MAGI',
|
---|
52 | :provider => provider,
|
---|
53 | :location => location,
|
---|
54 | :time => DV_Date_Time.new('2009-07-03T12:16:31'),
|
---|
55 | :subject => Party_Proxy.new(:external_ref => party_ref),
|
---|
56 | :version_id => '0.0.4')}
|
---|
57 | feeder_audit_details = Feeder_Audit_Details.new(:system_id => 'AKAGI')
|
---|
58 | dv_identifier = DV_Identifier.new('NERV', 'MELCHIOR', 'RITSUKO', 'COMPUTER')
|
---|
59 | feeder_audit_details2 = Feeder_Audit_Details.new(:system_id => 'KATSURAGI')
|
---|
60 | dv_identifier2 = DV_Identifier.new('NERV', 'SHOGOUKI', 'MISATO', 'EVANGELION')
|
---|
61 | charset = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('UTF-8','character-sets')
|
---|
62 | language = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('ja', 'languages')
|
---|
63 |
|
---|
64 | dv_encapsulated = OpenEHR::RM::Data_Types::Encapsulated::DV_Encapsulated.new(charset, language, 10)
|
---|
65 | assert_nothing_raised(Exception){
|
---|
66 | @feeder_audit = Feeder_Audit.new(:originating_system_audit => feeder_audit_details,
|
---|
67 | :originating_system_item_ids => [dv_identifier],
|
---|
68 | :feeder_system_audit => feeder_audit_details2,
|
---|
69 | :feeder_system_item_ids => [dv_identifier2],
|
---|
70 | :original_content => dv_encapsulated)}
|
---|
71 | end
|
---|
72 |
|
---|
73 | def test_init
|
---|
74 | assert_instance_of OpenEHR::RM::Common::Archetyped::Archetyped, @archetyped
|
---|
75 | assert_instance_of OpenEHR::RM::Common::Archetyped::Link, @link
|
---|
76 | assert_instance_of OpenEHR::RM::Common::Archetyped::Pathable, @pathable
|
---|
77 | assert_instance_of OpenEHR::RM::Common::Archetyped::Locatable, @locatable
|
---|
78 | assert_instance_of Feeder_Audit_Details, @feeder_audit_details
|
---|
79 | assert_instance_of Feeder_Audit, @feeder_audit
|
---|
80 | end
|
---|
81 |
|
---|
82 | def test_archetyped
|
---|
83 | assert_equal @archetype_id, @archetyped.archetype_id
|
---|
84 | assert_equal '1.0.1', @archetyped.rm_version
|
---|
85 | assert_raise(ArgumentError){@archetyped.archetype_id = nil}
|
---|
86 | assert_raise(ArgumentError){@archetyped.rm_version = nil}
|
---|
87 | assert_raise(ArgumentError){@archetyped.rm_version = ''}
|
---|
88 | assert_nothing_raised(Exception){@archetyped.template_id = @template_id}
|
---|
89 | assert_equal @template_id, @archetyped.template_id
|
---|
90 | archetype_id2 = OpenEHR::RM::Support::Identification::Archetype_ID.new("1.0.2", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
|
---|
91 | assert_nothing_raised(ArgumentError){@archetyped.archetype_id = archetype_id2}
|
---|
92 | assert_equal archetype_id2, @archetyped.archetype_id
|
---|
93 | assert_nothing_raised(ArgumentError){@archetyped.rm_version = '1.0.2'}
|
---|
94 | assert_equal '1.0.2', @archetyped.rm_version
|
---|
95 | end
|
---|
96 |
|
---|
97 | def test_link
|
---|
98 | # test constructor
|
---|
99 | assert_equal 'generic', @link.meaning.value
|
---|
100 | assert_equal 'ehr://test/', @link.target.value
|
---|
101 | assert_equal 'problem', @link.type.value
|
---|
102 | # test meaning
|
---|
103 | assert_nothing_raised(Exception){@link.meaning = OpenEHR::RM::Data_Types::Text::DV_Text.new('clinical')}
|
---|
104 | assert_equal 'clinical', @link.meaning.value
|
---|
105 | assert_raise(ArgumentError){@link.meaning = nil}
|
---|
106 | # test target
|
---|
107 | assert_nothing_raised(Exception){@link.target = OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://try/")}
|
---|
108 | assert_equal 'ehr://try/', @link.target.value
|
---|
109 | assert_raise(ArgumentError){@link.target = nil}
|
---|
110 | # test type
|
---|
111 | assert_nothing_raised(Exception){@link.type = OpenEHR::RM::Data_Types::Text::DV_Text.new("issue")}
|
---|
112 | assert_equal 'issue', @link.type.value
|
---|
113 | assert_raise(ArgumentError){@link.type = nil}
|
---|
114 | end
|
---|
115 |
|
---|
116 | def test_feeder_audit
|
---|
117 | assert_equal 'AKAGI', @feeder_audit.originating_system_audit.system_id
|
---|
118 | assert_equal 'RITSUKO', @feeder_audit.originating_system_item_ids[0].issuer
|
---|
119 | assert_equal 'KATSURAGI', @feeder_audit.feeder_system_audit.system_id
|
---|
120 | assert_equal 'MISATO', @feeder_audit.feeder_system_item_ids[0].issuer
|
---|
121 | assert_equal 'UTF-8', @feeder_audit.original_content.charset.code_string
|
---|
122 | end
|
---|
123 |
|
---|
124 | def test_feeder_audit_detail
|
---|
125 | assert_equal 'MAGI', @feeder_audit_details.system_id
|
---|
126 | assert_equal 'NERV', @feeder_audit_details.provider.name
|
---|
127 | assert_equal 'GEOFRONT', @feeder_audit_details.location.name
|
---|
128 | assert_equal 2009, @feeder_audit_details.time.year
|
---|
129 | assert_equal 'local', @feeder_audit_details.subject.external_ref.namespace
|
---|
130 | assert_equal '0.0.4', @feeder_audit_details.version_id
|
---|
131 | end
|
---|
132 | end
|
---|
133 |
|
---|
134 | class RM_Common_Generic_Test < Test::Unit::TestCase
|
---|
135 | def setup
|
---|
136 | assert_nothing_raised(Exception){party_proxy = Party_Proxy.new}
|
---|
137 | object_id = Object_ID.new('0.0.4')
|
---|
138 | party_ref = Party_Ref.new('unknown', 'ORGANISATION', object_id)
|
---|
139 | assert_nothing_raised(Exception){
|
---|
140 | @party_proxy = Party_Proxy.new(:external_ref => party_ref)}
|
---|
141 | assert_nothing_raised(Exception){party_self = Party_Self.new}
|
---|
142 | assert_nothing_raised(Exception){
|
---|
143 | @party_self = Party_Self.new(:external_ref => party_ref)}
|
---|
144 | assert_raise(ArgumentError){
|
---|
145 | party_identified = Party_Identified.new}
|
---|
146 |
|
---|
147 | identifiers = []
|
---|
148 | identifiers << DV_Identifier.new('NERV', 'MELCHIOR', 'GENDO', 'COMPUTER')
|
---|
149 | identifiers << DV_Identifier.new('NERV', 'CASPER', 'GENDO', 'COMPUTER')
|
---|
150 | identifiers << DV_Identifier.new('NERV', 'BALTHAZAR', 'GENDO', 'COMPUTER')
|
---|
151 | assert_nothing_raised(Exception){
|
---|
152 | @party_identified = Party_Identified.new(:name => 'NERV',
|
---|
153 | :external_ref => party_ref,
|
---|
154 | :identifier => identifiers)}
|
---|
155 |
|
---|
156 | terminology_id = Terminology_ID.new('test','0.04')
|
---|
157 | code_phrase = Code_Phrase.new('self', terminology_id)
|
---|
158 | dv_coded_text = DV_Coded_Text.new('Seele',code_phrase)
|
---|
159 | assert_nothing_raised(Exception){
|
---|
160 | @party_related = Party_Related.new(:name => 'GEHIRN',
|
---|
161 | :relationship => dv_coded_text)}
|
---|
162 | dv_text = DV_Text.new('commiter')
|
---|
163 | dv_coded_text = DV_Coded_Text.new('present',terminology_id)
|
---|
164 | dv_date_time1 = DV_Date_Time.new('2009-07-04T16:30:00')
|
---|
165 | dv_date_time2 = DV_Date_Time.new('2009-07-14T00:00:00')
|
---|
166 | dv_interval = DV_Interval.new(dv_date_time1, dv_date_time2)
|
---|
167 | assert_nothing_raised(Exception){
|
---|
168 | @participation = Participation.new(:performer => @party_proxy,
|
---|
169 | :function => dv_text,
|
---|
170 | :mode => dv_coded_text,
|
---|
171 | :time => dv_interval)}
|
---|
172 | dv_date_time = DV_Date_Time.new('2009-07-04T18:56:00')
|
---|
173 | terminology_id = Terminology_ID.new('openehr','1.0.2')
|
---|
174 | code_phrase = Code_Phrase.new('249', terminology_id)
|
---|
175 | dv_coded_text = DV_Coded_Text.new('creation', code_phrase)
|
---|
176 | dv_text = DV_Text.new('test environment')
|
---|
177 | assert_nothing_raised(Exception){
|
---|
178 | @audit_details = Audit_Details.new(:system_id => 'MAGI',
|
---|
179 | :committer => @party_proxy,
|
---|
180 | :time_committed => dv_date_time,
|
---|
181 | :change_type => dv_coded_text,
|
---|
182 | :description => dv_text)}
|
---|
183 | dv_text = DV_Text.new('authorisation')
|
---|
184 | dv_ehr_uri = DV_EHR_URI.new('ehr://test/')
|
---|
185 | assert_nothing_raised(Exception){
|
---|
186 | @attestation = Attestation.new(:system_id => 'NERV',
|
---|
187 | :committer => @party_proxy,
|
---|
188 | :time_committed => dv_date_time,
|
---|
189 | :change_type => dv_coded_text,
|
---|
190 | :reason => dv_text,
|
---|
191 | :description => dv_text,
|
---|
192 | :proof => 'hashedstring',
|
---|
193 | :items => Set[dv_ehr_uri])}
|
---|
194 | object_version_id = Object_Version_ID.new('SHOGOUKI::NERV::1.1.1')
|
---|
195 | audit_details2 = Audit_Details.new(:system_id => 'MAGI',
|
---|
196 | :committer => @party_proxy,
|
---|
197 | :time_committed => dv_date_time2,
|
---|
198 | :change_type => dv_coded_text)
|
---|
199 | assert_nothing_raised(Exception){
|
---|
200 | @revision_history_item = Revision_History_Item.new(:audits => [@audit_details, audit_details2],
|
---|
201 | :version_id => object_version_id)}
|
---|
202 | dv_date_time3 = DV_Date_Time.new('2009-07-14T12:00:00')
|
---|
203 | dv_date_time4 = DV_Date_Time.new('2009-07-15T00:00:00')
|
---|
204 | audit_details3 = Audit_Details.new(:system_id => 'MAGI',
|
---|
205 | :committer => @party_proxy,
|
---|
206 | :time_committed => dv_date_time3,
|
---|
207 | :change_type => dv_coded_text)
|
---|
208 | audit_details4 = Audit_Details.new(:system_id => 'MAGI',
|
---|
209 | :committer => @party_proxy,
|
---|
210 | :time_committed => dv_date_time4,
|
---|
211 | :change_type => dv_coded_text)
|
---|
212 | object_version_id = Object_Version_ID.new('NIGOUKI::NERV::2.2.2')
|
---|
213 | revision_history_item2 = Revision_History_Item.new(:audits => [audit_details3, audit_details4],
|
---|
214 | :version_id => object_version_id)
|
---|
215 | assert_nothing_raised(Exception){
|
---|
216 | @revision_history = Revision_History.new([@revision_history_item, revision_history_item2])}
|
---|
217 | end
|
---|
218 |
|
---|
219 | def test_init
|
---|
220 | assert_instance_of Party_Proxy, @party_proxy
|
---|
221 | assert_instance_of Party_Self, @party_self
|
---|
222 | assert_instance_of Party_Identified, @party_identified
|
---|
223 | assert_instance_of Participation, @participation
|
---|
224 | assert_instance_of Audit_Details, @audit_details
|
---|
225 | assert_instance_of Attestation, @attestation
|
---|
226 | assert_instance_of Revision_History_Item, @revision_history_item
|
---|
227 | assert_instance_of Revision_History, @revision_history
|
---|
228 | end
|
---|
229 |
|
---|
230 | def test_party_proxy
|
---|
231 | assert_equal 'unknown', @party_proxy.external_ref.namespace
|
---|
232 | end
|
---|
233 |
|
---|
234 | def test_party_self
|
---|
235 | assert_equal 'ORGANISATION', @party_self.external_ref.type
|
---|
236 | end
|
---|
237 |
|
---|
238 | def test_party_identified
|
---|
239 | assert_equal 'NERV', @party_identified.name
|
---|
240 | assert_equal '0.0.4', @party_identified.external_ref.id.value
|
---|
241 | identifiers = @party_identified.identifier
|
---|
242 | ids = [ ]
|
---|
243 | identifiers.each do |id|
|
---|
244 | ids << id.id
|
---|
245 | end
|
---|
246 | assert_equal %w[MELCHIOR CASPER BALTHAZAR], ids
|
---|
247 | end
|
---|
248 |
|
---|
249 | def test_party_related
|
---|
250 | assert_equal 'GEHIRN', @party_related.name
|
---|
251 | end
|
---|
252 |
|
---|
253 | def test_participation
|
---|
254 | assert_equal 'unknown', @participation.performer.external_ref.namespace
|
---|
255 | assert_equal 'commiter', @participation.function.value
|
---|
256 | assert_equal 'present', @participation.mode.value
|
---|
257 | assert_equal 2009, @participation.time.lower.year
|
---|
258 | end
|
---|
259 |
|
---|
260 | def test_audit_details
|
---|
261 | assert_equal 'MAGI', @audit_details.system_id
|
---|
262 | assert_equal 'unknown', @audit_details.committer.external_ref.namespace
|
---|
263 | assert_equal '2009-07-04T18:56:00', @audit_details.time_committed.as_string
|
---|
264 | assert_equal 'creation', @audit_details.change_type.value
|
---|
265 | assert_equal 'test environment', @audit_details.description.value
|
---|
266 | end
|
---|
267 |
|
---|
268 | def test_attestation
|
---|
269 | assert_equal 'NERV', @attestation.system_id
|
---|
270 | assert_equal 'unknown', @attestation.committer.external_ref.namespace
|
---|
271 | assert_equal '249', @attestation.change_type.defining_code.code_string
|
---|
272 | assert_equal 7, @attestation.time_committed.month
|
---|
273 | assert_equal 'authorisation', @attestation.reason.value
|
---|
274 | assert_equal 'authorisation', @attestation.description.value
|
---|
275 | assert_equal 'hashedstring', @attestation.proof
|
---|
276 | assert_equal 'ehr://test/', @attestation.items.to_a[0].value
|
---|
277 | end
|
---|
278 |
|
---|
279 | def test_revision_history_item
|
---|
280 | assert_equal 'SHOGOUKI::NERV::1.1.1', @revision_history_item.version_id.value
|
---|
281 | assert_equal 'MAGI', @revision_history_item.audits[0].system_id
|
---|
282 | end
|
---|
283 |
|
---|
284 | def test_revision_history
|
---|
285 | assert_equal 'NIGOUKI::NERV::2.2.2', @revision_history.most_recent_version
|
---|
286 | assert_equal '2009-07-14T12:00:00', @revision_history.most_recent_version_time_committed
|
---|
287 | end
|
---|
288 | end
|
---|
289 |
|
---|
290 | class RM_Common_Directory_Test < Test::Unit::TestCase
|
---|
291 | def setup
|
---|
292 | dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('root')
|
---|
293 | assert_nothing_raised(Exception){@folder = OpenEHR::RM::Common::Directory::Folder.new('at0000', dv_text, nil)}
|
---|
294 | end
|
---|
295 |
|
---|
296 | def test_init
|
---|
297 | assert_instance_of OpenEHR::RM::Common::Directory::Folder, @folder
|
---|
298 | end
|
---|
299 |
|
---|
300 | def test_folder
|
---|
301 | assert_equal 'at0000', @folder.archetype_node_id
|
---|
302 | assert_equal 'root', @folder.name.value
|
---|
303 | end
|
---|
304 | end
|
---|
305 |
|
---|
306 | class RM_Common_Change_Control_Test < Test::Unit::TestCase
|
---|
307 | def setup
|
---|
308 | hier_object_id = OpenEHR::RM::Support::Identification::Hier_Object_ID.new('0.0.4')
|
---|
309 | object_id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.3")
|
---|
310 | object_ref = OpenEHR::RM::Support::Identification::Object_Ref.new('local', 'ANY', object_id)
|
---|
311 | versions = Set.new [object_ref]
|
---|
312 | # audit_detail = OpenEHR::RM::Generic::Audit_Detail.new()
|
---|
313 | # assert_nothing_raised(Exception){@version = OpenEHR::RM::Common::Change_Control::Version.new(hier_object_id, versions)}
|
---|
314 | # assert_nothing_raised(Exception){@contribution = OpenEHR::RM::Common::Change_Control::Contribution.new(hier_object_id, versions, audit_detail)}
|
---|
315 | end
|
---|
316 | def test_init
|
---|
317 | # assert_instace_of OpenEHR::RM::Common::Change_Control::Contribution @contribution
|
---|
318 | # assert_instace_of OpenEHR::RM::Common::Change_Control::Version @version
|
---|
319 | end
|
---|
320 | def test_version
|
---|
321 | end
|
---|
322 | def test_contribution
|
---|
323 | # assert_equal @contribution.uid
|
---|
324 | end
|
---|
325 | end
|
---|