[4] | 1 |
|
---|
[372] | 2 | module OpenEHR
|
---|
[4] | 3 | module AM
|
---|
| 4 | module Archetype
|
---|
[372] | 5 | module ConstraintModel
|
---|
| 6 | class ArchetypeConstraint
|
---|
[373] | 7 | attr_reader :path
|
---|
| 8 | attr_accessor :parent
|
---|
[372] | 9 |
|
---|
[373] | 10 | def initialize(args = { })
|
---|
| 11 | self.path = args[:path]
|
---|
| 12 | self.parent = args[:parent]
|
---|
| 13 | end
|
---|
| 14 |
|
---|
| 15 | def path=(path)
|
---|
| 16 | if path.nil?
|
---|
| 17 | raise ArgumentError, 'path is mandatory'
|
---|
| 18 | end
|
---|
| 19 | @path = path
|
---|
| 20 | end
|
---|
| 21 |
|
---|
| 22 | def has_path?(path)
|
---|
| 23 | return @path.include?(path)
|
---|
| 24 | end
|
---|
| 25 |
|
---|
| 26 | def congruent?
|
---|
| 27 | if @path.index(@parent.path) == 0
|
---|
| 28 | return true
|
---|
| 29 | else
|
---|
| 30 | return false
|
---|
| 31 | end
|
---|
| 32 | end
|
---|
| 33 |
|
---|
| 34 | alias is_congruent? congruent?
|
---|
| 35 |
|
---|
| 36 | def node_conforms_to?(other)
|
---|
| 37 | if @path.index(other.path) == 0
|
---|
| 38 | return true
|
---|
| 39 | else
|
---|
| 40 | return false
|
---|
| 41 | end
|
---|
| 42 | end
|
---|
[4] | 43 | end
|
---|
[21] | 44 |
|
---|
[372] | 45 | class Cardinality
|
---|
[35] | 46 | attr_accessor :interval, :is_ordered, :is_unique
|
---|
| 47 |
|
---|
| 48 | def initialize(args = { })
|
---|
| 49 | @interval = args[:interval]
|
---|
| 50 | @is_ordered = args[:is_ordered]
|
---|
| 51 | @is_unique = args[:is_unique]
|
---|
| 52 | end
|
---|
[21] | 53 | end
|
---|
| 54 |
|
---|
[372] | 55 | class CObject < ArchetypeConstraint
|
---|
[23] | 56 | attr_accessor :node_id, :occurrences, :rm_type_name
|
---|
| 57 |
|
---|
| 58 | def initialize(args = { })
|
---|
| 59 | @node_id = args[:node_id] if args[:node_id]
|
---|
| 60 | @occurrences = args[:occurrences] if args[:occurrences]
|
---|
| 61 | @rm_type_name = args[:rm_type_name] if args[:rm_type_name]
|
---|
| 62 | end
|
---|
[32] | 63 |
|
---|
| 64 | def self.create(args = { }, &block)
|
---|
| 65 | c_object = new(args)
|
---|
| 66 | if block_given?
|
---|
| 67 | yield c_object
|
---|
| 68 | end
|
---|
| 69 | return c_object
|
---|
| 70 | end
|
---|
[23] | 71 | end
|
---|
| 72 |
|
---|
[372] | 73 | class CAttribute < ArchetypeConstraint
|
---|
[23] | 74 | attr_accessor :rm_attribute_name, :existence, :children
|
---|
| 75 |
|
---|
| 76 | def initialize(args = { })
|
---|
| 77 | @rm_attribute_name = args[:rm_attribute_name] if args[:rm_attribute_name]
|
---|
| 78 | @existence = args[:existence] if args[:existence]
|
---|
| 79 | @children = args[:children] ? args[:children] : []
|
---|
| 80 |
|
---|
| 81 | end
|
---|
[21] | 82 | end
|
---|
| 83 |
|
---|
[372] | 84 | class CDefinedObject < CObject
|
---|
[23] | 85 | attr_accessor :assumed_value
|
---|
[21] | 86 |
|
---|
[23] | 87 | def initialize(args = { })
|
---|
| 88 | @assumed_value = args[:assumed_value] if args[:assumed_value]
|
---|
| 89 | super
|
---|
| 90 | end
|
---|
[21] | 91 | end
|
---|
| 92 |
|
---|
[372] | 93 | class CPrimitiveObject < CDefinedObject
|
---|
[23] | 94 | attr_accessor :item
|
---|
[32] | 95 |
|
---|
[23] | 96 | def initialize(args = { })
|
---|
| 97 | @attributes = args[:item] if args[:item]
|
---|
| 98 | super
|
---|
| 99 | end
|
---|
[21] | 100 | end
|
---|
| 101 |
|
---|
[372] | 102 | class CComplexObject < CDefinedObject
|
---|
[21] | 103 | attr_accessor :attributes, :attributes_valid
|
---|
[32] | 104 |
|
---|
[23] | 105 | def initialize(args = { })
|
---|
| 106 | @attributes = args[:attributes] ? args[:attributes] : []
|
---|
| 107 | super
|
---|
| 108 | end
|
---|
| 109 |
|
---|
| 110 | def self.create(args = { }, &block)
|
---|
| 111 | c_complex_object = new(args)
|
---|
| 112 | if block_given?
|
---|
| 113 | yield c_complex_object
|
---|
| 114 | end
|
---|
| 115 | return c_complex_object
|
---|
| 116 | end
|
---|
[21] | 117 | end
|
---|
| 118 |
|
---|
[372] | 119 | class CDomainType < CDefinedObject
|
---|
[21] | 120 |
|
---|
| 121 | end
|
---|
| 122 |
|
---|
[372] | 123 | class CReferenceObject < CObject
|
---|
[21] | 124 | end
|
---|
| 125 |
|
---|
[372] | 126 | class ArchetypeInternalRef < CReferenceObject
|
---|
[32] | 127 | attr_accessor :target_path
|
---|
[21] | 128 | end
|
---|
| 129 |
|
---|
[372] | 130 | class ArchetypeSlot < CReferenceObject
|
---|
[32] | 131 | attr_accessor :includes, :excludes
|
---|
| 132 |
|
---|
| 133 | def self.create(args = { }, &block)
|
---|
| 134 | archetype_slot = new(args)
|
---|
| 135 | archetype_slot.includes = args[:includes]
|
---|
| 136 | archetype_slot.excludes = args[:excludes]
|
---|
| 137 | if block_given?
|
---|
| 138 | yield archetype_slot
|
---|
| 139 | end
|
---|
| 140 | return archetype_slot
|
---|
| 141 | end
|
---|
[21] | 142 | end
|
---|
| 143 |
|
---|
[372] | 144 | class ConstantRef < CReferenceObject
|
---|
[32] | 145 | attr_accessor :reference
|
---|
| 146 |
|
---|
| 147 | def self.create(args = { }, &block)
|
---|
| 148 | constraint_ref = new(args)
|
---|
| 149 | constraint_ref.reference = args[:reference]
|
---|
| 150 | if block_given?
|
---|
| 151 | yield constraint_ref
|
---|
| 152 | end
|
---|
| 153 | return constraint_ref
|
---|
| 154 | end
|
---|
[21] | 155 | end
|
---|
| 156 |
|
---|
[372] | 157 | class CSingleAttribute < CAttribute
|
---|
[23] | 158 | attr_accessor :alternatives
|
---|
| 159 |
|
---|
| 160 | def initialize(args = { })
|
---|
| 161 | @alternatives = args[:alternatives] ? args[:alternatives] : []
|
---|
| 162 | super
|
---|
| 163 | end
|
---|
| 164 | end
|
---|
| 165 |
|
---|
[372] | 166 | class CMultipleAttribute < CAttribute
|
---|
[23] | 167 | attr_accessor :members, :cardinality
|
---|
| 168 |
|
---|
| 169 | def initialize(args = { })
|
---|
| 170 | @members = args[:members] ? args[:members] : []
|
---|
| 171 | @cardinality = args[:cardinality] if args[:cardinality]
|
---|
| 172 | super
|
---|
| 173 | end
|
---|
| 174 | end
|
---|
[4] | 175 | end
|
---|
| 176 | end
|
---|
| 177 | end
|
---|
| 178 | end
|
---|
| 179 |
|
---|