Class: DaVinciPASTestKit::ClaimEndpoint

Inherits:
Inferno::DSL::SuiteEndpoint
  • Object
show all
Includes:
ClientURLs, FhirpathUtils, ResponseGenerator, ResponseSelectionUtils, SubscriptionsTestKit::SubscriptionsR5BackportR4Client::SubscriptionSimulationUtils
Defined in:
lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb

Constant Summary collapse

WORKFLOW_TAG_MAP =
{
  pended: PENDED_WORKFLOW_TAG,
  denial: DENIAL_WORKFLOW_TAG,
  approval: APPROVAL_WORKFLOW_TAG,
  operation_failure: OPERATION_FAILURE_WORKFLOW_TAG,
  processing_error: PROCESSING_ERROR_WORKFLOW_TAG,
  modification: MODIFICATION_WORKFLOW_TAG
}.freeze

Constants included from ResponseSelectionUtils

ResponseSelectionUtils::BUNDLE_KEY, ResponseSelectionUtils::CRITERIA_KEY, ResponseSelectionUtils::FHIRPATH_KEY, ResponseSelectionUtils::REQUEST_RANGE_KEY

Instance Method Summary collapse

Methods included from ResponseSelectionUtils

#bare_bundle?, #count_previous_successful_requests, #entity_bundle, #entity_criteria, #include_entity?, #ranges_cover_value?, #request_meets_inclusion_criteria?, #request_meets_request_range_criteria?

Methods included from FhirpathUtils

#calculate_expression_string_value, #execute_fhirpath, #fhirpath_evaluator, #interpret_fhirpath_result_as_boolean, #replace_tokens_in_string

Methods included from ClientURLs

#fhir_base_url, #fhir_subscription_url, #inquire_url, #registration_url, #session_fhir_base_url, #session_fhir_subscription_url, #session_inquire_url, #session_submit_url, #submit_url, #token_url, #udap_discovery_url

Methods included from BaseURLs

#base_url, #resume_fail_url, #resume_pass_url, #resume_skip_url

Methods included from ResponseGenerator

#mock_full_resource_notification_bundle, #mock_id_only_notification_bundle, #mock_response_bundle, #update_tester_provided_notification, #update_tester_provided_response

Methods included from ParametersHelper

#extract_bundles_from_pas_inquiry_response_parameters

Instance Method Details

#claim_update_request_tagObject

A unique tag set by each Claim Update wait test (via config option) so that verification tests can reload that specific submission by tag.



44
45
46
# File 'lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb', line 44

def claim_update_request_tag
  test.config.options[:claim_update_tag]
end

#ig_versionObject

Determines the IG version from the suite_id



148
149
150
# File 'lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb', line 148

def ig_version
  @ig_version ||= suite_id.include?('v221') ? 'v2.2.1' : 'v2.0.1'
end

#make_responseObject



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb', line 85

def make_response
  return if response.status == 401 # set in update_result (expired token handling there)

  response.format = :json

  # Handle the operation failure and processing error workflows, which require a user-provided response.
  if workflow == :operation_failure
    make_operation_failure_response
    return
  end

  if workflow == :processing_error
    make_processing_error_response
    return
  end

  response.status = 200

  req_bundle = FHIR.from_contents(request.body.string)
  claim_entry = req_bundle&.entry&.find { |e| e&.resource&.resourceType == 'Claim' }
  claim_full_url = claim_entry&.fullUrl
  if claim_entry.blank? || claim_full_url.blank?
    handle_missing_required_elements(claim_entry, response)
    return
  end

  user_inputted_response = resolve_user_response(req_bundle)
  if user_inputted_response.present?
    generated_claim_response_uuid = nil
    response_bundle_json = update_tester_provided_response(user_inputted_response, claim_full_url, operation,
                                                           ig_version)
  else
    decision = # always use the workflow, except for pended when the inquire will get approved
      if operation == 'inquire' && workflow == :pended
        :approval
      else
        workflow
      end
    generated_claim_response_uuid = SecureRandom.uuid
    response_bundle_json = mock_response_bundle(req_bundle, operation, decision, generated_claim_response_uuid,
                                                ig_version)
  end

  response.body = response_bundle_json

  # Claim Update wait tests must never trigger a Subscription notification,
  # even if the tester supplies a pended response body.
  return if suppress_notifications?
  return unless workflow == :pended && operation == 'submit'

  start_notification_job(response_bundle_json, :approval, generated_claim_response_uuid)
end

#must_support_workflow?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb', line 72

def must_support_workflow?
  test.id =~ /.*must_support.*/ || test.id =~ /.*gather_must_support.*/
end

#suite_idObject

override the one from URLs to make it version specific



19
20
21
# File 'lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb', line 19

def suite_id
  request.path.split('/custom/')[1].split('/')[0] # request.path = {base inferno path}/custom/{suite_id}/...
end

#suppress_notifications?Boolean

Claim Update wait tests set this so that Inferno never sends a Subscription notification in response to their submission, even when the configured response indicates the request was pended.

Returns:

  • (Boolean)


51
52
53
# File 'lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb', line 51

def suppress_notifications?
  test.config.options[:suppress_notifications] == true
end

#tagsObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb', line 31

def tags
  operation_tag = operation == 'submit' ? SUBMIT_TAG : INQUIRE_TAG
  workflow_tag = WORKFLOW_TAG_MAP[workflow]

  tag_list = [operation_tag]
  tag_list << workflow_tag if workflow_tag.present?
  tag_list << MUST_SUPPORT_WORKFLOW_TAG if must_support_workflow?
  tag_list << claim_update_request_tag if claim_update_request_tag.present?
  tag_list
end

#test_run_identifierObject



23
24
25
26
27
28
29
# File 'lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb', line 23

def test_run_identifier
  return request.params[:session_path] if request.params[:session_path].present?

  UDAPSecurityTestKit::MockUDAPServer.issued_token_to_client_id(
    request.headers['authorization']&.delete_prefix('Bearer ')
  )
end

#update_resultObject



138
139
140
141
142
143
144
145
# File 'lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb', line 138

def update_result
  if UDAPSecurityTestKit::MockUDAPServer.request_has_expired_token?(request)
    UDAPSecurityTestKit::MockUDAPServer.update_response_for_expired_token(response, 'Bearer token')
    return
  end

  results_repo.update_result(result.id, 'pass') unless test.config.options[:accepts_multiple_requests]
end

#workflowObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/davinci_pas_test_kit/client/endpoints/claim_endpoint.rb', line 55

def workflow
  case test.id
  when /.*pended.*/
    :pended
  when /.*denial.*/
    :denial
  when /.*approval.*/
    :approval
  when /.*operation_failure.*/
    :operation_failure
  when /.*processing_error.*/
    :processing_error
  when /.*modification.*/
    :modification
  end
end