health-data-standards 3.4.6 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/README.md +4 -0
- data/lib/health-data-standards.rb +1 -0
- data/lib/health-data-standards/export/cat_1.rb +4 -4
- data/lib/health-data-standards/export/helper/scooped_view_helper.rb +16 -16
- data/lib/health-data-standards/export/qrda/hqmf-qrda-oids.json +6 -0
- data/lib/health-data-standards/export/view_helper.rb +8 -1
- data/lib/health-data-standards/import/bulk_record_importer.rb +45 -13
- data/lib/health-data-standards/import/bundle/importer.rb +2 -4
- data/lib/health-data-standards/import/cda/provider_importer.rb +2 -2
- data/lib/health-data-standards/import/green_c32/section_importer.rb +2 -2
- data/lib/health-data-standards/import/provider_import_utils.rb +2 -2
- data/lib/health-data-standards/models/cda_identifier.rb +1 -0
- data/lib/health-data-standards/models/cqm/bundle.rb +4 -1
- data/lib/health-data-standards/models/cqm/measure.rb +40 -25
- data/lib/health-data-standards/models/cqm/patient_cache.rb +61 -60
- data/lib/health-data-standards/models/encounter.rb +4 -12
- data/lib/health-data-standards/models/entry.rb +4 -8
- data/lib/health-data-standards/models/facility.rb +1 -0
- data/lib/health-data-standards/models/fulfillment_history.rb +6 -18
- data/lib/health-data-standards/models/guarantor.rb +1 -0
- data/lib/health-data-standards/models/lab_result.rb +2 -6
- data/lib/health-data-standards/models/medical_equipment.rb +2 -7
- data/lib/health-data-standards/models/medication.rb +11 -31
- data/lib/health-data-standards/models/metadata/link_info.rb +1 -0
- data/lib/health-data-standards/models/order_information.rb +5 -13
- data/lib/health-data-standards/models/organization.rb +1 -0
- data/lib/health-data-standards/models/procedure.rb +1 -4
- data/lib/health-data-standards/models/provider.rb +2 -1
- data/lib/health-data-standards/models/provider_performance.rb +1 -0
- data/lib/health-data-standards/models/qrda/legal_authenticator.rb +1 -0
- data/lib/health-data-standards/models/qrda/organization.rb +2 -0
- data/lib/health-data-standards/models/record.rb +7 -7
- data/lib/health-data-standards/models/result_value.rb +1 -0
- data/lib/health-data-standards/models/svs/concept.rb +1 -0
- data/lib/health-data-standards/models/svs/value_set.rb +1 -0
- data/lib/health-data-standards/models/telecom.rb +1 -0
- data/lib/health-data-standards/models/transfer.rb +1 -0
- data/lib/health-data-standards/tasks/bundle.rake +3 -3
- data/lib/health-data-standards/util/vs_api.rb +2 -2
- data/lib/hqmf-generator/attribute.xml.erb +9 -11
- data/lib/hqmf-generator/characteristic_criteria.xml.erb +5 -5
- data/lib/hqmf-generator/code.xml.erb +6 -2
- data/lib/hqmf-generator/condition_criteria.xml.erb +4 -5
- data/lib/hqmf-generator/derivation.xml.erb +6 -6
- data/lib/hqmf-generator/description.xml.erb +1 -1
- data/lib/hqmf-generator/document.xml.erb +46 -11
- data/lib/hqmf-generator/encounter_criteria.xml.erb +4 -5
- data/lib/hqmf-generator/field.xml.erb +13 -1
- data/lib/hqmf-generator/grouper_criteria.xml.erb +17 -0
- data/lib/hqmf-generator/hqmf-generator.rb +75 -8
- data/lib/hqmf-generator/local_variable.xml.erb +1 -0
- data/lib/hqmf-generator/measure_observation_definition.xml.erb +25 -0
- data/lib/hqmf-generator/observation_criteria.xml.erb +4 -5
- data/lib/hqmf-generator/population_criteria.xml.erb +2 -3
- data/lib/hqmf-generator/precondition.xml.erb +2 -2
- data/lib/hqmf-generator/precondition_cv.xml.erb +8 -0
- data/lib/hqmf-generator/procedure_criteria.xml.erb +4 -5
- data/lib/hqmf-generator/reference.xml.erb +2 -2
- data/lib/hqmf-generator/source.xml.erb +2 -2
- data/lib/hqmf-generator/specific_occurrence.xml.erb +4 -5
- data/lib/hqmf-generator/subset.xml.erb +16 -3
- data/lib/hqmf-generator/substance_criteria.xml.erb +4 -5
- data/lib/hqmf-generator/supply_criteria.xml.erb +4 -5
- data/lib/hqmf-generator/temporal_relationship.xml.erb +1 -1
- data/lib/hqmf-generator/value.xml.erb +35 -9
- data/lib/hqmf-generator/variable_criteria.xml.erb +2 -3
- data/lib/hqmf-model/attribute.rb +36 -8
- data/lib/hqmf-model/data_criteria.json +38 -204
- data/lib/hqmf-model/data_criteria.rb +40 -16
- data/lib/hqmf-model/document.rb +61 -2
- data/lib/hqmf-model/population_criteria.rb +11 -7
- data/lib/hqmf-model/precondition.rb +1 -1
- data/lib/hqmf-model/types.rb +91 -8
- data/lib/hqmf-parser/1.0/attribute.rb +55 -2
- data/lib/hqmf-parser/1.0/document.rb +10 -23
- data/lib/hqmf-parser/1.0/population_criteria.rb +2 -2
- data/lib/hqmf-parser/1.0/range.rb +0 -1
- data/lib/hqmf-parser/2.0/data_criteria.rb +90 -21
- data/lib/hqmf-parser/2.0/document.rb +122 -7
- data/lib/hqmf-parser/2.0/population_criteria.rb +18 -6
- data/lib/hqmf-parser/2.0/precondition.rb +4 -1
- data/lib/hqmf-parser/2.0/types.rb +36 -15
- data/lib/hqmf-parser/converter/pass1/document_converter.rb +4 -56
- data/lib/hqmf-parser/converter/pass1/population_criteria_converter.rb +24 -8
- data/lib/hqmf-parser/converter/pass1/precondition_extractor.rb +15 -2
- data/lib/hqmf-parser/converter/pass2/comparison_converter.rb +1 -1
- data/lib/hqmf-parser/parser.rb +64 -41
- data/templates/cat1/_2.16.840.1.113883.10.20.22.4.85.cat1.erb +0 -1
- data/templates/cat1/_address.cat1.erb +9 -0
- data/templates/cat1/_author.cat1.erb +28 -0
- data/templates/cat1/_id.cat1.erb +1 -0
- data/templates/cat1/_organization.cat1.erb +8 -0
- data/templates/cat1/_patient_data.cat1.erb +0 -3
- data/templates/cat1/_telecom.cat1.erb +1 -0
- data/templates/cat1/show.cat1.erb +96 -58
- metadata +115 -66
- checksums.yaml +0 -7
@@ -9,6 +9,11 @@ module HQMF
|
|
9
9
|
|
10
10
|
XPRODUCT = 'XPRODUCT'
|
11
11
|
UNION = 'UNION'
|
12
|
+
INTERSECT = 'INTERSECT'
|
13
|
+
|
14
|
+
SATISFIES_ALL = 'satisfies_all'
|
15
|
+
SATISFIES_ANY = 'satisfies_any'
|
16
|
+
VARIABLE = 'variable'
|
12
17
|
|
13
18
|
FIELDS = {'SEVERITY' => {title:'Severity', coded_entry_method: :severity, code: 'SEV', code_system:'2.16.840.1.113883.5.4', template_id: '2.16.840.1.113883.3.560.1.1021.2', field_type: :value},
|
14
19
|
'ORDINAL' => {title:'Ordinal', coded_entry_method: :ordinality, code: '117363000', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1012.2', field_type: :value},
|
@@ -31,7 +36,7 @@ module HQMF
|
|
31
36
|
'INCISION_DATETIME' => {title:'Incision Date/Time', coded_entry_method: :incision_time, code: '34896006', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1007.1', field_type: :timestamp},
|
32
37
|
'REMOVAL_DATETIME' => {title:'Removal Date/Time', coded_entry_method: :removal_time, code: '118292001', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1032.1', field_type: :timestamp},
|
33
38
|
'TRANSFER_TO' => {title:'Transfer To', coded_entry_method: :transfer_to, code: 'TRANSFER_TO', template_id: '2.16.840.1.113883.3.560.1.72', field_type: :value},
|
34
|
-
'TRANSFER_FROM' => {title:'Transfer From', coded_entry_method: :transfer_from, code: 'TRANSFER_FROM', template_id: '2.16.840.1.113883.3.560.1.71', field_type: :value}
|
39
|
+
'TRANSFER_FROM' => {title:'Transfer From', coded_entry_method: :transfer_from, code: 'TRANSFER_FROM', template_id: '2.16.840.1.113883.3.560.1.71', field_type: :value},
|
35
40
|
}
|
36
41
|
|
37
42
|
VALUE_FIELDS = {'SEV' => 'SEVERITY',
|
@@ -51,12 +56,14 @@ module HQMF
|
|
51
56
|
'91723000' => 'ANATOMICAL_STRUCTURE',
|
52
57
|
'397898000' => 'STOP_DATETIME',
|
53
58
|
'34896006' => 'INCISION_DATETIME',
|
54
|
-
'118292001' =>'REMOVAL_DATETIME'
|
59
|
+
'118292001' =>'REMOVAL_DATETIME',
|
60
|
+
'SDLOC_ARRIVAL' => 'FACILITY_LOCATION_ARRIVAL_DATETIME',
|
61
|
+
'SDLOC_DEPARTURE' => 'FACILITY_LOCATION_DEPARTURE_DATETIME'
|
55
62
|
}
|
56
63
|
|
57
64
|
|
58
|
-
attr_reader :title, :description, :code_list_id, :
|
59
|
-
attr_accessor :id, :value, :field_values, :effective_time, :status, :temporal_references, :subset_operators, :definition, :inline_code_list, :negation_code_list_id, :negation, :display_name
|
65
|
+
attr_reader :title, :description, :code_list_id, :derivation_operator , :specific_occurrence, :specific_occurrence_const, :source_data_criteria, :variable
|
66
|
+
attr_accessor :id, :value, :field_values, :children_criteria, :effective_time, :status, :temporal_references, :subset_operators, :definition, :inline_code_list, :negation_code_list_id, :negation, :display_name, :comments
|
60
67
|
|
61
68
|
# Create a new data criteria instance
|
62
69
|
# @param [String] id
|
@@ -80,7 +87,9 @@ module HQMF
|
|
80
87
|
# @param [String] specific_occurrence
|
81
88
|
# @param [String] specific_occurrence_const
|
82
89
|
# @param [String] source_data_criteria (id for the source data criteria, important for specific occurrences)
|
83
|
-
|
90
|
+
# @param [String] user comments for the criteria
|
91
|
+
# @param [Boolean] variable defines if the element is a QDM variable
|
92
|
+
def initialize(id, title, display_name, description, code_list_id, children_criteria, derivation_operator, definition, status, value, field_values, effective_time, inline_code_list, negation, negation_code_list_id, temporal_references, subset_operators, specific_occurrence, specific_occurrence_const, source_data_criteria=nil, comments=nil, variable=false)
|
84
93
|
|
85
94
|
status = normalize_status(definition, status)
|
86
95
|
@settings = HQMF::DataCriteria.get_settings_for_definition(definition, status)
|
@@ -105,6 +114,8 @@ module HQMF
|
|
105
114
|
@specific_occurrence = specific_occurrence
|
106
115
|
@specific_occurrence_const = specific_occurrence_const
|
107
116
|
@source_data_criteria = source_data_criteria || id
|
117
|
+
@comments = comments
|
118
|
+
@variable = variable
|
108
119
|
end
|
109
120
|
|
110
121
|
# create a new data criteria given a category and sub_category. A sub category can either be a status or a sub category
|
@@ -112,13 +123,6 @@ module HQMF
|
|
112
123
|
settings = HQMF::DataCriteria.get_settings_for_definition(category, sub_category)
|
113
124
|
HQMF::DataCriteria.new(id, title, nil, description, code_list_id, nil, nil, settings['definition'], settings['status'], nil, nil, nil, nil, negation, negation_code_list_id, nil, nil, nil,nil)
|
114
125
|
end
|
115
|
-
|
116
|
-
def standard_category
|
117
|
-
@settings['standard_category']
|
118
|
-
end
|
119
|
-
def qds_data_type
|
120
|
-
@settings['qds_data_type']
|
121
|
-
end
|
122
126
|
def type
|
123
127
|
@settings['category'].to_sym
|
124
128
|
end
|
@@ -131,7 +135,13 @@ module HQMF
|
|
131
135
|
def hard_status
|
132
136
|
@settings['hard_status']
|
133
137
|
end
|
134
|
-
|
138
|
+
def update_copy(hard_status, title, description, derivation_operator, definition)
|
139
|
+
@settings['hard_status'] = hard_status
|
140
|
+
@title = title
|
141
|
+
@description = description
|
142
|
+
@derivation_operator = derivation_operator
|
143
|
+
@definition = definition
|
144
|
+
end
|
135
145
|
def definition=(definition)
|
136
146
|
@definition = definition
|
137
147
|
@settings = HQMF::DataCriteria.get_settings_for_definition(@definition, @status)
|
@@ -163,9 +173,16 @@ module HQMF
|
|
163
173
|
specific_occurrence = json['specific_occurrence'] if json['specific_occurrence']
|
164
174
|
specific_occurrence_const = json['specific_occurrence_const'] if json['specific_occurrence_const']
|
165
175
|
source_data_criteria = json['source_data_criteria'] if json['source_data_criteria']
|
176
|
+
comments = json['comments'] if json['comments']
|
177
|
+
variable = json['variable'] || false
|
166
178
|
|
167
179
|
HQMF::DataCriteria.new(id, title, display_name, description, code_list_id, children_criteria, derivation_operator, definition, status, value, field_values,
|
168
|
-
effective_time, inline_code_list, negation, negation_code_list_id, temporal_references, subset_operators,specific_occurrence,specific_occurrence_const,source_data_criteria)
|
180
|
+
effective_time, inline_code_list, negation, negation_code_list_id, temporal_references, subset_operators,specific_occurrence,specific_occurrence_const,source_data_criteria, comments, variable)
|
181
|
+
end
|
182
|
+
|
183
|
+
def is_same_type?(criteria)
|
184
|
+
return @definition == criteria.definition && @hard_status == criteria.hard_status &&
|
185
|
+
@negation == criteria.negation && all_code_set_oids.sort == criteria.all_code_set_oids.sort
|
169
186
|
end
|
170
187
|
|
171
188
|
def to_json
|
@@ -175,7 +192,7 @@ module HQMF
|
|
175
192
|
|
176
193
|
def base_json
|
177
194
|
x = nil
|
178
|
-
json = build_hash(self, [:title,:display_name,:description,:
|
195
|
+
json = build_hash(self, [:title,:display_name,:description,:code_list_id,:children_criteria, :derivation_operator, :property, :type, :definition, :status, :hard_status, :negation, :negation_code_list_id,:specific_occurrence,:specific_occurrence_const,:source_data_criteria,:variable])
|
179
196
|
json[:children_criteria] = @children_criteria unless @children_criteria.nil? || @children_criteria.empty?
|
180
197
|
json[:value] = ((@value.is_a? String) ? @value : @value.to_json) if @value
|
181
198
|
json[:field_values] = @field_values.inject({}) {|memo,(k,v)| memo[k] = (!v.nil? ? v.to_json : nil); memo} if @field_values
|
@@ -183,6 +200,7 @@ module HQMF
|
|
183
200
|
json[:inline_code_list] = @inline_code_list if @inline_code_list
|
184
201
|
json[:temporal_references] = x if x = json_array(@temporal_references)
|
185
202
|
json[:subset_operators] = x if x = json_array(@subset_operators)
|
203
|
+
json[:comments] = @comments if @comments
|
186
204
|
json
|
187
205
|
end
|
188
206
|
|
@@ -259,9 +277,15 @@ module HQMF
|
|
259
277
|
|
260
278
|
end
|
261
279
|
|
280
|
+
def self.get_settings_map
|
281
|
+
return @settings_map if @settings_map
|
282
|
+
settings_file = File.expand_path('../data_criteria.json', __FILE__)
|
283
|
+
@settings_map = JSON.parse(File.read(settings_file))
|
284
|
+
end
|
285
|
+
|
262
286
|
def self.get_settings_for_definition(definition, status)
|
263
287
|
settings_file = File.expand_path('../data_criteria.json', __FILE__)
|
264
|
-
settings_map =
|
288
|
+
settings_map = get_settings_map
|
265
289
|
key = definition + ((status.nil? || status.empty?) ? '' : "_#{status}")
|
266
290
|
settings = settings_map[key]
|
267
291
|
|
data/lib/hqmf-model/document.rb
CHANGED
@@ -122,6 +122,14 @@ module HQMF
|
|
122
122
|
def population_criteria(id)
|
123
123
|
find(@population_criteria, :id, id)
|
124
124
|
end
|
125
|
+
|
126
|
+
def is_cv?
|
127
|
+
find(@population_criteria, :type, HQMF::PopulationCriteria::MSRPOPL)
|
128
|
+
end
|
129
|
+
|
130
|
+
def find_population_by_type(type)
|
131
|
+
find(@population_criteria, :type, type)
|
132
|
+
end
|
125
133
|
|
126
134
|
# Get all the data criteria defined by the measure
|
127
135
|
# @return [Array] an array of HQMF::DataCriteria describing the data elements used by the measure
|
@@ -167,7 +175,14 @@ module HQMF
|
|
167
175
|
end
|
168
176
|
used_dc
|
169
177
|
end
|
170
|
-
|
178
|
+
|
179
|
+
# Get specific attributes by code.
|
180
|
+
# @param [String] code the attribute code
|
181
|
+
# @param [String] code_system the attribute code system
|
182
|
+
# @return [Array#Attribute] the matching attributes, raises an Exception if not found
|
183
|
+
def attributes_for_code(code, code_system)
|
184
|
+
@attributes.find_all { |e| e.send(:code) == code && e.send(:code_obj).send(:system) == code_system }
|
185
|
+
end
|
171
186
|
|
172
187
|
# Get a specific data criteria by id.
|
173
188
|
# @param [String] id the data criteria identifier
|
@@ -176,10 +191,54 @@ module HQMF
|
|
176
191
|
find(@data_criteria, :id, id)
|
177
192
|
end
|
178
193
|
|
194
|
+
# patient characteristics data criteria such as GENDER require looking at the codes to determine if the
|
195
|
+
# measure is interested in Males or Females. This process is awkward, and thus is done as a separate
|
196
|
+
# step after the document has been converted.
|
197
|
+
def backfill_patient_characteristics_with_codes(codes)
|
198
|
+
|
199
|
+
[].concat(self.all_data_criteria).concat(self.source_data_criteria).each do |data_criteria|
|
200
|
+
if (data_criteria.type == :characteristic and !data_criteria.property.nil?)
|
201
|
+
if (codes)
|
202
|
+
value_set = codes[data_criteria.code_list_id]
|
203
|
+
puts "\tno value set for unknown patient characteristic: #{data_criteria.id}" unless value_set
|
204
|
+
else
|
205
|
+
puts "\tno code set to back fill: #{data_criteria.title}"
|
206
|
+
next
|
207
|
+
end
|
208
|
+
|
209
|
+
if (data_criteria.property == :gender)
|
210
|
+
next if value_set.nil?
|
211
|
+
key = value_set.keys[0]
|
212
|
+
data_criteria.value = HQMF::Coded.new('CD','Administrative Sex',value_set[key].first)
|
213
|
+
else
|
214
|
+
data_criteria.inline_code_list = value_set
|
215
|
+
end
|
216
|
+
|
217
|
+
elsif (data_criteria.type == :characteristic)
|
218
|
+
if (codes)
|
219
|
+
value_set = codes[data_criteria.code_list_id]
|
220
|
+
if (value_set)
|
221
|
+
# this is looking for a birthdate characteristic that is set as a generic characteristic but points to a loinc code set
|
222
|
+
if (value_set['LOINC'] and value_set['LOINC'].first == '21112-8')
|
223
|
+
data_criteria.definition = 'patient_characteristic_birthdate'
|
224
|
+
end
|
225
|
+
# this is looking for a gender characteristic that is set as a generic characteristic
|
226
|
+
gender_key = (value_set.keys.select {|set| set == 'Administrative Sex' || set == 'AdministrativeSex'}).first
|
227
|
+
if (gender_key and ['M','F'].include? value_set[gender_key].first)
|
228
|
+
data_criteria.definition = 'patient_characteristic_gender'
|
229
|
+
data_criteria.value = HQMF::Coded.new('CD','Gender',value_set[gender_key].first)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
179
238
|
private
|
180
239
|
|
181
240
|
def find(collection, attribute, value)
|
182
241
|
collection.find {|e| e.send(attribute)==value}
|
183
242
|
end
|
184
243
|
end
|
185
|
-
end
|
244
|
+
end
|
@@ -5,7 +5,7 @@ module HQMF
|
|
5
5
|
|
6
6
|
include HQMF::Conversion::Utilities
|
7
7
|
|
8
|
-
attr_reader :preconditions, :id, :type, :title, :hqmf_id
|
8
|
+
attr_reader :preconditions, :id, :type, :title, :hqmf_id, :comments
|
9
9
|
attr_accessor :aggregator
|
10
10
|
|
11
11
|
IPP = 'IPP'
|
@@ -15,21 +15,24 @@ module HQMF
|
|
15
15
|
DENEX = 'DENEX'
|
16
16
|
MSRPOPL = 'MSRPOPL'
|
17
17
|
OBSERV = 'OBSERV'
|
18
|
+
|
19
|
+
STRAT = 'STRAT'
|
18
20
|
|
19
|
-
ALL_POPULATION_CODES = [IPP, DENOM, DENEX, NUMER, DENEXCEP, MSRPOPL, OBSERV]
|
21
|
+
ALL_POPULATION_CODES = [STRAT, IPP, DENOM, DENEX, NUMER, DENEXCEP, MSRPOPL, OBSERV]
|
20
22
|
|
21
23
|
# Create a new population criteria
|
22
24
|
# @param [String] id
|
23
25
|
# @param [String] hqmf_id
|
24
26
|
# @param [Array#Precondition] preconditions
|
25
27
|
# @param [String] title (optional)
|
26
|
-
def initialize(id, hqmf_id, type, preconditions, title='', aggregator=nil)
|
28
|
+
def initialize(id, hqmf_id, type, preconditions, title='', aggregator=nil, comments=nil)
|
27
29
|
@id = id
|
28
30
|
@hqmf_id = hqmf_id
|
29
31
|
@preconditions = preconditions
|
30
32
|
@type = type
|
31
33
|
@title = title
|
32
34
|
@aggregator = aggregator
|
35
|
+
@comments = comments
|
33
36
|
end
|
34
37
|
|
35
38
|
# Create a new population criteria from a JSON hash keyed off symbols
|
@@ -41,8 +44,9 @@ module HQMF
|
|
41
44
|
title = json['title']
|
42
45
|
hqmf_id = json['hqmf_id']
|
43
46
|
aggregator = json['aggregator']
|
47
|
+
comments = json['comments']
|
44
48
|
|
45
|
-
HQMF::PopulationCriteria.new(id, hqmf_id, type, preconditions, title, aggregator)
|
49
|
+
HQMF::PopulationCriteria.new(id, hqmf_id, type, preconditions, title, aggregator, comments)
|
46
50
|
end
|
47
51
|
|
48
52
|
def to_json
|
@@ -51,7 +55,7 @@ module HQMF
|
|
51
55
|
|
52
56
|
def base_json
|
53
57
|
x = nil
|
54
|
-
json = build_hash(self, [:conjunction?, :type, :title, :hqmf_id, :aggregator])
|
58
|
+
json = build_hash(self, [:conjunction?, :type, :title, :hqmf_id, :aggregator, :comments])
|
55
59
|
json[:preconditions] = x if x = json_array(@preconditions)
|
56
60
|
json
|
57
61
|
end
|
@@ -68,7 +72,7 @@ module HQMF
|
|
68
72
|
def conjunction_code
|
69
73
|
|
70
74
|
case @type
|
71
|
-
when IPP, DENOM, NUMER, MSRPOPL
|
75
|
+
when IPP, STRAT, DENOM, NUMER, MSRPOPL
|
72
76
|
HQMF::Precondition::ALL_TRUE
|
73
77
|
when DENEXCEP, DENEX
|
74
78
|
HQMF::Precondition::AT_LEAST_ONE_TRUE
|
@@ -93,4 +97,4 @@ module HQMF
|
|
93
97
|
|
94
98
|
end
|
95
99
|
|
96
|
-
end
|
100
|
+
end
|
@@ -62,7 +62,7 @@ module HQMF
|
|
62
62
|
json[:id] = self.id
|
63
63
|
json[:reference] = self.reference.id if self.reference
|
64
64
|
json[:preconditions] = x if x = json_array(@preconditions)
|
65
|
-
json[:conjunction_code] = self.conjunction_code if self.conjunction_code
|
65
|
+
json[:conjunction_code] = self.conjunction_code if self.conjunction_code && self.preconditions.length > 0
|
66
66
|
json[:negation] = self.negation if self.negation
|
67
67
|
json
|
68
68
|
end
|
data/lib/hqmf-model/types.rb
CHANGED
@@ -117,7 +117,6 @@ module HQMF
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def stringify
|
120
|
-
operator = ""
|
121
120
|
if (@high && @low)
|
122
121
|
if (@high.value == @low.value and @high.inclusive? and low.inclusive?)
|
123
122
|
"#{@low.stringify}"
|
@@ -155,19 +154,21 @@ module HQMF
|
|
155
154
|
# Represents a HQMF CD value which has a code and codeSystem
|
156
155
|
class Coded
|
157
156
|
include HQMF::Conversion::Utilities
|
158
|
-
attr_reader :type, :system, :code, :code_list_id, :title
|
157
|
+
attr_reader :type, :system, :code, :code_list_id, :title, :null_flavor, :original_text
|
159
158
|
|
160
159
|
# Create a new HQMF::Coded
|
161
160
|
# @param [String] type
|
162
161
|
# @param [String] system
|
163
162
|
# @param [String] code
|
164
163
|
# @param [String] code_list_id
|
165
|
-
def initialize(type,system,code,code_list_id=nil,title=nil)
|
164
|
+
def initialize(type,system,code,code_list_id=nil,title=nil,null_flavor=nil,original_text=nil)
|
166
165
|
@type = type
|
167
166
|
@system = system
|
168
167
|
@code = code
|
169
168
|
@code_list_id = code_list_id
|
170
169
|
@title = title
|
170
|
+
@null_flavor = null_flavor
|
171
|
+
@original_text = original_text
|
171
172
|
end
|
172
173
|
|
173
174
|
def self.for_code_list(code_list_id,title=nil)
|
@@ -177,19 +178,26 @@ module HQMF
|
|
177
178
|
def self.for_single_code(system,code,title=nil)
|
178
179
|
HQMF::Coded.new('CD',system,code,nil,title)
|
179
180
|
end
|
181
|
+
|
182
|
+
def self.for_null_flavor(null_flavor,original_text=nil)
|
183
|
+
HQMF::Coded.new('CD',nil,nil,nil,nil,null_flavor,original_text)
|
184
|
+
end
|
180
185
|
|
181
186
|
def self.from_json(json)
|
187
|
+
json = json.with_indifferent_access
|
182
188
|
type = json["type"] if json["type"]
|
183
189
|
system = json["system"] if json["system"]
|
184
190
|
code = json["code"] if json["code"]
|
185
191
|
code_list_id = json["code_list_id"] if json["code_list_id"]
|
186
192
|
title = json["title"] if json["title"]
|
193
|
+
null_flavor = json["null_flavor"] if json["null_flavor"]
|
194
|
+
original_text = json["original_text"] if json["original_text"]
|
187
195
|
|
188
|
-
HQMF::Coded.new(type,system,code,code_list_id,title)
|
196
|
+
HQMF::Coded.new(type,system,code,code_list_id,title, null_flavor, original_text)
|
189
197
|
end
|
190
198
|
|
191
199
|
def to_json
|
192
|
-
build_hash(self, [:type,:system,:code,:code_list_id,:title])
|
200
|
+
build_hash(self, [:type,:system,:code,:code_list_id,:title,:null_flavor,:original_text])
|
193
201
|
end
|
194
202
|
|
195
203
|
def value
|
@@ -213,7 +221,7 @@ module HQMF
|
|
213
221
|
class TemporalReference
|
214
222
|
include HQMF::Conversion::Utilities
|
215
223
|
|
216
|
-
TYPES = ['DURING','SBS','SAS','SBE','SAE','EBS','EAS','EBE','EAE','SDU','EDU','ECW','SCW','CONCURRENT']
|
224
|
+
TYPES = ['DURING','OVERLAP','SBS','SAS','SBE','SAE','EBS','EAS','EBE','EAE','SDU','EDU','ECW','SCW','ECWS','SCWE','SBCW','SBCWE','SACW','SACWE','SBDU','EBCW','EBCWS','EACW','EACWS','EADU','CONCURRENT']
|
217
225
|
INVERSION = {'SBS' => 'SAS','EAE' => 'EBE','SAS' => 'SBS','EBE' => 'EAE','SBE' => 'EAS','EAS' => 'SBE','SAE' => 'EBS','EBS' => 'SAE'}
|
218
226
|
|
219
227
|
attr_reader :type, :reference, :range
|
@@ -241,7 +249,6 @@ module HQMF
|
|
241
249
|
|
242
250
|
|
243
251
|
def to_json
|
244
|
-
x = nil
|
245
252
|
json = build_hash(self, [:type])
|
246
253
|
json[:reference] = @reference.to_json if @reference
|
247
254
|
json[:range] = @range.to_json if @range
|
@@ -272,6 +279,10 @@ module HQMF
|
|
272
279
|
end
|
273
280
|
end
|
274
281
|
|
282
|
+
def supports_grouper_criteria?
|
283
|
+
['FIRST', 'SECOND', 'THIRD', 'FOURTH', 'FIFTH', 'RECENT', 'LAST'].include? @type
|
284
|
+
end
|
285
|
+
|
275
286
|
def self.from_json(json)
|
276
287
|
type = json["type"] if json["type"]
|
277
288
|
|
@@ -282,7 +293,6 @@ module HQMF
|
|
282
293
|
|
283
294
|
|
284
295
|
def to_json
|
285
|
-
x = nil
|
286
296
|
json = build_hash(self, [:type])
|
287
297
|
json[:value] = @value.to_json if @value
|
288
298
|
json
|
@@ -315,5 +325,78 @@ module HQMF
|
|
315
325
|
end
|
316
326
|
|
317
327
|
end
|
328
|
+
|
329
|
+
class Identifier
|
330
|
+
include HQMF::Conversion::Utilities
|
331
|
+
attr_accessor :type, :root, :extension
|
332
|
+
|
333
|
+
def initialize(type, root, extension=nil)
|
334
|
+
@type = type || 'II'
|
335
|
+
@root = root
|
336
|
+
@extension = extension
|
337
|
+
end
|
338
|
+
|
339
|
+
def self.from_json(json)
|
340
|
+
json = json.with_indifferent_access
|
341
|
+
HQMF::Identifier.new(json['type'], json['root'], json['extension'])
|
342
|
+
end
|
343
|
+
|
344
|
+
def to_json
|
345
|
+
build_hash(self, [:type, :root, :extension])
|
346
|
+
end
|
347
|
+
|
348
|
+
def ==(other)
|
349
|
+
check_equality(self,other)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
# What does ED stand for?
|
354
|
+
# ED has a lot more elements / attributes to represent, but only caring about what I see used...
|
355
|
+
class ED
|
356
|
+
include HQMF::Conversion::Utilities
|
357
|
+
attr_accessor :type, :value, :media_type
|
358
|
+
|
359
|
+
def initialize(type, value, media_type)
|
360
|
+
@type = type || 'ED'
|
361
|
+
@value = value
|
362
|
+
@media_type = media_type
|
363
|
+
end
|
364
|
+
|
365
|
+
def self.from_json(json)
|
366
|
+
json = json.with_indifferent_access
|
367
|
+
HQMF::ED.new(json['type'], json['value'], json['media_type'])
|
368
|
+
end
|
369
|
+
|
370
|
+
def to_json
|
371
|
+
build_hash(self, [:type, :value, :media_type])
|
372
|
+
end
|
373
|
+
|
374
|
+
def ==(other)
|
375
|
+
check_equality(self,other)
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
class GenericValueContainer
|
380
|
+
include HQMF::Conversion::Utilities
|
381
|
+
attr_accessor :type, :value
|
382
|
+
|
383
|
+
def initialize(type, value)
|
384
|
+
@type = type
|
385
|
+
@value = value
|
386
|
+
end
|
387
|
+
|
388
|
+
def self.from_json(json)
|
389
|
+
json = json.with_indifferent_access
|
390
|
+
HQMF::GenericValueContainer.new(json['type'], json['value'])
|
391
|
+
end
|
392
|
+
|
393
|
+
def to_json
|
394
|
+
build_hash(self, [:type, :value])
|
395
|
+
end
|
396
|
+
|
397
|
+
def ==(other)
|
398
|
+
check_equality(self,other)
|
399
|
+
end
|
400
|
+
end
|
318
401
|
|
319
402
|
end
|