class HQMF1::PopulationCriteria

Represents an HQMF population criteria

Attributes

doc[R]
entry[R]
hqmf_id[RW]
id[RW]
preconditions[R]
stratification_id[RW]

Public Class Methods

new(entry, doc) click to toggle source

Create a new population criteria from the supplied HQMF entry @param [Nokogiri::XML::Element] the HQMF entry

# 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

Public Instance Methods

code() click to toggle source

Get the code for the population criteria @return [String] the code (e.g. IPP, DEMON, NUMER, DENEX, DENEXCEP)

# 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() click to toggle source
# 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() click to toggle source
# File lib/hqmf-parser/1.0/population_criteria.rb, line 45
def title
  attr_val('cda:observation/cda:value/@displayName')
end
to_json() click to toggle source
# 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