Class: DaVinciCRDTestKit::PrefetchCompletenessChecker
- Inherits:
-
Object
- Object
- DaVinciCRDTestKit::PrefetchCompletenessChecker
- Includes:
- FhirpathOnCDSRequest, ReplaceTokens
- Defined in:
- lib/davinci_crd_test_kit/cross_suite/prefetch_completeness_checker.rb
Overview
Prefetch Check Helper Class
Constant Summary
Constants included from FhirpathOnCDSRequest
FhirpathOnCDSRequest::SUPPORTED_POST_RESOLVE_FUNCTIONS, FhirpathOnCDSRequest::TODAY_EXPRESSION_PATTERN
Instance Attribute Summary collapse
-
#hook_request ⇒ Object
Returns the value of attribute hook_request.
-
#instantiated_prefetch_templates ⇒ Object
Returns the value of attribute instantiated_prefetch_templates.
-
#observed_fhirpath_collection_as_comma_delimited_string ⇒ Object
Returns the value of attribute observed_fhirpath_collection_as_comma_delimited_string.
-
#request_index ⇒ Object
Returns the value of attribute request_index.
-
#services_file_path ⇒ Object
Returns the value of attribute services_file_path.
Instance Method Summary collapse
- #check_prefetched_data ⇒ Object
-
#data_set_different_with_alternate_service?(alternate_services_file_path, compare_key_map) ⇒ Boolean
———————————————————————– Complete vs Subset Prefetch Difference Checking ———————————————————————–.
-
#data_sets_different?(original_service_checker, compare_key_map) ⇒ Boolean
Precondition: the original checker passed without errors meaning the expected set was present handles both subset < complete and complete > subset checks via two checks.
-
#initialize(hook_request, request_index, services_file_path) ⇒ PrefetchCompletenessChecker
constructor
A new instance of PrefetchCompletenessChecker.
Methods included from ReplaceTokens
#replace_tokens, #replace_tokens_in_string
Methods included from FhirpathOnCDSRequest
#execute_fhirpath_on_cds_request
Constructor Details
#initialize(hook_request, request_index, services_file_path) ⇒ PrefetchCompletenessChecker
Returns a new instance of PrefetchCompletenessChecker.
17 18 19 20 21 22 23 24 |
# File 'lib/davinci_crd_test_kit/cross_suite/prefetch_completeness_checker.rb', line 17 def initialize(hook_request, request_index, services_file_path) @hook_request = hook_request @request_index = request_index @services_file_path = services_file_path @observed_fhirpath_collection_as_comma_delimited_string = false @instantiated_prefetch_templates = {} extract_prefetched_resources end |
Instance Attribute Details
#hook_request ⇒ Object
Returns the value of attribute hook_request.
13 14 15 |
# File 'lib/davinci_crd_test_kit/cross_suite/prefetch_completeness_checker.rb', line 13 def hook_request @hook_request end |
#instantiated_prefetch_templates ⇒ Object
Returns the value of attribute instantiated_prefetch_templates.
13 14 15 |
# File 'lib/davinci_crd_test_kit/cross_suite/prefetch_completeness_checker.rb', line 13 def instantiated_prefetch_templates @instantiated_prefetch_templates end |
#observed_fhirpath_collection_as_comma_delimited_string ⇒ Object
Returns the value of attribute observed_fhirpath_collection_as_comma_delimited_string.
13 14 15 |
# File 'lib/davinci_crd_test_kit/cross_suite/prefetch_completeness_checker.rb', line 13 def observed_fhirpath_collection_as_comma_delimited_string @observed_fhirpath_collection_as_comma_delimited_string end |
#request_index ⇒ Object
Returns the value of attribute request_index.
13 14 15 |
# File 'lib/davinci_crd_test_kit/cross_suite/prefetch_completeness_checker.rb', line 13 def request_index @request_index end |
#services_file_path ⇒ Object
Returns the value of attribute services_file_path.
13 14 15 |
# File 'lib/davinci_crd_test_kit/cross_suite/prefetch_completeness_checker.rb', line 13 def services_file_path @services_file_path end |
Instance Method Details
#check_prefetched_data ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/davinci_crd_test_kit/cross_suite/prefetch_completeness_checker.rb', line 26 def check_prefetched_data return ["#{request_error_prefix} No prefetch data provided."] unless hook_request.key?('prefetch') hook_prefetch_templates.each do |prefetch_key, prefetch_request| check_prefetch_template(prefetch_key, prefetch_request) end hook_request['prefetch'].each_key do |prefetch_template| next if hook_prefetch_templates.key?(prefetch_template) errors << "#{request_error_prefix} Extra prefetch data " \ "provided in unrequested template '#{prefetch_template}'." end errors.uniq end |
#data_set_different_with_alternate_service?(alternate_services_file_path, compare_key_map) ⇒ Boolean
Complete vs Subset Prefetch Difference Checking
47 48 49 50 |
# File 'lib/davinci_crd_test_kit/cross_suite/prefetch_completeness_checker.rb', line 47 def data_set_different_with_alternate_service?(alternate_services_file_path, compare_key_map) PrefetchCompletenessChecker.new(hook_request, request_index, alternate_services_file_path) .data_sets_different?(self, compare_key_map) end |
#data_sets_different?(original_service_checker, compare_key_map) ⇒ Boolean
Precondition: the original checker passed without errors meaning the expected set was present handles both subset < complete and complete > subset checks via two checks.
-
differences in the calculated id set for ‘_id` searches signal differences in the data sets.
-
errors during instantiation signal that a resource in the set wasn’t present. Since the original set was complete, this will only happen if the original set was a subset and the complete set includes more data, meaning that the sets are different. (NOTE: triggers an error rather than a different set of ids because fhirpath like ‘…resolve().id` requires the resource be present to evaluate it)
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/davinci_crd_test_kit/cross_suite/prefetch_completeness_checker.rb', line 59 def data_sets_different?(original_service_checker, compare_key_map) template_key_map = compare_key_map.transform_keys { |key| "%#{key}." }.transform_values { |value| "%#{value}." } hook_prefetch_templates.each do |prefetch_key, prefetch_request| data_set_different = data_set_different?(original_service_checker, compare_key_map, template_key_map, prefetch_key, prefetch_request) return true if data_set_different end false end |