1 | # This module is based on the UML,
|
---|
2 | # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109326589721_134411_997Report.html
|
---|
3 | # Ticket refs #64
|
---|
4 |
|
---|
5 | module OpenEHR
|
---|
6 | module RM
|
---|
7 | module Common
|
---|
8 | module Change_Control
|
---|
9 | class Contribution
|
---|
10 | attr_reader :uid, :versions, :audit
|
---|
11 |
|
---|
12 | def initialize(uid, versions, audit)
|
---|
13 | self.uid = uid
|
---|
14 | self.versions = versions
|
---|
15 | self.audit = audit
|
---|
16 | end
|
---|
17 |
|
---|
18 | def uid=(uid)
|
---|
19 | if uid.nil?
|
---|
20 | raise ArgumentError, "uid should not be nil."
|
---|
21 | end
|
---|
22 | @uid = uid
|
---|
23 | end
|
---|
24 |
|
---|
25 | def versions=(versions)
|
---|
26 | unless versions.nil?
|
---|
27 | if versions.empty?
|
---|
28 | raise ArgumentError, 'versions shoud not be nil or empty.'
|
---|
29 | end
|
---|
30 | end
|
---|
31 | @versions = versions
|
---|
32 | end
|
---|
33 |
|
---|
34 | def audit=(audit)
|
---|
35 | if audit.nil?
|
---|
36 | raise ArgumentError, 'audit should not be nil.'
|
---|
37 | end
|
---|
38 | if audit.description.nil?
|
---|
39 | raise ArgumentError, 'audit.description should not be nil.'
|
---|
40 | end
|
---|
41 | @audit = audit
|
---|
42 | end
|
---|
43 | end
|
---|
44 |
|
---|
45 | class Versioned_Object
|
---|
46 | end
|
---|
47 |
|
---|
48 | class Version
|
---|
49 | attr_reader :uid, :preceding_version_uid, :lifecycle_state,
|
---|
50 | :commit_audit, :contribution
|
---|
51 | attr_accessor :data, :signature
|
---|
52 |
|
---|
53 | def initialize(args = { })
|
---|
54 | self.uid = args[:uid]
|
---|
55 | self.preceding_version_uid = args[:preceding_version_uid]
|
---|
56 | self.data = args[:data]
|
---|
57 | self.lifcycle_state = args[:lifecycle_state]
|
---|
58 | self.commit_audit = args[:commit_audit]
|
---|
59 | self.contribution = args[:contribution]
|
---|
60 | self.signature = args[:signature]
|
---|
61 | end
|
---|
62 |
|
---|
63 | def uid=(uid)
|
---|
64 | raise ArgumentError, "uid should not be nil" if uid.nil?
|
---|
65 | @uid = uid
|
---|
66 | end
|
---|
67 |
|
---|
68 | def preceding_version_uid=(preceding_version_uid)
|
---|
69 | if (!preceding_version_uid.nil?) == @uid.version_tree_id.is_first?
|
---|
70 | raise ArgumentError, 'preceding version is invalid'
|
---|
71 | end
|
---|
72 | @preceding_version_uid = preceding_version_uid
|
---|
73 | end
|
---|
74 |
|
---|
75 | def lifcycle_state=(lifecycle_state)
|
---|
76 | if lifecycle_state.nil? ||
|
---|
77 | !%w[532 553 523].include?(
|
---|
78 | lifecycle_state.defining_code.code_string)
|
---|
79 | raise ArgumentError, 'invalid lifecycle_state'
|
---|
80 | end
|
---|
81 | @lifecycle_state = lifecycle_state
|
---|
82 | end
|
---|
83 |
|
---|
84 | def commit_audit=(commit_audit)
|
---|
85 | if commit_audit.nil?
|
---|
86 | raise ArgumentError,'commit_audit is mandatory'
|
---|
87 | end
|
---|
88 | @commit_audit = commit_audit
|
---|
89 | end
|
---|
90 |
|
---|
91 | def contribution=(contribution)
|
---|
92 | raise ArgumentError, "contribution should not be nil" if contribution.nil? or contribution.type.empty?
|
---|
93 | @contribution = contribution
|
---|
94 | end
|
---|
95 |
|
---|
96 | def owner_id
|
---|
97 | return Hier_Object_ID.new(@uid.object_id.value)
|
---|
98 | end
|
---|
99 |
|
---|
100 | def is_branch?
|
---|
101 | return @uid.is_branch?
|
---|
102 | end
|
---|
103 |
|
---|
104 | def canonical_form
|
---|
105 | raise NotImplementedError, 'canonical form not implemented'
|
---|
106 | end
|
---|
107 | end
|
---|
108 |
|
---|
109 | class Imported_Version < Version
|
---|
110 | end
|
---|
111 |
|
---|
112 | class Original_Version < Version
|
---|
113 | attr_reader :attestations
|
---|
114 |
|
---|
115 | def initialize(args = { })
|
---|
116 | super(args)
|
---|
117 | self.attestations = args[:attestations]
|
---|
118 | self.other_input_version_uids = args[:other_input_version_uids]
|
---|
119 | end
|
---|
120 |
|
---|
121 | def attestations=(attestations)
|
---|
122 | if attestations.nil? || attestations.empty?
|
---|
123 | raise ArgumentError, 'attestations is mandatory'
|
---|
124 | end
|
---|
125 | @attestations = attestations
|
---|
126 | end
|
---|
127 |
|
---|
128 | def other_input_version_uids=(other_input_version_uids)
|
---|
129 | if !other_input_version_uids.nil? && other_input_version_uids.empty?
|
---|
130 | raise ArgumentError, 'invaild other_input_version_uids'
|
---|
131 | end
|
---|
132 | @other_input_version_uids = other_input_version_uids
|
---|
133 | end
|
---|
134 |
|
---|
135 | def is_merged?
|
---|
136 |
|
---|
137 | end
|
---|
138 | end
|
---|
139 | end # of Change_Control
|
---|
140 | end # of Common
|
---|
141 | end # of RM
|
---|
142 | end # of OpenEHR
|
---|