Class: OpenEHR::RM::DataStructures::ItemStructure::ItemTable
Constant Summary
Common::Archetyped::LocaterConstants::CONTENT_PATH_SEPARATOR, Common::Archetyped::LocaterConstants::CURRENT_TRANSACTION_ID, Common::Archetyped::LocaterConstants::FRAGMENT_SEPARATOR, Common::Archetyped::LocaterConstants::MULTIPART_ID_DELIMITER, Common::Archetyped::LocaterConstants::ORGANIZER_PATH_SEPARATOR
Instance Attribute Summary collapse
#archetype_details, #archetype_node_id, #feeder_audit, #links, #name, #uid
#parent
Instance Method Summary
collapse
#concept, #is_archetype_root?
#item_at_path, #items_at_path, #path_exists?, #path_of_item, #path_unique?
Constructor Details
#initialize(args = {}) ⇒ ItemTable
Returns a new instance of ItemTable.
77
78
79
80
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 77
def initialize(args = {})
super(args)
self.rows = args[:rows]
end
|
Instance Attribute Details
#rows ⇒ Object
Returns the value of attribute rows.
75
76
77
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 75
def rows
@rows
end
|
Instance Method Details
#as_hierarchy ⇒ Object
179
180
181
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 179
def as_hierarchy
return @rows[0]
end
|
#column_count ⇒ Object
90
91
92
93
94
95
96
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 90
def column_count
if @rows.nil?
return 0
else
return @rows[0].items.count
end
end
|
#column_names ⇒ Object
106
107
108
109
110
111
112
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 106
def column_names
if @rows.nil?
return []
else
return @rows[0].items.collect{|i| i.name}
end
end
|
#element_at_cell_ij(i, j) ⇒ Object
162
163
164
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 162
def element_at_cell_ij(i,j)
return @rows[i-1].items[j-1]
end
|
#element_at_named_cell(row_key, column_key) ⇒ Object
166
167
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 166
def element_at_named_cell(row_key, column_key)
i,j=0,0
@rows[0].items.each do |c|
break if c.name.value == column_key
i+=1
end
@rows.each do |row|
break if row.name.value == row_key
j+=1
end
return element_at_cell_ij(i,j)
end
|
#has_column_with_name?(key) ⇒ Boolean
127
128
129
130
131
132
133
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 127
def has_column_with_name?(key)
raise ArgumentError, 'invalid argument' if key.nil? or key.empty?
self.column_names.each do |name|
return true if name.value == key
end
return false
end
|
#has_row_with_key?(keys) ⇒ Boolean
142
143
144
145
146
147
148
149
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 142
def has_row_with_key?(keys)
keys.each do |key|
@rows.each do |row|
return true if row.items[0].name.value == key
end
end
return false
end
|
#has_row_with_name?(key) ⇒ Boolean
119
120
121
122
123
124
125
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 119
def has_row_with_name?(key)
raise ArgumentError, 'invalid argument' if key.nil? or key.empty?
@rows.each do |row|
return true if row.items[0].name.value == key
end
return false
end
|
#ith_row(i) ⇒ Object
114
115
116
117
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 114
def ith_row(i)
raise ArgumentError, 'invalid index' if i<=0 or i>@rows.size
return @rows[i - 1]
end
|
#named_row(key) ⇒ Object
135
136
137
138
139
140
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 135
def named_row(key)
raise ArgumentError, 'invalid argument' unless has_row_with_name?(key)
@rows.each do |row|
return row if row.items[0].name.value == key
end
end
|
#row_count ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 82
def row_count
if @rows.nil?
return 0
else
return @rows.size
end
end
|
#row_names ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 98
def row_names
if @rows.nil?
return []
else
return @rows.collect{|r| r.name}
end
end
|
#row_with_key(keys) ⇒ Object
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 151
def row_with_key(keys)
unless has_row_with_key?(keys)
raise ArgumentError, 'no row for key'
end
keys.each do |key|
@rows.each do |row|
return row if row.items[0].name.value == key
end
end
end
|