lib/hqmf-model/population_criteria.rb in health-data-standards-3.4.6 vs lib/hqmf-model/population_criteria.rb in health-data-standards-3.5.0

- old
+ new

@@ -3,35 +3,38 @@ # HQMF::Precondition class PopulationCriteria include HQMF::Conversion::Utilities - attr_reader :preconditions, :id, :type, :title, :hqmf_id + attr_reader :preconditions, :id, :type, :title, :hqmf_id, :comments attr_accessor :aggregator IPP = 'IPP' DENOM = 'DENOM' NUMER = 'NUMER' DENEXCEP = 'DENEXCEP' DENEX = 'DENEX' MSRPOPL = 'MSRPOPL' OBSERV = 'OBSERV' + + STRAT = 'STRAT' - ALL_POPULATION_CODES = [IPP, DENOM, DENEX, NUMER, DENEXCEP, MSRPOPL, OBSERV] + ALL_POPULATION_CODES = [STRAT, IPP, DENOM, DENEX, NUMER, DENEXCEP, MSRPOPL, OBSERV] # Create a new population criteria # @param [String] id # @param [String] hqmf_id # @param [Array#Precondition] preconditions # @param [String] title (optional) - def initialize(id, hqmf_id, type, preconditions, title='', aggregator=nil) + def initialize(id, hqmf_id, type, preconditions, title='', aggregator=nil, comments=nil) @id = id @hqmf_id = hqmf_id @preconditions = preconditions @type = type @title = title @aggregator = aggregator + @comments = comments end # Create a new population criteria from a JSON hash keyed off symbols def self.from_json(id, json) preconditions = json["preconditions"].map do |precondition| @@ -39,21 +42,22 @@ end if json['preconditions'] type = json["type"] title = json['title'] hqmf_id = json['hqmf_id'] aggregator = json['aggregator'] + comments = json['comments'] - HQMF::PopulationCriteria.new(id, hqmf_id, type, preconditions, title, aggregator) + HQMF::PopulationCriteria.new(id, hqmf_id, type, preconditions, title, aggregator, comments) end def to_json {self.id.to_sym => base_json} end def base_json x = nil - json = build_hash(self, [:conjunction?, :type, :title, :hqmf_id, :aggregator]) + json = build_hash(self, [:conjunction?, :type, :title, :hqmf_id, :aggregator, :comments]) json[:preconditions] = x if x = json_array(@preconditions) json end # Return true of this precondition represents a conjunction with nested preconditions @@ -66,11 +70,11 @@ # Get the conjunction code, e.g. allTrue, atLeastOneTrue # @return [String] conjunction code def conjunction_code case @type - when IPP, DENOM, NUMER, MSRPOPL + when IPP, STRAT, DENOM, NUMER, MSRPOPL HQMF::Precondition::ALL_TRUE when DENEXCEP, DENEX HQMF::Precondition::AT_LEAST_ONE_TRUE else raise "Unknown population type [#{@type}]" @@ -91,6 +95,6 @@ data_criteria_ids end end -end \ No newline at end of file +end