Class: HQMF2::PopulationCriteria

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/hqmf-parser/2.0/population_criteria.rb

Overview

Represents an HQMF population criteria, also supports all the same methods as HQMF2::Precondition

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#attr_val, attr_val, #to_xml

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(entry, doc) ⇒ PopulationCriteria

Create a new population criteria from the supplied HQMF entry

Parameters:

  • the (Nokogiri::XML::Element)

    HQMF entry



12
13
14
15
16
17
18
19
20
21
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 12

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

Instance Attribute Details

#hqmf_idObject (readonly)

Returns the value of attribute hqmf_id.



8
9
10
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 8

def hqmf_id
  @hqmf_id
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 8

def id
  @id
end

#preconditionsObject (readonly)

Returns the value of attribute preconditions.



8
9
10
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 8

def preconditions
  @preconditions
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 8

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 8

def type
  @type
end

Instance Method Details

#conjunction?Boolean

Return true of this precondition represents a conjunction with nested preconditions or false of this precondition is a reference to a data criteria

Returns:

  • (Boolean)


29
30
31
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 29

def conjunction?
  true
end

#conjunction_codeString

Get the conjunction code, e.g. allTrue, allFalse

Returns:

  • (String)

    conjunction code



35
36
37
38
39
40
41
42
43
44
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 35

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

#create_human_readable_id(id) ⇒ Object



23
24
25
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 23

def create_human_readable_id(id)
  @id = id
end

#to_modelObject



46
47
48
49
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 46

def to_model
  mps = preconditions.collect {|p| p.to_model}
  HQMF::PopulationCriteria.new(id, hqmf_id, type, mps, title)
end