Class: HQMF1::PopulationCriteria

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

Overview

Represents an HQMF population criteria

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Parameters:

  • the (Nokogiri::XML::Element)

    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

#docObject (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

#entryObject (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_idObject

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

#idString

Get the id for the population criteria, used elsewhere in the HQMF document to refer to this criteria

Returns:

  • (String)

    the id



41
42
43
# File 'lib/hqmf-parser/1.0/population_criteria.rb', line 41

def id
  @id
end

#preconditionsObject (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_idObject

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

#codeString

Get the code for the population criteria

Returns:

  • (String)

    the code (e.g. IPP, DEMON, NUMER, DENEX, DENEXCEP)



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

#referenceObject



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

#titleObject



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_jsonObject



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