Sha256: 3046a77ba177ae04b87cd3058bc38753a1eb8218d16edc017c51d9b24228905e

Contents?: true

Size: 1.19 KB

Versions: 34

Compression:

Stored size: 1.19 KB

Contents

module HQMF2
  
  class Precondition
  
    include HQMF2::Utilities
    
    attr_reader :preconditions, :reference
  
    def initialize(entry, doc)
      @doc = doc
      @entry = entry
      @preconditions = @entry.xpath('./*/cda:precondition', HQMF2::Document::NAMESPACES).collect do |precondition|
        Precondition.new(precondition, @doc)
      end
      reference_def = @entry.at_xpath('./*/cda:id', HQMF2::Document::NAMESPACES)
      if reference_def
        @reference = Reference.new(reference_def)
      end
    end
    
    # Return true of this precondition represents a conjunction with nested preconditions
    # or false of this precondition is a reference to a data criteria
    def conjunction?
      @preconditions.length>0
    end
    
    # Get the conjunction code, e.g. allTrue, allFalse
    # @return [String] conjunction code
    def conjunction_code
      if conjunction?
        @entry.at_xpath('./*[1]', HQMF2::Document::NAMESPACES).name
      else
        nil
      end
    end
    
    def to_model
      pcs = preconditions.collect {|p| p.to_model}
      mr = reference ? reference.to_model : nil
      HQMF::Precondition.new(nil, pcs, mr, conjunction_code, false)
    end
  end
    
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
health-data-standards-3.4.6 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.4.5 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.4.4 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.4.3 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.4.2 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.4.1 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.4.0 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.12 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.3.0 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.11 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.10 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.8 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.7 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.6 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.5 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.4 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.3 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.2 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.1 lib/hqmf-parser/2.0/precondition.rb
health-data-standards-3.2.0 lib/hqmf-parser/2.0/precondition.rb