Class: OpenehrRails::Aql::DatasetAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/openehr_rails/aql/dataset_adapter.rb

Overview

Builds an OpenEHR::AQL::Dataset (the AQL engine's only input boundary) out of the RM graph. Feeds it real OpenEHR::RM objects via Rm::Composition#to_rm (RmObjectBuilder) rather than the rm_composition JSON cache, because OpenEHR::RM::CompositionFactory.create_from_json does not recursively convert array-valued attributes (content/events/ items) into RM objects -- see doc/HANDOFF_openehr_aql_create_from_json.md and spec/openehr_rails/rm/create_from_json_roundtrip_spec.rb.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ehr_scope:, composition_scope:) ⇒ DatasetAdapter

Returns a new instance of DatasetAdapter.



19
20
21
22
# File 'lib/openehr_rails/aql/dataset_adapter.rb', line 19

def initialize(ehr_scope:, composition_scope:)
  @ehr_scope = ehr_scope
  @composition_scope = composition_scope
end

Class Method Details

.build(ehr_scope: OpenehrRails::Rm::Ehr.all, composition_scope: OpenehrRails::Rm::Composition.latest) ⇒ Object



15
16
17
# File 'lib/openehr_rails/aql/dataset_adapter.rb', line 15

def self.build(ehr_scope: OpenehrRails::Rm::Ehr.all, composition_scope: OpenehrRails::Rm::Composition.latest)
  new(ehr_scope: ehr_scope, composition_scope: composition_scope).call
end

Instance Method Details

#callObject

Dataset.new never iterates eagerly, so this stays lazy end to end: constructing it issues no queries; each Enumerator::Lazy chain below only runs when the caller actually walks #each_ehr.



27
28
29
# File 'lib/openehr_rails/aql/dataset_adapter.rb', line 27

def call
  OpenEHR::AQL::Dataset.new(ehrs: ehr_records)
end