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