lib/hqmf-model/precondition.rb in health-data-standards-3.6.1 vs lib/hqmf-model/precondition.rb in health-data-standards-3.7.0

- old
+ new

@@ -20,22 +20,23 @@ ALL_TRUE => AT_LEAST_ONE_TRUE, AT_LEAST_ONE_FALSE => ALL_FALSE } attr_reader :id, :preconditions, :reference, :conjunction_code - attr_accessor :negation + attr_accessor :negation, :comments # Create a new population criteria # @param [Array#Precondition] preconditions # @param [Reference] reference # @param [String] conjunction_code - def initialize(id, preconditions, reference, conjunction_code, negation) + def initialize(id, preconditions, reference, conjunction_code, negation, comments=nil) @preconditions = preconditions || [] @reference = reference @conjunction_code = conjunction_code @negation = negation @id = id + @comments = comments end def conjunction_code_with_negation if negation NEGATIONS[conjunction_code] @@ -50,21 +51,23 @@ id = json["id"] if json["id"] preconditions = json["preconditions"].map {|precondition| HQMF::Precondition.from_json(precondition)} if json["preconditions"] reference = Reference.new(json["reference"]) if json["reference"] conjunction_code = json["conjunction_code"] if json["conjunction_code"] negation = json["negation"] if json["negation"] + comments = json['comments'] if json['comments'] - HQMF::Precondition.new(id, preconditions, reference, conjunction_code, negation) + HQMF::Precondition.new(id, preconditions, reference, conjunction_code, negation, comments) end def to_json x = nil json = {} json[:id] = self.id json[:reference] = self.reference.id if self.reference json[:preconditions] = x if x = json_array(@preconditions) json[:conjunction_code] = self.conjunction_code if self.conjunction_code && self.preconditions.length > 0 json[:negation] = self.negation if self.negation + json[:comments] = self.comments if self.comments json end # Return true of this precondition represents a conjunction with nested preconditions # or false of this precondition is a reference to a data criteria \ No newline at end of file