source: ruby/trunk/lib/open_ehr/rm/common/generic.rb@ 370

Last change on this file since 370 was 370, checked in by KOBAYASHI, Shinji, 14 years ago

merge operation

File size: 6.3 KB
Line 
1# This module is a implementation of the bellow UML
2# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_1_76d0249_1140169202660_257304_813Report.html
3# Related to the ticket #62
4include OpenEHR::RM::Support::Identification
5include OpenEHR::RM::DataTypes::Basic
6module OpenEHR
7 module RM
8 module Common
9 module Generic
10 class AuditDetails
11 attr_reader :system_id, :committer, :time_committed, :change_type
12 attr_accessor :description
13
14 def initialize(args = { })
15 self.system_id = args[:system_id]
16 self.committer = args[:committer]
17 self.time_committed = args[:time_committed]
18 self.change_type = args[:change_type]
19 self.description = args[:description]
20 end
21
22 def system_id=(system_id)
23 if system_id.nil? or system_id.empty?
24 raise ArgumentError, 'system_id is mandatory'
25 end
26 @system_id = system_id
27 end
28
29 def committer=(committer)
30 raise ArgumentError, 'committer is mandatory' if committer.nil?
31 @committer = committer
32 end
33
34 def time_committed=(time_committed)
35 if time_committed.nil?
36 raise ArgumentError, 'time_committed is mandatory'
37 end
38 @time_committed = time_committed
39 end
40
41 def change_type=(change_type)
42 raise ArgumentError, 'change_type is mandatory' if change_type.nil?
43 @change_type = change_type
44 end
45 end
46
47 class RevisionHistory
48 attr_reader :items
49
50 def initialize(args = { })
51 self.items = args[:items]
52 end
53
54 def items=(items)
55 if items.nil? or items.empty?
56 raise ArgumentError, 'item(s) is/are mandatory'
57 end
58 @items = items
59 end
60
61 def most_recent_version
62 return @items.last.version_id.value
63 end
64
65 def most_recent_version_time_committed
66 return @items.last.audits.first.time_committed.value
67 end
68 end # of RevisionHistory
69
70 class RevisionHistoryItem
71 attr_reader :version_id, :audits
72
73 def initialize(args = { })
74 self.version_id = args[:version_id]
75 self.audits = args[:audits]
76 end
77
78 def audits=(audits)
79 if audits.nil? or audits.empty?
80 raise ArgumentError, 'audits is mandatory'
81 end
82 @audits = audits
83 end
84
85 def version_id=(version_id)
86 raise ArgumentError, 'version_id is mandatory' if version_id.nil?
87 @version_id = version_id
88 end
89 end # of RevisionHistory_Item
90
91 class PartyProxy
92 attr_accessor :external_ref
93
94 def initialize(args = { })
95 self.external_ref = args[:external_ref]
96 end
97 end
98
99 class PartySelf < PartyProxy
100
101 end
102
103 class PartyIdentified < PartyProxy
104 attr_reader :name, :identifier
105
106 def initialize(args = { })
107 if args[:external_ref].nil? && args[:name].nil? &&
108 args[:identifier].nil?
109 raise ArgumentError, 'cannot identified'
110 end
111 self.name = args[:name]
112 self.identifier = args[:identifier]
113 super(args)
114 end
115
116 def name=(name)
117 if name.nil? && @external_ref.nil? && @identifier.nil?
118 raise ArgumentError, 'cannot identified'
119 end
120 raise ArgumentError, 'invaild name' unless name.nil? || !name.empty?
121 @name = name
122 end
123
124 def identifier=(identifier)
125 if @name.nil? && @external_ref.nil? && identifier.nil?
126 raise ArgumentError, 'cannot identified'
127 end
128 if !identifier.nil? && identifier.empty?
129 raise ArgumentError, 'invaild identifier'
130 end
131 @identifier = identifier
132 end
133
134 def external_ref=(external_ref)
135 if @name.nil? && @identifier.nil? && external_ref.nil?
136 raise ArgumentError, 'invalid external_ref'
137 end
138 @external_ref = external_ref
139 end
140 end
141
142 class PartyRelated < PartyIdentified
143 attr_reader :relationship
144 def initialize(args = { })
145 super(args)
146 self.relationship = args[:relationship]
147 end
148
149 def relationship=(relationship)
150 if relationship.nil?
151 raise ArgumentError, 'relationship must not be nil'
152 end
153 @relationship = relationship
154 end
155 end
156
157 class Participation
158 attr_reader :performer, :function, :mode
159 attr_accessor :time
160
161 def initialize(args ={ })
162 self.performer = args[:performer]
163 self.function = args[:function]
164 self.mode = args[:mode]
165 self.time = args[:time]
166 end
167
168 def performer=(performer)
169 raise ArgumentError, 'performer is mandatory' if performer.nil?
170 @performer = performer
171 end
172
173 def function=(function)
174 raise ArgumentError, 'function is mandatory' if function.nil?
175 @function = function
176 end
177
178 def mode=(mode)
179 raise ArgumentError, 'mode is mandatory' if mode.nil?
180 @mode = mode
181 end
182 end
183
184 class Attestation < AuditDetails
185 attr_reader :reason
186 attr_accessor :proof, :attested_view, :is_pending, :items
187
188 def initialize(args = { })
189 super(args)
190 self.reason = args[:reason]
191 self.proof = args[:proof]
192 self.items = args[:items]
193 self.attested_view = args[:attested_view]
194 self.is_pending = args[:is_pending]
195 end
196
197 def reason=(reason)
198 raise ArgumentError, 'reason is mandatory' if reason.nil?
199 @reason = reason
200 end
201
202 def items=(items)
203 if !items.nil? && items.empty?
204 raise ArgumentError, 'items should not be empty'
205 end
206 @items = items
207 end
208
209 def is_pending?
210 return is_pending
211 end
212 end
213 end # of Generic
214 end # of Common
215 end # of RM
216end # of OpenEHR
Note: See TracBrowser for help on using the repository browser.