Module: HealthDataStandards::Export::Helper::Cat1ViewHelper

Includes:
ScoopedViewHelper
Defined in:
lib/health-data-standards/export/helper/cat1_view_helper.rb

Constant Summary

Constants included from ScoopedViewHelper

ScoopedViewHelper::VS_MAP

Instance Method Summary collapse

Methods included from ScoopedViewHelper

#entries_for_data_criteria, #entry_matches_criteria, #handle_clinical_trial_participant, #handle_patient_expired, #handle_payer_information, #unique_data_criteria, #value_set_map

Instance Method Details

#negation_indicator(entry) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/health-data-standards/export/helper/cat1_view_helper.rb', line 38

def negation_indicator(entry)
  if entry.negation_ind
    'negationInd="true"'
  else
    ''
  end
end

#oid_for_code(codedValue, valueset_oids, bundle_id = nil) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/health-data-standards/export/helper/cat1_view_helper.rb', line 46

def oid_for_code(codedValue, valueset_oids,  bundle_id = nil)
  return nil if codedValue.nil?
  valueset_oids ||=[]
  code = codedValue["code"]
  code_system = codedValue["code_set"] || codedValue["code_system"]
  vs_map = (value_set_map(bundle_id) || {})
  valueset_oids.each do |vs_oid|
    oid_list = (vs_map[vs_oid] || [])
    oid_map = Hash[oid_list.collect{|x| [x["set"],x["values"]]}]
    if (oid_map[code_system] || []).include? code
      return vs_oid
    end
  end
  return nil
end

#render_data_criteria(dc, entries, r2_compatibility, qrda_version = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/health-data-standards/export/helper/cat1_view_helper.rb', line 7

def render_data_criteria(dc, entries, r2_compatibility, qrda_version = nil)
  html_array = entries.map do |entry|
      bundle_id = entry.record ? entry.record["bundle_id"] : nil
      vs_map = (value_set_map(bundle_id) || {})[dc['value_set_oid']]
      render(:partial => HealthDataStandards::Export::QRDA::EntryTemplateResolver.partial_for(dc['data_criteria_oid'], dc['value_set_oid'], qrda_version), :locals => {:entry => entry,
                                                                                                                           :data_criteria => dc['data_criteria'],
                                                                                                                           :value_set_oid => dc['value_set_oid'],
                                                                                                                           :filtered_vs_map => vs_map,
                                                                                                                           :result_oids => dc["result_oids"],
                                                                                                                           :field_oids => dc["field_oids"],
                                                                                                                           :r2_compatibility => r2_compatibility,
                                                                                                                           :bundle_id => bundle_id})
  end
  html_array.join("\n")
end

#render_patient_data(patient, measures, r2_compatibility, qrda_version = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/health-data-standards/export/helper/cat1_view_helper.rb', line 23

def render_patient_data(patient, measures, r2_compatibility, qrda_version = nil)
  HealthDataStandards.logger.warn("Generating CAT I for #{patient.first} #{patient.last}")
  udcs = unique_data_criteria(measures, r2_compatibility)
  data_criteria_html = udcs.map do |udc|
    # If there's an error exporting particular criteria, re-raise an error that includes useful debugging info
    begin
      entries = entries_for_data_criteria(udc['data_criteria'], patient)
      render_data_criteria(udc, entries, r2_compatibility, qrda_version)
    rescue => e
      raise HealthDataStandards::Export::PatientExportDataCriteriaException.new(e.message, patient, udc['data_criteria'], entries)
    end
  end
  data_criteria_html.compact.join("\n")
end