source: ruby/branches/0.5/lib/open_ehr/rm/ehr.rb@ 352

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

fixed #44

File size: 4.5 KB
Line 
1# rm::ehr
2# ehr module
3# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109004889781_854011_47Report.html
4# refs #44
5include OpenEHR::RM::Common::ChangeControl
6include OpenEHR::RM::Common::Archetyped
7include OpenEHR::RM::Security
8
9module OpenEHR
10 module RM
11 module EHR
12 class EHR
13 attr_reader :system_id, :ehr_id, :time_created, :contributions,
14 :ehr_access, :ehr_status, :compositions, :directory
15
16 def initialize(args = { })
17 self.system_id = args[:system_id]
18 self.ehr_id = args[:ehr_id]
19 self.time_created = args[:time_created]
20 self.contributions = args[:contributions]
21 self.ehr_access = args[:ehr_access]
22 self.ehr_status = args[:ehr_status]
23 self.compositions = args[:compositions]
24 self.directory = args[:directory]
25 end
26
27 def system_id=(system_id)
28 if system_id.nil?
29 raise ArgumentError, 'system_id is mandatory'
30 end
31 @system_id = system_id
32 end
33
34 def ehr_id=(ehr_id)
35 if ehr_id.nil?
36 raise ArgumentError, 'ehr_id is mandatory'
37 end
38 @ehr_id = ehr_id
39 end
40
41 def time_created=(time_created)
42 if time_created.nil?
43 raise ArgumentError, 'time_created is mandatory'
44 end
45 @time_created = time_created
46 end
47
48 def contributions=(contributions)
49 unless contributions.nil?
50 contributions.each do |contrib|
51 unless contrib.type == 'CONTRIBUTION'
52 raise ArgumentError, 'contribution type should be CONTRIBUTION'
53 end
54 end
55 @contributions = contributions
56 else
57 raise ArgumentError, 'contributions are mandatory'
58 end
59 end
60
61 def ehr_access=(ehr_access)
62 if ehr_access.nil? || ehr_access.type != 'VERSIONED_EHR_ACCESS'
63 raise ArgumentError, 'ehr_access is invalid'
64 end
65 @ehr_access = ehr_access
66 end
67
68 def ehr_status=(ehr_status)
69 if ehr_status.nil? || ehr_status.type != 'VERSIONED_EHR_STATUS'
70 raise ArgumentError, 'ehr_status is invalid'
71 end
72 @ehr_status = ehr_status
73 end
74
75 def compositions=(compositions)
76 unless compositions.nil?
77 compositions.each do |compo|
78 unless compo.type == 'VERSIONED_COMPOSITION'
79 raise ArgumentError, 'composition type should be VERSIONED_COMPOSITION'
80 end
81 end
82 @compositions = compositions
83 else
84 raise ArgumentError, 'compositions are mandatory'
85 end
86 end
87
88 def directory=(directory)
89 if !directory.nil? && directory.type != 'VERSIONED_FOLDER'
90 raise ArgumentError, 'invalid directory'
91 end
92 @directory = directory
93 end
94 end
95
96 class VersionedEHRAccesss < VersionedObject
97
98 end
99
100 class EHRAccess < Locatable
101 attr_accessor :settings
102 attr_reader :scheme
103
104 def initialize(args = { })
105 super(args)
106 self.settings = args[:settings]
107 self.scheme = args[:scheme]
108 end
109
110 def scheme=(scheme)
111 if scheme.nil? || scheme.empty?
112 raise ArgumentError, 'scheme is mandatory'
113 end
114 @scheme = scheme
115 end
116 end
117
118 class VersionedEHRStatus < VersionedObject
119
120 end
121
122 class EHRStatus < Locatable
123 attr_reader :subject
124 attr_accessor :is_modifiable, :is_queryable, :other_details
125
126 def initialize(args = { })
127 super(args)
128 self.subject = args[:subject]
129 self.is_queryable = args[:is_queryable]
130 self.is_modifiable = args[:is_modifiable]
131 self.other_details = args[:other_details]
132 end
133
134 def subject=(subject)
135 raise ArgumentError, 'subject is mandatory' if subject.nil?
136 @subject = subject
137 end
138
139 def is_queryable?
140 return @is_queryable
141 end
142
143 def is_modifiable?
144 return @is_modifiable
145 end
146
147 def parent=(parent)
148 unless parent.nil?
149 raise ArgumentError, 'parent should be nil'
150 end
151 @parent = parent
152 end
153 end
154
155 class VersionedComposition < VersionedObject
156 def is_persistent?
157 return @all_versions.first.data.is_persistent?
158 end
159 end
160 end # of EHR
161 end # of RM
162end # of OpenEHR
Note: See TracBrowser for help on using the repository browser.