Class: HealthDataStandards::Validate::PerformanceRateValidator
Instance Method Summary
collapse
#build_error, #get_document
#convert_value, #extract_component_value, #extract_cv_value, #extract_performance_rate, #extract_results_by_ids, #extract_supplemental_data, #find_measure_node, #get_aggregate_count, #get_cv_value, #get_measure_components, #translate
Constructor Details
9
10
11
12
13
|
# File 'lib/health-data-standards/validate/performance_rate_validator.rb', line 9
def initialize()
end
|
Instance Method Details
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/health-data-standards/validate/performance_rate_validator.rb', line 38
def calculate_performance_rates(reported_result)
denex = 0
denexcep = 0
denom = 0
numer = 0
if reported_result['DENEX'] != nil
denex = reported_result['DENEX']
end
if reported_result['DENEXCEP'] != nil
denexcep = reported_result['DENEXCEP']
end
if reported_result['DENOM'] != nil
denom = reported_result['DENOM']
end
if reported_result['NUMER'] != nil
numer = reported_result['NUMER']
end
denom = denom - denex - denexcep
pr = 0
if denom == 0
pr = "NA"
else
pr = numer / denom.to_f
end
return pr
end
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/health-data-standards/validate/performance_rate_validator.rb', line 66
def check_performance_rates(reported_result, population_ids, measure_id, data = {})
expected = calculate_performance_rates(reported_result)
_ids = population_ids
if expected == "NA"
if reported_result['PR']['nullFlavor'] != "NA"
return build_error("Reported Performance Rate for Numerator #{_ids['NUMER']} should be NA", "/", data[:file_name])
end
else
if reported_result['PR']['nullFlavor'] == "NA"
return build_error("Reported Performance Rate for Numerator #{_ids['NUMER']} should not be NA", "/", data[:file_name])
else
if (reported_result['PR']['value'].split('.',2).last.size > 6)
return build_error("Reported Performance Rate SHALL not have a precision greater than .000001 ", "/", data[:file_name])
elsif (reported_result['PR']['value'].to_f - expected.round(6)).abs > 0.0000001
return build_error("Reported Performance Rate of #{reported_result['PR']['value']} for Numerator #{_ids['NUMER']} does not match expected value of #{expected.round(6)}.", "/", data[:file_name])
end
end
end
end
|
#measure_selector ⇒ Object
86
87
88
89
90
|
# File 'lib/health-data-standards/validate/performance_rate_validator.rb', line 86
def measure_selector
"/cda:ClinicalDocument/cda:component/cda:structuredBody/cda:component/cda:section/cda:entry" +
"/cda:organizer[./cda:templateId[@root='2.16.840.1.113883.10.20.27.3.1']]/cda:reference[@typeCode='REFR']" +
"/cda:externalDocument[@classCode='DOC']/cda:id[@root='2.16.840.1.113883.4.738']/@extension"
end
|
#validate(file, data = {}) ⇒ Object
Nothing to see here - Move along
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/health-data-standards/validate/performance_rate_validator.rb', line 16
def validate(file, data = {})
errorsList = []
document = get_document(file)
measure_ids = document.xpath(measure_selector).map(&:value).map(&:upcase)
measure_ids.each do |measure_id|
measures = HealthDataStandards::CQM::Measure.where(id: measure_id)
measures.each do |measure|
result_key = measure["population_ids"].dup
reported_result, errors = (measure['id'], result_key, document)
if reported_result['PR'] != nil
error = check_performance_rates(reported_result, result_key, measure['id'], data)
if error != nil
errorsList << error
end
end
end
end
errorsList
end
|