Rev | Line | |
---|
[190] | 1 | # rm::data_structures::item_structure
|
---|
| 2 | # ItemStructure module
|
---|
| 3 | # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109346709572_859750_3810Report.html
|
---|
| 4 | # refs #54
|
---|
| 5 | include OpenEhr::RM::DataStructures
|
---|
| 6 | module OpenEhr
|
---|
| 7 | module RM
|
---|
| 8 | module DataStructures
|
---|
| 9 | module ItemStructure
|
---|
| 10 | class ItemStructure < DataStructure
|
---|
| 11 | end
|
---|
| 12 |
|
---|
| 13 | class ItemSingle < ItemStructure
|
---|
| 14 | attr_reader :item
|
---|
| 15 |
|
---|
| 16 | def initialize(args = {})
|
---|
| 17 | super(args)
|
---|
| 18 | self.item = args[:item]
|
---|
| 19 | end
|
---|
| 20 |
|
---|
| 21 | def as_hierarchy
|
---|
| 22 | return @item
|
---|
| 23 | end
|
---|
| 24 |
|
---|
| 25 | def item=(item)
|
---|
| 26 | raise ArgumentError, 'item is mandatory' if item.nil?
|
---|
| 27 | @item = item
|
---|
| 28 | end
|
---|
| 29 | end
|
---|
[192] | 30 |
|
---|
| 31 | class ItemList < ItemStructure
|
---|
[194] | 32 | attr_accessor :items
|
---|
| 33 |
|
---|
[195] | 34 | def initialize(args = {})
|
---|
| 35 | super(args)
|
---|
| 36 | self.items = args[:items]
|
---|
| 37 | end
|
---|
| 38 |
|
---|
[194] | 39 | def item_count
|
---|
| 40 | unless @items.nil?
|
---|
| 41 | return @items.size
|
---|
| 42 | else
|
---|
| 43 | return 0
|
---|
| 44 | end
|
---|
| 45 | end
|
---|
[195] | 46 |
|
---|
| 47 | def names
|
---|
| 48 | return @items.collect{|item| item.name}
|
---|
| 49 | end
|
---|
| 50 |
|
---|
| 51 | def named_item(a_name)
|
---|
| 52 | @items.each do |item|
|
---|
| 53 | return item if item.name.value == a_name
|
---|
| 54 | end
|
---|
| 55 | retrun nil
|
---|
| 56 | end
|
---|
| 57 |
|
---|
| 58 | def ith_item(i)
|
---|
| 59 | return @items[i]
|
---|
| 60 | end
|
---|
| 61 |
|
---|
| 62 | def as_hierarchy
|
---|
| 63 | return Cluster.new(:name => @name,
|
---|
| 64 | :archetype_node_id => @archetype_node_id,
|
---|
| 65 | :items => @items)
|
---|
| 66 | end
|
---|
[192] | 67 | end
|
---|
[203] | 68 |
|
---|
[200] | 69 | class ItemTable < ItemStructure
|
---|
| 70 | attr_accessor :rows
|
---|
| 71 |
|
---|
[203] | 72 | def initialize(args = {})
|
---|
[200] | 73 | super(args)
|
---|
| 74 | self.rows = args[:rows]
|
---|
| 75 | end
|
---|
[203] | 76 |
|
---|
| 77 | def row_count
|
---|
| 78 | if @rows.nil?
|
---|
| 79 | return 0
|
---|
| 80 | else
|
---|
| 81 | return @rows.size
|
---|
| 82 | end
|
---|
| 83 | end
|
---|
[200] | 84 | end
|
---|
[190] | 85 | end # of ItemStructure
|
---|
| 86 | end # of DataStructures
|
---|
| 87 | end # of RM
|
---|
| 88 | end # of OpenEhr
|
---|
Note:
See
TracBrowser
for help on using the repository browser.