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