lib/hqmf-parser/converter/pass1/document_converter.rb in health-data-standards-3.4.6 vs lib/hqmf-parser/converter/pass1/document_converter.rb in health-data-standards-3.5.0

- old
+ new

@@ -7,13 +7,13 @@ def self.convert(json, codes) title = json[:title] description = json[:description] + # TODO: Investigate why we never use json[:attributes] metadata = json[:metadata] metadata.keys.each {|key| metadata[key.to_s] = metadata[key]; metadata.delete(key.to_sym)} - id = metadata["NQF_ID_NUMBER"][:value] if metadata["NQF_ID_NUMBER"] emeasure_id = metadata['EMEASURE_IDENTIFIER'][:value] if metadata['EMEASURE_IDENTIFIER'] attributes = parse_attributes(metadata) hqmf_id = json[:hqmf_id] hqmf_set_id = json[:hqmf_set_id] @@ -43,76 +43,24 @@ populations = @population_criteria_converter.sub_measures doc = HQMF::Document.new(id, hqmf_id, hqmf_set_id, hqmf_version_number, cms_id, title, description, population_criteria, data_criteria, source_data_criteria, attributes, measure_period, populations) - backfill_patient_characteristics_with_codes(doc, codes) + HQMF::DocumentConverter.validate(doc, codes) if codes - HQMF::DocumentConverter.validate(doc, codes) - doc end private - + def self.parse_attributes(metadata) attributes = [] metadata.keys.each do |key| - attribute_hash = metadata[key] - code = attribute_hash[:code] - value = attribute_hash[:value] - unit = attribute_hash[:unit] - name = attribute_hash[:name] - attributes << HQMF::Attribute.new(key,code,value,unit,name) + attributes << HQMF::Attribute.from_json(metadata[key]) end attributes end - - - # patient characteristics data criteria such as GENDER require looking at the codes to determine if the - # measure is interested in Males or Females. This process is awkward, and thus is done as a separate - # step after the document has been converted. - def self.backfill_patient_characteristics_with_codes(doc, codes) - - [].concat(doc.all_data_criteria).concat(doc.source_data_criteria).each do |data_criteria| - if (data_criteria.type == :characteristic and !data_criteria.property.nil?) - if (codes) - value_set = codes[data_criteria.code_list_id] - puts "\tno value set for unknown patient characteristic: #{data_criteria.id}" unless value_set - else - puts "\tno code set to back fill: #{data_criteria.title}" - next - end - - if (data_criteria.property == :gender) - key = value_set.keys[0] - data_criteria.value = HQMF::Coded.new('CD','Administrative Sex',value_set[key].first) - else - data_criteria.inline_code_list = value_set - end - - elsif (data_criteria.type == :characteristic) - if (codes) - value_set = codes[data_criteria.code_list_id] - if (value_set) - # this is looking for a birthdate characteristic that is set as a generic characteristic but points to a loinc code set - if (value_set['LOINC'] and value_set['LOINC'].first == '21112-8') - data_criteria.definition = 'patient_characteristic_birthdate' - end - # this is looking for a gender characteristic that is set as a generic characteristic - gender_key = (value_set.keys.select {|set| set == 'Administrative Sex' || set == 'AdministrativeSex'}).first - if (gender_key and ['M','F'].include? value_set[gender_key].first) - data_criteria.definition = 'patient_characteristic_gender' - data_criteria.value = HQMF::Coded.new('CD','Gender',value_set[gender_key].first) - end - end - end - - end - end - end - def self.parse_measure_period(json) # Create a new HQMF::EffectiveTime # @param [Value] low