diff --git a/.rubocop.yml b/.rubocop.yml index c51c4435b..50e4fb4a5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -104,6 +104,7 @@ Metrics/ClassLength: - 'lib/cypress/demographics_randomizer.rb' - 'lib/cypress/expected_results_calculator.rb' - 'lib/cypress/population_clone_job.rb' + - 'lib/validators/cat3_population_validator.rb' Metrics/CyclomaticComplexity: Max: 12 Exclude: diff --git a/lib/validators/cat3_population_validator.rb b/lib/validators/cat3_population_validator.rb index 2e244e18b..eb282b20a 100644 --- a/lib/validators/cat3_population_validator.rb +++ b/lib/validators/cat3_population_validator.rb @@ -6,10 +6,6 @@ class Cat3PopulationValidator < QrdaFileValidator include ::CqmValidators::ReportedResultExtractor include QrdaHelper - # These are the demographic codes specified in the CMS IG for Payer, Sex, Race and Ethnicity - REQUIRED_CODES = { 'PAYER' => %w[A B C D], 'SEX' => %w[M F], 'RACE' => %w[2106-3 2076-8 2054-5 2028-9 1002-5 2131-1], - 'ETHNICITY' => %w[2135-2 2186-5] }.freeze - def initialize(expected_measures = []) @expected_measures = expected_measures end @@ -111,11 +107,15 @@ def validate_demographics(reported_result, pop_key, pop_set_hash, options) verify_all_codes_reported(reported_result, pop_key, 'ETHNICITY', options) unless @missing_codes['ETHNICITY'] end - # Verifiy that all demographic codes for a sup_key (e.g., RACE) are present for a pop_key (e.g., DENOM) in a reported result + # Verify that all demographic codes for a sup_key (e.g., RACE) are present for a pop_key (e.g., DENOM) in a reported result def verify_all_codes_reported(reported_result, pop_key, sup_key, options) + gender_codes = options['test_execution'].task.bundle.randomization['genders']&.map(&:code) + required_codes = { 'PAYER' => %w[A B C D], 'SEX' => gender_codes, 'RACE' => %w[2106-3 2076-8 2054-5 2028-9 1002-5 2131-1], + 'ETHNICITY' => %w[2135-2 2186-5] }.freeze + reported_codes = reported_result[:supplemental_data][pop_key][sup_key] - required_codes = REQUIRED_CODES[sup_key] - missing_codes = required_codes - reported_codes.keys + required_codes_for_key = required_codes[sup_key] + missing_codes = required_codes_for_key - reported_codes.keys return if missing_codes.empty? msg = "For CMS eligible clinicians and eligible professionals programs, all #{sup_key} codes present in the value set must be reported," \ diff --git a/test/fixtures/qrda/cat_III/ep_test_qrda_cat3_good.xml b/test/fixtures/qrda/cat_III/ep_test_qrda_cat3_good.xml index c0da6553b..24bd236e6 100644 --- a/test/fixtures/qrda/cat_III/ep_test_qrda_cat3_good.xml +++ b/test/fixtures/qrda/cat_III/ep_test_qrda_cat3_good.xml @@ -1,479 +1,1372 @@ - - - - - - - - - - - QRDA Calculated Summary Report - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + +QRDA Calculated Summary Report + + + + + + + + + + + + + + + + + + TestSystem Test Deck + + + 202 Burlington Rd. + Bedford + MA + 01730 + US + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 202 Burlington Rd + Bedford + MA + 01730 + US + + + + Given_Name 11 + ["Family_Name 11"] + + + + + + 202 Burlington Rd + Bedford + MA + 01730 + US + + + + + + - - -
- - - - - - Reporting Parameters - - - Reporting period: January 1st, 2012 00:00 - December 31st, 2012 23:59 - - - - - - - - - - - - - - -
-
-
+ + + Measure Section - + + + + + + + + + + + + + + +
eMeasure TitleVersion specific identifier
Static Proportion Measure Description40280382-5FA6-FE85-0160-0918E74D2075 +
+
+ - + + + - - + - Static Measure + Static Proportion Measure Description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -482,7 +1375,6 @@ Measure Section
-
-
-
+
+
\ No newline at end of file diff --git a/test/unit/lib/validators/cat3_population_validator_test.rb b/test/unit/lib/validators/cat3_population_validator_test.rb index 856edd7cd..b36aa8750 100644 --- a/test/unit/lib/validators/cat3_population_validator_test.rb +++ b/test/unit/lib/validators/cat3_population_validator_test.rb @@ -33,6 +33,18 @@ def test_good_document assert_empty @validator.errors, "Expected no errors for good Cat 3 document, found #{@validator.errors}" end + def test_good_document_diff_year + @task._type = 'C3Cat3Task' + @validator.validate(@document, 'test_execution' => @test_execution) + + assert_empty @validator.errors, "Expected no errors for good Cat 3 document, found #{@validator.errors}" + + @test_execution.task.bundle.version = '2025.0.0' + @validator.validate(@document, 'test_execution' => @test_execution) + + assert_equal 1, @validator.errors.count, "Expected 1 error for good Cat 3 document validated for the wrong year, found #{@validator.errors}" + end + def test_no_exception_thrown_on_bad_document @document.xpath('/cda:ClinicalDocument/cda:component/cda:structuredBody/cda:component').each(&:remove)