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
|
---|
4 | include OpenEHR::RM::Common::Archetyped
|
---|
5 |
|
---|
6 | module OpenEHR
|
---|
7 | module RM
|
---|
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
|
---|
14 |
|
---|
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]
|
---|
24 | end
|
---|
25 |
|
---|
26 | def uid=(uid)
|
---|
27 | raise ArgumentError, 'uid is mandatory' if uid.nil?
|
---|
28 | @uid = uid
|
---|
29 | end
|
---|
30 |
|
---|
31 | def identities=(identities)
|
---|
32 | if identities.nil? || identities.empty?
|
---|
33 | raise ArgumentError, 'identities are mandatory'
|
---|
34 | end
|
---|
35 | @identities = identities
|
---|
36 | end
|
---|
37 |
|
---|
38 | def contacts=(contacts)
|
---|
39 | if !contacts.nil? && contacts.empty?
|
---|
40 | raise ArgumentError, 'contacts should not be empty'
|
---|
41 | end
|
---|
42 | @contacts = contacts
|
---|
43 | end
|
---|
44 |
|
---|
45 | def parent=(parent)
|
---|
46 | @parent = nil
|
---|
47 | end
|
---|
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
|
---|
62 | end
|
---|
63 |
|
---|
64 | def reverse_relationships=(reverse_relationships)
|
---|
65 | if !reverse_relationships.nil? && reverse_relationships.empty?
|
---|
66 | raise ArgumentError, 'reverse_relationships should not be empty'
|
---|
67 | end
|
---|
68 | @reverse_relationships = reverse_relationships
|
---|
69 | end
|
---|
70 | end
|
---|
71 |
|
---|
72 | class PartyIdentity < Locatable
|
---|
73 | attr_reader :details
|
---|
74 |
|
---|
75 | def initialize(args = { })
|
---|
76 | super(args)
|
---|
77 | self.details = args[:details]
|
---|
78 | end
|
---|
79 |
|
---|
80 | def details=(details)
|
---|
81 | if details.nil?
|
---|
82 | raise ArgumentError, 'details are mandatory'
|
---|
83 | end
|
---|
84 | @details = details
|
---|
85 | end
|
---|
86 |
|
---|
87 | def purpose
|
---|
88 | return @name
|
---|
89 | end
|
---|
90 | end
|
---|
91 |
|
---|
92 | class Contact < Locatable
|
---|
93 | attr_accessor :time_validity
|
---|
94 | attr_reader :addresses
|
---|
95 |
|
---|
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
|
---|
112 | end
|
---|
113 |
|
---|
114 | class Address < Locatable
|
---|
115 | attr_reader :details
|
---|
116 |
|
---|
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
|
---|
132 | end
|
---|
133 |
|
---|
134 | class Actor < Party
|
---|
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]
|
---|
142 | end
|
---|
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 |
|
---|
151 | def has_legal_identity?
|
---|
152 | @identities.each do |identity|
|
---|
153 | if identity.purpose.value == LEAGAL_IDENTITY
|
---|
154 | return true
|
---|
155 | end
|
---|
156 | end
|
---|
157 | return false
|
---|
158 | end
|
---|
159 |
|
---|
160 | def languages=(languages)
|
---|
161 | if !languages.nil? && languages.empty?
|
---|
162 | raise ArgumentError, 'languages should not be empty.'
|
---|
163 | end
|
---|
164 | @languages = languages
|
---|
165 | end
|
---|
166 | end
|
---|
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
|
---|
186 | attr_accessor :time_validity
|
---|
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]
|
---|
193 | end
|
---|
194 |
|
---|
195 | def performer=(performer)
|
---|
196 | if performer.nil?
|
---|
197 | raise ArgumentError, 'performer is mandatory'
|
---|
198 | end
|
---|
199 | @performer = performer
|
---|
200 | end
|
---|
201 |
|
---|
202 | def capabilities=(capabilities)
|
---|
203 | if !capabilities.nil? && capabilities.empty?
|
---|
204 | raise ArgumentError, 'capability should not be empty'
|
---|
205 | end
|
---|
206 | @capabilities = capabilities
|
---|
207 | end
|
---|
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]
|
---|
218 | end
|
---|
219 |
|
---|
220 | def credentials=(credentials)
|
---|
221 | if credentials.nil?
|
---|
222 | raise ArgumentError, 'credentials are mandatory'
|
---|
223 | end
|
---|
224 | @credentials = credentials
|
---|
225 | end
|
---|
226 | end
|
---|
227 |
|
---|
228 | class PartyRelationship < Locatable
|
---|
229 | attr_accessor :details, :time_validity
|
---|
230 | attr_reader :source, :target
|
---|
231 | alias :type :name
|
---|
232 |
|
---|
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
|
---|
241 |
|
---|
242 | def uid=(uid)
|
---|
243 | if uid.nil?
|
---|
244 | raise ArgumentError, 'uid is mandatory'
|
---|
245 | end
|
---|
246 | @uid = uid
|
---|
247 | end
|
---|
248 |
|
---|
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
|
---|
255 |
|
---|
256 | def target=(target)
|
---|
257 | if target.nil?
|
---|
258 | raise ArgumentError, 'taraget is invalid'
|
---|
259 | end
|
---|
260 | @target = target
|
---|
261 | end
|
---|
262 | end
|
---|
263 |
|
---|
264 | class VersionedParty < Locatable
|
---|
265 |
|
---|
266 | end
|
---|
267 | end # of Demographic
|
---|
268 | end # of RM
|
---|
269 | end # of OpenEHR
|
---|