Class: HQMF2::PopulationCriteria
- Inherits:
-
Object
- Object
- HQMF2::PopulationCriteria
- 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
-
#hqmf_id ⇒ Object
readonly
Returns the value of attribute hqmf_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#preconditions ⇒ Object
readonly
Returns the value of attribute preconditions.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#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.
-
#conjunction_code ⇒ String
Get the conjunction code, e.g.
- #create_human_readable_id(id) ⇒ Object
-
#initialize(entry, doc) ⇒ PopulationCriteria
constructor
Create a new population criteria from the supplied HQMF entry.
- #to_model ⇒ Object
Methods included from Utilities
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
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_id ⇒ Object (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 |
#id ⇒ Object (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 |
#preconditions ⇒ Object (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 |
#title ⇒ Object (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 |
#type ⇒ Object (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
29 30 31 |
# File 'lib/hqmf-parser/2.0/population_criteria.rb', line 29 def conjunction? true end |
#conjunction_code ⇒ String
Get the conjunction code, e.g. allTrue, allFalse
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_model ⇒ Object
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 |