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