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), NOT CONTAINS (parent matches survive only when the negated class is absent), and an EHR-level standardPredicate (e.g. "[ehr_id/value=$ehr_id]", reusing PathEvaluator/PredicateEvaluator's existing comparison machinery rather than new bespoke logic). standardPredicate/ nodePredicate filtering on non-EHR CONTAINS classes is added by a later engine milestone (see predicate_matches? below).

Instance Method Summary collapse

Constructor Details

#initialize(from_clause, dataset, params: {}) ⇒ ContainsResolver

Returns a new instance of ContainsResolver.



22
23
24
25
26
# File 'lib/openehr/aql/engine/contains_resolver.rb', line 22

def initialize(from_clause, dataset, params: {})
  @root = from_clause.containment
  @dataset = dataset
  @params = params
end

Instance Method Details

#each_bindingObject



28
29
30
31
32
33
34
35
36
# File 'lib/openehr/aql/engine/contains_resolver.rb', line 28

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