[119] | 1 | require 'test/unit'
|
---|
| 2 | require 'set'
|
---|
| 3 | require 'rm'
|
---|
| 4 |
|
---|
[153] | 5 | include OpenEHR::RM::Data_Types::Text
|
---|
| 6 | include OpenEHR::RM::Common::Resource
|
---|
| 7 | include OpenEHR::RM::Common::Archetyped
|
---|
[154] | 8 | include OpenEHR::RM::Common::Generic
|
---|
[158] | 9 | include OpenEHR::RM::Common::Change_Control
|
---|
[162] | 10 | include OpenEHR::RM::Common::Directory
|
---|
[155] | 11 | include OpenEHR::RM::Support::Identification
|
---|
| 12 | include OpenEHR::RM::Data_Types::Basic
|
---|
[156] | 13 | include OpenEHR::RM::Data_Types::Quantity
|
---|
[157] | 14 | include OpenEHR::RM::Data_Types::URI
|
---|
[153] | 15 |
|
---|
[119] | 16 | class RM_Common_Resource_Test < Test::Unit::TestCase
|
---|
| 17 | def setup
|
---|
[163] | 18 | terminology_id = Terminology_ID.new('openehr')
|
---|
| 19 | code_phrase = Code_Phrase.new('ja', terminology_id)
|
---|
| 20 | @translation_details = OpenEHR::RM::Common::Resource::Translation_Details.new(:language => code_phrase, :author => {'KOBAYASHI, Shinji', 'Ehime Univ'},
|
---|
| 21 | :accreditation => 'jp', :other_details => {'ruby', 'test'})
|
---|
| 22 | @authored_resource = OpenEHR::RM::Common::Resource::Authored_Resource.new(:original_language => code_phrase, :translations => {'ja', @translation_details}, :description => "test")
|
---|
| 23 | @resource_description_item = OpenEHR::RM::Common::Resource::Resource_Description_Item.new(:language => code_phrase,
|
---|
| 24 | :purpose => 'test',
|
---|
| 25 | :keywords => %w[test ruby],
|
---|
| 26 | :use => 'unit test',
|
---|
| 27 | :misuse => 'real use',
|
---|
| 28 | :copyright => 'openEHR.jp',
|
---|
| 29 | :original_resource_uri => {'issuer', 'http://openehr.jp/'},
|
---|
| 30 | :other_details => {'samos', 'icicth7'})
|
---|
| 31 | @resource_description = OpenEHR::RM::Common::Resource::Resource_Description.new(:original_author => {'KOBAYASHI, Shinji' => 'Ehime University'},
|
---|
| 32 | :lifecycle_state => 'experimental',
|
---|
| 33 | :details => {'ja', @resource_description_item},
|
---|
| 34 | :other_contributors => %w[aki tim hugh],
|
---|
| 35 | :resource_package_uri => 'http://openehr.jp/svn/ruby',
|
---|
| 36 | :other_details => {'ja', 'shikoku'},
|
---|
| 37 | :parent_resource => @authored_resource)
|
---|
| 38 | @authored_resource = OpenEHR::RM::Common::Resource::Authored_Resource.new(:original_language => code_phrase, :translations => {'ja', @translation_details}, :description => @resource_description)
|
---|
[119] | 39 | end
|
---|
[163] | 40 |
|
---|
[119] | 41 | def test_init
|
---|
[163] | 42 | assert_instance_of OpenEHR::RM::Common::Resource::Authored_Resource, @authored_resource
|
---|
| 43 | assert_instance_of OpenEHR::RM::Common::Resource::Translation_Details, @translation_details
|
---|
| 44 | assert_instance_of OpenEHR::RM::Common::Resource::Resource_Description_Item, @resource_description_item
|
---|
| 45 | assert_instance_of OpenEHR::RM::Common::Resource::Resource_Description, @resource_description
|
---|
[119] | 46 | end
|
---|
| 47 |
|
---|
[163] | 48 | def test_translation_details
|
---|
| 49 | assert_equal 'ja', @translation_details.language.code_string
|
---|
| 50 | assert_equal 'Ehime Univ', @translation_details.author['KOBAYASHI, Shinji']
|
---|
| 51 | assert_equal 'jp', @translation_details.accreditation
|
---|
| 52 | assert_equal 'test', @translation_details.other_details['ruby']
|
---|
| 53 | end
|
---|
| 54 |
|
---|
[153] | 55 | def test_authoured_resource
|
---|
[163] | 56 | assert_equal 'ja', @authored_resource.original_language.code_string
|
---|
| 57 | assert_equal @translation_details, @authored_resource.translations['ja']
|
---|
| 58 | assert_equal 'experimental', @authored_resource.description.lifecycle_state
|
---|
| 59 | assert !@authored_resource.is_controlled?
|
---|
| 60 | assert_equal(Set['ja'], @authored_resource.languages_available)
|
---|
[153] | 61 | end
|
---|
[163] | 62 |
|
---|
| 63 | def test_resource_description_item
|
---|
| 64 | assert_equal 'ja', @resource_description_item.language.code_string
|
---|
| 65 | assert_equal 'test', @resource_description_item.purpose
|
---|
| 66 | assert_equal %w[test ruby], @resource_description_item.keywords
|
---|
| 67 | assert_equal 'unit test', @resource_description_item.use
|
---|
| 68 | assert_equal 'real use', @resource_description_item.misuse
|
---|
| 69 | assert_equal 'openEHR.jp', @resource_description_item.copyright
|
---|
| 70 | assert_equal 'http://openehr.jp/', @resource_description_item.original_resource_uri['issuer']
|
---|
| 71 | assert_equal 'icicth7', @resource_description_item.other_details['samos']
|
---|
| 72 | end
|
---|
| 73 |
|
---|
| 74 | def test_resource_description
|
---|
| 75 | assert_equal 'Ehime University', @resource_description.original_author['KOBAYASHI, Shinji']
|
---|
| 76 | assert_equal 'experimental', @resource_description.lifecycle_state
|
---|
| 77 | assert_equal 'test', @resource_description.details['ja'].purpose
|
---|
| 78 | assert_equal %w[aki tim hugh], @resource_description.other_contributors
|
---|
| 79 | assert_equal 'http://openehr.jp/svn/ruby', @resource_description.resource_package_uri
|
---|
| 80 | assert_equal 'shikoku', @resource_description.other_details['ja']
|
---|
| 81 | assert_equal 'ja', @resource_description.parent_resource.original_language.code_string
|
---|
| 82 | end
|
---|
[119] | 83 | end
|
---|
| 84 |
|
---|
[154] | 85 |
|
---|
[119] | 86 | class RM_Common_Archetyped_Test < Test::Unit::TestCase
|
---|
| 87 | def setup
|
---|
| 88 | @dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('Test')
|
---|
| 89 | @uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.5')
|
---|
| 90 | @archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
|
---|
| 91 | @template_id = OpenEHR::RM::Support::Identification::Template_ID.new('1.0.1')
|
---|
| 92 | assert_nothing_raised(Exception){@archetyped = OpenEHR::RM::Common::Archetyped::Archetyped.new(@archetype_id, '1.0.1')}
|
---|
| 93 | 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"))}
|
---|
[128] | 94 | assert_nothing_raised(Exception){
|
---|
| 95 | @pathable = OpenEHR::RM::Common::Archetyped::Pathable.new }
|
---|
| 96 | name = OpenEHR::RM::Data_Types::Text::DV_Text.new('blood')
|
---|
| 97 | links = Set.new([@uid_based_id])
|
---|
| 98 | assert_nothing_raised(Exception){
|
---|
[162] | 99 | @locatable = Locatable.new(:archetype_node_id => 'at0001',
|
---|
| 100 | :name => name,
|
---|
| 101 | :links => links)}
|
---|
[154] | 102 | provider = Party_Identified.new(:name => 'NERV')
|
---|
| 103 | location = Party_Identified.new(:name => 'GEOFRONT')
|
---|
[157] | 104 | object_version_id = Object_Version_ID.new('ABC::DEF::1.3.4')
|
---|
[154] | 105 | party_ref = Party_Ref.new('local', 'ORGANISATION', object_id)
|
---|
[153] | 106 | assert_nothing_raised(Exception){
|
---|
[154] | 107 | @feeder_audit_details = Feeder_Audit_Details.new(:system_id => 'MAGI',
|
---|
| 108 | :provider => provider,
|
---|
| 109 | :location => location,
|
---|
| 110 | :time => DV_Date_Time.new('2009-07-03T12:16:31'),
|
---|
| 111 | :subject => Party_Proxy.new(:external_ref => party_ref),
|
---|
| 112 | :version_id => '0.0.4')}
|
---|
| 113 | feeder_audit_details = Feeder_Audit_Details.new(:system_id => 'AKAGI')
|
---|
| 114 | dv_identifier = DV_Identifier.new('NERV', 'MELCHIOR', 'RITSUKO', 'COMPUTER')
|
---|
| 115 | feeder_audit_details2 = Feeder_Audit_Details.new(:system_id => 'KATSURAGI')
|
---|
| 116 | dv_identifier2 = DV_Identifier.new('NERV', 'SHOGOUKI', 'MISATO', 'EVANGELION')
|
---|
| 117 | charset = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('UTF-8','character-sets')
|
---|
| 118 | language = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('ja', 'languages')
|
---|
| 119 |
|
---|
| 120 | dv_encapsulated = OpenEHR::RM::Data_Types::Encapsulated::DV_Encapsulated.new(charset, language, 10)
|
---|
| 121 | assert_nothing_raised(Exception){
|
---|
| 122 | @feeder_audit = Feeder_Audit.new(:originating_system_audit => feeder_audit_details,
|
---|
| 123 | :originating_system_item_ids => [dv_identifier],
|
---|
| 124 | :feeder_system_audit => feeder_audit_details2,
|
---|
| 125 | :feeder_system_item_ids => [dv_identifier2],
|
---|
| 126 | :original_content => dv_encapsulated)}
|
---|
[119] | 127 | end
|
---|
| 128 |
|
---|
| 129 | def test_init
|
---|
| 130 | assert_instance_of OpenEHR::RM::Common::Archetyped::Archetyped, @archetyped
|
---|
| 131 | assert_instance_of OpenEHR::RM::Common::Archetyped::Link, @link
|
---|
[128] | 132 | assert_instance_of OpenEHR::RM::Common::Archetyped::Pathable, @pathable
|
---|
| 133 | assert_instance_of OpenEHR::RM::Common::Archetyped::Locatable, @locatable
|
---|
[153] | 134 | assert_instance_of Feeder_Audit_Details, @feeder_audit_details
|
---|
[154] | 135 | assert_instance_of Feeder_Audit, @feeder_audit
|
---|
[119] | 136 | end
|
---|
| 137 |
|
---|
| 138 | def test_archetyped
|
---|
| 139 | assert_equal @archetype_id, @archetyped.archetype_id
|
---|
| 140 | assert_equal '1.0.1', @archetyped.rm_version
|
---|
| 141 | assert_raise(ArgumentError){@archetyped.archetype_id = nil}
|
---|
| 142 | assert_raise(ArgumentError){@archetyped.rm_version = nil}
|
---|
| 143 | assert_raise(ArgumentError){@archetyped.rm_version = ''}
|
---|
| 144 | assert_nothing_raised(Exception){@archetyped.template_id = @template_id}
|
---|
| 145 | assert_equal @template_id, @archetyped.template_id
|
---|
| 146 | archetype_id2 = OpenEHR::RM::Support::Identification::Archetype_ID.new("1.0.2", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
|
---|
| 147 | assert_nothing_raised(ArgumentError){@archetyped.archetype_id = archetype_id2}
|
---|
| 148 | assert_equal archetype_id2, @archetyped.archetype_id
|
---|
| 149 | assert_nothing_raised(ArgumentError){@archetyped.rm_version = '1.0.2'}
|
---|
| 150 | assert_equal '1.0.2', @archetyped.rm_version
|
---|
| 151 | end
|
---|
| 152 |
|
---|
| 153 | def test_link
|
---|
| 154 | # test constructor
|
---|
| 155 | assert_equal 'generic', @link.meaning.value
|
---|
| 156 | assert_equal 'ehr://test/', @link.target.value
|
---|
| 157 | assert_equal 'problem', @link.type.value
|
---|
| 158 | # test meaning
|
---|
| 159 | assert_nothing_raised(Exception){@link.meaning = OpenEHR::RM::Data_Types::Text::DV_Text.new('clinical')}
|
---|
| 160 | assert_equal 'clinical', @link.meaning.value
|
---|
| 161 | assert_raise(ArgumentError){@link.meaning = nil}
|
---|
| 162 | # test target
|
---|
| 163 | assert_nothing_raised(Exception){@link.target = OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://try/")}
|
---|
| 164 | assert_equal 'ehr://try/', @link.target.value
|
---|
| 165 | assert_raise(ArgumentError){@link.target = nil}
|
---|
| 166 | # test type
|
---|
| 167 | assert_nothing_raised(Exception){@link.type = OpenEHR::RM::Data_Types::Text::DV_Text.new("issue")}
|
---|
| 168 | assert_equal 'issue', @link.type.value
|
---|
| 169 | assert_raise(ArgumentError){@link.type = nil}
|
---|
| 170 | end
|
---|
[153] | 171 |
|
---|
| 172 | def test_feeder_audit
|
---|
[154] | 173 | assert_equal 'AKAGI', @feeder_audit.originating_system_audit.system_id
|
---|
| 174 | assert_equal 'RITSUKO', @feeder_audit.originating_system_item_ids[0].issuer
|
---|
| 175 | assert_equal 'KATSURAGI', @feeder_audit.feeder_system_audit.system_id
|
---|
| 176 | assert_equal 'MISATO', @feeder_audit.feeder_system_item_ids[0].issuer
|
---|
| 177 | assert_equal 'UTF-8', @feeder_audit.original_content.charset.code_string
|
---|
[153] | 178 | end
|
---|
| 179 |
|
---|
| 180 | def test_feeder_audit_detail
|
---|
| 181 | assert_equal 'MAGI', @feeder_audit_details.system_id
|
---|
[154] | 182 | assert_equal 'NERV', @feeder_audit_details.provider.name
|
---|
| 183 | assert_equal 'GEOFRONT', @feeder_audit_details.location.name
|
---|
| 184 | assert_equal 2009, @feeder_audit_details.time.year
|
---|
| 185 | assert_equal 'local', @feeder_audit_details.subject.external_ref.namespace
|
---|
| 186 | assert_equal '0.0.4', @feeder_audit_details.version_id
|
---|
[153] | 187 | end
|
---|
[119] | 188 | end
|
---|
| 189 |
|
---|
| 190 | class RM_Common_Generic_Test < Test::Unit::TestCase
|
---|
| 191 | def setup
|
---|
[153] | 192 | assert_nothing_raised(Exception){party_proxy = Party_Proxy.new}
|
---|
| 193 | object_id = Object_ID.new('0.0.4')
|
---|
| 194 | party_ref = Party_Ref.new('unknown', 'ORGANISATION', object_id)
|
---|
| 195 | assert_nothing_raised(Exception){
|
---|
| 196 | @party_proxy = Party_Proxy.new(:external_ref => party_ref)}
|
---|
| 197 | assert_nothing_raised(Exception){party_self = Party_Self.new}
|
---|
| 198 | assert_nothing_raised(Exception){
|
---|
| 199 | @party_self = Party_Self.new(:external_ref => party_ref)}
|
---|
| 200 | assert_raise(ArgumentError){
|
---|
| 201 | party_identified = Party_Identified.new}
|
---|
[156] | 202 |
|
---|
[153] | 203 | identifiers = []
|
---|
| 204 | identifiers << DV_Identifier.new('NERV', 'MELCHIOR', 'GENDO', 'COMPUTER')
|
---|
| 205 | identifiers << DV_Identifier.new('NERV', 'CASPER', 'GENDO', 'COMPUTER')
|
---|
| 206 | identifiers << DV_Identifier.new('NERV', 'BALTHAZAR', 'GENDO', 'COMPUTER')
|
---|
| 207 | assert_nothing_raised(Exception){
|
---|
| 208 | @party_identified = Party_Identified.new(:name => 'NERV',
|
---|
| 209 | :external_ref => party_ref,
|
---|
| 210 | :identifier => identifiers)}
|
---|
[156] | 211 |
|
---|
[158] | 212 | terminology_id = Terminology_ID.new('test(0.04)')
|
---|
[155] | 213 | code_phrase = Code_Phrase.new('self', terminology_id)
|
---|
[156] | 214 | dv_coded_text = DV_Coded_Text.new('Seele',code_phrase)
|
---|
[155] | 215 | assert_nothing_raised(Exception){
|
---|
| 216 | @party_related = Party_Related.new(:name => 'GEHIRN',
|
---|
| 217 | :relationship => dv_coded_text)}
|
---|
[156] | 218 | dv_text = DV_Text.new('commiter')
|
---|
| 219 | dv_coded_text = DV_Coded_Text.new('present',terminology_id)
|
---|
| 220 | dv_date_time1 = DV_Date_Time.new('2009-07-04T16:30:00')
|
---|
| 221 | dv_date_time2 = DV_Date_Time.new('2009-07-14T00:00:00')
|
---|
| 222 | dv_interval = DV_Interval.new(dv_date_time1, dv_date_time2)
|
---|
| 223 | assert_nothing_raised(Exception){
|
---|
| 224 | @participation = Participation.new(:performer => @party_proxy,
|
---|
| 225 | :function => dv_text,
|
---|
| 226 | :mode => dv_coded_text,
|
---|
| 227 | :time => dv_interval)}
|
---|
| 228 | dv_date_time = DV_Date_Time.new('2009-07-04T18:56:00')
|
---|
[158] | 229 | terminology_id = Terminology_ID.new('openehr(1.0.2)')
|
---|
[156] | 230 | code_phrase = Code_Phrase.new('249', terminology_id)
|
---|
| 231 | dv_coded_text = DV_Coded_Text.new('creation', code_phrase)
|
---|
| 232 | dv_text = DV_Text.new('test environment')
|
---|
| 233 | assert_nothing_raised(Exception){
|
---|
| 234 | @audit_details = Audit_Details.new(:system_id => 'MAGI',
|
---|
| 235 | :committer => @party_proxy,
|
---|
| 236 | :time_committed => dv_date_time,
|
---|
| 237 | :change_type => dv_coded_text,
|
---|
| 238 | :description => dv_text)}
|
---|
[157] | 239 | dv_text = DV_Text.new('authorisation')
|
---|
| 240 | dv_ehr_uri = DV_EHR_URI.new('ehr://test/')
|
---|
| 241 | assert_nothing_raised(Exception){
|
---|
| 242 | @attestation = Attestation.new(:system_id => 'NERV',
|
---|
| 243 | :committer => @party_proxy,
|
---|
| 244 | :time_committed => dv_date_time,
|
---|
| 245 | :change_type => dv_coded_text,
|
---|
| 246 | :reason => dv_text,
|
---|
| 247 | :description => dv_text,
|
---|
| 248 | :proof => 'hashedstring',
|
---|
| 249 | :items => Set[dv_ehr_uri])}
|
---|
| 250 | object_version_id = Object_Version_ID.new('SHOGOUKI::NERV::1.1.1')
|
---|
| 251 | audit_details2 = Audit_Details.new(:system_id => 'MAGI',
|
---|
| 252 | :committer => @party_proxy,
|
---|
| 253 | :time_committed => dv_date_time2,
|
---|
| 254 | :change_type => dv_coded_text)
|
---|
| 255 | assert_nothing_raised(Exception){
|
---|
| 256 | @revision_history_item = Revision_History_Item.new(:audits => [@audit_details, audit_details2],
|
---|
| 257 | :version_id => object_version_id)}
|
---|
| 258 | dv_date_time3 = DV_Date_Time.new('2009-07-14T12:00:00')
|
---|
| 259 | dv_date_time4 = DV_Date_Time.new('2009-07-15T00:00:00')
|
---|
| 260 | audit_details3 = Audit_Details.new(:system_id => 'MAGI',
|
---|
| 261 | :committer => @party_proxy,
|
---|
| 262 | :time_committed => dv_date_time3,
|
---|
| 263 | :change_type => dv_coded_text)
|
---|
| 264 | audit_details4 = Audit_Details.new(:system_id => 'MAGI',
|
---|
| 265 | :committer => @party_proxy,
|
---|
| 266 | :time_committed => dv_date_time4,
|
---|
| 267 | :change_type => dv_coded_text)
|
---|
| 268 | object_version_id = Object_Version_ID.new('NIGOUKI::NERV::2.2.2')
|
---|
| 269 | revision_history_item2 = Revision_History_Item.new(:audits => [audit_details3, audit_details4],
|
---|
| 270 | :version_id => object_version_id)
|
---|
| 271 | assert_nothing_raised(Exception){
|
---|
| 272 | @revision_history = Revision_History.new([@revision_history_item, revision_history_item2])}
|
---|
[119] | 273 | end
|
---|
[153] | 274 |
|
---|
[119] | 275 | def test_init
|
---|
[153] | 276 | assert_instance_of Party_Proxy, @party_proxy
|
---|
| 277 | assert_instance_of Party_Self, @party_self
|
---|
| 278 | assert_instance_of Party_Identified, @party_identified
|
---|
[156] | 279 | assert_instance_of Participation, @participation
|
---|
| 280 | assert_instance_of Audit_Details, @audit_details
|
---|
[157] | 281 | assert_instance_of Attestation, @attestation
|
---|
| 282 | assert_instance_of Revision_History_Item, @revision_history_item
|
---|
| 283 | assert_instance_of Revision_History, @revision_history
|
---|
[119] | 284 | end
|
---|
[153] | 285 |
|
---|
| 286 | def test_party_proxy
|
---|
| 287 | assert_equal 'unknown', @party_proxy.external_ref.namespace
|
---|
| 288 | end
|
---|
| 289 |
|
---|
| 290 | def test_party_self
|
---|
| 291 | assert_equal 'ORGANISATION', @party_self.external_ref.type
|
---|
| 292 | end
|
---|
| 293 |
|
---|
| 294 | def test_party_identified
|
---|
| 295 | assert_equal 'NERV', @party_identified.name
|
---|
| 296 | assert_equal '0.0.4', @party_identified.external_ref.id.value
|
---|
| 297 | identifiers = @party_identified.identifier
|
---|
| 298 | ids = [ ]
|
---|
| 299 | identifiers.each do |id|
|
---|
| 300 | ids << id.id
|
---|
| 301 | end
|
---|
| 302 | assert_equal %w[MELCHIOR CASPER BALTHAZAR], ids
|
---|
| 303 | end
|
---|
[155] | 304 |
|
---|
| 305 | def test_party_related
|
---|
| 306 | assert_equal 'GEHIRN', @party_related.name
|
---|
| 307 | end
|
---|
[156] | 308 |
|
---|
| 309 | def test_participation
|
---|
| 310 | assert_equal 'unknown', @participation.performer.external_ref.namespace
|
---|
| 311 | assert_equal 'commiter', @participation.function.value
|
---|
| 312 | assert_equal 'present', @participation.mode.value
|
---|
| 313 | assert_equal 2009, @participation.time.lower.year
|
---|
| 314 | end
|
---|
| 315 |
|
---|
| 316 | def test_audit_details
|
---|
| 317 | assert_equal 'MAGI', @audit_details.system_id
|
---|
| 318 | assert_equal 'unknown', @audit_details.committer.external_ref.namespace
|
---|
| 319 | assert_equal '2009-07-04T18:56:00', @audit_details.time_committed.as_string
|
---|
| 320 | assert_equal 'creation', @audit_details.change_type.value
|
---|
| 321 | assert_equal 'test environment', @audit_details.description.value
|
---|
| 322 | end
|
---|
[157] | 323 |
|
---|
| 324 | def test_attestation
|
---|
| 325 | assert_equal 'NERV', @attestation.system_id
|
---|
| 326 | assert_equal 'unknown', @attestation.committer.external_ref.namespace
|
---|
| 327 | assert_equal '249', @attestation.change_type.defining_code.code_string
|
---|
| 328 | assert_equal 7, @attestation.time_committed.month
|
---|
| 329 | assert_equal 'authorisation', @attestation.reason.value
|
---|
| 330 | assert_equal 'authorisation', @attestation.description.value
|
---|
| 331 | assert_equal 'hashedstring', @attestation.proof
|
---|
| 332 | assert_equal 'ehr://test/', @attestation.items.to_a[0].value
|
---|
| 333 | end
|
---|
| 334 |
|
---|
| 335 | def test_revision_history_item
|
---|
| 336 | assert_equal 'SHOGOUKI::NERV::1.1.1', @revision_history_item.version_id.value
|
---|
| 337 | assert_equal 'MAGI', @revision_history_item.audits[0].system_id
|
---|
| 338 | end
|
---|
| 339 |
|
---|
| 340 | def test_revision_history
|
---|
| 341 | assert_equal 'NIGOUKI::NERV::2.2.2', @revision_history.most_recent_version
|
---|
| 342 | assert_equal '2009-07-14T12:00:00', @revision_history.most_recent_version_time_committed
|
---|
| 343 | end
|
---|
[119] | 344 | end
|
---|
| 345 |
|
---|
| 346 | class RM_Common_Directory_Test < Test::Unit::TestCase
|
---|
| 347 | def setup
|
---|
[162] | 348 | archetype_node_id = 'at0001'
|
---|
| 349 | name = DV_Text.new('folder_test')
|
---|
| 350 | object_id = Object_ID.new('1.1.1')
|
---|
| 351 | object_ref = Object_Ref.new('local', 'PARTY', object_id)
|
---|
| 352 | assert_nothing_raised(Exception){
|
---|
| 353 | @folder = Folder.new(:archetype_node_id => archetype_node_id,
|
---|
| 354 | :name => name,
|
---|
| 355 | :items => [object_ref])}
|
---|
| 356 |
|
---|
| 357 |
|
---|
[119] | 358 | end
|
---|
| 359 |
|
---|
| 360 | def test_init
|
---|
| 361 | assert_instance_of OpenEHR::RM::Common::Directory::Folder, @folder
|
---|
| 362 | end
|
---|
| 363 |
|
---|
| 364 | def test_folder
|
---|
[162] | 365 | assert_equal 'at0001', @folder.archetype_node_id
|
---|
| 366 | assert_equal 'local', @folder.items[0].namespace
|
---|
[119] | 367 | end
|
---|
| 368 | end
|
---|
| 369 |
|
---|
| 370 | class RM_Common_Change_Control_Test < Test::Unit::TestCase
|
---|
| 371 | def setup
|
---|
[158] | 372 | object_version_id1 = Object_Version_ID.new('ABC::DEF::2.2.3')
|
---|
| 373 | object_version_id2 = Object_Version_ID.new('GHI::JKL::4.5.6')
|
---|
| 374 | object_id = Object_ID.new('ehr://uniqueid1020')
|
---|
| 375 | dv_date_time = DV_Date_Time.new('2009-07-06T21:10:12')
|
---|
| 376 | party_ref = Party_Ref.new('unknown', 'ORGANISATION', object_id)
|
---|
| 377 | party_proxy = Party_Proxy.new(:external_ref => party_ref)
|
---|
| 378 | terminology_id = Terminology_ID.new('openehr(1.0.2)')
|
---|
| 379 | code_phrase = Code_Phrase.new('249', terminology_id)
|
---|
| 380 | dv_coded_text = DV_Coded_Text.new('creation', code_phrase)
|
---|
| 381 | audit_details = Audit_Details.new(:system_id => 'MAGI',
|
---|
| 382 | :committer => party_proxy,
|
---|
| 383 | :time_committed => dv_date_time,
|
---|
| 384 | :change_type => dv_coded_text)
|
---|
| 385 | code_phrase = Code_Phrase.new('532', terminology_id)
|
---|
| 386 | dv_coded_text = DV_Coded_Text.new('complete', code_phrase)
|
---|
| 387 | object_id = Object_ID.new('ehr://test_location')
|
---|
| 388 | object_ref = Object_Ref.new('local', 'PARTY', object_id)
|
---|
| 389 | hier_object_id = Hier_Object_ID.new('ABC')
|
---|
| 390 | assert_nothing_raised(Exception){
|
---|
| 391 | @version = Version.new(:uid => object_version_id1,
|
---|
| 392 | :preceding_version_uid => object_version_id2,
|
---|
| 393 | :lifecycle_state => dv_coded_text,
|
---|
| 394 | :commit_audit => audit_details,
|
---|
| 395 | :contribution => object_ref,
|
---|
| 396 | :signature => 'test_version',
|
---|
| 397 | :data => 'data')}
|
---|
| 398 | object_version_id3 = Object_Version_ID.new('MNO::PQR::7.8.9')
|
---|
| 399 | object_version_id4 = Object_Version_ID.new('STU::VWX::1.2.3')
|
---|
| 400 | code_phrase = Code_Phrase.new('240', terminology_id)
|
---|
| 401 | dv_coded_text2 = DV_Coded_Text.new('signed', code_phrase)
|
---|
| 402 | attestation = Attestation.new(:system_id => 'NERV',
|
---|
| 403 | :committer => party_proxy,
|
---|
| 404 | :time_committed => dv_date_time,
|
---|
| 405 | :change_type => dv_coded_text,
|
---|
| 406 | :reason => DV_Text.new('signed'))
|
---|
[160] | 407 | dv_date_time = DV_Date_Time.new('2009-07-07T21:10:12')
|
---|
| 408 | audit_details = Audit_Details.new(:system_id => 'MAGI',
|
---|
| 409 | :committer => party_proxy,
|
---|
| 410 | :time_committed => dv_date_time,
|
---|
| 411 | :change_type => dv_coded_text)
|
---|
[158] | 412 | assert_nothing_raised(Exception){
|
---|
| 413 | @original_version = Original_Version.new(:uid => object_version_id3,
|
---|
| 414 | :preceding_version_uid => object_version_id4,
|
---|
| 415 | :other_input_version_uids => Set[object_version_id1, object_version_id2],
|
---|
| 416 | :commit_audit => audit_details,
|
---|
| 417 | :contribution => object_ref,
|
---|
| 418 | :attestations => [attestation],
|
---|
| 419 | :data => 'data',
|
---|
| 420 | :lifecycle_state => dv_coded_text)}
|
---|
[160] | 421 | dv_date_time = DV_Date_Time.new('2009-07-08T21:10:12')
|
---|
[159] | 422 | audit_details = Audit_Details.new(:system_id => 'CASPER',
|
---|
| 423 | :committer => party_proxy,
|
---|
| 424 | :time_committed => dv_date_time,
|
---|
| 425 | :change_type => dv_coded_text,
|
---|
| 426 | :description => 'for contribution')
|
---|
| 427 | object_ref = Object_Ref.new('unknown', 'PARTY', object_id)
|
---|
| 428 | assert_nothing_raised(Exception){
|
---|
| 429 | @imported_version = Imported_Version.new(:item => @original_version,
|
---|
| 430 | :commit_audit => audit_details,
|
---|
| 431 | :contribution => object_ref,
|
---|
| 432 | :signature => 'import test')}
|
---|
| 433 | assert_nothing_raised(Exception){
|
---|
| 434 | @contribution = Contribution.new(:uid => hier_object_id,
|
---|
| 435 | :versions => Set[object_ref],
|
---|
| 436 | :audit => audit_details)}
|
---|
[160] | 437 | dv_date_time = DV_Date_Time.new('2009-07-08T18:10:12')
|
---|
| 438 | audit_details = Audit_Details.new(:system_id => 'MAGI',
|
---|
| 439 | :committer => party_proxy,
|
---|
| 440 | :time_committed => dv_date_time,
|
---|
| 441 | :change_type => dv_coded_text)
|
---|
| 442 | @trunk_version = Version.new(:uid => object_version_id4,
|
---|
| 443 | :lifecycle_state => dv_coded_text,
|
---|
| 444 | :commit_audit => audit_details,
|
---|
| 445 | :contribution => object_ref,
|
---|
| 446 | :change_type => dv_coded_text)
|
---|
| 447 | assert_nothing_raised(Exception){
|
---|
| 448 | @versioned_object = Versioned_Object.new(:uid => hier_object_id,
|
---|
| 449 | :owner_id => object_ref,
|
---|
| 450 | :time_created => dv_date_time,
|
---|
| 451 | :all_versions => [@version,@original_version,@imported_version,@trunk_version])}
|
---|
[119] | 452 | end
|
---|
[158] | 453 |
|
---|
[119] | 454 | def test_init
|
---|
[158] | 455 | assert_instance_of OpenEHR::RM::Common::Change_Control::Version, @version
|
---|
| 456 | assert_instance_of Original_Version, @original_version
|
---|
[159] | 457 | assert_instance_of Imported_Version, @imported_version
|
---|
| 458 | assert_instance_of OpenEHR::RM::Common::Change_Control::Contribution, @contribution
|
---|
[160] | 459 | assert_instance_of Versioned_Object, @versioned_object
|
---|
[119] | 460 | end
|
---|
[158] | 461 |
|
---|
[119] | 462 | def test_version
|
---|
[158] | 463 | assert_equal 'ABC::DEF::2.2.3', @version.uid.value
|
---|
| 464 | assert !@version.uid.version_tree_id.is_first?
|
---|
| 465 | assert_equal 'GHI::JKL::4.5.6', @version.preceding_version_uid.value
|
---|
| 466 | assert_equal '532', @version.lifecycle_state.defining_code.code_string
|
---|
| 467 | assert_equal 'MAGI', @version.commit_audit.system_id
|
---|
| 468 | assert_equal 'local', @version.contribution.namespace
|
---|
| 469 | assert_equal 'test_version', @version.signature
|
---|
| 470 | assert_equal 'ABC', @version.owner_id.value
|
---|
| 471 | assert_equal 'data', @version.data
|
---|
| 472 | assert @version.is_branch?
|
---|
[119] | 473 | end
|
---|
[158] | 474 |
|
---|
| 475 | def test_original_version
|
---|
| 476 | assert_equal 'MNO::PQR::7.8.9', @original_version.uid.value
|
---|
| 477 | assert_equal 'NERV', @original_version.attestations[0].system_id
|
---|
| 478 | end
|
---|
| 479 |
|
---|
[159] | 480 | def test_imported_version
|
---|
| 481 | assert_equal 'import test', @imported_version.signature
|
---|
| 482 | assert_equal 'MNO::PQR::7.8.9', @imported_version.item.uid.value
|
---|
| 483 | assert_equal 'CASPER', @imported_version.commit_audit.system_id
|
---|
| 484 | assert_equal 'unknown', @imported_version.contribution.namespace
|
---|
| 485 | assert_equal 'STU::VWX::1.2.3', @imported_version.preceding_version_uid.value
|
---|
| 486 | assert_equal '532', @imported_version.lifecycle_state.defining_code.code_string
|
---|
| 487 | end
|
---|
| 488 |
|
---|
[119] | 489 | def test_contribution
|
---|
[159] | 490 | assert_equal 'ABC', @contribution.uid.value
|
---|
| 491 | assert_equal 'PARTY', @contribution.versions.to_a[0].type
|
---|
| 492 | assert_equal 'for contribution', @contribution.audit.description
|
---|
[119] | 493 | end
|
---|
[160] | 494 |
|
---|
| 495 | def test_versioned_object
|
---|
| 496 | assert_equal 'ABC', @versioned_object.uid.value
|
---|
| 497 | assert_equal 'unknown', @versioned_object.owner_id.namespace
|
---|
| 498 | assert_equal 18, @versioned_object.time_created.hour
|
---|
| 499 | assert_equal [@version, @original_version, @imported_version, @trunk_version],
|
---|
| 500 | @versioned_object.all_versions
|
---|
| 501 | assert_equal 4, @versioned_object.version_count
|
---|
| 502 | assert_equal [@version.uid, @original_version.uid, @imported_version.uid, @trunk_version.uid],
|
---|
| 503 | @versioned_object.all_version_ids
|
---|
| 504 | assert @versioned_object.has_version_id?(@version.uid)
|
---|
| 505 | assert !@versioned_object.is_original_version?(@version.uid)
|
---|
| 506 | assert @versioned_object.is_original_version?(@original_version.uid)
|
---|
| 507 | assert @versioned_object.has_version_at_time?(DV_Date_Time.new('2009-07-06T21:10:12'))
|
---|
| 508 | assert_equal @version, @versioned_object.version_with_id(@version.uid)
|
---|
| 509 | assert_equal @version, @versioned_object.version_at_time(@version.commit_audit.time_committed)
|
---|
| 510 | assert_equal @imported_version, @versioned_object.latest_version
|
---|
| 511 | assert_equal @trunk_version, @versioned_object.latest_trunk_version
|
---|
| 512 | assert_equal 'complete', @versioned_object.trunk_lifecycle_state.value
|
---|
| 513 | assert_equal '2009-07-08T18:10:12', @versioned_object.revision_history.most_recent_version_time_committed
|
---|
| 514 | assert_nothing_raised(Exception){
|
---|
| 515 | @versioned_object.commit_original_version(:contribution => @original_version.contribution,
|
---|
| 516 | :uid => @original_version.uid,
|
---|
| 517 | :preceding_version_uid => @original_version.preceding_version_uid,
|
---|
| 518 | :commit_audit => @original_version.commit_audit,
|
---|
| 519 | :attestations => @original_version.attestations,
|
---|
| 520 | :lifecycle_state => @original_version.lifecycle_state,
|
---|
| 521 | :data => 'commit original',
|
---|
| 522 | :signature => 'testtett')}
|
---|
| 523 | assert_equal 5, @versioned_object.version_count
|
---|
[161] | 524 | assert_nothing_raised(Exception){
|
---|
| 525 | @versioned_object.commit_original_merged_version(:contribution => @original_version.contribution,
|
---|
| 526 | :uid => @original_version.uid,
|
---|
| 527 | :preceding_version_uid => @original_version.preceding_version_uid,
|
---|
| 528 | :commit_audit => @original_version.commit_audit,
|
---|
| 529 | :lifecycle_state => @original_version.lifecycle_state,
|
---|
| 530 | :attestations => @original_version.attestations,
|
---|
| 531 | :data => @original_version.data,
|
---|
| 532 | :other_input_version_uids => @original_version.other_input_version_uids,
|
---|
| 533 | :signature => @original_version.signature)}
|
---|
| 534 | assert_equal 6, @versioned_object.version_count
|
---|
| 535 | assert_nothing_raised(Exception){
|
---|
| 536 | @versioned_object.commit_imported_version(:contribution => @imported_version.contribution,
|
---|
| 537 | :commit_audit => @imported_version.commit_audit,
|
---|
| 538 | :item => @imported_version.item)}
|
---|
| 539 | assert_equal 7, @versioned_object.version_count
|
---|
| 540 | dv_date_time = DV_Date_Time.new('2009-07-07T22:11:31')
|
---|
| 541 | attestation = Attestation.new(:system_id => 'NERV2',
|
---|
| 542 | :committer => @version.contribution,
|
---|
| 543 | :time_committed => dv_date_time,
|
---|
| 544 | :change_type => @original_version.commit_audit.change_type,
|
---|
| 545 | :reason => DV_Text.new('signed'))
|
---|
| 546 | assert_nothing_raised(Exception){
|
---|
| 547 | @versioned_object.commit_attestation(:attestation => attestation,
|
---|
| 548 | :uid => @original_version.uid,
|
---|
| 549 | :signature => 'new signature')}
|
---|
[160] | 550 | end
|
---|
[119] | 551 | end
|
---|