Sha256: 1fc55b195127063498d8bcab19af54b005d17c283601b763c62cd5d753fe3d23

Contents?: true

Size: 1.67 KB

Versions: 30

Compression:

Stored size: 1.67 KB

Contents

module HQMF2
  # Represents an HQMF population criteria, also supports all the same methods as
  # HQMF2::Precondition
  class PopulationCriteria
  
    include HQMF2::Utilities
    
    attr_reader :preconditions, :id, :hqmf_id, :title, :type
    
    # Create a new population criteria from the supplied HQMF entry
    # @param [Nokogiri::XML::Element] the HQMF entry
    def initialize(entry, doc)
      @doc = doc
      @entry = entry
      @hqmf_id = attr_val('./*/cda:id/@extension')
      @title = attr_val('./*/cda:code/cda:displayName/@value') 
      @type = attr_val('./*/cda:code/@code')
      @preconditions = @entry.xpath('./*/cda:precondition[not(@nullFlavor)]', HQMF2::Document::NAMESPACES).collect do |precondition|
        Precondition.new(precondition, @doc)
      end
    end
    
    def create_human_readable_id(id)
      @id = id
    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?
      true
    end

    # Get the conjunction code, e.g. allTrue, allFalse
    # @return [String] conjunction code
    def conjunction_code
      case @type
      when HQMF::PopulationCriteria::IPP, HQMF::PopulationCriteria::DENOM, HQMF::PopulationCriteria::NUMER
        HQMF::Precondition::ALL_TRUE
      when HQMF::PopulationCriteria::DENEXCEP, HQMF::PopulationCriteria::DENEX
        HQMF::Precondition::AT_LEAST_ONE_TRUE
      else
        raise "Unknown population type [#{@type}]"
      end
    end
    
    def to_model
      mps = preconditions.collect {|p| p.to_model}
      HQMF::PopulationCriteria.new(id, hqmf_id, type, mps, title)
    end

  end
  
end

Version data entries

30 entries across 30 versions & 2 rubygems

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