lib/hqmf-parser/2.0/population_criteria.rb in health-data-standards-3.4.6 vs lib/hqmf-parser/2.0/population_criteria.rb in health-data-standards-3.5.0
- old
+ new
@@ -3,20 +3,32 @@
# HQMF2::Precondition
class PopulationCriteria
include HQMF2::Utilities
- attr_reader :preconditions, :id, :hqmf_id, :title, :type
-
+ attr_reader :preconditions, :id, :hqmf_id, :title, :aggregator, :comments
+ #need to do this to allow for setting the type to OBSERV for
+ attr_accessor :type
# Create a new population criteria from the supplied HQMF entry
# @param [Nokogiri::XML::Element] the HQMF entry
def initialize(entry, doc)
@doc = doc
@entry = entry
- @hqmf_id = attr_val('./*/cda:id/@extension')
+ @hqmf_id = attr_val('./*/cda:id/@extension') || attr_val('./*/cda:typeId/@extension')
@title = attr_val('./*/cda:code/cda:displayName/@value')
@type = attr_val('./*/cda:code/@code')
+ @aggregator = nil
+ @comments = @entry.xpath("./*/cda:text/cda:xml/cda:qdmUserComments/cda:item/text()", HQMF2::Document::NAMESPACES)
+ .map{ |v| v.content }
+ obs_test = attr_val('./cda:measureObservationDefinition/@classCode')
+ if !@title && obs_test.to_s == "OBS"
+ @title = attr_val('../cda:code/cda:displayName/@value')
+ @aggregator = attr_val('./cda:measureObservationDefinition/cda:methodCode/cda:item/@code')
+ end
+ if(!@hqmf_id) # The id extension is not required, if it's not provided use the code
+ @hqmf_id = @type
+ end
@preconditions = @entry.xpath('./*/cda:precondition[not(@nullFlavor)]', HQMF2::Document::NAMESPACES).collect do |precondition|
Precondition.new(precondition, @doc)
end
end
@@ -32,22 +44,22 @@
# Get the conjunction code, e.g. allTrue, allFalse
# @return [String] conjunction code
def conjunction_code
case @type
- when HQMF::PopulationCriteria::IPP, HQMF::PopulationCriteria::DENOM, HQMF::PopulationCriteria::NUMER
+ when HQMF::PopulationCriteria::IPP, HQMF::PopulationCriteria::DENOM, HQMF::PopulationCriteria::NUMER,HQMF::PopulationCriteria::MSRPOPL
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
def to_model
mps = preconditions.collect {|p| p.to_model}
- HQMF::PopulationCriteria.new(id, hqmf_id, type, mps, title)
+ HQMF::PopulationCriteria.new(id, hqmf_id, type, mps, title, aggregator, comments)
end
end
-end
\ No newline at end of file
+end