[66] | 1 | require 'test/unit'
|
---|
| 2 | require 'set'
|
---|
| 3 | require 'rm'
|
---|
| 4 |
|
---|
| 5 | class ReferenceModelTest < Test::Unit::TestCase
|
---|
| 6 | def setup
|
---|
| 7 | @authored_resource = OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE.new(:original_language => "ja",
|
---|
| 8 | :translations => "en",
|
---|
| 9 | :description => "test")
|
---|
| 10 | @translation_details = OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS.new(nil,nil,nil,nil,nil)
|
---|
| 11 | # @openehr_definitions = OpenEHR::RM::Support::Definition::OpenEHR_Definitions.new
|
---|
| 12 | @dv_boolean = OpenEHR::RM::Data_Types::Basic::DV_Boolean.new("TRUE")
|
---|
| 13 | @dv_state = OpenEHR::RM::Data_Types::Basic::DV_State.new("code1",true)
|
---|
| 14 | @dv_identifier = OpenEHR::RM::Data_Types::Basic::DV_Identifier.new("Ruby Hospital","0123456-0", "Information office", "personal id")
|
---|
| 15 | @dv_uri = OpenEHR::RM::Data_Types::URI::DV_URI.new("http://www.openehr.jp/changeset/test?cmd=93#file0")
|
---|
| 16 | @dv_ehr_uri = OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://1234567/87284370-2D4B-4e3d-A3F3-F303D2F4F34B@2005-08-02T04:30:00")
|
---|
| 17 | @dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new("valid value")
|
---|
| 18 | @dv_coded_text = OpenEHR::RM::Data_Types::Text::DV_Coded_Text.new("valid value", "AT1000")
|
---|
| 19 | @dv_paragraph = OpenEHR::RM::Data_Types::Text::DV_Paragraph.new(Set.new(["test1", "test2"]))
|
---|
[90] | 20 | @term_mapping = OpenEHR::RM::Data_Types::Text::Term_Mapping.new('=',@dv_coded_text,"TEST")
|
---|
| 21 | # @code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase.new
|
---|
[89] | 22 | # @agent = OpenEHR::RM::Demogrphic::Agent.new
|
---|
| 23 | # @organisation = OpenEHR::RM::Demogrphic::Organisation.new
|
---|
| 24 | # @person = OpenEHR::RM::Demogrphic::Person.new
|
---|
| 25 | # @group = OpenEHR::RM::Demogrphic::Group.new
|
---|
[66] | 26 | end
|
---|
| 27 |
|
---|
| 28 | def test_init
|
---|
| 29 | assert_instance_of OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE, @authored_resource
|
---|
| 30 | assert_instance_of OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS, @translation_details
|
---|
| 31 | assert_instance_of OpenEHR::RM::Data_Types::Basic::DV_Boolean, @dv_boolean
|
---|
| 32 | assert_instance_of OpenEHR::RM::Data_Types::Basic::DV_State, @dv_state
|
---|
| 33 | assert_instance_of OpenEHR::RM::Data_Types::Basic::DV_Identifier, @dv_identifier
|
---|
| 34 | assert_instance_of OpenEHR::RM::Data_Types::URI::DV_URI, @dv_uri
|
---|
| 35 | assert_instance_of OpenEHR::RM::Data_Types::URI::DV_EHR_URI, @dv_ehr_uri
|
---|
| 36 | assert_instance_of OpenEHR::RM::Data_Types::Text::DV_Text, @dv_text
|
---|
| 37 | assert_instance_of OpenEHR::RM::Data_Types::Text::DV_Coded_Text, @dv_coded_text
|
---|
[90] | 38 | assert_instance_of OpenEHR::RM::Data_Types::Text::Term_Mapping, @term_mapping
|
---|
[89] | 39 | # assert_instance_of OpenEHR::RM::Demogrphic::Agent, @agent
|
---|
| 40 | # assert_instance_of OpenEHR::RM::Demogrphic::Organisation, @organisation
|
---|
| 41 | # assert_instance_of OpenEHR::RM::Demogrphic::Person, @person
|
---|
| 42 | # assert_instance_of OpenEHR::RM::Demogrphic::Group, @group
|
---|
[66] | 43 | end
|
---|
| 44 |
|
---|
| 45 | def test_constant
|
---|
| 46 | assert_equal("\r", OpenEHR::RM::Support::Definition::OpenEHR_Definitions::CR)
|
---|
| 47 | assert_equal("\n", OpenEHR::RM::Support::Definition::OpenEHR_Definitions::LF)
|
---|
| 48 | assert_equal("\r", OpenEHR::RM::Data_Types::Basic::Data_Value::CR)
|
---|
| 49 | assert_equal("\n", OpenEHR::RM::Data_Types::Basic::Data_Value::LF)
|
---|
| 50 | end
|
---|
| 51 |
|
---|
| 52 | def test_dv_boolean
|
---|
| 53 | assert @dv_boolean.value?
|
---|
| 54 | @dv_boolean.value = false
|
---|
| 55 | assert !@dv_boolean.value?
|
---|
| 56 | # Constraints Value_exists
|
---|
| 57 | assert_raise(ArgumentError){@dv_boolean.value=nil}
|
---|
| 58 | assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Basic::DV_Boolean.new(nil)}
|
---|
| 59 | end
|
---|
| 60 |
|
---|
| 61 | def test_dv_state
|
---|
| 62 | assert_equal("code1", @dv_state.value)
|
---|
[89] | 63 | assert_nothing_raised(Exception){@dv_state.value = "code2"}
|
---|
[66] | 64 | assert_equal("code2", @dv_state.value)
|
---|
| 65 | assert @dv_state.is_terminal?
|
---|
[89] | 66 | assert_nothing_raised(Exception){@dv_state.is_terminal = false}
|
---|
[66] | 67 | assert !@dv_state.is_terminal?
|
---|
| 68 | assert_raise(ArgumentError) {OpenEHR::RM::Data_Types::Basic::DV_State.new(nil,nil)}
|
---|
[89] | 69 | assert_raise(ArgumentError) {@dv_state.value=nil}
|
---|
| 70 | assert_raise(ArgumentError) {@dv_state.is_terminal=nil}
|
---|
[66] | 71 | end
|
---|
| 72 |
|
---|
| 73 | def test_dv_identifier
|
---|
| 74 | assert_equal("Ruby Hospital", @dv_identifier.assigner)
|
---|
| 75 | assert_equal("0123456-0", @dv_identifier.id)
|
---|
| 76 | assert_equal("Information office", @dv_identifier.issuer)
|
---|
| 77 | assert_equal("personal id", @dv_identifier.type)
|
---|
| 78 | @dv_identifier.assigner = "Test Hospital"
|
---|
| 79 | assert_equal("Test Hospital", @dv_identifier.assigner)
|
---|
| 80 | @dv_identifier.id = "TEST-0987"
|
---|
| 81 | assert_equal("TEST-0987", @dv_identifier.id)
|
---|
| 82 | @dv_identifier.issuer = "Security office"
|
---|
| 83 | assert_equal("Security office", @dv_identifier.issuer)
|
---|
| 84 | @dv_identifier.type = "test id"
|
---|
| 85 | assert_equal("test id", @dv_identifier.type)
|
---|
| 86 | assert_raise(ArgumentError) {OpenEHR::RM::Data_Types::Basic::DV_Identifier.new(nil, nil, nil, nil)}
|
---|
| 87 | end
|
---|
| 88 |
|
---|
| 89 | def test_dv_uri
|
---|
| 90 | assert_equal("file0", @dv_uri.fragment_id)
|
---|
| 91 | assert_equal("/changeset/test", @dv_uri.path)
|
---|
| 92 | assert_equal("cmd=93", @dv_uri.query)
|
---|
| 93 | assert_equal("http", @dv_uri.scheme)
|
---|
| 94 | assert_equal("http://www.openehr.jp/changeset/test?cmd=93#file0", @dv_uri.value)
|
---|
| 95 | @dv_uri.value="svn://www.openehr.jp/openehr-jp/"
|
---|
| 96 | assert_equal("svn://www.openehr.jp/openehr-jp/", @dv_uri.value)
|
---|
| 97 | assert_equal("/openehr-jp/", @dv_uri.path)
|
---|
| 98 | end
|
---|
| 99 |
|
---|
| 100 | def test_dv_ehr_uri
|
---|
| 101 | assert_equal("ehr", @dv_ehr_uri.scheme)
|
---|
| 102 | assert_raise(ArgumentError){
|
---|
| 103 | @dv_ehr_uri.value="svn://www.openehr.jp/openehr-jp/" }
|
---|
| 104 | end
|
---|
| 105 |
|
---|
| 106 | def test_dv_text
|
---|
| 107 | assert_equal("valid value", @dv_text.value)
|
---|
| 108 | assert_raise(ArgumentError){@dv_text.value = "not valid value\n"}
|
---|
| 109 | assert_raise(ArgumentError){@dv_text.value = nil }
|
---|
| 110 | assert_raise(ArgumentError){@dv_text.value = "" }
|
---|
| 111 | assert_raise(ArgumentError){@dv_text.formatting = "" }
|
---|
| 112 | assert_raise(ArgumentError){@dv_text.encoding = ""}
|
---|
| 113 | assert_raise(ArgumentError){@dv_text.language = ""}
|
---|
| 114 | assert_raise(ArgumentError){@dv_text.mappings = Set.new}
|
---|
| 115 | assert_raise(ArgumentError){@dv_text.mappings = ""}
|
---|
| 116 | assert_raise(ArgumentError){@dv_text.language = ""}
|
---|
| 117 | end
|
---|
| 118 |
|
---|
| 119 | def test_dv_coded_text
|
---|
| 120 | assert_equal("valid value", @dv_coded_text.value)
|
---|
| 121 | assert_equal("AT1000", @dv_coded_text.defining_code)
|
---|
| 122 | assert_raise(ArgumentError){@dv_coded_text.defining_code=nil}
|
---|
| 123 | end
|
---|
| 124 |
|
---|
| 125 | def test_dv_paragraph
|
---|
| 126 | assert_equal((Set.new ["test1", "test2"]), @dv_paragraph.items)
|
---|
| 127 | assert_raise(ArgumentError){@dv_paragraph.items=Set.new}
|
---|
| 128 | end
|
---|
| 129 |
|
---|
[90] | 130 | def test_term_mapping
|
---|
| 131 | assert_equal '=', @term_mapping.match
|
---|
| 132 | assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('>')
|
---|
| 133 | assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('=')
|
---|
| 134 | assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('<')
|
---|
| 135 | assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('?')
|
---|
| 136 | assert !OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('!')
|
---|
| 137 | assert_equal @dv_coded_text, @term_mapping.purpose
|
---|
| 138 | assert_equal "TEST", @term_mapping.target
|
---|
| 139 | assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new}
|
---|
| 140 | assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new('!',@dv_coded_text, "invalid case")}
|
---|
| 141 | assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new('=',nil , "invalid case")}
|
---|
| 142 | assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new('=',@dv_coded_text, nil)}
|
---|
[66] | 143 | end
|
---|
| 144 | end
|
---|
| 145 |
|
---|
[92] | 146 | class RM_Support_Identification_Test < Test::Unit::TestCase
|
---|
[66] | 147 | def setup
|
---|
[90] | 148 | assert_nothing_raised(Exception){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.3")}
|
---|
[94] | 149 | assert_nothing_raised(Exception){@object_ref = OpenEHR::RM::Support::Identification::Object_Ref.new('local', 'ANY', @object_id)}
|
---|
[92] | 150 | assert_nothing_raised(Exception){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
| 151 | assert_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("0.0.7", 'terminology','0.0.3')}
|
---|
| 152 | assert_nothing_raised(Exception){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", "openehr")}
|
---|
[93] | 153 | assert_nothing_raised(Exception){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.3')}
|
---|
[95] | 154 | assert_nothing_raised(Exception){@hier_object_id = OpenEHR::RM::Support::Identification::Hier_Object_ID.new('0.0.4')}
|
---|
[97] | 155 | assert_nothing_raised(Exception){@locatable_ref = OpenEHR::RM::Support::Identification::Locatable_Ref.new('unknown', 'PERSON', @uid_based_id, 'data/event[at0001, standing]')}
|
---|
[98] | 156 | assert_nothing_raised(Exception){@party_ref = OpenEHR::RM::Support::Identification::Party_Ref.new('unknown', 'ORGANISATION', @object_id)}
|
---|
[99] | 157 | assert_nothing_raised(Exception){@access_group_ref = OpenEHR::RM::Support::Identification::Access_Group_Ref.new('unknown', 'ACCESS_GROUP', @object_id)}
|
---|
[66] | 158 | end
|
---|
| 159 |
|
---|
| 160 | def test_init
|
---|
[90] | 161 | assert_instance_of OpenEHR::RM::Support::Identification::Object_ID, @object_id
|
---|
[94] | 162 | assert_instance_of OpenEHR::RM::Support::Identification::Object_Ref, @object_ref
|
---|
[91] | 163 | assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, @archetype_id
|
---|
[90] | 164 | assert_instance_of OpenEHR::RM::Support::Identification::Terminology_ID, @terminology_id
|
---|
[92] | 165 | assert_instance_of OpenEHR::RM::Support::Identification::Object_ID, @object_id
|
---|
[96] | 166 | assert_instance_of OpenEHR::RM::Support::Identification::Generic_ID, @generic_id
|
---|
[93] | 167 | assert_instance_of OpenEHR::RM::Support::Identification::UID_Based_ID, @uid_based_id
|
---|
[95] | 168 | assert_instance_of OpenEHR::RM::Support::Identification::Hier_Object_ID, @hier_object_id
|
---|
[96] | 169 | assert_instance_of OpenEHR::RM::Support::Identification::Locatable_Ref, @locatable_ref
|
---|
[98] | 170 | assert_instance_of OpenEHR::RM::Support::Identification::Party_Ref, @party_ref
|
---|
[99] | 171 | assert_instance_of OpenEHR::RM::Support::Identification::Access_Group_Ref, @access_group_ref
|
---|
[90] | 172 | end
|
---|
[66] | 173 |
|
---|
[91] | 174 | def test_object_id
|
---|
| 175 | assert_equal "0.0.3", @object_id.value
|
---|
| 176 | assert_nothing_raised(Exception){@object_id.value = "0.0.4"}
|
---|
| 177 | assert_equal "0.0.4", @object_id.value
|
---|
| 178 | assert_raise(ArgumentError){@object_id.value=nil}
|
---|
| 179 | assert_raise(ArgumentError){@object_id.value=""}
|
---|
| 180 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new}
|
---|
| 181 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new(nil)}
|
---|
| 182 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new("")}
|
---|
[96] | 183 | assert_equal @object_id, OpenEHR::RM::Support::Identification::Object_ID.new("0.0.4")
|
---|
[91] | 184 | end
|
---|
| 185 |
|
---|
[94] | 186 | def test_object_refs
|
---|
| 187 | assert_equal 'local', @object_ref.namespace
|
---|
| 188 | assert_equal 'ANY', @object_ref.type
|
---|
| 189 | assert_equal @object_id, @object_ref.id
|
---|
| 190 |
|
---|
| 191 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new}
|
---|
| 192 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new(nil, 'ANY', @object_id)}
|
---|
| 193 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('', 'ANY', @object_id)}
|
---|
| 194 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', nil, @object_id)}
|
---|
| 195 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', '', @object_id)}
|
---|
| 196 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', 'ANY', nil)}
|
---|
| 197 |
|
---|
| 198 | assert_nothing_raised(Exception){@object_ref.namespace = 'terminology'}
|
---|
| 199 | assert_equal 'terminology', @object_ref.namespace
|
---|
| 200 | assert_raise(ArgumentError){@object_ref.namespace = nil}
|
---|
| 201 | assert_raise(ArgumentError){@object_ref.namespace = ''}
|
---|
| 202 | assert_raise(ArgumentError){@object_ref.namespace = '?&&'}
|
---|
| 203 | assert_raise(ArgumentError){@object_ref.namespace = '843'}
|
---|
| 204 |
|
---|
| 205 | assert_nothing_raised(Exception){@object_ref.type = 'GUIDELINE'}
|
---|
| 206 | assert_equal 'GUIDELINE', @object_ref.type
|
---|
| 207 | assert_raise(ArgumentError){@object_ref.type = nil}
|
---|
| 208 | assert_raise(ArgumentError){@object_ref.type = ''}
|
---|
| 209 |
|
---|
| 210 | assert_nothing_raised(Exception){@object_ref.id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.5")}
|
---|
| 211 | assert_equal OpenEHR::RM::Support::Identification::Object_ID.new("0.0.5"), @object_ref.id
|
---|
| 212 | assert_raise(ArgumentError){@object_ref.id = nil}
|
---|
| 213 | end
|
---|
| 214 |
|
---|
[91] | 215 | def test_archetype_id
|
---|
| 216 | assert_equal "0.0.5", @archetype_id.value
|
---|
| 217 | assert_nothing_raised(Exception){@archetype_id.value = "0.0.6"}
|
---|
| 218 | assert_equal "0.0.6", @archetype_id.value
|
---|
| 219 | assert_raise(ArgumentError){@archetype_id.value=nil}
|
---|
| 220 | assert_raise(ArgumentError){@archetype_id.value=""}
|
---|
| 221 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new}
|
---|
[92] | 222 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new(nil, "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
| 223 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
| 224 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", nil, "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
| 225 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
| 226 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", nil, "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
| 227 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "", "ehr_rm", "openehr","cholesterol","0.0.3")}
|
---|
| 228 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", nil, "openehr","cholesterol","0.0.3")}
|
---|
| 229 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "", "openehr","cholesterol","0.0.3")}
|
---|
| 230 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", nil,"cholesterol","0.0.3")}
|
---|
| 231 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "","cholesterol","0.0.3")}
|
---|
| 232 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr",nil ,"0.0.3")}
|
---|
| 233 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","","0.0.3")}
|
---|
| 234 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol", nil)}
|
---|
| 235 | assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","")}
|
---|
[91] | 236 |
|
---|
| 237 | assert_equal "biochemistry result_cholesterol", @archetype_id.domain_concept
|
---|
[92] | 238 | assert_nothing_raised(Exception){(@archetype_id.domain_concept = "biochemistry result_triglyceride")}
|
---|
| 239 | assert_equal "biochemistry result_triglyceride", @archetype_id.domain_concept
|
---|
| 240 | assert_raise(ArgumentError){@archetype_id.domain_concept = nil}
|
---|
| 241 | assert_raise(ArgumentError){@archetype_id.domain_concept = ""}
|
---|
[91] | 242 |
|
---|
| 243 | assert_equal "entry", @archetype_id.rm_name
|
---|
[92] | 244 | assert_nothing_raised(Exception){@archetype_id.rm_name = "section"}
|
---|
| 245 | assert_equal "section", @archetype_id.rm_name
|
---|
| 246 | assert_raise(ArgumentError){@archetype_id.rm_name = nil}
|
---|
| 247 | assert_raise(ArgumentError){@archetype_id.rm_name = ""}
|
---|
[91] | 248 |
|
---|
| 249 | assert_equal "ehr_rm", @archetype_id.rm_entity
|
---|
[92] | 250 | assert_nothing_raised(Exception){@archetype_id.rm_entity = "13606"}
|
---|
| 251 | assert_equal "13606", @archetype_id.rm_entity
|
---|
| 252 | assert_raise(ArgumentError){@archetype_id.rm_entity = nil}
|
---|
| 253 | assert_raise(ArgumentError){@archetype_id.rm_entity = ""}
|
---|
[91] | 254 |
|
---|
| 255 | assert_equal "openehr", @archetype_id.rm_originator
|
---|
[92] | 256 | assert_nothing_raised(Exception){@archetype_id.rm_originator = "cen"}
|
---|
| 257 | assert_equal "cen", @archetype_id.rm_originator
|
---|
| 258 | assert_raise(ArgumentError){@archetype_id.rm_originator = nil}
|
---|
| 259 | assert_raise(ArgumentError){@archetype_id.rm_originator = ""}
|
---|
[91] | 260 |
|
---|
| 261 | assert_equal "cholesterol", @archetype_id.specialisation
|
---|
[92] | 262 | assert_nothing_raised(Exception){@archetype_id.specialisation = "triglyceride"}
|
---|
| 263 | assert_equal "triglyceride", @archetype_id.specialisation
|
---|
| 264 | assert_raise(ArgumentError){@archetype_id.specialisation = nil}
|
---|
| 265 | assert_raise(ArgumentError){@archetype_id.specialisation = ""}
|
---|
[91] | 266 |
|
---|
| 267 | assert_equal "0.0.3", @archetype_id.version_id
|
---|
[92] | 268 | assert_nothing_raised(Exception){@archetype_id.version_id = "0.0.7"}
|
---|
| 269 | assert_equal "0.0.7", @archetype_id.version_id
|
---|
| 270 | assert_raise(ArgumentError){@archetype_id.version_id = nil}
|
---|
| 271 | assert_raise(ArgumentError){@archetype_id.version_id = ""}
|
---|
| 272 | end
|
---|
[91] | 273 |
|
---|
[92] | 274 | def test_terminology_id
|
---|
| 275 | assert_equal "0.0.7", @terminology_id.value
|
---|
| 276 | assert_nothing_raised(Exception){@terminology_id.value = "0.0.8"}
|
---|
| 277 | assert_equal "0.0.8", @terminology_id.value
|
---|
| 278 | assert_raise(ArgumentError){@terminology_id.value = nil}
|
---|
| 279 | assert_raise(ArgumentError){@terminology_id.value = ""}
|
---|
| 280 |
|
---|
| 281 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new}
|
---|
| 282 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new(nil, 'terminology','0.0.3')}
|
---|
| 283 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("", 'terminology','0.0.3')}
|
---|
| 284 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("", 'terminology','0.0.3')}
|
---|
| 285 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("0.0.7", nil,'0.0.3')}
|
---|
| 286 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("0.0.7", '','0.0.3')}
|
---|
| 287 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("0.0.7", "terminology", nil)}
|
---|
| 288 | assert_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("0.0.7", "terminology",'')}
|
---|
| 289 |
|
---|
| 290 | assert_equal "terminology", @terminology_id.name
|
---|
| 291 | assert_nothing_raised(Exception){@terminology_id.name = "snomed"}
|
---|
| 292 | assert_equal "snomed", @terminology_id.name
|
---|
| 293 | assert_raise(ArgumentError){@terminology_id.name = nil}
|
---|
| 294 | assert_raise(ArgumentError){@terminology_id.name = ""}
|
---|
| 295 |
|
---|
| 296 | assert_equal "", @terminology_id.version_id
|
---|
| 297 | assert_nothing_raised(Exception){@terminology_id.version_id = "0.0.8"}
|
---|
| 298 | assert_equal "0.0.8", @terminology_id.version_id
|
---|
| 299 | assert_raise(ArgumentError){@terminology_id.version_id = nil}
|
---|
| 300 | assert_nothing_raised(Exception){@terminology_id.version_id = ''}
|
---|
[91] | 301 | end
|
---|
[92] | 302 |
|
---|
| 303 | def test_generic_id
|
---|
| 304 | assert_equal "0.0.3", @generic_id.value
|
---|
| 305 | assert_equal "openehr", @generic_id.scheme
|
---|
| 306 |
|
---|
| 307 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new(nil, "openehr")}
|
---|
| 308 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("", "openehr")}
|
---|
| 309 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", nil)}
|
---|
| 310 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", "")}
|
---|
| 311 |
|
---|
| 312 | assert_raise(ArgumentError){@generic_id.value = nil}
|
---|
| 313 | assert_raise(ArgumentError){@generic_id.value = ""}
|
---|
| 314 | assert_nothing_raised(Exception){@generic_id.value = "0.0.5"}
|
---|
| 315 | assert_equal "0.0.5", @generic_id.value
|
---|
| 316 |
|
---|
| 317 | assert_raise(ArgumentError){@generic_id.scheme = nil}
|
---|
| 318 | assert_raise(ArgumentError){@generic_id.scheme = ""}
|
---|
| 319 | assert_nothing_raised(Exception){@generic_id.scheme = "cen"}
|
---|
| 320 | assert_equal "cen", @generic_id.scheme
|
---|
| 321 | end
|
---|
[95] | 322 |
|
---|
[93] | 323 | def test_uid_based_id
|
---|
| 324 | assert_equal "rrip::0.0.3", @uid_based_id.value
|
---|
| 325 | assert_equal "rrip", @uid_based_id.root
|
---|
| 326 | assert_equal '0.0.3', @uid_based_id.extension
|
---|
| 327 | assert @uid_based_id.has_extension?
|
---|
| 328 |
|
---|
| 329 | assert_raise(ArgumentError){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new(nil)}
|
---|
| 330 | assert_raise(ArgumentError){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('')}
|
---|
| 331 | assert_raise(ArgumentError){@uid_based_id.value = nil}
|
---|
| 332 | assert_raise(ArgumentError){@uid_based_id.value = ''}
|
---|
| 333 |
|
---|
| 334 | assert_nothing_raised(Exception){@uid_based_id.value = 'rrip'}
|
---|
| 335 | assert_equal 'rrip', @uid_based_id.value
|
---|
| 336 | assert_equal 'rrip', @uid_based_id.root
|
---|
| 337 | assert_equal '', @uid_based_id.extension
|
---|
| 338 | end
|
---|
[95] | 339 |
|
---|
| 340 | def test_hier_object_id
|
---|
| 341 | assert_equal '0.0.4', @hier_object_id.value
|
---|
| 342 | assert !@hier_object_id.root.nil?
|
---|
| 343 | assert !@hier_object_id.has_extension?
|
---|
| 344 | # in the specification 1.0.1 has_extension? xor extention != Void void is not nil?
|
---|
| 345 | assert @hier_object_id.extension.empty?
|
---|
| 346 | assert_nothing_raised(Exception){@hier_object_id.value = "ehr::test"}
|
---|
| 347 | assert !@hier_object_id.root.nil?
|
---|
| 348 | assert @hier_object_id.has_extension?
|
---|
| 349 | assert !@hier_object_id.extension.empty?
|
---|
| 350 | end
|
---|
[96] | 351 |
|
---|
| 352 | def test_locatable_ref
|
---|
[98] | 353 | # test constructorpp
|
---|
[96] | 354 | assert_equal 'unknown', @locatable_ref.namespace
|
---|
[97] | 355 | assert_equal 'PERSON', @locatable_ref.type
|
---|
[96] | 356 | assert_equal @uid_based_id, @locatable_ref.id
|
---|
[97] | 357 | assert_equal 'data/event[at0001, standing]', @locatable_ref.path
|
---|
| 358 | assert_equal 'ehr://rrip::0.0.3/data/event[at0001, standing]', @locatable_ref.as_uri
|
---|
| 359 | #test path
|
---|
| 360 | assert_nothing_raised(Exception){@locatable_ref.path = 'data/event[at0002, tilting]'}
|
---|
| 361 | assert_equal 'data/event[at0002, tilting]', @locatable_ref.path
|
---|
| 362 | assert_equal 'ehr://rrip::0.0.3/data/event[at0002, tilting]', @locatable_ref.as_uri
|
---|
[96] | 363 | end
|
---|
[98] | 364 |
|
---|
| 365 | def test_party_ref
|
---|
| 366 | # test constructor
|
---|
| 367 | assert_equal 'unknown', @party_ref.namespace
|
---|
| 368 | assert_equal 'ORGANISATION', @party_ref.type
|
---|
| 369 | assert_equal @object_id, @party_ref.id
|
---|
| 370 | # test type validation
|
---|
| 371 | assert_raise(ArgumentError){@party_ref.type = 'GUIDELINE'}
|
---|
| 372 | assert_nothing_raised(Exception){@party_ref.type = 'PERSON'}
|
---|
| 373 | assert_equal 'PERSON', @party_ref.type
|
---|
| 374 | assert_nothing_raised(Exception){@party_ref.type = 'GROUP'}
|
---|
| 375 | assert_nothing_raised(Exception){@party_ref.type = 'AGENT'}
|
---|
| 376 | assert_nothing_raised(Exception){@party_ref.type = 'ROLE'}
|
---|
| 377 | assert_nothing_raised(Exception){@party_ref.type = 'PARTY'}
|
---|
| 378 | assert_nothing_raised(Exception){@party_ref.type = 'ACTOR'}
|
---|
| 379 | end
|
---|
[99] | 380 |
|
---|
| 381 | def test_access_group_ref
|
---|
| 382 | # test constructor
|
---|
| 383 | assert_equal 'unknown', @access_group_ref.namespace
|
---|
| 384 | assert_equal 'ACCESS_GROUP', @access_group_ref.type
|
---|
| 385 | assert_equal @object_id, @access_group_ref.id
|
---|
| 386 | # test type validation
|
---|
| 387 | assert_raise(ArgumentError){@access_group_ref.type = 'PERSON'}
|
---|
| 388 | assert_nothing_raised(Exception){@access_group_ref.type = 'ACCESS_GROUP'}
|
---|
| 389 | end
|
---|
[66] | 390 | end
|
---|