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 |
|
---|
10 | class RM_Common_Resource_Test < Test::Unit::TestCase
|
---|
11 | def setup
|
---|
12 | @authored_resource = OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE.new(:original_language => "ja",
|
---|
13 | :translations => "en",
|
---|
14 | :description => "test")
|
---|
15 | @translation_details = OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS.new(nil,nil,nil,nil,nil)
|
---|
16 | end
|
---|
17 | def test_init
|
---|
18 | assert_instance_of OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE, @authored_resource
|
---|
19 | assert_instance_of OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS, @translation_details
|
---|
20 | end
|
---|
21 |
|
---|
22 | def test_authoured_resource
|
---|
23 | assert_equal 'ja', @authored_resource.original_language
|
---|
24 | end
|
---|
25 | end
|
---|
26 |
|
---|
27 |
|
---|
28 | class RM_Common_Archetyped_Test < Test::Unit::TestCase
|
---|
29 | def setup
|
---|
30 | @dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('Test')
|
---|
31 | @uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.5')
|
---|
32 | @archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
|
---|
33 | @template_id = OpenEHR::RM::Support::Identification::Template_ID.new('1.0.1')
|
---|
34 | assert_nothing_raised(Exception){@archetyped = OpenEHR::RM::Common::Archetyped::Archetyped.new(@archetype_id, '1.0.1')}
|
---|
35 | 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"))}
|
---|
36 | assert_nothing_raised(Exception){
|
---|
37 | @pathable = OpenEHR::RM::Common::Archetyped::Pathable.new }
|
---|
38 | name = OpenEHR::RM::Data_Types::Text::DV_Text.new('blood')
|
---|
39 | links = Set.new([@uid_based_id])
|
---|
40 | assert_nothing_raised(Exception){
|
---|
41 | @locatable = OpenEHR::RM::Common::Archetyped::Locatable.new('at0001',name,links)}
|
---|
42 | provider = Party_Identified.new(:name => 'NERV')
|
---|
43 | location = Party_Identified.new(:name => 'GEOFRONT')
|
---|
44 | object_id = Object_ID.new('0.0.4')
|
---|
45 | party_ref = Party_Ref.new('local', 'ORGANISATION', object_id)
|
---|
46 | assert_nothing_raised(Exception){
|
---|
47 | @feeder_audit_details = Feeder_Audit_Details.new(:system_id => 'MAGI',
|
---|
48 | :provider => provider,
|
---|
49 | :location => location,
|
---|
50 | :time => DV_Date_Time.new('2009-07-03T12:16:31'),
|
---|
51 | :subject => Party_Proxy.new(:external_ref => party_ref),
|
---|
52 | :version_id => '0.0.4')}
|
---|
53 | feeder_audit_details = Feeder_Audit_Details.new(:system_id => 'AKAGI')
|
---|
54 | dv_identifier = DV_Identifier.new('NERV', 'MELCHIOR', 'RITSUKO', 'COMPUTER')
|
---|
55 | feeder_audit_details2 = Feeder_Audit_Details.new(:system_id => 'KATSURAGI')
|
---|
56 | dv_identifier2 = DV_Identifier.new('NERV', 'SHOGOUKI', 'MISATO', 'EVANGELION')
|
---|
57 | charset = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('UTF-8','character-sets')
|
---|
58 | language = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('ja', 'languages')
|
---|
59 |
|
---|
60 | dv_encapsulated = OpenEHR::RM::Data_Types::Encapsulated::DV_Encapsulated.new(charset, language, 10)
|
---|
61 | assert_nothing_raised(Exception){
|
---|
62 | @feeder_audit = Feeder_Audit.new(:originating_system_audit => feeder_audit_details,
|
---|
63 | :originating_system_item_ids => [dv_identifier],
|
---|
64 | :feeder_system_audit => feeder_audit_details2,
|
---|
65 | :feeder_system_item_ids => [dv_identifier2],
|
---|
66 | :original_content => dv_encapsulated)}
|
---|
67 | end
|
---|
68 |
|
---|
69 | def test_init
|
---|
70 | assert_instance_of OpenEHR::RM::Common::Archetyped::Archetyped, @archetyped
|
---|
71 | assert_instance_of OpenEHR::RM::Common::Archetyped::Link, @link
|
---|
72 | assert_instance_of OpenEHR::RM::Common::Archetyped::Pathable, @pathable
|
---|
73 | assert_instance_of OpenEHR::RM::Common::Archetyped::Locatable, @locatable
|
---|
74 | assert_instance_of Feeder_Audit_Details, @feeder_audit_details
|
---|
75 | assert_instance_of Feeder_Audit, @feeder_audit
|
---|
76 | end
|
---|
77 |
|
---|
78 | def test_archetyped
|
---|
79 | assert_equal @archetype_id, @archetyped.archetype_id
|
---|
80 | assert_equal '1.0.1', @archetyped.rm_version
|
---|
81 | assert_raise(ArgumentError){@archetyped.archetype_id = nil}
|
---|
82 | assert_raise(ArgumentError){@archetyped.rm_version = nil}
|
---|
83 | assert_raise(ArgumentError){@archetyped.rm_version = ''}
|
---|
84 | assert_nothing_raised(Exception){@archetyped.template_id = @template_id}
|
---|
85 | assert_equal @template_id, @archetyped.template_id
|
---|
86 | archetype_id2 = OpenEHR::RM::Support::Identification::Archetype_ID.new("1.0.2", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
|
---|
87 | assert_nothing_raised(ArgumentError){@archetyped.archetype_id = archetype_id2}
|
---|
88 | assert_equal archetype_id2, @archetyped.archetype_id
|
---|
89 | assert_nothing_raised(ArgumentError){@archetyped.rm_version = '1.0.2'}
|
---|
90 | assert_equal '1.0.2', @archetyped.rm_version
|
---|
91 | end
|
---|
92 |
|
---|
93 | def test_link
|
---|
94 | # test constructor
|
---|
95 | assert_equal 'generic', @link.meaning.value
|
---|
96 | assert_equal 'ehr://test/', @link.target.value
|
---|
97 | assert_equal 'problem', @link.type.value
|
---|
98 | # test meaning
|
---|
99 | assert_nothing_raised(Exception){@link.meaning = OpenEHR::RM::Data_Types::Text::DV_Text.new('clinical')}
|
---|
100 | assert_equal 'clinical', @link.meaning.value
|
---|
101 | assert_raise(ArgumentError){@link.meaning = nil}
|
---|
102 | # test target
|
---|
103 | assert_nothing_raised(Exception){@link.target = OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://try/")}
|
---|
104 | assert_equal 'ehr://try/', @link.target.value
|
---|
105 | assert_raise(ArgumentError){@link.target = nil}
|
---|
106 | # test type
|
---|
107 | assert_nothing_raised(Exception){@link.type = OpenEHR::RM::Data_Types::Text::DV_Text.new("issue")}
|
---|
108 | assert_equal 'issue', @link.type.value
|
---|
109 | assert_raise(ArgumentError){@link.type = nil}
|
---|
110 | end
|
---|
111 |
|
---|
112 | def test_feeder_audit
|
---|
113 | assert_equal 'AKAGI', @feeder_audit.originating_system_audit.system_id
|
---|
114 | assert_equal 'RITSUKO', @feeder_audit.originating_system_item_ids[0].issuer
|
---|
115 | assert_equal 'KATSURAGI', @feeder_audit.feeder_system_audit.system_id
|
---|
116 | assert_equal 'MISATO', @feeder_audit.feeder_system_item_ids[0].issuer
|
---|
117 | assert_equal 'UTF-8', @feeder_audit.original_content.charset.code_string
|
---|
118 | end
|
---|
119 |
|
---|
120 | def test_feeder_audit_detail
|
---|
121 | assert_equal 'MAGI', @feeder_audit_details.system_id
|
---|
122 | assert_equal 'NERV', @feeder_audit_details.provider.name
|
---|
123 | assert_equal 'GEOFRONT', @feeder_audit_details.location.name
|
---|
124 | assert_equal 2009, @feeder_audit_details.time.year
|
---|
125 | assert_equal 'local', @feeder_audit_details.subject.external_ref.namespace
|
---|
126 | assert_equal '0.0.4', @feeder_audit_details.version_id
|
---|
127 | end
|
---|
128 | end
|
---|
129 |
|
---|
130 | class RM_Common_Generic_Test < Test::Unit::TestCase
|
---|
131 | include OpenEHR::RM::Common::Generic
|
---|
132 | include OpenEHR::RM::Support::Identification
|
---|
133 | include OpenEHR::RM::Data_Types::Basic
|
---|
134 | def setup
|
---|
135 | assert_nothing_raised(Exception){party_proxy = Party_Proxy.new}
|
---|
136 | object_id = Object_ID.new('0.0.4')
|
---|
137 | party_ref = Party_Ref.new('unknown', 'ORGANISATION', object_id)
|
---|
138 | assert_nothing_raised(Exception){
|
---|
139 | @party_proxy = Party_Proxy.new(:external_ref => party_ref)}
|
---|
140 | assert_nothing_raised(Exception){party_self = Party_Self.new}
|
---|
141 | assert_nothing_raised(Exception){
|
---|
142 | @party_self = Party_Self.new(:external_ref => party_ref)}
|
---|
143 | assert_raise(ArgumentError){
|
---|
144 | party_identified = Party_Identified.new}
|
---|
145 | identifiers = []
|
---|
146 | identifiers << DV_Identifier.new('NERV', 'MELCHIOR', 'GENDO', 'COMPUTER')
|
---|
147 | identifiers << DV_Identifier.new('NERV', 'CASPER', 'GENDO', 'COMPUTER')
|
---|
148 | identifiers << DV_Identifier.new('NERV', 'BALTHAZAR', 'GENDO', 'COMPUTER')
|
---|
149 | assert_nothing_raised(Exception){
|
---|
150 | @party_identified = Party_Identified.new(:name => 'NERV',
|
---|
151 | :external_ref => party_ref,
|
---|
152 | :identifier => identifiers)}
|
---|
153 | # change_type = OpenEHR::RM::Data_Types::Text::DV_Text.new('audit_type')
|
---|
154 | # time_committed = OpenEHR::RM::Data_Types::Quantity::Date_Time::DV_Date_Time.new(2008)
|
---|
155 | # assert_nothing_raised(Exception){@audit_details = OpenEHR::RM::Common::Generic::Audit_Details.new('rails',@party_proxy, change_type, time_committed)}
|
---|
156 | end
|
---|
157 |
|
---|
158 | def test_init
|
---|
159 | assert_instance_of Party_Proxy, @party_proxy
|
---|
160 | assert_instance_of Party_Self, @party_self
|
---|
161 | assert_instance_of Party_Identified, @party_identified
|
---|
162 | end
|
---|
163 |
|
---|
164 | def test_party_proxy
|
---|
165 | assert_equal 'unknown', @party_proxy.external_ref.namespace
|
---|
166 | end
|
---|
167 |
|
---|
168 | def test_party_self
|
---|
169 | assert_equal 'ORGANISATION', @party_self.external_ref.type
|
---|
170 | end
|
---|
171 |
|
---|
172 | def test_party_identified
|
---|
173 | assert_equal 'NERV', @party_identified.name
|
---|
174 | assert_equal '0.0.4', @party_identified.external_ref.id.value
|
---|
175 | identifiers = @party_identified.identifier
|
---|
176 | ids = [ ]
|
---|
177 | identifiers.each do |id|
|
---|
178 | ids << id.id
|
---|
179 | end
|
---|
180 | assert_equal %w[MELCHIOR CASPER BALTHAZAR], ids
|
---|
181 | end
|
---|
182 | end
|
---|
183 |
|
---|
184 | class RM_Common_Directory_Test < Test::Unit::TestCase
|
---|
185 | def setup
|
---|
186 | dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('root')
|
---|
187 | assert_nothing_raised(Exception){@folder = OpenEHR::RM::Common::Directory::Folder.new('at0000', dv_text, nil)}
|
---|
188 | end
|
---|
189 |
|
---|
190 | def test_init
|
---|
191 | assert_instance_of OpenEHR::RM::Common::Directory::Folder, @folder
|
---|
192 | end
|
---|
193 |
|
---|
194 | def test_folder
|
---|
195 | assert_equal 'at0000', @folder.archetype_node_id
|
---|
196 | assert_equal 'root', @folder.name.value
|
---|
197 | end
|
---|
198 | end
|
---|
199 |
|
---|
200 | class RM_Common_Change_Control_Test < Test::Unit::TestCase
|
---|
201 | def setup
|
---|
202 | hier_object_id = OpenEHR::RM::Support::Identification::Hier_Object_ID.new('0.0.4')
|
---|
203 | object_id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.3")
|
---|
204 | object_ref = OpenEHR::RM::Support::Identification::Object_Ref.new('local', 'ANY', object_id)
|
---|
205 | versions = Set.new [object_ref]
|
---|
206 | # audit_detail = OpenEHR::RM::Generic::Audit_Detail.new()
|
---|
207 | # assert_nothing_raised(Exception){@version = OpenEHR::RM::Common::Change_Control::Version.new(hier_object_id, versions)}
|
---|
208 | # assert_nothing_raised(Exception){@contribution = OpenEHR::RM::Common::Change_Control::Contribution.new(hier_object_id, versions, audit_detail)}
|
---|
209 | end
|
---|
210 | def test_init
|
---|
211 | # assert_instace_of OpenEHR::RM::Common::Change_Control::Contribution @contribution
|
---|
212 | # assert_instace_of OpenEHR::RM::Common::Change_Control::Version @version
|
---|
213 | end
|
---|
214 | def test_version
|
---|
215 | end
|
---|
216 | def test_contribution
|
---|
217 | # assert_equal @contribution.uid
|
---|
218 | end
|
---|
219 | end
|
---|