Class: HQMF::PopulationCriteria
- Inherits:
-
Object
- Object
- HQMF::PopulationCriteria
- Includes:
- Conversion::Utilities
- Defined in:
- lib/hqmf-model/population_criteria.rb
Overview
Represents an HQMF population criteria, also supports all the same methods as HQMF::Precondition
Direct Known Subclasses
Constant Summary collapse
- IPP =
'IPP'
- DENOM =
'DENOM'
- NUMER =
'NUMER'
- DENEXCEP =
'DENEXCEP'
- DENEX =
'DENEX'
- MSRPOPL =
'MSRPOPL'
- OBSERV =
'OBSERV'
- ALL_POPULATION_CODES =
[IPP, DENOM, NUMER, DENEXCEP, DENEX, MSRPOPL, OBSERV]
Instance Attribute Summary collapse
-
#hqmf_id ⇒ Object
readonly
Returns the value of attribute hqmf_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#preconditions ⇒ Object
readonly
Returns the value of attribute preconditions.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.from_json(id, json) ⇒ Object
Create a new population criteria from a JSON hash keyed off symbols.
Instance Method Summary collapse
- #base_json ⇒ Object
-
#conjunction? ⇒ Boolean
Return true of this precondition represents a conjunction with nested preconditions or false of this precondition is a reference to a data criteria.
-
#conjunction_code ⇒ String
Get the conjunction code, e.g.
-
#conjunction_code_with_negation ⇒ Object
Can’t have negation on population so this is the same as conjunction_code.
-
#initialize(id, hqmf_id, type, preconditions, title = '') ⇒ PopulationCriteria
constructor
Create a new population criteria.
- #referenced_data_criteria ⇒ Object
- #to_json ⇒ Object
Methods included from Conversion::Utilities
#build_hash, #check_equality, #json_array, #openstruct_to_json
Constructor Details
#initialize(id, hqmf_id, type, preconditions, title = '') ⇒ PopulationCriteria
Create a new population criteria
25 26 27 28 29 30 31 |
# File 'lib/hqmf-model/population_criteria.rb', line 25 def initialize(id, hqmf_id, type, preconditions, title='') @id = id @hqmf_id = hqmf_id @preconditions = preconditions @type = type @title=title end |
Instance Attribute Details
#hqmf_id ⇒ Object (readonly)
Returns the value of attribute hqmf_id.
8 9 10 |
# File 'lib/hqmf-model/population_criteria.rb', line 8 def hqmf_id @hqmf_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/hqmf-model/population_criteria.rb', line 8 def id @id end |
#preconditions ⇒ Object (readonly)
Returns the value of attribute preconditions.
8 9 10 |
# File 'lib/hqmf-model/population_criteria.rb', line 8 def preconditions @preconditions end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
8 9 10 |
# File 'lib/hqmf-model/population_criteria.rb', line 8 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/hqmf-model/population_criteria.rb', line 8 def type @type end |
Class Method Details
.from_json(id, json) ⇒ Object
Create a new population criteria from a JSON hash keyed off symbols
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hqmf-model/population_criteria.rb', line 34 def self.from_json(id, json) preconditions = json["preconditions"].map do |precondition| HQMF::Precondition.from_json(precondition) end if json['preconditions'] type = json["type"] title = json['title'] hqmf_id = json['hqmf_id'] HQMF::PopulationCriteria.new(id, hqmf_id, type, preconditions, title) end |
Instance Method Details
#base_json ⇒ Object
49 50 51 52 53 54 |
# File 'lib/hqmf-model/population_criteria.rb', line 49 def base_json x = nil json = build_hash(self, [:conjunction?, :type, :title, :hqmf_id]) json[:preconditions] = x if x = json_array(@preconditions) json end |
#conjunction? ⇒ Boolean
Return true of this precondition represents a conjunction with nested preconditions or false of this precondition is a reference to a data criteria
58 59 60 |
# File 'lib/hqmf-model/population_criteria.rb', line 58 def conjunction? true end |
#conjunction_code ⇒ String
Get the conjunction code, e.g. allTrue, atLeastOneTrue
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/hqmf-model/population_criteria.rb', line 64 def conjunction_code case @type when IPP, DENOM, NUMER, MSRPOPL HQMF::Precondition::ALL_TRUE when DENEXCEP, DENEX HQMF::Precondition::AT_LEAST_ONE_TRUE else raise "Unknown population type [#{@type}]" end end |
#conjunction_code_with_negation ⇒ Object
Can’t have negation on population so this is the same as conjunction_code
78 79 80 |
# File 'lib/hqmf-model/population_criteria.rb', line 78 def conjunction_code_with_negation conjunction_code end |
#referenced_data_criteria ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/hqmf-model/population_criteria.rb', line 82 def referenced_data_criteria data_criteria_ids = [] @preconditions.each do |precondition| data_criteria_ids.concat(precondition.referenced_data_criteria) end if @preconditions data_criteria_ids end |
#to_json ⇒ Object
45 46 47 |
# File 'lib/hqmf-model/population_criteria.rb', line 45 def to_json {self.id.to_sym => base_json} end |