[102] | 1 | # This module is based on the UML,
|
---|
| 2 | # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109318114715_211173_0Report.html
|
---|
| 3 | # Ticket refs #65
|
---|
[4] | 4 | module OpenEHR
|
---|
| 5 | module RM
|
---|
| 6 | module Common
|
---|
| 7 | module Archetyped
|
---|
| 8 | module Locater_Constants
|
---|
| 9 | CURRENT_TRANSACTION_ID = "current"
|
---|
| 10 | FRAGMENT_SEPARATOR = "#"
|
---|
| 11 | CONTENT_PATH_SEPARATOR = "|"
|
---|
| 12 | ORGANIZER_PATH_SEPARATOR = "/"
|
---|
| 13 | MULTIPART_ID_DELIMITER = "::"
|
---|
| 14 | end
|
---|
[102] | 15 |
|
---|
[4] | 16 | class Pathable
|
---|
[102] | 17 | attr_accessor :parent
|
---|
[128] | 18 |
|
---|
[102] | 19 | def initialize(parent = nil)
|
---|
[4] | 20 | @parent = parent
|
---|
| 21 | end
|
---|
[128] | 22 |
|
---|
[4] | 23 | def item_at_path(path)
|
---|
| 24 | raise NotImplementError, "item_at_path must be implemented"
|
---|
| 25 | end
|
---|
[128] | 26 |
|
---|
[4] | 27 | def items_at_path(path)
|
---|
| 28 | raise NotImplementError, "items_at_path must be implemented"
|
---|
| 29 | end
|
---|
[128] | 30 |
|
---|
[4] | 31 | def path_exists?(path)
|
---|
| 32 | raise NotImplementError, "path_exists? must be implemented"
|
---|
| 33 | end
|
---|
[128] | 34 |
|
---|
[4] | 35 | def path_of_item(item)
|
---|
| 36 | raise NotImplementError, "path_of_item must be implemented"
|
---|
| 37 | end
|
---|
[128] | 38 |
|
---|
[4] | 39 | def path_unique(path)
|
---|
| 40 | raise NotImplementError, "path_unique must be implemented"
|
---|
| 41 | end
|
---|
[7] | 42 | end
|
---|
[102] | 43 |
|
---|
[4] | 44 | class Locatable < Pathable
|
---|
| 45 | include Locater_Constants
|
---|
[110] | 46 | attr_reader :archetype_node_id, :name, :links
|
---|
| 47 | attr_accessor :uid, :archetype_details, :feeder_audit
|
---|
[128] | 48 |
|
---|
[110] | 49 | def initialize(archetype_node_id, name, links, parent=nil, uid=nil, archetype_details=nil, feeder_audit=nil)
|
---|
[4] | 50 | super(parent)
|
---|
[110] | 51 | self.archetype_node_id = archetype_node_id
|
---|
| 52 | self.name = name
|
---|
| 53 | self.links = links
|
---|
| 54 | self.uid = uid
|
---|
| 55 | self.archetype_details = archetype_details
|
---|
| 56 | self.feeder_audit = feeder_audit
|
---|
| 57 | self.parent = parent
|
---|
| 58 | end
|
---|
| 59 |
|
---|
| 60 | def archetype_node_id=(archetype_node_id)
|
---|
| 61 | raise ArgumentError, 'archetype_node_id should not be nil' if archetype_node_id.nil?
|
---|
[4] | 62 | @archetype_node_id = archetype_node_id
|
---|
[110] | 63 | end
|
---|
| 64 |
|
---|
| 65 | def name=(name)
|
---|
[112] | 66 | raise ArgumentError, 'name should not be empty' if name.nil? or name.value.empty?
|
---|
[110] | 67 | @name = name
|
---|
| 68 | end
|
---|
| 69 | def links=(links)
|
---|
[112] | 70 | raise ArgumentError, "links shoud not be empty" if !links.nil? and links.empty?
|
---|
[4] | 71 | @links = links
|
---|
| 72 | end
|
---|
| 73 | def item_at_path(path)
|
---|
[7] | 74 | if !@path.nil?
|
---|
| 75 | if @path == ""
|
---|
| 76 | raise ArgumentError, "path is not valid"
|
---|
| 77 | end
|
---|
| 78 | end
|
---|
[4] | 79 | end
|
---|
[7] | 80 | def items_at_path(path)
|
---|
[4] | 81 | raise NotImplementError, "items_at_path must be implemented"
|
---|
| 82 | end
|
---|
| 83 | def path_exists?
|
---|
| 84 | raise NotImplementError, "path_exists? must be implemented"
|
---|
| 85 | end
|
---|
| 86 | def path_unique
|
---|
| 87 | raise NotImplementError, "path_unique must be implemented"
|
---|
| 88 | end
|
---|
| 89 | def concept
|
---|
| 90 | end
|
---|
| 91 | def is_archetype_root?
|
---|
[7] | 92 | !archetype_details.nil?
|
---|
[4] | 93 | end
|
---|
| 94 | end
|
---|
[103] | 95 |
|
---|
[102] | 96 | class Archetyped
|
---|
| 97 | attr_reader :archetype_id, :rm_version
|
---|
| 98 | attr_accessor :template_id
|
---|
| 99 | def initialize(archetype_id, rm_version, template_id = nil)
|
---|
| 100 | self.archetype_id = archetype_id
|
---|
| 101 | self.rm_version = rm_version
|
---|
[110] | 102 | self.template_id = template_id
|
---|
[102] | 103 | end
|
---|
| 104 | def archetype_id=(archetype_id)
|
---|
| 105 | raise ArgumentError, "invalid archetype_id" if archetype_id.nil?
|
---|
| 106 | @archetype_id = archetype_id
|
---|
| 107 | end
|
---|
| 108 | def rm_version=(rm_version)
|
---|
| 109 | raise ArgumentError, "invalid rm_version" if rm_version.nil? or rm_version.empty?
|
---|
| 110 | @rm_version = rm_version
|
---|
| 111 | end
|
---|
| 112 | end
|
---|
[104] | 113 |
|
---|
[103] | 114 | class Link
|
---|
| 115 | attr_reader :meaning, :target, :type
|
---|
| 116 | def initialize(meaning, target, type)
|
---|
| 117 | self.meaning = meaning
|
---|
| 118 | self.target = target
|
---|
| 119 | self.type = type
|
---|
| 120 | end
|
---|
| 121 | def meaning=(meaning)
|
---|
| 122 | raise ArgumentError, "meaning should not be nil" if meaning.nil?
|
---|
| 123 | @meaning = meaning
|
---|
| 124 | end
|
---|
| 125 | def target=(target)
|
---|
| 126 | raise ArgumentError, "target should not be nil" if target.nil?
|
---|
| 127 | @target = target
|
---|
| 128 | end
|
---|
| 129 | def type=(type)
|
---|
| 130 | raise ArgumentError, "type should not be nil" if type.nil?
|
---|
| 131 | @type = type
|
---|
| 132 | end
|
---|
[110] | 133 | end # of Link
|
---|
[131] | 134 |
|
---|
| 135 | class Feeder_Audit
|
---|
| 136 |
|
---|
| 137 | end # of Feeder_Audit
|
---|
| 138 |
|
---|
| 139 | class Feeder_Audit_Details
|
---|
[153] | 140 | attr_reader :system_id
|
---|
[131] | 141 |
|
---|
[153] | 142 | def initialize(args ={ })
|
---|
| 143 | self.system_id = args[:system_id]
|
---|
| 144 | end
|
---|
| 145 |
|
---|
| 146 | def system_id=(system_id)
|
---|
| 147 | raise ArgumentError, 'system_id invalid' if system_id.nil? or system_id.empty?
|
---|
| 148 | @system_id = system_id
|
---|
| 149 | end
|
---|
[131] | 150 | end # of Feeder_Audit_Details
|
---|
[110] | 151 | end # of Archetyped
|
---|
| 152 | end # of Common
|
---|
| 153 | end # of RM
|
---|
| 154 | end # OpenEHR
|
---|