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 | 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
|
---|
15 |
|
---|
16 | class Pathable
|
---|
17 | attr_accessor :parent
|
---|
18 | def initialize(parent = nil)
|
---|
19 | @parent = parent
|
---|
20 | end
|
---|
21 | def item_at_path(path)
|
---|
22 | raise NotImplementError, "item_at_path must be implemented"
|
---|
23 | end
|
---|
24 | def items_at_path(path)
|
---|
25 | raise NotImplementError, "items_at_path must be implemented"
|
---|
26 | end
|
---|
27 | def path_exists?(path)
|
---|
28 | raise NotImplementError, "path_exists? must be implemented"
|
---|
29 | end
|
---|
30 | def path_of_item(item)
|
---|
31 | raise NotImplementError, "path_of_item must be implemented"
|
---|
32 | end
|
---|
33 | def path_unique(path)
|
---|
34 | raise NotImplementError, "path_unique must be implemented"
|
---|
35 | end
|
---|
36 | end
|
---|
37 |
|
---|
38 | class Locatable < Pathable
|
---|
39 | include Locater_Constants
|
---|
40 | attr_accessor :uid, :archetype_node_id, :archetype_details
|
---|
41 | attr_accessor :feeder_audit, :links, :parent
|
---|
42 | def initialize(uid, archetype_node_id, name, archetype_details,
|
---|
43 | feeder_audit, links, parent)
|
---|
44 | super(parent)
|
---|
45 | if archetype_node_id.nil?
|
---|
46 | raise ArgumentError, "null archetype_node_id"
|
---|
47 | end
|
---|
48 | if name.nil?
|
---|
49 | raise ArgumentError, "name is empty"
|
---|
50 | end
|
---|
51 | if links.nil?
|
---|
52 | raise ArgumentError, "links is empty"
|
---|
53 | end
|
---|
54 | @uid = uid
|
---|
55 | @archetype_node_id = archetype_node_id
|
---|
56 | @archetype_details = archetype_details
|
---|
57 | @feeder_audit = feeder_audit
|
---|
58 | @links = links
|
---|
59 | @parent = parent
|
---|
60 | end
|
---|
61 | def item_at_path(path)
|
---|
62 | if !@path.nil?
|
---|
63 | if @path == ""
|
---|
64 | raise ArgumentError, "path is not valid"
|
---|
65 | end
|
---|
66 | end
|
---|
67 | end
|
---|
68 | def items_at_path(path)
|
---|
69 | raise NotImplementError, "items_at_path must be implemented"
|
---|
70 | end
|
---|
71 | def path_exists?
|
---|
72 | raise NotImplementError, "path_exists? must be implemented"
|
---|
73 | end
|
---|
74 | def path_unique
|
---|
75 | raise NotImplementError, "path_unique must be implemented"
|
---|
76 | end
|
---|
77 | def concept
|
---|
78 | end
|
---|
79 | def is_archetype_root?
|
---|
80 | !archetype_details.nil?
|
---|
81 | end
|
---|
82 | end
|
---|
83 | class Archetyped
|
---|
84 | attr_reader :archetype_id, :rm_version
|
---|
85 | attr_accessor :template_id
|
---|
86 | def initialize(archetype_id, rm_version, template_id = nil)
|
---|
87 | self.archetype_id = archetype_id
|
---|
88 | self.rm_version = rm_version
|
---|
89 | @template_id = template_id
|
---|
90 | end
|
---|
91 | def archetype_id=(archetype_id)
|
---|
92 | raise ArgumentError, "invalid archetype_id" if archetype_id.nil?
|
---|
93 | @archetype_id = archetype_id
|
---|
94 | end
|
---|
95 | def rm_version=(rm_version)
|
---|
96 | raise ArgumentError, "invalid rm_version" if rm_version.nil? or rm_version.empty?
|
---|
97 | @rm_version = rm_version
|
---|
98 | end
|
---|
99 | end
|
---|
100 | end # end of Archetyped
|
---|
101 | end # end of Common
|
---|
102 | end # end of RM
|
---|
103 | end # end of OpenEHR
|
---|