Class: OpenEHR::AQL::ContainsResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/openehr/aql/engine/contains_resolver.rb

Overview

Walks a FromClause's containment tree against a Dataset, producing one Binding per match.

An EHR root variable (bound to the Dataset::EHRRecord itself - not an OpenEHR::RM::EHR::EHR - since a Dataset element doesn't have to carry one; see Dataset's own header comment), a right-recursive CONTAINS chain searching a matched Locatable's entire subtree (any depth, via Pathable#path_children) for the next class, archetype-predicate filtering, AND/OR-grouped sibling branches (cross-product / union of each branch's matches) and NOT CONTAINS (parent matches survive only when the negated class is absent). standardPredicate/nodePredicate filtering and an EHR-level predicate (e.g. "[ehr_id/value=$ehr_id]") are added by a later engine milestone.

Instance Method Summary collapse

Constructor Details

#initialize(from_clause, dataset) ⇒ ContainsResolver

Returns a new instance of ContainsResolver.



20
21
22
23
# File 'lib/openehr/aql/engine/contains_resolver.rb', line 20

def initialize(from_clause, dataset)
  @root = from_clause.containment
  @dataset = dataset
end

Instance Method Details

#each_bindingObject



25
26
27
28
29
30
31
32
33
# File 'lib/openehr/aql/engine/contains_resolver.rb', line 25

def each_binding
  return enum_for(:each_binding) unless block_given?

  @dataset.each_ehr do |ehr_record|
    resolve(@root, ehr_record, ehr_record.compositions).each do |variables, _bound|
      yield Binding.new(ehr_record: ehr_record, variables: variables)
    end
  end
end