[86] | 1 | # This module is based on the UML,
|
---|
| 2 | # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_76d0249_1118674798473_6021_0Report.html
|
---|
| 3 | # Ticket refs #45
|
---|
[369] | 4 | include OpenEHR::RM::Common::Archetyped
|
---|
| 5 |
|
---|
[6] | 6 | module OpenEHR
|
---|
| 7 | module RM
|
---|
[369] | 8 | module Demographic
|
---|
| 9 | class Party < Locatable
|
---|
| 10 | attr_reader :uid, :identities, :contacts, :relationships,
|
---|
| 11 | :reverse_relationships
|
---|
| 12 | attr_accessor :details
|
---|
| 13 | alias :type :name
|
---|
[87] | 14 |
|
---|
[369] | 15 | def initialize(args = { })
|
---|
| 16 | super(args)
|
---|
| 17 | self.uid = args[:uid]
|
---|
| 18 | self.identities = args[:identities]
|
---|
| 19 | self.contacts = args[:contacts]
|
---|
| 20 | self.relationships = args[:relationships]
|
---|
| 21 | self.reverse_relationships =
|
---|
| 22 | args[:reverse_relationships]
|
---|
| 23 | self.details = args[:details]
|
---|
[87] | 24 | end
|
---|
| 25 |
|
---|
[9] | 26 | def uid=(uid)
|
---|
[369] | 27 | raise ArgumentError, 'uid is mandatory' if uid.nil?
|
---|
[9] | 28 | @uid = uid
|
---|
| 29 | end
|
---|
[369] | 30 |
|
---|
[9] | 31 | def identities=(identities)
|
---|
[369] | 32 | if identities.nil? || identities.empty?
|
---|
| 33 | raise ArgumentError, 'identities are mandatory'
|
---|
| 34 | end
|
---|
[9] | 35 | @identities = identities
|
---|
[369] | 36 | end
|
---|
| 37 |
|
---|
[9] | 38 | def contacts=(contacts)
|
---|
[369] | 39 | if !contacts.nil? && contacts.empty?
|
---|
| 40 | raise ArgumentError, 'contacts should not be empty'
|
---|
| 41 | end
|
---|
[9] | 42 | @contacts = contacts
|
---|
| 43 | end
|
---|
[369] | 44 |
|
---|
[8] | 45 | def parent=(parent)
|
---|
| 46 | @parent = nil
|
---|
| 47 | end
|
---|
[369] | 48 |
|
---|
| 49 | def relationships=(relationships)
|
---|
| 50 | unless relationships.nil?
|
---|
| 51 | if relationships.empty?
|
---|
| 52 | raise ArgumentError, 'relationships should not be empty?'
|
---|
| 53 | else
|
---|
| 54 | relationships.each do |rel|
|
---|
| 55 | if rel.source.id.value != @uid.value
|
---|
| 56 | raise ArgumentError, 'invalid source of relationships'
|
---|
| 57 | end
|
---|
| 58 | end
|
---|
| 59 | end
|
---|
| 60 | end
|
---|
| 61 | @relationships = relationships
|
---|
[8] | 62 | end
|
---|
[369] | 63 |
|
---|
| 64 | def reverse_relationships=(reverse_relationships)
|
---|
| 65 | if !reverse_relationships.nil? && reverse_relationships.empty?
|
---|
| 66 | raise ArgumentError, 'reverse_relationships should not be empty'
|
---|
[9] | 67 | end
|
---|
[369] | 68 | @reverse_relationships = reverse_relationships
|
---|
[9] | 69 | end
|
---|
[7] | 70 | end
|
---|
[87] | 71 |
|
---|
[369] | 72 | class PartyIdentity < Locatable
|
---|
[87] | 73 | attr_reader :details
|
---|
| 74 |
|
---|
[369] | 75 | def initialize(args = { })
|
---|
| 76 | super(args)
|
---|
| 77 | self.details = args[:details]
|
---|
| 78 | end
|
---|
[87] | 79 |
|
---|
[369] | 80 | def details=(details)
|
---|
| 81 | if details.nil?
|
---|
| 82 | raise ArgumentError, 'details are mandatory'
|
---|
| 83 | end
|
---|
| 84 | @details = details
|
---|
| 85 | end
|
---|
[87] | 86 |
|
---|
[369] | 87 | def purpose
|
---|
| 88 | return @name
|
---|
| 89 | end
|
---|
[87] | 90 | end
|
---|
| 91 |
|
---|
[369] | 92 | class Contact < Locatable
|
---|
| 93 | attr_accessor :time_validity
|
---|
| 94 | attr_reader :addresses
|
---|
[87] | 95 |
|
---|
[369] | 96 | def initialize(args = { })
|
---|
| 97 | super(args)
|
---|
| 98 | self.addresses = args[:addresses]
|
---|
| 99 | self.time_validity = args[:time_validity]
|
---|
| 100 | end
|
---|
| 101 |
|
---|
| 102 | def purpose
|
---|
| 103 | return @name
|
---|
| 104 | end
|
---|
| 105 |
|
---|
| 106 | def addresses=(addresses)
|
---|
| 107 | if addresses.nil? || addresses.empty?
|
---|
| 108 | raise ArgumentError, 'address is mandatory'
|
---|
| 109 | end
|
---|
| 110 | @addresses = addresses
|
---|
| 111 | end
|
---|
[87] | 112 | end
|
---|
| 113 |
|
---|
[369] | 114 | class Address < Locatable
|
---|
| 115 | attr_reader :details
|
---|
[87] | 116 |
|
---|
[369] | 117 | def initialize(args = { })
|
---|
| 118 | super(args)
|
---|
| 119 | self.details = args[:details]
|
---|
| 120 | end
|
---|
| 121 |
|
---|
| 122 | def details=(details)
|
---|
| 123 | if details.nil?
|
---|
| 124 | raise ArgumentError, 'details are mandatory'
|
---|
| 125 | end
|
---|
| 126 | @details = details
|
---|
| 127 | end
|
---|
| 128 |
|
---|
| 129 | def type
|
---|
| 130 | return @name
|
---|
| 131 | end
|
---|
[87] | 132 | end
|
---|
| 133 |
|
---|
[86] | 134 | class Actor < Party
|
---|
[369] | 135 | LEAGAL_IDENTITY = 'legal identity'
|
---|
| 136 | attr_reader :languages, :roles
|
---|
| 137 |
|
---|
| 138 | def initialize(args = { })
|
---|
| 139 | super(args)
|
---|
| 140 | self.roles = args[:roles]
|
---|
| 141 | self.languages = args[:languages]
|
---|
[51] | 142 | end
|
---|
[369] | 143 |
|
---|
| 144 | def roles=(roles)
|
---|
| 145 | if !roles.nil? && roles.empty?
|
---|
| 146 | raise ArgumentError, 'roles should not be empty'
|
---|
| 147 | end
|
---|
| 148 | @roles = roles
|
---|
| 149 | end
|
---|
| 150 |
|
---|
[51] | 151 | def has_legal_identity?
|
---|
[369] | 152 | @identities.each do |identity|
|
---|
| 153 | if identity.purpose.value == LEAGAL_IDENTITY
|
---|
[51] | 154 | return true
|
---|
| 155 | end
|
---|
[369] | 156 | end
|
---|
| 157 | return false
|
---|
[51] | 158 | end
|
---|
[369] | 159 |
|
---|
[51] | 160 | def languages=(languages)
|
---|
[369] | 161 | if !languages.nil? && languages.empty?
|
---|
| 162 | raise ArgumentError, 'languages should not be empty.'
|
---|
[51] | 163 | end
|
---|
| 164 | @languages = languages
|
---|
| 165 | end
|
---|
[10] | 166 | end
|
---|
[369] | 167 |
|
---|
| 168 | class Person < Actor
|
---|
| 169 |
|
---|
| 170 | end
|
---|
| 171 |
|
---|
| 172 | class Organisation < Actor
|
---|
| 173 |
|
---|
| 174 | end
|
---|
| 175 |
|
---|
| 176 | class Group < Actor
|
---|
| 177 |
|
---|
| 178 | end
|
---|
| 179 |
|
---|
| 180 | class Agent < Actor
|
---|
| 181 |
|
---|
| 182 | end
|
---|
| 183 |
|
---|
| 184 | class Role < Party
|
---|
| 185 | attr_reader :performer, :capabilities
|
---|
[51] | 186 | attr_accessor :time_validity
|
---|
[369] | 187 |
|
---|
| 188 | def initialize(args = { })
|
---|
| 189 | super(args)
|
---|
| 190 | self.performer = args[:performer]
|
---|
| 191 | self.capabilities = args[:capabilities]
|
---|
| 192 | self.time_validity = args[:time_validity]
|
---|
[51] | 193 | end
|
---|
[369] | 194 |
|
---|
| 195 | def performer=(performer)
|
---|
| 196 | if performer.nil?
|
---|
| 197 | raise ArgumentError, 'performer is mandatory'
|
---|
| 198 | end
|
---|
| 199 | @performer = performer
|
---|
[51] | 200 | end
|
---|
[369] | 201 |
|
---|
| 202 | def capabilities=(capabilities)
|
---|
| 203 | if !capabilities.nil? && capabilities.empty?
|
---|
| 204 | raise ArgumentError, 'capability should not be empty'
|
---|
| 205 | end
|
---|
| 206 | @capabilities = capabilities
|
---|
[51] | 207 | end
|
---|
[369] | 208 | end
|
---|
| 209 |
|
---|
| 210 | class Capability < Locatable
|
---|
| 211 | attr_reader :credentials
|
---|
| 212 | attr_accessor :time_validity
|
---|
| 213 |
|
---|
| 214 | def initialize(args = { })
|
---|
| 215 | super(args)
|
---|
| 216 | self.credentials = args[:credentials]
|
---|
| 217 | self.time_validity = args[:time_validity]
|
---|
[51] | 218 | end
|
---|
[369] | 219 |
|
---|
| 220 | def credentials=(credentials)
|
---|
| 221 | if credentials.nil?
|
---|
| 222 | raise ArgumentError, 'credentials are mandatory'
|
---|
[51] | 223 | end
|
---|
[369] | 224 | @credentials = credentials
|
---|
[51] | 225 | end
|
---|
| 226 | end
|
---|
[86] | 227 |
|
---|
[369] | 228 | class PartyRelationship < Locatable
|
---|
| 229 | attr_accessor :details, :time_validity
|
---|
| 230 | attr_reader :source, :target
|
---|
| 231 | alias :type :name
|
---|
[86] | 232 |
|
---|
[369] | 233 | def initialize(args = { })
|
---|
| 234 | super(args)
|
---|
| 235 | self.uid = args[:uid]
|
---|
| 236 | self.details = args[:details]
|
---|
| 237 | self.time_validity = args[:time_validity]
|
---|
| 238 | self.source = args[:source]
|
---|
| 239 | self.target = args[:target]
|
---|
| 240 | end
|
---|
[86] | 241 |
|
---|
[369] | 242 | def uid=(uid)
|
---|
| 243 | if uid.nil?
|
---|
| 244 | raise ArgumentError, 'uid is mandatory'
|
---|
| 245 | end
|
---|
| 246 | @uid = uid
|
---|
| 247 | end
|
---|
[86] | 248 |
|
---|
[369] | 249 | def source=(source)
|
---|
| 250 | if source.nil? or source.id.value != @uid.value
|
---|
| 251 | raise ArgumentError, 'source is invalid'
|
---|
| 252 | end
|
---|
| 253 | @source = source
|
---|
| 254 | end
|
---|
[86] | 255 |
|
---|
[369] | 256 | def target=(target)
|
---|
| 257 | if target.nil?
|
---|
| 258 | raise ArgumentError, 'taraget is invalid'
|
---|
| 259 | end
|
---|
| 260 | @target = target
|
---|
| 261 | end
|
---|
[86] | 262 | end
|
---|
| 263 |
|
---|
[369] | 264 | class VersionedParty < Locatable
|
---|
[86] | 265 |
|
---|
| 266 | end
|
---|
[6] | 267 | end # of Demographic
|
---|
| 268 | end # of RM
|
---|
| 269 | end # of OpenEHR
|
---|