Class: OpenEHR::AQL::Dataset

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

Defined Under Namespace

Classes: EHRRecord

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ehrs:) ⇒ Dataset

Returns a new instance of Dataset.



55
56
57
# File 'lib/openehr/aql/engine/dataset.rb', line 55

def initialize(ehrs:)
  @ehrs = ehrs
end

Class Method Details

.of_compositions(compositions, ehr_id: nil) ⇒ Object



38
39
40
# File 'lib/openehr/aql/engine/dataset.rb', line 38

def self.of_compositions(compositions, ehr_id: nil)
  new(ehrs: [{ ehr_id: ehr_id, compositions: compositions }])
end

.wrap(source) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/openehr/aql/engine/dataset.rb', line 42

def self.wrap(source)
  return source if source.is_a?(Dataset)

  unless source.is_a?(Enumerable)
    raise DatasetError, "cannot build a Dataset from a #{source.class} (expected a Dataset or an Enumerable)"
  end

  first, rest = source.first, source
  return of_compositions(rest) if first.is_a?(OpenEHR::RM::Common::Archetyped::Pathable)

  new(ehrs: rest)
end

Instance Method Details

#each_ehrObject



59
60
61
62
63
# File 'lib/openehr/aql/engine/dataset.rb', line 59

def each_ehr
  return enum_for(:each_ehr) unless block_given?

  @ehrs.each { |element| yield normalize(element) }
end