Class: HQMF1::PopulationCriteria
- Inherits:
-
Object
- Object
- HQMF1::PopulationCriteria
- Includes:
- Utilities
- Defined in:
- lib/hqmf-parser/1.0/population_criteria.rb
Overview
Represents an HQMF population criteria
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#hqmf_id ⇒ Object
Returns the value of attribute hqmf_id.
-
#id ⇒ String
Get the id for the population criteria, used elsewhere in the HQMF document to refer to this criteria.
-
#preconditions ⇒ Object
readonly
Returns the value of attribute preconditions.
-
#stratification_id ⇒ Object
Returns the value of attribute stratification_id.
Instance Method Summary collapse
-
#code ⇒ String
Get the code for the population criteria.
-
#initialize(entry, doc) ⇒ PopulationCriteria
constructor
Create a new population criteria from the supplied HQMF entry.
- #reference ⇒ Object
- #title ⇒ Object
- #to_json ⇒ Object
Methods included from Utilities
#attr_val, #check_nil_conjunction_on_child, #clean_json, #clean_json_recursive
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 22 23 24 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 12 def initialize(entry, doc) @doc = doc @entry = entry @id = attr_val('cda:observation/cda:id/@root').upcase @preconditions = @entry.xpath('./*/cda:sourceOf[@typeCode="PRCN"]').collect do |entry| pc = Precondition.new(entry, nil, @doc) if pc.preconditions.length==0 && !pc.comparison && pc.restrictions.length==0 nil else pc end end.compact end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
7 8 9 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 7 def doc @doc end |
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
7 8 9 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 7 def entry @entry end |
#hqmf_id ⇒ Object
Returns the value of attribute hqmf_id.
8 9 10 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 8 def hqmf_id @hqmf_id end |
#id ⇒ String
Get the id for the population criteria, used elsewhere in the HQMF document to refer to this criteria
41 42 43 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 41 def id @id end |
#preconditions ⇒ Object (readonly)
Returns the value of attribute preconditions.
7 8 9 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 7 def preconditions @preconditions end |
#stratification_id ⇒ Object
Returns the value of attribute stratification_id.
8 9 10 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 8 def stratification_id @stratification_id end |
Instance Method Details
#code ⇒ String
Get the code for the population criteria
28 29 30 31 32 33 34 35 36 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 28 def code value = attr_val('cda:observation/cda:value/@code') || HQMF::PopulationCriteria::STRAT # exclusion population criteria has id of DENOM with actionNegationInd of true # special case this to simply handling if attr_val('cda:observation/@actionNegationInd')=='true' && value == HQMF::PopulationCriteria::DENOM value = HQMF::PopulationCriteria::DENEX end value.upcase end |
#reference ⇒ Object
49 50 51 52 53 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 49 def reference reference = attr_val('./cda:observation/cda:sourceOf[@typeCode="PRCN"]/cda:observation[@classCode="OBS"]/cda:id/@root') reference = reference.upcase if reference reference end |
#title ⇒ Object
45 46 47 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 45 def title attr_val('cda:observation/cda:value/@displayName') end |
#to_json ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 55 def to_json json = {} self.preconditions.compact.each do |precondition| json[:preconditions] ||= [] json[:preconditions] << precondition.to_json end json[:id] = id json[:title] = title json[:code] = code json[:hqmf_id] = hqmf_id if hqmf_id json[:stratification_id] = stratification_id if stratification_id json[:reference] = reference {self.code => json} end |