Class: OpenEHR::AM::Archetype::ConstraintModel::CObject

Inherits:
ArchetypeConstraint show all
Defined in:
lib/openehr/am/archetype/constraint_model.rb

Direct Known Subclasses

CDefinedObject, CReferenceObject

Instance Attribute Summary collapse

Attributes inherited from ArchetypeConstraint

#parent

Instance Method Summary collapse

Methods inherited from ArchetypeConstraint

#congruent?, #has_path?

Constructor Details

#initialize(args = { }) ⇒ CObject

Returns a new instance of CObject.



98
99
100
101
102
103
# File 'lib/openehr/am/archetype/constraint_model.rb', line 98

def initialize(args = { })
  super
  self.rm_type_name = args[:rm_type_name]
  self.node_id = args[:node_id]
  self.occurrences = args[:occurrences]
end

Instance Attribute Details

#node_idObject

Returns the value of attribute node_id.



96
97
98
# File 'lib/openehr/am/archetype/constraint_model.rb', line 96

def node_id
  @node_id
end

#occurrencesObject

Returns the value of attribute occurrences.



96
97
98
# File 'lib/openehr/am/archetype/constraint_model.rb', line 96

def occurrences
  @occurrences
end

#rm_type_nameObject

Returns the value of attribute rm_type_name.



96
97
98
# File 'lib/openehr/am/archetype/constraint_model.rb', line 96

def rm_type_name
  @rm_type_name
end

Instance Method Details

#node_conforms_to?(other) ⇒ Boolean

Whether this (potentially specialised) node is a legal redefinition of other, the corresponding node in the flat parent archetype: same node_id lineage (at0001.1 specialises at0001), same rm_type_name (subtype checking is deferred until the RM type-name helper lands), and occurrences no wider than the parent's.

Returns:

  • (Boolean)


140
141
142
143
144
145
146
# File 'lib/openehr/am/archetype/constraint_model.rb', line 140

def node_conforms_to?(other)
  return false if other.nil?

  node_id_conforms_to?(other.node_id) &&
    rm_type_name == other.rm_type_name &&
    interval_conforms_to?(occurrences, other.occurrences)
end

#pathObject



126
127
128
# File 'lib/openehr/am/archetype/constraint_model.rb', line 126

def path
  @path || calculate_path
end

#to_rmObject



130
131
132
# File 'lib/openehr/am/archetype/constraint_model.rb', line 130

def to_rm
  @rm ||= OpenEHR::RM::Factory.create(rm_type_name, params)
end