[119] | 1 | require 'test/unit'
|
---|
| 2 | require 'set'
|
---|
| 3 | require 'rm'
|
---|
| 4 |
|
---|
| 5 | class RM_Support_Definition_Test < Test::Unit::TestCase
|
---|
| 6 | def test_constant
|
---|
| 7 | assert_equal("\r", OpenEHR::RM::Support::Definition::OpenEHR_Definitions::CR)
|
---|
| 8 | assert_equal("\n", OpenEHR::RM::Support::Definition::OpenEHR_Definitions::LF)
|
---|
| 9 | end
|
---|
| 10 | end
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | class RM_Support_Identification_Test < Test::Unit::TestCase
|
---|
| 14 | def setup
|
---|
| 15 | assert_nothing_raised(Exception){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.3")}
|
---|
| 16 | assert_nothing_raised(Exception){@object_ref = OpenEHR::RM::Support::Identification::Object_Ref.new('local', 'ANY', @object_id)}
|
---|
[268] | 17 | assert_nothing_raised(Exception){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new('openEHR-EHR-SECTION.physical_examination-prenatal.v2')}
|
---|
[158] | 18 | assert_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('ICD10(2003)')}
|
---|
[119] | 19 | assert_nothing_raised(Exception){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", "openehr")}
|
---|
| 20 | assert_nothing_raised(Exception){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.3')}
|
---|
| 21 | assert_nothing_raised(Exception){@hier_object_id = OpenEHR::RM::Support::Identification::Hier_Object_ID.new('0.0.4')}
|
---|
| 22 | assert_nothing_raised(Exception){@locatable_ref = OpenEHR::RM::Support::Identification::Locatable_Ref.new('unknown', 'PERSON', @uid_based_id, 'data/event[at0001, standing]')}
|
---|
| 23 | assert_nothing_raised(Exception){@party_ref = OpenEHR::RM::Support::Identification::Party_Ref.new('unknown', 'ORGANISATION', @object_id)}
|
---|
| 24 | assert_nothing_raised(Exception){@access_group_ref = OpenEHR::RM::Support::Identification::Access_Group_Ref.new('unknown', 'ACCESS_GROUP', @object_id)}
|
---|
| 25 | assert_nothing_raised(Exception){@version_tree_id = OpenEHR::RM::Support::Identification::Version_Tree_ID.new('1.2.3')}
|
---|
[157] | 26 | assert_nothing_raised(Exception){@object_version_id = OpenEHR::RM::Support::Identification::Object_Version_ID.new('ABC::DEF::1.2.3')}
|
---|
[119] | 27 | end
|
---|
| 28 |
|
---|
| 29 | def test_init
|
---|
| 30 | assert_instance_of OpenEHR::RM::Support::Identification::Object_ID, @object_id
|
---|
| 31 | assert_instance_of OpenEHR::RM::Support::Identification::Object_Ref, @object_ref
|
---|
| 32 | assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, @archetype_id
|
---|
| 33 | assert_instance_of OpenEHR::RM::Support::Identification::Terminology_ID, @terminology_id
|
---|
| 34 | assert_instance_of OpenEHR::RM::Support::Identification::Object_ID, @object_id
|
---|
| 35 | assert_instance_of OpenEHR::RM::Support::Identification::Generic_ID, @generic_id
|
---|
| 36 | assert_instance_of OpenEHR::RM::Support::Identification::UID_Based_ID, @uid_based_id
|
---|
| 37 | assert_instance_of OpenEHR::RM::Support::Identification::Hier_Object_ID, @hier_object_id
|
---|
| 38 | assert_instance_of OpenEHR::RM::Support::Identification::Locatable_Ref, @locatable_ref
|
---|
| 39 | assert_instance_of OpenEHR::RM::Support::Identification::Party_Ref, @party_ref
|
---|
| 40 | assert_instance_of OpenEHR::RM::Support::Identification::Access_Group_Ref, @access_group_ref
|
---|
| 41 | assert_instance_of OpenEHR::RM::Support::Identification::Version_Tree_ID, @version_tree_id
|
---|
[157] | 42 | assert_instance_of OpenEHR::RM::Support::Identification::Object_Version_ID, @object_version_id
|
---|
[119] | 43 | end
|
---|
| 44 |
|
---|
| 45 | def test_object_id
|
---|
| 46 | assert_equal "0.0.3", @object_id.value
|
---|
| 47 | assert_nothing_raised(Exception){@object_id.value = "0.0.4"}
|
---|
| 48 | assert_equal "0.0.4", @object_id.value
|
---|
| 49 | assert_raise(ArgumentError){@object_id.value=nil}
|
---|
| 50 | assert_raise(ArgumentError){@object_id.value=""}
|
---|
| 51 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new}
|
---|
| 52 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new(nil)}
|
---|
| 53 | assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new("")}
|
---|
| 54 | assert_equal @object_id, OpenEHR::RM::Support::Identification::Object_ID.new("0.0.4")
|
---|
| 55 | end
|
---|
| 56 |
|
---|
| 57 | def test_object_refs
|
---|
| 58 | assert_equal 'local', @object_ref.namespace
|
---|
| 59 | assert_equal 'ANY', @object_ref.type
|
---|
| 60 | assert_equal @object_id, @object_ref.id
|
---|
| 61 |
|
---|
| 62 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new}
|
---|
| 63 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new(nil, 'ANY', @object_id)}
|
---|
| 64 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('', 'ANY', @object_id)}
|
---|
| 65 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', nil, @object_id)}
|
---|
| 66 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', '', @object_id)}
|
---|
| 67 | assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', 'ANY', nil)}
|
---|
| 68 |
|
---|
| 69 | assert_nothing_raised(Exception){@object_ref.namespace = 'terminology'}
|
---|
| 70 | assert_equal 'terminology', @object_ref.namespace
|
---|
| 71 | assert_raise(ArgumentError){@object_ref.namespace = nil}
|
---|
| 72 | assert_raise(ArgumentError){@object_ref.namespace = ''}
|
---|
| 73 | assert_raise(ArgumentError){@object_ref.namespace = '?&&'}
|
---|
| 74 | assert_raise(ArgumentError){@object_ref.namespace = '843'}
|
---|
| 75 |
|
---|
| 76 | assert_nothing_raised(Exception){@object_ref.type = 'GUIDELINE'}
|
---|
| 77 | assert_equal 'GUIDELINE', @object_ref.type
|
---|
| 78 | assert_raise(ArgumentError){@object_ref.type = nil}
|
---|
| 79 | assert_raise(ArgumentError){@object_ref.type = ''}
|
---|
| 80 |
|
---|
| 81 | assert_nothing_raised(Exception){@object_ref.id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.5")}
|
---|
| 82 | assert_equal OpenEHR::RM::Support::Identification::Object_ID.new("0.0.5"), @object_ref.id
|
---|
| 83 | assert_raise(ArgumentError){@object_ref.id = nil}
|
---|
| 84 | end
|
---|
| 85 |
|
---|
| 86 | def test_archetype_id
|
---|
[268] | 87 | assert_equal 'openEHR-EHR-SECTION.physical_examination-prenatal.v2', @archetype_id.value
|
---|
| 88 | assert_equal 'openEHR-EHR-SECTION', @archetype_id.qualified_rm_entity
|
---|
| 89 | assert_equal 'openEHR', @archetype_id.rm_originator
|
---|
| 90 | assert_equal 'EHR', @archetype_id.rm_name
|
---|
| 91 | assert_equal 'SECTION', @archetype_id.rm_entity
|
---|
| 92 | assert_equal 'physical_examination', @archetype_id.concept_name
|
---|
| 93 | assert_equal 'prenatal', @archetype_id.specialisation
|
---|
| 94 | assert_equal 'v2', @archetype_id.version_id
|
---|
[119] | 95 | end
|
---|
| 96 |
|
---|
| 97 | def test_terminology_id
|
---|
| 98 | assert_equal "ICD10(2003)", @terminology_id.value
|
---|
| 99 | assert_nothing_raised(Exception){@terminology_id.value = "ICD9(1999)"}
|
---|
| 100 | assert_equal "ICD9", @terminology_id.name
|
---|
| 101 | assert_equal "1999", @terminology_id.version_id
|
---|
| 102 | assert_raise(ArgumentError){@terminology_id.value = nil}
|
---|
| 103 | assert_raise(ArgumentError){@terminology_id.value = ""}
|
---|
| 104 |
|
---|
| 105 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new}
|
---|
| 106 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new(nil,'2008')}
|
---|
| 107 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('','02008')}
|
---|
| 108 | assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("SNOMED", nil)}
|
---|
[158] | 109 | assert_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("SNOMED")}
|
---|
[119] | 110 |
|
---|
| 111 | assert_equal "SNOMED", @terminology_id.name
|
---|
| 112 | assert_nothing_raised(Exception){@terminology_id.name = "LOINC"}
|
---|
| 113 | assert_equal "LOINC", @terminology_id.name
|
---|
| 114 | assert_raise(ArgumentError){@terminology_id.name = nil}
|
---|
| 115 | assert_raise(ArgumentError){@terminology_id.name = ""}
|
---|
| 116 |
|
---|
| 117 | assert_equal "", @terminology_id.version_id
|
---|
| 118 | assert_nothing_raised(Exception){@terminology_id.version_id = "2008"}
|
---|
| 119 | assert_equal "2008", @terminology_id.version_id
|
---|
| 120 | assert_equal 'LOINC(2008)', @terminology_id.value
|
---|
| 121 | assert_raise(ArgumentError){@terminology_id.version_id = nil}
|
---|
| 122 | assert_nothing_raised(Exception){@terminology_id.version_id = ''}
|
---|
| 123 | end
|
---|
| 124 |
|
---|
| 125 | def test_generic_id
|
---|
| 126 | assert_equal "0.0.3", @generic_id.value
|
---|
| 127 | assert_equal "openehr", @generic_id.scheme
|
---|
| 128 |
|
---|
| 129 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new(nil, "openehr")}
|
---|
| 130 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("", "openehr")}
|
---|
| 131 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", nil)}
|
---|
| 132 | assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", "")}
|
---|
| 133 |
|
---|
| 134 | assert_raise(ArgumentError){@generic_id.value = nil}
|
---|
| 135 | assert_raise(ArgumentError){@generic_id.value = ""}
|
---|
| 136 | assert_nothing_raised(Exception){@generic_id.value = "0.0.5"}
|
---|
| 137 | assert_equal "0.0.5", @generic_id.value
|
---|
| 138 |
|
---|
| 139 | assert_raise(ArgumentError){@generic_id.scheme = nil}
|
---|
| 140 | assert_raise(ArgumentError){@generic_id.scheme = ""}
|
---|
| 141 | assert_nothing_raised(Exception){@generic_id.scheme = "cen"}
|
---|
| 142 | assert_equal "cen", @generic_id.scheme
|
---|
| 143 | end
|
---|
| 144 |
|
---|
| 145 | def test_uid_based_id
|
---|
| 146 | assert_equal "rrip::0.0.3", @uid_based_id.value
|
---|
| 147 | assert_equal "rrip", @uid_based_id.root
|
---|
| 148 | assert_equal '0.0.3', @uid_based_id.extension
|
---|
| 149 | assert @uid_based_id.has_extension?
|
---|
| 150 |
|
---|
| 151 | assert_raise(ArgumentError){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new(nil)}
|
---|
| 152 | assert_raise(ArgumentError){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('')}
|
---|
| 153 | assert_raise(ArgumentError){@uid_based_id.value = nil}
|
---|
| 154 | assert_raise(ArgumentError){@uid_based_id.value = ''}
|
---|
| 155 |
|
---|
| 156 | assert_nothing_raised(Exception){@uid_based_id.value = 'rrip'}
|
---|
| 157 | assert_equal 'rrip', @uid_based_id.value
|
---|
| 158 | assert_equal 'rrip', @uid_based_id.root
|
---|
| 159 | assert_equal '', @uid_based_id.extension
|
---|
| 160 | end
|
---|
| 161 |
|
---|
| 162 | def test_hier_object_id
|
---|
| 163 | assert_equal '0.0.4', @hier_object_id.value
|
---|
| 164 | assert !@hier_object_id.root.nil?
|
---|
| 165 | assert !@hier_object_id.has_extension?
|
---|
| 166 | # in the specification 1.0.1 has_extension? xor extention != Void void is not nil?
|
---|
| 167 | assert @hier_object_id.extension.empty?
|
---|
| 168 | assert_nothing_raised(Exception){@hier_object_id.value = "ehr::test"}
|
---|
| 169 | assert !@hier_object_id.root.nil?
|
---|
| 170 | assert @hier_object_id.has_extension?
|
---|
| 171 | assert !@hier_object_id.extension.empty?
|
---|
| 172 | end
|
---|
| 173 |
|
---|
[157] | 174 | def test_object_version_id
|
---|
| 175 | assert_equal 'ABC::DEF::1.2.3', @object_version_id.value
|
---|
| 176 | assert_equal 'ABC', @object_version_id.object_id.value
|
---|
| 177 | assert_equal 'DEF', @object_version_id.creating_system_id.value
|
---|
| 178 | assert_equal '1', @object_version_id.version_tree_id.trunk_version
|
---|
| 179 | end
|
---|
| 180 |
|
---|
[119] | 181 | def test_locatable_ref
|
---|
| 182 | # test constructor
|
---|
| 183 | assert_equal 'unknown', @locatable_ref.namespace
|
---|
| 184 | assert_equal 'PERSON', @locatable_ref.type
|
---|
| 185 | assert_equal @uid_based_id, @locatable_ref.id
|
---|
| 186 | assert_equal 'data/event[at0001, standing]', @locatable_ref.path
|
---|
| 187 | assert_equal 'ehr://rrip::0.0.3/data/event[at0001, standing]', @locatable_ref.as_uri
|
---|
| 188 | #test path
|
---|
| 189 | assert_nothing_raised(Exception){@locatable_ref.path = 'data/event[at0002, tilting]'}
|
---|
| 190 | assert_equal 'data/event[at0002, tilting]', @locatable_ref.path
|
---|
| 191 | assert_equal 'ehr://rrip::0.0.3/data/event[at0002, tilting]', @locatable_ref.as_uri
|
---|
| 192 | end
|
---|
| 193 |
|
---|
| 194 | def test_party_ref
|
---|
| 195 | # test constructor
|
---|
| 196 | assert_equal 'unknown', @party_ref.namespace
|
---|
| 197 | assert_equal 'ORGANISATION', @party_ref.type
|
---|
| 198 | assert_equal @object_id, @party_ref.id
|
---|
| 199 | # test type validation
|
---|
| 200 | assert_raise(ArgumentError){@party_ref.type = 'GUIDELINE'}
|
---|
| 201 | assert_nothing_raised(Exception){@party_ref.type = 'PERSON'}
|
---|
| 202 | assert_equal 'PERSON', @party_ref.type
|
---|
| 203 | assert_nothing_raised(Exception){@party_ref.type = 'GROUP'}
|
---|
| 204 | assert_nothing_raised(Exception){@party_ref.type = 'AGENT'}
|
---|
| 205 | assert_nothing_raised(Exception){@party_ref.type = 'ROLE'}
|
---|
| 206 | assert_nothing_raised(Exception){@party_ref.type = 'PARTY'}
|
---|
| 207 | assert_nothing_raised(Exception){@party_ref.type = 'ACTOR'}
|
---|
| 208 | end
|
---|
| 209 |
|
---|
| 210 | def test_access_group_ref
|
---|
| 211 | # test constructor
|
---|
| 212 | assert_equal 'unknown', @access_group_ref.namespace
|
---|
| 213 | assert_equal 'ACCESS_GROUP', @access_group_ref.type
|
---|
| 214 | assert_equal @object_id, @access_group_ref.id
|
---|
| 215 | # test type validation
|
---|
| 216 | assert_raise(ArgumentError){@access_group_ref.type = 'PERSON'}
|
---|
| 217 | assert_nothing_raised(Exception){@access_group_ref.type = 'ACCESS_GROUP'}
|
---|
| 218 | end
|
---|
| 219 |
|
---|
| 220 | def test_version_tree_id
|
---|
| 221 | assert_equal '1.2.3', @version_tree_id.value
|
---|
| 222 | assert_equal '1', @version_tree_id.trunk_version
|
---|
| 223 | assert_equal '2', @version_tree_id.branch_number
|
---|
| 224 | assert_equal '3', @version_tree_id.branch_version
|
---|
| 225 | assert @version_tree_id.is_first?
|
---|
| 226 | assert @version_tree_id.is_branch?
|
---|
| 227 | assert_nothing_raised(Exception){@version_tree_id.value = '2'}
|
---|
| 228 | assert_equal '2', @version_tree_id.trunk_version
|
---|
| 229 | assert !@version_tree_id.is_first?
|
---|
| 230 | assert !@version_tree_id.is_branch?
|
---|
| 231 | assert_nil @version_tree_id.branch_number
|
---|
| 232 | assert_nil @version_tree_id.branch_version
|
---|
| 233 | assert_raise(ArgumentError){@version_tree_id.branch_version = '5'}
|
---|
| 234 | end
|
---|
| 235 | end
|
---|